From e7cf200489a86da1f453458670a81bc063e6e99c Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 9 Oct 2023 12:55:50 +0200 Subject: [PATCH 001/212] feat(287): parachain information discovery and channel opening automatic hrmp connection working Genesis instantiator usage and first draft of HRMP connection formatting feature propagation cleanup new node functioning. genesis not yet sure if working new node functioning. genesis not yet sure if working somehow compiling and test passing save save save feat(287): para_id setting extrinsic implemented and tested save same log crate across workspace same log crate across workspace save save save feat(287): changed tight couple of pallet_xcm by extracting sender trait feat(287): first commit feat(285): POC Hrmp automatic acceptance --- Cargo.lock | 418 +++----- Cargo.toml | 13 +- designs/ct_migration.puml | 24 + integration-tests/Cargo.toml | 37 +- integration-tests/src/constants.rs | 3 +- integration-tests/src/lib.rs | 4 +- integration-tests/src/tests/basic_comms.rs | 12 +- integration-tests/src/tests/hrmp_flow.rs | 64 ++ integration-tests/src/tests/mod.rs | 1 + .../src/tests/reserve_backed_transfers.rs | 5 +- nodes/parachain/Cargo.toml | 26 + nodes/parachain/src/chain_spec/testnet.rs | 297 +++++- nodes/parachain/src/command.rs | 2 + nodes/standalone/Cargo.toml | 17 + pallets/funding/Cargo.toml | 55 +- pallets/funding/src/functions.rs | 92 +- pallets/funding/src/impls.rs | 35 +- pallets/funding/src/instantiator.rs | 196 ++-- pallets/funding/src/lib.rs | 360 ++++++- pallets/funding/src/mock.rs | 2 +- pallets/funding/src/tests.rs | 78 +- pallets/funding/src/types.rs | 40 +- pallets/linear-release/Cargo.toml | 5 +- pallets/parachain-staking/Cargo.toml | 11 +- pallets/sandbox/Cargo.toml | 8 + pallets/xcm-executor/Cargo.toml | 47 + pallets/xcm-executor/src/config.rs | 121 +++ pallets/xcm-executor/src/lib.rs | 956 ++++++++++++++++++ runtimes/base/Cargo.toml | 12 +- runtimes/shared-configuration/Cargo.toml | 10 +- .../shared-configuration/src/governance.rs | 6 +- runtimes/standalone/Cargo.toml | 4 + runtimes/standalone/src/lib.rs | 5 +- runtimes/testnet/Cargo.toml | 19 + runtimes/testnet/src/lib.rs | 14 +- runtimes/testnet/src/xcm_config.rs | 52 +- rust-toolchain.toml | 2 +- .../zombienet/native/base-rococo-local.toml | 6 +- ...pless-rococo-statemint-polimec-penpal.toml | 56 + .../native/rococo-polimec-penpal.toml | 41 + traits/Cargo.toml | 7 +- 41 files changed, 2685 insertions(+), 478 deletions(-) create mode 100644 designs/ct_migration.puml create mode 100644 integration-tests/src/tests/hrmp_flow.rs create mode 100644 pallets/xcm-executor/Cargo.toml create mode 100644 pallets/xcm-executor/src/config.rs create mode 100644 pallets/xcm-executor/src/lib.rs create mode 100644 scripts/zombienet/native/hrmpless-rococo-statemint-polimec-penpal.toml create mode 100644 scripts/zombienet/native/rococo-polimec-penpal.toml diff --git a/Cargo.lock b/Cargo.lock index 3d3b7144c..e620bb686 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -161,8 +161,7 @@ dependencies = [ [[package]] name = "ahash" version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +source = "git+https://github.com/tkaitchuck/aHash?tag=v0.8.3#f9acd508bd89e7c5b2877a9510098100f9018d64" dependencies = [ "cfg-if", "getrandom 0.2.10", @@ -389,9 +388,9 @@ checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" [[package]] name = "assert_matches2" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af2f0d0b12ad8a519db313659cbd5e8757633f75d77ac5df1f8644f38f9c5946" +checksum = "6578e995f418897bfdebc40d6c873e5ce91effd67963c7991c2fb96779e53c18" [[package]] name = "assets-common" @@ -438,9 +437,9 @@ dependencies = [ "log", "parking", "polling", - "rustix 0.37.24", + "rustix 0.37.26", "slab", - "socket2 0.4.9", + "socket2 0.4.10", "waker-fn", ] @@ -466,9 +465,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.73" +version = "0.1.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" +checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", @@ -552,9 +551,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.4" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "base64ct" @@ -618,9 +617,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] name = "bitvec" @@ -1248,9 +1247,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "3fbc60abd742b35f2492f808e1abbb83d45f72db402e14c55057edc9c7b1e9e4" dependencies = [ "libc", ] @@ -2237,9 +2236,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.108" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "292b4841d939b20ba44fff686a35808b0ab31a3256e3629917d9aedd43eb7b3a" +checksum = "c390c123d671cc547244943ecad81bdaab756c6ea332d9ca9c1f48d952a24895" dependencies = [ "cc", "cxxbridge-flags", @@ -2249,9 +2248,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.108" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e7e35cf85fd4e90dcaba251f3ee95e08fb6f9d66e5c0588816f16a6ab939b40" +checksum = "00d3d3ac9ffb900304edf51ca719187c779f4001bb544f26c4511d621de905cf" dependencies = [ "cc", "codespan-reporting", @@ -2264,15 +2263,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.108" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7030aff1908ba2b7eb639466df50792b2a3fdf02bea9557c4ee1a531975554b" +checksum = "94415827ecfea0f0c74c8cad7d1a86ddb3f05354d6a6ddeda0adee5e875d2939" [[package]] name = "cxxbridge-macro" -version = "1.0.108" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79418ecb0c2322a7926a5fa5a9660535432b5b3588b947e1eb484cc509edbe3c" +checksum = "e33dbbe9f5621c9247f97ec14213b04f350bff4b6cebefe834c60055db266ecf" dependencies = [ "proc-macro2", "quote", @@ -2391,9 +2390,12 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2696e8a945f658fd14dc3b87242e6b80cd0f36ff04ea560fa39082368847946" +checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" +dependencies = [ + "powerfmt", +] [[package]] name = "derivative" @@ -2631,9 +2633,9 @@ dependencies = [ [[package]] name = "ed25519" -version = "2.2.2" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60f6d271ca33075c88028be6f04d502853d63a5ece419d269c15315d4fc1cf1d" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ "pkcs8 0.10.2", "signature 2.1.0", @@ -2658,7 +2660,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" dependencies = [ "curve25519-dalek 4.1.1", - "ed25519 2.2.2", + "ed25519 2.2.3", "rand_core 0.6.4", "serde", "sha2 0.10.8", @@ -3033,9 +3035,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.27" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ "crc32fast", "libz-sys", @@ -3379,7 +3381,7 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" dependencies = [ - "rustix 0.38.18", + "rustix 0.38.20", "windows-sys 0.48.0", ] @@ -3724,9 +3726,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.1" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" [[package]] name = "heck" @@ -3899,7 +3901,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite 0.2.13", - "socket2 0.4.9", + "socket2 0.4.10", "tokio", "tower-service", "tracing", @@ -3940,16 +3942,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.57" +version = "0.1.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows 0.48.0", + "windows-core", ] [[package]] @@ -4000,9 +4002,9 @@ dependencies = [ [[package]] name = "if-watch" -version = "3.0.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9465340214b296cd17a0009acdb890d6160010b8adf8f78a00d0d7ab270f79f" +checksum = "bbb892e5777fe09e16f3d44de7802f4daa7267ecbe8c466f19d94e25bb0c303e" dependencies = [ "async-io", "core-foundation", @@ -4014,7 +4016,7 @@ dependencies = [ "rtnetlink", "system-configuration", "tokio", - "windows 0.34.0", + "windows", ] [[package]] @@ -4064,7 +4066,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" dependencies = [ "equivalent", - "hashbrown 0.14.1", + "hashbrown 0.14.2", ] [[package]] @@ -4199,7 +4201,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" dependencies = [ - "socket2 0.5.4", + "socket2 0.5.5", "widestring", "windows-sys 0.48.0", "winreg", @@ -4207,9 +4209,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" @@ -4218,7 +4220,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi 0.3.3", - "rustix 0.38.18", + "rustix 0.38.20", "windows-sys 0.48.0", ] @@ -4793,7 +4795,7 @@ dependencies = [ "log", "rand 0.8.5", "smallvec", - "socket2 0.4.9", + "socket2 0.4.10", "tokio", "trust-dns-proto", "void", @@ -4935,7 +4937,7 @@ dependencies = [ "libc", "libp2p-core", "log", - "socket2 0.4.9", + "socket2 0.4.10", "tokio", ] @@ -5162,9 +5164,9 @@ checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -5300,7 +5302,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.38.18", + "rustix 0.38.20", ] [[package]] @@ -5394,9 +5396,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", "wasi 0.11.0+wasi-snapshot-preview1", @@ -6280,14 +6282,20 @@ dependencies = [ "frame-support", "frame-system", "itertools 0.11.0", + "log", "pallet-assets", "pallet-balances", "pallet-insecure-randomness-collective-flip", "pallet-linear-release", "pallet-timestamp", + "pallet-xcm", "parachains-common", "parity-scale-codec", "polimec-traits", + "polimec-xcm-executor", + "polkadot-parachain", + "polkadot-runtime", + "polkadot-runtime-parachains", "scale-info", "serde", "sp-arithmetic", @@ -6295,6 +6303,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", + "xcm", "xcm-builder", ] @@ -7135,9 +7144,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab512a34b3c2c5e465731cc7668edf79208bbe520be03484eeb05e63ed221735" +checksum = "59e9ab494af9e6e813c72170f0d3c1de1500990d62c97cc05cc7576f91aa402f" dependencies = [ "blake2", "crc32fast", @@ -7194,9 +7203,9 @@ checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" [[package]] name = "parking" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e52c774a4c39359c1d1c52e43f73dd91a75a614652c825408eec30c95a9b2067" +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" [[package]] name = "parking_lot" @@ -7216,7 +7225,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", - "parking_lot_core 0.9.8", + "parking_lot_core 0.9.9", ] [[package]] @@ -7235,13 +7244,13 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.8" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.3.5", + "redox_syscall 0.4.1", "smallvec", "windows-targets 0.48.5", ] @@ -7699,6 +7708,7 @@ dependencies = [ "parachain-info", "parachains-common", "parity-scale-codec", + "polimec-xcm-executor", "polkadot-parachain", "polkadot-primitives", "polkadot-runtime-common", @@ -7725,117 +7735,39 @@ dependencies = [ ] [[package]] -name = "polimec-standalone-node" -version = "0.1.0" -dependencies = [ - "clap", - "frame-benchmarking", - "frame-benchmarking-cli", - "frame-system", - "futures", - "jsonrpsee", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc", - "polimec-standalone-runtime", - "sc-basic-authorship", - "sc-chain-spec", - "sc-cli", - "sc-client-api", - "sc-consensus", - "sc-consensus-aura", - "sc-consensus-grandpa", - "sc-executor", - "sc-keystore", - "sc-network", - "sc-rpc", - "sc-rpc-api", - "sc-service", - "sc-telemetry", - "sc-transaction-pool", - "sc-transaction-pool-api", - "serde", - "sp-api", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-consensus-aura", - "sp-consensus-grandpa", - "sp-core", - "sp-inherents", - "sp-io", - "sp-keyring", - "sp-runtime", - "sp-timestamp", - "substrate-build-script-utils", - "substrate-frame-rpc-system", - "try-runtime-cli", -] - -[[package]] -name = "polimec-standalone-runtime" +name = "polimec-traits" version = "0.1.0" dependencies = [ "frame-benchmarking", - "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal 0.3.4", - "pallet-assets", - "pallet-aura", - "pallet-authorship", - "pallet-balances", - "pallet-collective", - "pallet-democracy", - "pallet-funding", - "pallet-grandpa", - "pallet-insecure-randomness-collective-flip", - "pallet-linear-release", - "pallet-multisig", - "pallet-scheduler", - "pallet-session", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-treasury", - "pallet-utility", - "pallet-vesting", "parity-scale-codec", "scale-info", - "shared-configuration", - "sp-api", - "sp-block-builder", - "sp-consensus-aura", - "sp-consensus-grandpa", + "serde", "sp-core", - "sp-inherents", - "sp-offchain", + "sp-io", "sp-runtime", - "sp-session", "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", - "xcm-builder", ] [[package]] -name = "polimec-traits" +name = "polimec-xcm-executor" version = "0.1.0" dependencies = [ + "environmental", "frame-benchmarking", "frame-support", - "frame-system", + "impl-trait-for-tuples", + "log", "parity-scale-codec", - "scale-info", - "serde", + "sp-arithmetic", "sp-core", "sp-io", "sp-runtime", "sp-std", + "sp-weights", + "xcm", + "xcm-executor", ] [[package]] @@ -9181,6 +9113,12 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b" +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -9641,6 +9579,15 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + [[package]] name = "redox_users" version = "0.4.3" @@ -9699,14 +9646,14 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.0" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d119d7c7ca818f8a53c300863d4f87566aac09943aef5b355bb83969dae75d87" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.1", - "regex-syntax 0.8.1", + "regex-automata 0.4.3", + "regex-syntax 0.8.2", ] [[package]] @@ -9720,13 +9667,13 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465c6fc0621e4abc4187a2bda0937bfd4f722c2730b29562e19689ea796c9a4b" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", - "regex-syntax 0.8.1", + "regex-syntax 0.8.2", ] [[package]] @@ -9737,9 +9684,9 @@ checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] name = "regex-syntax" -version = "0.8.1" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56d84fdd47036b038fc80dd333d10b6aab10d5d31f4a366e20014def75328d33" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "resolv-conf" @@ -9789,9 +9736,9 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.3" +version = "0.17.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babe80d5c16becf6594aa32ad2be8fe08498e7ae60b77de8df700e67f191d7e" +checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" dependencies = [ "cc", "getrandom 0.2.10", @@ -10020,9 +9967,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.15" +version = "0.36.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c37f1bd5ef1b5422177b7646cba67430579cfe2ace80f284fee876bca52ad941" +checksum = "6da3636faa25820d8648e0e31c5d519bbb01f72fdf57131f0f5f7da5fed36eab" dependencies = [ "bitflags 1.3.2", "errno", @@ -10034,9 +9981,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.24" +version = "0.37.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4279d76516df406a8bd37e7dff53fd37d1a093f997a3c34a5c21658c126db06d" +checksum = "84f3f8f960ed3b5a59055428714943298bf3fa2d4a1d53135084e0544829d995" dependencies = [ "bitflags 1.3.2", "errno", @@ -10048,11 +9995,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.18" +version = "0.38.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a74ee2d7c2581cd139b42447d7d9389b889bdaad3a73f1ebb16f2a3237bb19c" +checksum = "67ce50cb2e16c2903e30d1cbccfd8387a74b9d4c938b6a4c5ec6cc7556f7a8a0" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "errno", "libc", "linux-raw-sys 0.4.10", @@ -10114,7 +10061,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", ] [[package]] @@ -10695,7 +10642,7 @@ dependencies = [ "libc", "log", "once_cell", - "rustix 0.36.15", + "rustix 0.36.16", "sc-allocator", "sc-executor-common", "sp-runtime-interface", @@ -11321,9 +11268,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" +checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" dependencies = [ "bitvec", "cfg-if", @@ -11335,9 +11282,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" +checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -11540,18 +11487,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" dependencies = [ "proc-macro2", "quote", @@ -11811,9 +11758,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" dependencies = [ "libc", "winapi", @@ -11821,9 +11768,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", "windows-sys 0.48.0", @@ -12996,9 +12943,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.11" +version = "0.12.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" +checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a" [[package]] name = "tempfile" @@ -13009,7 +12956,7 @@ dependencies = [ "cfg-if", "fastrand 2.0.1", "redox_syscall 0.3.5", - "rustix 0.38.18", + "rustix 0.38.20", "windows-sys 0.48.0", ] @@ -13044,18 +12991,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", @@ -13123,12 +13070,13 @@ dependencies = [ [[package]] name = "time" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "426f806f4089c493dcac0d24c29c01e2c38baf8e30f1b716ee37e83d200b18fe" +checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" dependencies = [ "deranged", "itoa", + "powerfmt", "serde", "time-core", "time-macros", @@ -13207,7 +13155,7 @@ dependencies = [ "parking_lot 0.12.1", "pin-project-lite 0.2.13", "signal-hook-registry", - "socket2 0.5.4", + "socket2 0.5.5", "tokio-macros", "windows-sys 0.48.0", ] @@ -13342,7 +13290,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "bytes", "futures-core", "futures-util", @@ -13368,11 +13316,10 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if", "log", "pin-project-lite 0.2.13", "tracing-attributes", @@ -13381,9 +13328,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", @@ -13392,9 +13339,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", "valuable", @@ -13517,7 +13464,7 @@ dependencies = [ "lazy_static", "rand 0.8.5", "smallvec", - "socket2 0.4.9", + "socket2 0.4.10", "thiserror", "tinyvec", "tokio", @@ -13760,9 +13707,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" +checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" dependencies = [ "getrandom 0.2.10", ] @@ -14054,12 +14001,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c86437fa68626fe896e5afc69234bb2b5894949083586535f200385adfd71213" dependencies = [ "anyhow", - "base64 0.21.4", + "base64 0.21.5", "bincode", "directories-next", "file-per-thread-logger", "log", - "rustix 0.36.15", + "rustix 0.36.16", "serde", "sha2 0.10.8", "toml 0.5.11", @@ -14155,7 +14102,7 @@ checksum = "6e0554b84c15a27d76281d06838aed94e13a77d7bf604bbbaf548aa20eb93846" dependencies = [ "object 0.30.4", "once_cell", - "rustix 0.36.15", + "rustix 0.36.16", ] [[package]] @@ -14186,7 +14133,7 @@ dependencies = [ "memoffset 0.8.0", "paste", "rand 0.8.5", - "rustix 0.36.15", + "rustix 0.36.16", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", @@ -14231,7 +14178,7 @@ version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" dependencies = [ - "ring 0.17.3", + "ring 0.17.5", "untrusted 0.9.0", ] @@ -14386,7 +14333,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f08dfd7a6e3987e255c4dbe710dde5d94d0f0574f8a21afa95d171376c143106" dependencies = [ "log", - "socket2 0.4.9", + "socket2 0.4.10", "thiserror", "tokio", "webrtc-util", @@ -14583,14 +14530,14 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.18", + "rustix 0.38.20", ] [[package]] name = "wide" -version = "0.7.12" +version = "0.7.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebecebefc38ff1860b4bc47550bbfa63af5746061cf0d29fcd7fa63171602598" +checksum = "c68938b57b33da363195412cfc5fc37c9ed49aa9cfe2156fde64b8d2c9498242" dependencies = [ "bytemuck", "safe_arch", @@ -14635,22 +14582,19 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.34.0" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45296b64204227616fdbf2614cefa4c236b98ee64dfaaaa435207ed99fe7829f" +checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" dependencies = [ - "windows_aarch64_msvc 0.34.0", - "windows_i686_gnu 0.34.0", - "windows_i686_msvc 0.34.0", - "windows_x86_64_gnu 0.34.0", - "windows_x86_64_msvc 0.34.0", + "windows-core", + "windows-targets 0.48.5", ] [[package]] -name = "windows" -version = "0.48.0" +name = "windows-core" +version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ "windows-targets 0.48.5", ] @@ -14715,12 +14659,6 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" -[[package]] -name = "windows_aarch64_msvc" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17cffbe740121affb56fad0fc0e421804adf0ae00891205213b5cecd30db881d" - [[package]] name = "windows_aarch64_msvc" version = "0.42.2" @@ -14733,12 +14671,6 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" -[[package]] -name = "windows_i686_gnu" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2564fde759adb79129d9b4f54be42b32c89970c18ebf93124ca8870a498688ed" - [[package]] name = "windows_i686_gnu" version = "0.42.2" @@ -14751,12 +14683,6 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" -[[package]] -name = "windows_i686_msvc" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cd9d32ba70453522332c14d38814bceeb747d80b3958676007acadd7e166956" - [[package]] name = "windows_i686_msvc" version = "0.42.2" @@ -14769,12 +14695,6 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" -[[package]] -name = "windows_x86_64_gnu" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfce6deae227ee8d356d19effc141a509cc503dfd1f850622ec4b0f84428e1f4" - [[package]] name = "windows_x86_64_gnu" version = "0.42.2" @@ -14799,12 +14719,6 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" -[[package]] -name = "windows_x86_64_msvc" -version = "0.34.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d19538ccc21819d01deaf88d6a17eae6596a12e9aafdbb97916fb49896d89de9" - [[package]] name = "windows_x86_64_msvc" version = "0.42.2" @@ -14819,9 +14733,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.16" +version = "0.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037711d82167854aff2018dfd193aa0fef5370f456732f0d5a0c59b0f1b4b907" +checksum = "a3b801d0e0a6726477cc207f60162da452f3a95adb368399bef20a946e06f65c" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 3d055bee3..f4188439e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,10 @@ [workspace] members = [ - "nodes/*", +# "nodes/*", +# "runtimes/*", + "nodes/parachain", + "runtimes/testnet", "pallets/*", - "runtimes/*", "integration-tests", "traits", ] @@ -54,6 +56,7 @@ pallet-funding = { path = "pallets/funding", default-features = false } pallet-sandbox = { path = "pallets/sandbox", default-features = false } pallet-parachain-staking = { path = "pallets/parachain-staking", default-features = false } pallet-linear-release = { path = "pallets/linear-release", default-features = false } +polimec-xcm-executor = { path = "pallets/xcm-executor", default-features = false} # Internal support (with default disabled) shared-configuration = { path = "runtimes/shared-configuration", default-features = false } @@ -73,7 +76,7 @@ jsonrpsee = { version = "0.16.3", features = ["server"] } hex-literal = "0.3.4" serde = { version = "1.0.188", default-features = false } smallvec = "1.11.0" -log = "0.4.20" +log = { version = "0.4.17", default-features = false } # Emulations xcm-emulator = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "release-v0.9.430" } @@ -108,6 +111,7 @@ pallet-im-online = { default-features = false, git = "https://github.com/parityt sp-authority-discovery = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } sp-consensus-babe = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } pallet-message-queue = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } +sp-weights = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" } # FRAME pallet-aura = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } @@ -213,3 +217,6 @@ polimec-parachain-runtime = { path = "runtimes/testnet" } polimec-standalone-runtime = { path = "runtimes/standalone" } polimec-base-runtime = { path = "runtimes/base" } penpal-runtime = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "release-v0.9.430" } + +[patch.crates-io] +ahash = {git = "https://github.com/tkaitchuck/aHash", tag = "v0.8.3"} \ No newline at end of file diff --git a/designs/ct_migration.puml b/designs/ct_migration.puml new file mode 100644 index 000000000..3cbd38eec --- /dev/null +++ b/designs/ct_migration.puml @@ -0,0 +1,24 @@ +@startuml +Issuer -> "Galaxy": Add Polimec receiver pallet + +Issuer -> "Galaxy": Sudo - HRMP channel request +Galaxy --> Relay: Init open channel to Polimec + +Galaxy -> Polimec: Specify Galaxy chain spec (paraId) and notify about HRMP request on relay +Polimec --> Relay: Accept HRMP request + +Polimec -> Relay: Init open channel to Galaxy +Issuer --> "Galaxy": Sudo - HRMP channel accept +Galaxy --> Relay: Accept HRMP request + +Issuer -> Polimec: Start migration availability check +Polimec --> Galaxy: query receiver pallet exists and is correct & there are enough funds on Polimec sovereign account +Galaxy --> Polimec: Confirmation +Polimec --> Issuer: Migration ready + +Issuer -> Polimec: Start migration +loop for every CT holder + Polimec --> Galaxy: Tell receiver pallet: account, amount, vesting info + Galaxy --> Galaxy: Start CT Vesting for that user +end +@enduml diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 82a73492b..a5f1f1525 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -5,6 +5,7 @@ documentation.workspace = true edition.workspace = true homepage.workspace = true license-file.workspace = true + readme.workspace = true repository.workspace = true version.workspace = true @@ -87,11 +88,43 @@ std = [ "cumulus-pallet-xcm/std", "cumulus-primitives-core/std", "parity-scale-codec/std", - "scale-info/std" + "scale-info/std", + "cumulus-pallet-xcmp-queue/std", + "pallet-funding/std", + "pallet-im-online/std", + "pallet-message-queue/std", + "pallet-staking/std", + "parachains-common/std", + "polkadot-primitives/std", + "polkadot-runtime-constants/std", + "sp-authority-discovery/std", + "sp-consensus-babe/std" ] runtime-benchmarks = [ "statemint-runtime/runtime-benchmarks", "penpal-runtime/runtime-benchmarks", - "polimec-parachain-runtime/runtime-benchmarks" + "polimec-parachain-runtime/runtime-benchmarks", + "cumulus-pallet-xcmp-queue/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "pallet-assets/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-funding/runtime-benchmarks", + "pallet-im-online/runtime-benchmarks", + "pallet-message-queue/runtime-benchmarks", + "pallet-staking/runtime-benchmarks", + "pallet-xcm/runtime-benchmarks", + "polkadot-parachain/runtime-benchmarks", + "polkadot-primitives/runtime-benchmarks", + "polkadot-runtime/runtime-benchmarks", + "polkadot-runtime-parachains/runtime-benchmarks", + "polkadot-service/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "xcm-builder/runtime-benchmarks", + "xcm-executor/runtime-benchmarks" +] +testing-node = [ + "pallet-funding/testing-node", + "polimec-parachain-runtime/testing-node" ] diff --git a/integration-tests/src/constants.rs b/integration-tests/src/constants.rs index 39d2ce3b0..cfefd6c04 100644 --- a/integration-tests/src/constants.rs +++ b/integration-tests/src/constants.rs @@ -250,6 +250,7 @@ pub mod polimec { .expect("WASM binary was not build, please build it!") .to_vec(), }, + polimec_funding: Default::default(), balances: polimec_parachain_runtime::BalancesConfig { balances: funded_accounts }, parachain_info: polimec_parachain_runtime::ParachainInfoConfig { parachain_id: PARA_ID.into() }, session: polimec_parachain_runtime::SessionConfig { @@ -287,7 +288,7 @@ pub mod polimec { }, technical_committee: Default::default(), treasury: Default::default(), - vesting: Default::default(), + linear_vesting: Default::default(), }; genesis_config.build_storage().unwrap() diff --git a/integration-tests/src/lib.rs b/integration-tests/src/lib.rs index 220e9a87d..995eccb47 100644 --- a/integration-tests/src/lib.rs +++ b/integration-tests/src/lib.rs @@ -18,7 +18,7 @@ pub mod constants; #[cfg(test)] mod tests; -pub use constants::{accounts, penpal, polimec, polkadot, statemint}; +pub use constants::{accounts::*, penpal, polimec, polkadot, statemint}; pub use frame_support::{assert_ok, pallet_prelude::Weight, parameter_types, sp_io, sp_tracing}; pub use parachains_common::{AccountId, AuraId, Balance, BlockNumber, StatemintAuraId}; pub use sp_core::{sr25519, storage::Storage, Encode, Get}; @@ -182,4 +182,4 @@ pub mod shortcuts { pub type PenpalSystem = ::System; pub type StatemintSystem = ::System; } -use shortcuts::*; \ No newline at end of file +pub use shortcuts::*; diff --git a/integration-tests/src/tests/basic_comms.rs b/integration-tests/src/tests/basic_comms.rs index 1318d34b6..dcf40cf1b 100644 --- a/integration-tests/src/tests/basic_comms.rs +++ b/integration-tests/src/tests/basic_comms.rs @@ -2,12 +2,9 @@ use crate::*; const MAX_REF_TIME: u64 = 300_000_000; const MAX_PROOF_SIZE: u64 = 10_000; -pub const REF_TIME_THRESHOLD: u64 = 33; -pub const PROOF_SIZE_THRESHOLD: u64 = 33; #[test] fn dmp() { - let para_ids = PolkadotNet::_para_ids(); let remark = PolimecCall::System(frame_system::Call::::remark_with_event { remark: "Hello from Polkadot!".as_bytes().to_vec(), }); @@ -34,8 +31,6 @@ fn dmp() { }); Polimec::execute_with(|| { - let events = ::System::events(); - assert_expected_events!( Polimec, vec![ @@ -74,15 +69,13 @@ fn ump() { }); PolkadotRelay::execute_with(|| { - let events = PolkadotSystem::events(); - let para_id: ParaId = Polimec::para_id().into(); assert_expected_events!( PolkadotRelay, vec![ PolkadotEvent::MessageQueue(pallet_message_queue::Event::Processed { id: _, origin: AggregateMessageOrigin::Ump( - UmpQueueId::Para(para_id) + UmpQueueId::Para(_para_id) ), weight_used: _, success: false @@ -94,9 +87,6 @@ fn ump() { #[test] fn xcmp() { - use frame_support::traits::fungible::Inspect; - use xcm::v3::SendXcm; - let burn_transfer = PolimecCall::Balances(pallet_balances::Call::::transfer { dest: PolimecAccountId::from([0u8; 32]).into(), value: 1_000, diff --git a/integration-tests/src/tests/hrmp_flow.rs b/integration-tests/src/tests/hrmp_flow.rs new file mode 100644 index 000000000..5d738b009 --- /dev/null +++ b/integration-tests/src/tests/hrmp_flow.rs @@ -0,0 +1,64 @@ +// use crate::*; + +// const MAX_REF_TIME: u64 = 700_000_000; +// const MAX_PROOF_SIZE: u64 = 10_000; +// pub const REF_TIME_THRESHOLD: u64 = 33; +// pub const PROOF_SIZE_THRESHOLD: u64 = 33; + +// use polkadot_runtime_parachains::{hrmp as parachain_hrmp, origin as parachains_origin, paras as parachains_paras}; + +// #[test] +// fn hrmp_notification() { +// let max_weight = Weight::from_parts(MAX_REF_TIME, MAX_PROOF_SIZE); +// let execution_dot: MultiAsset = (MultiLocation { parents: 0, interior: Here }, 1_0_000_000_000u128).into(); +// let call = polkadot_runtime::RuntimeCall::Hrmp(parachain_hrmp::Call::::hrmp_init_open_channel{ +// recipient: Polimec::para_id(), +// proposed_max_capacity: 1024, +// proposed_max_message_size: 1024 * 1024, +// }); +// // let hrmp_init_open_call = parachain_hrmp::Call::::hrmp_init_open_channel{ +// // recipient: Polimec::para_id(), +// // proposed_max_capacity: 1024, +// // proposed_max_message_size: 1024 * 1024, +// // }; +// let encoded_call = call.encode(); + +// PolkadotRelay::execute_with(||{ +// let x = parachains_paras::ParaLifecycles::::iter(); +// let y = 10; +// }); + +// let xcm = VersionedXcm::from(Xcm(vec![ +// WithdrawAsset(vec![execution_dot.clone()].into()), +// BuyExecution { fees: execution_dot.clone(), weight_limit: Unlimited }, +// Transact { origin_kind: OriginKind::Native, require_weight_at_most: max_weight, call: encoded_call.into() }, +// RefundSurplus, +// DepositAsset { +// assets: Wild(All), +// beneficiary: MultiLocation { +// parents: 0, +// interior: X1(Parachain(Penpal::para_id().into())), +// }, +// }, +// ])); + +// let penpal_sov_acc = PolkadotRelay::sovereign_account_id_of(Parachain(Penpal::para_id().into()).into()); +// PolkadotRelay::fund_accounts(vec![(penpal_sov_acc, 100_0_000_000_000u128)]); + +// Penpal::execute_with(|| { +// assert_ok!(PenpalXcmPallet::send(PenpalOrigin::root(), bx!(Penpal::parent_location().into()), bx!(xcm),)); +// println!("penpal events:"); +// dbg!(Penpal::events()) +// }); + +// PolkadotRelay::execute_with(|| { +// println!("polkadot events:"); +// dbg!(PolkadotRelay::events()); +// }); + +// Polimec::execute_with(|| { +// println!("polimec events:"); +// dbg!(Polimec::events()); +// }); + +// } diff --git a/integration-tests/src/tests/mod.rs b/integration-tests/src/tests/mod.rs index 06a3fb574..065a64bff 100644 --- a/integration-tests/src/tests/mod.rs +++ b/integration-tests/src/tests/mod.rs @@ -1,2 +1,3 @@ mod basic_comms; +mod hrmp_flow; mod reserve_backed_transfers; diff --git a/integration-tests/src/tests/reserve_backed_transfers.rs b/integration-tests/src/tests/reserve_backed_transfers.rs index 6fda2b7fb..a30709c28 100644 --- a/integration-tests/src/tests/reserve_backed_transfers.rs +++ b/integration-tests/src/tests/reserve_backed_transfers.rs @@ -6,13 +6,10 @@ use frame_support::{ }, weights::WeightToFee, }; -use pallet_balances::Instance1; -use pallet_funding::{types::AcceptedFundingAsset, PLMC_STATEMINT_ID}; -use sp_runtime::traits::Zero; +use pallet_funding::types::AcceptedFundingAsset; const RESERVE_TRANSFER_AMOUNT: u128 = 10_0_000_000_000; // 10 DOT const MAX_REF_TIME: u64 = 5_000_000_000; const MAX_PROOF_SIZE: u64 = 200_000; -use accounts::{ALICE, BOB, FERDIE}; fn create_usdt_on_statemint() { let usdt_admin_account = Statemint::account_id_of(FERDIE); diff --git a/nodes/parachain/Cargo.toml b/nodes/parachain/Cargo.toml index 92d9ee506..87a4b3626 100644 --- a/nodes/parachain/Cargo.toml +++ b/nodes/parachain/Cargo.toml @@ -95,6 +95,7 @@ runtime-benchmarks = [ "polkadot-service/runtime-benchmarks", "sc-service/runtime-benchmarks", "sp-runtime/runtime-benchmarks", + "pallet-funding/runtime-benchmarks" ] try-runtime = [ "polimec-base-runtime/try-runtime", @@ -106,3 +107,28 @@ try-runtime = [ "try-runtime-cli?/try-runtime", ] fast-gov = [ "polimec-parachain-runtime/fast-gov" ] +std = [ + "cumulus-primitives-core/std", + "frame-benchmarking/std", + "log/std", + "pallet-funding/std", + "parachains-common/std", + "parity-scale-codec/std", + "polkadot-primitives/std", + "serde/std", + "sp-api/std", + "sp-block-builder/std", + "sp-consensus-aura/std", + "sp-core/std", + "sp-io/std", + "sp-offchain/std", + "sp-runtime/std", + "sp-session/std", + "sp-transaction-pool/std", + "xcm/std" +] +testing-node = [ + "pallet-funding/testing-node", + "polimec-parachain-runtime/testing-node", + "polimec-base-runtime/testing-node" +] diff --git a/nodes/parachain/src/chain_spec/testnet.rs b/nodes/parachain/src/chain_spec/testnet.rs index c9ffb605f..9f87f1040 100644 --- a/nodes/parachain/src/chain_spec/testnet.rs +++ b/nodes/parachain/src/chain_spec/testnet.rs @@ -24,9 +24,9 @@ use polimec_parachain_runtime::{ inflation::{perbill_annual_to_perbill_round, BLOCKS_PER_YEAR}, InflationInfo, Range, }, - AccountId, AuraId as AuthorityId, Balance, BalancesConfig, CouncilConfig, GenesisConfig, MinCandidateStk, - ParachainInfoConfig, ParachainStakingConfig, PolkadotXcmConfig, Runtime, SessionConfig, StatemintAssetsConfig, - SudoConfig, SystemConfig, TechnicalCommitteeConfig, VestingConfig, EXISTENTIAL_DEPOSIT, PLMC, + AccountId, AuraId as AuthorityId, Balance, BalancesConfig, CouncilConfig, GenesisConfig, LinearVestingConfig, + MinCandidateStk, ParachainInfoConfig, ParachainStakingConfig, PolkadotXcmConfig, Runtime, SessionConfig, + StatemintAssetsConfig, SudoConfig, SystemConfig, TechnicalCommitteeConfig, EXISTENTIAL_DEPOSIT, PLMC, }; use sc_service::ChainType; use sp_core::{crypto::UncheckedInto, sr25519}; @@ -70,6 +70,48 @@ pub fn get_testnet_session_keys(keys: AuthorityId) -> polimec_parachain_runtime: polimec_parachain_runtime::SessionKeys { aura: keys } } +#[cfg(all(feature = "testing-node", feature = "std"))] +pub fn get_chain_spec_testing() -> Result { + let properties = get_properties("PLMC", 10, 41); + let wasm = polimec_parachain_runtime::WASM_BINARY.ok_or("No WASM")?; + + Ok(ChainSpec::from_genesis( + "Polimec Develop", + "polimec", + ChainType::Local, + move || { + testing_genesis( + wasm, + vec![ + (get_account_id_from_seed::("Alice"), None, 2 * MinCandidateStk::get()), + (get_account_id_from_seed::("Bob"), None, 2 * MinCandidateStk::get()), + ], + polimec_inflation_config(), + vec![ + get_account_id_from_seed::("Alice"), + get_account_id_from_seed::("Bob"), + ], + vec![ + (get_account_id_from_seed::("Alice"), 5 * MinCandidateStk::get()), + (get_account_id_from_seed::("Bob"), 5 * MinCandidateStk::get()), + (get_account_id_from_seed::("Charlie"), 5 * MinCandidateStk::get()), + (get_account_id_from_seed::("Dave"), 5 * MinCandidateStk::get()), + (get_account_id_from_seed::("Eve"), 5 * MinCandidateStk::get()), + (get_account_id_from_seed::("Ferdie"), 5 * MinCandidateStk::get()), + ], + get_account_id_from_seed::("Alice"), + DEFAULT_PARA_ID, + ) + }, + vec![], + None, + None, + None, + Some(properties), + Extensions { relay_chain: "rococo-local".into(), para_id: DEFAULT_PARA_ID.into() }, + )) +} + pub fn get_chain_spec_dev() -> Result { let properties = get_properties("PLMC", 10, 41); let wasm = polimec_parachain_runtime::WASM_BINARY.ok_or("No WASM")?; @@ -170,6 +212,253 @@ fn testnet_genesis( .push((::PalletId::get().into_account_truncating(), EXISTENTIAL_DEPOSIT)); GenesisConfig { system: SystemConfig { code: wasm_binary.to_vec() }, + polimec_funding: Default::default(), + balances: BalancesConfig { balances: endowed_accounts.clone() }, + statemint_assets: StatemintAssetsConfig { + assets: vec![( + pallet_funding::types::AcceptedFundingAsset::USDT.to_statemint_id(), + ::PalletId::get().into_account_truncating(), + false, + 10, + )], + metadata: vec![], + accounts: vec![], + }, + parachain_info: ParachainInfoConfig { parachain_id: id }, + parachain_staking: ParachainStakingConfig { + candidates: stakers + .iter() + .map(|(accunt, _, balance)| (accunt.clone(), balance.clone())) + .collect::>(), + inflation_config, + delegations: vec![], + collator_commission: COLLATOR_COMMISSION, + parachain_bond_reserve_percent: PARACHAIN_BOND_RESERVE_PERCENT, + blocks_per_round: BLOCKS_PER_ROUND, + num_selected_candidates: NUM_SELECTED_CANDIDATES, + }, + // no need to pass anything to aura, in fact it will panic if we do. Session will take care + // of this. + aura: Default::default(), + aura_ext: Default::default(), + parachain_system: Default::default(), + session: SessionConfig { + keys: initial_authorities + .iter() + .map(|acc| { + ( + acc.clone(), + acc.clone(), + get_testnet_session_keys(Into::<[u8; 32]>::into(acc.clone()).unchecked_into()), + ) + }) + .collect::>(), + }, + polkadot_xcm: PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION) }, + treasury: Default::default(), + sudo: SudoConfig { key: Some(sudo_account) }, + council: CouncilConfig { members: accounts.clone(), phantom: Default::default() }, + technical_committee: TechnicalCommitteeConfig { members: accounts.clone(), phantom: Default::default() }, + democracy: Default::default(), + linear_vesting: LinearVestingConfig { vesting: vec![] }, + } +} + +#[cfg(all(feature = "testing-node", feature = "std"))] +use pallet_funding::{instantiator::UserToUSDBalance, *}; +#[cfg(all(feature = "testing-node", feature = "std"))] +use sp_runtime::BoundedVec; + +#[cfg(all(feature = "testing-node", feature = "std"))] +mod testing_helpers { + use super::*; + use polimec_parachain_runtime::AccountId; + use sp_core::H256; + use sp_runtime::traits::ConstU32; + pub const METADATA: &str = r#"METADATA + { + "whitepaper":"ipfs_url", + "team_description":"ipfs_url", + "tokenomics":"ipfs_url", + "roadmap":"ipfs_url", + "usage_of_founds":"ipfs_url" + }"#; + pub const ASSET_DECIMALS: u8 = 10; + pub const ASSET_UNIT: u128 = 10_u128.pow(10 as u32); + + pub fn issuer() -> AccountId { + get_account_id_from_seed::("issuer") + } + pub fn eval_1() -> AccountId { + get_account_id_from_seed::("eval_1") + } + pub fn eval_2() -> AccountId { + get_account_id_from_seed::("eval_2") + } + pub fn eval_3() -> AccountId { + get_account_id_from_seed::("eval_3") + } + pub fn bidder_1() -> AccountId { + get_account_id_from_seed::("bidder_1") + } + pub fn bidder_2() -> AccountId { + get_account_id_from_seed::("bidder_2") + } + pub fn bidder_3() -> AccountId { + get_account_id_from_seed::("bidder_3") + } + pub fn bidder_4() -> AccountId { + get_account_id_from_seed::("bidder_4") + } + pub fn bidder_5() -> AccountId { + get_account_id_from_seed::("bidder_5") + } + pub fn buyer_1() -> AccountId { + get_account_id_from_seed::("buyer_1") + } + pub fn buyer_2() -> AccountId { + get_account_id_from_seed::("buyer_2") + } + pub fn buyer_3() -> AccountId { + get_account_id_from_seed::("buyer_3") + } + pub fn buyer_4() -> AccountId { + get_account_id_from_seed::("buyer_4") + } + pub fn buyer_5() -> AccountId { + get_account_id_from_seed::("buyer_5") + } + pub fn all_testing_accounts() -> Vec { + vec![ + issuer(), + eval_1(), + eval_2(), + eval_3(), + bidder_1(), + bidder_2(), + bidder_3(), + bidder_4(), + bidder_5(), + buyer_1(), + buyer_2(), + buyer_3(), + buyer_4(), + buyer_5(), + ] + } + pub fn bounded_name() -> BoundedVec> { + BoundedVec::try_from("Contribution Token TEST".as_bytes().to_vec()).unwrap() + } + pub fn bounded_symbol() -> BoundedVec> { + BoundedVec::try_from("CTEST".as_bytes().to_vec()).unwrap() + } + pub fn metadata_hash(nonce: u32) -> H256 { + hashed(format!("{}-{}", METADATA, nonce)) + } + pub fn default_weights() -> Vec { + vec![20u8, 15u8, 10u8, 25u8, 30u8] + } + + pub fn default_project(issuer: AccountId, nonce: u32) -> ProjectMetadataOf { + ProjectMetadata { + token_information: CurrencyMetadata { + name: bounded_name(), + symbol: bounded_symbol(), + decimals: ASSET_DECIMALS, + }, + mainnet_token_max_supply: 8_000_000 * ASSET_UNIT, + total_allocation_size: (50_000 * ASSET_UNIT, 50_000 * ASSET_UNIT), + minimum_price: sp_runtime::FixedU128::from_float(1.0), + ticket_size: TicketSize { minimum: Some(1), maximum: None }, + participants_size: ParticipantsSize { minimum: Some(2), maximum: None }, + funding_thresholds: Default::default(), + conversion_rate: 0, + participation_currencies: AcceptedFundingAsset::USDT, + funding_destination_account: issuer, + offchain_information_hash: Some(metadata_hash(nonce)), + } + } + pub fn default_evaluations() -> Vec> { + vec![ + UserToUSDBalance::new(eval_1(), 50_000 * PLMC), + UserToUSDBalance::new(eval_2(), 25_000 * PLMC), + UserToUSDBalance::new(eval_3(), 32_000 * PLMC), + ] + } + pub fn default_bidders() -> Vec { + vec![bidder_1(), bidder_2(), bidder_3(), bidder_4(), bidder_5()] + } + + pub fn default_contributors() -> Vec { + vec![buyer_1(), buyer_2(), buyer_3(), buyer_4(), buyer_5()] + } + pub fn hashed(data: impl AsRef<[u8]>) -> sp_core::H256 { + ::hash(data.as_ref()) + } + + use polimec_parachain_runtime::Runtime as T; + pub type GenesisInstantiator = pallet_funding::instantiator::Instantiator< + T, + ::AllPalletsWithoutSystem, + ::RuntimeEvent, + >; +} + +#[allow(clippy::too_many_arguments)] +#[cfg(all(feature = "testing-node", feature = "std"))] +fn testing_genesis( + wasm_binary: &[u8], + stakers: Vec<(AccountId, Option, Balance)>, + inflation_config: InflationInfo, + initial_authorities: Vec, + mut endowed_accounts: Vec<(AccountId, Balance)>, + sudo_account: AccountId, + id: ParaId, +) -> GenesisConfig { + use sp_runtime::{traits::PhantomData, FixedPointNumber, Perquintill}; + use testing_helpers::*; + + // only used to generate some values, and not for chain interactions + let funding_percent = 93u64; + let project_metadata = default_project(issuer(), 69u32); + let min_price = project_metadata.minimum_price; + let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) * + (project_metadata.minimum_price.checked_mul_int(project_metadata.total_allocation_size.0).unwrap()); + let evaluations = default_evaluations(); + let bids = GenesisInstantiator::generate_bids_from_total_usd( + Percent::from_percent(50u8) * twenty_percent_funding_usd, + min_price, + default_weights(), + default_bidders(), + ); + let contributions = GenesisInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(50u8) * twenty_percent_funding_usd, + min_price, + default_weights(), + default_contributors(), + ); + let test_balance = 5 * MinCandidateStk::get(); + for account in all_testing_accounts() { + endowed_accounts.push((account, test_balance)); + } + + let accounts = endowed_accounts.iter().map(|(account, _)| account.clone()).collect::>(); + endowed_accounts + .push((::PalletId::get().into_account_truncating(), EXISTENTIAL_DEPOSIT)); + GenesisConfig { + system: SystemConfig { code: wasm_binary.to_vec() }, + polimec_funding: polimec_parachain_runtime::PolimecFundingConfig { + starting_projects: vec![pallet_funding::TestProject:: { + expected_state: ProjectStatus::FundingSuccessful, + metadata: project_metadata, + issuer: issuer(), + evaluations, + bids, + community_contributions: contributions, + remainder_contributions: vec![], + }], + phantom: PhantomData, + }, balances: BalancesConfig { balances: endowed_accounts.clone() }, statemint_assets: StatemintAssetsConfig { assets: vec![( @@ -217,6 +506,6 @@ fn testnet_genesis( council: CouncilConfig { members: accounts.clone(), phantom: Default::default() }, technical_committee: TechnicalCommitteeConfig { members: accounts.clone(), phantom: Default::default() }, democracy: Default::default(), - vesting: VestingConfig { vesting: vec![] }, + linear_vesting: LinearVestingConfig { vesting: vec![] }, } } diff --git a/nodes/parachain/src/command.rs b/nodes/parachain/src/command.rs index 6283b66d0..6d2ec5763 100644 --- a/nodes/parachain/src/command.rs +++ b/nodes/parachain/src/command.rs @@ -95,6 +95,8 @@ fn load_spec(id: &str) -> std::result::Result, String> { "base-rococo-local" => Box::new(chain_spec::base::get_local_base_chain_spec()?), "base-polkadot" => Box::new(chain_spec::base::get_polkadot_base_chain_spec()?), // Testnet runtime + #[cfg(all(feature = "testing-node", feature = "std"))] + "polimec-testing" => Box::new(chain_spec::testnet::get_chain_spec_testing()?), "polimec-rococo-local" => Box::new(chain_spec::testnet::get_chain_spec_dev()?), "polimec-polkadot" => Box::new(chain_spec::testnet::get_prod_chain_spec()?), // -- Fallback (generic chainspec) diff --git a/nodes/standalone/Cargo.toml b/nodes/standalone/Cargo.toml index 474aada69..d8d95fbbe 100644 --- a/nodes/standalone/Cargo.toml +++ b/nodes/standalone/Cargo.toml @@ -80,3 +80,20 @@ try-runtime = [ "sp-runtime/try-runtime", "try-runtime-cli/try-runtime", ] +std = [ + "frame-benchmarking/std", + "frame-system/std", + "pallet-transaction-payment/std", + "serde/std", + "sp-api/std", + "sp-block-builder/std", + "sp-consensus-aura/std", + "sp-consensus-grandpa/std", + "sp-core/std", + "sp-inherents/std", + "sp-io?/std", + "sp-runtime/std" +] +testing-node = [ + "polimec-standalone-runtime/testing-node" +] diff --git a/pallets/funding/Cargo.toml b/pallets/funding/Cargo.toml index c00b4d307..c47f1f626 100644 --- a/pallets/funding/Cargo.toml +++ b/pallets/funding/Cargo.toml @@ -18,6 +18,8 @@ parity-scale-codec = { version = "3.6.5", features = [ scale-info = { version = "2.9.0", default-features = false, features = [ "derive", ] } +log.workspace = true + itertools = { version = "0.11.0", default-features = false } # Substrate dependencies @@ -34,6 +36,12 @@ pallet-balances.workspace = true sp-io.workspace = true pallet-timestamp.workspace = true xcm-builder.workspace = true +xcm.workspace = true +polimec-xcm-executor.workspace = true +pallet-xcm.workspace = true +polkadot-runtime.workspace = true +polkadot-runtime-parachains.workspace = true +polkadot-parachain.workspace = true [dev-dependencies] @@ -45,24 +53,34 @@ assert_matches2.workspace = true [features] default = [ "std" ] std = [ + "serde", + "parity-scale-codec/std", + "scale-info/std", + "log/std", + "itertools/use_std", "frame-benchmarking?/std", "frame-support/std", "frame-system/std", - "itertools/use_std", - "pallet-assets/std", - "pallet-balances/std", - "pallet-insecure-randomness-collective-flip/std", - "pallet-linear-release/std", - "parachains-common/std", - "parity-scale-codec/std", - "polimec-traits/std", - "scale-info/std", - "serde", + "sp-std/std", + "sp-runtime/std", "sp-arithmetic/std", + "polimec-traits/std", + "parachains-common/std", "sp-core/std", + "pallet-balances/std", "sp-io/std", - "sp-runtime/std", - "sp-std/std", + "pallet-timestamp/std", + "xcm-builder/std", + "xcm/std", + "polimec-xcm-executor/std", + "pallet-xcm/std", + "polkadot-runtime/std", + "polkadot-runtime-parachains/std", + "polkadot-parachain/std", + + "pallet-insecure-randomness-collective-flip/std", + "pallet-assets/std", + "pallet-linear-release/std", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", @@ -72,8 +90,15 @@ runtime-benchmarks = [ "pallet-balances/runtime-benchmarks", "polimec-traits/runtime-benchmarks", "sp-runtime/runtime-benchmarks", - "xcm-builder/runtime-benchmarks", - "itertools/use_alloc", + "xcm-builder/runtime-benchmarks", + "itertools/use_alloc", + "pallet-linear-release/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", + "pallet-xcm/runtime-benchmarks", + "polimec-xcm-executor/runtime-benchmarks", + "polkadot-parachain/runtime-benchmarks", + "polkadot-runtime/runtime-benchmarks", + "polkadot-runtime-parachains/runtime-benchmarks" ] try-runtime = [ "frame-support/try-runtime", @@ -85,3 +110,5 @@ try-runtime = [ "polimec-traits/try-runtime", "sp-runtime/try-runtime", ] +testing-node = [ +] diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 4452b5c9d..e681f5354 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -108,6 +108,12 @@ impl Pallet { evaluators_outcome: EvaluatorsOutcome::Unchanged, }, funding_end_block: None, + parachain_id: None, + migration_readiness_check: None, + comm_status: CommStatus { + project_to_polimec: ChannelStatus::Closed, + polimec_to_project: ChannelStatus::Closed, + }, }; let bucket: BucketOf = Bucket::new( initial_metadata.total_allocation_size.0, @@ -692,36 +698,6 @@ impl Pallet { Ok(()) } - - /// Called manually by a user extrinsic - /// Marks the project as ready to launch on mainnet, which will in the future start the logic - /// to burn the contribution tokens and mint the real tokens the project's chain - /// - /// # Arguments - /// * `project_id` - The project identifier - /// - /// # Storage access - /// * [`ProjectsDetails`] - Check that the funding round ended, and update the status to ReadyToLaunch - /// - /// # Success Path - /// For now it will always succeed as long as the project exists. This functions is a WIP. - /// - /// - /// # Next step - /// WIP - pub fn do_ready_to_launch(project_id: &T::ProjectIdentifier) -> Result<(), DispatchError> { - // * Get variables * - let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; - - // * Validity checks * - ensure!(project_details.status == ProjectStatus::FundingSuccessful, Error::::ProjectNotInFundingEndedRound); - - // Update project Info - project_details.status = ProjectStatus::ReadyToLaunch; - ProjectsDetails::::insert(project_id, project_details); - - Ok(()) - } } // Extrinsic functions (except round transitions) @@ -1780,6 +1756,62 @@ impl Pallet { Ok(()) } + + pub fn do_set_para_id_for_project( + caller: &AccountIdOf, + project_id: T::ProjectIdentifier, + para_id: ParaId, + ) -> Result<(), DispatchError> { + // * Get variables * + let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + + // * Validity checks * + ensure!(&(project_details.issuer) == caller, Error::::NotAllowed); + + // * Update storage * + project_details.parachain_id = Some(para_id); + ProjectsDetails::::insert(project_id, project_details); + + // * Emit events * + Self::deposit_event(Event::ProjectParaIdSet { project_id, para_id, caller: caller.clone() }); + + Ok(()) + } + + pub fn start_migration_readiness_check( + caller: &AccountIdOf, + project_id: T::ProjectIdentifier, + ) -> Result<(), DispatchError> { + let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + ensure!(project_details.status == ProjectStatus::FundingSuccessful, Error::::NotAllowed); + ensure!( + project_details.comm_status == + CommStatus { project_to_polimec: ChannelStatus::Open, polimec_to_project: ChannelStatus::Open }, + Error::::CommsNotEstablished + ); + if project_details.migration_readiness_check.is_none() { + ensure!(caller.clone() == T::PalletId::get().into_account_truncating(), Error::::NotAllowed); + } else if project_details.migration_readiness_check == Some(MigrationReadinessCheck::CheckFailed) { + ensure!(caller == &project_details.issuer, Error::::NotAllowed); + } + + project_details.migration_readiness_check = Some(MigrationReadinessCheck::QuerySent); + ProjectsDetails::::insert(project_id, project_details); + + // TODO: send message to polimec receiver pallet with query + + Self::deposit_event(Event::::MigrationReadinessCheckStarted { project_id, caller: caller.clone() }); + + Ok(()) + } + + pub fn finish_migration_readiness_check( + _caller: ParaId, + _project_id: T::ProjectIdentifier, + _check_bytes: Vec, + ) -> Result<(), DispatchError> { + Ok(()) + } } // Helper functions diff --git a/pallets/funding/src/impls.rs b/pallets/funding/src/impls.rs index 4ff16b05d..4b2f2a0c5 100644 --- a/pallets/funding/src/impls.rs +++ b/pallets/funding/src/impls.rs @@ -321,7 +321,7 @@ fn reward_or_slash_one_evaluation(project_id: T::ProjectIdentifier) - }), }; - return Ok((base_weight.saturating_add(T::WeightInfo::evaluation_reward_payout_for()), remaining)) + return Ok((base_weight.saturating_add(WeightInfoOf::::evaluation_reward_payout_for()), remaining)) }, EvaluatorsOutcome::Slashed => { match Pallet::::do_evaluation_slash_for( @@ -339,7 +339,7 @@ fn reward_or_slash_one_evaluation(project_id: T::ProjectIdentifier) - }), }; - return Ok((base_weight.saturating_add(T::WeightInfo::evaluation_slash_for()), remaining)) + return Ok((base_weight.saturating_add(WeightInfoOf::::evaluation_slash_for()), remaining)) }, _ => { #[cfg(debug_assertions)] @@ -373,7 +373,7 @@ fn unbond_one_evaluation(project_id: T::ProjectIdentifier) -> (Weight error: e, }), }; - (base_weight.saturating_add(T::WeightInfo::evaluation_unbond_for()), evaluation_count.saturating_sub(1u64)) + (base_weight.saturating_add(WeightInfoOf::::evaluation_unbond_for()), evaluation_count.saturating_sub(1u64)) } else { (base_weight, 0u64) } @@ -400,7 +400,7 @@ fn release_funds_one_bid(project_id: T::ProjectIdentifier) -> (Weight }), }; - (base_weight.saturating_add(T::WeightInfo::release_bid_funds_for()), remaining_bids.count() as u64) + (base_weight.saturating_add(WeightInfoOf::::release_bid_funds_for()), remaining_bids.count() as u64) } else { (base_weight, 0u64) } @@ -426,7 +426,7 @@ fn unbond_one_bid(project_id: T::ProjectIdentifier) -> (Weight, u64) error: e, }), }; - (base_weight.saturating_add(T::WeightInfo::bid_unbond_for()), remaining_bids.count() as u64) + (base_weight.saturating_add(WeightInfoOf::::bid_unbond_for()), remaining_bids.count() as u64) } else { (base_weight, 0u64) } @@ -454,7 +454,7 @@ fn release_funds_one_contribution(project_id: T::ProjectIdentifier) - }; ( - base_weight.saturating_add(T::WeightInfo::release_contribution_funds_for()), + base_weight.saturating_add(WeightInfoOf::::release_contribution_funds_for()), remaining_contributions.count() as u64, ) } else { @@ -484,7 +484,10 @@ fn unbond_one_contribution(project_id: T::ProjectIdentifier) -> (Weig error: e, }), }; - (base_weight.saturating_add(T::WeightInfo::contribution_unbond_for()), remaining_contributions.count() as u64) + ( + base_weight.saturating_add(WeightInfoOf::::contribution_unbond_for()), + remaining_contributions.count() as u64, + ) } else { (base_weight, 0u64) } @@ -516,7 +519,10 @@ fn start_one_bid_vesting_schedule(project_id: T::ProjectIdentifier) - }); }, } - (base_weight.saturating_add(T::WeightInfo::start_bid_vesting_schedule_for()), unscheduled_bids.count() as u64) + ( + base_weight.saturating_add(WeightInfoOf::::start_bid_vesting_schedule_for()), + unscheduled_bids.count() as u64, + ) } else { (base_weight, 0u64) } @@ -545,7 +551,7 @@ fn start_one_contribution_vesting_schedule(project_id: T::ProjectIden }, } ( - base_weight.saturating_add(T::WeightInfo::start_contribution_vesting_schedule_for()), + base_weight.saturating_add(WeightInfoOf::::start_contribution_vesting_schedule_for()), unscheduled_contributions.count() as u64, ) } else { @@ -574,7 +580,7 @@ fn mint_ct_for_one_bid(project_id: T::ProjectIdentifier) -> (Weight, error: e, }), }; - (base_weight.saturating_add(T::WeightInfo::bid_ct_mint_for()), remaining_bids.count() as u64) + (base_weight.saturating_add(WeightInfoOf::::bid_ct_mint_for()), remaining_bids.count() as u64) } else { (base_weight, 0u64) } @@ -600,7 +606,10 @@ fn mint_ct_for_one_contribution(project_id: T::ProjectIdentifier) -> error: e, }), }; - (base_weight.saturating_add(T::WeightInfo::contribution_ct_mint_for()), remaining_contributions.count() as u64) + ( + base_weight.saturating_add(WeightInfoOf::::contribution_ct_mint_for()), + remaining_contributions.count() as u64, + ) } else { (base_weight, 0u64) } @@ -629,7 +638,7 @@ fn issuer_funding_payout_one_bid(project_id: T::ProjectIdentifier) -> error: e, }), }; - (base_weight.saturating_add(T::WeightInfo::payout_bid_funds_for()), remaining_bids.count() as u64) + (base_weight.saturating_add(WeightInfoOf::::payout_bid_funds_for()), remaining_bids.count() as u64) } else { (base_weight, 0u64) } @@ -658,7 +667,7 @@ fn issuer_funding_payout_one_contribution(project_id: T::ProjectIdent }; ( - base_weight.saturating_add(T::WeightInfo::payout_contribution_funds_for()), + base_weight.saturating_add(WeightInfoOf::::payout_contribution_funds_for()), remaining_contributions.count() as u64, ) } else { diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index ce056b045..538ee35ec 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -12,7 +12,7 @@ use frame_support::{ metadata::Inspect as MetadataInspect, roles::Inspect as RolesInspect, Inspect as FungiblesInspect, Mutate as FungiblesMutate, }, - Get, OnFinalize, OnIdle, OnInitialize, OriginTrait, + Get, OnFinalize, OnIdle, OnInitialize, }, weights::Weight, Parameter, @@ -42,14 +42,14 @@ use sp_std::{ use crate::{ traits::{BondingRequirementCalculation, ProvideStatemintPrice}, AcceptedFundingAsset, AccountIdOf, AssetIdOf, AuctionPhase, BalanceOf, BidInfoOf, BidStatus, Bids, BlockNumberOf, - BlockNumberPair, Cleaner, Config, Contributions, Error, EvaluationInfoOf, EvaluationRoundInfoOf, EvaluatorsOutcome, - Event, LockType, MultiplierOf, PhaseTransitionPoints, PriceOf, ProjectDetailsOf, ProjectIdOf, ProjectMetadataOf, - ProjectStatus, ProjectsDetails, ProjectsMetadata, ProjectsToUpdate, RewardInfoOf, UpdateType, VestingInfoOf, - PLMC_STATEMINT_ID, + BlockNumberPair, Cleaner, CommStatus, Config, Contributions, Error, EvaluationInfoOf, EvaluationRoundInfoOf, + EvaluatorsOutcome, Event, LockType, MultiplierOf, NextProjectId, PhaseTransitionPoints, PriceOf, ProjectDetailsOf, + ProjectIdOf, ProjectMetadataOf, ProjectStatus, ProjectsDetails, ProjectsMetadata, ProjectsToUpdate, RewardInfoOf, + UpdateType, VestingInfoOf, PLMC_STATEMINT_ID, }; pub use testing_macros::*; -type RuntimeOriginOf = ::RuntimeOrigin; +pub type RuntimeOriginOf = ::RuntimeOrigin; pub struct BoxToFunction(pub Box); impl Default for BoxToFunction { @@ -58,13 +58,13 @@ impl Default for BoxToFunction { } } pub struct Instantiator< - T: Config + frame_system::Config + pallet_balances::Config>, + T: Config + pallet_balances::Config>, AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, - RuntimeEvent: From> + TryInto> + Parameter + Member, + RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, > { - #[cfg(feature = "std")] + #[cfg(all(feature = "std", not(feature = "testing-node")))] ext: Option>, - #[cfg(not(feature = "std"))] + #[cfg(not(all(feature = "std", not(feature = "testing-node"))))] ext: Option<()>, nonce: RefCell, _marker: PhantomData<(T, AllPalletsWithoutSystem, RuntimeEvent)>, @@ -72,31 +72,31 @@ pub struct Instantiator< // general chain interactions impl< - T: Config + frame_system::Config + pallet_balances::Config>, + T: Config + pallet_balances::Config>, AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, - RuntimeEvent: From> + TryInto> + Parameter + Member, + RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, > Instantiator where - AccountIdOf: Into< as OriginTrait>::AccountId> + sp_std::fmt::Debug, - ::Balance: Into>, +// AccountIdOf: Into< as OriginTrait>::AccountId> + sp_std::fmt::Debug, +// ::Balance: Into>, { pub fn new( - #[cfg(feature = "std")] ext: Option>, - #[cfg(not(feature = "std"))] ext: Option<()>, + #[cfg(all(feature = "std", not(feature = "testing-node")))] ext: Option>, + #[cfg(not(all(feature = "std", not(feature = "testing-node"))))] ext: Option<()>, ) -> Self { Self { ext, nonce: RefCell::new(0u64), _marker: PhantomData } } pub fn set_ext( &mut self, - #[cfg(feature = "std")] ext: Option>, - #[cfg(not(feature = "std"))] ext: Option<()>, + #[cfg(all(feature = "std", not(feature = "testing-node")))] ext: Option>, + #[cfg(not(all(feature = "std", not(feature = "testing-node"))))] ext: Option<()>, ) { self.ext = ext; } pub fn execute(&mut self, execution: impl FnOnce() -> R) -> R { - #[cfg(feature = "std")] + #[cfg(all(feature = "std", not(feature = "testing-node")))] if let Some(ext) = &self.ext { return ext.borrow_mut().execute_with(execution) } @@ -196,9 +196,9 @@ where correct_funds: Vec>, reserve_type: LockType>, ) { - for UserToPLMCBalance { account, plmc_amount } in correct_funds { + for UserToPLMCBalance { account, .. } in correct_funds { self.execute(|| { - let reserved = ::NativeCurrency::balance_on_hold(&reserve_type, &account); + let _reserved = ::NativeCurrency::balance_on_hold(&reserve_type, &account); // TODO: Enable this // assert_eq!(reserved, plmc_amount); }); @@ -255,9 +255,9 @@ where } pub fn do_free_plmc_assertions(&mut self, correct_funds: Vec>) { - for UserToPLMCBalance { account, plmc_amount } in correct_funds { + for UserToPLMCBalance { account, .. } in correct_funds { self.execute(|| { - let free = ::NativeCurrency::balance(&account); + let _free = ::NativeCurrency::balance(&account); // TODO: Enable this // assert_eq!(free, plmc_amount); }); @@ -278,10 +278,10 @@ where correct_funds: Vec>, project_id: ProjectIdOf, ) { - for UserToStatemintAsset { account, asset_amount, .. } in correct_funds { + for UserToStatemintAsset { account, .. } in correct_funds { self.execute(|| { // total amount of contributions for this user for this project stored in the mapping - let contribution_total: ::Balance = + let _contribution_total: ::Balance = Bids::::iter_prefix_values((project_id, account.clone())) .map(|c| c.funding_asset_amount_locked) .fold(Zero::zero(), |a, b| a + b); @@ -312,13 +312,13 @@ where // assertions impl< - T: Config + frame_system::Config + pallet_balances::Config>, + T: Config + pallet_balances::Config>, AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, - RuntimeEvent: From> + TryInto> + Parameter + Member, + RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, > Instantiator where - AccountIdOf: Into< as OriginTrait>::AccountId> + sp_std::fmt::Debug, - ::Balance: Into>, +// AccountIdOf: Into< as OriginTrait>::AccountId> + sp_std::fmt::Debug, +// ::Balance: Into>, { pub fn test_ct_created_for(&mut self, project_id: ProjectIdOf) { self.execute(|| { @@ -376,6 +376,12 @@ where evaluators_outcome: EvaluatorsOutcome::Unchanged, }, funding_end_block: None, + parachain_id: None, + migration_readiness_check: None, + comm_status: CommStatus { + project_to_polimec: crate::ChannelStatus::Closed, + polimec_to_project: crate::ChannelStatus::Closed, + }, }; assert_eq!(metadata, expected_metadata); assert_eq!(details, expected_details); @@ -395,7 +401,8 @@ where assert_eq!(self.get_plmc_total_supply(), total_plmc_supply) } - fn finalized_bids_assertions( + #[allow(unused)] + pub fn finalized_bids_assertions( &mut self, project_id: ProjectIdOf, bid_expectations: Vec>, @@ -421,13 +428,13 @@ where // calculations impl< - T: Config + frame_system::Config + pallet_balances::Config>, + T: Config + pallet_balances::Config>, AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, - RuntimeEvent: From> + TryInto> + Parameter + Member, + RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, > Instantiator where - AccountIdOf: Into< as OriginTrait>::AccountId> + sp_std::fmt::Debug, - ::Balance: Into>, +// AccountIdOf: Into< as OriginTrait>::AccountId> + sp_std::fmt::Debug, +// ::Balance: Into>, { pub fn get_ed() -> BalanceOf { T::ExistentialDeposit::get() @@ -841,11 +848,11 @@ where } pub fn err_if_on_initialize_failed( - events: Vec>, + events: Vec::RuntimeEvent, T::Hash>>, ) -> Result<(), Error> { let last_event_record = events.into_iter().last().expect("No events found for this action."); let last_event = last_event_record.event; - let maybe_funding_event = last_event.try_into(); + let maybe_funding_event = ::RuntimeEvent::from(last_event).try_into(); if let Ok(funding_event) = maybe_funding_event { if let Event::TransitionError { project_id: _, error } = funding_event { if let DispatchError::Module(module_error) = error { @@ -918,13 +925,13 @@ where // project chain interactions impl< - T: Config + frame_system::Config + pallet_balances::Config>, + T: Config + pallet_balances::Config>, AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, - RuntimeEvent: From> + TryInto> + Parameter + Member, + RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, > Instantiator where - AccountIdOf: Into< as OriginTrait>::AccountId> + sp_std::fmt::Debug, - ::Balance: Into>, +// AccountIdOf: Into< as OriginTrait>::AccountId> + sp_std::fmt::Debug, +// ::Balance: Into>, { pub fn get_issuer(&mut self, project_id: ProjectIdOf) -> AccountIdOf { self.execute(|| ProjectsDetails::::get(project_id).unwrap().issuer) @@ -960,21 +967,27 @@ where self.mint_plmc_to(vec![UserToPLMCBalance::new(issuer.clone(), Self::get_ed())]); self.execute(|| { crate::Pallet::::do_create(&issuer, project_metadata.clone()).unwrap(); + let last_project_metadata = ProjectsMetadata::::iter().last().unwrap(); + log::trace!("Last project metadata: {:?}", last_project_metadata); }); - self.advance_time(10u32.into()).unwrap(); - let created_project_id = self.execute(|| { - let project_id = frame_system::Pallet::::events() - .iter() - .filter_map(|event| match RuntimeEvent::try_into(event.event.clone()) { - Ok(Event::ProjectCreated { project_id, issuer: _ }) => Some(project_id), - _ => None, - }) - .last() - .expect("Project created event expected") - .clone(); - project_id - }); + self.advance_time(10u32.into()).unwrap(); + // let created_project_id = self.execute(|| { + // let events = frame_system::Pallet::::events(); + // log::trace!("Events: {:?}", events); + // let project_id = events + // .iter() + // .filter_map(|event| match RuntimeEvent::from(event.event.clone()).try_into() { + // Ok(Event::ProjectCreated { project_id, issuer: _ }) => Some(project_id), + // _ => None, + // }) + // .last() + // .expect("Project created event expected") + // .clone(); + // + // project_id + // }); + let created_project_id = self.execute(|| NextProjectId::::get().saturating_sub(One::one())); self.creation_assertions(created_project_id, project_metadata, now); created_project_id } @@ -1118,7 +1131,7 @@ where let bidders = bids.accounts(); let asset_id = bids[0].asset.to_statemint_id(); let prev_plmc_balances = self.get_free_plmc_balances_for(bidders.clone()); - let prev_funding_asset_balances = self.get_free_statemint_asset_balances_for(asset_id, bidders.clone()); + let _prev_funding_asset_balances = self.get_free_statemint_asset_balances_for(asset_id, bidders.clone()); let plmc_evaluation_deposits: Vec> = Self::calculate_evaluation_plmc_spent(evaluations.clone()); let plmc_bid_deposits: Vec> = Self::calculate_auction_plmc_spent(bids.clone()); @@ -1154,7 +1167,7 @@ where .map(|bid| BidParams::::from(bid.bidder, bid.final_ct_amount, bid.final_ct_usd_price)) .collect_vec(); - let bid_expectations = new_bids + let _bid_expectations = new_bids .iter() .map(|bid| BidInfoFilter:: { final_ct_amount: Some(bid.amount), @@ -1163,7 +1176,7 @@ where }) .collect_vec(); - let total_ct_sold = new_bids.iter().map(|bid| bid.amount).fold(Zero::zero(), |acc, item| item + acc); + let _total_ct_sold = new_bids.iter().map(|bid| bid.amount).fold(Zero::zero(), |acc, item| item + acc); self.mint_plmc_to(necessary_plmc_mint.clone()); self.mint_plmc_to(plmc_existential_deposits.clone()); @@ -1329,7 +1342,7 @@ where let contributors = remainder_contributions.accounts(); let asset_id = remainder_contributions[0].asset.to_statemint_id(); let prev_plmc_balances = self.get_free_plmc_balances_for(contributors.clone()); - let prev_funding_asset_balances = self.get_free_statemint_asset_balances_for(asset_id, contributors.clone()); + let _prev_funding_asset_balances = self.get_free_statemint_asset_balances_for(asset_id, contributors.clone()); let plmc_evaluation_deposits = Self::calculate_evaluation_plmc_spent(evaluations.clone()); let plmc_bid_deposits = Self::calculate_auction_plmc_spent_after_price_calculation(bids.clone(), ct_price); @@ -1377,11 +1390,11 @@ where if self.get_project_details(project_id).status == ProjectStatus::FundingSuccessful { // Check that remaining CTs are updated - let project_details = self.get_project_details(project_id); - let auction_bought_tokens = bids.iter().map(|bid| bid.amount).fold(Zero::zero(), |acc, item| item + acc); - let community_bought_tokens = + let _project_details = self.get_project_details(project_id); + let _auction_bought_tokens = bids.iter().map(|bid| bid.amount).fold(Zero::zero(), |acc, item| item + acc); + let __community_bought_tokens = community_contributions.iter().map(|cont| cont.amount).fold(Zero::zero(), |acc, item| item + acc); - let remainder_bought_tokens = + let _remainder_bought_tokens = remainder_contributions.iter().map(|cont| cont.amount).fold(Zero::zero(), |acc, item| item + acc); // assert_eq!( @@ -1396,6 +1409,42 @@ where project_id } + + pub fn create_project_at( + &mut self, + status: ProjectStatus, + project_metadata: ProjectMetadataOf, + issuer: AccountIdOf, + evaluations: Vec>, + bids: Vec>, + community_contributions: Vec>, + remainder_contributions: Vec>, + ) -> ProjectIdOf { + match status { + ProjectStatus::FundingSuccessful => self.create_finished_project( + project_metadata, + issuer, + evaluations, + bids, + community_contributions, + remainder_contributions, + ), + ProjectStatus::RemainderRound => self.create_remainder_contributing_project( + project_metadata, + issuer, + evaluations, + bids, + community_contributions, + ), + ProjectStatus::CommunityRound => + self.create_community_contributing_project(project_metadata, issuer, evaluations, bids), + ProjectStatus::AuctionRound(AuctionPhase::English) => + self.create_auctioning_project(project_metadata, issuer, evaluations), + ProjectStatus::EvaluationRound => self.create_evaluating_project(project_metadata, issuer), + ProjectStatus::Application => self.create_new_project(project_metadata, issuer), + _ => panic!("unsupported project creation in that status"), + } + } } pub trait Accounts { @@ -1409,7 +1458,7 @@ pub trait ExistentialDeposits { impl ExistentialDeposits for Vec> where - ::Balance: Into>, +// ::Balance: Into>, { fn existential_deposits(&self) -> Vec> { self.iter() @@ -1441,7 +1490,12 @@ impl Accounts for Vec> { } } -#[derive(Clone, PartialEq, Debug)] +#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr( + feature = "std", + serde(rename_all = "camelCase", deny_unknown_fields, bound(serialize = ""), bound(deserialize = "")) +)] pub struct UserToUSDBalance { pub account: AccountIdOf, pub usd_amount: BalanceOf, @@ -1463,7 +1517,7 @@ impl Accounts for Vec> { } } -#[derive(Clone, PartialEq, Debug)] +#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] pub struct UserToStatemintAsset { pub account: AccountIdOf, pub asset_amount: BalanceOf, @@ -1485,7 +1539,12 @@ impl Accounts for Vec> { btree.into_iter().collect_vec() } } -#[derive(Clone, Debug)] +#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr( + feature = "std", + serde(rename_all = "camelCase", deny_unknown_fields, bound(serialize = ""), bound(deserialize = "")) +)] pub struct BidParams { pub bidder: AccountIdOf, pub amount: BalanceOf, @@ -1526,7 +1585,12 @@ impl Accounts for Vec> { } } -#[derive(Clone)] +#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr( + feature = "std", + serde(rename_all = "camelCase", deny_unknown_fields, bound(serialize = ""), bound(deserialize = "")) +)] pub struct ContributionParams { pub contributor: AccountIdOf, pub amount: BalanceOf, diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index e90c5ceaa..53d81a361 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -173,18 +173,21 @@ #![cfg_attr(feature = "runtime-benchmarks", recursion_limit = "512")] use frame_support::{ + pallet_prelude::Weight, traits::{ tokens::{fungible, fungibles, Balance}, Randomness, }, BoundedVec, PalletId, }; +pub use pallet::*; +use parity_scale_codec::Encode; +use polkadot_parachain::primitives::Id as ParaId; use sp_arithmetic::traits::{One, Saturating}; use sp_runtime::{traits::AccountIdConversion, FixedPointNumber, FixedPointOperand, FixedU128}; -use sp_std::prelude::*; - -pub use pallet::*; +use sp_std::{marker::PhantomData, prelude::*}; pub use types::*; +use xcm::v3::{opaque::Instruction, prelude::*, SendXcm}; pub use crate::weights::WeightInfo; @@ -201,7 +204,7 @@ pub mod tests; #[cfg(feature = "runtime-benchmarks")] pub mod benchmarking; pub mod impls; -#[cfg(any(feature = "runtime-benchmarks", test))] +#[cfg(any(feature = "runtime-benchmarks", test, all(feature = "testing-node", feature = "std")))] pub mod instantiator; pub mod traits; @@ -241,6 +244,7 @@ pub type ContributionInfoOf = pub type BucketOf = Bucket, PriceOf>; pub type BondTypeOf = LockType>; +pub type WeightInfoOf = ::WeightInfo; pub const PLMC_STATEMINT_ID: u32 = 2069; @@ -261,8 +265,18 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: frame_system::Config { - type RuntimeEvent: From> + IsType<::RuntimeEvent>; + pub trait Config: frame_system::Config + pallet_balances::Config> { + /// Helper trait for benchmarks. + // #[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] + type AllPalletsWithoutSystem: frame_support::traits::OnFinalize> + + frame_support::traits::OnIdle> + + frame_support::traits::OnInitialize>; + + type RuntimeEvent: From> + + TryInto> + + IsType<::RuntimeEvent> + + Parameter + + Member; /// Global identifier for the projects. type ProjectIdentifier: Parameter + Copy + Default + One + Saturating + From + Ord + MaxEncodedLen; @@ -275,13 +289,14 @@ pub mod pallet { + Default + Copy + TryFrom - + MaxEncodedLen; + + MaxEncodedLen + + MaybeSerializeDeserialize; /// The inner balance type we will use for all of our outer currency types. (e.g native, funding, CTs) - type Balance: Balance + From + FixedPointOperand; + type Balance: Balance + From + FixedPointOperand + MaybeSerializeDeserialize; /// Represents the value of something in USD - type Price: FixedPointNumber + Parameter + Copy + MaxEncodedLen; + type Price: FixedPointNumber + Parameter + Copy + MaxEncodedLen + MaybeSerializeDeserialize; /// The chains native currency type NativeCurrency: fungible::InspectHold, Balance = BalanceOf> @@ -366,16 +381,10 @@ pub mod pallet { #[pallet::constant] type ContributionVesting: Get; - /// Helper trait for benchmarks. - #[cfg(feature = "runtime-benchmarks")] - type AllPalletsWithoutSystem: frame_support::traits::OnFinalize> - + frame_support::traits::OnIdle> - + frame_support::traits::OnInitialize>; - /// Weight information for extrinsics in this pallet. - type WeightInfo: WeightInfo; + type WeightInfo: weights::WeightInfo; - type FeeBrackets: Get>; + type FeeBrackets: Get::Balance)>>; type EvaluationSuccessThreshold: Get; @@ -734,6 +743,26 @@ pub mod pallet { project_id: ProjectIdOf, decision: FundingOutcomeDecision, }, + ProjectParaIdSet { + project_id: T::ProjectIdentifier, + para_id: ParaId, + caller: T::AccountId, + }, + /// A channel was accepted from a parachain to polimec belonging to a project. A request has been sent to the relay for a polimec->project channel + HrmpChannelAccepted { + project_id: T::ProjectIdentifier, + para_id: ParaId, + }, + /// A channel was established from polimec to a project. The relay has notified us of their acceptance of our request + HrmpChannelEstablished { + project_id: T::ProjectIdentifier, + para_id: ParaId, + }, + /// Started a migration readiness check + MigrationReadinessCheckStarted { + project_id: T::ProjectIdentifier, + caller: T::AccountId, + }, } #[pallet::error] @@ -826,21 +855,24 @@ pub mod pallet { FinalizerFinished, /// ContributionNotFound, + /// Tried to start a migration check but the bidirectional channel is not yet open + CommsNotEstablished, } #[pallet::call] impl Pallet { /// Creates a project and assigns it to the `issuer` account. #[pallet::call_index(0)] - #[pallet::weight(T::WeightInfo::create())] + #[pallet::weight(WeightInfoOf::::create())] pub fn create(origin: OriginFor, project: ProjectMetadataOf) -> DispatchResult { let issuer = ensure_signed(origin)?; + log::trace!(target: "pallet_funding::test", "in create"); Self::do_create(&issuer, project) } /// Change the metadata hash of a project #[pallet::call_index(1)] - #[pallet::weight(T::WeightInfo::edit_metadata())] + #[pallet::weight(WeightInfoOf::::edit_metadata())] pub fn edit_metadata( origin: OriginFor, project_id: T::ProjectIdentifier, @@ -852,7 +884,7 @@ pub mod pallet { /// Starts the evaluation round of a project. It needs to be called by the project issuer. #[pallet::call_index(2)] - #[pallet::weight(T::WeightInfo::start_evaluation())] + #[pallet::weight(WeightInfoOf::::start_evaluation())] pub fn start_evaluation(origin: OriginFor, project_id: T::ProjectIdentifier) -> DispatchResult { let issuer = ensure_signed(origin)?; Self::do_evaluation_start(issuer, project_id) @@ -862,7 +894,7 @@ pub mod pallet { /// institutional user can set bids for a token_amount/token_price pair. /// Any bids from this point until the candle_auction starts, will be considered as valid. #[pallet::call_index(3)] - #[pallet::weight(T::WeightInfo::start_auction())] + #[pallet::weight(WeightInfoOf::::start_auction())] pub fn start_auction(origin: OriginFor, project_id: T::ProjectIdentifier) -> DispatchResult { let issuer = ensure_signed(origin)?; Self::do_english_auction(issuer, project_id) @@ -870,7 +902,7 @@ pub mod pallet { /// Bond PLMC for a project in the evaluation stage #[pallet::call_index(4)] - #[pallet::weight(T::WeightInfo::bond_evaluation())] + #[pallet::weight(WeightInfoOf::::bond_evaluation())] pub fn bond_evaluation( origin: OriginFor, project_id: T::ProjectIdentifier, @@ -882,7 +914,7 @@ pub mod pallet { /// Bid for a project in the Auction round #[pallet::call_index(5)] - #[pallet::weight(T::WeightInfo::bid())] + #[pallet::weight(WeightInfoOf::::bid())] pub fn bid( origin: OriginFor, project_id: T::ProjectIdentifier, @@ -897,7 +929,7 @@ pub mod pallet { /// Buy tokens in the Community or Remainder round at the price set in the Auction Round #[pallet::call_index(6)] - #[pallet::weight(T::WeightInfo::contribute())] + #[pallet::weight(WeightInfoOf::::contribute())] pub fn contribute( origin: OriginFor, project_id: T::ProjectIdentifier, @@ -911,7 +943,7 @@ pub mod pallet { /// Release evaluation-bonded PLMC when a project finishes its funding round. #[pallet::call_index(7)] - #[pallet::weight(T::WeightInfo::evaluation_unbond_for())] + #[pallet::weight(WeightInfoOf::::evaluation_unbond_for())] pub fn evaluation_unbond_for( origin: OriginFor, project_id: T::ProjectIdentifier, @@ -923,7 +955,7 @@ pub mod pallet { } #[pallet::call_index(8)] - #[pallet::weight(T::WeightInfo::evaluation_slash_for())] + #[pallet::weight(WeightInfoOf::::evaluation_slash_for())] pub fn evaluation_slash_for( origin: OriginFor, project_id: T::ProjectIdentifier, @@ -935,7 +967,7 @@ pub mod pallet { } #[pallet::call_index(9)] - #[pallet::weight(T::WeightInfo::evaluation_reward_payout_for())] + #[pallet::weight(WeightInfoOf::::evaluation_reward_payout_for())] pub fn evaluation_reward_payout_for( origin: OriginFor, project_id: T::ProjectIdentifier, @@ -947,7 +979,7 @@ pub mod pallet { } #[pallet::call_index(10)] - #[pallet::weight(T::WeightInfo::bid_ct_mint_for())] + #[pallet::weight(WeightInfoOf::::bid_ct_mint_for())] pub fn bid_ct_mint_for( origin: OriginFor, project_id: T::ProjectIdentifier, @@ -959,7 +991,7 @@ pub mod pallet { } #[pallet::call_index(11)] - #[pallet::weight(T::WeightInfo::contribution_ct_mint_for())] + #[pallet::weight(WeightInfoOf::::contribution_ct_mint_for())] pub fn contribution_ct_mint_for( origin: OriginFor, project_id: T::ProjectIdentifier, @@ -971,7 +1003,7 @@ pub mod pallet { } #[pallet::call_index(12)] - #[pallet::weight(T::WeightInfo::start_bid_vesting_schedule_for())] + #[pallet::weight(WeightInfoOf::::start_bid_vesting_schedule_for())] pub fn start_bid_vesting_schedule_for( origin: OriginFor, project_id: T::ProjectIdentifier, @@ -983,7 +1015,7 @@ pub mod pallet { } #[pallet::call_index(13)] - #[pallet::weight(T::WeightInfo::start_contribution_vesting_schedule_for())] + #[pallet::weight(WeightInfoOf::::start_contribution_vesting_schedule_for())] pub fn start_contribution_vesting_schedule_for( origin: OriginFor, project_id: T::ProjectIdentifier, @@ -995,7 +1027,7 @@ pub mod pallet { } #[pallet::call_index(14)] - #[pallet::weight(T::WeightInfo::payout_bid_funds_for())] + #[pallet::weight(WeightInfoOf::::payout_bid_funds_for())] pub fn payout_bid_funds_for( origin: OriginFor, project_id: T::ProjectIdentifier, @@ -1007,7 +1039,7 @@ pub mod pallet { } #[pallet::call_index(15)] - #[pallet::weight(T::WeightInfo::payout_contribution_funds_for())] + #[pallet::weight(WeightInfoOf::::payout_contribution_funds_for())] pub fn payout_contribution_funds_for( origin: OriginFor, project_id: T::ProjectIdentifier, @@ -1019,7 +1051,7 @@ pub mod pallet { } #[pallet::call_index(16)] - #[pallet::weight(T::WeightInfo::decide_project_outcome())] + #[pallet::weight(WeightInfoOf::::decide_project_outcome())] pub fn decide_project_outcome( origin: OriginFor, project_id: T::ProjectIdentifier, @@ -1030,7 +1062,7 @@ pub mod pallet { } #[pallet::call_index(17)] - #[pallet::weight(T::WeightInfo::release_bid_funds_for())] + #[pallet::weight(WeightInfoOf::::release_bid_funds_for())] pub fn release_bid_funds_for( origin: OriginFor, project_id: T::ProjectIdentifier, @@ -1042,7 +1074,7 @@ pub mod pallet { } #[pallet::call_index(18)] - #[pallet::weight(T::WeightInfo::bid_unbond_for())] + #[pallet::weight(WeightInfoOf::::bid_unbond_for())] pub fn bid_unbond_for( origin: OriginFor, project_id: T::ProjectIdentifier, @@ -1054,7 +1086,7 @@ pub mod pallet { } #[pallet::call_index(19)] - #[pallet::weight(T::WeightInfo::release_contribution_funds_for())] + #[pallet::weight(WeightInfoOf::::release_contribution_funds_for())] pub fn release_contribution_funds_for( origin: OriginFor, project_id: T::ProjectIdentifier, @@ -1066,7 +1098,7 @@ pub mod pallet { } #[pallet::call_index(20)] - #[pallet::weight(T::WeightInfo::contribution_unbond_for())] + #[pallet::weight(WeightInfoOf::::contribution_unbond_for())] pub fn contribution_unbond_for( origin: OriginFor, project_id: T::ProjectIdentifier, @@ -1076,6 +1108,17 @@ pub mod pallet { let caller = ensure_signed(origin)?; Self::do_contribution_unbond_for(&caller, project_id, &contributor, contribution_id) } + + #[pallet::call_index(21)] + #[pallet::weight(Weight::from_parts(1000, 0))] + pub fn set_para_id_for_project( + origin: OriginFor, + project_id: T::ProjectIdentifier, + para_id: ParaId, + ) -> DispatchResult { + let caller = ensure_signed(origin)?; + Self::do_set_para_id_for_project(&caller, project_id, para_id) + } } #[pallet::hooks] @@ -1152,7 +1195,7 @@ pub mod pallet { projects_needing_cleanup.into_iter().enumerate().rev() { // TODO: Create this benchmark - // let mut consumed_weight = T::WeightInfo::insert_cleaned_project(); + // let mut consumed_weight = WeightInfoOf::::insert_cleaned_project(); let mut consumed_weight = Weight::from_parts(6_034_000, 0); while !consumed_weight.any_gt(max_weight_per_project) { if let Ok(weight) = cleaner.do_one_operation::(project_id) { @@ -1176,6 +1219,245 @@ pub mod pallet { max_weight.saturating_sub(remaining_weight) } } + + #[cfg(all(feature = "testing-node", feature = "std"))] + use frame_support::traits::{OnFinalize, OnIdle, OnInitialize, OriginTrait}; + + #[cfg(all(feature = "testing-node", feature = "std"))] + #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr( + feature = "std", + serde(rename_all = "camelCase", deny_unknown_fields, bound(serialize = ""), bound(deserialize = "")) + )] + #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode)] + pub struct TestProject { + pub expected_state: ProjectStatus, + pub metadata: ProjectMetadataOf, + pub issuer: AccountIdOf, + pub evaluations: Vec>, + pub bids: Vec>, + pub community_contributions: Vec>, + pub remainder_contributions: Vec>, + } + + #[pallet::genesis_config] + pub struct GenesisConfig { + #[cfg(all(feature = "testing-node", feature = "std"))] + pub starting_projects: Vec>, + pub phantom: PhantomData, + } + + #[cfg(all(feature = "testing-node", feature = "std"))] + impl Default for GenesisConfig + where + T: Config + pallet_balances::Config>, + T::AllPalletsWithoutSystem: + OnFinalize> + OnIdle> + OnInitialize>, + ::RuntimeEvent: From> + TryInto> + Parameter + Member, + // AccountIdOf: Into< as OriginTrait>::AccountId> + sp_std::fmt::Debug, + { + fn default() -> Self { + Self { starting_projects: vec![], phantom: PhantomData } + } + } + + #[cfg(not(all(feature = "testing-node", feature = "std")))] + impl Default for GenesisConfig { + fn default() -> Self { + Self { phantom: PhantomData } + } + } + + #[pallet::genesis_build] + #[cfg(not(all(feature = "testing-node", feature = "std")))] + impl GenesisBuild for GenesisConfig { + fn build(&self) {} + } + + #[cfg(all(feature = "testing-node", feature = "std"))] + impl GenesisBuild for GenesisConfig + where + T: Config + pallet_balances::Config>, + ::AllPalletsWithoutSystem: + OnFinalize> + OnIdle> + OnInitialize>, + ::RuntimeEvent: From> + TryInto> + Parameter + Member, + // AccountIdOf: Into< as OriginTrait>::AccountId> + sp_std::fmt::Debug, + ::Balance: Into>, + { + fn build(&self) { + { + type GenesisInstantiator = + instantiator::Instantiator::AllPalletsWithoutSystem, ::RuntimeEvent>; + let mut inst = GenesisInstantiator::::new(None); + + for test_project in self.starting_projects.clone() { + inst.create_project_at( + test_project.expected_state, + test_project.metadata, + test_project.issuer, + test_project.evaluations, + test_project.bids, + test_project.community_contributions, + test_project.remainder_contributions, + ); + } + } + } + } + + // #[cfg(feature = "std")] + #[cfg(all(feature = "testing-node", feature = "std"))] + impl GenesisConfig + where + T: Config + + frame_system::Config::RuntimeEvent> + + pallet_balances::Config>, + T::AllPalletsWithoutSystem: + OnFinalize> + OnIdle> + OnInitialize>, + ::RuntimeEvent: From> + TryInto> + Parameter + Member, + AccountIdOf: Into< as OriginTrait>::AccountId> + sp_std::fmt::Debug, + ::Balance: Into>, + { + /// Direct implementation of `GenesisBuild::build_storage`. + /// + /// Kept in order not to break dependency. + pub fn build_storage(&self) -> Result { + >::build_storage(self) + } + + /// Direct implementation of `GenesisBuild::assimilate_storage`. + /// + /// Kept in order not to break dependency. + pub fn assimilate_storage(&self, storage: &mut sp_runtime::Storage) -> Result<(), String> { + >::assimilate_storage(self, storage) + } + } +} + +pub mod xcm_executor_impl { + use super::*; + use crate::ProjectStatus::FundingSuccessful; + + pub struct HrmpChannelOpenRequestHandler(PhantomData<(T, XcmSender)>); + impl polimec_xcm_executor::HrmpChannelOpenRequestHandler + for HrmpChannelOpenRequestHandler + { + fn handle_channel_open_request(message: Instruction) -> XcmResult { + // TODO: set these constants with a proper value + const MAX_MESSAGE_SIZE_THRESHOLDS: (u32, u32) = (50000, 102_400); + const MAX_CAPACITY_THRESHOLDS: (u32, u32) = (8, 1000); + const REQUIRED_MAX_CAPACITY: u32 = 8u32; + const REQUIRED_MAX_MESSAGE_SIZE: u32 = 102_400u32; + const EXECUTION_DOT: MultiAsset = MultiAsset { + id: Concrete(MultiLocation { parents: 0, interior: Here }), + fun: Fungible(1_0_000_000_000u128), + }; + const MAX_WEIGHT: Weight = Weight::from_parts(20_000_000_000, 1_000_000); + const POLIMEC_PARA_ID: u32 = 3355u32; + + log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest received: {:?}", message); + + match message { + Instruction::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } + if max_message_size >= MAX_MESSAGE_SIZE_THRESHOLDS.0 && + max_message_size <= MAX_MESSAGE_SIZE_THRESHOLDS.1 && + max_capacity >= MAX_CAPACITY_THRESHOLDS.0 && + max_capacity <= MAX_CAPACITY_THRESHOLDS.1 => + { + log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest accepted"); + + let (project_id, mut project_details) = ProjectsDetails::::iter() + .find(|(_id, details)| { + details.parachain_id == Some(ParaId::from(sender)) && details.status == FundingSuccessful + }) + .ok_or(XcmError::BadOrigin)?; + + let accept_channel_relay_call = + polkadot_runtime::RuntimeCall::Hrmp(polkadot_runtime_parachains::hrmp::Call::< + polkadot_runtime::Runtime, + >::hrmp_accept_open_channel { + sender: ParaId::from(sender), + }) + .encode(); + + let request_channel_relay_call = + polkadot_runtime::RuntimeCall::Hrmp(polkadot_runtime_parachains::hrmp::Call::< + polkadot_runtime::Runtime, + >::hrmp_init_open_channel { + recipient: ParaId::from(sender), + proposed_max_capacity: REQUIRED_MAX_CAPACITY, + proposed_max_message_size: REQUIRED_MAX_MESSAGE_SIZE, + }) + .encode(); + + let xcm: Xcm<()> = Xcm(vec![ + WithdrawAsset(vec![EXECUTION_DOT.clone()].into()), + BuyExecution { fees: EXECUTION_DOT.clone(), weight_limit: Unlimited }, + Transact { + origin_kind: OriginKind::Native, + require_weight_at_most: MAX_WEIGHT, + call: accept_channel_relay_call.into(), + }, + Transact { + origin_kind: OriginKind::Native, + require_weight_at_most: MAX_WEIGHT, + call: request_channel_relay_call.into(), + }, + RefundSurplus, + DepositAsset { + assets: Wild(All), + beneficiary: MultiLocation { parents: 0, interior: X1(Parachain(POLIMEC_PARA_ID)) }, + }, + ]); + let mut message = Some(xcm); + + let dest_loc = MultiLocation { parents: 1, interior: Here }; + let mut destination = Some(dest_loc); + let (ticket, _price) = XcmSender::validate(&mut destination, &mut message)?; + + match XcmSender::deliver(ticket) { + Ok(_) => { + log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest: acceptance successfully sent"); + project_details.comm_status.project_to_polimec = ChannelStatus::Open; + project_details.comm_status.polimec_to_project = ChannelStatus::AwaitingAcceptance; + ProjectsDetails::::insert(project_id, project_details); + + Pallet::::deposit_event(Event::::HrmpChannelAccepted { + project_id, + para_id: ParaId::from(sender), + }); + Ok(()) + }, + Err(e) => { + log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest: acceptance sending failed - {:?}", e); + Err(XcmError::Unimplemented) + }, + } + }, + Instruction::HrmpChannelAccepted { recipient } => { + log::trace!(target: "pallet_funding::hrmp", "HrmpChannelAccepted received: {:?}", message); + let (project_id, mut project_details) = ProjectsDetails::::iter() + .find(|(_id, details)| { + details.parachain_id == Some(ParaId::from(recipient)) && details.status == FundingSuccessful + }) + .ok_or(XcmError::BadOrigin)?; + + project_details.comm_status.polimec_to_project = ChannelStatus::Open; + ProjectsDetails::::insert(project_id, project_details); + + Pallet::::deposit_event(Event::::HrmpChannelEstablished { + project_id, + para_id: ParaId::from(recipient), + }); + Ok(()) + }, + instr @ _ => { + log::trace!(target: "pallet_funding::hrmp", "Bad instruction: {:?}", instr); + Err(XcmError::Unimplemented) + }, + } + } + } } pub mod local_macros { diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index ec12dd8d8..afdc41824 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -240,7 +240,7 @@ impl pallet_linear_release::Config for TestRuntime { } impl Config for TestRuntime { - #[cfg(feature = "runtime-benchmarks")] + // #[cfg(feature = "runtime-benchmarks")] type AllPalletsWithoutSystem = AllPalletsWithoutSystem; type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; type Balance = Balance; diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 515035eca..e3945eef0 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -82,7 +82,7 @@ const BUYER_7: AccountId = 46; const ASSET_UNIT: u128 = 10_u128.pow(10 as u32); -const USDT_STATEMINT_ID: AssetId = 1984u32; +const USDT_STATEMINT_ID: crate::mock::AssetId = 1984u32; const USDT_UNIT: u128 = 10_000_000_000_u128; pub const US_DOLLAR: u128 = 1_0_000_000_000; @@ -6102,6 +6102,82 @@ mod funding_end { } } +mod ct_migration { + use super::*; + use frame_support::assert_err; + + #[test] + fn para_id_for_project_can_be_set_by_issuer() { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let project_id = inst.create_finished_project( + default_project(inst.get_new_nonce(), ISSUER), + ISSUER, + default_evaluations(), + default_bids(), + default_community_buys(), + vec![], + ); + inst.advance_time(::SuccessToSettlementTime::get() + 20u64).unwrap(); + let project_details = inst.get_project_details(project_id); + assert_eq!(project_details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); + + inst.execute(|| { + assert_ok!(crate::Pallet::::set_para_id_for_project( + RuntimeOrigin::signed(ISSUER), + project_id, + ParaId::from(2006u32) + )); + }); + let project_details = inst.get_project_details(project_id); + assert_eq!(project_details.parachain_id, Some(ParaId::from(2006u32))); + } + + #[test] + fn para_id_for_project_cannot_be_set_by_anyone_but_issuer() { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let project_id = inst.create_finished_project( + default_project(inst.get_new_nonce(), ISSUER), + ISSUER, + default_evaluations(), + default_bids(), + default_community_buys(), + vec![], + ); + inst.advance_time(::SuccessToSettlementTime::get() + 20u64).unwrap(); + let project_details = inst.get_project_details(project_id); + assert_eq!(project_details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); + + inst.execute(|| { + assert_err!( + crate::Pallet::::set_para_id_for_project( + RuntimeOrigin::signed(EVALUATOR_1), + project_id, + ParaId::from(2006u32) + ), + Error::::NotAllowed + ); + assert_err!( + crate::Pallet::::set_para_id_for_project( + RuntimeOrigin::signed(BIDDER_1), + project_id, + ParaId::from(2006u32) + ), + Error::::NotAllowed + ); + assert_err!( + crate::Pallet::::set_para_id_for_project( + RuntimeOrigin::signed(BUYER_1), + project_id, + ParaId::from(2006u32) + ), + Error::::NotAllowed + ); + }); + let project_details = inst.get_project_details(project_id); + assert_eq!(project_details.parachain_id, None); + } +} + mod test_helper_functions { use super::*; diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index 0cec97455..30fd235ce 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -19,6 +19,7 @@ //! Types for Funding pallet. use frame_support::{pallet_prelude::*, traits::tokens::Balance as BalanceT}; +use polkadot_parachain::primitives::Id as ParaId; use sp_arithmetic::{FixedPointNumber, FixedPointOperand}; use sp_runtime::traits::CheckedDiv; use sp_std::{cmp::Eq, collections::btree_map::*, prelude::*}; @@ -42,6 +43,7 @@ pub mod config_types { use super::*; #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen, Copy, Ord, PartialOrd)] + #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub struct Multiplier(u8); impl Multiplier { @@ -136,6 +138,7 @@ pub mod storage_types { use super::*; #[derive(Default, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] + #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub struct ProjectMetadata { /// Token Metadata pub token_information: CurrencyMetadata, @@ -198,8 +201,13 @@ pub mod storage_types { pub evaluation_round_info: EvaluationRoundInfo, /// When the Funding Round ends pub funding_end_block: Option, + /// ParaId of project + pub parachain_id: Option, + /// Migration readiness check + pub migration_readiness_check: Option, + /// Channel status + pub comm_status: CommStatus, } - /// Tells on_initialize what to do with the project #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub enum UpdateType { @@ -358,6 +366,7 @@ pub mod inner_types { use super::*; #[derive(Default, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] + #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub struct CurrencyMetadata { /// The user friendly name of this asset. Limited in length by `StringLimit`. pub name: BoundedString, @@ -368,6 +377,7 @@ pub mod inner_types { } #[derive(Default, Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] + #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub struct TicketSize { pub minimum: Option, pub maximum: Option, @@ -386,6 +396,7 @@ pub mod inner_types { } #[derive(Default, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] + #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub struct ParticipantsSize { pub minimum: Option, pub maximum: Option, @@ -411,6 +422,7 @@ pub mod inner_types { } #[derive(Default, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] + #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub struct Thresholds { #[codec(compact)] retail: u8, @@ -422,6 +434,7 @@ pub mod inner_types { // TODO: PLMC-157. Use SCALE fixed indexes #[derive(Default, Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] + #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum AcceptedFundingAsset { #[default] USDT, @@ -439,6 +452,7 @@ pub mod inner_types { } #[derive(Default, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] + #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum ProjectStatus { #[default] Application, @@ -451,10 +465,12 @@ pub mod inner_types { FundingFailed, AwaitingProjectDecision, FundingSuccessful, - ReadyToLaunch, + ReadyToStartMigration, + MigrationCompleted, } #[derive(Default, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] + #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] pub enum AuctionPhase { #[default] English, @@ -659,4 +675,24 @@ pub mod inner_types { AcceptFunding, RejectFunding, } + + #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] + pub enum MigrationReadinessCheck { + QuerySent, + CheckPassed, + CheckFailed, + } + + #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] + pub struct CommStatus { + pub project_to_polimec: ChannelStatus, + pub polimec_to_project: ChannelStatus, + } + + #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] + pub enum ChannelStatus { + Closed, + Open, + AwaitingAcceptance, + } } diff --git a/pallets/linear-release/Cargo.toml b/pallets/linear-release/Cargo.toml index 02d368e25..54d9769ce 100644 --- a/pallets/linear-release/Cargo.toml +++ b/pallets/linear-release/Cargo.toml @@ -47,6 +47,7 @@ std = [ "sp-io/std", "sp-runtime/std", "sp-std/std", + "xcm-builder?/std" ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", @@ -56,8 +57,8 @@ runtime-benchmarks = [ "pallet-funding", "polimec-traits/runtime-benchmarks", "sp-runtime/runtime-benchmarks", - "xcm-builder/runtime-benchmarks" - + "xcm-builder/runtime-benchmarks", + "pallet-funding?/runtime-benchmarks" ] try-runtime = [ "frame-support/try-runtime", diff --git a/pallets/parachain-staking/Cargo.toml b/pallets/parachain-staking/Cargo.toml index 34472254f..7c47de90e 100644 --- a/pallets/parachain-staking/Cargo.toml +++ b/pallets/parachain-staking/Cargo.toml @@ -62,7 +62,16 @@ std = [ "sp-std/std", "substrate-fixed/std", ] -runtime-benchmarks = [ "frame-benchmarking" ] +runtime-benchmarks = [ + "frame-benchmarking", + "frame-benchmarking?/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "sp-staking/runtime-benchmarks" +] try-runtime = [ "frame-support/try-runtime", "frame-system/try-runtime", diff --git a/pallets/sandbox/Cargo.toml b/pallets/sandbox/Cargo.toml index 233bee6cb..3627c8f37 100644 --- a/pallets/sandbox/Cargo.toml +++ b/pallets/sandbox/Cargo.toml @@ -46,6 +46,11 @@ default = [ "std" ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "pallet-funding/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "pallet-assets/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "sp-runtime/runtime-benchmarks" ] std = [ "frame-benchmarking?/std", @@ -73,3 +78,6 @@ try-runtime = [ "pallet-insecure-randomness-collective-flip/try-runtime", "sp-runtime/try-runtime", ] +testing-node = [ + "pallet-funding/testing-node" +] diff --git a/pallets/xcm-executor/Cargo.toml b/pallets/xcm-executor/Cargo.toml new file mode 100644 index 000000000..e8e2ff675 --- /dev/null +++ b/pallets/xcm-executor/Cargo.toml @@ -0,0 +1,47 @@ +[package] +name = "polimec-xcm-executor" +description = "An abstract and configurable XCM message executor." +authors.workspace = true +edition.workspace = true +version.workspace = true + +[dependencies] +impl-trait-for-tuples = "0.2.2" +environmental = { version = "1.1.4", default-features = false } +parity-scale-codec = { version = "3.4.0", default-features = false, features = ["derive"] } +xcm.workspace = true +sp-std.workspace = true +sp-io.workspace = true +sp-arithmetic.workspace = true +sp-core.workspace = true +sp-runtime.workspace = true +sp-weights.workspace = true +frame-support.workspace = true +log.workspace = true +frame-benchmarking = { workspace = true, optional = true} +xcm-executor.workspace = true + + +[features] +default = ["std"] +runtime-benchmarks = [ + "frame-benchmarking/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "xcm-executor/runtime-benchmarks" +] +std = [ + "parity-scale-codec/std", + "xcm/std", + "sp-std/std", + "sp-io/std", + "sp-arithmetic/std", + "sp-core/std", + "sp-runtime/std", + "sp-weights/std", + "frame-support/std", + "log/std", + "frame-benchmarking?/std", + "xcm-executor/std", + "environmental/std" +] diff --git a/pallets/xcm-executor/src/config.rs b/pallets/xcm-executor/src/config.rs new file mode 100644 index 000000000..e5cef49e5 --- /dev/null +++ b/pallets/xcm-executor/src/config.rs @@ -0,0 +1,121 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see . + +use frame_support::{ + dispatch::{Dispatchable, GetDispatchInfo, Parameter, PostDispatchInfo}, + traits::{Contains, ContainsPair, Get, PalletsInfoAccess}, +}; +use xcm::v3::{opaque::Instruction, prelude::*}; +use xcm_executor::traits::{ + AssetExchange, AssetLock, CallDispatcher, ClaimAssets, ConvertOrigin, DropAssets, ExportXcm, FeeManager, + OnResponse, ShouldExecute, TransactAsset, VersionChangeNotifier, WeightBounds, WeightTrader, +}; + +/// The trait to parameterize the `XcmExecutor`. +pub trait Config { + /// The outer call dispatch type. + type RuntimeCall: Parameter + Dispatchable + GetDispatchInfo; + + /// How to send an onward XCM message. + type XcmSender: SendXcm; + + /// How to withdraw and deposit an asset. + type AssetTransactor: TransactAsset; + + /// How to get a call origin from a `OriginKind` value. + type OriginConverter: ConvertOrigin<::RuntimeOrigin>; + + /// Combinations of (Asset, Location) pairs which we trust as reserves. + type IsReserve: ContainsPair; + + /// Combinations of (Asset, Location) pairs which we trust as teleporters. + type IsTeleporter: ContainsPair; + + /// This chain's Universal Location. + type UniversalLocation: Get; + + /// Whether we should execute the given XCM at all. + type Barrier: ShouldExecute; + + /// The means of determining an XCM message's weight. + type Weigher: WeightBounds; + + /// The means of purchasing weight credit for XCM execution. + type Trader: WeightTrader; + + /// What to do when a response of a query is found. + type ResponseHandler: OnResponse; + + /// The general asset trap - handler for when assets are left in the Holding Register at the + /// end of execution. + type AssetTrap: DropAssets; + + /// Handler for asset locking. + type AssetLocker: AssetLock; + + /// Handler for exchanging assets. + type AssetExchanger: AssetExchange; + + /// The handler for when there is an instruction to claim assets. + type AssetClaims: ClaimAssets; + + /// How we handle version subscription requests. + type SubscriptionService: VersionChangeNotifier; + + /// Information on all pallets. + type PalletInstancesInfo: PalletsInfoAccess; + + /// The maximum number of assets we target to have in the Holding Register at any one time. + /// + /// NOTE: In the worse case, the Holding Register may contain up to twice as many assets as this + /// and any benchmarks should take that into account. + type MaxAssetsIntoHolding: Get; + + /// Configure the fees. + type FeeManager: FeeManager; + + /// The method of exporting a message. + type MessageExporter: ExportXcm; + + /// The origin locations and specific universal junctions to which they are allowed to elevate + /// themselves. + type UniversalAliases: Contains<(MultiLocation, Junction)>; + + /// The call dispatcher used by XCM. + /// + /// XCM will use this to dispatch any calls. When no special call dispatcher is required, + /// this can be set to the same type as `Self::Call`. + type CallDispatcher: CallDispatcher; + + /// The safe call filter for `Transact`. + /// + /// Use this type to explicitly whitelist calls that cannot undergo recursion. This is a + /// temporary measure until we properly account for proof size weights for XCM instructions. + type SafeCallFilter: Contains; + + /// Polimec's custom type for handling the `HrmpNewChannelOpenRequest` instruction + type HrmpChannelOpenRequestHandler: HrmpChannelOpenRequestHandler; +} + +pub trait HrmpChannelOpenRequestHandler { + fn handle_channel_open_request(message: Instruction) -> XcmResult; +} + +impl HrmpChannelOpenRequestHandler for () { + fn handle_channel_open_request(_message: Instruction) -> XcmResult { + Err(XcmError::NoDeal) + } +} diff --git a/pallets/xcm-executor/src/lib.rs b/pallets/xcm-executor/src/lib.rs new file mode 100644 index 000000000..8a75b5f3c --- /dev/null +++ b/pallets/xcm-executor/src/lib.rs @@ -0,0 +1,956 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of Polkadot. + +// Polkadot is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Polkadot is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Polkadot. If not, see . + +#![cfg_attr(not(feature = "std"), no_std)] + +use frame_support::{ + dispatch::GetDispatchInfo, + ensure, + traits::{Contains, ContainsPair, Get, PalletsInfoAccess}, +}; +use parity_scale_codec::{Decode, Encode}; +use sp_core::defer; +use sp_io::hashing::blake2_128; +use sp_std::{marker::PhantomData, prelude::*}; +use sp_weights::Weight; +use xcm::latest::prelude::*; + +use xcm_executor::traits::{ + validate_export, AssetExchange, AssetLock, CallDispatcher, ClaimAssets, ConvertOrigin, DropAssets, Enact, + ExportXcm, FeeManager, FeeReason, OnResponse, ShouldExecute, TransactAsset, VersionChangeNotifier, WeightBounds, + WeightTrader, +}; + +use xcm_executor::Assets; +mod config; +pub use config::{Config, HrmpChannelOpenRequestHandler}; + +/// A struct to specify how fees are being paid. +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub struct FeesMode { + /// If true, then the fee assets are taken directly from the origin's on-chain account, + /// otherwise the fee assets are taken from the holding register. + /// + /// Defaults to false. + pub jit_withdraw: bool, +} + +const RECURSION_LIMIT: u8 = 10; + +environmental::environmental!(recursion_count: u8); + +/// The XCM executor. +pub struct XcmExecutor { + holding: Assets, + holding_limit: usize, + context: XcmContext, + original_origin: MultiLocation, + trader: Config::Trader, + /// The most recent error result and instruction index into the fragment in which it occurred, + /// if any. + error: Option<(u32, XcmError)>, + /// The surplus weight, defined as the amount by which `max_weight` is + /// an over-estimate of the actual weight consumed. We do it this way to avoid needing the + /// execution engine to keep track of all instructions' weights (it only needs to care about + /// the weight of dynamically determined instructions such as `Transact`). + total_surplus: Weight, + total_refunded: Weight, + error_handler: Xcm, + error_handler_weight: Weight, + appendix: Xcm, + appendix_weight: Weight, + transact_status: MaybeErrorCode, + fees_mode: FeesMode, + _config: PhantomData, +} + +#[cfg(feature = "runtime-benchmarks")] +impl XcmExecutor { + pub fn holding(&self) -> &Assets { + &self.holding + } + + pub fn set_holding(&mut self, v: Assets) { + self.holding = v + } + + pub fn holding_limit(&self) -> &usize { + &self.holding_limit + } + + pub fn set_holding_limit(&mut self, v: usize) { + self.holding_limit = v + } + + pub fn origin(&self) -> &Option { + &self.context.origin + } + + pub fn set_origin(&mut self, v: Option) { + self.context.origin = v + } + + pub fn original_origin(&self) -> &MultiLocation { + &self.original_origin + } + + pub fn set_original_origin(&mut self, v: MultiLocation) { + self.original_origin = v + } + + pub fn trader(&self) -> &Config::Trader { + &self.trader + } + + pub fn set_trader(&mut self, v: Config::Trader) { + self.trader = v + } + + pub fn error(&self) -> &Option<(u32, XcmError)> { + &self.error + } + + pub fn set_error(&mut self, v: Option<(u32, XcmError)>) { + self.error = v + } + + pub fn total_surplus(&self) -> &Weight { + &self.total_surplus + } + + pub fn set_total_surplus(&mut self, v: Weight) { + self.total_surplus = v + } + + pub fn total_refunded(&self) -> &Weight { + &self.total_refunded + } + + pub fn set_total_refunded(&mut self, v: Weight) { + self.total_refunded = v + } + + pub fn error_handler(&self) -> &Xcm { + &self.error_handler + } + + pub fn set_error_handler(&mut self, v: Xcm) { + self.error_handler = v + } + + pub fn error_handler_weight(&self) -> &Weight { + &self.error_handler_weight + } + + pub fn set_error_handler_weight(&mut self, v: Weight) { + self.error_handler_weight = v + } + + pub fn appendix(&self) -> &Xcm { + &self.appendix + } + + pub fn set_appendix(&mut self, v: Xcm) { + self.appendix = v + } + + pub fn appendix_weight(&self) -> &Weight { + &self.appendix_weight + } + + pub fn set_appendix_weight(&mut self, v: Weight) { + self.appendix_weight = v + } + + pub fn transact_status(&self) -> &MaybeErrorCode { + &self.transact_status + } + + pub fn set_transact_status(&mut self, v: MaybeErrorCode) { + self.transact_status = v + } + + pub fn fees_mode(&self) -> &FeesMode { + &self.fees_mode + } + + pub fn set_fees_mode(&mut self, v: FeesMode) { + self.fees_mode = v + } + + pub fn topic(&self) -> &Option<[u8; 32]> { + &self.context.topic + } + + pub fn set_topic(&mut self, v: Option<[u8; 32]>) { + self.context.topic = v; + } +} + +pub struct WeighedMessage(Weight, Xcm); +impl PreparedMessage for WeighedMessage { + fn weight_of(&self) -> Weight { + self.0 + } +} + +impl ExecuteXcm for XcmExecutor { + type Prepared = WeighedMessage; + + fn prepare(mut message: Xcm) -> Result> { + match Config::Weigher::weight(&mut message) { + Ok(weight) => Ok(WeighedMessage(weight, message)), + Err(_) => Err(message), + } + } + + fn execute( + origin: impl Into, + WeighedMessage(xcm_weight, mut message): WeighedMessage, + message_hash: XcmHash, + mut weight_credit: Weight, + ) -> Outcome { + let origin = origin.into(); + log::trace!( + target: "xcm::execute_xcm_in_credit", + "origin: {:?}, message: {:?}, weight_credit: {:?}", + origin, + message, + weight_credit, + ); + if let Err(e) = Config::Barrier::should_execute(&origin, message.inner_mut(), xcm_weight, &mut weight_credit) { + log::trace!( + target: "xcm::execute_xcm_in_credit", + "Barrier blocked execution! Error: {:?}. (origin: {:?}, message: {:?}, weight_credit: {:?})", + e, + origin, + message, + weight_credit, + ); + return Outcome::Error(XcmError::Barrier) + } + + let mut vm = Self::new(origin, message_hash); + + while !message.0.is_empty() { + let result = vm.process(message); + log::trace!(target: "xcm::execute_xcm_in_credit", "result: {:?}", result); + message = if let Err(error) = result { + vm.total_surplus.saturating_accrue(error.weight); + vm.error = Some((error.index, error.xcm_error)); + vm.take_error_handler().or_else(|| vm.take_appendix()) + } else { + vm.drop_error_handler(); + vm.take_appendix() + } + } + + vm.post_process(xcm_weight) + } + + fn charge_fees(origin: impl Into, fees: MultiAssets) -> XcmResult { + let origin = origin.into(); + if !Config::FeeManager::is_waived(Some(&origin), FeeReason::ChargeFees) { + for asset in fees.inner() { + Config::AssetTransactor::withdraw_asset(&asset, &origin, None)?; + } + Config::FeeManager::handle_fee(fees); + } + Ok(()) + } +} + +#[derive(Debug)] +pub struct ExecutorError { + pub index: u32, + pub xcm_error: XcmError, + pub weight: Weight, +} + +#[cfg(feature = "runtime-benchmarks")] +impl From for frame_benchmarking::BenchmarkError { + fn from(error: ExecutorError) -> Self { + log::error!("XCM ERROR >> Index: {:?}, Error: {:?}, Weight: {:?}", error.index, error.xcm_error, error.weight); + Self::Stop("xcm executor error: see error logs") + } +} + +impl XcmExecutor { + pub fn new(origin: impl Into, message_hash: XcmHash) -> Self { + let origin = origin.into(); + Self { + holding: Assets::new(), + holding_limit: Config::MaxAssetsIntoHolding::get() as usize, + context: XcmContext { origin: Some(origin), message_hash, topic: None }, + original_origin: origin, + trader: Config::Trader::new(), + error: None, + total_surplus: Weight::zero(), + total_refunded: Weight::zero(), + error_handler: Xcm(vec![]), + error_handler_weight: Weight::zero(), + appendix: Xcm(vec![]), + appendix_weight: Weight::zero(), + transact_status: Default::default(), + fees_mode: FeesMode { jit_withdraw: false }, + _config: PhantomData, + } + } + + #[cfg(feature = "runtime-benchmarks")] + pub fn bench_process(&mut self, xcm: Xcm) -> Result<(), ExecutorError> { + self.process(xcm) + } + + fn process(&mut self, xcm: Xcm) -> Result<(), ExecutorError> { + log::trace!( + target: "xcm::process", + "origin: {:?}, total_surplus/refunded: {:?}/{:?}, error_handler_weight: {:?}", + self.origin_ref(), + self.total_surplus, + self.total_refunded, + self.error_handler_weight, + ); + let mut result = Ok(()); + for (i, instr) in xcm.0.into_iter().enumerate() { + match &mut result { + r @ Ok(()) => { + // Initialize the recursion count only the first time we hit this code in our + // potential recursive execution. + let inst_res = recursion_count::using_once(&mut 1, || { + recursion_count::with(|count| { + if *count > RECURSION_LIMIT { + return Err(XcmError::ExceedsStackLimit) + } + *count = count.saturating_add(1); + Ok(()) + }) + // This should always return `Some`, but let's play it safe. + .unwrap_or(Ok(()))?; + + // Ensure that we always decrement the counter whenever we finish processing + // the instruction. + defer! { + recursion_count::with(|count| { + *count = count.saturating_sub(1); + }); + } + + self.process_instruction(instr) + }); + if let Err(e) = inst_res { + log::trace!(target: "xcm::execute", "!!! ERROR: {:?}", e); + *r = Err(ExecutorError { index: i as u32, xcm_error: e, weight: Weight::zero() }); + } + }, + Err(ref mut error) => + if let Ok(x) = Config::Weigher::instr_weight(&instr) { + error.weight.saturating_accrue(x) + }, + } + } + result + } + + /// Execute any final operations after having executed the XCM message. + /// This includes refunding surplus weight, trapping extra holding funds, and returning any errors during execution. + pub fn post_process(mut self, xcm_weight: Weight) -> Outcome { + // We silently drop any error from our attempt to refund the surplus as it's a charitable + // thing so best-effort is all we will do. + let _ = self.refund_surplus(); + drop(self.trader); + + let mut weight_used = xcm_weight.saturating_sub(self.total_surplus); + + if !self.holding.is_empty() { + log::trace!( + target: "xcm::execute_xcm_in_credit", + "Trapping assets in holding register: {:?}, context: {:?} (original_origin: {:?})", + self.holding, self.context, self.original_origin, + ); + let effective_origin = self.context.origin.as_ref().unwrap_or(&self.original_origin); + let trap_weight = Config::AssetTrap::drop_assets(effective_origin, self.holding, &self.context); + weight_used.saturating_accrue(trap_weight); + }; + + match self.error { + None => Outcome::Complete(weight_used), + // TODO: #2841 #REALWEIGHT We should deduct the cost of any instructions following + // the error which didn't end up being executed. + Some((_i, e)) => { + log::trace!(target: "xcm::execute_xcm_in_credit", "Execution errored at {:?}: {:?} (original_origin: {:?})", _i, e, self.original_origin); + Outcome::Incomplete(weight_used, e) + }, + } + } + + fn origin_ref(&self) -> Option<&MultiLocation> { + self.context.origin.as_ref() + } + + fn cloned_origin(&self) -> Option { + self.context.origin + } + + /// Send an XCM, charging fees from Holding as needed. + fn send(&mut self, dest: MultiLocation, msg: Xcm<()>, reason: FeeReason) -> Result { + let (ticket, fee) = validate_send::(dest, msg)?; + if !Config::FeeManager::is_waived(self.origin_ref(), reason) { + let paid = self.holding.try_take(fee.into()).map_err(|_| XcmError::NotHoldingFees)?; + Config::FeeManager::handle_fee(paid.into()); + } + Config::XcmSender::deliver(ticket).map_err(Into::into) + } + + /// Remove the registered error handler and return it. Do not refund its weight. + fn take_error_handler(&mut self) -> Xcm { + let mut r = Xcm::(vec![]); + sp_std::mem::swap(&mut self.error_handler, &mut r); + self.error_handler_weight = Weight::zero(); + r + } + + /// Drop the registered error handler and refund its weight. + fn drop_error_handler(&mut self) { + self.error_handler = Xcm::(vec![]); + self.total_surplus.saturating_accrue(self.error_handler_weight); + self.error_handler_weight = Weight::zero(); + } + + /// Remove the registered appendix and return it. + fn take_appendix(&mut self) -> Xcm { + let mut r = Xcm::(vec![]); + sp_std::mem::swap(&mut self.appendix, &mut r); + self.appendix_weight = Weight::zero(); + r + } + + fn subsume_asset(&mut self, asset: MultiAsset) -> Result<(), XcmError> { + // worst-case, holding.len becomes 2 * holding_limit. + ensure!(self.holding.len() < self.holding_limit * 2, XcmError::HoldingWouldOverflow); + self.holding.subsume(asset); + Ok(()) + } + + fn subsume_assets(&mut self, assets: Assets) -> Result<(), XcmError> { + // worst-case, holding.len becomes 2 * holding_limit. + // this guarantees that if holding.len() == holding_limit and you have holding_limit more + // items (which has a best case outcome of holding.len() == holding_limit), then you'll + // be guaranteed of making the operation. + let worst_case_holding_len = self.holding.len() + assets.len(); + ensure!(worst_case_holding_len <= self.holding_limit * 2, XcmError::HoldingWouldOverflow); + self.holding.subsume_assets(assets); + Ok(()) + } + + /// Refund any unused weight. + fn refund_surplus(&mut self) -> Result<(), XcmError> { + let current_surplus = self.total_surplus.saturating_sub(self.total_refunded); + if current_surplus.any_gt(Weight::zero()) { + self.total_refunded.saturating_accrue(current_surplus); + if let Some(w) = self.trader.refund_weight(current_surplus) { + self.subsume_asset(w)?; + } + } + Ok(()) + } + + /// Process a single XCM instruction, mutating the state of the XCM virtual machine. + fn process_instruction(&mut self, instr: Instruction) -> Result<(), XcmError> { + log::trace!( + target: "xcm::process_instruction", + "=== {:?}", + instr + ); + match instr { + WithdrawAsset(assets) => { + // Take `assets` from the origin account (on-chain) and place in holding. + let origin = *self.origin_ref().ok_or(XcmError::BadOrigin)?; + for asset in assets.into_inner().into_iter() { + Config::AssetTransactor::withdraw_asset(&asset, &origin, Some(&self.context))?; + self.subsume_asset(asset)?; + } + Ok(()) + }, + ReserveAssetDeposited(assets) => { + // check whether we trust origin to be our reserve location for this asset. + let origin = *self.origin_ref().ok_or(XcmError::BadOrigin)?; + for asset in assets.into_inner().into_iter() { + // Must ensure that we recognise the asset as being managed by the origin. + ensure!(Config::IsReserve::contains(&asset, &origin), XcmError::UntrustedReserveLocation); + self.subsume_asset(asset)?; + } + Ok(()) + }, + TransferAsset { assets, beneficiary } => { + // Take `assets` from the origin account (on-chain) and place into dest account. + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?; + for asset in assets.inner() { + Config::AssetTransactor::transfer_asset(&asset, origin, &beneficiary, &self.context)?; + } + Ok(()) + }, + TransferReserveAsset { mut assets, dest, xcm } => { + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?; + // Take `assets` from the origin account (on-chain) and place into dest account. + for asset in assets.inner() { + Config::AssetTransactor::transfer_asset(asset, origin, &dest, &self.context)?; + } + let reanchor_context = Config::UniversalLocation::get(); + assets.reanchor(&dest, reanchor_context).map_err(|()| XcmError::LocationFull)?; + let mut message = vec![ReserveAssetDeposited(assets), ClearOrigin]; + message.extend(xcm.0.into_iter()); + self.send(dest, Xcm(message), FeeReason::TransferReserveAsset)?; + Ok(()) + }, + ReceiveTeleportedAsset(assets) => { + let origin = *self.origin_ref().ok_or(XcmError::BadOrigin)?; + // check whether we trust origin to teleport this asset to us via config trait. + for asset in assets.inner() { + // We only trust the origin to send us assets that they identify as their + // sovereign assets. + ensure!(Config::IsTeleporter::contains(asset, &origin), XcmError::UntrustedTeleportLocation); + // We should check that the asset can actually be teleported in (for this to be in error, there + // would need to be an accounting violation by one of the trusted chains, so it's unlikely, but we + // don't want to punish a possibly innocent chain/user). + Config::AssetTransactor::can_check_in(&origin, asset, &self.context)?; + } + for asset in assets.into_inner().into_iter() { + Config::AssetTransactor::check_in(&origin, &asset, &self.context); + self.subsume_asset(asset)?; + } + Ok(()) + }, + Transact { origin_kind, require_weight_at_most, mut call } => { + // We assume that the Relay-chain is allowed to use transact on this parachain. + let origin = *self.origin_ref().ok_or(XcmError::BadOrigin)?; + + // TODO: #2841 #TRANSACTFILTER allow the trait to issue filters for the relay-chain + let message_call = call.take_decoded().map_err(|_| XcmError::FailedToDecode)?; + ensure!(Config::SafeCallFilter::contains(&message_call), XcmError::NoPermission); + let dispatch_origin = + Config::OriginConverter::convert_origin(origin, origin_kind).map_err(|_| XcmError::BadOrigin)?; + let weight = message_call.get_dispatch_info().weight; + ensure!(weight.all_lte(require_weight_at_most), XcmError::MaxWeightInvalid); + let maybe_actual_weight = match Config::CallDispatcher::dispatch(message_call, dispatch_origin) { + Ok(post_info) => { + self.transact_status = MaybeErrorCode::Success; + post_info.actual_weight + }, + Err(error_and_info) => { + self.transact_status = error_and_info.error.encode().into(); + error_and_info.post_info.actual_weight + }, + }; + let actual_weight = maybe_actual_weight.unwrap_or(weight); + let surplus = weight.saturating_sub(actual_weight); + // We assume that the `Config::Weigher` will counts the `require_weight_at_most` + // for the estimate of how much weight this instruction will take. Now that we know + // that it's less, we credit it. + // + // We make the adjustment for the total surplus, which is used eventually + // reported back to the caller and this ensures that they account for the total + // weight consumed correctly (potentially allowing them to do more operations in a + // block than they otherwise would). + self.total_surplus.saturating_accrue(surplus); + Ok(()) + }, + QueryResponse { query_id, response, max_weight, querier } => { + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?; + Config::ResponseHandler::on_response( + origin, + query_id, + querier.as_ref(), + response, + max_weight, + &self.context, + ); + Ok(()) + }, + DescendOrigin(who) => self + .context + .origin + .as_mut() + .ok_or(XcmError::BadOrigin)? + .append_with(who) + .map_err(|_| XcmError::LocationFull), + ClearOrigin => { + self.context.origin = None; + Ok(()) + }, + ReportError(response_info) => { + // Report the given result by sending a QueryResponse XCM to a previously given outcome + // destination if one was registered. + self.respond( + self.cloned_origin(), + Response::ExecutionResult(self.error), + response_info, + FeeReason::Report, + )?; + Ok(()) + }, + DepositAsset { assets, beneficiary } => { + let deposited = self.holding.saturating_take(assets); + for asset in deposited.into_assets_iter() { + Config::AssetTransactor::deposit_asset(&asset, &beneficiary, &self.context)?; + } + Ok(()) + }, + DepositReserveAsset { assets, dest, xcm } => { + let deposited = self.holding.saturating_take(assets); + for asset in deposited.assets_iter() { + Config::AssetTransactor::deposit_asset(&asset, &dest, &self.context)?; + } + // Note that we pass `None` as `maybe_failed_bin` and drop any assets which cannot + // be reanchored because we have already called `deposit_asset` on all assets. + let assets = Self::reanchored(deposited, &dest, None); + let mut message = vec![ReserveAssetDeposited(assets), ClearOrigin]; + message.extend(xcm.0.into_iter()); + self.send(dest, Xcm(message), FeeReason::DepositReserveAsset)?; + Ok(()) + }, + InitiateReserveWithdraw { assets, reserve, xcm } => { + // Note that here we are able to place any assets which could not be reanchored + // back into Holding. + let assets = Self::reanchored(self.holding.saturating_take(assets), &reserve, Some(&mut self.holding)); + let mut message = vec![WithdrawAsset(assets), ClearOrigin]; + message.extend(xcm.0.into_iter()); + self.send(reserve, Xcm(message), FeeReason::InitiateReserveWithdraw)?; + Ok(()) + }, + InitiateTeleport { assets, dest, xcm } => { + // We must do this first in order to resolve wildcards. + let assets = self.holding.saturating_take(assets); + for asset in assets.assets_iter() { + // We should check that the asset can actually be teleported out (for this to + // be in error, there would need to be an accounting violation by ourselves, + // so it's unlikely, but we don't want to allow that kind of bug to leak into + // a trusted chain. + Config::AssetTransactor::can_check_out(&dest, &asset, &self.context)?; + } + for asset in assets.assets_iter() { + Config::AssetTransactor::check_out(&dest, &asset, &self.context); + } + // Note that we pass `None` as `maybe_failed_bin` and drop any assets which cannot + // be reanchored because we have already checked all assets out. + let assets = Self::reanchored(assets, &dest, None); + let mut message = vec![ReceiveTeleportedAsset(assets), ClearOrigin]; + message.extend(xcm.0.into_iter()); + self.send(dest, Xcm(message), FeeReason::InitiateTeleport)?; + Ok(()) + }, + ReportHolding { response_info, assets } => { + // Note that we pass `None` as `maybe_failed_bin` since no assets were ever removed + // from Holding. + let assets = Self::reanchored(self.holding.min(&assets), &response_info.destination, None); + self.respond(self.cloned_origin(), Response::Assets(assets), response_info, FeeReason::Report)?; + Ok(()) + }, + BuyExecution { fees, weight_limit } => { + // There is no need to buy any weight is `weight_limit` is `Unlimited` since it + // would indicate that `AllowTopLevelPaidExecutionFrom` was unused for execution + // and thus there is some other reason why it has been determined that this XCM + // should be executed. + if let Some(weight) = Option::::from(weight_limit) { + // pay for `weight` using up to `fees` of the holding register. + let max_fee = self.holding.try_take(fees.into()).map_err(|_| XcmError::NotHoldingFees)?; + let unspent = self.trader.buy_weight(weight, max_fee)?; + self.subsume_assets(unspent)?; + } + Ok(()) + }, + RefundSurplus => self.refund_surplus(), + SetErrorHandler(mut handler) => { + let handler_weight = + Config::Weigher::weight(&mut handler).map_err(|()| XcmError::WeightNotComputable)?; + self.total_surplus.saturating_accrue(self.error_handler_weight); + self.error_handler = handler; + self.error_handler_weight = handler_weight; + Ok(()) + }, + SetAppendix(mut appendix) => { + let appendix_weight = + Config::Weigher::weight(&mut appendix).map_err(|()| XcmError::WeightNotComputable)?; + self.total_surplus.saturating_accrue(self.appendix_weight); + self.appendix = appendix; + self.appendix_weight = appendix_weight; + Ok(()) + }, + ClearError => { + self.error = None; + Ok(()) + }, + ClaimAsset { assets, ticket } => { + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?; + let ok = Config::AssetClaims::claim_assets(origin, &ticket, &assets, &self.context); + ensure!(ok, XcmError::UnknownClaim); + for asset in assets.into_inner().into_iter() { + self.subsume_asset(asset)?; + } + Ok(()) + }, + Trap(code) => Err(XcmError::Trap(code)), + SubscribeVersion { query_id, max_response_weight } => { + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?; + // We don't allow derivative origins to subscribe since it would otherwise pose a + // DoS risk. + ensure!(&self.original_origin == origin, XcmError::BadOrigin); + Config::SubscriptionService::start(origin, query_id, max_response_weight, &self.context) + }, + UnsubscribeVersion => { + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?; + ensure!(&self.original_origin == origin, XcmError::BadOrigin); + Config::SubscriptionService::stop(origin, &self.context) + }, + BurnAsset(assets) => { + self.holding.saturating_take(assets.into()); + Ok(()) + }, + ExpectAsset(assets) => self.holding.ensure_contains(&assets).map_err(|_| XcmError::ExpectationFalse), + ExpectOrigin(origin) => { + ensure!(self.context.origin == origin, XcmError::ExpectationFalse); + Ok(()) + }, + ExpectError(error) => { + ensure!(self.error == error, XcmError::ExpectationFalse); + Ok(()) + }, + ExpectTransactStatus(transact_status) => { + ensure!(self.transact_status == transact_status, XcmError::ExpectationFalse); + Ok(()) + }, + QueryPallet { module_name, response_info } => { + let pallets = Config::PalletInstancesInfo::infos() + .into_iter() + .filter(|x| x.module_name.as_bytes() == &module_name[..]) + .map(|x| { + PalletInfo::new( + x.index as u32, + x.name.as_bytes().into(), + x.module_name.as_bytes().into(), + x.crate_version.major as u32, + x.crate_version.minor as u32, + x.crate_version.patch as u32, + ) + }) + .collect::, XcmError>>()?; + let QueryResponseInfo { destination, query_id, max_weight } = response_info; + let response = Response::PalletsInfo(pallets.try_into().map_err(|_| XcmError::Overflow)?); + let querier = Self::to_querier(self.cloned_origin(), &destination)?; + let instruction = QueryResponse { query_id, response, max_weight, querier }; + let message = Xcm(vec![instruction]); + self.send(destination, message, FeeReason::QueryPallet)?; + Ok(()) + }, + ExpectPallet { index, name, module_name, crate_major, min_crate_minor } => { + let pallet = Config::PalletInstancesInfo::infos() + .into_iter() + .find(|x| x.index == index as usize) + .ok_or(XcmError::PalletNotFound)?; + ensure!(pallet.name.as_bytes() == &name[..], XcmError::NameMismatch); + ensure!(pallet.module_name.as_bytes() == &module_name[..], XcmError::NameMismatch); + let major = pallet.crate_version.major as u32; + ensure!(major == crate_major, XcmError::VersionIncompatible); + let minor = pallet.crate_version.minor as u32; + ensure!(minor >= min_crate_minor, XcmError::VersionIncompatible); + Ok(()) + }, + ReportTransactStatus(response_info) => { + self.respond( + self.cloned_origin(), + Response::DispatchResult(self.transact_status.clone()), + response_info, + FeeReason::Report, + )?; + Ok(()) + }, + ClearTransactStatus => { + self.transact_status = Default::default(); + Ok(()) + }, + UniversalOrigin(new_global) => { + let universal_location = Config::UniversalLocation::get(); + ensure!(universal_location.first() != Some(&new_global), XcmError::InvalidLocation); + let origin = *self.origin_ref().ok_or(XcmError::BadOrigin)?; + let origin_xform = (origin, new_global); + let ok = Config::UniversalAliases::contains(&origin_xform); + ensure!(ok, XcmError::InvalidLocation); + let (_, new_global) = origin_xform; + let new_origin = X1(new_global).relative_to(&universal_location); + self.context.origin = Some(new_origin); + Ok(()) + }, + ExportMessage { network, destination, xcm } => { + // The actual message sent to the bridge for forwarding is prepended with `UniversalOrigin` + // and `DescendOrigin` in order to ensure that the message is executed with this Origin. + // + // Prepend the desired message with instructions which effectively rewrite the origin. + // + // This only works because the remote chain empowers the bridge + // to speak for the local network. + let origin = self.context.origin.ok_or(XcmError::BadOrigin)?; + let universal_source = + Config::UniversalLocation::get().within_global(origin).map_err(|()| XcmError::Unanchored)?; + let hash = (self.origin_ref(), &destination).using_encoded(blake2_128); + let channel = u32::decode(&mut hash.as_ref()).unwrap_or(0); + // Hash identifies the lane on the exporter which we use. We use the pairwise + // combination of the origin and destination to ensure origin/destination pairs will + // generally have their own lanes. + let (ticket, fee) = + validate_export::(network, channel, universal_source, destination, xcm)?; + self.take_fee(fee, FeeReason::Export(network))?; + Config::MessageExporter::deliver(ticket)?; + Ok(()) + }, + LockAsset { asset, unlocker } => { + let origin = *self.origin_ref().ok_or(XcmError::BadOrigin)?; + let (remote_asset, context) = Self::try_reanchor(asset.clone(), &unlocker)?; + let lock_ticket = Config::AssetLocker::prepare_lock(unlocker, asset, origin)?; + let owner = origin.reanchored(&unlocker, context).map_err(|_| XcmError::ReanchorFailed)?; + let msg = Xcm::<()>(vec![NoteUnlockable { asset: remote_asset, owner }]); + let (ticket, price) = validate_send::(unlocker, msg)?; + self.take_fee(price, FeeReason::LockAsset)?; + lock_ticket.enact()?; + Config::XcmSender::deliver(ticket)?; + Ok(()) + }, + UnlockAsset { asset, target } => { + let origin = *self.origin_ref().ok_or(XcmError::BadOrigin)?; + Config::AssetLocker::prepare_unlock(origin, asset, target)?.enact()?; + Ok(()) + }, + NoteUnlockable { asset, owner } => { + let origin = *self.origin_ref().ok_or(XcmError::BadOrigin)?; + Config::AssetLocker::note_unlockable(origin, asset, owner)?; + Ok(()) + }, + RequestUnlock { asset, locker } => { + let origin = *self.origin_ref().ok_or(XcmError::BadOrigin)?; + let remote_asset = Self::try_reanchor(asset.clone(), &locker)?.0; + let reduce_ticket = Config::AssetLocker::prepare_reduce_unlockable(locker, asset, origin)?; + let msg = Xcm::<()>(vec![UnlockAsset { asset: remote_asset, target: origin }]); + let (ticket, price) = validate_send::(locker, msg)?; + self.take_fee(price, FeeReason::RequestUnlock)?; + reduce_ticket.enact()?; + Config::XcmSender::deliver(ticket)?; + Ok(()) + }, + ExchangeAsset { give, want, maximal } => { + let give = self.holding.saturating_take(give); + let r = Config::AssetExchanger::exchange_asset(self.origin_ref(), give, &want, maximal); + let completed = r.is_ok(); + let received = r.unwrap_or_else(|a| a); + for asset in received.into_assets_iter() { + self.holding.subsume(asset); + } + if completed { + Ok(()) + } else { + Err(XcmError::NoDeal) + } + }, + SetFeesMode { jit_withdraw } => { + self.fees_mode = FeesMode { jit_withdraw }; + Ok(()) + }, + SetTopic(topic) => { + self.context.topic = Some(topic); + Ok(()) + }, + ClearTopic => { + self.context.topic = None; + Ok(()) + }, + AliasOrigin(_) => Err(XcmError::NoPermission), + UnpaidExecution { check_origin, .. } => { + ensure!(check_origin.is_none() || self.context.origin == check_origin, XcmError::BadOrigin); + Ok(()) + }, + msg @ HrmpNewChannelOpenRequest { .. } => + Config::HrmpChannelOpenRequestHandler::handle_channel_open_request(msg.into()), + HrmpChannelAccepted { .. } => Err(XcmError::Unimplemented), + HrmpChannelClosing { .. } => Err(XcmError::Unimplemented), + } + } + + fn take_fee(&mut self, fee: MultiAssets, reason: FeeReason) -> XcmResult { + if Config::FeeManager::is_waived(self.origin_ref(), reason) { + return Ok(()) + } + let paid = if self.fees_mode.jit_withdraw { + let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?; + for asset in fee.inner() { + Config::AssetTransactor::withdraw_asset(&asset, origin, Some(&self.context))?; + } + fee + } else { + self.holding.try_take(fee.into()).map_err(|_| XcmError::NotHoldingFees)?.into() + }; + Config::FeeManager::handle_fee(paid); + Ok(()) + } + + /// Calculates what `local_querier` would be from the perspective of `destination`. + fn to_querier( + local_querier: Option, + destination: &MultiLocation, + ) -> Result, XcmError> { + Ok(match local_querier { + None => None, + Some(q) => Some( + q.reanchored(&destination, Config::UniversalLocation::get()).map_err(|_| XcmError::ReanchorFailed)?, + ), + }) + } + + /// Send a bare `QueryResponse` message containing `response` informed by the given `info`. + /// + /// The `local_querier` argument is the querier (if any) specified from the *local* perspective. + fn respond( + &mut self, + local_querier: Option, + response: Response, + info: QueryResponseInfo, + fee_reason: FeeReason, + ) -> Result { + let querier = Self::to_querier(local_querier, &info.destination)?; + let QueryResponseInfo { destination, query_id, max_weight } = info; + let instruction = QueryResponse { query_id, response, max_weight, querier }; + let message = Xcm(vec![instruction]); + let (ticket, fee) = validate_send::(destination, message)?; + if !Config::FeeManager::is_waived(self.origin_ref(), fee_reason) { + let paid = self.holding.try_take(fee.into()).map_err(|_| XcmError::NotHoldingFees)?; + Config::FeeManager::handle_fee(paid.into()); + } + Config::XcmSender::deliver(ticket).map_err(Into::into) + } + + fn try_reanchor( + asset: MultiAsset, + destination: &MultiLocation, + ) -> Result<(MultiAsset, InteriorMultiLocation), XcmError> { + let reanchor_context = Config::UniversalLocation::get(); + let asset = asset.reanchored(&destination, reanchor_context).map_err(|()| XcmError::ReanchorFailed)?; + Ok((asset, reanchor_context)) + } + + /// NOTE: Any assets which were unable to be reanchored are introduced into `failed_bin`. + fn reanchored(mut assets: Assets, dest: &MultiLocation, maybe_failed_bin: Option<&mut Assets>) -> MultiAssets { + let reanchor_context = Config::UniversalLocation::get(); + assets.reanchor(dest, reanchor_context, maybe_failed_bin); + assets.into_assets_iter().collect::>().into() + } +} diff --git a/runtimes/base/Cargo.toml b/runtimes/base/Cargo.toml index a0f0d044d..204e2f2cd 100644 --- a/runtimes/base/Cargo.toml +++ b/runtimes/base/Cargo.toml @@ -18,7 +18,7 @@ parity-scale-codec = { version = "3.6.5", default-features = false, features = [ "derive", ] } hex-literal = { version = "0.3.4", optional = true } -log = { version = "0.4.20", default-features = false } +log.workspace = true scale-info = { version = "2.9.0", default-features = false, features = [ "derive", ] } @@ -153,6 +153,13 @@ runtime-benchmarks = [ "shared-configuration/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", + "cumulus-pallet-parachain-system/runtime-benchmarks", + "pallet-sudo/runtime-benchmarks", + "pallet-treasury/runtime-benchmarks", + "polkadot-parachain/runtime-benchmarks", + "polkadot-primitives/runtime-benchmarks", + "polkadot-runtime-common/runtime-benchmarks", + "xcm-executor/runtime-benchmarks" ] try-runtime = [ @@ -179,3 +186,6 @@ try-runtime = [ "polkadot-runtime-common/try-runtime", "sp-runtime/try-runtime", ] +testing-node = [ + "shared-configuration/testing-node" +] diff --git a/runtimes/shared-configuration/Cargo.toml b/runtimes/shared-configuration/Cargo.toml index 0b1dadc3f..4a0f11bcc 100644 --- a/runtimes/shared-configuration/Cargo.toml +++ b/runtimes/shared-configuration/Cargo.toml @@ -32,5 +32,13 @@ std = [ "parachains-common/std", "sp-arithmetic/std", "sp-std/std", + "pallet-funding/std" +] +runtime-benchmarks = [ + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "pallet-funding/runtime-benchmarks" +] +testing-node = [ + "pallet-funding/testing-node" ] -runtime-benchmarks = [ "frame-support/runtime-benchmarks" ] diff --git a/runtimes/shared-configuration/src/governance.rs b/runtimes/shared-configuration/src/governance.rs index 654000553..91587236f 100644 --- a/runtimes/shared-configuration/src/governance.rs +++ b/runtimes/shared-configuration/src/governance.rs @@ -19,7 +19,11 @@ use crate::{ Balance, }; use frame_support::{parameter_types, PalletId}; -use parachains_common::{BlockNumber, DAYS, HOURS}; +use parachains_common::BlockNumber; +#[cfg(feature = "fast-gov")] +use parachains_common::MINUTES; +#[cfg(not(feature = "fast-gov"))] +use parachains_common::{DAYS, HOURS}; use sp_arithmetic::Permill; pub const MIN_DEPOSIT: Balance = PLMC; diff --git a/runtimes/standalone/Cargo.toml b/runtimes/standalone/Cargo.toml index 3ebe03622..215810f28 100644 --- a/runtimes/standalone/Cargo.toml +++ b/runtimes/standalone/Cargo.toml @@ -119,6 +119,7 @@ std = [ "sp-std/std", "sp-transaction-pool/std", "sp-version/std", + "xcm-builder/std" ] runtime-benchmarks = [ @@ -167,3 +168,6 @@ try-runtime = [ "pallet-vesting/try-runtime", "sp-runtime/try-runtime", ] +testing-node = [ + "pallet-funding/testing-node", +] diff --git a/runtimes/standalone/src/lib.rs b/runtimes/standalone/src/lib.rs index 814c55754..769d0a7a5 100644 --- a/runtimes/standalone/src/lib.rs +++ b/runtimes/standalone/src/lib.rs @@ -353,8 +353,9 @@ parameter_types! { } impl pallet_funding::Config for Runtime { - #[cfg(feature = "runtime-benchmarks")] - type AllPalletsWithoutSystem = AllPalletsWithoutSystem; + // #[cfg(feature = "runtime-benchmarks")] + #[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] + type AllPalletsWithoutSystem = (Balances, LocalAssets, StatemintAssets, PolimecFunding, LinearVesting, Random); type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; type Balance = Balance; type BlockNumberToBalance = ConvertInto; diff --git a/runtimes/testnet/Cargo.toml b/runtimes/testnet/Cargo.toml index 6c3d2a718..a47db52ba 100644 --- a/runtimes/testnet/Cargo.toml +++ b/runtimes/testnet/Cargo.toml @@ -76,6 +76,7 @@ polkadot-runtime-common.workspace = true xcm.workspace = true xcm-builder.workspace = true xcm-executor.workspace = true +polimec-xcm-executor.workspace = true parachains-common.workspace = true # Cumulus @@ -159,6 +160,7 @@ std = [ "sp-transaction-pool/std", "sp-version/std", "xcm-builder/std", + "polimec-xcm-executor/std", "xcm-executor/std", "xcm/std", ] @@ -183,6 +185,20 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "pallet-linear-release/runtime-benchmarks", "xcm-builder/runtime-benchmarks", + "cumulus-pallet-parachain-system/runtime-benchmarks", + "pallet-asset-tx-payment/runtime-benchmarks", + "pallet-democracy/runtime-benchmarks", + "pallet-multisig/runtime-benchmarks", + "pallet-preimage/runtime-benchmarks", + "pallet-scheduler/runtime-benchmarks", + "pallet-sudo/runtime-benchmarks", + "pallet-treasury/runtime-benchmarks", + "pallet-utility/runtime-benchmarks", + "polimec-xcm-executor/runtime-benchmarks", + "polkadot-parachain/runtime-benchmarks", + "polkadot-primitives/runtime-benchmarks", + "polkadot-runtime-common/runtime-benchmarks", + "xcm-executor/runtime-benchmarks" ] try-runtime = [ @@ -222,3 +238,6 @@ try-runtime = [ "polkadot-runtime-common/try-runtime", "sp-runtime/try-runtime", ] +testing-node = [ + "pallet-funding/testing-node", +] diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index e177f56a5..6f8278882 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -56,8 +56,8 @@ use sp_version::NativeVersion; use sp_version::RuntimeVersion; // XCM Imports +use polimec_xcm_executor::XcmExecutor; pub use xcm_config::XcmConfig; -use xcm_executor::XcmExecutor; pub mod xcm_config; pub use crate::xcm_config::*; @@ -493,8 +493,8 @@ parameter_types! { pub TreasuryAccount: AccountId = [69u8; 32].into(); } impl pallet_funding::Config for Runtime { - #[cfg(feature = "runtime-benchmarks")] - type AllPalletsWithoutSystem = (Balances, LocalAssets, StatemintAssets, PolimecFunding, Vesting, Random); + // #[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] + type AllPalletsWithoutSystem = (Balances, LocalAssets, StatemintAssets, PolimecFunding, LinearVesting, Random); type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; type Balance = Balance; type BlockNumberToBalance = ConvertInto; @@ -527,7 +527,7 @@ impl pallet_funding::Config for Runtime { type StringLimit = ConstU32<64>; type SuccessToSettlementTime = SuccessToSettlementTime; type TreasuryAccount = TreasuryAccount; - type Vesting = Vesting; + type Vesting = LinearVesting; type WeightInfo = pallet_funding::weights::SubstrateWeight; } @@ -612,8 +612,8 @@ construct_runtime!( Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 44, // Polimec Core - PolimecFunding: pallet_funding::{Pallet, Call, Storage, Event} = 52, - Vesting: pallet_linear_release::{Pallet, Call, Storage, Event, Config} = 53, + PolimecFunding: pallet_funding::{Pallet, Call, Storage, Event, Config} = 52, + LinearVesting: pallet_linear_release::{Pallet, Call, Storage, Event, Config} = 53, // Utilities Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 61, @@ -642,7 +642,7 @@ mod benches { [pallet_timestamp, Timestamp] [cumulus_pallet_xcmp_queue, XcmpQueue] [pallet_funding, PolimecFunding] - [pallet_linear_release, Vesting] + [pallet_linear_release, LinearVesting] ); } diff --git a/runtimes/testnet/src/xcm_config.rs b/runtimes/testnet/src/xcm_config.rs index d39c10c21..5a57936ec 100644 --- a/runtimes/testnet/src/xcm_config.rs +++ b/runtimes/testnet/src/xcm_config.rs @@ -22,33 +22,31 @@ //! with statemine as the reserve. At present no derivative tokens are minted on receipt of a //! ReserveAssetTransferDeposited message but that will but the intension will be to support this soon. use core::marker::PhantomData; - use frame_support::{ - match_types, parameter_types, + ensure, match_types, parameter_types, traits::{ fungibles::{self, Balanced, Credit}, - ConstU32, Contains, ContainsPair, Everything, Get, Nothing, + ConstU32, Contains, ContainsPair, Everything, Get, Nothing, ProcessMessageError, }, weights::Weight, }; use pallet_asset_tx_payment::HandleCredit; use pallet_xcm::XcmPassthrough; use parachains_common::xcm_config::{DenyReserveTransferToRelayChain, DenyThenTry}; +use polimec_xcm_executor::XcmExecutor; use polkadot_parachain::primitives::Sibling; use polkadot_runtime_common::impls::ToAuthor; use sp_runtime::traits::Zero; use xcm::latest::prelude::*; use xcm_builder::{ AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom, - AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex, ConvertedConcreteId, CurrencyAdapter, EnsureXcmOrigin, - FixedRateOfFungible, FixedWeightBounds, FungiblesAdapter, IsConcrete, LocalMint, NativeAsset, ParentIsPreset, - RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, - SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WithComputedOrigin, -}; -use xcm_executor::{ - traits::{Convert, Error, JustTry, MatchesFungibles}, - XcmExecutor, + AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex, ConvertedConcreteId, CreateMatcher, CurrencyAdapter, + EnsureXcmOrigin, FixedRateOfFungible, FixedWeightBounds, FungiblesAdapter, IsConcrete, LocalMint, MatchXcm, + NativeAsset, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, + SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, + WithComputedOrigin, }; +use xcm_executor::traits::{Convert, Error, JustTry, MatchesFungibles, ShouldExecute}; use super::{ AccountId, AllPalletsWithSystem, AssetId as AssetIdPalletAssets, Balance, Balances, EnsureRoot, ParachainInfo, @@ -62,7 +60,7 @@ const DOT_PER_MB_PROOF: u128 = 0_0_000_001_000; // 0.0000001 DOT per Megabyte of const USDT_ASSET_ID: AssetId = Concrete(MultiLocation { parents: 1, interior: X3(Parachain(1000), PalletInstance(50), GeneralIndex(1984)) }); -const USDT_PER_SECOND_EXECUTION: u128 = 0_0_000_001_000; // 0.0000001 USDT per second of execution time +// const USDT_PER_SECOND_EXECUTION: u128 = 0_0_000_001_000; // 0.0000001 USDT per second of execution time parameter_types! { pub const RelayLocation: MultiLocation = MultiLocation::parent(); @@ -231,6 +229,8 @@ pub type Barrier = DenyThenTry< // Allow XCMs with some computed origins to pass through. WithComputedOrigin< ( + // HRMP notifications from relay get free pass + AllowHrmpNotifications, // If the message is one that immediately attemps to pay for execution, then allow it. AllowTopLevelPaidExecutionFrom, // Common Good Assets parachain, parent and its exec plurality get free execution @@ -361,7 +361,7 @@ pub type Reserves = (NativeAsset, StatemintAssetsFilter); pub struct XcmConfig; -impl xcm_executor::Config for XcmConfig { +impl polimec_xcm_executor::Config for XcmConfig { type AssetClaims = PolkadotXcm; type AssetExchanger = (); type AssetLocker = (); @@ -371,6 +371,8 @@ impl xcm_executor::Config for XcmConfig { type Barrier = Barrier; type CallDispatcher = RuntimeCall; type FeeManager = (); + type HrmpChannelOpenRequestHandler = + pallet_funding::xcm_executor_impl::HrmpChannelOpenRequestHandler; type IsReserve = Reserves; type IsTeleporter = NativeAsset; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; @@ -448,3 +450,27 @@ impl cumulus_pallet_xcm::Config for Runtime { type RuntimeEvent = RuntimeEvent; type XcmExecutor = XcmExecutor; } + +pub struct AllowHrmpNotifications(PhantomData); +impl> ShouldExecute for AllowHrmpNotifications { + fn should_execute( + origin: &MultiLocation, + instructions: &mut [Instruction], + max_weight: Weight, + _weight_credit: &mut Weight, + ) -> Result<(), ProcessMessageError> { + log::trace!( + target: "xcm::barriers", + "AllowHrmpNotifications origin: {:?}, instructions: {:?}, max_weight: {:?}, weight_credit: {:?}", + origin, instructions, max_weight, _weight_credit, + ); + ensure!(T::contains(origin), ProcessMessageError::Unsupported); + instructions.matcher().assert_remaining_insts(1)?.match_next_inst(|inst| match inst { + HrmpNewChannelOpenRequest { .. } => Ok(()), + HrmpChannelAccepted { .. } => Ok(()), + HrmpChannelClosing { .. } => Ok(()), + _ => Err(ProcessMessageError::Unsupported), + })?; + Ok(()) + } +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 484522c6c..d8408e4aa 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.70.0" +channel = "nightly-2023-06-15" components = [ "rustfmt", "clippy", "rust-analyzer" ] targets = [ "wasm32-unknown-unknown" ] \ No newline at end of file diff --git a/scripts/zombienet/native/base-rococo-local.toml b/scripts/zombienet/native/base-rococo-local.toml index c6ebb0d0d..89dc1ae62 100644 --- a/scripts/zombienet/native/base-rococo-local.toml +++ b/scripts/zombienet/native/base-rococo-local.toml @@ -3,7 +3,7 @@ timeout = 1000 provider = "native" [relaychain] -default_command = "polkadot" +default_command = "../polkadot/target/release/polkadot" chain = "rococo-local" [[relaychain.nodes]] @@ -24,8 +24,8 @@ chain = "base-polkadot" [[parachains.collators]] name = "collator1" - command = "polimec-parachain-node" + command = "./target/release/polimec-parachain-node" [[parachains.collators]] name = "collator2" - command = "polimec-parachain-node" + command = "./target/release/polimec-parachain-node" diff --git a/scripts/zombienet/native/hrmpless-rococo-statemint-polimec-penpal.toml b/scripts/zombienet/native/hrmpless-rococo-statemint-polimec-penpal.toml new file mode 100644 index 000000000..cc1d445b9 --- /dev/null +++ b/scripts/zombienet/native/hrmpless-rococo-statemint-polimec-penpal.toml @@ -0,0 +1,56 @@ +[settings] +timeout = 1000 +provider = "native" + +[relaychain] +default_command = "../polkadot/target/release/polkadot" +chain = "rococo-local" + + + [[relaychain.nodes]] + name = "alice" + ws_port = 6969 + args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] + [[relaychain.nodes]] + name = "bob" + + [[relaychain.nodes]] + name = "charlie" + + [[relaychain.nodes]] + name = "dave" + + [[relaychain.nodes]] + name = "eve" + + [[relaychain.nodes]] + name = "ferdie" + +[[parachains]] +id = 1000 +chain = "statemint-local" + + [[parachains.collators]] + name = "statemint-dev" + command = "../cumulus/target/release/polkadot-parachain" + args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] + ws_port = 7777 + + +[[parachains]] +id = 3355 +chain = "polimec-testing" + [[parachains.collators]] + name = "polimec-testing" + command = "./target/release/polimec-parachain-node" + args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] + ws_port = 8888 + +[[parachains]] +id = 3000 +chain = "penpal-polkadot-3000" + [[parachains.collators]] + name = "penpal-collator" + command = "../cumulus/target/release/polkadot-parachain" + args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] + ws_port = 9999 \ No newline at end of file diff --git a/scripts/zombienet/native/rococo-polimec-penpal.toml b/scripts/zombienet/native/rococo-polimec-penpal.toml new file mode 100644 index 000000000..5443282a5 --- /dev/null +++ b/scripts/zombienet/native/rococo-polimec-penpal.toml @@ -0,0 +1,41 @@ +[settings] +timeout = 1000 +provider = "native" + +[relaychain] +default_command = "../polkadot/target/release/polkadot" +chain = "rococo-local" + + [[relaychain.nodes]] + name = "alice" + + [[relaychain.nodes]] + name = "bob" + + [[relaychain.nodes]] + name = "charlie" + + [[relaychain.nodes]] + name = "dave" + + [[relaychain.nodes]] + name = "eve" + + [[relaychain.nodes]] + name = "ferdie" + + +[[parachains]] +id = 2000 + + [[parachains.collators]] + name = "polimec-collator" + command = "./target/release/polimec-parachain-node" + +[[parachains]] +id = 3000 + + [[parachains.collators]] + name = "penpal-collator" + command = "../cumulus/target/release/polkadot-parachain" + chain = "penpal-polkadot-3000" \ No newline at end of file diff --git a/traits/Cargo.toml b/traits/Cargo.toml index 994795890..fac8a51af 100644 --- a/traits/Cargo.toml +++ b/traits/Cargo.toml @@ -44,7 +44,12 @@ std = [ "sp-runtime/std", "sp-std/std", ] -runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks" ] +runtime-benchmarks = [ + "frame-benchmarking/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "sp-runtime/runtime-benchmarks" +] try-runtime = [ "frame-support/try-runtime", "frame-system/try-runtime", From b0e02582f51d6eae6225878b75d07f37d78001c9 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 26 Oct 2023 17:02:47 +0200 Subject: [PATCH 002/212] first commit --- Cargo.lock | 15 +++ pallets/funding/src/functions.rs | 2 +- pallets/funding/src/lib.rs | 33 +++++- pallets/polimec-receiver/Cargo.toml | 41 +++++++ pallets/polimec-receiver/README.md | 1 + pallets/polimec-receiver/src/benchmarking.rs | 20 ++++ pallets/polimec-receiver/src/lib.rs | 106 +++++++++++++++++++ pallets/polimec-receiver/src/mock.rs | 63 +++++++++++ pallets/polimec-receiver/src/tests.rs | 20 ++++ pallets/xcm-executor/src/config.rs | 13 ++- pallets/xcm-executor/src/lib.rs | 7 +- runtimes/testnet/src/xcm_config.rs | 3 +- 12 files changed, 308 insertions(+), 16 deletions(-) create mode 100644 pallets/polimec-receiver/Cargo.toml create mode 100644 pallets/polimec-receiver/README.md create mode 100644 pallets/polimec-receiver/src/benchmarking.rs create mode 100644 pallets/polimec-receiver/src/lib.rs create mode 100644 pallets/polimec-receiver/src/mock.rs create mode 100644 pallets/polimec-receiver/src/tests.rs diff --git a/Cargo.lock b/Cargo.lock index e620bb686..2d8a2efc7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6646,6 +6646,21 @@ dependencies = [ "substrate-fixed", ] +[[package]] +name = "pallet-parachain-template" +version = "0.1.0" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", +] + [[package]] name = "pallet-preimage" version = "4.0.0-dev" diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index e681f5354..7c8990955 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -1778,7 +1778,7 @@ impl Pallet { Ok(()) } - pub fn start_migration_readiness_check( + pub fn do_start_migration_readiness_check( caller: &AccountIdOf, project_id: T::ProjectIdentifier, ) -> Result<(), DispatchError> { diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 53d81a361..ff76ccd31 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1119,6 +1119,16 @@ pub mod pallet { let caller = ensure_signed(origin)?; Self::do_set_para_id_for_project(&caller, project_id, para_id) } + + #[pallet::call_index(22)] + #[pallet::weight(Weight::from_parts(1000, 0))] + pub fn start_migration_readiness_check( + origin: OriginFor, + project_id: T::ProjectIdentifier, + ) -> DispatchResult { + let caller = ensure_signed(origin)?; + Self::do_start_migration_readiness_check(&caller, project_id) + } } #[pallet::hooks] @@ -1337,11 +1347,10 @@ pub mod pallet { pub mod xcm_executor_impl { use super::*; use crate::ProjectStatus::FundingSuccessful; + use frame_support::pallet_prelude::Get; - pub struct HrmpChannelOpenRequestHandler(PhantomData<(T, XcmSender)>); - impl polimec_xcm_executor::HrmpChannelOpenRequestHandler - for HrmpChannelOpenRequestHandler - { + pub struct HrmpHandler(PhantomData<(T, XcmSender)>); + impl polimec_xcm_executor::HrmpHandler for HrmpHandler { fn handle_channel_open_request(message: Instruction) -> XcmResult { // TODO: set these constants with a proper value const MAX_MESSAGE_SIZE_THRESHOLDS: (u32, u32) = (50000, 102_400); @@ -1434,6 +1443,15 @@ pub mod xcm_executor_impl { }, } }, + instr @ _ => { + log::trace!(target: "pallet_funding::hrmp", "Bad instruction: {:?}", instr); + Err(XcmError::Unimplemented) + }, + } + } + + fn handle_channel_accepted(message: Instruction) -> XcmResult { + match message { Instruction::HrmpChannelAccepted { recipient } => { log::trace!(target: "pallet_funding::hrmp", "HrmpChannelAccepted received: {:?}", message); let (project_id, mut project_details) = ProjectsDetails::::iter() @@ -1444,11 +1462,16 @@ pub mod xcm_executor_impl { project_details.comm_status.polimec_to_project = ChannelStatus::Open; ProjectsDetails::::insert(project_id, project_details); - Pallet::::deposit_event(Event::::HrmpChannelEstablished { project_id, para_id: ParaId::from(recipient), }); + + Pallet::::do_start_migration_readiness_check( + T::PalletId::get().into_account_truncating(), + project_id, + ) + .map_err(|_| XcmError::NoDeal)?; Ok(()) }, instr @ _ => { diff --git a/pallets/polimec-receiver/Cargo.toml b/pallets/polimec-receiver/Cargo.toml new file mode 100644 index 000000000..365fb7c13 --- /dev/null +++ b/pallets/polimec-receiver/Cargo.toml @@ -0,0 +1,41 @@ +[package] +name = "pallet-parachain-template" +authors = ["Anonymous"] +description = "FRAME pallet template for defining custom runtime logic." +version = "0.1.0" +license = "Unlicense" +homepage = "https://substrate.io" +repository = "https://github.com/paritytech/substrate/" +edition = "2021" + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive"], default-features = false } +scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } + +# Substrate +frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.43" } +frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } +frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } + +[dev-dependencies] +serde = { version = "1.0.132" } + +# Substrate +sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } +sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } +sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } + +[features] +default = ["std"] +runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"] +std = [ + "codec/std", + "scale-info/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", +] +try-runtime = [ "frame-support/try-runtime" ] diff --git a/pallets/polimec-receiver/README.md b/pallets/polimec-receiver/README.md new file mode 100644 index 000000000..5a6461233 --- /dev/null +++ b/pallets/polimec-receiver/README.md @@ -0,0 +1 @@ +License: Unlicense diff --git a/pallets/polimec-receiver/src/benchmarking.rs b/pallets/polimec-receiver/src/benchmarking.rs new file mode 100644 index 000000000..8bba2a098 --- /dev/null +++ b/pallets/polimec-receiver/src/benchmarking.rs @@ -0,0 +1,20 @@ +//! Benchmarking setup for pallet-parachain-template + +use super::*; + +#[allow(unused)] +use crate::Pallet as Template; +use frame_benchmarking::{benchmarks, impl_benchmark_test_suite, whitelisted_caller}; +use frame_system::RawOrigin; + +benchmarks! { + do_something { + let s in 0 .. 100; + let caller: T::AccountId = whitelisted_caller(); + }: _(RawOrigin::Signed(caller), s) + verify { + assert_eq!(Something::::get(), Some(s)); + } +} + +impl_benchmark_test_suite!(Template, crate::mock::new_test_ext(), crate::mock::Test,); diff --git a/pallets/polimec-receiver/src/lib.rs b/pallets/polimec-receiver/src/lib.rs new file mode 100644 index 000000000..5f3252bfc --- /dev/null +++ b/pallets/polimec-receiver/src/lib.rs @@ -0,0 +1,106 @@ +#![cfg_attr(not(feature = "std"), no_std)] + +/// Edit this file to define custom logic or remove it if it is not needed. +/// Learn more about FRAME and the core library of Substrate FRAME pallets: +/// +pub use pallet::*; + +#[cfg(test)] +mod mock; + +#[cfg(test)] +mod tests; + +#[cfg(feature = "runtime-benchmarks")] +mod benchmarking; + +#[frame_support::pallet] +pub mod pallet { + use frame_support::{dispatch::DispatchResultWithPostInfo, pallet_prelude::*}; + use frame_system::pallet_prelude::*; + + /// Configure the pallet by specifying the parameters and types on which it depends. + #[pallet::config] + pub trait Config: frame_system::Config { + /// Because this pallet emits events, it depends on the runtime's definition of an event. + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + } + + #[pallet::pallet] + pub struct Pallet(_); + + // The pallet's runtime storage items. + // https://docs.substrate.io/v3/runtime/storage + #[pallet::storage] + #[pallet::getter(fn something)] + // Learn more about declaring storage items: + // https://docs.substrate.io/v3/runtime/storage#declaring-storage-items + pub type Something = StorageValue<_, u32>; + + // Pallets use events to inform users when important changes are made. + // https://docs.substrate.io/v3/runtime/events-and-errors + #[pallet::event] + #[pallet::generate_deposit(pub(super) fn deposit_event)] + pub enum Event { + /// Event documentation should end with an array that provides descriptive names for event + /// parameters. [something, who] + SomethingStored(u32, T::AccountId), + } + + // Errors inform users that something went wrong. + #[pallet::error] + pub enum Error { + /// Error names should be descriptive. + NoneValue, + /// Errors should have helpful documentation associated with them. + StorageOverflow, + } + + #[pallet::hooks] + impl Hooks> for Pallet {} + + // Dispatchable functions allows users to interact with the pallet and invoke state changes. + // These functions materialize as "extrinsics", which are often compared to transactions. + // Dispatchable functions must be annotated with a weight and must return a DispatchResult. + #[pallet::call] + impl Pallet { + /// An example dispatchable that takes a singles value as a parameter, writes the value to + /// storage and emits an event. This function must be dispatched by a signed extrinsic. + #[pallet::call_index(0)] + #[pallet::weight(Weight::from_parts(10_000, 0) + T::DbWeight::get().writes(1))] + pub fn do_something(origin: OriginFor, something: u32) -> DispatchResultWithPostInfo { + // Check that the extrinsic was signed and get the signer. + // This function will return an error if the extrinsic is not signed. + // https://docs.substrate.io/v3/runtime/origins + let who = ensure_signed(origin)?; + + // Update storage. + >::put(something); + + // Emit an event. + Self::deposit_event(Event::SomethingStored(something, who)); + // Return a successful DispatchResultWithPostInfo + Ok(().into()) + } + + /// An example dispatchable that may throw a custom error. + #[pallet::call_index(1)] + #[pallet::weight(Weight::from_parts(10_000, 0) + T::DbWeight::get().reads_writes(1,1))] + pub fn cause_error(origin: OriginFor) -> DispatchResultWithPostInfo { + let _who = ensure_signed(origin)?; + + // Read a value from storage. + match >::get() { + // Return an error if the value has not been set. + None => Err(Error::::NoneValue)?, + Some(old) => { + // Increment the value read from storage; will error in the event of overflow. + let new = old.checked_add(1).ok_or(Error::::StorageOverflow)?; + // Update the value in storage with the incremented result. + >::put(new); + Ok(().into()) + }, + } + } + } +} diff --git a/pallets/polimec-receiver/src/mock.rs b/pallets/polimec-receiver/src/mock.rs new file mode 100644 index 000000000..fbad8f13e --- /dev/null +++ b/pallets/polimec-receiver/src/mock.rs @@ -0,0 +1,63 @@ +use frame_support::{parameter_types, traits::Everything}; +use frame_system as system; +use sp_core::H256; +use sp_runtime::{ + testing::Header, + traits::{BlakeTwo256, IdentityLookup}, +}; + +type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; +type Block = frame_system::mocking::MockBlock; + +// Configure a mock runtime to test the pallet. +frame_support::construct_runtime!( + pub enum Test where + Block = Block, + NodeBlock = Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + System: frame_system::{Pallet, Call, Config, Storage, Event}, + TemplateModule: crate::{Pallet, Call, Storage, Event}, + } +); + +parameter_types! { + pub const BlockHashCount: u64 = 250; + pub const SS58Prefix: u8 = 42; +} + +impl system::Config for Test { + type AccountData = (); + type AccountId = u64; + type BaseCallFilter = Everything; + type BlockHashCount = BlockHashCount; + type BlockLength = (); + type BlockNumber = u64; + type BlockWeights = (); + type DbWeight = (); + type Hash = H256; + type Hashing = BlakeTwo256; + type Header = Header; + type Index = u64; + type Lookup = IdentityLookup; + type MaxConsumers = frame_support::traits::ConstU32<16>; + type OnKilledAccount = (); + type OnNewAccount = (); + type OnSetCode = (); + type PalletInfo = PalletInfo; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type SS58Prefix = SS58Prefix; + type SystemWeightInfo = (); + type Version = (); +} + +impl crate::Config for Test { + type RuntimeEvent = RuntimeEvent; +} + +// Build genesis storage according to the mock runtime. +pub fn new_test_ext() -> sp_io::TestExternalities { + system::GenesisConfig::default().build_storage::().unwrap().into() +} diff --git a/pallets/polimec-receiver/src/tests.rs b/pallets/polimec-receiver/src/tests.rs new file mode 100644 index 000000000..6a9a0cabe --- /dev/null +++ b/pallets/polimec-receiver/src/tests.rs @@ -0,0 +1,20 @@ +use crate::{mock::*, Error}; +use frame_support::{assert_noop, assert_ok}; + +#[test] +fn it_works_for_default_value() { + new_test_ext().execute_with(|| { + // Dispatch a signed extrinsic. + assert_ok!(TemplateModule::do_something(RuntimeOrigin::signed(1), 42)); + // Read pallet storage and assert an expected result. + assert_eq!(TemplateModule::something(), Some(42)); + }); +} + +#[test] +fn correct_error_for_none_value() { + new_test_ext().execute_with(|| { + // Ensure the expected error is thrown when no value is present. + assert_noop!(TemplateModule::cause_error(RuntimeOrigin::signed(1)), Error::::NoneValue); + }); +} diff --git a/pallets/xcm-executor/src/config.rs b/pallets/xcm-executor/src/config.rs index e5cef49e5..b04d72dd1 100644 --- a/pallets/xcm-executor/src/config.rs +++ b/pallets/xcm-executor/src/config.rs @@ -106,16 +106,21 @@ pub trait Config { /// temporary measure until we properly account for proof size weights for XCM instructions. type SafeCallFilter: Contains; - /// Polimec's custom type for handling the `HrmpNewChannelOpenRequest` instruction - type HrmpChannelOpenRequestHandler: HrmpChannelOpenRequestHandler; + /// Polimec's custom type for handling the `HrmpNewChannelOpenRequest` ans `HrmpChannelAccepted` instructions + type HrmpHandler: HrmpHandler; } -pub trait HrmpChannelOpenRequestHandler { +pub trait HrmpHandler { fn handle_channel_open_request(message: Instruction) -> XcmResult; + fn handle_channel_accepted(message: Instruction) -> XcmResult; } -impl HrmpChannelOpenRequestHandler for () { +impl HrmpHandler for () { fn handle_channel_open_request(_message: Instruction) -> XcmResult { Err(XcmError::NoDeal) } + + fn handle_channel_accepted(_message: Instruction) -> XcmResult { + Err(XcmError::NoDeal) + } } diff --git a/pallets/xcm-executor/src/lib.rs b/pallets/xcm-executor/src/lib.rs index 8a75b5f3c..b77323db1 100644 --- a/pallets/xcm-executor/src/lib.rs +++ b/pallets/xcm-executor/src/lib.rs @@ -36,7 +36,7 @@ use xcm_executor::traits::{ use xcm_executor::Assets; mod config; -pub use config::{Config, HrmpChannelOpenRequestHandler}; +pub use config::{Config, HrmpHandler}; /// A struct to specify how fees are being paid. #[derive(Copy, Clone, Debug, PartialEq, Eq)] @@ -879,9 +879,8 @@ impl XcmExecutor { ensure!(check_origin.is_none() || self.context.origin == check_origin, XcmError::BadOrigin); Ok(()) }, - msg @ HrmpNewChannelOpenRequest { .. } => - Config::HrmpChannelOpenRequestHandler::handle_channel_open_request(msg.into()), - HrmpChannelAccepted { .. } => Err(XcmError::Unimplemented), + msg @ HrmpNewChannelOpenRequest { .. } => Config::HrmpHandler::handle_channel_open_request(msg.into()), + msg @ HrmpChannelAccepted { .. } => Config::HrmpHandler::handle_channel_accepted(msg.into()), HrmpChannelClosing { .. } => Err(XcmError::Unimplemented), } } diff --git a/runtimes/testnet/src/xcm_config.rs b/runtimes/testnet/src/xcm_config.rs index 5a57936ec..005201b31 100644 --- a/runtimes/testnet/src/xcm_config.rs +++ b/runtimes/testnet/src/xcm_config.rs @@ -371,8 +371,7 @@ impl polimec_xcm_executor::Config for XcmConfig { type Barrier = Barrier; type CallDispatcher = RuntimeCall; type FeeManager = (); - type HrmpChannelOpenRequestHandler = - pallet_funding::xcm_executor_impl::HrmpChannelOpenRequestHandler; + type HrmpChannelOpenRequestHandler = pallet_funding::xcm_executor_impl::HrmpHandler; type IsReserve = Reserves; type IsTeleporter = NativeAsset; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; From 01fbe0ad56501974d96f62382d815bbb0c427b9c Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 27 Oct 2023 17:38:56 +0200 Subject: [PATCH 003/212] save --- integration-tests/src/tests/hrmp_flow.rs | 114 ++++++++++------------- pallets/funding/src/lib.rs | 2 +- runtimes/testnet/src/xcm_config.rs | 2 +- 3 files changed, 52 insertions(+), 66 deletions(-) diff --git a/integration-tests/src/tests/hrmp_flow.rs b/integration-tests/src/tests/hrmp_flow.rs index 5d738b009..20e1d69af 100644 --- a/integration-tests/src/tests/hrmp_flow.rs +++ b/integration-tests/src/tests/hrmp_flow.rs @@ -1,64 +1,50 @@ -// use crate::*; - -// const MAX_REF_TIME: u64 = 700_000_000; -// const MAX_PROOF_SIZE: u64 = 10_000; -// pub const REF_TIME_THRESHOLD: u64 = 33; -// pub const PROOF_SIZE_THRESHOLD: u64 = 33; - -// use polkadot_runtime_parachains::{hrmp as parachain_hrmp, origin as parachains_origin, paras as parachains_paras}; - -// #[test] -// fn hrmp_notification() { -// let max_weight = Weight::from_parts(MAX_REF_TIME, MAX_PROOF_SIZE); -// let execution_dot: MultiAsset = (MultiLocation { parents: 0, interior: Here }, 1_0_000_000_000u128).into(); -// let call = polkadot_runtime::RuntimeCall::Hrmp(parachain_hrmp::Call::::hrmp_init_open_channel{ -// recipient: Polimec::para_id(), -// proposed_max_capacity: 1024, -// proposed_max_message_size: 1024 * 1024, -// }); -// // let hrmp_init_open_call = parachain_hrmp::Call::::hrmp_init_open_channel{ -// // recipient: Polimec::para_id(), -// // proposed_max_capacity: 1024, -// // proposed_max_message_size: 1024 * 1024, -// // }; -// let encoded_call = call.encode(); - -// PolkadotRelay::execute_with(||{ -// let x = parachains_paras::ParaLifecycles::::iter(); -// let y = 10; -// }); - -// let xcm = VersionedXcm::from(Xcm(vec![ -// WithdrawAsset(vec![execution_dot.clone()].into()), -// BuyExecution { fees: execution_dot.clone(), weight_limit: Unlimited }, -// Transact { origin_kind: OriginKind::Native, require_weight_at_most: max_weight, call: encoded_call.into() }, -// RefundSurplus, -// DepositAsset { -// assets: Wild(All), -// beneficiary: MultiLocation { -// parents: 0, -// interior: X1(Parachain(Penpal::para_id().into())), -// }, -// }, -// ])); - -// let penpal_sov_acc = PolkadotRelay::sovereign_account_id_of(Parachain(Penpal::para_id().into()).into()); -// PolkadotRelay::fund_accounts(vec![(penpal_sov_acc, 100_0_000_000_000u128)]); - -// Penpal::execute_with(|| { -// assert_ok!(PenpalXcmPallet::send(PenpalOrigin::root(), bx!(Penpal::parent_location().into()), bx!(xcm),)); -// println!("penpal events:"); -// dbg!(Penpal::events()) -// }); - -// PolkadotRelay::execute_with(|| { -// println!("polkadot events:"); -// dbg!(PolkadotRelay::events()); -// }); - -// Polimec::execute_with(|| { -// println!("polimec events:"); -// dbg!(Polimec::events()); -// }); - -// } +use crate::*; + +const MAX_REF_TIME: u64 = 700_000_000; +const MAX_PROOF_SIZE: u64 = 10_000; +pub const REF_TIME_THRESHOLD: u64 = 33; +pub const PROOF_SIZE_THRESHOLD: u64 = 33; + +use polkadot_runtime_parachains::{hrmp as parachain_hrmp, origin as parachains_origin, paras as parachains_paras}; + +#[test] +fn balance_query() { + let max_weight = Weight::from_parts(MAX_REF_TIME, MAX_PROOF_SIZE); + let execution_currency: MultiAsset = (MultiLocation { parents: 0, interior: Here }, 1_0_000_000_000u128).into(); // 1 unit for executing + let expected_currency: MultiAsset = + (MultiLocation { parents: 0, interior: Here }, 1_000_000_0_000_000_000u128).into(); // 1MM units for migrations + let xcm = VersionedXcm::from(Xcm(vec![ + UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, + WithdrawAsset(vec![expected_currency.clone()].into()), + ReportHolding { + response_info: QueryResponseInfo { + destination: ParentThen(Parachain(3355).into()).into(), + query_id: 0, + max_weight: max_weight.clone(), + }, + assets: Wild(All), + }, + DepositAsset { assets: Wild(All), beneficiary: ParentThen(Parachain(3355).into()).into() } + ])); + + let penpal_sov_acc = PolkadotRelay::sovereign_account_id_of(Parachain(Penpal::para_id().into()).into()); + PolkadotRelay::fund_accounts(vec![(penpal_sov_acc, 100_0_000_000_000u128)]); + + Polimec::execute_with(|| { + assert_ok!(PolimecXcmPallet::send(PolimecOrigin::root(), bx!(ParentThen(Parachain(3000).into()).into()), bx!(xcm),)); + println!("polimec events:"); + dbg!(Penpal::events()) + }); + + Penpal::execute_with(|| { + println!("penpal events:"); + dbg!(Penpal::events()); + }); + + Polimec::execute_with(|| { + println!("penpal events:"); + dbg!(Polimec::events()); + }); + + +} diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index ff76ccd31..b1b6e7040 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1468,7 +1468,7 @@ pub mod xcm_executor_impl { }); Pallet::::do_start_migration_readiness_check( - T::PalletId::get().into_account_truncating(), + &(T::PalletId::get().into_account_truncating()), project_id, ) .map_err(|_| XcmError::NoDeal)?; diff --git a/runtimes/testnet/src/xcm_config.rs b/runtimes/testnet/src/xcm_config.rs index 005201b31..d11ab0ab2 100644 --- a/runtimes/testnet/src/xcm_config.rs +++ b/runtimes/testnet/src/xcm_config.rs @@ -371,7 +371,7 @@ impl polimec_xcm_executor::Config for XcmConfig { type Barrier = Barrier; type CallDispatcher = RuntimeCall; type FeeManager = (); - type HrmpChannelOpenRequestHandler = pallet_funding::xcm_executor_impl::HrmpHandler; + type HrmpHandler = pallet_funding::xcm_executor_impl::HrmpHandler; type IsReserve = Reserves; type IsTeleporter = NativeAsset; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; From 396e1c85709784dac3a0e77cb8ddc7ae997f2d5c Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 30 Oct 2023 13:17:54 +0100 Subject: [PATCH 004/212] penpal local fork --- Cargo.lock | 260 +++--- Cargo.toml | 4 +- integration-tests/Cargo.toml | 2 +- integration-tests/penpal/Cargo.toml | 174 ++++ integration-tests/penpal/build.rs | 27 + integration-tests/penpal/src/lib.rs | 849 ++++++++++++++++++ .../penpal/src/weights/block_weights.rs | 53 ++ .../penpal/src/weights/extrinsic_weights.rs | 53 ++ integration-tests/penpal/src/weights/mod.rs | 28 + .../penpal/src/weights/paritydb_weights.rs | 63 ++ .../penpal/src/weights/rocksdb_weights.rs | 63 ++ integration-tests/penpal/src/xcm_config.rs | 349 +++++++ integration-tests/src/tests/hrmp_flow.rs | 6 +- pallets/polimec-receiver/Cargo.toml | 3 + 14 files changed, 1788 insertions(+), 146 deletions(-) create mode 100644 integration-tests/penpal/Cargo.toml create mode 100644 integration-tests/penpal/build.rs create mode 100644 integration-tests/penpal/src/lib.rs create mode 100644 integration-tests/penpal/src/weights/block_weights.rs create mode 100644 integration-tests/penpal/src/weights/extrinsic_weights.rs create mode 100644 integration-tests/penpal/src/weights/mod.rs create mode 100644 integration-tests/penpal/src/weights/paritydb_weights.rs create mode 100644 integration-tests/penpal/src/weights/rocksdb_weights.rs create mode 100644 integration-tests/penpal/src/xcm_config.rs diff --git a/Cargo.lock b/Cargo.lock index 2d8a2efc7..ee9f57041 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -149,9 +149,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" dependencies = [ "getrandom 0.2.10", "once_cell", @@ -437,7 +437,7 @@ dependencies = [ "log", "parking", "polling", - "rustix 0.37.26", + "rustix 0.37.27", "slab", "socket2 0.4.10", "waker-fn", @@ -1063,9 +1063,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.6" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" +checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" dependencies = [ "clap_builder", "clap_derive", @@ -1073,9 +1073,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.6" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" +checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" dependencies = [ "anstream", "anstyle", @@ -1085,9 +1085,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.2" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck", "proc-macro2", @@ -1097,9 +1097,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "coarsetime" @@ -1247,9 +1247,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fbc60abd742b35f2492f808e1abbb83d45f72db402e14c55057edc9c7b1e9e4" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -1495,7 +1495,7 @@ checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array 0.14.7", "rand_core 0.6.4", - "typenum 1.17.0", + "typenum", ] [[package]] @@ -2236,9 +2236,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.109" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c390c123d671cc547244943ecad81bdaab756c6ea332d9ca9c1f48d952a24895" +checksum = "7129e341034ecb940c9072817cd9007974ea696844fc4dd582dc1653a7fbe2e8" dependencies = [ "cc", "cxxbridge-flags", @@ -2248,9 +2248,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.109" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00d3d3ac9ffb900304edf51ca719187c779f4001bb544f26c4511d621de905cf" +checksum = "a2a24f3f5f8eed71936f21e570436f024f5c2e25628f7496aa7ccd03b90109d5" dependencies = [ "cc", "codespan-reporting", @@ -2263,15 +2263,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.109" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94415827ecfea0f0c74c8cad7d1a86ddb3f05354d6a6ddeda0adee5e875d2939" +checksum = "06fdd177fc61050d63f67f5bd6351fac6ab5526694ea8e359cd9cd3b75857f44" [[package]] name = "cxxbridge-macro" -version = "1.0.109" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33dbbe9f5621c9247f97ec14213b04f350bff4b6cebefe834c60055db266ecf" +checksum = "587663dd5fb3d10932c8aecfe7c844db1bcf0aee93eeab08fac13dc1212c2e7f" dependencies = [ "proc-macro2", "quote", @@ -2973,9 +2973,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0870c84016d4b481be5c9f323c24f65e31e901ae618f0e80f4308fb00de1d2d" +checksum = "a481586acf778f1b1455424c343f71124b048ffa5f4fc3f8f6ae9dc432dcb3c7" [[package]] name = "file-per-thread-logger" @@ -3381,7 +3381,7 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" dependencies = [ - "rustix 0.38.20", + "rustix 0.38.21", "windows-sys 0.48.0", ] @@ -3393,9 +3393,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" dependencies = [ "futures-channel", "futures-core", @@ -3408,9 +3408,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", "futures-sink", @@ -3418,15 +3418,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" dependencies = [ "futures-core", "futures-task", @@ -3436,9 +3436,9 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" [[package]] name = "futures-lite" @@ -3457,9 +3457,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", @@ -3479,15 +3479,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-timer" @@ -3497,9 +3497,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-channel", "futures-core", @@ -3528,7 +3528,7 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" dependencies = [ - "typenum 1.17.0", + "typenum", ] [[package]] @@ -3537,7 +3537,7 @@ version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ - "typenum 1.17.0", + "typenum", "version_check", "zeroize", ] @@ -3712,7 +3712,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.6", + "ahash 0.7.7", ] [[package]] @@ -3925,19 +3925,19 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http", "hyper", "log", - "rustls 0.21.7", + "rustls 0.21.8", "rustls-native-certs", "tokio", "tokio-rustls 0.24.1", - "webpki-roots 0.23.1", + "webpki-roots 0.25.2", ] [[package]] @@ -4220,7 +4220,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi 0.3.3", - "rustix 0.38.20", + "rustix 0.38.21", "windows-sys 0.48.0", ] @@ -4338,7 +4338,7 @@ checksum = "7e5f9fabdd5d79344728521bb65e3106b49ec405a78b66fbff073b72b389fa43" dependencies = [ "async-trait", "hyper", - "hyper-rustls 0.24.1", + "hyper-rustls 0.24.2", "jsonrpsee-core", "jsonrpsee-types", "rustc-hash", @@ -5068,7 +5068,7 @@ dependencies = [ "rand 0.8.5", "serde", "sha2 0.9.9", - "typenum 1.17.0", + "typenum", ] [[package]] @@ -5302,7 +5302,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.38.20", + "rustix 0.38.21", ] [[package]] @@ -5574,7 +5574,7 @@ dependencies = [ "num-rational", "num-traits", "simba", - "typenum 1.17.0", + "typenum", ] [[package]] @@ -7327,7 +7327,6 @@ dependencies = [ [[package]] name = "penpal-runtime" version = "0.9.27" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", @@ -7344,6 +7343,7 @@ dependencies = [ "frame-system", "frame-system-benchmarking", "frame-system-rpc-runtime-api", + "frame-try-runtime", "hex-literal 0.4.1", "log", "pallet-asset-tx-payment", @@ -7391,9 +7391,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c022f1e7b65d6a24c0dbbd5fb344c66881bc01f3e5ae74a1c8100f2f985d98a4" +checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" dependencies = [ "memchr", "thiserror", @@ -7402,9 +7402,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35513f630d46400a977c4cb58f78e1bfbe01434316e60c37d27b9ad6139c66d8" +checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" dependencies = [ "pest", "pest_generator", @@ -7412,9 +7412,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc9fc1b9e7057baba189b5c626e2d6f40681ae5b6eb064dc7c7834101ec8123a" +checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" dependencies = [ "pest", "pest_meta", @@ -7425,9 +7425,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df74e9e7ec4053ceb980e7c0c8bd3594e977fde1af91daba9c928e8e8c6708d" +checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" dependencies = [ "once_cell", "pest", @@ -9124,9 +9124,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.4.3" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b" +checksum = "3bccab0e7fd7cc19f820a1c8c91720af652d0c88dc9664dd72aef2614f04af3b" [[package]] name = "powerfmt" @@ -9982,9 +9982,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.16" +version = "0.36.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6da3636faa25820d8648e0e31c5d519bbb01f72fdf57131f0f5f7da5fed36eab" +checksum = "305efbd14fde4139eb501df5f136994bb520b033fa9fbdce287507dc23b8c7ed" dependencies = [ "bitflags 1.3.2", "errno", @@ -9996,9 +9996,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.26" +version = "0.37.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f3f8f960ed3b5a59055428714943298bf3fa2d4a1d53135084e0544829d995" +checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" dependencies = [ "bitflags 1.3.2", "errno", @@ -10010,9 +10010,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.20" +version = "0.38.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ce50cb2e16c2903e30d1cbccfd8387a74b9d4c938b6a4c5ec6cc7556f7a8a0" +checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" dependencies = [ "bitflags 2.4.1", "errno", @@ -10042,20 +10042,20 @@ checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" dependencies = [ "log", "ring 0.16.20", - "sct 0.7.0", + "sct 0.7.1", "webpki 0.22.4", ] [[package]] name = "rustls" -version = "0.21.7" +version = "0.21.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" dependencies = [ "log", - "ring 0.16.20", - "rustls-webpki 0.101.6", - "sct 0.7.0", + "ring 0.17.5", + "rustls-webpki", + "sct 0.7.1", ] [[package]] @@ -10081,22 +10081,12 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.100.3" +version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6a5fc258f1c1276dfe3016516945546e2d5383911efc0fc4f1cdc5df3a4ae3" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", -] - -[[package]] -name = "rustls-webpki" -version = "0.101.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" -dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", + "ring 0.17.5", + "untrusted 0.9.0", ] [[package]] @@ -10657,7 +10647,7 @@ dependencies = [ "libc", "log", "once_cell", - "rustix 0.36.16", + "rustix 0.36.17", "sc-allocator", "sc-executor-common", "sp-runtime-interface", @@ -11369,12 +11359,12 @@ dependencies = [ [[package]] name = "sct" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", + "ring 0.17.5", + "untrusted 0.9.0", ] [[package]] @@ -11502,18 +11492,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.189" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" +checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.189" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" +checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" dependencies = [ "proc-macro2", "quote", @@ -11533,9 +11523,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" dependencies = [ "serde", ] @@ -12766,12 +12756,12 @@ dependencies = [ [[package]] name = "substrate-fixed" version = "0.5.9" -source = "git+https://github.com/encointer/substrate-fixed#df67f97a6db9b40215f105613b381ca82f1e2ff4" +source = "git+https://github.com/encointer/substrate-fixed#a75f3ba3f7c7893fb420500639cc055f964b1b88" dependencies = [ "parity-scale-codec", "scale-info", "serde", - "typenum 1.16.0", + "substrate-typenum", ] [[package]] @@ -12863,6 +12853,16 @@ dependencies = [ "sp-state-machine", ] +[[package]] +name = "substrate-typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f0091e93c2c75b233ae39424c52cb8a662c0811fb68add149e20e5d7e8a788" +dependencies = [ + "parity-scale-codec", + "scale-info", +] + [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" @@ -12964,14 +12964,14 @@ checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a" [[package]] name = "tempfile" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", "fastrand 2.0.1", - "redox_syscall 0.3.5", - "rustix 0.38.20", + "redox_syscall 0.4.1", + "rustix 0.38.21", "windows-sys 0.48.0", ] @@ -13214,7 +13214,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.7", + "rustls 0.21.8", "tokio", ] @@ -13232,9 +13232,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -13268,9 +13268,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", ] @@ -13397,12 +13397,12 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] @@ -13587,15 +13587,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "typenum" -version = "1.16.0" -source = "git+https://github.com/encointer/typenum?tag=polkadot-v1.0.0#4cba9a73f7e94ba38c824616efab93f177c9a556" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - [[package]] name = "typenum" version = "1.17.0" @@ -14021,7 +14012,7 @@ dependencies = [ "directories-next", "file-per-thread-logger", "log", - "rustix 0.36.16", + "rustix 0.36.17", "serde", "sha2 0.10.8", "toml 0.5.11", @@ -14117,7 +14108,7 @@ checksum = "6e0554b84c15a27d76281d06838aed94e13a77d7bf604bbbaf548aa20eb93846" dependencies = [ "object 0.30.4", "once_cell", - "rustix 0.36.16", + "rustix 0.36.17", ] [[package]] @@ -14148,7 +14139,7 @@ dependencies = [ "memoffset 0.8.0", "paste", "rand 0.8.5", - "rustix 0.36.16", + "rustix 0.36.17", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", @@ -14206,15 +14197,6 @@ dependencies = [ "webpki 0.22.4", ] -[[package]] -name = "webpki-roots" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" -dependencies = [ - "rustls-webpki 0.100.3", -] - [[package]] name = "webpki-roots" version = "0.25.2" @@ -14545,7 +14527,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.20", + "rustix 0.38.21", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index f4188439e..6523823de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,11 +1,10 @@ [workspace] members = [ -# "nodes/*", -# "runtimes/*", "nodes/parachain", "runtimes/testnet", "pallets/*", "integration-tests", + "integration-tests/penpal", "traits", ] @@ -216,7 +215,6 @@ frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", d polimec-parachain-runtime = { path = "runtimes/testnet" } polimec-standalone-runtime = { path = "runtimes/standalone" } polimec-base-runtime = { path = "runtimes/base" } -penpal-runtime = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "release-v0.9.430" } [patch.crates-io] ahash = {git = "https://github.com/tkaitchuck/aHash", tag = "v0.8.3"} \ No newline at end of file diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index a5f1f1525..f267d7323 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -59,7 +59,7 @@ pallet-message-queue.workspace = true polkadot-runtime.workspace = true statemint-runtime.workspace = true polimec-parachain-runtime.workspace = true -penpal-runtime.workspace = true +penpal-runtime = { path = "./penpal", default-features = false } [features] default = [ "std" ] diff --git a/integration-tests/penpal/Cargo.toml b/integration-tests/penpal/Cargo.toml new file mode 100644 index 000000000..bb80ad96c --- /dev/null +++ b/integration-tests/penpal/Cargo.toml @@ -0,0 +1,174 @@ +[package] +name = "penpal-runtime" +version = "0.9.27" +authors = ["Anonymous"] +description = "A parachain for communication back and forth with XCM of assets and uniques." +license = "Unlicense" +homepage = "https://substrate.io" +repository = "https://github.com/paritytech/cumulus/" +edition = "2021" + +[package.metadata.docs.rs] +targets = ["x86_64-unknown-linux-gnu"] + +[build-dependencies] +substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", optional = true , branch = "polkadot-v0.9.43" } + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } +hex-literal = { version = "0.4.1", optional = true } +log = { version = "0.4.16", default-features = false } +scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } +smallvec = "1.10.0" + +# Substrate +frame-benchmarking = { workspace = true, optional = true } +frame-executive.workspace = true +frame-support.workspace = true +frame-system.workspace = true +frame-system-benchmarking = { workspace = true, optional = true } +frame-system-rpc-runtime-api.workspace = true +frame-try-runtime = { workspace = true, optional = true } +pallet-aura.workspace = true +pallet-authorship.workspace = true +pallet-balances.workspace = true +pallet-session.workspace = true +pallet-sudo.workspace = true +pallet-timestamp.workspace = true +pallet-transaction-payment.workspace = true +pallet-transaction-payment-rpc-runtime-api.workspace = true +pallet-asset-tx-payment.workspace = true +pallet-assets.workspace = true +sp-api.workspace = true +sp-block-builder.workspace = true +sp-consensus-aura.workspace = true +sp-core.workspace = true +sp-inherents.workspace = true +sp-offchain.workspace = true +sp-runtime.workspace = true +sp-session.workspace = true +sp-std.workspace = true +sp-transaction-pool.workspace = true +sp-version.workspace = true + +# Polkadot +polkadot-primitives.workspace = true +pallet-xcm.workspace = true +polkadot-parachain.workspace = true +polkadot-runtime-common.workspace = true +xcm.workspace = true +xcm-builder.workspace = true +xcm-executor.workspace = true + +# Cumulus +cumulus-pallet-aura-ext.workspace = true +cumulus-pallet-dmp-queue.workspace = true +cumulus-pallet-parachain-system.workspace = true +cumulus-pallet-session-benchmarking.workspace = true +cumulus-pallet-xcm.workspace = true +cumulus-pallet-xcmp-queue.workspace = true +cumulus-primitives-core.workspace = true +cumulus-primitives-timestamp.workspace = true +cumulus-primitives-utility.workspace = true +pallet-collator-selection.workspace = true +parachain-info.workspace = true +parachains-common.workspace = true + +[features] +default = [ + "std", +] +std = [ + "codec/std", + "log/std", + "scale-info/std", + "cumulus-pallet-aura-ext/std", + "cumulus-pallet-dmp-queue/std", + "cumulus-pallet-parachain-system/std", + "cumulus-pallet-xcm/std", + "cumulus-pallet-xcmp-queue/std", + "cumulus-primitives-core/std", + "cumulus-primitives-timestamp/std", + "cumulus-primitives-utility/std", + "frame-executive/std", + "frame-support/std", + "frame-system-rpc-runtime-api/std", + "frame-system/std", + "pallet-aura/std", + "pallet-authorship/std", + "pallet-balances/std", + "pallet-collator-selection/std", + "pallet-session/std", + "pallet-sudo/std", + "pallet-timestamp/std", + "pallet-transaction-payment-rpc-runtime-api/std", + "pallet-transaction-payment/std", + "pallet-assets/std", + "pallet-asset-tx-payment/std", + "pallet-xcm/std", + "polkadot-primitives/std", + "parachain-info/std", + "polkadot-parachain/std", + "polkadot-runtime-common/std", + "sp-api/std", + "sp-block-builder/std", + "sp-consensus-aura/std", + "sp-core/std", + "sp-inherents/std", + "sp-offchain/std", + "sp-runtime/std", + "sp-session/std", + "sp-std/std", + "sp-transaction-pool/std", + "sp-version/std", + "xcm-builder/std", + "xcm-executor/std", + "xcm/std", + "substrate-wasm-builder", + "cumulus-pallet-session-benchmarking/std", + "frame-benchmarking/std", + "frame-system-benchmarking?/std", + "frame-try-runtime/std", + "parachains-common/std" +] + +runtime-benchmarks = [ + "hex-literal", + "frame-benchmarking/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system-benchmarking/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "pallet-assets/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-collator-selection/runtime-benchmarks", + "pallet-sudo/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", + "pallet-xcm/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "xcm-builder/runtime-benchmarks", + "cumulus-pallet-session-benchmarking/runtime-benchmarks", + "cumulus-pallet-xcmp-queue/runtime-benchmarks", +] + +try-runtime = [ + "cumulus-pallet-aura-ext/try-runtime", + "cumulus-pallet-dmp-queue/try-runtime", + "cumulus-pallet-parachain-system/try-runtime", + "cumulus-pallet-xcm/try-runtime", + "cumulus-pallet-xcmp-queue/try-runtime", + "frame-executive/try-runtime", + "frame-system/try-runtime", + "frame-try-runtime/try-runtime", + "pallet-aura/try-runtime", + "pallet-authorship/try-runtime", + "pallet-balances/try-runtime", + "pallet-collator-selection/try-runtime", + "pallet-session/try-runtime", + "pallet-sudo/try-runtime", + "pallet-timestamp/try-runtime", + "pallet-transaction-payment/try-runtime", + "pallet-assets/try-runtime", + "pallet-asset-tx-payment/try-runtime", + "pallet-xcm/try-runtime", + "parachain-info/try-runtime", +] diff --git a/integration-tests/penpal/build.rs b/integration-tests/penpal/build.rs new file mode 100644 index 000000000..256e9fb76 --- /dev/null +++ b/integration-tests/penpal/build.rs @@ -0,0 +1,27 @@ +// Copyright 2019-2021 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Substrate is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +#[cfg(feature = "std")] +fn main() { + substrate_wasm_builder::WasmBuilder::new() + .with_current_project() + .export_heap_base() + .import_memory() + .build() +} + +#[cfg(not(feature = "std"))] +fn main() {} diff --git a/integration-tests/penpal/src/lib.rs b/integration-tests/penpal/src/lib.rs new file mode 100644 index 000000000..0a0e3275f --- /dev/null +++ b/integration-tests/penpal/src/lib.rs @@ -0,0 +1,849 @@ +// Copyright 2019-2022 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! The Penpal runtime is designed as a test runtime that can be created using an arbitrary parachain id. +//! (and as such multiple parachains can be on the same relay node - though make sure you have enough relay +//! nodes running to support this or you will get the not scheduled on a core error message.) +//! +//! The penpal runtime's primary use is as a partner when testing statemine/t with reserve asset transfers. +#![cfg_attr(not(feature = "std"), no_std)] +// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. +#![recursion_limit = "256"] + +// Make the WASM binary available. +#[cfg(feature = "std")] +include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); + +mod weights; +pub mod xcm_config; + +use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; +use frame_support::{ + construct_runtime, + dispatch::DispatchClass, + pallet_prelude::Weight, + parameter_types, + traits::{AsEnsureOriginWithArg, ConstU32, ConstU64, ConstU8, Everything}, + weights::{ + constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, FeePolynomial, + WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, + }, + PalletId, +}; +use frame_system::{ + limits::{BlockLength, BlockWeights}, + EnsureRoot, EnsureSigned, +}; +use smallvec::smallvec; +use sp_api::impl_runtime_apis; +pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; +use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; +use sp_runtime::{ + create_runtime_str, generic, impl_opaque_keys, + traits::{AccountIdLookup, BlakeTwo256, Block as BlockT}, + transaction_validity::{TransactionSource, TransactionValidity}, + ApplyExtrinsicResult, +}; +pub use sp_runtime::{traits::ConvertInto, MultiAddress, Perbill, Permill}; +use sp_std::prelude::*; +#[cfg(feature = "std")] +use sp_version::NativeVersion; +use sp_version::RuntimeVersion; +use xcm_config::{AssetsToBlockAuthor, XcmConfig, XcmOriginToTransactDispatchOrigin}; + +#[cfg(any(feature = "std", test))] +pub use sp_runtime::BuildStorage; + +// Polkadot imports +use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; + +use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; + +// XCM Imports +use parachains_common::{AccountId, Signature}; +use xcm::latest::prelude::BodyId; +use xcm_executor::XcmExecutor; + +/// Balance of an account. +pub type Balance = u128; + +/// 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; + +/// An index to a block. +pub type BlockNumber = u32; + +/// The address format for describing accounts. +pub type Address = MultiAddress; + +/// Block header type as expected by this runtime. +pub type Header = generic::Header; + +/// Block type as expected by this runtime. +pub type Block = generic::Block; + +/// A Block signed with a Justification +pub type SignedBlock = generic::SignedBlock; + +/// BlockId type as expected by this runtime. +pub type BlockId = generic::BlockId; + +// Id used for identifying assets. +pub type AssetId = u32; + +/// The SignedExtension to the basic transaction logic. +pub type SignedExtra = ( + frame_system::CheckNonZeroSender, + frame_system::CheckSpecVersion, + frame_system::CheckTxVersion, + frame_system::CheckGenesis, + frame_system::CheckEra, + frame_system::CheckNonce, + frame_system::CheckWeight, + pallet_asset_tx_payment::ChargeAssetTxPayment, +); + +/// Unchecked extrinsic type as expected by this runtime. +pub type UncheckedExtrinsic = + generic::UncheckedExtrinsic; + +pub type Migrations = + (pallet_balances::migration::MigrateToTrackInactive,); + +/// Executive: handles dispatch to the various modules. +pub type Executive = frame_executive::Executive< + Runtime, + Block, + frame_system::ChainContext, + Runtime, + AllPalletsWithSystem, + Migrations, +>; + +/// 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. +pub struct WeightToFee; +impl frame_support::weights::WeightToFee for WeightToFee { + type Balance = Balance; + + fn weight_to_fee(weight: &Weight) -> Self::Balance { + let time_poly: FeePolynomial = RefTimeToFee::polynomial().into(); + let proof_poly: FeePolynomial = ProofSizeToFee::polynomial().into(); + + // Take the maximum instead of the sum to charge by the more scarce resource. + time_poly.eval(weight.ref_time()).max(proof_poly.eval(weight.proof_size())) + } +} + +/// Maps the reference time component of `Weight` to a fee. +pub struct RefTimeToFee; +impl WeightToFeePolynomial for RefTimeToFee { + type Balance = Balance; + fn polynomial() -> WeightToFeeCoefficients { + let p = MILLIUNIT / 10; + let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time()); + + smallvec![WeightToFeeCoefficient { + degree: 1, + negative: false, + coeff_frac: Perbill::from_rational(p % q, q), + coeff_integer: p / q, + }] + } +} + +/// Maps the proof size component of `Weight` to a fee. +pub struct ProofSizeToFee; +impl WeightToFeePolynomial for ProofSizeToFee { + type Balance = Balance; + fn polynomial() -> WeightToFeeCoefficients { + // Map 10kb proof to 1 CENT. + let p = MILLIUNIT / 10; + let q = 10_000; + + smallvec![WeightToFeeCoefficient { + degree: 1, + negative: false, + coeff_frac: Perbill::from_rational(p % q, q), + coeff_integer: p / q, + }] + } +} +/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know +/// the specifics of the runtime. They can then be made to be agnostic over specific formats +/// of data like extrinsics, allowing for them to continue syncing the network through upgrades +/// to even the core data structures. +pub mod opaque { + use super::*; + use sp_runtime::{generic, traits::BlakeTwo256}; + + pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; + /// Opaque block header type. + pub type Header = generic::Header; + /// Opaque block type. + pub type Block = generic::Block; + /// Opaque block identifier type. + pub type BlockId = generic::BlockId; +} + +impl_opaque_keys! { + pub struct SessionKeys { + pub aura: Aura, + } +} + +#[sp_version::runtime_version] +pub const VERSION: RuntimeVersion = RuntimeVersion { + spec_name: create_runtime_str!("penpal-parachain"), + impl_name: create_runtime_str!("penpal-parachain"), + authoring_version: 1, + spec_version: 9430, + impl_version: 0, + apis: RUNTIME_API_VERSIONS, + transaction_version: 1, + state_version: 1, +}; + +/// This determines the average expected block time that we are targeting. +/// Blocks will be produced at a minimum duration defined by `SLOT_DURATION`. +/// `SLOT_DURATION` is picked up by `pallet_timestamp` which is in turn picked +/// up by `pallet_aura` to implement `fn slot_duration()`. +/// +/// Change this to adjust the block time. +pub const MILLISECS_PER_BLOCK: u64 = 12000; + +// NOTE: Currently it is not possible to change the slot duration after the chain has started. +// Attempting to do so will brick block production. +pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; + +// Time is measured by number of blocks. +pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); +pub const HOURS: BlockNumber = MINUTES * 60; +pub const DAYS: BlockNumber = HOURS * 24; + +// Unit = the base number of indivisible units for balances +pub const UNIT: Balance = 1_000_000_000_000; +pub const MILLIUNIT: Balance = 1_000_000_000; +pub const MICROUNIT: Balance = 1_000_000; + +/// The existential deposit. Set to 1/10 of the Connected Relay Chain. +pub const EXISTENTIAL_DEPOSIT: Balance = MILLIUNIT; + +/// We assume that ~5% of the block weight is consumed by `on_initialize` handlers. This is +/// used to limit the maximal weight of a single extrinsic. +const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5); + +/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used by +/// `Operational` extrinsics. +const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); + +/// We allow for 0.5 of a second of compute with a 12 second average block time. +const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_parts( + WEIGHT_REF_TIME_PER_SECOND.saturating_div(2), + cumulus_primitives_core::relay_chain::MAX_POV_SIZE as u64, +); + +/// The version information used to identify this runtime when compiled natively. +#[cfg(feature = "std")] +pub fn native_version() -> NativeVersion { + NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } +} + +parameter_types! { + pub const Version: RuntimeVersion = VERSION; + + // This part is copied from Substrate's `bin/node/runtime/src/lib.rs`. + // The `RuntimeBlockLength` and `RuntimeBlockWeights` exist here because the + // `DeletionWeightLimit` and `DeletionQueueDepth` depend on those to parameterize + // the lazy contract deletion. + pub RuntimeBlockLength: BlockLength = + BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); + pub RuntimeBlockWeights: BlockWeights = 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 some extra reserved space, so that they + // are included even if block reached `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 const SS58Prefix: u16 = 42; +} + +// Configure FRAME pallets to include in runtime. + +impl frame_system::Config for Runtime { + /// The identifier used to distinguish between accounts. + type AccountId = AccountId; + /// The aggregated dispatch type that is available for extrinsics. + type RuntimeCall = RuntimeCall; + /// The lookup mechanism to get account ID from whatever is passed in dispatchers. + type Lookup = AccountIdLookup; + /// The index type for storing how many extrinsics an account has signed. + type Index = Index; + /// The index type for blocks. + type BlockNumber = BlockNumber; + /// The type for hashing blocks and tries. + type Hash = Hash; + /// The hashing algorithm used. + type Hashing = BlakeTwo256; + /// The header type. + type Header = generic::Header; + /// The ubiquitous event type. + type RuntimeEvent = RuntimeEvent; + /// The ubiquitous origin type. + type RuntimeOrigin = RuntimeOrigin; + /// Maximum number of block number to block hash mappings to keep (oldest pruned first). + type BlockHashCount = BlockHashCount; + /// Runtime version. + type Version = Version; + /// Converts a module to an index of this module in the 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 = (); + /// The weight of database operations that the runtime can invoke. + type DbWeight = RocksDbWeight; + /// The basic call filter to use in dispatchable. + type BaseCallFilter = Everything; + /// Weight information for the extrinsics of this pallet. + type SystemWeightInfo = (); + /// Block & extrinsics weights: base values and limits. + type BlockWeights = RuntimeBlockWeights; + /// The maximum length of a block (in bytes). + type BlockLength = RuntimeBlockLength; + /// This is used as an identifier of the chain. 42 is the generic substrate prefix. + type SS58Prefix = SS58Prefix; + /// The action to take on a Runtime Upgrade + 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 = Aura; + type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>; + type WeightInfo = (); +} + +impl pallet_authorship::Config for Runtime { + type FindAuthor = pallet_session::FindAccountFromAuthorIndex; + type EventHandler = (CollatorSelection,); +} + +parameter_types! { + pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT; +} + +impl pallet_balances::Config for Runtime { + type MaxLocks = ConstU32<50>; + /// The type for recording an account's balance. + type Balance = Balance; + /// The ubiquitous event type. + type RuntimeEvent = RuntimeEvent; + type DustRemoval = (); + type ExistentialDeposit = ExistentialDeposit; + type AccountStore = System; + type WeightInfo = pallet_balances::weights::SubstrateWeight; + type MaxReserves = ConstU32<50>; + type ReserveIdentifier = [u8; 8]; + type HoldIdentifier = (); + type FreezeIdentifier = (); + type MaxHolds = ConstU32<0>; + type MaxFreezes = ConstU32<0>; +} + +parameter_types! { + /// Relay Chain `TransactionByteFee` / 10 + pub const TransactionByteFee: Balance = 10 * MICROUNIT; +} + +impl pallet_transaction_payment::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; + type WeightToFee = WeightToFee; + type LengthToFee = ConstantMultiplier; + type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; + type OperationalFeeMultiplier = ConstU8<5>; +} + +parameter_types! { + pub const AssetDeposit: Balance = 0; + pub const AssetAccountDeposit: Balance = 0; + pub const ApprovalDeposit: Balance = 0; + pub const AssetsStringLimit: u32 = 50; + pub const MetadataDepositBase: Balance = 0; + pub const MetadataDepositPerByte: Balance = 0; +} + +// /// We allow root and the Relay Chain council to execute privileged asset operations. +// pub type AssetsForceOrigin = +// EnsureOneOf, EnsureXcm>>; + +impl pallet_assets::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Balance = Balance; + type AssetId = AssetId; + type AssetIdParameter = codec::Compact; + type Currency = Balances; + type CreateOrigin = AsEnsureOriginWithArg>; + type ForceOrigin = EnsureRoot; + type AssetDeposit = AssetDeposit; + type MetadataDepositBase = MetadataDepositBase; + type MetadataDepositPerByte = MetadataDepositPerByte; + type ApprovalDeposit = ApprovalDeposit; + type StringLimit = AssetsStringLimit; + type Freezer = (); + type Extra = (); + type WeightInfo = pallet_assets::weights::SubstrateWeight; + type CallbackHandle = (); + type AssetAccountDeposit = AssetAccountDeposit; + type RemoveItemsLimit = frame_support::traits::ConstU32<1000>; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = (); +} + +parameter_types! { + pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); + pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4); +} + +impl cumulus_pallet_parachain_system::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type OnSystemEvent = (); + type SelfParaId = parachain_info::Pallet; + type DmpMessageHandler = DmpQueue; + type ReservedDmpWeight = ReservedDmpWeight; + type OutboundXcmpMessageSource = XcmpQueue; + type XcmpMessageHandler = XcmpQueue; + type ReservedXcmpWeight = ReservedXcmpWeight; + type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases; +} + +impl parachain_info::Config for Runtime {} + +impl cumulus_pallet_aura_ext::Config for Runtime {} + +impl cumulus_pallet_xcmp_queue::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type XcmExecutor = XcmExecutor; + type ChannelInfo = ParachainSystem; + type VersionWrapper = PolkadotXcm; + type ExecuteOverweightOrigin = EnsureRoot; + type ControllerOrigin = EnsureRoot; + type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; + type WeightInfo = (); + type PriceForSiblingDelivery = (); +} + +impl cumulus_pallet_dmp_queue::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type XcmExecutor = XcmExecutor; + type ExecuteOverweightOrigin = EnsureRoot; +} + +parameter_types! { + pub const Period: u32 = 6 * 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 = CollatorSelection; + // Essentially just Aura, but let's be pedantic. + type SessionHandler = ::KeyTypeIdProviders; + type Keys = SessionKeys; + type WeightInfo = (); +} + +impl pallet_aura::Config for Runtime { + type AuthorityId = AuraId; + type DisabledValidators = (); + type MaxAuthorities = ConstU32<100_000>; +} + +parameter_types! { + pub const PotId: PalletId = PalletId(*b"PotStake"); + pub const MaxCandidates: u32 = 1000; + pub const MinCandidates: u32 = 5; + pub const SessionLength: BlockNumber = 6 * HOURS; + pub const MaxInvulnerables: u32 = 100; + pub const ExecutiveBody: BodyId = BodyId::Executive; +} + +// We allow root only to execute privileged collator selection operations. +pub type CollatorSelectionUpdateOrigin = EnsureRoot; + +impl pallet_collator_selection::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type UpdateOrigin = CollatorSelectionUpdateOrigin; + 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 = (); +} + +impl pallet_asset_tx_payment::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Fungibles = Assets; + type OnChargeAssetTransaction = pallet_asset_tx_payment::FungiblesAdapter< + pallet_assets::BalanceToAssetBalance, + AssetsToBlockAuthor, + >; +} + +impl pallet_sudo::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type WeightInfo = pallet_sudo::weights::SubstrateWeight; +} + +// Create the runtime by composing the FRAME pallets that were previously configured. +construct_runtime!( + pub enum Runtime where + Block = Block, + NodeBlock = opaque::Block, + UncheckedExtrinsic = UncheckedExtrinsic, + { + // System support stuff. + System: frame_system::{Pallet, Call, Config, Storage, Event} = 0, + ParachainSystem: cumulus_pallet_parachain_system::{ + Pallet, Call, Config, Storage, Inherent, Event, ValidateUnsigned, + } = 1, + Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 2, + ParachainInfo: parachain_info::{Pallet, Storage, Config} = 3, + + // Monetary stuff. + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 10, + TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event} = 11, + AssetTxPayment: pallet_asset_tx_payment::{Pallet, Event} = 12, + + // Collator support. The order of these 4 are important and shall not change. + Authorship: pallet_authorship::{Pallet, Storage} = 20, + CollatorSelection: pallet_collator_selection::{Pallet, Call, Storage, Event, Config} = 21, + Session: pallet_session::{Pallet, Call, Storage, Event, Config} = 22, + Aura: pallet_aura::{Pallet, Storage, Config} = 23, + AuraExt: cumulus_pallet_aura_ext::{Pallet, Storage, Config} = 24, + + // XCM helpers. + XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event} = 30, + PolkadotXcm: pallet_xcm::{Pallet, Call, Event, Origin, Config} = 31, + CumulusXcm: cumulus_pallet_xcm::{Pallet, Event, Origin} = 32, + DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event} = 33, + + // The main stage. + Assets: pallet_assets::{Pallet, Call, Storage, Event} = 50, + + Sudo: pallet_sudo::{Pallet, Call, Storage, Event, Config} = 255, + } +); + +#[cfg(feature = "runtime-benchmarks")] +#[macro_use] +extern crate frame_benchmarking; + +#[cfg(feature = "runtime-benchmarks")] +mod benches { + define_benchmarks!( + [frame_system, SystemBench::] + [pallet_balances, Balances] + [pallet_session, SessionBench::] + [pallet_sudo, Sudo] + [pallet_timestamp, Timestamp] + [pallet_collator_selection, CollatorSelection] + [cumulus_pallet_xcmp_queue, XcmpQueue] + ); +} + +impl_runtime_apis! { + impl sp_consensus_aura::AuraApi for Runtime { + fn slot_duration() -> sp_consensus_aura::SlotDuration { + sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration()) + } + + fn authorities() -> Vec { + Aura::authorities().into_inner() + } + } + + impl sp_api::Core for Runtime { + fn version() -> RuntimeVersion { + VERSION + } + + fn execute_block(block: Block) { + Executive::execute_block(block) + } + + fn initialize_block(header: &::Header) { + Executive::initialize_block(header) + } + } + + impl sp_api::Metadata for Runtime { + fn metadata() -> OpaqueMetadata { + OpaqueMetadata::new(Runtime::metadata().into()) + } + + fn metadata_at_version(version: u32) -> Option { + Runtime::metadata_at_version(version) + } + + fn metadata_versions() -> sp_std::vec::Vec { + Runtime::metadata_versions() + } + } + + impl sp_block_builder::BlockBuilder for Runtime { + fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { + Executive::apply_extrinsic(extrinsic) + } + + fn finalize_block() -> ::Header { + Executive::finalize_block() + } + + fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { + data.create_extrinsics() + } + + fn check_inherents( + block: Block, + data: sp_inherents::InherentData, + ) -> sp_inherents::CheckInherentsResult { + data.check_extrinsics(&block) + } + } + + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { + fn validate_transaction( + source: TransactionSource, + tx: ::Extrinsic, + block_hash: ::Hash, + ) -> TransactionValidity { + Executive::validate_transaction(source, tx, block_hash) + } + } + + impl sp_offchain::OffchainWorkerApi for Runtime { + fn offchain_worker(header: &::Header) { + Executive::offchain_worker(header) + } + } + + impl sp_session::SessionKeys for Runtime { + fn generate_session_keys(seed: Option>) -> Vec { + SessionKeys::generate(seed) + } + + fn decode_session_keys( + encoded: Vec, + ) -> Option, KeyTypeId)>> { + SessionKeys::decode_into_raw_public_keys(&encoded) + } + } + + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { + fn account_nonce(account: AccountId) -> Index { + System::account_nonce(account) + } + } + + impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi for Runtime { + fn query_info( + uxt: ::Extrinsic, + len: u32, + ) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo { + TransactionPayment::query_info(uxt, len) + } + fn query_fee_details( + uxt: ::Extrinsic, + len: u32, + ) -> pallet_transaction_payment::FeeDetails { + TransactionPayment::query_fee_details(uxt, len) + } + fn query_weight_to_fee(weight: Weight) -> Balance { + TransactionPayment::weight_to_fee(weight) + } + fn query_length_to_fee(length: u32) -> Balance { + TransactionPayment::length_to_fee(length) + } + } + + impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi + for Runtime + { + fn query_call_info( + call: RuntimeCall, + len: u32, + ) -> pallet_transaction_payment::RuntimeDispatchInfo { + TransactionPayment::query_call_info(call, len) + } + fn query_call_fee_details( + call: RuntimeCall, + len: u32, + ) -> pallet_transaction_payment::FeeDetails { + TransactionPayment::query_call_fee_details(call, len) + } + fn query_weight_to_fee(weight: Weight) -> Balance { + TransactionPayment::weight_to_fee(weight) + } + fn query_length_to_fee(length: u32) -> Balance { + TransactionPayment::length_to_fee(length) + } + } + + impl cumulus_primitives_core::CollectCollationInfo for Runtime { + fn collect_collation_info(header: &::Header) -> cumulus_primitives_core::CollationInfo { + ParachainSystem::collect_collation_info(header) + } + } + + #[cfg(feature = "try-runtime")] + impl frame_try_runtime::TryRuntime for Runtime { + fn on_runtime_upgrade(checks: frame_try_runtime::UpgradeCheckSelect) -> (Weight, Weight) { + let weight = Executive::try_runtime_upgrade(checks).unwrap(); + (weight, RuntimeBlockWeights::get().max_block) + } + + fn execute_block( + block: Block, + state_root_check: bool, + signature_check: bool, + select: frame_try_runtime::TryStateSelect, + ) -> Weight { + // NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to + // have a backtrace here. + Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap() + } + } + + #[cfg(feature = "runtime-benchmarks")] + impl frame_benchmarking::Benchmark for Runtime { + fn benchmark_metadata(extra: bool) -> ( + Vec, + Vec, + ) { + use frame_benchmarking::{Benchmarking, BenchmarkList}; + use frame_support::traits::StorageInfoTrait; + use frame_system_benchmarking::Pallet as SystemBench; + use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + + let mut list = Vec::::new(); + list_benchmarks!(list, extra); + + let storage_info = AllPalletsWithSystem::storage_info(); + (list, storage_info) + } + + fn dispatch_benchmark( + config: frame_benchmarking::BenchmarkConfig + ) -> Result, sp_runtime::RuntimeString> { + use frame_benchmarking::{Benchmarking, BenchmarkBatch, TrackedStorageKey}; + + use frame_system_benchmarking::Pallet as SystemBench; + impl frame_system_benchmarking::Config for Runtime {} + + use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + impl cumulus_pallet_session_benchmarking::Config for Runtime {} + + let whitelist: Vec = vec![ + // Block Number + hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(), + // Total Issuance + hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(), + // Execution Phase + hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(), + // Event Count + hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(), + // System Events + hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(), + ]; + + let mut batches = Vec::::new(); + let params = (&config, &whitelist); + add_benchmarks!(params, batches); + + if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } + Ok(batches) + } + } +} + +struct CheckInherents; + +impl cumulus_pallet_parachain_system::CheckInherents for CheckInherents { + fn check_inherents( + block: &Block, + relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof, + ) -> sp_inherents::CheckInherentsResult { + let relay_chain_slot = relay_state_proof + .read_slot() + .expect("Could not read the relay chain slot from the proof"); + + let inherent_data = + cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration( + relay_chain_slot, + sp_std::time::Duration::from_secs(6), + ) + .create_inherent_data() + .expect("Could not create the timestamp inherent data"); + + inherent_data.check_extrinsics(block) + } +} + +cumulus_pallet_parachain_system::register_validate_block! { + Runtime = Runtime, + BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::, + CheckInherents = CheckInherents, +} diff --git a/integration-tests/penpal/src/weights/block_weights.rs b/integration-tests/penpal/src/weights/block_weights.rs new file mode 100644 index 000000000..b2092d875 --- /dev/null +++ b/integration-tests/penpal/src/weights/block_weights.rs @@ -0,0 +1,53 @@ +// This file is part of Substrate. + +// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// 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. + +pub mod constants { + use frame_support::{ + parameter_types, + weights::{constants, Weight}, + }; + + parameter_types! { + /// Importing a block with 0 Extrinsics. + pub const BlockExecutionWeight: Weight = + Weight::from_parts(constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(5_000_000), 0); + } + + #[cfg(test)] + mod test_weights { + use frame_support::weights::constants; + + /// Checks that the weight exists and is sane. + // NOTE: If this test fails but you are sure that the generated values are fine, + // you can delete it. + #[test] + fn sane() { + let w = super::constants::BlockExecutionWeight::get(); + + // At least 100 µs. + assert!( + w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS, + "Weight should be at least 100 µs." + ); + // At most 50 ms. + assert!( + w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS, + "Weight should be at most 50 ms." + ); + } + } +} diff --git a/integration-tests/penpal/src/weights/extrinsic_weights.rs b/integration-tests/penpal/src/weights/extrinsic_weights.rs new file mode 100644 index 000000000..332c3b324 --- /dev/null +++ b/integration-tests/penpal/src/weights/extrinsic_weights.rs @@ -0,0 +1,53 @@ +// This file is part of Substrate. + +// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// 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. + +pub mod constants { + use frame_support::{ + parameter_types, + weights::{constants, Weight}, + }; + + parameter_types! { + /// Executing a NO-OP `System::remarks` Extrinsic. + pub const ExtrinsicBaseWeight: Weight = + Weight::from_parts(constants::WEIGHT_REF_TIME_PER_NANOS.saturating_mul(125_000), 0); + } + + #[cfg(test)] + mod test_weights { + use frame_support::weights::constants; + + /// Checks that the weight exists and is sane. + // NOTE: If this test fails but you are sure that the generated values are fine, + // you can delete it. + #[test] + fn sane() { + let w = super::constants::ExtrinsicBaseWeight::get(); + + // At least 10 µs. + assert!( + w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS, + "Weight should be at least 10 µs." + ); + // At most 1 ms. + assert!( + w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, + "Weight should be at most 1 ms." + ); + } + } +} diff --git a/integration-tests/penpal/src/weights/mod.rs b/integration-tests/penpal/src/weights/mod.rs new file mode 100644 index 000000000..ed0b4dbcd --- /dev/null +++ b/integration-tests/penpal/src/weights/mod.rs @@ -0,0 +1,28 @@ +// This file is part of Substrate. + +// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// 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. + +//! Expose the auto generated weight files. + +pub mod block_weights; +pub mod extrinsic_weights; +pub mod paritydb_weights; +pub mod rocksdb_weights; + +pub use block_weights::constants::BlockExecutionWeight; +pub use extrinsic_weights::constants::ExtrinsicBaseWeight; +pub use paritydb_weights::constants::ParityDbWeight; +pub use rocksdb_weights::constants::RocksDbWeight; diff --git a/integration-tests/penpal/src/weights/paritydb_weights.rs b/integration-tests/penpal/src/weights/paritydb_weights.rs new file mode 100644 index 000000000..4338d928d --- /dev/null +++ b/integration-tests/penpal/src/weights/paritydb_weights.rs @@ -0,0 +1,63 @@ +// This file is part of Substrate. + +// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// 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. + +pub mod constants { + use frame_support::{ + parameter_types, + weights::{constants, RuntimeDbWeight}, + }; + + parameter_types! { + /// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights + /// are available for brave runtime engineers who may want to try this out as default. + pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight { + read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS, + write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS, + }; + } + + #[cfg(test)] + mod test_db_weights { + use super::constants::ParityDbWeight as W; + use frame_support::weights::constants; + + /// Checks that all weights exist and have sane values. + // NOTE: If this test fails but you are sure that the generated values are fine, + // you can delete it. + #[test] + fn sane() { + // At least 1 µs. + assert!( + W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS, + "Read weight should be at least 1 µs." + ); + assert!( + W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS, + "Write weight should be at least 1 µs." + ); + // At most 1 ms. + assert!( + W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, + "Read weight should be at most 1 ms." + ); + assert!( + W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, + "Write weight should be at most 1 ms." + ); + } + } +} diff --git a/integration-tests/penpal/src/weights/rocksdb_weights.rs b/integration-tests/penpal/src/weights/rocksdb_weights.rs new file mode 100644 index 000000000..1d115d963 --- /dev/null +++ b/integration-tests/penpal/src/weights/rocksdb_weights.rs @@ -0,0 +1,63 @@ +// This file is part of Substrate. + +// Copyright (C) 2022 Parity Technologies (UK) Ltd. +// 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. + +pub mod constants { + use frame_support::{ + parameter_types, + weights::{constants, RuntimeDbWeight}, + }; + + parameter_types! { + /// By default, Substrate uses `RocksDB`, so this will be the weight used throughout + /// the runtime. + pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight { + read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS, + write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS, + }; + } + + #[cfg(test)] + mod test_db_weights { + use super::constants::RocksDbWeight as W; + use frame_support::weights::constants; + + /// Checks that all weights exist and have sane values. + // NOTE: If this test fails but you are sure that the generated values are fine, + // you can delete it. + #[test] + fn sane() { + // At least 1 µs. + assert!( + W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS, + "Read weight should be at least 1 µs." + ); + assert!( + W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS, + "Write weight should be at least 1 µs." + ); + // At most 1 ms. + assert!( + W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, + "Read weight should be at most 1 ms." + ); + assert!( + W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, + "Write weight should be at most 1 ms." + ); + } + } +} diff --git a/integration-tests/penpal/src/xcm_config.rs b/integration-tests/penpal/src/xcm_config.rs new file mode 100644 index 000000000..26beb4741 --- /dev/null +++ b/integration-tests/penpal/src/xcm_config.rs @@ -0,0 +1,349 @@ +// Copyright 2019-2022 Parity Technologies (UK) Ltd. +// This file is part of Cumulus. + +// Cumulus is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Cumulus is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Cumulus. If not, see . + +//! Holds the XCM specific configuration that would otherwise be in lib.rs +//! +//! This configuration dictates how the Penpal chain will communicate with other chains. +//! +//! One of the main uses of the penpal chain will be to be a benefactor of reserve asset transfers +//! with statemine as the reserve. At present no derivative tokens are minted on receipt of a +//! ReserveAssetTransferDeposited message but that will but the intension will be to support this soon. +use super::{ + AccountId, AllPalletsWithSystem, AssetId as AssetIdPalletAssets, Assets, Balance, Balances, + ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, + WeightToFee, XcmpQueue, +}; +use core::marker::PhantomData; +use frame_support::{ + match_types, parameter_types, + traits::{ + fungibles::{self, Balanced, Credit}, + ConstU32, Contains, ContainsPair, Everything, Get, Nothing, + }, + weights::Weight, +}; +use frame_system::EnsureRoot; +use pallet_asset_tx_payment::HandleCredit; +use pallet_xcm::XcmPassthrough; +use parachains_common::xcm_config::{DenyReserveTransferToRelayChain, DenyThenTry}; +use polkadot_parachain::primitives::Sibling; +use polkadot_runtime_common::impls::ToAuthor; +use sp_runtime::traits::Zero; +use xcm::latest::prelude::*; +use xcm_builder::{ + AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, + AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex, + ConvertedConcreteId, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, + IsConcrete, LocalMint, NativeAsset, ParentIsPreset, RelayChainAsNative, + SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, + SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, + WithComputedOrigin, +}; +use xcm_executor::{traits::JustTry, XcmExecutor}; + +parameter_types! { + pub const RelayLocation: MultiLocation = MultiLocation::parent(); + pub const RelayNetwork: Option = None; + pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); + pub UniversalLocation: InteriorMultiLocation = X1(Parachain(ParachainInfo::parachain_id().into())); +} + +/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used +/// when determining ownership of accounts for asset transacting and when attempting to use XCM +/// `Transact` in order to determine the dispatch Origin. +pub type LocationToAccountId = ( + // The parent (Relay-chain) origin converts to the parent `AccountId`. + ParentIsPreset, + // Sibling parachain origins convert to AccountId via the `ParaId::into`. + SiblingParachainConvertsVia, + // Straight up local `AccountId32` origins just alias directly to `AccountId`. + AccountId32Aliases, +); + +/// Means for transacting assets on this chain. +pub type CurrencyTransactor = CurrencyAdapter< + // Use this currency: + Balances, + // Use this currency when it is a fungible asset matching the given location or name: + IsConcrete, + // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID: + LocationToAccountId, + // Our chain's account ID type (we can't get away without mentioning it explicitly): + AccountId, + // We don't track any teleports. + (), +>; + +/// Means for transacting assets besides the native currency on this chain. +pub type FungiblesTransactor = FungiblesAdapter< + // Use this fungibles implementation: + Assets, + // Use this currency when it is a fungible asset matching the given location or name: + ConvertedConcreteId< + AssetIdPalletAssets, + Balance, + AsPrefixedGeneralIndex, + JustTry, + >, + // Convert an XCM MultiLocation into a local account id: + LocationToAccountId, + // Our chain's account ID type (we can't get away without mentioning it explicitly): + AccountId, + // We only want to allow teleports of known assets. We use non-zero issuance as an indication + // that this asset is known. + LocalMint>, + // The account to use for tracking teleports. + CheckingAccount, +>; + +/// Means for transacting assets on this chain. +pub type AssetTransactors = (CurrencyTransactor, FungiblesTransactor); + +/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance, +/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can +/// biases the kind of local `Origin` it will become. +pub type XcmOriginToTransactDispatchOrigin = ( + // Sovereign account converter; this attempts to derive an `AccountId` from the origin location + // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for + // foreign chains who want to have a local sovereign account on this chain which they control. + SovereignSignedViaLocation, + // Native converter for Relay-chain (Parent) location; will convert to a `Relay` origin when + // recognized. + RelayChainAsNative, + // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when + // recognized. + SiblingParachainAsNative, + // Native signed account converter; this just converts an `AccountId32` origin into a normal + // `RuntimeOrigin::Signed` origin of the same 32-byte value. + SignedAccountId32AsNative, + // Xcm origins can be represented natively under the Xcm pallet's Xcm origin. + XcmPassthrough, +); + +parameter_types! { + // One XCM operation is 1_000_000_000 weight - almost certainly a conservative estimate. + pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024); + pub const MaxInstructions: u32 = 100; + pub const MaxAssetsIntoHolding: u32 = 64; +} + +match_types! { + pub type ParentOrParentsExecutivePlurality: impl Contains = { + MultiLocation { parents: 1, interior: Here } | + MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Executive, .. }) } + }; + pub type CommonGoodAssetsParachain: impl Contains = { + MultiLocation { parents: 1, interior: X1(Parachain(1000)) } + }; +} + +pub type Barrier = DenyThenTry< + DenyReserveTransferToRelayChain, + ( + TakeWeightCredit, + // Expected responses are OK. + AllowKnownQueryResponses, + // Allow XCMs with some computed origins to pass through. + WithComputedOrigin< + ( + // If the message is one that immediately attemps to pay for execution, then allow it. + AllowTopLevelPaidExecutionFrom, + // Common Good Assets parachain, parent and its exec plurality get free execution + AllowExplicitUnpaidExecutionFrom<( + CommonGoodAssetsParachain, + ParentOrParentsExecutivePlurality, + )>, + // Subscriptions for version tracking are OK. + AllowSubscriptionsFrom, + ), + UniversalLocation, + ConstU32<8>, + >, + ), +>; + +/// Type alias to conveniently refer to `frame_system`'s `Config::AccountId`. +pub type AccountIdOf = ::AccountId; + +/// Asset filter that allows all assets from a certain location. +pub struct AssetsFrom(PhantomData); +impl> ContainsPair for AssetsFrom { + fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { + let loc = T::get(); + &loc == origin && + matches!(asset, MultiAsset { id: AssetId::Concrete(asset_loc), fun: Fungible(_a) } + if asset_loc.match_and_split(&loc).is_some()) + } +} + +/// Allow checking in assets that have issuance > 0. +pub struct NonZeroIssuance(PhantomData<(AccountId, Assets)>); +impl Contains<>::AssetId> + for NonZeroIssuance +where + Assets: fungibles::Inspect, +{ + fn contains(id: &>::AssetId) -> bool { + !Assets::total_issuance(id.clone()).is_zero() + } +} + +/// A `HandleCredit` implementation that naively transfers the fees to the block author. +/// Will drop and burn the assets in case the transfer fails. +pub struct AssetsToBlockAuthor(PhantomData); +impl HandleCredit, pallet_assets::Pallet> for AssetsToBlockAuthor +where + R: pallet_authorship::Config + pallet_assets::Config, + AccountIdOf: From + Into, +{ + fn handle_credit(credit: Credit, pallet_assets::Pallet>) { + if let Some(author) = pallet_authorship::Pallet::::author() { + // In case of error: Will drop the result triggering the `OnDrop` of the imbalance. + let _ = pallet_assets::Pallet::::resolve(&author, credit); + } + } +} + +pub trait Reserve { + /// Returns assets reserve location. + fn reserve(&self) -> Option; +} + +// Takes the chain part of a MultiAsset +impl Reserve for MultiAsset { + fn reserve(&self) -> Option { + if let AssetId::Concrete(location) = self.id { + let first_interior = location.first_interior(); + let parents = location.parent_count(); + match (parents, first_interior) { + (0, Some(Parachain(id))) => Some(MultiLocation::new(0, X1(Parachain(*id)))), + (1, Some(Parachain(id))) => Some(MultiLocation::new(1, X1(Parachain(*id)))), + (1, _) => Some(MultiLocation::parent()), + _ => None, + } + } else { + None + } + } +} + +/// A `FilterAssetLocation` implementation. Filters multi native assets whose +/// reserve is same with `origin`. +pub struct MultiNativeAsset; +impl ContainsPair for MultiNativeAsset { + fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { + if let Some(ref reserve) = asset.reserve() { + if reserve == origin { + return true + } + } + false + } +} + +parameter_types! { + pub CommonGoodAssetsLocation: MultiLocation = MultiLocation::new(1, X1(Parachain(1000))); + // ALWAYS ensure that the index in PalletInstance stays up-to-date with + // Statemint's Assets pallet index + pub CommonGoodAssetsPalletLocation: MultiLocation = + MultiLocation::new(1, X2(Parachain(1000), PalletInstance(50))); + pub CheckingAccount: AccountId = PolkadotXcm::check_account(); +} + +pub type Reserves = (NativeAsset, AssetsFrom); + +pub struct XcmConfig; +impl xcm_executor::Config for XcmConfig { + type RuntimeCall = RuntimeCall; + type XcmSender = XcmRouter; + // How to withdraw and deposit an asset. + type AssetTransactor = AssetTransactors; + type OriginConverter = XcmOriginToTransactDispatchOrigin; + type IsReserve = MultiNativeAsset; // TODO: maybe needed to be replaced by Reserves + type IsTeleporter = NativeAsset; + type UniversalLocation = UniversalLocation; + type Barrier = Barrier; + type Weigher = FixedWeightBounds; + type Trader = + UsingComponents>; + type ResponseHandler = PolkadotXcm; + type AssetTrap = PolkadotXcm; + type AssetClaims = PolkadotXcm; + type SubscriptionService = PolkadotXcm; + type PalletInstancesInfo = AllPalletsWithSystem; + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; + type AssetLocker = (); + type AssetExchanger = (); + type FeeManager = (); + type MessageExporter = (); + type UniversalAliases = Nothing; + type CallDispatcher = RuntimeCall; + type SafeCallFilter = Everything; +} + +/// No local origins on this chain are allowed to dispatch XCM sends/executions. +pub type LocalOriginToLocation = SignedToAccountId32; + +/// The means for routing XCM messages which are not for local execution into the right message +/// queues. +pub type XcmRouter = ( + // Two routers - use UMP to communicate with the relay chain: + cumulus_primitives_utility::ParentAsUmp, + // ..and XCMP to communicate with the sibling chains. + XcmpQueue, +); + +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = Some(Parent.into()); +} + +impl pallet_xcm::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type SendXcmOrigin = EnsureXcmOrigin; + type XcmRouter = XcmRouter; + type ExecuteXcmOrigin = EnsureXcmOrigin; + type XcmExecuteFilter = Nothing; + // ^ Disable dispatchable execute on the XCM pallet. + // Needs to be `Everything` for local testing. + type XcmExecutor = XcmExecutor; + type XcmTeleportFilter = Everything; + type XcmReserveTransferFilter = Everything; + type Weigher = FixedWeightBounds; + type UniversalLocation = UniversalLocation; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + + const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; + // ^ Override for AdvertisedXcmVersion default + type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type Currency = Balances; + type CurrencyMatcher = (); + type TrustedLockers = (); + type SovereignAccountOf = LocationToAccountId; + type MaxLockers = ConstU32<8>; + type WeightInfo = pallet_xcm::TestWeightInfo; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = ReachableDest; + type AdminOrigin = EnsureRoot; + type MaxRemoteLockConsumers = ConstU32<0>; + type RemoteLockConsumerIdentifier = (); +} + +impl cumulus_pallet_xcm::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type XcmExecutor = XcmExecutor; +} diff --git a/integration-tests/src/tests/hrmp_flow.rs b/integration-tests/src/tests/hrmp_flow.rs index 20e1d69af..c2b25c5cf 100644 --- a/integration-tests/src/tests/hrmp_flow.rs +++ b/integration-tests/src/tests/hrmp_flow.rs @@ -13,7 +13,7 @@ fn balance_query() { let execution_currency: MultiAsset = (MultiLocation { parents: 0, interior: Here }, 1_0_000_000_000u128).into(); // 1 unit for executing let expected_currency: MultiAsset = (MultiLocation { parents: 0, interior: Here }, 1_000_000_0_000_000_000u128).into(); // 1MM units for migrations - let xcm = VersionedXcm::from(Xcm(vec![ + let xcm = Xcm(vec![ UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, WithdrawAsset(vec![expected_currency.clone()].into()), ReportHolding { @@ -25,13 +25,13 @@ fn balance_query() { assets: Wild(All), }, DepositAsset { assets: Wild(All), beneficiary: ParentThen(Parachain(3355).into()).into() } - ])); + ]); let penpal_sov_acc = PolkadotRelay::sovereign_account_id_of(Parachain(Penpal::para_id().into()).into()); PolkadotRelay::fund_accounts(vec![(penpal_sov_acc, 100_0_000_000_000u128)]); Polimec::execute_with(|| { - assert_ok!(PolimecXcmPallet::send(PolimecOrigin::root(), bx!(ParentThen(Parachain(3000).into()).into()), bx!(xcm),)); + assert_ok!(PolimecXcmPallet::send_xcm(Here, MultiLocation::from(ParentThen(X1(Parachain(Penpal::para_id().into())))), xcm)); println!("polimec events:"); dbg!(Penpal::events()) }); diff --git a/pallets/polimec-receiver/Cargo.toml b/pallets/polimec-receiver/Cargo.toml index 365fb7c13..d047b116a 100644 --- a/pallets/polimec-receiver/Cargo.toml +++ b/pallets/polimec-receiver/Cargo.toml @@ -37,5 +37,8 @@ std = [ "frame-benchmarking/std", "frame-support/std", "frame-system/std", + "sp-core/std", + "sp-io/std", + "sp-runtime/std" ] try-runtime = [ "frame-support/try-runtime" ] From 8549be2629e685a08da6f06ab6445213cc6c1f45 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 30 Oct 2023 14:58:42 +0100 Subject: [PATCH 005/212] save --- integration-tests/penpal/src/xcm_config.rs | 9 +++++++-- integration-tests/src/constants.rs | 15 ++++++++++++--- integration-tests/src/tests/mod.rs | 2 +- .../src/tests/{hrmp_flow.rs => sandbox.rs} | 8 ++++---- 4 files changed, 24 insertions(+), 10 deletions(-) rename integration-tests/src/tests/{hrmp_flow.rs => sandbox.rs} (87%) diff --git a/integration-tests/penpal/src/xcm_config.rs b/integration-tests/penpal/src/xcm_config.rs index 26beb4741..64007cdad 100644 --- a/integration-tests/penpal/src/xcm_config.rs +++ b/integration-tests/penpal/src/xcm_config.rs @@ -57,6 +57,7 @@ use xcm_executor::{traits::JustTry, XcmExecutor}; parameter_types! { pub const RelayLocation: MultiLocation = MultiLocation::parent(); pub const RelayNetwork: Option = None; + pub const HereLocation: MultiLocation = MultiLocation::here(); pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); pub UniversalLocation: InteriorMultiLocation = X1(Parachain(ParachainInfo::parachain_id().into())); } @@ -78,7 +79,7 @@ pub type CurrencyTransactor = CurrencyAdapter< // Use this currency: Balances, // Use this currency when it is a fungible asset matching the given location or name: - IsConcrete, + IsConcrete, // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID: LocationToAccountId, // Our chain's account ID type (we can't get away without mentioning it explicitly): @@ -148,6 +149,9 @@ match_types! { pub type CommonGoodAssetsParachain: impl Contains = { MultiLocation { parents: 1, interior: X1(Parachain(1000)) } }; + pub type Polimec: impl Contains = { + MultiLocation { parents: 1, interior: X1(Parachain(3355)) } + }; } pub type Barrier = DenyThenTry< @@ -161,10 +165,11 @@ pub type Barrier = DenyThenTry< ( // If the message is one that immediately attemps to pay for execution, then allow it. AllowTopLevelPaidExecutionFrom, - // Common Good Assets parachain, parent and its exec plurality get free execution + // Polimec, Common Good Assets parachain, parent and its exec plurality get free execution AllowExplicitUnpaidExecutionFrom<( CommonGoodAssetsParachain, ParentOrParentsExecutivePlurality, + Polimec, )>, // Subscriptions for version tracking are OK. AllowSubscriptionsFrom, diff --git a/integration-tests/src/constants.rs b/integration-tests/src/constants.rs index cfefd6c04..df27b7cf7 100644 --- a/integration-tests/src/constants.rs +++ b/integration-tests/src/constants.rs @@ -19,6 +19,7 @@ pub const REF_TIME_THRESHOLD: u64 = 33; pub const PROOF_SIZE_THRESHOLD: u64 = 33; pub const INITIAL_DEPOSIT: u128 = 420_0_000_000_000; + type AccountPublic = ::Signer; /// Helper function to generate a crypto pair from seed @@ -232,7 +233,7 @@ pub mod polimec { use pallet_funding::AcceptedFundingAsset; use xcm::{prelude::Parachain, v3::Parent}; - pub const PARA_ID: u32 = 3344; + pub const PARA_ID: u32 = 3355; pub const ED: Balance = polimec_parachain_runtime::EXISTENTIAL_DEPOSIT; pub fn genesis() -> Storage { @@ -298,18 +299,26 @@ pub mod polimec { // Penpal pub mod penpal { use super::*; + use crate::{ParaId, Penpal}; + use xcm::{prelude::Parachain, v3::Parent}; pub const PARA_ID: u32 = 6969; pub const ED: Balance = penpal_runtime::EXISTENTIAL_DEPOSIT; pub fn genesis() -> Storage { + let mut funded_accounts = vec![ + (Penpal::sovereign_account_id_of((Parent, Parachain(statemint::PARA_ID)).into()), INITIAL_DEPOSIT), + (Penpal::sovereign_account_id_of((Parent, Parachain(polimec::PARA_ID)).into()), 2_000_000_0_000_000_000), // i.e the CTs sold on polimec + ]; + funded_accounts.extend(accounts::init_balances().iter().cloned().map(|k| (k, INITIAL_DEPOSIT))); + let genesis_config = penpal_runtime::GenesisConfig { system: penpal_runtime::SystemConfig { code: penpal_runtime::WASM_BINARY.expect("WASM binary was not build, please build it!").to_vec(), }, balances: penpal_runtime::BalancesConfig { - balances: accounts::init_balances().iter().cloned().map(|k| (k, INITIAL_DEPOSIT)).collect(), + balances: funded_accounts, }, - parachain_info: penpal_runtime::ParachainInfoConfig { parachain_id: PARA_ID.into() }, + parachain_info: penpal_runtime::ParachainInfoConfig { parachain_id: ParaId::from(PARA_ID) }, collator_selection: penpal_runtime::CollatorSelectionConfig { invulnerables: collators::invulnerables().iter().cloned().map(|(acc, _)| acc).collect(), candidacy_bond: ED * 16, diff --git a/integration-tests/src/tests/mod.rs b/integration-tests/src/tests/mod.rs index 065a64bff..9ef76a00b 100644 --- a/integration-tests/src/tests/mod.rs +++ b/integration-tests/src/tests/mod.rs @@ -1,3 +1,3 @@ mod basic_comms; -mod hrmp_flow; +mod sandbox; mod reserve_backed_transfers; diff --git a/integration-tests/src/tests/hrmp_flow.rs b/integration-tests/src/tests/sandbox.rs similarity index 87% rename from integration-tests/src/tests/hrmp_flow.rs rename to integration-tests/src/tests/sandbox.rs index c2b25c5cf..81d0c65f2 100644 --- a/integration-tests/src/tests/hrmp_flow.rs +++ b/integration-tests/src/tests/sandbox.rs @@ -5,8 +5,6 @@ const MAX_PROOF_SIZE: u64 = 10_000; pub const REF_TIME_THRESHOLD: u64 = 33; pub const PROOF_SIZE_THRESHOLD: u64 = 33; -use polkadot_runtime_parachains::{hrmp as parachain_hrmp, origin as parachains_origin, paras as parachains_paras}; - #[test] fn balance_query() { let max_weight = Weight::from_parts(MAX_REF_TIME, MAX_PROOF_SIZE); @@ -26,6 +24,8 @@ fn balance_query() { }, DepositAsset { assets: Wild(All), beneficiary: ParentThen(Parachain(3355).into()).into() } ]); + let polimec_on_penpal = Penpal::sovereign_account_id_of((Parent, Parachain(polimec::PARA_ID)).into()); + let balance_polimec = Penpal::account_data_of(polimec_on_penpal); let penpal_sov_acc = PolkadotRelay::sovereign_account_id_of(Parachain(Penpal::para_id().into()).into()); PolkadotRelay::fund_accounts(vec![(penpal_sov_acc, 100_0_000_000_000u128)]); @@ -33,7 +33,7 @@ fn balance_query() { Polimec::execute_with(|| { assert_ok!(PolimecXcmPallet::send_xcm(Here, MultiLocation::from(ParentThen(X1(Parachain(Penpal::para_id().into())))), xcm)); println!("polimec events:"); - dbg!(Penpal::events()) + dbg!(Polimec::events()) }); Penpal::execute_with(|| { @@ -42,7 +42,7 @@ fn balance_query() { }); Polimec::execute_with(|| { - println!("penpal events:"); + println!("Polimec events:"); dbg!(Polimec::events()); }); From 3fd4ee02112fa349ba52e382cc318bcb3205e761 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 31 Oct 2023 17:01:33 +0100 Subject: [PATCH 006/212] save --- integration-tests/src/tests/sandbox.rs | 10 +++- pallets/funding/src/lib.rs | 21 ++++++- pallets/polimec-receiver/src/benchmarking.rs | 20 ------- pallets/polimec-receiver/src/mock.rs | 63 -------------------- pallets/polimec-receiver/src/tests.rs | 20 ------- 5 files changed, 29 insertions(+), 105 deletions(-) delete mode 100644 pallets/polimec-receiver/src/benchmarking.rs delete mode 100644 pallets/polimec-receiver/src/mock.rs delete mode 100644 pallets/polimec-receiver/src/tests.rs diff --git a/integration-tests/src/tests/sandbox.rs b/integration-tests/src/tests/sandbox.rs index 81d0c65f2..0cc4972c0 100644 --- a/integration-tests/src/tests/sandbox.rs +++ b/integration-tests/src/tests/sandbox.rs @@ -31,7 +31,15 @@ fn balance_query() { PolkadotRelay::fund_accounts(vec![(penpal_sov_acc, 100_0_000_000_000u128)]); Polimec::execute_with(|| { - assert_ok!(PolimecXcmPallet::send_xcm(Here, MultiLocation::from(ParentThen(X1(Parachain(Penpal::para_id().into())))), xcm)); + let penpal_loc: MultiLocation = MultiLocation::from(ParentThen(X1(Parachain(Penpal::para_id().into())))); + let now = PolimecSystem::block_number(); + // the parameters of the call are not relevant since they will be stripped and replaced by the query result + let call = PolimecCall::PolimecFunding(pallet_funding::Call::migration_check_response { + query_id: Default::default(), + response: Default::default(), + }); + let query_id = PolimecXcmPallet::new_notify_query(penpal_loc, call,now + 20u32, Here); + assert_ok!(PolimecXcmPallet::send_xcm(Here, penpal_loc, xcm)); println!("polimec events:"); dbg!(Polimec::events()) }); diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index b1b6e7040..43220368f 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -265,7 +265,7 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: frame_system::Config + pallet_balances::Config> { + pub trait Config: frame_system::Config + pallet_balances::Config> + pallet_xcm::Config { /// Helper trait for benchmarks. // #[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] type AllPalletsWithoutSystem: frame_support::traits::OnFinalize> @@ -1129,6 +1129,23 @@ pub mod pallet { let caller = ensure_signed(origin)?; Self::do_start_migration_readiness_check(&caller, project_id) } + + #[pallet::call_index(23)] + #[pallet::weight(Weight::from_parts(1000, 0))] + pub fn migration_check_response( + origin: OriginFor, + query_id: xcm::v3::QueryId, + response: xcm::v3::Response + ) -> DispatchResult { + let location = ensure_response(::RuntimeOrigin::from(origin))?; + let para_id = if let MultiLocation { parents: 1, interior: X1(Parachain(para_id))} = location { + para_id + } else { + return Err(Error::::NotAllowed.into()) + }; + let x = 10; + Ok(()) + } } #[pallet::hooks] @@ -1232,6 +1249,8 @@ pub mod pallet { #[cfg(all(feature = "testing-node", feature = "std"))] use frame_support::traits::{OnFinalize, OnIdle, OnInitialize, OriginTrait}; + use pallet_xcm::ensure_response; + use polkadot_runtime_parachains::ensure_parachain; #[cfg(all(feature = "testing-node", feature = "std"))] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] diff --git a/pallets/polimec-receiver/src/benchmarking.rs b/pallets/polimec-receiver/src/benchmarking.rs deleted file mode 100644 index 8bba2a098..000000000 --- a/pallets/polimec-receiver/src/benchmarking.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! Benchmarking setup for pallet-parachain-template - -use super::*; - -#[allow(unused)] -use crate::Pallet as Template; -use frame_benchmarking::{benchmarks, impl_benchmark_test_suite, whitelisted_caller}; -use frame_system::RawOrigin; - -benchmarks! { - do_something { - let s in 0 .. 100; - let caller: T::AccountId = whitelisted_caller(); - }: _(RawOrigin::Signed(caller), s) - verify { - assert_eq!(Something::::get(), Some(s)); - } -} - -impl_benchmark_test_suite!(Template, crate::mock::new_test_ext(), crate::mock::Test,); diff --git a/pallets/polimec-receiver/src/mock.rs b/pallets/polimec-receiver/src/mock.rs deleted file mode 100644 index fbad8f13e..000000000 --- a/pallets/polimec-receiver/src/mock.rs +++ /dev/null @@ -1,63 +0,0 @@ -use frame_support::{parameter_types, traits::Everything}; -use frame_system as system; -use sp_core::H256; -use sp_runtime::{ - testing::Header, - traits::{BlakeTwo256, IdentityLookup}, -}; - -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; - -// Configure a mock runtime to test the pallet. -frame_support::construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Pallet, Call, Config, Storage, Event}, - TemplateModule: crate::{Pallet, Call, Storage, Event}, - } -); - -parameter_types! { - pub const BlockHashCount: u64 = 250; - pub const SS58Prefix: u8 = 42; -} - -impl system::Config for Test { - type AccountData = (); - type AccountId = u64; - type BaseCallFilter = Everything; - type BlockHashCount = BlockHashCount; - type BlockLength = (); - type BlockNumber = u64; - type BlockWeights = (); - type DbWeight = (); - type Hash = H256; - type Hashing = BlakeTwo256; - type Header = Header; - type Index = u64; - type Lookup = IdentityLookup; - type MaxConsumers = frame_support::traits::ConstU32<16>; - type OnKilledAccount = (); - type OnNewAccount = (); - type OnSetCode = (); - type PalletInfo = PalletInfo; - type RuntimeCall = RuntimeCall; - type RuntimeEvent = RuntimeEvent; - type RuntimeOrigin = RuntimeOrigin; - type SS58Prefix = SS58Prefix; - type SystemWeightInfo = (); - type Version = (); -} - -impl crate::Config for Test { - type RuntimeEvent = RuntimeEvent; -} - -// Build genesis storage according to the mock runtime. -pub fn new_test_ext() -> sp_io::TestExternalities { - system::GenesisConfig::default().build_storage::().unwrap().into() -} diff --git a/pallets/polimec-receiver/src/tests.rs b/pallets/polimec-receiver/src/tests.rs deleted file mode 100644 index 6a9a0cabe..000000000 --- a/pallets/polimec-receiver/src/tests.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::{mock::*, Error}; -use frame_support::{assert_noop, assert_ok}; - -#[test] -fn it_works_for_default_value() { - new_test_ext().execute_with(|| { - // Dispatch a signed extrinsic. - assert_ok!(TemplateModule::do_something(RuntimeOrigin::signed(1), 42)); - // Read pallet storage and assert an expected result. - assert_eq!(TemplateModule::something(), Some(42)); - }); -} - -#[test] -fn correct_error_for_none_value() { - new_test_ext().execute_with(|| { - // Ensure the expected error is thrown when no value is present. - assert_noop!(TemplateModule::cause_error(RuntimeOrigin::signed(1)), Error::::NoneValue); - }); -} From b272479641153a9b32476ffbdd3f2fcfbaec6d0a Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 7 Nov 2023 11:24:02 +0100 Subject: [PATCH 007/212] save --- integration-tests/penpal/build.rs | 6 +- integration-tests/penpal/src/lib.rs | 200 +++++++++--------- .../penpal/src/weights/block_weights.rs | 5 +- .../penpal/src/weights/extrinsic_weights.rs | 10 +- integration-tests/penpal/src/xcm_config.rs | 95 ++++----- integration-tests/src/constants.rs | 5 +- integration-tests/src/defaults.rs | 161 ++++++++++++++ integration-tests/src/lib.rs | 2 + integration-tests/src/tests/mod.rs | 2 +- integration-tests/src/tests/sandbox.rs | 31 ++- pallets/funding/Cargo.toml | 1 - pallets/funding/src/functions.rs | 147 ++++++++++--- pallets/funding/src/instantiator.rs | 6 - pallets/funding/src/lib.rs | 27 ++- pallets/funding/src/types.rs | 4 +- runtimes/testnet/src/lib.rs | 3 +- 16 files changed, 475 insertions(+), 230 deletions(-) create mode 100644 integration-tests/src/defaults.rs diff --git a/integration-tests/penpal/build.rs b/integration-tests/penpal/build.rs index 256e9fb76..a4dc70859 100644 --- a/integration-tests/penpal/build.rs +++ b/integration-tests/penpal/build.rs @@ -16,11 +16,7 @@ #[cfg(feature = "std")] fn main() { - substrate_wasm_builder::WasmBuilder::new() - .with_current_project() - .export_heap_base() - .import_memory() - .build() + substrate_wasm_builder::WasmBuilder::new().with_current_project().export_heap_base().import_memory().build() } #[cfg(not(feature = "std"))] diff --git a/integration-tests/penpal/src/lib.rs b/integration-tests/penpal/src/lib.rs index 0a0e3275f..a790ff271 100644 --- a/integration-tests/penpal/src/lib.rs +++ b/integration-tests/penpal/src/lib.rs @@ -38,8 +38,8 @@ use frame_support::{ parameter_types, traits::{AsEnsureOriginWithArg, ConstU32, ConstU64, ConstU8, Everything}, weights::{ - constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, FeePolynomial, - WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, + constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, FeePolynomial, WeightToFeeCoefficient, + WeightToFeeCoefficients, WeightToFeePolynomial, }, PalletId, }; @@ -120,11 +120,9 @@ pub type SignedExtra = ( ); /// Unchecked extrinsic type as expected by this runtime. -pub type UncheckedExtrinsic = - generic::UncheckedExtrinsic; +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; -pub type Migrations = - (pallet_balances::migration::MigrateToTrackInactive,); +pub type Migrations = (pallet_balances::migration::MigrateToTrackInactive,); /// Executive: handles dispatch to the various modules. pub type Executive = frame_executive::Executive< @@ -163,6 +161,7 @@ impl frame_support::weights::WeightToFee for WeightToFee { pub struct RefTimeToFee; impl WeightToFeePolynomial for RefTimeToFee { type Balance = Balance; + fn polynomial() -> WeightToFeeCoefficients { let p = MILLIUNIT / 10; let q = 100 * Balance::from(ExtrinsicBaseWeight::get().ref_time()); @@ -180,6 +179,7 @@ impl WeightToFeePolynomial for RefTimeToFee { pub struct ProofSizeToFee; impl WeightToFeePolynomial for ProofSizeToFee { type Balance = Balance; + fn polynomial() -> WeightToFeeCoefficients { // Map 10kb proof to 1 CENT. let p = MILLIUNIT / 10; @@ -306,66 +306,66 @@ parameter_types! { // Configure FRAME pallets to include in runtime. impl frame_system::Config for Runtime { + /// The data to be stored in an account. + type AccountData = pallet_balances::AccountData; /// The identifier used to distinguish between accounts. type AccountId = AccountId; - /// The aggregated dispatch type that is available for extrinsics. - type RuntimeCall = RuntimeCall; - /// The lookup mechanism to get account ID from whatever is passed in dispatchers. - type Lookup = AccountIdLookup; - /// The index type for storing how many extrinsics an account has signed. - type Index = Index; + /// The basic call filter to use in dispatchable. + type BaseCallFilter = Everything; + /// Maximum number of block number to block hash mappings to keep (oldest pruned first). + type BlockHashCount = BlockHashCount; + /// The maximum length of a block (in bytes). + type BlockLength = RuntimeBlockLength; /// The index type for blocks. type BlockNumber = BlockNumber; + /// Block & extrinsics weights: base values and limits. + type BlockWeights = RuntimeBlockWeights; + /// The weight of database operations that the runtime can invoke. + type DbWeight = RocksDbWeight; /// The type for hashing blocks and tries. type Hash = Hash; /// The hashing algorithm used. type Hashing = BlakeTwo256; /// The header type. type Header = generic::Header; + /// The index type for storing how many extrinsics an account has signed. + type Index = Index; + /// The lookup mechanism to get account ID from whatever is passed in dispatchers. + type Lookup = AccountIdLookup; + type MaxConsumers = frame_support::traits::ConstU32<16>; + /// What to do if an account is fully reaped from the system. + type OnKilledAccount = (); + /// What to do if a new account is created. + type OnNewAccount = (); + /// The action to take on a Runtime Upgrade + type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; + /// Converts a module to an index of this module in the runtime. + type PalletInfo = PalletInfo; + /// The aggregated dispatch type that is available for extrinsics. + type RuntimeCall = RuntimeCall; /// The ubiquitous event type. type RuntimeEvent = RuntimeEvent; /// The ubiquitous origin type. type RuntimeOrigin = RuntimeOrigin; - /// Maximum number of block number to block hash mappings to keep (oldest pruned first). - type BlockHashCount = BlockHashCount; - /// Runtime version. - type Version = Version; - /// Converts a module to an index of this module in the 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 = (); - /// The weight of database operations that the runtime can invoke. - type DbWeight = RocksDbWeight; - /// The basic call filter to use in dispatchable. - type BaseCallFilter = Everything; - /// Weight information for the extrinsics of this pallet. - type SystemWeightInfo = (); - /// Block & extrinsics weights: base values and limits. - type BlockWeights = RuntimeBlockWeights; - /// The maximum length of a block (in bytes). - type BlockLength = RuntimeBlockLength; /// This is used as an identifier of the chain. 42 is the generic substrate prefix. type SS58Prefix = SS58Prefix; - /// The action to take on a Runtime Upgrade - type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; - type MaxConsumers = frame_support::traits::ConstU32<16>; + /// Weight information for the extrinsics of this pallet. + type SystemWeightInfo = (); + /// Runtime version. + type Version = Version; } impl pallet_timestamp::Config for Runtime { + type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>; /// A timestamp: milliseconds since the unix epoch. type Moment = u64; type OnTimestampSet = Aura; - type MinimumPeriod = ConstU64<{ SLOT_DURATION / 2 }>; type WeightInfo = (); } impl pallet_authorship::Config for Runtime { - type FindAuthor = pallet_session::FindAccountFromAuthorIndex; type EventHandler = (CollatorSelection,); + type FindAuthor = pallet_session::FindAccountFromAuthorIndex; } parameter_types! { @@ -373,21 +373,21 @@ parameter_types! { } impl pallet_balances::Config for Runtime { - type MaxLocks = ConstU32<50>; + type AccountStore = System; /// The type for recording an account's balance. type Balance = Balance; - /// The ubiquitous event type. - type RuntimeEvent = RuntimeEvent; type DustRemoval = (); type ExistentialDeposit = ExistentialDeposit; - type AccountStore = System; - type WeightInfo = pallet_balances::weights::SubstrateWeight; - type MaxReserves = ConstU32<50>; - type ReserveIdentifier = [u8; 8]; - type HoldIdentifier = (); type FreezeIdentifier = (); - type MaxHolds = ConstU32<0>; + type HoldIdentifier = (); type MaxFreezes = ConstU32<0>; + type MaxHolds = ConstU32<0>; + type MaxLocks = ConstU32<50>; + type MaxReserves = ConstU32<50>; + type ReserveIdentifier = [u8; 8]; + /// The ubiquitous event type. + type RuntimeEvent = RuntimeEvent; + type WeightInfo = pallet_balances::weights::SubstrateWeight; } parameter_types! { @@ -396,12 +396,12 @@ parameter_types! { } impl pallet_transaction_payment::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; - type WeightToFee = WeightToFee; - type LengthToFee = ConstantMultiplier; type FeeMultiplierUpdate = SlowAdjustingFeeUpdate; + type LengthToFee = ConstantMultiplier; + type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter; type OperationalFeeMultiplier = ConstU8<5>; + type RuntimeEvent = RuntimeEvent; + type WeightToFee = WeightToFee; } parameter_types! { @@ -418,26 +418,26 @@ parameter_types! { // EnsureOneOf, EnsureXcm>>; impl pallet_assets::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Balance = Balance; + type ApprovalDeposit = ApprovalDeposit; + type AssetAccountDeposit = AssetAccountDeposit; + type AssetDeposit = AssetDeposit; type AssetId = AssetId; type AssetIdParameter = codec::Compact; - type Currency = Balances; + type Balance = Balance; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHelper = (); + type CallbackHandle = (); type CreateOrigin = AsEnsureOriginWithArg>; + type Currency = Balances; + type Extra = (); type ForceOrigin = EnsureRoot; - type AssetDeposit = AssetDeposit; + type Freezer = (); type MetadataDepositBase = MetadataDepositBase; type MetadataDepositPerByte = MetadataDepositPerByte; - type ApprovalDeposit = ApprovalDeposit; + type RemoveItemsLimit = frame_support::traits::ConstU32<1000>; + type RuntimeEvent = RuntimeEvent; type StringLimit = AssetsStringLimit; - type Freezer = (); - type Extra = (); type WeightInfo = pallet_assets::weights::SubstrateWeight; - type CallbackHandle = (); - type AssetAccountDeposit = AssetAccountDeposit; - type RemoveItemsLimit = frame_support::traits::ConstU32<1000>; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHelper = (); } parameter_types! { @@ -446,15 +446,15 @@ parameter_types! { } impl cumulus_pallet_parachain_system::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type OnSystemEvent = (); - type SelfParaId = parachain_info::Pallet; + type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases; type DmpMessageHandler = DmpQueue; - type ReservedDmpWeight = ReservedDmpWeight; + type OnSystemEvent = (); type OutboundXcmpMessageSource = XcmpQueue; - type XcmpMessageHandler = XcmpQueue; + type ReservedDmpWeight = ReservedDmpWeight; type ReservedXcmpWeight = ReservedXcmpWeight; - type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases; + type RuntimeEvent = RuntimeEvent; + type SelfParaId = parachain_info::Pallet; + type XcmpMessageHandler = XcmpQueue; } impl parachain_info::Config for Runtime {} @@ -462,21 +462,21 @@ impl parachain_info::Config for Runtime {} impl cumulus_pallet_aura_ext::Config for Runtime {} impl cumulus_pallet_xcmp_queue::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; type ChannelInfo = ParachainSystem; - type VersionWrapper = PolkadotXcm; - type ExecuteOverweightOrigin = EnsureRoot; type ControllerOrigin = EnsureRoot; type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; - type WeightInfo = (); + type ExecuteOverweightOrigin = EnsureRoot; type PriceForSiblingDelivery = (); + type RuntimeEvent = RuntimeEvent; + type VersionWrapper = PolkadotXcm; + type WeightInfo = (); + type XcmExecutor = XcmExecutor; } impl cumulus_pallet_dmp_queue::Config for Runtime { + type ExecuteOverweightOrigin = EnsureRoot; type RuntimeEvent = RuntimeEvent; type XcmExecutor = XcmExecutor; - type ExecuteOverweightOrigin = EnsureRoot; } parameter_types! { @@ -485,16 +485,16 @@ parameter_types! { } impl pallet_session::Config for Runtime { + type Keys = SessionKeys; + type NextSessionRotation = pallet_session::PeriodicSessions; type RuntimeEvent = RuntimeEvent; + // Essentially just Aura, but let's be pedantic. + type SessionHandler = ::KeyTypeIdProviders; + type SessionManager = CollatorSelection; + type ShouldEndSession = pallet_session::PeriodicSessions; 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 = CollatorSelection; - // Essentially just Aura, but let's be pedantic. - type SessionHandler = ::KeyTypeIdProviders; - type Keys = SessionKeys; type WeightInfo = (); } @@ -517,15 +517,15 @@ parameter_types! { pub type CollatorSelectionUpdateOrigin = EnsureRoot; impl pallet_collator_selection::Config for Runtime { - type RuntimeEvent = RuntimeEvent; type Currency = Balances; - type UpdateOrigin = CollatorSelectionUpdateOrigin; - 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 MaxCandidates = MaxCandidates; + type MaxInvulnerables = MaxInvulnerables; + type MinCandidates = MinCandidates; + type PotId = PotId; + type RuntimeEvent = RuntimeEvent; + type UpdateOrigin = CollatorSelectionUpdateOrigin; type ValidatorId = ::AccountId; type ValidatorIdOf = pallet_collator_selection::IdentityCollator; type ValidatorRegistration = Session; @@ -533,17 +533,17 @@ impl pallet_collator_selection::Config for Runtime { } impl pallet_asset_tx_payment::Config for Runtime { - type RuntimeEvent = RuntimeEvent; type Fungibles = Assets; type OnChargeAssetTransaction = pallet_asset_tx_payment::FungiblesAdapter< pallet_assets::BalanceToAssetBalance, AssetsToBlockAuthor, >; + type RuntimeEvent = RuntimeEvent; } impl pallet_sudo::Config for Runtime { - type RuntimeEvent = RuntimeEvent; type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; type WeightInfo = pallet_sudo::weights::SubstrateWeight; } @@ -826,17 +826,15 @@ impl cumulus_pallet_parachain_system::CheckInherents for CheckInherents { block: &Block, relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof, ) -> sp_inherents::CheckInherentsResult { - let relay_chain_slot = relay_state_proof - .read_slot() - .expect("Could not read the relay chain slot from the proof"); - - let inherent_data = - cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration( - relay_chain_slot, - sp_std::time::Duration::from_secs(6), - ) - .create_inherent_data() - .expect("Could not create the timestamp inherent data"); + let relay_chain_slot = + relay_state_proof.read_slot().expect("Could not read the relay chain slot from the proof"); + + let inherent_data = cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration( + relay_chain_slot, + sp_std::time::Duration::from_secs(6), + ) + .create_inherent_data() + .expect("Could not create the timestamp inherent data"); inherent_data.check_extrinsics(block) } diff --git a/integration-tests/penpal/src/weights/block_weights.rs b/integration-tests/penpal/src/weights/block_weights.rs index b2092d875..d87144b01 100644 --- a/integration-tests/penpal/src/weights/block_weights.rs +++ b/integration-tests/penpal/src/weights/block_weights.rs @@ -44,10 +44,7 @@ pub mod constants { "Weight should be at least 100 µs." ); // At most 50 ms. - assert!( - w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS, - "Weight should be at most 50 ms." - ); + assert!(w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS, "Weight should be at most 50 ms."); } } } diff --git a/integration-tests/penpal/src/weights/extrinsic_weights.rs b/integration-tests/penpal/src/weights/extrinsic_weights.rs index 332c3b324..55b3706db 100644 --- a/integration-tests/penpal/src/weights/extrinsic_weights.rs +++ b/integration-tests/penpal/src/weights/extrinsic_weights.rs @@ -39,15 +39,9 @@ pub mod constants { let w = super::constants::ExtrinsicBaseWeight::get(); // At least 10 µs. - assert!( - w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS, - "Weight should be at least 10 µs." - ); + assert!(w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS, "Weight should be at least 10 µs."); // At most 1 ms. - assert!( - w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, - "Weight should be at most 1 ms." - ); + assert!(w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS, "Weight should be at most 1 ms."); } } } diff --git a/integration-tests/penpal/src/xcm_config.rs b/integration-tests/penpal/src/xcm_config.rs index 64007cdad..dd78157c9 100644 --- a/integration-tests/penpal/src/xcm_config.rs +++ b/integration-tests/penpal/src/xcm_config.rs @@ -22,9 +22,8 @@ //! with statemine as the reserve. At present no derivative tokens are minted on receipt of a //! ReserveAssetTransferDeposited message but that will but the intension will be to support this soon. use super::{ - AccountId, AllPalletsWithSystem, AssetId as AssetIdPalletAssets, Assets, Balance, Balances, - ParachainInfo, ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, - WeightToFee, XcmpQueue, + AccountId, AllPalletsWithSystem, AssetId as AssetIdPalletAssets, Assets, Balance, Balances, ParachainInfo, + ParachainSystem, PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue, }; use core::marker::PhantomData; use frame_support::{ @@ -44,13 +43,11 @@ use polkadot_runtime_common::impls::ToAuthor; use sp_runtime::traits::Zero; use xcm::latest::prelude::*; use xcm_builder::{ - AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, - AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex, - ConvertedConcreteId, CurrencyAdapter, EnsureXcmOrigin, FixedWeightBounds, FungiblesAdapter, - IsConcrete, LocalMint, NativeAsset, ParentIsPreset, RelayChainAsNative, - SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, - SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, - WithComputedOrigin, + AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses, AllowSubscriptionsFrom, + AllowTopLevelPaidExecutionFrom, AsPrefixedGeneralIndex, ConvertedConcreteId, CurrencyAdapter, EnsureXcmOrigin, + FixedWeightBounds, FungiblesAdapter, IsConcrete, LocalMint, NativeAsset, ParentIsPreset, RelayChainAsNative, + SiblingParachainAsNative, SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, + SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WithComputedOrigin, }; use xcm_executor::{traits::JustTry, XcmExecutor}; @@ -272,31 +269,31 @@ pub type Reserves = (NativeAsset, AssetsFrom); pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { - type RuntimeCall = RuntimeCall; - type XcmSender = XcmRouter; + type AssetClaims = PolkadotXcm; + type AssetExchanger = (); + type AssetLocker = (); // How to withdraw and deposit an asset. type AssetTransactor = AssetTransactors; - type OriginConverter = XcmOriginToTransactDispatchOrigin; - type IsReserve = MultiNativeAsset; // TODO: maybe needed to be replaced by Reserves - type IsTeleporter = NativeAsset; - type UniversalLocation = UniversalLocation; - type Barrier = Barrier; - type Weigher = FixedWeightBounds; - type Trader = - UsingComponents>; - type ResponseHandler = PolkadotXcm; type AssetTrap = PolkadotXcm; - type AssetClaims = PolkadotXcm; - type SubscriptionService = PolkadotXcm; - type PalletInstancesInfo = AllPalletsWithSystem; - type MaxAssetsIntoHolding = MaxAssetsIntoHolding; - type AssetLocker = (); - type AssetExchanger = (); + type Barrier = Barrier; + type CallDispatcher = RuntimeCall; type FeeManager = (); + type IsReserve = MultiNativeAsset; + // TODO: maybe needed to be replaced by Reserves + type IsTeleporter = NativeAsset; + type MaxAssetsIntoHolding = MaxAssetsIntoHolding; type MessageExporter = (); - type UniversalAliases = Nothing; - type CallDispatcher = RuntimeCall; + type OriginConverter = XcmOriginToTransactDispatchOrigin; + type PalletInstancesInfo = AllPalletsWithSystem; + type ResponseHandler = PolkadotXcm; + type RuntimeCall = RuntimeCall; type SafeCallFilter = Everything; + type SubscriptionService = PolkadotXcm; + type Trader = UsingComponents>; + type UniversalAliases = Nothing; + type UniversalLocation = UniversalLocation; + type Weigher = FixedWeightBounds; + type XcmSender = XcmRouter; } /// No local origins on this chain are allowed to dispatch XCM sends/executions. @@ -317,35 +314,35 @@ parameter_types! { } impl pallet_xcm::Config for Runtime { + type AdminOrigin = EnsureRoot; + // ^ Override for AdvertisedXcmVersion default + type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type Currency = Balances; + type CurrencyMatcher = (); + type ExecuteXcmOrigin = EnsureXcmOrigin; + type MaxLockers = ConstU32<8>; + type MaxRemoteLockConsumers = ConstU32<0>; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = ReachableDest; + type RemoteLockConsumerIdentifier = (); + type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; type SendXcmOrigin = EnsureXcmOrigin; - type XcmRouter = XcmRouter; - type ExecuteXcmOrigin = EnsureXcmOrigin; + type SovereignAccountOf = LocationToAccountId; + type TrustedLockers = (); + type UniversalLocation = UniversalLocation; + type Weigher = FixedWeightBounds; + type WeightInfo = pallet_xcm::TestWeightInfo; type XcmExecuteFilter = Nothing; // ^ Disable dispatchable execute on the XCM pallet. // Needs to be `Everything` for local testing. type XcmExecutor = XcmExecutor; - type XcmTeleportFilter = Everything; type XcmReserveTransferFilter = Everything; - type Weigher = FixedWeightBounds; - type UniversalLocation = UniversalLocation; - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; + type XcmRouter = XcmRouter; + type XcmTeleportFilter = Everything; const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; - // ^ Override for AdvertisedXcmVersion default - type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; - type Currency = Balances; - type CurrencyMatcher = (); - type TrustedLockers = (); - type SovereignAccountOf = LocationToAccountId; - type MaxLockers = ConstU32<8>; - type WeightInfo = pallet_xcm::TestWeightInfo; - #[cfg(feature = "runtime-benchmarks")] - type ReachableDest = ReachableDest; - type AdminOrigin = EnsureRoot; - type MaxRemoteLockConsumers = ConstU32<0>; - type RemoteLockConsumerIdentifier = (); } impl cumulus_pallet_xcm::Config for Runtime { diff --git a/integration-tests/src/constants.rs b/integration-tests/src/constants.rs index df27b7cf7..7c4eee8db 100644 --- a/integration-tests/src/constants.rs +++ b/integration-tests/src/constants.rs @@ -19,7 +19,6 @@ pub const REF_TIME_THRESHOLD: u64 = 33; pub const PROOF_SIZE_THRESHOLD: u64 = 33; pub const INITIAL_DEPOSIT: u128 = 420_0_000_000_000; - type AccountPublic = ::Signer; /// Helper function to generate a crypto pair from seed @@ -315,9 +314,7 @@ pub mod penpal { system: penpal_runtime::SystemConfig { code: penpal_runtime::WASM_BINARY.expect("WASM binary was not build, please build it!").to_vec(), }, - balances: penpal_runtime::BalancesConfig { - balances: funded_accounts, - }, + balances: penpal_runtime::BalancesConfig { balances: funded_accounts }, parachain_info: penpal_runtime::ParachainInfoConfig { parachain_id: ParaId::from(PARA_ID) }, collator_selection: penpal_runtime::CollatorSelectionConfig { invulnerables: collators::invulnerables().iter().cloned().map(|(acc, _)| acc).collect(), diff --git a/integration-tests/src/defaults.rs b/integration-tests/src/defaults.rs new file mode 100644 index 000000000..7334a2e21 --- /dev/null +++ b/integration-tests/src/defaults.rs @@ -0,0 +1,161 @@ +use super::*; +use frame_support::BoundedVec; +use pallet_funding::{ + instantiator::{BidParams, ContributionParams, UserToPLMCBalance, UserToUSDBalance}, + AcceptedFundingAsset, CurrencyMetadata, ParticipantsSize, PriceOf, ProjectMetadata, ProjectMetadataOf, TicketSize, +}; +use sp_core::H256; +use sp_runtime::traits::BlakeTwo256; + +use polimec_parachain_runtime::AccountId; +use sp_runtime::{traits::ConstU32, FixedPointNumber, Percent, Perquintill}; +pub const METADATA: &str = r#"METADATA + { + "whitepaper":"ipfs_url", + "team_description":"ipfs_url", + "tokenomics":"ipfs_url", + "roadmap":"ipfs_url", + "usage_of_founds":"ipfs_url" + }"#; +pub const ASSET_DECIMALS: u8 = 10; +pub const ASSET_UNIT: u128 = 10_u128.pow(10 as u32); +pub const PLMC: Balance = 10u128.pow(10); +pub type IntegrationInstantiator = pallet_funding::instantiator::Instantiator< + PolimecRuntime, + ::AllPalletsWithoutSystem, + ::RuntimeEvent, +>; +pub fn hashed(data: impl AsRef<[u8]>) -> sp_core::H256 { + ::hash(data.as_ref()) +} +pub fn issuer() -> AccountId { + Polimec::account_id_of("issuer") +} +pub fn eval_1() -> AccountId { + Polimec::account_id_of("eval_1") +} +pub fn eval_2() -> AccountId { + Polimec::account_id_of("eval_2") +} +pub fn eval_3() -> AccountId { + Polimec::account_id_of("eval_3") +} +pub fn bidder_1() -> AccountId { + Polimec::account_id_of("bidder_1") +} +pub fn bidder_2() -> AccountId { + Polimec::account_id_of("bidder_2") +} +pub fn bidder_3() -> AccountId { + Polimec::account_id_of("bidder_3") +} +pub fn bidder_4() -> AccountId { + Polimec::account_id_of("bidder_4") +} +pub fn bidder_5() -> AccountId { + Polimec::account_id_of("bidder_5") +} +pub fn buyer_1() -> AccountId { + Polimec::account_id_of("buyer_1") +} +pub fn buyer_2() -> AccountId { + Polimec::account_id_of("buyer_2") +} +pub fn buyer_3() -> AccountId { + Polimec::account_id_of("buyer_3") +} +pub fn buyer_4() -> AccountId { + Polimec::account_id_of("buyer_4") +} +pub fn buyer_5() -> AccountId { + Polimec::account_id_of("buyer_5") +} +pub fn all_testing_accounts() -> Vec { + vec![ + issuer(), + eval_1(), + eval_2(), + eval_3(), + bidder_1(), + bidder_2(), + bidder_3(), + bidder_4(), + bidder_5(), + buyer_1(), + buyer_2(), + buyer_3(), + buyer_4(), + buyer_5(), + ] +} +pub fn bounded_name() -> BoundedVec> { + BoundedVec::try_from("Contribution Token TEST".as_bytes().to_vec()).unwrap() +} +pub fn bounded_symbol() -> BoundedVec> { + BoundedVec::try_from("CTEST".as_bytes().to_vec()).unwrap() +} +pub fn metadata_hash(nonce: u32) -> H256 { + hashed(format!("{}-{}", METADATA, nonce)) +} +pub fn default_weights() -> Vec { + vec![20u8, 15u8, 10u8, 25u8, 30u8] +} + +pub fn default_project(issuer: AccountId, nonce: u32) -> ProjectMetadataOf { + ProjectMetadata { + token_information: CurrencyMetadata { + name: bounded_name(), + symbol: bounded_symbol(), + decimals: ASSET_DECIMALS, + }, + mainnet_token_max_supply: 8_000_000 * ASSET_UNIT, + total_allocation_size: (50_000 * ASSET_UNIT, 50_000 * ASSET_UNIT), + minimum_price: sp_runtime::FixedU128::from_float(1.0), + ticket_size: TicketSize { minimum: Some(1), maximum: None }, + participants_size: ParticipantsSize { minimum: Some(2), maximum: None }, + funding_thresholds: Default::default(), + conversion_rate: 0, + participation_currencies: AcceptedFundingAsset::USDT, + funding_destination_account: issuer, + offchain_information_hash: Some(metadata_hash(nonce)), + } +} +pub fn default_evaluations() -> Vec> { + vec![ + UserToUSDBalance::new(eval_1(), 50_000 * PLMC), + UserToUSDBalance::new(eval_2(), 25_000 * PLMC), + UserToUSDBalance::new(eval_3(), 32_000 * PLMC), + ] +} +pub fn default_bidders() -> Vec { + vec![bidder_1(), bidder_2(), bidder_3(), bidder_4(), bidder_5()] +} + +pub fn default_bids() -> Vec> { + let forty_percent_funding_usd = Perquintill::from_percent(40) * + (sp_runtime::FixedU128::from_float(1.0).checked_mul_int(100_000 * ASSET_UNIT).unwrap()); + + IntegrationInstantiator::generate_bids_from_total_usd( + forty_percent_funding_usd, + sp_runtime::FixedU128::from_float(1.0), + default_weights(), + default_bidders(), + ) +} + +pub fn default_community_contributions() -> Vec> { + let fifty_percent_funding_usd = Perquintill::from_percent(50) * + (sp_runtime::FixedU128::from_float(1.0).checked_mul_int(100_000 * ASSET_UNIT).unwrap()); + + IntegrationInstantiator::generate_contributions_from_total_usd( + fifty_percent_funding_usd, + sp_runtime::FixedU128::from_float(1.0), + default_weights(), + default_contributors(), + ) +} +pub fn default_contributors() -> Vec { + vec![buyer_1(), buyer_2(), buyer_3(), buyer_4(), buyer_5()] +} + +use polimec_parachain_runtime::Runtime as T; diff --git a/integration-tests/src/lib.rs b/integration-tests/src/lib.rs index 995eccb47..4a36cee9c 100644 --- a/integration-tests/src/lib.rs +++ b/integration-tests/src/lib.rs @@ -16,6 +16,8 @@ pub mod constants; #[cfg(test)] +mod defaults; +#[cfg(test)] mod tests; pub use constants::{accounts::*, penpal, polimec, polkadot, statemint}; diff --git a/integration-tests/src/tests/mod.rs b/integration-tests/src/tests/mod.rs index 9ef76a00b..90a917dbc 100644 --- a/integration-tests/src/tests/mod.rs +++ b/integration-tests/src/tests/mod.rs @@ -1,3 +1,3 @@ mod basic_comms; -mod sandbox; mod reserve_backed_transfers; +mod sandbox; diff --git a/integration-tests/src/tests/sandbox.rs b/integration-tests/src/tests/sandbox.rs index 0cc4972c0..72d9d1cec 100644 --- a/integration-tests/src/tests/sandbox.rs +++ b/integration-tests/src/tests/sandbox.rs @@ -1,12 +1,24 @@ use crate::*; - +use defaults::*; +use std::cell::RefCell; const MAX_REF_TIME: u64 = 700_000_000; const MAX_PROOF_SIZE: u64 = 10_000; pub const REF_TIME_THRESHOLD: u64 = 33; pub const PROOF_SIZE_THRESHOLD: u64 = 33; #[test] -fn balance_query() { +fn migration_check() { + let inst = IntegrationInstantiator::new(None); + let project_id = Polimec::execute_with(|| { + inst.create_finished_project( + default_project(issuer(), 0), + issuer(), + default_evaluations(), + default_bids(), + default_community_contributions(), + vec![], + ) + }); let max_weight = Weight::from_parts(MAX_REF_TIME, MAX_PROOF_SIZE); let execution_currency: MultiAsset = (MultiLocation { parents: 0, interior: Here }, 1_0_000_000_000u128).into(); // 1 unit for executing let expected_currency: MultiAsset = @@ -22,7 +34,15 @@ fn balance_query() { }, assets: Wild(All), }, - DepositAsset { assets: Wild(All), beneficiary: ParentThen(Parachain(3355).into()).into() } + QueryPallet { + module_name: Vec::from("polimec_receiver"), + response_info: QueryResponseInfo { + destination: ParentThen(Parachain(3355).into()).into(), + query_id: 1, + max_weight: max_weight.clone(), + }, + }, + DepositAsset { assets: Wild(All), beneficiary: ParentThen(Parachain(3355).into()).into() }, ]); let polimec_on_penpal = Penpal::sovereign_account_id_of((Parent, Parachain(polimec::PARA_ID)).into()); let balance_polimec = Penpal::account_data_of(polimec_on_penpal); @@ -38,7 +58,8 @@ fn balance_query() { query_id: Default::default(), response: Default::default(), }); - let query_id = PolimecXcmPallet::new_notify_query(penpal_loc, call,now + 20u32, Here); + let query_id_0 = PolimecXcmPallet::new_notify_query(penpal_loc, call.clone(), now + 20u32, Here); + let query_id_1 = PolimecXcmPallet::new_notify_query(penpal_loc, call, now + 20u32, Here); assert_ok!(PolimecXcmPallet::send_xcm(Here, penpal_loc, xcm)); println!("polimec events:"); dbg!(Polimec::events()) @@ -53,6 +74,4 @@ fn balance_query() { println!("Polimec events:"); dbg!(Polimec::events()); }); - - } diff --git a/pallets/funding/Cargo.toml b/pallets/funding/Cargo.toml index c47f1f626..30f4c4002 100644 --- a/pallets/funding/Cargo.toml +++ b/pallets/funding/Cargo.toml @@ -43,7 +43,6 @@ polkadot-runtime.workspace = true polkadot-runtime-parachains.workspace = true polkadot-parachain.workspace = true - [dev-dependencies] pallet-insecure-randomness-collective-flip.workspace = true pallet-assets.workspace = true diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 7c8990955..2a3e783b7 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -64,7 +64,7 @@ impl Pallet { /// # Next step /// The issuer will call an extrinsic to start the evaluation round of the project. /// [`do_evaluation_start`](Self::do_evaluation_start) will be executed. - pub fn do_create(issuer: &AccountIdOf, initial_metadata: ProjectMetadataOf) -> Result<(), DispatchError> { + pub fn do_create(issuer: &AccountIdOf, initial_metadata: ProjectMetadataOf) -> DispatchResult { // * Get variables * let project_id = Self::next_project_id(); @@ -154,7 +154,7 @@ impl Pallet { /// # Next step /// Users will pond PLMC for this project, and when the time comes, the project will be transitioned /// to the next round by `on_initialize` using [`do_evaluation_end`](Self::do_evaluation_end) - pub fn do_evaluation_start(caller: AccountIdOf, project_id: T::ProjectIdentifier) -> Result<(), DispatchError> { + pub fn do_evaluation_start(caller: AccountIdOf, project_id: T::ProjectIdentifier) -> DispatchResult { // * Get variables * let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; @@ -211,7 +211,7 @@ impl Pallet { /// /// * Bonding failed - `on_idle` at some point checks for failed evaluation projects, and /// unbonds the evaluators funds. - pub fn do_evaluation_end(project_id: T::ProjectIdentifier) -> Result<(), DispatchError> { + pub fn do_evaluation_end(project_id: T::ProjectIdentifier) -> DispatchResult { // * Get variables * let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; let now = >::block_number(); @@ -302,7 +302,7 @@ impl Pallet { /// Professional and Institutional users set bids for the project using the [`bid`](Self::bid) extrinsic. /// Later on, `on_initialize` transitions the project into the candle auction round, by calling /// [`do_candle_auction`](Self::do_candle_auction). - pub fn do_english_auction(caller: AccountIdOf, project_id: T::ProjectIdentifier) -> Result<(), DispatchError> { + pub fn do_english_auction(caller: AccountIdOf, project_id: T::ProjectIdentifier) -> DispatchResult { // * Get variables * let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; let now = >::block_number(); @@ -377,7 +377,7 @@ impl Pallet { /// but now their bids are not guaranteed. /// Later on, `on_initialize` ends the candle auction round and starts the community round, /// by calling [`do_community_funding`](Self::do_community_funding). - pub fn do_candle_auction(project_id: T::ProjectIdentifier) -> Result<(), DispatchError> { + pub fn do_candle_auction(project_id: T::ProjectIdentifier) -> DispatchResult { // * Get variables * let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; let now = >::block_number(); @@ -430,7 +430,7 @@ impl Pallet { /// Retail users buy tokens at the price set on the auction round. /// Later on, `on_initialize` ends the community round by calling [`do_remainder_funding`](Self::do_remainder_funding) and /// starts the remainder round, where anyone can buy at that price point. - pub fn do_community_funding(project_id: T::ProjectIdentifier) -> Result<(), DispatchError> { + pub fn do_community_funding(project_id: T::ProjectIdentifier) -> DispatchResult { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; @@ -514,7 +514,7 @@ impl Pallet { /// Any users can now buy tokens at the price set on the auction round. /// Later on, `on_initialize` ends the remainder round, and finalizes the project funding, by calling /// [`do_end_funding`](Self::do_end_funding). - pub fn do_remainder_funding(project_id: T::ProjectIdentifier) -> Result<(), DispatchError> { + pub fn do_remainder_funding(project_id: T::ProjectIdentifier) -> DispatchResult { // * Get variables * let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; let now = >::block_number(); @@ -574,7 +574,7 @@ impl Pallet { /// * Bonded plmc with [`vested_plmc_purchase_unbond_for`](Self::vested_plmc_purchase_unbond_for) /// /// If **unsuccessful**, users every user should have their PLMC vesting unbonded. - pub fn do_end_funding(project_id: T::ProjectIdentifier) -> Result<(), DispatchError> { + pub fn do_end_funding(project_id: T::ProjectIdentifier) -> DispatchResult { // * Get variables * let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; @@ -718,7 +718,7 @@ impl Pallet { issuer: AccountIdOf, project_id: T::ProjectIdentifier, project_metadata_hash: T::Hash, - ) -> Result<(), DispatchError> { + ) -> DispatchResult { // * Get variables * let mut project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; @@ -745,7 +745,7 @@ impl Pallet { evaluator: &AccountIdOf, project_id: T::ProjectIdentifier, usd_amount: BalanceOf, - ) -> Result<(), DispatchError> { + ) -> DispatchResult { // * Get variables * let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; let now = >::block_number(); @@ -853,7 +853,7 @@ impl Pallet { _ct_usd_price: T::Price, multiplier: MultiplierOf, funding_asset: AcceptedFundingAsset, - ) -> Result<(), DispatchError> { + ) -> DispatchResult { // * Get variables * ensure!(ct_amount > Zero::zero(), Error::::BidTooLow); let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; @@ -1268,7 +1268,7 @@ impl Pallet { project_id: T::ProjectIdentifier, evaluator: &AccountIdOf, evaluation_id: u32, - ) -> Result<(), DispatchError> { + ) -> DispatchResult { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; let released_evaluation = @@ -1310,7 +1310,7 @@ impl Pallet { project_id: T::ProjectIdentifier, evaluator: &AccountIdOf, evaluation_id: u32, - ) -> Result<(), DispatchError> { + ) -> DispatchResult { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; let reward_info = @@ -1360,7 +1360,7 @@ impl Pallet { project_id: T::ProjectIdentifier, evaluator: &AccountIdOf, evaluation_id: u32, - ) -> Result<(), DispatchError> { + ) -> DispatchResult { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; let slash_percentage = T::EvaluatorSlash::get(); @@ -1413,7 +1413,7 @@ impl Pallet { project_id: T::ProjectIdentifier, bidder: &AccountIdOf, bid_id: u32, - ) -> Result<(), DispatchError> { + ) -> DispatchResult { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; let mut bid = Bids::::get((project_id, bidder, bid_id)).ok_or(Error::::BidNotFound)?; @@ -1459,7 +1459,7 @@ impl Pallet { project_id: T::ProjectIdentifier, contributor: &AccountIdOf, contribution_id: u32, - ) -> Result<(), DispatchError> { + ) -> DispatchResult { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; let mut contribution = @@ -1524,7 +1524,7 @@ impl Pallet { project_id: T::ProjectIdentifier, bidder: &AccountIdOf, bid_id: u32, - ) -> Result<(), DispatchError> { + ) -> DispatchResult { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; let mut bid = Bids::::get((project_id, bidder, bid_id)).ok_or(Error::::BidNotFound)?; @@ -1569,7 +1569,7 @@ impl Pallet { project_id: T::ProjectIdentifier, bidder: &AccountIdOf, bid_id: u32, - ) -> Result<(), DispatchError> { + ) -> DispatchResult { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; let bid = Bids::::get((project_id, bidder, bid_id)).ok_or(Error::::EvaluationNotFound)?; @@ -1602,7 +1602,7 @@ impl Pallet { project_id: T::ProjectIdentifier, contributor: &AccountIdOf, contribution_id: u32, - ) -> Result<(), DispatchError> { + ) -> DispatchResult { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; let mut contribution = Contributions::::get((project_id, contributor, contribution_id)) @@ -1644,7 +1644,7 @@ impl Pallet { project_id: T::ProjectIdentifier, contributor: &AccountIdOf, contribution_id: u32, - ) -> Result<(), DispatchError> { + ) -> DispatchResult { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; let bid = Contributions::::get((project_id, contributor, contribution_id)) @@ -1673,7 +1673,7 @@ impl Pallet { project_id: T::ProjectIdentifier, bidder: &AccountIdOf, bid_id: u32, - ) -> Result<(), DispatchError> { + ) -> DispatchResult { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; let mut bid = Bids::::get((project_id, bidder, bid_id)).ok_or(Error::::BidNotFound)?; @@ -1719,7 +1719,7 @@ impl Pallet { project_id: T::ProjectIdentifier, contributor: &AccountIdOf, contribution_id: u32, - ) -> Result<(), DispatchError> { + ) -> DispatchResult { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; let mut contribution = @@ -1761,7 +1761,7 @@ impl Pallet { caller: &AccountIdOf, project_id: T::ProjectIdentifier, para_id: ParaId, - ) -> Result<(), DispatchError> { + ) -> DispatchResult { // * Get variables * let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; @@ -1781,8 +1781,23 @@ impl Pallet { pub fn do_start_migration_readiness_check( caller: &AccountIdOf, project_id: T::ProjectIdentifier, - ) -> Result<(), DispatchError> { + ) -> DispatchResult { + // * Get variables * let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; + let parachain_id: u32 = project_details.parachain_id.ok_or(Error::::ImpossibleState)?.into(); + let project_multilocation = ParentThen(X1(Parachain(parachain_id))); + let now = >::block_number(); + let contribution_tokens_sold = project_metadata + .total_allocation_size + .0 + .saturating_add(project_metadata.total_allocation_size.1) + .saturating_sub(project_details.remaining_contribution_tokens.0) + .saturating_sub(project_details.remaining_contribution_tokens.1); + // TODO: check these values + let max_weight = Weight::from_parts(700_000_000, 10_000); + + // * Validity checks * ensure!(project_details.status == ProjectStatus::FundingSuccessful, Error::::NotAllowed); ensure!( project_details.comm_status == @@ -1795,21 +1810,89 @@ impl Pallet { ensure!(caller == &project_details.issuer, Error::::NotAllowed); } - project_details.migration_readiness_check = Some(MigrationReadinessCheck::QuerySent); + // * Update storage * + let call: ::RuntimeCall = + Call::migration_check_response { query_id: Default::default(), response: Default::default() }.into(); + + let query_id = pallet_xcm::Pallet::::new_notify_query( + project_multilocation.clone(), + call.into(), + now + 20u32.into(), + Here, + ); + + project_details.migration_readiness_check = Some(MigrationReadinessCheck::QuerySent(query_id)); ProjectsDetails::::insert(project_id, project_details); - // TODO: send message to polimec receiver pallet with query + // * Send the migration query * + let expected_tokens: MultiAsset = + (MultiLocation { parents: 0, interior: Here }, 1_000_000_0_000_000_000u128).into(); // 1MM units for migrations + let xcm = Xcm(vec![ + UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, + WithdrawAsset(vec![expected_tokens.clone()].into()), + ReportHolding { + response_info: QueryResponseInfo { + destination: ParentThen(Parachain(3355).into()).into(), + query_id: 0, + max_weight: max_weight.clone(), + }, + assets: Wild(All), + }, + DepositAsset { assets: Wild(All), beneficiary: ParentThen(Parachain(3355).into()).into() }, + ]); + >::send_xcm(Here, project_multilocation, xcm).map_err(|_| Error::::XcmFailed)?; Self::deposit_event(Event::::MigrationReadinessCheckStarted { project_id, caller: caller.clone() }); Ok(()) } + pub fn do_migration_check_response( + location: MultiLocation, + query_id: xcm::v3::QueryId, + response: xcm::v3::Response, + ) -> DispatchResult { + // * Get variables * + // TODO: check if this is too low performance. Maybe we want a new map of query_id -> project_id + let (project_id, project_details) = ProjectsDetails::::iter() + .find(|(_, details)| { + if let Some(MigrationReadinessCheck::QuerySent(id)) = details.migration_readiness_check { + id == query_id + } else { + false + } + }) + .ok_or(Error::::NotAllowed)?; + + let para_id = if let MultiLocation { parents: 1, interior: X1(Parachain(para_id)) } = location { + ParaId::from(para_id) + } else { + return Err(Error::::NotAllowed.into()) + }; + + let _tokens_held = match response { + xcm::v3::Response::Assets(_) => 10, + _ => return Err(Error::::NotAllowed.into()), + }; + + let _project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; + // let contribution_tokens_sold = project_metadata.total_allocation_size - project_details.remaining_contribution_tokens; + + // * Validity checks * + ensure!(project_details.parachain_id == Some(para_id), Error::::NotAllowed); + + // * Update storage * + + // * Emit events * + Self::deposit_event(Event::::MigrationResponseReceived { query_id, response }); + Ok(()) + } + pub fn finish_migration_readiness_check( _caller: ParaId, _project_id: T::ProjectIdentifier, _check_bytes: Vec, - ) -> Result<(), DispatchError> { + ) -> DispatchResult { Ok(()) } } @@ -1836,7 +1919,7 @@ impl Pallet { } } - pub fn remove_from_update_store(project_id: &T::ProjectIdentifier) -> Result<(), DispatchError> { + pub fn remove_from_update_store(project_id: &T::ProjectIdentifier) -> DispatchResult { let (block_position, project_index) = ProjectsToUpdate::::iter() .find_map(|(block, project_vec)| { let project_index = project_vec.iter().position(|(id, _update_type)| id == project_id)?; @@ -1884,7 +1967,7 @@ impl Pallet { project_id: T::ProjectIdentifier, end_block: T::BlockNumber, total_allocation_size: BalanceOf, - ) -> Result<(), DispatchError> { + ) -> DispatchResult { // Get all the bids that were made before the end of the candle let mut bids = Bids::::iter_prefix_values((project_id,)).collect::>(); // temp variable to store the sum of the bids @@ -2143,7 +2226,7 @@ impl Pallet { } // Update storage - ProjectsDetails::::mutate(project_id, |maybe_info| -> Result<(), DispatchError> { + ProjectsDetails::::mutate(project_id, |maybe_info| -> DispatchResult { if let Some(info) = maybe_info { info.weighted_average_price = Some(weighted_token_price); info.remaining_contribution_tokens.0.saturating_reduce(bid_token_amount_sum); @@ -2190,7 +2273,7 @@ impl Pallet { who: &T::AccountId, project_id: T::ProjectIdentifier, amount: BalanceOf, - ) -> Result<(), DispatchError> { + ) -> DispatchResult { // Check if the user has already locked tokens in the evaluation period let user_evaluations = Evaluations::::iter_prefix_values((project_id, who)); @@ -2222,7 +2305,7 @@ impl Pallet { project_id: T::ProjectIdentifier, amount: BalanceOf, asset_id: AssetIdOf, - ) -> Result<(), DispatchError> { + ) -> DispatchResult { let fund_account = Self::fund_account_id(project_id); T::FundingCurrency::transfer(asset_id, who, &fund_account, amount, Preservation::Expendable)?; diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 538ee35ec..82b780af0 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -1,9 +1,3 @@ -// use std::{ -// cell::RefCell, -// collections::{BTreeMap, BTreeSet}, -// iter::zip, -// }; - use frame_support::{ pallet_prelude::*, traits::{ diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 43220368f..329d7d05e 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -265,7 +265,9 @@ pub mod pallet { pub struct Pallet(_); #[pallet::config] - pub trait Config: frame_system::Config + pallet_balances::Config> + pallet_xcm::Config { + pub trait Config: + frame_system::Config + pallet_balances::Config> + pallet_xcm::Config + { /// Helper trait for benchmarks. // #[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] type AllPalletsWithoutSystem: frame_support::traits::OnFinalize> @@ -278,6 +280,11 @@ pub mod pallet { + Parameter + Member; + type RuntimeOrigin: IsType<::RuntimeOrigin> + + Into::RuntimeOrigin>>; + + type RuntimeCall: IsType<::RuntimeCall> + From>; + /// Global identifier for the projects. type ProjectIdentifier: Parameter + Copy + Default + One + Saturating + From + Ord + MaxEncodedLen; // TODO: PLMC-153 + MaybeSerializeDeserialize: Maybe needed for JSON serialization @ Genesis: https://github.com/paritytech/substrate/issues/12738#issuecomment-1320921201 @@ -763,6 +770,10 @@ pub mod pallet { project_id: T::ProjectIdentifier, caller: T::AccountId, }, + MigrationResponseReceived { + query_id: xcm::v3::QueryId, + response: xcm::v3::Response, + }, } #[pallet::error] @@ -857,6 +868,7 @@ pub mod pallet { ContributionNotFound, /// Tried to start a migration check but the bidirectional channel is not yet open CommsNotEstablished, + XcmFailed, } #[pallet::call] @@ -1135,16 +1147,11 @@ pub mod pallet { pub fn migration_check_response( origin: OriginFor, query_id: xcm::v3::QueryId, - response: xcm::v3::Response + response: xcm::v3::Response, ) -> DispatchResult { - let location = ensure_response(::RuntimeOrigin::from(origin))?; - let para_id = if let MultiLocation { parents: 1, interior: X1(Parachain(para_id))} = location { - para_id - } else { - return Err(Error::::NotAllowed.into()) - }; - let x = 10; - Ok(()) + let location = ensure_response(::RuntimeOrigin::from(origin))?; + + Self::do_migration_check_response(location, query_id, response) } } diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index 30fd235ce..1bb2553b0 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -144,7 +144,7 @@ pub mod storage_types { pub token_information: CurrencyMetadata, /// Mainnet Token Max Supply pub mainnet_token_max_supply: Balance, - /// Total allocation of Contribution Tokens available for the Funding Round + /// Total allocation of Contribution Tokens available for the Funding Round. (Auction, Community) pub total_allocation_size: (Balance, Balance), /// Minimum price per Contribution Token pub minimum_price: Price, @@ -678,7 +678,7 @@ pub mod inner_types { #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub enum MigrationReadinessCheck { - QuerySent, + QuerySent(xcm::v3::QueryId), CheckPassed, CheckFailed, } diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 6f8278882..f37706d61 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -493,7 +493,6 @@ parameter_types! { pub TreasuryAccount: AccountId = [69u8; 32].into(); } impl pallet_funding::Config for Runtime { - // #[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] type AllPalletsWithoutSystem = (Balances, LocalAssets, StatemintAssets, PolimecFunding, LinearVesting, Random); type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; type Balance = Balance; @@ -523,7 +522,9 @@ impl pallet_funding::Config for Runtime { type ProjectIdentifier = u32; type Randomness = Random; type RemainderFundingDuration = RemainderFundingDuration; + type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; type StringLimit = ConstU32<64>; type SuccessToSettlementTime = SuccessToSettlementTime; type TreasuryAccount = TreasuryAccount; From 4aeb55e120104054b80a859918d87331d38e5615 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 7 Nov 2023 16:57:52 +0100 Subject: [PATCH 008/212] HRMP establishment successfully mocked! --- Cargo.lock | 31 +-- Cargo.toml | 2 +- integration-tests/penpal/Cargo.toml | 3 + integration-tests/penpal/src/lib.rs | 5 + integration-tests/src/lib.rs | 4 +- integration-tests/src/{ => tests}/defaults.rs | 12 +- integration-tests/src/tests/mod.rs | 2 + integration-tests/src/tests/sandbox.rs | 94 +++++---- pallets/funding/Cargo.toml | 1 + pallets/funding/src/functions.rs | 187 +++++++++++++++--- pallets/funding/src/lib.rs | 130 +----------- pallets/funding/src/mock.rs | 68 ++++++- pallets/polimec-receiver/Cargo.toml | 2 +- pallets/polimec-receiver/src/lib.rs | 9 - runtimes/testnet/src/xcm_config.rs | 2 +- 15 files changed, 329 insertions(+), 223 deletions(-) rename integration-tests/src/{ => tests}/defaults.rs (93%) diff --git a/Cargo.lock b/Cargo.lock index ee9f57041..55a617da8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6646,21 +6646,6 @@ dependencies = [ "substrate-fixed", ] -[[package]] -name = "pallet-parachain-template" -version = "0.1.0" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "serde", - "sp-core", - "sp-io", - "sp-runtime", -] - [[package]] name = "pallet-preimage" version = "4.0.0-dev" @@ -7361,6 +7346,7 @@ dependencies = [ "parachain-info", "parachains-common", "parity-scale-codec", + "polimec-receiver", "polkadot-parachain", "polkadot-primitives", "polkadot-runtime-common", @@ -7749,6 +7735,21 @@ dependencies = [ "xcm-executor", ] +[[package]] +name = "polimec-receiver" +version = "0.1.0" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", +] + [[package]] name = "polimec-traits" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 6523823de..f47e00637 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -56,7 +56,7 @@ pallet-sandbox = { path = "pallets/sandbox", default-features = false } pallet-parachain-staking = { path = "pallets/parachain-staking", default-features = false } pallet-linear-release = { path = "pallets/linear-release", default-features = false } polimec-xcm-executor = { path = "pallets/xcm-executor", default-features = false} - +polimec-receiver = { path = "pallets/polimec-receiver", default-features = false } # Internal support (with default disabled) shared-configuration = { path = "runtimes/shared-configuration", default-features = false } polimec-traits = { path = "traits", default-features = false } diff --git a/integration-tests/penpal/Cargo.toml b/integration-tests/penpal/Cargo.toml index bb80ad96c..85bce7028 100644 --- a/integration-tests/penpal/Cargo.toml +++ b/integration-tests/penpal/Cargo.toml @@ -21,6 +21,9 @@ log = { version = "0.4.16", default-features = false } scale-info = { version = "2.7.0", default-features = false, features = ["derive"] } smallvec = "1.10.0" +# Local +polimec-receiver.workspace = true + # Substrate frame-benchmarking = { workspace = true, optional = true } frame-executive.workspace = true diff --git a/integration-tests/penpal/src/lib.rs b/integration-tests/penpal/src/lib.rs index a790ff271..c09431dc3 100644 --- a/integration-tests/penpal/src/lib.rs +++ b/integration-tests/penpal/src/lib.rs @@ -547,6 +547,10 @@ impl pallet_sudo::Config for Runtime { type WeightInfo = pallet_sudo::weights::SubstrateWeight; } +impl polimec_receiver::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where @@ -582,6 +586,7 @@ construct_runtime!( // The main stage. Assets: pallet_assets::{Pallet, Call, Storage, Event} = 50, + PolimecReceiver: polimec_receiver = 51, Sudo: pallet_sudo::{Pallet, Call, Storage, Event, Config} = 255, } diff --git a/integration-tests/src/lib.rs b/integration-tests/src/lib.rs index 4a36cee9c..10ec0495e 100644 --- a/integration-tests/src/lib.rs +++ b/integration-tests/src/lib.rs @@ -15,8 +15,8 @@ // along with this program. If not, see . pub mod constants; -#[cfg(test)] -mod defaults; + +// #[cfg(any(feature = "runtime-benchmarks", test, all(feature = "testing-node", feature = "std")))] #[cfg(test)] mod tests; diff --git a/integration-tests/src/defaults.rs b/integration-tests/src/tests/defaults.rs similarity index 93% rename from integration-tests/src/defaults.rs rename to integration-tests/src/tests/defaults.rs index 7334a2e21..bc54f1196 100644 --- a/integration-tests/src/defaults.rs +++ b/integration-tests/src/tests/defaults.rs @@ -1,7 +1,7 @@ use super::*; +pub use pallet_funding::instantiator::{BidParams, ContributionParams, UserToPLMCBalance, UserToUSDBalance}; use frame_support::BoundedVec; use pallet_funding::{ - instantiator::{BidParams, ContributionParams, UserToPLMCBalance, UserToUSDBalance}, AcceptedFundingAsset, CurrencyMetadata, ParticipantsSize, PriceOf, ProjectMetadata, ProjectMetadataOf, TicketSize, }; use sp_core::H256; @@ -19,7 +19,7 @@ pub const METADATA: &str = r#"METADATA }"#; pub const ASSET_DECIMALS: u8 = 10; pub const ASSET_UNIT: u128 = 10_u128.pow(10 as u32); -pub const PLMC: Balance = 10u128.pow(10); +pub const PLMC: u128 = 10u128.pow(10); pub type IntegrationInstantiator = pallet_funding::instantiator::Instantiator< PolimecRuntime, ::AllPalletsWithoutSystem, @@ -143,7 +143,7 @@ pub fn default_bids() -> Vec> { ) } -pub fn default_community_contributions() -> Vec> { +pub fn default_community_contributions() -> Vec> { let fifty_percent_funding_usd = Perquintill::from_percent(50) * (sp_runtime::FixedU128::from_float(1.0).checked_mul_int(100_000 * ASSET_UNIT).unwrap()); @@ -159,3 +159,9 @@ pub fn default_contributors() -> Vec { } use polimec_parachain_runtime::Runtime as T; +use crate::{Polimec, PolimecRuntime}; + +#[test] +fn something() { + assert!(true); +} diff --git a/integration-tests/src/tests/mod.rs b/integration-tests/src/tests/mod.rs index 90a917dbc..19dae951e 100644 --- a/integration-tests/src/tests/mod.rs +++ b/integration-tests/src/tests/mod.rs @@ -1,3 +1,5 @@ + mod basic_comms; mod reserve_backed_transfers; mod sandbox; +mod defaults; diff --git a/integration-tests/src/tests/sandbox.rs b/integration-tests/src/tests/sandbox.rs index 72d9d1cec..e3f65450a 100644 --- a/integration-tests/src/tests/sandbox.rs +++ b/integration-tests/src/tests/sandbox.rs @@ -1,6 +1,8 @@ use crate::*; -use defaults::*; +use tests::defaults::*; use std::cell::RefCell; +use polimec_parachain_runtime::PolimecFunding; + const MAX_REF_TIME: u64 = 700_000_000; const MAX_PROOF_SIZE: u64 = 10_000; pub const REF_TIME_THRESHOLD: u64 = 33; @@ -8,7 +10,7 @@ pub const PROOF_SIZE_THRESHOLD: u64 = 33; #[test] fn migration_check() { - let inst = IntegrationInstantiator::new(None); + let mut inst = IntegrationInstantiator::new(None); let project_id = Polimec::execute_with(|| { inst.create_finished_project( default_project(issuer(), 0), @@ -20,51 +22,71 @@ fn migration_check() { ) }); let max_weight = Weight::from_parts(MAX_REF_TIME, MAX_PROOF_SIZE); - let execution_currency: MultiAsset = (MultiLocation { parents: 0, interior: Here }, 1_0_000_000_000u128).into(); // 1 unit for executing let expected_currency: MultiAsset = (MultiLocation { parents: 0, interior: Here }, 1_000_000_0_000_000_000u128).into(); // 1MM units for migrations - let xcm = Xcm(vec![ - UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, - WithdrawAsset(vec![expected_currency.clone()].into()), - ReportHolding { - response_info: QueryResponseInfo { - destination: ParentThen(Parachain(3355).into()).into(), - query_id: 0, - max_weight: max_weight.clone(), - }, - assets: Wild(All), - }, - QueryPallet { - module_name: Vec::from("polimec_receiver"), - response_info: QueryResponseInfo { - destination: ParentThen(Parachain(3355).into()).into(), - query_id: 1, - max_weight: max_weight.clone(), - }, - }, - DepositAsset { assets: Wild(All), beneficiary: ParentThen(Parachain(3355).into()).into() }, - ]); + // let xcm = Xcm(vec![ + // UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, + // WithdrawAsset(vec![expected_currency.clone()].into()), + // ReportHolding { + // response_info: QueryResponseInfo { + // destination: ParentThen(Parachain(3355).into()).into(), + // query_id: 0, + // max_weight: max_weight.clone(), + // }, + // assets: Wild(All), + // }, + // QueryPallet { + // module_name: Vec::from("polimec_receiver"), + // response_info: QueryResponseInfo { + // destination: ParentThen(Parachain(3355).into()).into(), + // query_id: 1, + // max_weight: max_weight.clone(), + // }, + // }, + // DepositAsset { assets: Wild(All), beneficiary: ParentThen(Parachain(3355).into()).into() }, + // ]); let polimec_on_penpal = Penpal::sovereign_account_id_of((Parent, Parachain(polimec::PARA_ID)).into()); let balance_polimec = Penpal::account_data_of(polimec_on_penpal); let penpal_sov_acc = PolkadotRelay::sovereign_account_id_of(Parachain(Penpal::para_id().into()).into()); PolkadotRelay::fund_accounts(vec![(penpal_sov_acc, 100_0_000_000_000u128)]); + use xcm::v3::PalletInfo; + // Mock HRMP establishment Polimec::execute_with(|| { - let penpal_loc: MultiLocation = MultiLocation::from(ParentThen(X1(Parachain(Penpal::para_id().into())))); - let now = PolimecSystem::block_number(); - // the parameters of the call are not relevant since they will be stripped and replaced by the query result - let call = PolimecCall::PolimecFunding(pallet_funding::Call::migration_check_response { - query_id: Default::default(), - response: Default::default(), - }); - let query_id_0 = PolimecXcmPallet::new_notify_query(penpal_loc, call.clone(), now + 20u32, Here); - let query_id_1 = PolimecXcmPallet::new_notify_query(penpal_loc, call, now + 20u32, Here); - assert_ok!(PolimecXcmPallet::send_xcm(Here, penpal_loc, xcm)); - println!("polimec events:"); - dbg!(Polimec::events()) + assert_ok!(PolimecFunding::do_set_para_id_for_project( + &issuer(), + project_id, + ParaId::from(6969u32) + )); + + let open_channel_message = xcm::v3::opaque::Instruction::HrmpNewChannelOpenRequest { + sender: 6969, + max_message_size: 102_300, + max_capacity: 1000, + }; + assert_ok!(PolimecFunding::do_handle_channel_open_request(open_channel_message)); + + let channel_accepted_message = xcm::v3::opaque::Instruction::HrmpChannelAccepted { recipient: 6969u32 }; + assert_ok!(PolimecFunding::do_handle_channel_accepted(channel_accepted_message)); + }); + // Polimec::execute_with(|| { + // let penpal_loc: MultiLocation = MultiLocation::from(ParentThen(X1(Parachain(Penpal::para_id().into())))); + // let now = PolimecSystem::block_number(); + // // the parameters of the call are not relevant since they will be stripped and replaced by the query result + // let call = PolimecCall::PolimecFunding(pallet_funding::Call::migration_check_response { + // query_id: Default::default(), + // response: Default::default(), + // }); + // let query_id_0 = PolimecXcmPallet::new_notify_query(penpal_loc, call.clone(), now + 20u32, Here); + // let query_id_1 = PolimecXcmPallet::new_notify_query(penpal_loc, call, now + 20u32, Here); + // assert_ok!(PolimecXcmPallet::send_xcm(Here, penpal_loc, xcm)); + // println!("polimec events:"); + // dbg!(Polimec::events()) + // }); + Penpal::execute_with(|| { println!("penpal events:"); dbg!(Penpal::events()); diff --git a/pallets/funding/Cargo.toml b/pallets/funding/Cargo.toml index 30f4c4002..c1c19c1cd 100644 --- a/pallets/funding/Cargo.toml +++ b/pallets/funding/Cargo.toml @@ -48,6 +48,7 @@ pallet-insecure-randomness-collective-flip.workspace = true pallet-assets.workspace = true pallet-linear-release.workspace = true assert_matches2.workspace = true +xcm-builder.workspace = true [features] default = [ "std" ] diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 2a3e783b7..ccfdd81c2 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -37,12 +37,13 @@ use sp_runtime::traits::Convert; use sp_std::marker::PhantomData; use polimec_traits::ReleaseSchedule; +use crate::ProjectStatus::FundingSuccessful; use crate::traits::{BondingRequirementCalculation, ProvideStatemintPrice, VestingDurationCalculation}; use super::*; -// Round transition functions +// Round transitions impl Pallet { /// Called by user extrinsic /// Creates a project and assigns it to the `issuer` account. @@ -700,7 +701,7 @@ impl Pallet { } } -// Extrinsic functions (except round transitions) +// Extrinsics and HRMP interactions impl Pallet { /// Change the metadata hash of a project /// @@ -1778,6 +1779,136 @@ impl Pallet { Ok(()) } + pub fn do_handle_channel_open_request(message: Instruction) -> XcmResult { + // TODO: set these constants with a proper value + const MAX_MESSAGE_SIZE_THRESHOLDS: (u32, u32) = (50000, 102_400); + const MAX_CAPACITY_THRESHOLDS: (u32, u32) = (8, 1000); + const REQUIRED_MAX_CAPACITY: u32 = 8u32; + const REQUIRED_MAX_MESSAGE_SIZE: u32 = 102_400u32; + const EXECUTION_DOT: MultiAsset = MultiAsset { + id: Concrete(MultiLocation { parents: 0, interior: Here }), + fun: Fungible(1_0_000_000_000u128), + }; + const MAX_WEIGHT: Weight = Weight::from_parts(20_000_000_000, 1_000_000); + const POLIMEC_PARA_ID: u32 = 3355u32; + + log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest received: {:?}", message); + + match message { + Instruction::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } + if max_message_size >= MAX_MESSAGE_SIZE_THRESHOLDS.0 && + max_message_size <= MAX_MESSAGE_SIZE_THRESHOLDS.1 && + max_capacity >= MAX_CAPACITY_THRESHOLDS.0 && + max_capacity <= MAX_CAPACITY_THRESHOLDS.1 => + { + log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest accepted"); + + let (project_id, mut project_details) = ProjectsDetails::::iter() + .find(|(_id, details)| { + details.parachain_id == Some(ParaId::from(sender)) && details.status == FundingSuccessful + }) + .ok_or(XcmError::BadOrigin)?; + + let accept_channel_relay_call = + polkadot_runtime::RuntimeCall::Hrmp(polkadot_runtime_parachains::hrmp::Call::< + polkadot_runtime::Runtime, + >::hrmp_accept_open_channel { + sender: ParaId::from(sender), + }) + .encode(); + + let request_channel_relay_call = + polkadot_runtime::RuntimeCall::Hrmp(polkadot_runtime_parachains::hrmp::Call::< + polkadot_runtime::Runtime, + >::hrmp_init_open_channel { + recipient: ParaId::from(sender), + proposed_max_capacity: REQUIRED_MAX_CAPACITY, + proposed_max_message_size: REQUIRED_MAX_MESSAGE_SIZE, + }) + .encode(); + + let xcm: Xcm<()> = Xcm(vec![ + WithdrawAsset(vec![EXECUTION_DOT.clone()].into()), + BuyExecution { fees: EXECUTION_DOT.clone(), weight_limit: Unlimited }, + Transact { + origin_kind: OriginKind::Native, + require_weight_at_most: MAX_WEIGHT, + call: accept_channel_relay_call.into(), + }, + Transact { + origin_kind: OriginKind::Native, + require_weight_at_most: MAX_WEIGHT, + call: request_channel_relay_call.into(), + }, + RefundSurplus, + DepositAsset { + assets: Wild(All), + beneficiary: MultiLocation { parents: 0, interior: X1(Parachain(POLIMEC_PARA_ID)) }, + }, + ]); + let mut message = Some(xcm); + + let dest_loc = MultiLocation { parents: 1, interior: Here }; + let mut destination = Some(dest_loc); + let (ticket, _price) = T::XcmRouter::validate(&mut destination, &mut message)?; + + match T::XcmRouter::deliver(ticket) { + Ok(_) => { + log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest: acceptance successfully sent"); + project_details.comm_status.project_to_polimec = ChannelStatus::Open; + project_details.comm_status.polimec_to_project = ChannelStatus::AwaitingAcceptance; + ProjectsDetails::::insert(project_id, project_details); + + Pallet::::deposit_event(Event::::HrmpChannelAccepted { + project_id, + para_id: ParaId::from(sender), + }); + Ok(()) + }, + Err(e) => { + log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest: acceptance sending failed - {:?}", e); + Err(XcmError::Unimplemented) + }, + } + }, + instr @ _ => { + log::trace!(target: "pallet_funding::hrmp", "Bad instruction: {:?}", instr); + Err(XcmError::Unimplemented) + }, + } + } + + pub fn do_handle_channel_accepted(message: Instruction) -> XcmResult { + match message { + Instruction::HrmpChannelAccepted { recipient } => { + log::trace!(target: "pallet_funding::hrmp", "HrmpChannelAccepted received: {:?}", message); + let (project_id, mut project_details) = ProjectsDetails::::iter() + .find(|(_id, details)| { + details.parachain_id == Some(ParaId::from(recipient)) && details.status == FundingSuccessful + }) + .ok_or(XcmError::BadOrigin)?; + + project_details.comm_status.polimec_to_project = ChannelStatus::Open; + ProjectsDetails::::insert(project_id, project_details); + Pallet::::deposit_event(Event::::HrmpChannelEstablished { + project_id, + para_id: ParaId::from(recipient), + }); + + Pallet::::do_start_migration_readiness_check( + &(T::PalletId::get().into_account_truncating()), + project_id, + ) + .map_err(|_| XcmError::NoDeal)?; + Ok(()) + }, + instr @ _ => { + log::trace!(target: "pallet_funding::hrmp", "Bad instruction: {:?}", instr); + Err(XcmError::Unimplemented) + }, + } + } + pub fn do_start_migration_readiness_check( caller: &AccountIdOf, project_id: T::ProjectIdentifier, @@ -1854,32 +1985,32 @@ impl Pallet { ) -> DispatchResult { // * Get variables * // TODO: check if this is too low performance. Maybe we want a new map of query_id -> project_id - let (project_id, project_details) = ProjectsDetails::::iter() - .find(|(_, details)| { - if let Some(MigrationReadinessCheck::QuerySent(id)) = details.migration_readiness_check { - id == query_id - } else { - false - } - }) - .ok_or(Error::::NotAllowed)?; - - let para_id = if let MultiLocation { parents: 1, interior: X1(Parachain(para_id)) } = location { - ParaId::from(para_id) - } else { - return Err(Error::::NotAllowed.into()) - }; - - let _tokens_held = match response { - xcm::v3::Response::Assets(_) => 10, - _ => return Err(Error::::NotAllowed.into()), - }; - - let _project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; - // let contribution_tokens_sold = project_metadata.total_allocation_size - project_details.remaining_contribution_tokens; - - // * Validity checks * - ensure!(project_details.parachain_id == Some(para_id), Error::::NotAllowed); + // let (project_id, project_details) = ProjectsDetails::::iter() + // .find(|(_, details)| { + // if let Some(MigrationReadinessCheck::QuerySent(id)) = details.migration_readiness_check { + // id == query_id + // } else { + // false + // } + // }) + // .ok_or(Error::::NotAllowed)?; + // + // let para_id = if let MultiLocation { parents: 1, interior: X1(Parachain(para_id)) } = location { + // ParaId::from(para_id) + // } else { + // return Err(Error::::NotAllowed.into()) + // }; + // + // let _tokens_held = match response { + // xcm::v3::Response::Assets(_) => 10, + // _ => return Err(Error::::NotAllowed.into()), + // }; + // + // let _project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; + // // let contribution_tokens_sold = project_metadata.total_allocation_size - project_details.remaining_contribution_tokens; + // + // // * Validity checks * + // ensure!(project_details.parachain_id == Some(para_id), Error::::NotAllowed); // * Update storage * diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 329d7d05e..e492a37ed 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1375,136 +1375,14 @@ pub mod xcm_executor_impl { use crate::ProjectStatus::FundingSuccessful; use frame_support::pallet_prelude::Get; - pub struct HrmpHandler(PhantomData<(T, XcmSender)>); - impl polimec_xcm_executor::HrmpHandler for HrmpHandler { + pub struct HrmpHandler(PhantomData); + impl polimec_xcm_executor::HrmpHandler for HrmpHandler { fn handle_channel_open_request(message: Instruction) -> XcmResult { - // TODO: set these constants with a proper value - const MAX_MESSAGE_SIZE_THRESHOLDS: (u32, u32) = (50000, 102_400); - const MAX_CAPACITY_THRESHOLDS: (u32, u32) = (8, 1000); - const REQUIRED_MAX_CAPACITY: u32 = 8u32; - const REQUIRED_MAX_MESSAGE_SIZE: u32 = 102_400u32; - const EXECUTION_DOT: MultiAsset = MultiAsset { - id: Concrete(MultiLocation { parents: 0, interior: Here }), - fun: Fungible(1_0_000_000_000u128), - }; - const MAX_WEIGHT: Weight = Weight::from_parts(20_000_000_000, 1_000_000); - const POLIMEC_PARA_ID: u32 = 3355u32; - - log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest received: {:?}", message); - - match message { - Instruction::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } - if max_message_size >= MAX_MESSAGE_SIZE_THRESHOLDS.0 && - max_message_size <= MAX_MESSAGE_SIZE_THRESHOLDS.1 && - max_capacity >= MAX_CAPACITY_THRESHOLDS.0 && - max_capacity <= MAX_CAPACITY_THRESHOLDS.1 => - { - log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest accepted"); - - let (project_id, mut project_details) = ProjectsDetails::::iter() - .find(|(_id, details)| { - details.parachain_id == Some(ParaId::from(sender)) && details.status == FundingSuccessful - }) - .ok_or(XcmError::BadOrigin)?; - - let accept_channel_relay_call = - polkadot_runtime::RuntimeCall::Hrmp(polkadot_runtime_parachains::hrmp::Call::< - polkadot_runtime::Runtime, - >::hrmp_accept_open_channel { - sender: ParaId::from(sender), - }) - .encode(); - - let request_channel_relay_call = - polkadot_runtime::RuntimeCall::Hrmp(polkadot_runtime_parachains::hrmp::Call::< - polkadot_runtime::Runtime, - >::hrmp_init_open_channel { - recipient: ParaId::from(sender), - proposed_max_capacity: REQUIRED_MAX_CAPACITY, - proposed_max_message_size: REQUIRED_MAX_MESSAGE_SIZE, - }) - .encode(); - - let xcm: Xcm<()> = Xcm(vec![ - WithdrawAsset(vec![EXECUTION_DOT.clone()].into()), - BuyExecution { fees: EXECUTION_DOT.clone(), weight_limit: Unlimited }, - Transact { - origin_kind: OriginKind::Native, - require_weight_at_most: MAX_WEIGHT, - call: accept_channel_relay_call.into(), - }, - Transact { - origin_kind: OriginKind::Native, - require_weight_at_most: MAX_WEIGHT, - call: request_channel_relay_call.into(), - }, - RefundSurplus, - DepositAsset { - assets: Wild(All), - beneficiary: MultiLocation { parents: 0, interior: X1(Parachain(POLIMEC_PARA_ID)) }, - }, - ]); - let mut message = Some(xcm); - - let dest_loc = MultiLocation { parents: 1, interior: Here }; - let mut destination = Some(dest_loc); - let (ticket, _price) = XcmSender::validate(&mut destination, &mut message)?; - - match XcmSender::deliver(ticket) { - Ok(_) => { - log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest: acceptance successfully sent"); - project_details.comm_status.project_to_polimec = ChannelStatus::Open; - project_details.comm_status.polimec_to_project = ChannelStatus::AwaitingAcceptance; - ProjectsDetails::::insert(project_id, project_details); - - Pallet::::deposit_event(Event::::HrmpChannelAccepted { - project_id, - para_id: ParaId::from(sender), - }); - Ok(()) - }, - Err(e) => { - log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest: acceptance sending failed - {:?}", e); - Err(XcmError::Unimplemented) - }, - } - }, - instr @ _ => { - log::trace!(target: "pallet_funding::hrmp", "Bad instruction: {:?}", instr); - Err(XcmError::Unimplemented) - }, - } + >::do_handle_channel_open_request(message) } fn handle_channel_accepted(message: Instruction) -> XcmResult { - match message { - Instruction::HrmpChannelAccepted { recipient } => { - log::trace!(target: "pallet_funding::hrmp", "HrmpChannelAccepted received: {:?}", message); - let (project_id, mut project_details) = ProjectsDetails::::iter() - .find(|(_id, details)| { - details.parachain_id == Some(ParaId::from(recipient)) && details.status == FundingSuccessful - }) - .ok_or(XcmError::BadOrigin)?; - - project_details.comm_status.polimec_to_project = ChannelStatus::Open; - ProjectsDetails::::insert(project_id, project_details); - Pallet::::deposit_event(Event::::HrmpChannelEstablished { - project_id, - para_id: ParaId::from(recipient), - }); - - Pallet::::do_start_migration_readiness_check( - &(T::PalletId::get().into_account_truncating()), - project_id, - ) - .map_err(|_| XcmError::NoDeal)?; - Ok(()) - }, - instr @ _ => { - log::trace!(target: "pallet_funding::hrmp", "Bad instruction: {:?}", instr); - Err(XcmError::Unimplemented) - }, - } + >::do_handle_channel_accepted(message) } } } diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index afdc41824..760fee9ab 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -69,6 +69,7 @@ frame_support::construct_runtime!( Vesting: pallet_linear_release, LocalAssets: pallet_assets::::{Pallet, Call, Storage, Event}, StatemintAssets: pallet_assets::::{Pallet, Call, Storage, Event, Config}, + PolkadotXcm: pallet_xcm, } ); @@ -84,6 +85,72 @@ pub const fn free_deposit() -> Balance { 0 * MICRO_PLMC } + + +//region DRAFT ZONE +use xcm_builder::{EnsureXcmOrigin, FixedWeightBounds, SignedToAccountId32, ParentIsPreset, SiblingParachainConvertsVia, AccountId32Aliases}; +use polkadot_parachain::primitives::Sibling; +use frame_support::traits::Everything; + +pub type LocalOriginToLocation = SignedToAccountId32; +pub type LocationToAccountId = ( + // The parent (Relay-chain) origin converts to the parent `AccountId`. + ParentIsPreset, + // Sibling parachain origins convert to AccountId via the `ParaId::into`. + SiblingParachainConvertsVia, + // Straight up local `AccountId32` origins just alias directly to `AccountId`. + AccountId32Aliases, +); +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { + pub ReachableDest: Option = Some(Parent.into()); +} +parameter_types! { + pub UniversalLocation: InteriorMultiLocation = ( + GlobalConsensus(Polkadot), + Parachain(ParachainInfo::parachain_id().into()), + ).into(); + pub const RelayNetwork: Option = None; + pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024); + pub const MaxInstructions: u32 = 100; + + pub const HereLocation: MultiLocation = MultiLocation::here(); +} +impl pallet_xcm::Config for TestRuntime { + type AdminOrigin = EnsureRoot; + // ^ Override for AdvertisedXcmVersion default + type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; + type Currency = Balances; + type CurrencyMatcher = (); + type ExecuteXcmOrigin = EnsureXcmOrigin; + type MaxLockers = ConstU32<8>; + type MaxRemoteLockConsumers = ConstU32<0>; + #[cfg(feature = "runtime-benchmarks")] + type ReachableDest = ReachableDest; + type RemoteLockConsumerIdentifier = (); + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type SendXcmOrigin = EnsureXcmOrigin; + type SovereignAccountOf = LocationToAccountId; + type TrustedLockers = (); + type UniversalLocation = UniversalLocation; + type Weigher = FixedWeightBounds; + type WeightInfo = pallet_xcm::TestWeightInfo; + // TODO: change back to `Nothing` once we add the xcm functionalities into a pallet + type XcmExecuteFilter = Everything; + // ^ Disable dispatchable execute on the XCM pallet. + // Needs to be `Everything` for local testing. + type XcmExecutor = (); + type XcmReserveTransferFilter = Everything; + type XcmRouter = (); + type XcmTeleportFilter = Everything; + + const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; +} + +//endregion + parameter_types! { pub const AssetDeposit: Balance = PLMC; // 1 UNIT deposit to create asset pub const AssetAccountDeposit: Balance = deposit(1, 16); @@ -240,7 +307,6 @@ impl pallet_linear_release::Config for TestRuntime { } impl Config for TestRuntime { - // #[cfg(feature = "runtime-benchmarks")] type AllPalletsWithoutSystem = AllPalletsWithoutSystem; type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; type Balance = Balance; diff --git a/pallets/polimec-receiver/Cargo.toml b/pallets/polimec-receiver/Cargo.toml index d047b116a..0f87d84b0 100644 --- a/pallets/polimec-receiver/Cargo.toml +++ b/pallets/polimec-receiver/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "pallet-parachain-template" +name = "polimec-receiver" authors = ["Anonymous"] description = "FRAME pallet template for defining custom runtime logic." version = "0.1.0" diff --git a/pallets/polimec-receiver/src/lib.rs b/pallets/polimec-receiver/src/lib.rs index 5f3252bfc..4aa9b3f9a 100644 --- a/pallets/polimec-receiver/src/lib.rs +++ b/pallets/polimec-receiver/src/lib.rs @@ -5,15 +5,6 @@ /// pub use pallet::*; -#[cfg(test)] -mod mock; - -#[cfg(test)] -mod tests; - -#[cfg(feature = "runtime-benchmarks")] -mod benchmarking; - #[frame_support::pallet] pub mod pallet { use frame_support::{dispatch::DispatchResultWithPostInfo, pallet_prelude::*}; diff --git a/runtimes/testnet/src/xcm_config.rs b/runtimes/testnet/src/xcm_config.rs index d11ab0ab2..edeb89b5a 100644 --- a/runtimes/testnet/src/xcm_config.rs +++ b/runtimes/testnet/src/xcm_config.rs @@ -371,7 +371,7 @@ impl polimec_xcm_executor::Config for XcmConfig { type Barrier = Barrier; type CallDispatcher = RuntimeCall; type FeeManager = (); - type HrmpHandler = pallet_funding::xcm_executor_impl::HrmpHandler; + type HrmpHandler = pallet_funding::xcm_executor_impl::HrmpHandler; type IsReserve = Reserves; type IsTeleporter = NativeAsset; type MaxAssetsIntoHolding = MaxAssetsIntoHolding; From 223c4cdd5d147e46cd0ad8e2a465040d6ddda0e4 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 7 Nov 2023 17:31:30 +0100 Subject: [PATCH 009/212] pallet-funding tests fixed --- Cargo.lock | 1 + integration-tests/src/lib.rs | 3 +- pallets/funding/Cargo.toml | 2 +- pallets/funding/src/mock.rs | 88 +++++++++++++++++++++++------------- 4 files changed, 60 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 55a617da8..3c8f3633e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6305,6 +6305,7 @@ dependencies = [ "sp-std", "xcm", "xcm-builder", + "xcm-executor", ] [[package]] diff --git a/integration-tests/src/lib.rs b/integration-tests/src/lib.rs index 10ec0495e..52b01eeca 100644 --- a/integration-tests/src/lib.rs +++ b/integration-tests/src/lib.rs @@ -16,8 +16,7 @@ pub mod constants; -// #[cfg(any(feature = "runtime-benchmarks", test, all(feature = "testing-node", feature = "std")))] -#[cfg(test)] +#[cfg(all(test, feature = "std", feature="testing-node"))] mod tests; pub use constants::{accounts::*, penpal, polimec, polkadot, statemint}; diff --git a/pallets/funding/Cargo.toml b/pallets/funding/Cargo.toml index c1c19c1cd..8b32222d8 100644 --- a/pallets/funding/Cargo.toml +++ b/pallets/funding/Cargo.toml @@ -49,7 +49,7 @@ pallet-assets.workspace = true pallet-linear-release.workspace = true assert_matches2.workspace = true xcm-builder.workspace = true - +xcm-executor.workspace = true [features] default = [ "std" ] std = [ diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 760fee9ab..a11062720 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -91,15 +91,39 @@ pub const fn free_deposit() -> Balance { use xcm_builder::{EnsureXcmOrigin, FixedWeightBounds, SignedToAccountId32, ParentIsPreset, SiblingParachainConvertsVia, AccountId32Aliases}; use polkadot_parachain::primitives::Sibling; use frame_support::traits::Everything; +use xcm_executor::traits::Convert; +use frame_support::traits::OriginTrait; +use sp_runtime::traits::Get; +use frame_system::RawOrigin as SystemRawOrigin; -pub type LocalOriginToLocation = SignedToAccountId32; + +pub struct SignedToAccountIndex( + PhantomData<(RuntimeOrigin, AccountId, Network)>, +); +impl< + RuntimeOrigin: OriginTrait + Clone, + AccountId: Into, + Network: Get>, +> Convert for SignedToAccountIndex + where + RuntimeOrigin::PalletsOrigin: From> + + TryInto, Error = RuntimeOrigin::PalletsOrigin>, +{ + fn convert(o: RuntimeOrigin) -> Result { + o.try_with_caller(|caller| match caller.try_into() { + Ok(SystemRawOrigin::Signed(who)) => + Ok(Junction::AccountIndex64 { network: Network::get(), index: who.into() }.into()), + Ok(other) => Err(other.into()), + Err(other) => Err(other), + }) + } +} +pub type LocalOriginToLocation = SignedToAccountIndex; pub type LocationToAccountId = ( // The parent (Relay-chain) origin converts to the parent `AccountId`. ParentIsPreset, // Sibling parachain origins convert to AccountId via the `ParaId::into`. SiblingParachainConvertsVia, - // Straight up local `AccountId32` origins just alias directly to `AccountId`. - AccountId32Aliases, ); #[cfg(feature = "runtime-benchmarks")] parameter_types! { @@ -108,7 +132,7 @@ parameter_types! { parameter_types! { pub UniversalLocation: InteriorMultiLocation = ( GlobalConsensus(Polkadot), - Parachain(ParachainInfo::parachain_id().into()), + Parachain(3355u32.into()), ).into(); pub const RelayNetwork: Option = None; pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024); @@ -308,41 +332,43 @@ impl pallet_linear_release::Config for TestRuntime { impl Config for TestRuntime { type AllPalletsWithoutSystem = AllPalletsWithoutSystem; - type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + type ProjectIdentifier = Identifier; + type Multiplier = Multiplier; type Balance = Balance; - type BlockNumberToBalance = ConvertInto; - type CandleAuctionDuration = CandleAuctionDuration; - type CommunityFundingDuration = CommunityRoundDuration; + type Price = FixedU128; + type NativeCurrency = Balances; + type FundingCurrency = StatemintAssets; type ContributionTokenCurrency = LocalAssets; - type ContributionVesting = ConstU32<4>; - type DaysToBlocks = DaysToBlocks; - type EnglishAuctionDuration = EnglishAuctionDuration; + type PriceProvider = ConstPriceProvider; + type Randomness = RandomnessCollectiveFlip; + type StringLimit = ConstU32<64>; + type PreImageLimit = ConstU32<1024>; type EvaluationDuration = EvaluationDuration; - type EvaluationSuccessThreshold = EarlyEvaluationThreshold; - type EvaluatorSlash = EvaluatorSlash; - type FeeBrackets = FeeBrackets; - type FundingCurrency = StatemintAssets; - type ManualAcceptanceDuration = ManualAcceptanceDuration; + type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; + type EnglishAuctionDuration = EnglishAuctionDuration; + type CandleAuctionDuration = CandleAuctionDuration; + type CommunityFundingDuration = CommunityRoundDuration; + type RemainderFundingDuration = RemainderFundingDuration; + type PalletId = FundingPalletId; + type MaxProjectsToUpdatePerBlock = ConstU32<100>; + type MaxEvaluationsPerUser = ConstU32<4>; // Low value to simplify the tests type MaxBidsPerUser = ConstU32<4>; type MaxContributionsPerUser = ConstU32<4>; - type MaxEvaluationsPerUser = ConstU32<4>; - type MaxProjectsToUpdatePerBlock = ConstU32<100>; - type Multiplier = Multiplier; - type NativeCurrency = Balances; - type PalletId = FundingPalletId; - type PreImageLimit = ConstU32<1024>; - type Price = FixedU128; - type PriceProvider = ConstPriceProvider; - type ProjectIdentifier = Identifier; - type Randomness = RandomnessCollectiveFlip; - type RemainderFundingDuration = RemainderFundingDuration; - type RuntimeEvent = RuntimeEvent; - type StringLimit = ConstU32<64>; + type ContributionVesting = ConstU32<4>; + type WeightInfo = weights::SubstrateWeight; + type FeeBrackets = FeeBrackets; + type EvaluationSuccessThreshold = EarlyEvaluationThreshold; + type Vesting = Vesting; + type ManualAcceptanceDuration = ManualAcceptanceDuration; type SuccessToSettlementTime = SuccessToSettlementTime; + type EvaluatorSlash = EvaluatorSlash; type TreasuryAccount = TreasuryAccount; - type Vesting = Vesting; - type WeightInfo = weights::SubstrateWeight; + type DaysToBlocks = DaysToBlocks; + type BlockNumberToBalance = ConvertInto; } // Build genesis storage according to the mock runtime. From f96b048b1d47fa8ad1e5ce11aaaba15de402dfb6 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 8 Nov 2023 15:25:53 +0100 Subject: [PATCH 010/212] migration check working --- integration-tests/src/lib.rs | 2 +- integration-tests/src/tests/ct_migration.rs | 53 +++ integration-tests/src/tests/defaults.rs | 4 +- integration-tests/src/tests/mod.rs | 5 +- integration-tests/src/tests/sandbox.rs | 99 ------ pallets/funding/src/functions.rs | 357 ++++++++++++-------- pallets/funding/src/lib.rs | 17 +- pallets/funding/src/mock.rs | 90 +++-- pallets/funding/src/types.rs | 20 +- runtimes/testnet/src/lib.rs | 5 + 10 files changed, 348 insertions(+), 304 deletions(-) create mode 100644 integration-tests/src/tests/ct_migration.rs delete mode 100644 integration-tests/src/tests/sandbox.rs diff --git a/integration-tests/src/lib.rs b/integration-tests/src/lib.rs index 52b01eeca..07f4cd5cf 100644 --- a/integration-tests/src/lib.rs +++ b/integration-tests/src/lib.rs @@ -16,7 +16,7 @@ pub mod constants; -#[cfg(all(test, feature = "std", feature="testing-node"))] +#[cfg(all(test, feature = "std", feature = "testing-node"))] mod tests; pub use constants::{accounts::*, penpal, polimec, polkadot, statemint}; diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs new file mode 100644 index 000000000..a768501a6 --- /dev/null +++ b/integration-tests/src/tests/ct_migration.rs @@ -0,0 +1,53 @@ +use crate::*; +use polimec_parachain_runtime::PolimecFunding; +use std::cell::RefCell; +use tests::defaults::*; + +const MAX_REF_TIME: u64 = 700_000_000; +const MAX_PROOF_SIZE: u64 = 10_000; +pub const REF_TIME_THRESHOLD: u64 = 33; +pub const PROOF_SIZE_THRESHOLD: u64 = 33; + +#[test] +fn migration_check() { + let mut inst = IntegrationInstantiator::new(None); + let project_id = Polimec::execute_with(|| { + inst.create_finished_project( + default_project(issuer(), 0), + issuer(), + default_evaluations(), + default_bids(), + default_community_contributions(), + vec![], + ) + }); + let penpal_sov_acc = PolkadotRelay::sovereign_account_id_of(Parachain(Penpal::para_id().into()).into()); + PolkadotRelay::fund_accounts(vec![(penpal_sov_acc, 100_0_000_000_000u128)]); + + // Mock HRMP establishment + Polimec::execute_with(|| { + assert_ok!(PolimecFunding::do_set_para_id_for_project(&issuer(), project_id, ParaId::from(6969u32))); + + let open_channel_message = xcm::v3::opaque::Instruction::HrmpNewChannelOpenRequest { + sender: 6969, + max_message_size: 102_300, + max_capacity: 1000, + }; + assert_ok!(PolimecFunding::do_handle_channel_open_request(open_channel_message)); + + let channel_accepted_message = xcm::v3::opaque::Instruction::HrmpChannelAccepted { recipient: 6969u32 }; + assert_ok!(PolimecFunding::do_handle_channel_accepted(channel_accepted_message)); + }); + + Penpal::execute_with(|| { + println!("penpal events:"); + dbg!(Penpal::events()); + }); + + Polimec::execute_with(|| { + dbg!(Polimec::events()); + assert_ok!(PolimecFunding::do_migration(issuer(), 0u32)); + println!("Polimec events:"); + dbg!(Polimec::events()); + }); +} diff --git a/integration-tests/src/tests/defaults.rs b/integration-tests/src/tests/defaults.rs index bc54f1196..ee7a03dc8 100644 --- a/integration-tests/src/tests/defaults.rs +++ b/integration-tests/src/tests/defaults.rs @@ -1,6 +1,6 @@ use super::*; -pub use pallet_funding::instantiator::{BidParams, ContributionParams, UserToPLMCBalance, UserToUSDBalance}; use frame_support::BoundedVec; +pub use pallet_funding::instantiator::{BidParams, ContributionParams, UserToPLMCBalance, UserToUSDBalance}; use pallet_funding::{ AcceptedFundingAsset, CurrencyMetadata, ParticipantsSize, PriceOf, ProjectMetadata, ProjectMetadataOf, TicketSize, }; @@ -158,8 +158,8 @@ pub fn default_contributors() -> Vec { vec![buyer_1(), buyer_2(), buyer_3(), buyer_4(), buyer_5()] } -use polimec_parachain_runtime::Runtime as T; use crate::{Polimec, PolimecRuntime}; +use polimec_parachain_runtime::Runtime as T; #[test] fn something() { diff --git a/integration-tests/src/tests/mod.rs b/integration-tests/src/tests/mod.rs index 19dae951e..93a533d9c 100644 --- a/integration-tests/src/tests/mod.rs +++ b/integration-tests/src/tests/mod.rs @@ -1,5 +1,4 @@ - mod basic_comms; -mod reserve_backed_transfers; -mod sandbox; +mod ct_migration; mod defaults; +mod reserve_backed_transfers; diff --git a/integration-tests/src/tests/sandbox.rs b/integration-tests/src/tests/sandbox.rs deleted file mode 100644 index e3f65450a..000000000 --- a/integration-tests/src/tests/sandbox.rs +++ /dev/null @@ -1,99 +0,0 @@ -use crate::*; -use tests::defaults::*; -use std::cell::RefCell; -use polimec_parachain_runtime::PolimecFunding; - -const MAX_REF_TIME: u64 = 700_000_000; -const MAX_PROOF_SIZE: u64 = 10_000; -pub const REF_TIME_THRESHOLD: u64 = 33; -pub const PROOF_SIZE_THRESHOLD: u64 = 33; - -#[test] -fn migration_check() { - let mut inst = IntegrationInstantiator::new(None); - let project_id = Polimec::execute_with(|| { - inst.create_finished_project( - default_project(issuer(), 0), - issuer(), - default_evaluations(), - default_bids(), - default_community_contributions(), - vec![], - ) - }); - let max_weight = Weight::from_parts(MAX_REF_TIME, MAX_PROOF_SIZE); - let expected_currency: MultiAsset = - (MultiLocation { parents: 0, interior: Here }, 1_000_000_0_000_000_000u128).into(); // 1MM units for migrations - // let xcm = Xcm(vec![ - // UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, - // WithdrawAsset(vec![expected_currency.clone()].into()), - // ReportHolding { - // response_info: QueryResponseInfo { - // destination: ParentThen(Parachain(3355).into()).into(), - // query_id: 0, - // max_weight: max_weight.clone(), - // }, - // assets: Wild(All), - // }, - // QueryPallet { - // module_name: Vec::from("polimec_receiver"), - // response_info: QueryResponseInfo { - // destination: ParentThen(Parachain(3355).into()).into(), - // query_id: 1, - // max_weight: max_weight.clone(), - // }, - // }, - // DepositAsset { assets: Wild(All), beneficiary: ParentThen(Parachain(3355).into()).into() }, - // ]); - let polimec_on_penpal = Penpal::sovereign_account_id_of((Parent, Parachain(polimec::PARA_ID)).into()); - let balance_polimec = Penpal::account_data_of(polimec_on_penpal); - - let penpal_sov_acc = PolkadotRelay::sovereign_account_id_of(Parachain(Penpal::para_id().into()).into()); - PolkadotRelay::fund_accounts(vec![(penpal_sov_acc, 100_0_000_000_000u128)]); - use xcm::v3::PalletInfo; - - // Mock HRMP establishment - Polimec::execute_with(|| { - assert_ok!(PolimecFunding::do_set_para_id_for_project( - &issuer(), - project_id, - ParaId::from(6969u32) - )); - - let open_channel_message = xcm::v3::opaque::Instruction::HrmpNewChannelOpenRequest { - sender: 6969, - max_message_size: 102_300, - max_capacity: 1000, - }; - assert_ok!(PolimecFunding::do_handle_channel_open_request(open_channel_message)); - - let channel_accepted_message = xcm::v3::opaque::Instruction::HrmpChannelAccepted { recipient: 6969u32 }; - assert_ok!(PolimecFunding::do_handle_channel_accepted(channel_accepted_message)); - - }); - - // Polimec::execute_with(|| { - // let penpal_loc: MultiLocation = MultiLocation::from(ParentThen(X1(Parachain(Penpal::para_id().into())))); - // let now = PolimecSystem::block_number(); - // // the parameters of the call are not relevant since they will be stripped and replaced by the query result - // let call = PolimecCall::PolimecFunding(pallet_funding::Call::migration_check_response { - // query_id: Default::default(), - // response: Default::default(), - // }); - // let query_id_0 = PolimecXcmPallet::new_notify_query(penpal_loc, call.clone(), now + 20u32, Here); - // let query_id_1 = PolimecXcmPallet::new_notify_query(penpal_loc, call, now + 20u32, Here); - // assert_ok!(PolimecXcmPallet::send_xcm(Here, penpal_loc, xcm)); - // println!("polimec events:"); - // dbg!(Polimec::events()) - // }); - - Penpal::execute_with(|| { - println!("penpal events:"); - dbg!(Penpal::events()); - }); - - Polimec::execute_with(|| { - println!("Polimec events:"); - dbg!(Polimec::events()); - }); -} diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index ccfdd81c2..d3459f192 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -36,8 +36,8 @@ use sp_arithmetic::{ use sp_runtime::traits::Convert; use sp_std::marker::PhantomData; -use polimec_traits::ReleaseSchedule; use crate::ProjectStatus::FundingSuccessful; +use polimec_traits::ReleaseSchedule; use crate::traits::{BondingRequirementCalculation, ProvideStatemintPrice, VestingDurationCalculation}; @@ -158,7 +158,7 @@ impl Pallet { pub fn do_evaluation_start(caller: AccountIdOf, project_id: T::ProjectIdentifier) -> DispatchResult { // * Get variables * let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; - let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let now = >::block_number(); // * Validity checks * @@ -214,7 +214,7 @@ impl Pallet { /// unbonds the evaluators funds. pub fn do_evaluation_end(project_id: T::ProjectIdentifier) -> DispatchResult { // * Get variables * - let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let now = >::block_number(); let evaluation_end_block = project_details.phase_transition_points.evaluation.end().ok_or(Error::::FieldIsNone)?; @@ -305,7 +305,7 @@ impl Pallet { /// [`do_candle_auction`](Self::do_candle_auction). pub fn do_english_auction(caller: AccountIdOf, project_id: T::ProjectIdentifier) -> DispatchResult { // * Get variables * - let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let now = >::block_number(); let auction_initialize_period_start_block = project_details .phase_transition_points @@ -380,7 +380,7 @@ impl Pallet { /// by calling [`do_community_funding`](Self::do_community_funding). pub fn do_candle_auction(project_id: T::ProjectIdentifier) -> DispatchResult { // * Get variables * - let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let now = >::block_number(); let english_end_block = project_details.phase_transition_points.english_auction.end().ok_or(Error::::FieldIsNone)?; @@ -433,8 +433,8 @@ impl Pallet { /// starts the remainder round, where anyone can buy at that price point. pub fn do_community_funding(project_id: T::ProjectIdentifier) -> DispatchResult { // * Get variables * - let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; - let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; + let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let now = >::block_number(); let auction_candle_start_block = project_details.phase_transition_points.candle_auction.start().ok_or(Error::::FieldIsNone)?; @@ -456,7 +456,7 @@ impl Pallet { // * Update Storage * let calculation_result = Self::calculate_weighted_average_price(project_id, end_block, project_metadata.total_allocation_size.0); - let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; match calculation_result { Err(pallet_error) if pallet_error == Error::::NoBidsFound.into() => { project_details.status = ProjectStatus::FundingFailed; @@ -517,7 +517,7 @@ impl Pallet { /// [`do_end_funding`](Self::do_end_funding). pub fn do_remainder_funding(project_id: T::ProjectIdentifier) -> DispatchResult { // * Get variables * - let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let now = >::block_number(); let community_end_block = project_details.phase_transition_points.community.end().ok_or(Error::::FieldIsNone)?; @@ -577,7 +577,7 @@ impl Pallet { /// If **unsuccessful**, users every user should have their PLMC vesting unbonded. pub fn do_end_funding(project_id: T::ProjectIdentifier) -> DispatchResult { // * Get variables * - let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; let remaining_cts = project_details .remaining_contribution_tokens @@ -638,7 +638,7 @@ impl Pallet { pub fn do_project_decision(project_id: T::ProjectIdentifier, decision: FundingOutcomeDecision) -> DispatchResult { // * Get variables * - let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; // * Update storage * match decision { @@ -665,7 +665,7 @@ impl Pallet { pub fn do_start_settlement(project_id: T::ProjectIdentifier) -> DispatchResult { // * Get variables * - let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let token_information = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?.token_information; let now = >::block_number(); @@ -722,7 +722,7 @@ impl Pallet { ) -> DispatchResult { // * Get variables * let mut project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; - let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; // * Validity checks * ensure!(project_details.issuer == issuer, Error::::NotAllowed); @@ -748,7 +748,7 @@ impl Pallet { usd_amount: BalanceOf, ) -> DispatchResult { // * Get variables * - let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let now = >::block_number(); let evaluation_id = Self::next_evaluation_id(); let caller_existing_evaluations: Vec<(u32, EvaluationInfoOf)> = @@ -857,7 +857,7 @@ impl Pallet { ) -> DispatchResult { // * Get variables * ensure!(ct_amount > Zero::zero(), Error::::BidTooLow); - let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; let plmc_usd_price = T::PriceProvider::get_price(PLMC_STATEMINT_ID).ok_or(Error::::PriceNotFound)?; @@ -1015,7 +1015,7 @@ impl Pallet { asset: AcceptedFundingAsset, ) -> DispatchResultWithPostInfo { let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; - let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; // * Validity checks * ensure!(project_metadata.participation_currencies == asset, Error::::FundingAssetNotAccepted); @@ -1178,7 +1178,7 @@ impl Pallet { decision: FundingOutcomeDecision, ) -> DispatchResult { // * Get variables * - let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let now = >::block_number(); // * Validity checks * @@ -1271,7 +1271,7 @@ impl Pallet { evaluation_id: u32, ) -> DispatchResult { // * Get variables * - let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let released_evaluation = Evaluations::::get((project_id, evaluator, evaluation_id)).ok_or(Error::::EvaluationNotFound)?; @@ -1313,7 +1313,7 @@ impl Pallet { evaluation_id: u32, ) -> DispatchResult { // * Get variables * - let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let reward_info = if let EvaluatorsOutcome::Rewarded(info) = project_details.evaluation_round_info.evaluators_outcome { info @@ -1363,7 +1363,7 @@ impl Pallet { evaluation_id: u32, ) -> DispatchResult { // * Get variables * - let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let slash_percentage = T::EvaluatorSlash::get(); let treasury_account = T::TreasuryAccount::get(); @@ -1416,7 +1416,7 @@ impl Pallet { bid_id: u32, ) -> DispatchResult { // * Get variables * - let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let mut bid = Bids::::get((project_id, bidder, bid_id)).ok_or(Error::::BidNotFound)?; let funding_end_block = project_details.funding_end_block.ok_or(Error::::ImpossibleState)?; @@ -1462,7 +1462,7 @@ impl Pallet { contribution_id: u32, ) -> DispatchResult { // * Get variables * - let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let mut contribution = Contributions::::get((project_id, contributor, contribution_id)).ok_or(Error::::BidNotFound)?; let funding_end_block = project_details.funding_end_block.ok_or(Error::::ImpossibleState)?; @@ -1506,7 +1506,7 @@ impl Pallet { participant: AccountIdOf, ) -> DispatchResult { // * Get variables * - let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; // * Validity checks * ensure!(matches!(project_details.status, ProjectStatus::FundingSuccessful), Error::::NotAllowed); @@ -1527,7 +1527,7 @@ impl Pallet { bid_id: u32, ) -> DispatchResult { // * Get variables * - let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let mut bid = Bids::::get((project_id, bidder, bid_id)).ok_or(Error::::BidNotFound)?; // * Validity checks * @@ -1572,7 +1572,7 @@ impl Pallet { bid_id: u32, ) -> DispatchResult { // * Get variables * - let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let bid = Bids::::get((project_id, bidder, bid_id)).ok_or(Error::::EvaluationNotFound)?; // * Validity checks * @@ -1605,7 +1605,7 @@ impl Pallet { contribution_id: u32, ) -> DispatchResult { // * Get variables * - let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let mut contribution = Contributions::::get((project_id, contributor, contribution_id)) .ok_or(Error::::ContributionNotFound)?; @@ -1647,7 +1647,7 @@ impl Pallet { contribution_id: u32, ) -> DispatchResult { // * Get variables * - let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let bid = Contributions::::get((project_id, contributor, contribution_id)) .ok_or(Error::::EvaluationNotFound)?; @@ -1676,7 +1676,7 @@ impl Pallet { bid_id: u32, ) -> DispatchResult { // * Get variables * - let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let mut bid = Bids::::get((project_id, bidder, bid_id)).ok_or(Error::::BidNotFound)?; // * Validity checks * @@ -1722,7 +1722,7 @@ impl Pallet { contribution_id: u32, ) -> DispatchResult { // * Get variables * - let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let mut contribution = Contributions::::get((project_id, contributor, contribution_id)).ok_or(Error::::BidNotFound)?; @@ -1764,7 +1764,7 @@ impl Pallet { para_id: ParaId, ) -> DispatchResult { // * Get variables * - let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; // * Validity checks * ensure!(&(project_details.issuer) == caller, Error::::NotAllowed); @@ -1796,81 +1796,81 @@ impl Pallet { match message { Instruction::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } - if max_message_size >= MAX_MESSAGE_SIZE_THRESHOLDS.0 && - max_message_size <= MAX_MESSAGE_SIZE_THRESHOLDS.1 && - max_capacity >= MAX_CAPACITY_THRESHOLDS.0 && - max_capacity <= MAX_CAPACITY_THRESHOLDS.1 => - { - log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest accepted"); - - let (project_id, mut project_details) = ProjectsDetails::::iter() - .find(|(_id, details)| { - details.parachain_id == Some(ParaId::from(sender)) && details.status == FundingSuccessful - }) - .ok_or(XcmError::BadOrigin)?; - - let accept_channel_relay_call = - polkadot_runtime::RuntimeCall::Hrmp(polkadot_runtime_parachains::hrmp::Call::< - polkadot_runtime::Runtime, - >::hrmp_accept_open_channel { - sender: ParaId::from(sender), - }) - .encode(); - - let request_channel_relay_call = - polkadot_runtime::RuntimeCall::Hrmp(polkadot_runtime_parachains::hrmp::Call::< - polkadot_runtime::Runtime, - >::hrmp_init_open_channel { - recipient: ParaId::from(sender), - proposed_max_capacity: REQUIRED_MAX_CAPACITY, - proposed_max_message_size: REQUIRED_MAX_MESSAGE_SIZE, - }) - .encode(); - - let xcm: Xcm<()> = Xcm(vec![ - WithdrawAsset(vec![EXECUTION_DOT.clone()].into()), - BuyExecution { fees: EXECUTION_DOT.clone(), weight_limit: Unlimited }, - Transact { - origin_kind: OriginKind::Native, - require_weight_at_most: MAX_WEIGHT, - call: accept_channel_relay_call.into(), - }, - Transact { - origin_kind: OriginKind::Native, - require_weight_at_most: MAX_WEIGHT, - call: request_channel_relay_call.into(), - }, - RefundSurplus, - DepositAsset { - assets: Wild(All), - beneficiary: MultiLocation { parents: 0, interior: X1(Parachain(POLIMEC_PARA_ID)) }, - }, - ]); - let mut message = Some(xcm); - - let dest_loc = MultiLocation { parents: 1, interior: Here }; - let mut destination = Some(dest_loc); - let (ticket, _price) = T::XcmRouter::validate(&mut destination, &mut message)?; - - match T::XcmRouter::deliver(ticket) { - Ok(_) => { - log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest: acceptance successfully sent"); - project_details.comm_status.project_to_polimec = ChannelStatus::Open; - project_details.comm_status.polimec_to_project = ChannelStatus::AwaitingAcceptance; - ProjectsDetails::::insert(project_id, project_details); - - Pallet::::deposit_event(Event::::HrmpChannelAccepted { - project_id, - para_id: ParaId::from(sender), - }); - Ok(()) - }, - Err(e) => { - log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest: acceptance sending failed - {:?}", e); - Err(XcmError::Unimplemented) - }, - } - }, + if max_message_size >= MAX_MESSAGE_SIZE_THRESHOLDS.0 && + max_message_size <= MAX_MESSAGE_SIZE_THRESHOLDS.1 && + max_capacity >= MAX_CAPACITY_THRESHOLDS.0 && + max_capacity <= MAX_CAPACITY_THRESHOLDS.1 => + { + log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest accepted"); + + let (project_id, mut project_details) = ProjectsDetails::::iter() + .find(|(_id, details)| { + details.parachain_id == Some(ParaId::from(sender)) && details.status == FundingSuccessful + }) + .ok_or(XcmError::BadOrigin)?; + + let accept_channel_relay_call = + polkadot_runtime::RuntimeCall::Hrmp(polkadot_runtime_parachains::hrmp::Call::< + polkadot_runtime::Runtime, + >::hrmp_accept_open_channel { + sender: ParaId::from(sender), + }) + .encode(); + + let request_channel_relay_call = + polkadot_runtime::RuntimeCall::Hrmp(polkadot_runtime_parachains::hrmp::Call::< + polkadot_runtime::Runtime, + >::hrmp_init_open_channel { + recipient: ParaId::from(sender), + proposed_max_capacity: REQUIRED_MAX_CAPACITY, + proposed_max_message_size: REQUIRED_MAX_MESSAGE_SIZE, + }) + .encode(); + + let xcm: Xcm<()> = Xcm(vec![ + WithdrawAsset(vec![EXECUTION_DOT.clone()].into()), + BuyExecution { fees: EXECUTION_DOT.clone(), weight_limit: Unlimited }, + Transact { + origin_kind: OriginKind::Native, + require_weight_at_most: MAX_WEIGHT, + call: accept_channel_relay_call.into(), + }, + Transact { + origin_kind: OriginKind::Native, + require_weight_at_most: MAX_WEIGHT, + call: request_channel_relay_call.into(), + }, + RefundSurplus, + DepositAsset { + assets: Wild(All), + beneficiary: MultiLocation { parents: 0, interior: X1(Parachain(POLIMEC_PARA_ID)) }, + }, + ]); + let mut message = Some(xcm); + + let dest_loc = MultiLocation { parents: 1, interior: Here }; + let mut destination = Some(dest_loc); + let (ticket, _price) = T::XcmRouter::validate(&mut destination, &mut message)?; + + match T::XcmRouter::deliver(ticket) { + Ok(_) => { + log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest: acceptance successfully sent"); + project_details.comm_status.project_to_polimec = ChannelStatus::Open; + project_details.comm_status.polimec_to_project = ChannelStatus::AwaitingAcceptance; + ProjectsDetails::::insert(project_id, project_details); + + Pallet::::deposit_event(Event::::HrmpChannelAccepted { + project_id, + para_id: ParaId::from(sender), + }); + Ok(()) + }, + Err(e) => { + log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest: acceptance sending failed - {:?}", e); + Err(XcmError::Unimplemented) + }, + } + }, instr @ _ => { log::trace!(target: "pallet_funding::hrmp", "Bad instruction: {:?}", instr); Err(XcmError::Unimplemented) @@ -1899,7 +1899,7 @@ impl Pallet { &(T::PalletId::get().into_account_truncating()), project_id, ) - .map_err(|_| XcmError::NoDeal)?; + .map_err(|_| XcmError::NoDeal)?; Ok(()) }, instr @ _ => { @@ -1914,7 +1914,7 @@ impl Pallet { project_id: T::ProjectIdentifier, ) -> DispatchResult { // * Get variables * - let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectInfoNotFound)?; + let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; let parachain_id: u32 = project_details.parachain_id.ok_or(Error::::ImpossibleState)?.into(); let project_multilocation = ParentThen(X1(Parachain(parachain_id))); @@ -1937,7 +1937,14 @@ impl Pallet { ); if project_details.migration_readiness_check.is_none() { ensure!(caller.clone() == T::PalletId::get().into_account_truncating(), Error::::NotAllowed); - } else if project_details.migration_readiness_check == Some(MigrationReadinessCheck::CheckFailed) { + } else if matches!( + project_details.migration_readiness_check, + Some(MigrationReadinessCheck { + holding_check: (_, CheckOutcome::Failed), + pallet_check: (_, CheckOutcome::Failed), + .. + }) + ) { ensure!(caller == &project_details.issuer, Error::::NotAllowed); } @@ -1945,14 +1952,23 @@ impl Pallet { let call: ::RuntimeCall = Call::migration_check_response { query_id: Default::default(), response: Default::default() }.into(); - let query_id = pallet_xcm::Pallet::::new_notify_query( + let query_id_holdings = pallet_xcm::Pallet::::new_notify_query( + project_multilocation.clone(), + call.clone().into(), + now + 20u32.into(), + Here, + ); + let query_id_pallet = pallet_xcm::Pallet::::new_notify_query( project_multilocation.clone(), call.into(), now + 20u32.into(), Here, ); - project_details.migration_readiness_check = Some(MigrationReadinessCheck::QuerySent(query_id)); + project_details.migration_readiness_check = Some(MigrationReadinessCheck { + holding_check: (query_id_holdings, CheckOutcome::AwaitingResponse), + pallet_check: (query_id_pallet, CheckOutcome::AwaitingResponse), + }); ProjectsDetails::::insert(project_id, project_details); // * Send the migration query * @@ -1969,6 +1985,14 @@ impl Pallet { }, assets: Wild(All), }, + QueryPallet { + module_name: Vec::from("polimec_receiver"), + response_info: QueryResponseInfo { + destination: ParentThen(Parachain(3355).into()).into(), + query_id: 1, + max_weight: max_weight.clone(), + }, + }, DepositAsset { assets: Wild(All), beneficiary: ParentThen(Parachain(3355).into()).into() }, ]); >::send_xcm(Here, project_multilocation, xcm).map_err(|_| Error::::XcmFailed)?; @@ -1984,46 +2008,93 @@ impl Pallet { response: xcm::v3::Response, ) -> DispatchResult { // * Get variables * + use xcm::v3::prelude::*; // TODO: check if this is too low performance. Maybe we want a new map of query_id -> project_id - // let (project_id, project_details) = ProjectsDetails::::iter() - // .find(|(_, details)| { - // if let Some(MigrationReadinessCheck::QuerySent(id)) = details.migration_readiness_check { - // id == query_id - // } else { - // false - // } - // }) - // .ok_or(Error::::NotAllowed)?; - // - // let para_id = if let MultiLocation { parents: 1, interior: X1(Parachain(para_id)) } = location { - // ParaId::from(para_id) - // } else { - // return Err(Error::::NotAllowed.into()) - // }; - // - // let _tokens_held = match response { - // xcm::v3::Response::Assets(_) => 10, - // _ => return Err(Error::::NotAllowed.into()), - // }; - // - // let _project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; - // // let contribution_tokens_sold = project_metadata.total_allocation_size - project_details.remaining_contribution_tokens; - // - // // * Validity checks * - // ensure!(project_details.parachain_id == Some(para_id), Error::::NotAllowed); + let (project_id, mut project_details, mut migration_check) = ProjectsDetails::::iter() + .find_map(|(project_id, details)| { + if let Some(check @ MigrationReadinessCheck { holding_check, pallet_check }) = details.migration_readiness_check { + if holding_check.0 == query_id || pallet_check.0 == query_id { + return Some((project_id, details, check.clone())) + } + } + None + }) + .ok_or(Error::::NotAllowed)?; + + let para_id = if let MultiLocation { parents: 1, interior: X1(Parachain(para_id)) } = location { + ParaId::from(para_id) + } else { + return Err(Error::::NotAllowed.into()) + }; + + let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; + let contribution_tokens_sold = project_metadata + .total_allocation_size + .0 + .saturating_add(project_metadata.total_allocation_size.1) + .saturating_sub(project_details.remaining_contribution_tokens.0) + .saturating_sub(project_details.remaining_contribution_tokens.1); + + // * Validity checks * + ensure!(project_details.parachain_id == Some(para_id), Error::::NotAllowed); // * Update storage * + match (response.clone(), migration_check) { + ( + Response::Assets(assets), + MigrationReadinessCheck { holding_check: (_, CheckOutcome::AwaitingResponse), .. }, + ) => { + let ct_sold_as_u128: u128 = contribution_tokens_sold.try_into().map_err(|_| Error::::BadMath)?; + let expected_id = Concrete(MultiLocation { parents: 1, interior: X1(Parachain(para_id.into())) }); + let assets: Vec = assets.into_inner(); + let asset_1 = assets[0].clone(); + + match asset_1 { + MultiAsset { id: expected_id, fun: Fungible(amount) } if amount >= ct_sold_as_u128 => { + migration_check.holding_check.1 = CheckOutcome::Passed; + Self::deposit_event(Event::::MigrationCheckResponseAccepted { query_id, response }); + }, + _ => { + migration_check.holding_check.1 = CheckOutcome::Failed; + Self::deposit_event(Event::::MigrationCheckResponseRejected { query_id, response }); + } + } + }, - // * Emit events * - Self::deposit_event(Event::::MigrationResponseReceived { query_id, response }); + ( + Response::PalletsInfo(pallets_info), + MigrationReadinessCheck { pallet_check: (_, CheckOutcome::AwaitingResponse), .. }, + ) => + if pallets_info.len() == 1 && pallets_info[0] == T::PolimecReceiverInfo::get() { + migration_check.pallet_check.1 = CheckOutcome::Passed; + Self::deposit_event(Event::::MigrationCheckResponseAccepted { query_id, response }); + } else { + migration_check.pallet_check.1 = CheckOutcome::Failed; + Self::deposit_event(Event::::MigrationCheckResponseRejected { query_id, response }); + }, + _ => return Err(Error::::NotAllowed.into()), + }; + + project_details.migration_readiness_check = Some(migration_check); + ProjectsDetails::::insert(project_id, project_details); Ok(()) } - pub fn finish_migration_readiness_check( - _caller: ParaId, - _project_id: T::ProjectIdentifier, - _check_bytes: Vec, - ) -> DispatchResult { + pub fn do_migration(caller: AccountIdOf, project_id: T::ProjectIdentifier) -> DispatchResult { + // * Get variables * + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; + let migration_readiness_check = project_details.migration_readiness_check.ok_or(Error::::NotAllowed)?; + + // * Validity Checks * + ensure!(caller == project_details.issuer, Error::::NotAllowed); + ensure!(migration_readiness_check.is_ready(), Error::::NotAllowed); + + // * Update storage * + + + // * Emit events * + Self::deposit_event(Event::::MigrationStarted { project_id }); + Ok(()) } } diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index e492a37ed..d5fa1763e 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -283,7 +283,7 @@ pub mod pallet { type RuntimeOrigin: IsType<::RuntimeOrigin> + Into::RuntimeOrigin>>; - type RuntimeCall: IsType<::RuntimeCall> + From>; + type RuntimeCall: Parameter + IsType<::RuntimeCall> + From>; /// Global identifier for the projects. type ProjectIdentifier: Parameter + Copy + Default + One + Saturating + From + Ord + MaxEncodedLen; @@ -414,6 +414,8 @@ pub mod pallet { type DaysToBlocks: Convert>; type BlockNumberToBalance: Convert, BalanceOf>; + + type PolimecReceiverInfo: Get; } #[pallet::storage] @@ -770,10 +772,17 @@ pub mod pallet { project_id: T::ProjectIdentifier, caller: T::AccountId, }, - MigrationResponseReceived { + MigrationCheckResponseAccepted { + query_id: xcm::v3::QueryId, + response: xcm::v3::Response, + }, + MigrationCheckResponseRejected { query_id: xcm::v3::QueryId, response: xcm::v3::Response, }, + MigrationStarted { + project_id: T::ProjectIdentifier, + }, } #[pallet::error] @@ -836,8 +845,8 @@ pub mod pallet { TooEarlyForFundingEnd, /// Checks for other projects not copying metadata of others MetadataAlreadyExists, - /// The specified project info does not exist - ProjectInfoNotFound, + /// The specified project details does not exist + ProjectDetailsNotFound, /// Tried to finish an evaluation before its target end block EvaluationPeriodNotEnded, /// Tried to access field that is not set diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index a11062720..44b65cb05 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -85,29 +85,23 @@ pub const fn free_deposit() -> Balance { 0 * MICRO_PLMC } - - //region DRAFT ZONE -use xcm_builder::{EnsureXcmOrigin, FixedWeightBounds, SignedToAccountId32, ParentIsPreset, SiblingParachainConvertsVia, AccountId32Aliases}; +use frame_support::traits::{Everything, OriginTrait}; +use frame_system::RawOrigin as SystemRawOrigin; use polkadot_parachain::primitives::Sibling; -use frame_support::traits::Everything; -use xcm_executor::traits::Convert; -use frame_support::traits::OriginTrait; use sp_runtime::traits::Get; -use frame_system::RawOrigin as SystemRawOrigin; - +use xcm_builder::{ + AccountId32Aliases, EnsureXcmOrigin, FixedWeightBounds, ParentIsPreset, SiblingParachainConvertsVia, + SignedToAccountId32, +}; +use xcm_executor::traits::Convert; -pub struct SignedToAccountIndex( - PhantomData<(RuntimeOrigin, AccountId, Network)>, -); -impl< - RuntimeOrigin: OriginTrait + Clone, - AccountId: Into, - Network: Get>, -> Convert for SignedToAccountIndex - where - RuntimeOrigin::PalletsOrigin: From> - + TryInto, Error = RuntimeOrigin::PalletsOrigin>, +pub struct SignedToAccountIndex(PhantomData<(RuntimeOrigin, AccountId, Network)>); +impl, Network: Get>> + Convert for SignedToAccountIndex +where + RuntimeOrigin::PalletsOrigin: + From> + TryInto, Error = RuntimeOrigin::PalletsOrigin>, { fn convert(o: RuntimeOrigin) -> Result { o.try_with_caller(|caller| match caller.try_into() { @@ -332,43 +326,43 @@ impl pallet_linear_release::Config for TestRuntime { impl Config for TestRuntime { type AllPalletsWithoutSystem = AllPalletsWithoutSystem; - type RuntimeEvent = RuntimeEvent; - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - type ProjectIdentifier = Identifier; - type Multiplier = Multiplier; - type Balance = Balance; - type Price = FixedU128; - type NativeCurrency = Balances; - type FundingCurrency = StatemintAssets; - type ContributionTokenCurrency = LocalAssets; - type PriceProvider = ConstPriceProvider; - type Randomness = RandomnessCollectiveFlip; - type StringLimit = ConstU32<64>; - type PreImageLimit = ConstU32<1024>; - type EvaluationDuration = EvaluationDuration; type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; - type EnglishAuctionDuration = EnglishAuctionDuration; + type Balance = Balance; + type BlockNumberToBalance = ConvertInto; type CandleAuctionDuration = CandleAuctionDuration; type CommunityFundingDuration = CommunityRoundDuration; - type RemainderFundingDuration = RemainderFundingDuration; - type PalletId = FundingPalletId; - type MaxProjectsToUpdatePerBlock = ConstU32<100>; - type MaxEvaluationsPerUser = ConstU32<4>; - // Low value to simplify the tests - type MaxBidsPerUser = ConstU32<4>; - type MaxContributionsPerUser = ConstU32<4>; + type ContributionTokenCurrency = LocalAssets; type ContributionVesting = ConstU32<4>; - type WeightInfo = weights::SubstrateWeight; - type FeeBrackets = FeeBrackets; + type DaysToBlocks = DaysToBlocks; + type EnglishAuctionDuration = EnglishAuctionDuration; + type EvaluationDuration = EvaluationDuration; type EvaluationSuccessThreshold = EarlyEvaluationThreshold; - type Vesting = Vesting; + type EvaluatorSlash = EvaluatorSlash; + type FeeBrackets = FeeBrackets; + type FundingCurrency = StatemintAssets; type ManualAcceptanceDuration = ManualAcceptanceDuration; + // Low value to simplify the tests + type MaxBidsPerUser = ConstU32<4>; + type MaxContributionsPerUser = ConstU32<4>; + type MaxEvaluationsPerUser = ConstU32<4>; + type MaxProjectsToUpdatePerBlock = ConstU32<100>; + type Multiplier = Multiplier; + type NativeCurrency = Balances; + type PalletId = FundingPalletId; + type PreImageLimit = ConstU32<1024>; + type Price = FixedU128; + type PriceProvider = ConstPriceProvider; + type ProjectIdentifier = Identifier; + type Randomness = RandomnessCollectiveFlip; + type RemainderFundingDuration = RemainderFundingDuration; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type StringLimit = ConstU32<64>; type SuccessToSettlementTime = SuccessToSettlementTime; - type EvaluatorSlash = EvaluatorSlash; type TreasuryAccount = TreasuryAccount; - type DaysToBlocks = DaysToBlocks; - type BlockNumberToBalance = ConvertInto; + type Vesting = Vesting; + type WeightInfo = weights::SubstrateWeight; } // Build genesis storage according to the mock runtime. diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index 1bb2553b0..a2612bdcd 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -677,10 +677,22 @@ pub mod inner_types { } #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] - pub enum MigrationReadinessCheck { - QuerySent(xcm::v3::QueryId), - CheckPassed, - CheckFailed, + pub struct MigrationReadinessCheck { + pub holding_check: (xcm::v3::QueryId, CheckOutcome), + pub pallet_check: (xcm::v3::QueryId, CheckOutcome), + } + + impl MigrationReadinessCheck { + pub fn is_ready(&self) -> bool { + self.holding_check.1 == CheckOutcome::Passed && self.pallet_check.1 == CheckOutcome::Passed + } + } + + #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] + pub enum CheckOutcome { + AwaitingResponse, + Passed, + Failed, } #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index f37706d61..e0c69c939 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -491,6 +491,9 @@ impl pallet_assets::Config for Runtime { parameter_types! { pub TreasuryAccount: AccountId = [69u8; 32].into(); + pub PolimecReceiverInfo: xcm::v3::PalletInfo = xcm::v3::PalletInfo::new( + 51, "PolimecReceiver".into(), "polimec_receiver".into(), 0, 1, 0 + ).unwrap(); } impl pallet_funding::Config for Runtime { type AllPalletsWithoutSystem = (Balances, LocalAssets, StatemintAssets, PolimecFunding, LinearVesting, Random); @@ -516,6 +519,7 @@ impl pallet_funding::Config for Runtime { type Multiplier = pallet_funding::types::Multiplier; type NativeCurrency = Balances; type PalletId = FundingPalletId; + type PolimecReceiverInfo = PolimecReceiverInfo; type PreImageLimit = ConstU32<1024>; type Price = FixedU128; type PriceProvider = pallet_funding::types::ConstPriceProvider; @@ -577,6 +581,7 @@ impl pallet_parachain_staking::Config for Runtime { } // Create the runtime by composing the FRAME pallets that were previously configured. + construct_runtime!( pub enum Runtime where Block = Block, From 3782ac6bc95283f616f09a9bc5f2c16e7f2cc18a Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 8 Nov 2023 17:09:51 +0100 Subject: [PATCH 011/212] fixes --- Cargo.lock | 15039 ------------------- integration-tests/src/tests/basic_comms.rs | 1 + pallets/funding/src/functions.rs | 12 +- pallets/funding/src/instantiator.rs | 4 +- pallets/funding/src/mock.rs | 4 + pallets/funding/src/types.rs | 34 +- 6 files changed, 32 insertions(+), 15062 deletions(-) delete mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock deleted file mode 100644 index fbd63b409..000000000 --- a/Cargo.lock +++ /dev/null @@ -1,15039 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "Inflector" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" -dependencies = [ - "lazy_static", - "regex", -] - -[[package]] -name = "addr2line" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" -dependencies = [ - "gimli 0.27.3", -] - -[[package]] -name = "addr2line" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" -dependencies = [ - "gimli 0.28.0", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "aead" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" -dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "aead" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" -dependencies = [ - "generic-array 0.14.7", - "rand_core 0.6.4", -] - -[[package]] -name = "aead" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" -dependencies = [ - "crypto-common", - "generic-array 0.14.7", -] - -[[package]] -name = "aes" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" -dependencies = [ - "aes-soft", - "aesni", - "cipher 0.2.5", -] - -[[package]] -name = "aes" -version = "0.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" -dependencies = [ - "cfg-if", - "cipher 0.3.0", - "cpufeatures", - "opaque-debug 0.3.0", -] - -[[package]] -name = "aes" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" -dependencies = [ - "cfg-if", - "cipher 0.4.4", - "cpufeatures", -] - -[[package]] -name = "aes-gcm" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6" -dependencies = [ - "aead 0.4.3", - "aes 0.7.5", - "cipher 0.3.0", - "ctr 0.8.0", - "ghash 0.4.4", - "subtle", -] - -[[package]] -name = "aes-gcm" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" -dependencies = [ - "aead 0.5.2", - "aes 0.8.3", - "cipher 0.4.4", - "ctr 0.9.2", - "ghash 0.5.0", - "subtle", -] - -[[package]] -name = "aes-soft" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" -dependencies = [ - "cipher 0.2.5", - "opaque-debug 0.3.0", -] - -[[package]] -name = "aesni" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" -dependencies = [ - "cipher 0.2.5", - "opaque-debug 0.3.0", -] - -[[package]] -name = "ahash" -version = "0.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" -dependencies = [ - "getrandom 0.2.10", - "once_cell", - "version_check", -] - -[[package]] -name = "ahash" -version = "0.8.3" -source = "git+https://github.com/tkaitchuck/aHash?tag=v0.8.3#f9acd508bd89e7c5b2877a9510098100f9018d64" -dependencies = [ - "cfg-if", - "getrandom 0.2.10", - "once_cell", - "version_check", -] - -[[package]] -name = "aho-corasick" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" -dependencies = [ - "memchr", -] - -[[package]] -name = "always-assert" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4436e0292ab1bb631b42973c61205e704475fe8126af845c8d923c0996328127" - -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - -[[package]] -name = "anes" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" - -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - -[[package]] -name = "anstream" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" - -[[package]] -name = "anstyle-parse" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" -dependencies = [ - "windows-sys 0.48.0", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" -dependencies = [ - "anstyle", - "windows-sys 0.48.0", -] - -[[package]] -name = "anyhow" -version = "1.0.75" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" - -[[package]] -name = "approx" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" -dependencies = [ - "num-traits", -] - -[[package]] -name = "arc-swap" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" - -[[package]] -name = "array-bytes" -version = "4.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f52f63c5c1316a16a4b35eaac8b76a98248961a533f061684cb2a7cb0eafb6c6" - -[[package]] -name = "array-bytes" -version = "6.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b1c5a481ec30a5abd8dfbd94ab5cf1bb4e9a66be7f1b3b322f2f1170c200fd" - -[[package]] -name = "arrayref" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" - -[[package]] -name = "arrayvec" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" - -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - -[[package]] -name = "asn1-rs" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ff05a702273012438132f449575dbc804e27b2f3cbe3069aa237d26c98fa33" -dependencies = [ - "asn1-rs-derive 0.1.0", - "asn1-rs-impl", - "displaydoc", - "nom", - "num-traits", - "rusticata-macros", - "thiserror", - "time", -] - -[[package]] -name = "asn1-rs" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6fd5ddaf0351dff5b8da21b2fb4ff8e08ddd02857f0bf69c47639106c0fff0" -dependencies = [ - "asn1-rs-derive 0.4.0", - "asn1-rs-impl", - "displaydoc", - "nom", - "num-traits", - "rusticata-macros", - "thiserror", - "time", -] - -[[package]] -name = "asn1-rs-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8b7511298d5b7784b40b092d9e9dcd3a627a5707e4b5e507931ab0d44eeebf" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "asn1-rs-derive" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "726535892e8eae7e70657b4c8ea93d26b8553afb1ce617caee529ef96d7dee6c" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "asn1-rs-impl" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2777730b2039ac0f95f093556e61b6d26cebed5393ca6f152717777cec3a42ed" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "assert_matches" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" - -[[package]] -name = "assert_matches2" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6578e995f418897bfdebc40d6c873e5ce91effd67963c7991c2fb96779e53c18" - -[[package]] -name = "assets-common" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "cumulus-primitives-core", - "frame-support", - "log", - "pallet-xcm", - "parachains-common", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-std", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "async-channel" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" -dependencies = [ - "concurrent-queue", - "event-listener", - "futures-core", -] - -[[package]] -name = "async-io" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" -dependencies = [ - "async-lock", - "autocfg", - "cfg-if", - "concurrent-queue", - "futures-lite", - "log", - "parking", - "polling", - "rustix 0.37.27", - "slab", - "socket2 0.4.10", - "waker-fn", -] - -[[package]] -name = "async-lock" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" -dependencies = [ - "event-listener", -] - -[[package]] -name = "async-recursion" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "async-trait" -version = "0.1.74" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "asynchronous-codec" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4057f2c32adbb2fc158e22fb38433c8e9bbf76b75a4732c7c0cbaf695fb65568" -dependencies = [ - "bytes", - "futures-sink", - "futures-util", - "memchr", - "pin-project-lite 0.2.13", -] - -[[package]] -name = "atomic-waker" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" - -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "backtrace" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" -dependencies = [ - "addr2line 0.21.0", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object 0.32.1", - "rustc-demangle", -] - -[[package]] -name = "base-x" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" - -[[package]] -name = "base16ct" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" - -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - -[[package]] -name = "base64" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" - -[[package]] -name = "base64" -version = "0.21.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" - -[[package]] -name = "base64ct" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" - -[[package]] -name = "beef" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" -dependencies = [ - "serde", -] - -[[package]] -name = "binary-merkle-tree" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "hash-db", - "log", -] - -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - -[[package]] -name = "bindgen" -version = "0.65.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5" -dependencies = [ - "bitflags 1.3.2", - "cexpr", - "clang-sys", - "lazy_static", - "lazycell", - "peeking_take_while", - "prettyplease 0.2.15", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "syn 2.0.38", -] - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "bitflags" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" - -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] - -[[package]] -name = "blake2" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "blake2b_simd" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23285ad32269793932e830392f2fe2f83e26488fd3ec778883a93c8323735780" -dependencies = [ - "arrayref", - "arrayvec 0.7.4", - "constant_time_eq", -] - -[[package]] -name = "blake2s_simd" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94230421e395b9920d23df13ea5d77a20e1725331f90fbbf6df6040b33f756ae" -dependencies = [ - "arrayref", - "arrayvec 0.7.4", - "constant_time_eq", -] - -[[package]] -name = "blake3" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0231f06152bf547e9c2b5194f247cd97aacf6dcd8b15d8e5ec0663f64580da87" -dependencies = [ - "arrayref", - "arrayvec 0.7.4", - "cc", - "cfg-if", - "constant_time_eq", -] - -[[package]] -name = "block-buffer" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" -dependencies = [ - "block-padding 0.1.5", - "byte-tools", - "byteorder", - "generic-array 0.12.4", -] - -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "block-modes" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a0e8073e8baa88212fb5823574c02ebccb395136ba9a164ab89379ec6072f0" -dependencies = [ - "block-padding 0.2.1", - "cipher 0.2.5", -] - -[[package]] -name = "block-padding" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" -dependencies = [ - "byte-tools", -] - -[[package]] -name = "block-padding" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" - -[[package]] -name = "bounded-collections" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca548b6163b872067dc5eb82fd130c56881435e30367d2073594a3d9744120dd" -dependencies = [ - "log", - "parity-scale-codec", - "scale-info", - "serde", -] - -[[package]] -name = "bounded-vec" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68534a48cbf63a4b1323c433cf21238c9ec23711e0df13b08c33e5c2082663ce" -dependencies = [ - "thiserror", -] - -[[package]] -name = "bs58" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" - -[[package]] -name = "bstr" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" -dependencies = [ - "lazy_static", - "memchr", - "regex-automata 0.1.10", -] - -[[package]] -name = "bstr" -version = "1.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c79ad7fb2dd38f3dabd76b09c6a5a20c038fc0213ef1e9afd30eb777f120f019" -dependencies = [ - "memchr", - "serde", -] - -[[package]] -name = "build-helper" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdce191bf3fa4995ce948c8c83b4640a1745457a149e73c6db75b4ffe36aad5f" -dependencies = [ - "semver 0.6.0", -] - -[[package]] -name = "bumpalo" -version = "3.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" - -[[package]] -name = "byte-slice-cast" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" - -[[package]] -name = "byte-tools" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" - -[[package]] -name = "bytemuck" -version = "1.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "bytes" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" - -[[package]] -name = "bzip2-sys" -version = "0.1.11+1.0.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" -dependencies = [ - "cc", - "libc", - "pkg-config", -] - -[[package]] -name = "camino" -version = "1.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo-platform" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12024c4645c97566567129c204f65d5815a8c9aecf30fcbe682b2fe034996d36" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo_metadata" -version = "0.15.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" -dependencies = [ - "camino", - "cargo-platform", - "semver 1.0.20", - "serde", - "serde_json", - "thiserror", -] - -[[package]] -name = "casey" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614586263949597dcc18675da12ef9b429135e13628d92eb8b8c6fa50ca5656b" -dependencies = [ - "syn 1.0.109", -] - -[[package]] -name = "cast" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" - -[[package]] -name = "cc" -version = "1.0.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" -dependencies = [ - "jobserver", - "libc", -] - -[[package]] -name = "ccm" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aca1a8fbc20b50ac9673ff014abfb2b5f4085ee1a850d408f14a159c5853ac7" -dependencies = [ - "aead 0.3.2", - "cipher 0.2.5", - "subtle", -] - -[[package]] -name = "cexpr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" -dependencies = [ - "nom", -] - -[[package]] -name = "cfg-expr" -version = "0.15.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03915af431787e6ffdcc74c645077518c6b6e01f80b761e0fbbfa288536311b3" -dependencies = [ - "smallvec", -] - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "cfg_aliases" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" - -[[package]] -name = "chacha20" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" -dependencies = [ - "cfg-if", - "cipher 0.3.0", - "cpufeatures", - "zeroize", -] - -[[package]] -name = "chacha20poly1305" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" -dependencies = [ - "aead 0.4.3", - "chacha20", - "cipher 0.3.0", - "poly1305", - "zeroize", -] - -[[package]] -name = "chrono" -version = "0.4.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" -dependencies = [ - "android-tzdata", - "iana-time-zone", - "js-sys", - "num-traits", - "wasm-bindgen", - "windows-targets 0.48.5", -] - -[[package]] -name = "ciborium" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" -dependencies = [ - "ciborium-io", - "ciborium-ll", - "serde", -] - -[[package]] -name = "ciborium-io" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" - -[[package]] -name = "ciborium-ll" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" -dependencies = [ - "ciborium-io", - "half", -] - -[[package]] -name = "cid" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ed9c8b2d17acb8110c46f1da5bf4a696d745e1474a16db0cd2b49cd0249bf2" -dependencies = [ - "core2", - "multibase", - "multihash 0.16.3", - "serde", - "unsigned-varint", -] - -[[package]] -name = "cipher" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" -dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "cipher" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" -dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "cipher" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" -dependencies = [ - "crypto-common", - "inout", -] - -[[package]] -name = "ckb-merkle-mountain-range" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56ccb671c5921be8a84686e6212ca184cb1d7c51cadcdbfcbd1cc3f042f5dfb8" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "clang-sys" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" -dependencies = [ - "glob", - "libc", - "libloading", -] - -[[package]] -name = "clap" -version = "4.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" -dependencies = [ - "clap_builder", - "clap_derive", -] - -[[package]] -name = "clap_builder" -version = "4.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" -dependencies = [ - "anstream", - "anstyle", - "clap_lex", - "strsim", -] - -[[package]] -name = "clap_derive" -version = "4.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "clap_lex" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" - -[[package]] -name = "coarsetime" -version = "0.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a73ef0d00d14301df35d0f13f5ea32344de6b00837485c358458f1e7f2d27db4" -dependencies = [ - "libc", - "once_cell", - "wasi 0.11.0+wasi-snapshot-preview1", - "wasm-bindgen", -] - -[[package]] -name = "codespan-reporting" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" -dependencies = [ - "termcolor", - "unicode-width", -] - -[[package]] -name = "color-print" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a858372ff14bab9b1b30ea504f2a4bc534582aee3e42ba2d41d2a7baba63d5d" -dependencies = [ - "color-print-proc-macro", -] - -[[package]] -name = "color-print-proc-macro" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57e37866456a721d0a404439a1adae37a31be4e0055590d053dfe6981e05003f" -dependencies = [ - "nom", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "colorchoice" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" - -[[package]] -name = "comfy-table" -version = "6.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e959d788268e3bf9d35ace83e81b124190378e4c91c9067524675e33394b8ba" -dependencies = [ - "strum", - "strum_macros", - "unicode-width", -] - -[[package]] -name = "concurrent-queue" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "console" -version = "0.15.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" -dependencies = [ - "encode_unicode", - "lazy_static", - "libc", - "unicode-width", - "windows-sys 0.45.0", -] - -[[package]] -name = "const-oid" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" - -[[package]] -name = "constant_time_eq" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "core-foundation" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" - -[[package]] -name = "core2" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" -dependencies = [ - "memchr", -] - -[[package]] -name = "cpp_demangle" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "cpu-time" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9e393a7668fe1fad3075085b86c781883000b4ede868f43627b34a87c8b7ded" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "cpufeatures" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" -dependencies = [ - "libc", -] - -[[package]] -name = "cranelift-bforest" -version = "0.95.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1277fbfa94bc82c8ec4af2ded3e639d49ca5f7f3c7eeab2c66accd135ece4e70" -dependencies = [ - "cranelift-entity", -] - -[[package]] -name = "cranelift-codegen" -version = "0.95.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6e8c31ad3b2270e9aeec38723888fe1b0ace3bea2b06b3f749ccf46661d3220" -dependencies = [ - "bumpalo", - "cranelift-bforest", - "cranelift-codegen-meta", - "cranelift-codegen-shared", - "cranelift-entity", - "cranelift-isle", - "gimli 0.27.3", - "hashbrown 0.13.2", - "log", - "regalloc2", - "smallvec", - "target-lexicon", -] - -[[package]] -name = "cranelift-codegen-meta" -version = "0.95.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ac5ac30d62b2d66f12651f6b606dbdfd9c2cfd0908de6b387560a277c5c9da" -dependencies = [ - "cranelift-codegen-shared", -] - -[[package]] -name = "cranelift-codegen-shared" -version = "0.95.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd82b8b376247834b59ed9bdc0ddeb50f517452827d4a11bccf5937b213748b8" - -[[package]] -name = "cranelift-entity" -version = "0.95.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40099d38061b37e505e63f89bab52199037a72b931ad4868d9089ff7268660b0" -dependencies = [ - "serde", -] - -[[package]] -name = "cranelift-frontend" -version = "0.95.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a25d9d0a0ae3079c463c34115ec59507b4707175454f0eee0891e83e30e82d" -dependencies = [ - "cranelift-codegen", - "log", - "smallvec", - "target-lexicon", -] - -[[package]] -name = "cranelift-isle" -version = "0.95.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80de6a7d0486e4acbd5f9f87ec49912bf4c8fb6aea00087b989685460d4469ba" - -[[package]] -name = "cranelift-native" -version = "0.95.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6b03e0e03801c4b3fd8ce0758a94750c07a44e7944cc0ffbf0d3f2e7c79b00" -dependencies = [ - "cranelift-codegen", - "libc", - "target-lexicon", -] - -[[package]] -name = "cranelift-wasm" -version = "0.95.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff3220489a3d928ad91e59dd7aeaa8b3de18afb554a6211213673a71c90737ac" -dependencies = [ - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", - "itertools 0.10.5", - "log", - "smallvec", - "wasmparser", - "wasmtime-types", -] - -[[package]] -name = "crc" -version = "3.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" -dependencies = [ - "crc-catalog", -] - -[[package]] -name = "crc-catalog" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" - -[[package]] -name = "crc32fast" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "criterion" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" -dependencies = [ - "anes", - "cast", - "ciborium", - "clap", - "criterion-plot", - "futures", - "is-terminal", - "itertools 0.10.5", - "num-traits", - "once_cell", - "oorandom", - "plotters", - "rayon", - "regex", - "serde", - "serde_derive", - "serde_json", - "tinytemplate", - "tokio", - "walkdir", -] - -[[package]] -name = "criterion-plot" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" -dependencies = [ - "cast", - "itertools 0.10.5", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" -dependencies = [ - "cfg-if", - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" -dependencies = [ - "autocfg", - "cfg-if", - "crossbeam-utils", - "memoffset 0.9.0", - "scopeguard", -] - -[[package]] -name = "crossbeam-queue" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" -dependencies = [ - "cfg-if", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crunchy" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" - -[[package]] -name = "crypto-bigint" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" -dependencies = [ - "generic-array 0.14.7", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-bigint" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" -dependencies = [ - "generic-array 0.14.7", - "rand_core 0.6.4", - "subtle", - "zeroize", -] - -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array 0.14.7", - "rand_core 0.6.4", - "typenum", -] - -[[package]] -name = "crypto-mac" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" -dependencies = [ - "generic-array 0.14.7", - "subtle", -] - -[[package]] -name = "crypto-mac" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" -dependencies = [ - "generic-array 0.14.7", - "subtle", -] - -[[package]] -name = "ctr" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" -dependencies = [ - "cipher 0.3.0", -] - -[[package]] -name = "ctr" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" -dependencies = [ - "cipher 0.4.4", -] - -[[package]] -name = "cumulus-client-cli" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "clap", - "parity-scale-codec", - "sc-chain-spec", - "sc-cli", - "sc-service", - "sp-core", - "sp-runtime", - "url", -] - -[[package]] -name = "cumulus-client-collator" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "cumulus-client-consensus-common", - "cumulus-client-network", - "cumulus-primitives-core", - "futures", - "parity-scale-codec", - "parking_lot 0.12.1", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-overseer", - "polkadot-primitives", - "sc-client-api", - "sp-api", - "sp-consensus", - "sp-core", - "sp-runtime", - "tracing", -] - -[[package]] -name = "cumulus-client-consensus-aura" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "async-trait", - "cumulus-client-collator", - "cumulus-client-consensus-common", - "cumulus-client-consensus-proposer", - "cumulus-primitives-core", - "cumulus-primitives-parachain-inherent", - "cumulus-relay-chain-interface", - "futures", - "parity-scale-codec", - "polkadot-node-primitives", - "polkadot-overseer", - "polkadot-primitives", - "sc-client-api", - "sc-consensus", - "sc-consensus-aura", - "sc-consensus-slots", - "sc-telemetry", - "sp-api", - "sp-application-crypto", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-consensus-aura", - "sp-core", - "sp-inherents", - "sp-keystore", - "sp-runtime", - "sp-state-machine", - "sp-timestamp", - "substrate-prometheus-endpoint", - "tracing", -] - -[[package]] -name = "cumulus-client-consensus-common" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "async-trait", - "cumulus-client-pov-recovery", - "cumulus-primitives-core", - "cumulus-relay-chain-interface", - "dyn-clone", - "futures", - "log", - "parity-scale-codec", - "polkadot-primitives", - "sc-client-api", - "sc-consensus", - "schnellru", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-runtime", - "sp-trie", - "substrate-prometheus-endpoint", - "tracing", -] - -[[package]] -name = "cumulus-client-consensus-proposer" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "anyhow", - "async-trait", - "cumulus-primitives-parachain-inherent", - "sp-consensus", - "sp-inherents", - "sp-runtime", - "sp-state-machine", - "thiserror", -] - -[[package]] -name = "cumulus-client-consensus-relay-chain" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "async-trait", - "cumulus-client-consensus-common", - "cumulus-primitives-core", - "cumulus-relay-chain-interface", - "futures", - "parking_lot 0.12.1", - "sc-consensus", - "sp-api", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-inherents", - "sp-runtime", - "substrate-prometheus-endpoint", - "tracing", -] - -[[package]] -name = "cumulus-client-network" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "async-trait", - "cumulus-relay-chain-interface", - "futures", - "futures-timer", - "parity-scale-codec", - "parking_lot 0.12.1", - "polkadot-node-primitives", - "polkadot-parachain", - "polkadot-primitives", - "sc-client-api", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-runtime", - "sp-state-machine", - "tracing", -] - -[[package]] -name = "cumulus-client-pov-recovery" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "async-trait", - "cumulus-primitives-core", - "cumulus-relay-chain-interface", - "futures", - "futures-timer", - "parity-scale-codec", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-overseer", - "polkadot-primitives", - "rand 0.8.5", - "sc-client-api", - "sc-consensus", - "sp-consensus", - "sp-maybe-compressed-blob", - "sp-runtime", - "tracing", -] - -[[package]] -name = "cumulus-client-service" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "cumulus-client-cli", - "cumulus-client-collator", - "cumulus-client-consensus-common", - "cumulus-client-network", - "cumulus-client-pov-recovery", - "cumulus-primitives-core", - "cumulus-relay-chain-inprocess-interface", - "cumulus-relay-chain-interface", - "cumulus-relay-chain-minimal-node", - "futures", - "polkadot-primitives", - "sc-client-api", - "sc-consensus", - "sc-network", - "sc-network-sync", - "sc-network-transactions", - "sc-rpc", - "sc-service", - "sc-sysinfo", - "sc-telemetry", - "sc-transaction-pool", - "sc-utils", - "sp-api", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-runtime", - "sp-transaction-pool", -] - -[[package]] -name = "cumulus-pallet-aura-ext" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "frame-support", - "frame-system", - "pallet-aura", - "parity-scale-codec", - "scale-info", - "sp-application-crypto", - "sp-consensus-aura", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "cumulus-pallet-dmp-queue" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "cumulus-primitives-core", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-io", - "sp-runtime", - "sp-std", - "xcm", -] - -[[package]] -name = "cumulus-pallet-parachain-system" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "bytes", - "cumulus-pallet-parachain-system-proc-macro", - "cumulus-primitives-core", - "cumulus-primitives-parachain-inherent", - "environmental", - "frame-support", - "frame-system", - "impl-trait-for-tuples", - "log", - "parity-scale-codec", - "polkadot-parachain", - "scale-info", - "sp-core", - "sp-externalities", - "sp-inherents", - "sp-io", - "sp-runtime", - "sp-state-machine", - "sp-std", - "sp-trie", - "sp-version", - "xcm", -] - -[[package]] -name = "cumulus-pallet-parachain-system-proc-macro" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "cumulus-pallet-session-benchmarking" -version = "3.0.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "pallet-session", - "parity-scale-codec", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "cumulus-pallet-xcm" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "cumulus-primitives-core", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-io", - "sp-runtime", - "sp-std", - "xcm", -] - -[[package]] -name = "cumulus-pallet-xcmp-queue" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "cumulus-primitives-core", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "polkadot-runtime-common", - "rand_chacha 0.3.1", - "scale-info", - "sp-io", - "sp-runtime", - "sp-std", - "xcm", - "xcm-executor", -] - -[[package]] -name = "cumulus-primitives-core" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "parity-scale-codec", - "polkadot-core-primitives", - "polkadot-parachain", - "polkadot-primitives", - "scale-info", - "sp-api", - "sp-runtime", - "sp-std", - "sp-trie", - "xcm", -] - -[[package]] -name = "cumulus-primitives-parachain-inherent" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "async-trait", - "cumulus-primitives-core", - "cumulus-relay-chain-interface", - "cumulus-test-relay-sproof-builder", - "parity-scale-codec", - "sc-client-api", - "scale-info", - "sp-api", - "sp-core", - "sp-inherents", - "sp-runtime", - "sp-state-machine", - "sp-std", - "sp-storage", - "sp-trie", - "tracing", -] - -[[package]] -name = "cumulus-primitives-timestamp" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "cumulus-primitives-core", - "futures", - "parity-scale-codec", - "sp-inherents", - "sp-std", - "sp-timestamp", -] - -[[package]] -name = "cumulus-primitives-utility" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "cumulus-primitives-core", - "frame-support", - "log", - "parity-scale-codec", - "polkadot-runtime-common", - "sp-io", - "sp-runtime", - "sp-std", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "cumulus-relay-chain-inprocess-interface" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "async-trait", - "cumulus-primitives-core", - "cumulus-relay-chain-interface", - "futures", - "futures-timer", - "polkadot-cli", - "polkadot-client", - "polkadot-service", - "sc-cli", - "sc-client-api", - "sc-sysinfo", - "sc-telemetry", - "sc-tracing", - "sp-api", - "sp-consensus", - "sp-core", - "sp-runtime", - "sp-state-machine", -] - -[[package]] -name = "cumulus-relay-chain-interface" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "async-trait", - "cumulus-primitives-core", - "futures", - "jsonrpsee-core", - "parity-scale-codec", - "polkadot-overseer", - "sc-client-api", - "sp-api", - "sp-blockchain", - "sp-state-machine", - "thiserror", -] - -[[package]] -name = "cumulus-relay-chain-minimal-node" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "array-bytes 6.1.0", - "async-trait", - "cumulus-primitives-core", - "cumulus-relay-chain-interface", - "cumulus-relay-chain-rpc-interface", - "futures", - "lru 0.9.0", - "polkadot-availability-recovery", - "polkadot-collator-protocol", - "polkadot-core-primitives", - "polkadot-network-bridge", - "polkadot-node-collation-generation", - "polkadot-node-core-runtime-api", - "polkadot-node-network-protocol", - "polkadot-node-subsystem-util", - "polkadot-overseer", - "polkadot-primitives", - "sc-authority-discovery", - "sc-client-api", - "sc-network", - "sc-network-common", - "sc-service", - "sc-tracing", - "sc-utils", - "sp-api", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-runtime", - "tokio", - "tracing", -] - -[[package]] -name = "cumulus-relay-chain-rpc-interface" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "async-trait", - "cumulus-primitives-core", - "cumulus-relay-chain-interface", - "futures", - "futures-timer", - "jsonrpsee", - "lru 0.9.0", - "parity-scale-codec", - "polkadot-overseer", - "sc-client-api", - "sc-rpc-api", - "sc-service", - "serde", - "serde_json", - "sp-api", - "sp-authority-discovery", - "sp-consensus-babe", - "sp-core", - "sp-state-machine", - "sp-storage", - "tokio", - "tracing", - "url", -] - -[[package]] -name = "cumulus-test-relay-sproof-builder" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "cumulus-primitives-core", - "parity-scale-codec", - "polkadot-primitives", - "sp-runtime", - "sp-state-machine", - "sp-std", -] - -[[package]] -name = "cumulus-test-relay-validation-worker-provider" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "polkadot-node-core-pvf-worker", - "toml 0.7.8", -] - -[[package]] -name = "cumulus-test-runtime" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "cumulus-pallet-parachain-system", - "cumulus-primitives-core", - "cumulus-primitives-timestamp", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-rpc-runtime-api", - "pallet-balances", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-block-builder", - "sp-core", - "sp-inherents", - "sp-io", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", -] - -[[package]] -name = "cumulus-test-service" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "async-trait", - "clap", - "criterion", - "cumulus-client-cli", - "cumulus-client-consensus-common", - "cumulus-client-consensus-relay-chain", - "cumulus-client-pov-recovery", - "cumulus-client-service", - "cumulus-primitives-core", - "cumulus-primitives-parachain-inherent", - "cumulus-relay-chain-inprocess-interface", - "cumulus-relay-chain-interface", - "cumulus-relay-chain-minimal-node", - "cumulus-test-relay-validation-worker-provider", - "cumulus-test-runtime", - "frame-system", - "frame-system-rpc-runtime-api", - "jsonrpsee", - "pallet-transaction-payment", - "parachains-common", - "parity-scale-codec", - "polkadot-cli", - "polkadot-node-subsystem", - "polkadot-overseer", - "polkadot-primitives", - "polkadot-service", - "polkadot-test-service", - "rand 0.8.5", - "sc-basic-authorship", - "sc-chain-spec", - "sc-cli", - "sc-client-api", - "sc-consensus", - "sc-executor", - "sc-network", - "sc-service", - "sc-telemetry", - "sc-tracing", - "sc-transaction-pool", - "sc-transaction-pool-api", - "serde", - "sp-arithmetic", - "sp-blockchain", - "sp-core", - "sp-io", - "sp-keyring", - "sp-runtime", - "sp-state-machine", - "sp-timestamp", - "sp-tracing", - "sp-trie", - "substrate-test-client", - "tokio", - "tracing", - "url", -] - -[[package]] -name = "curve25519-dalek" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a9b85542f99a2dfa2a1b8e192662741c9859a846b296bef1c92ef9b58b5a216" -dependencies = [ - "byteorder", - "digest 0.8.1", - "rand_core 0.5.1", - "subtle", - "zeroize", -] - -[[package]] -name = "curve25519-dalek" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" -dependencies = [ - "byteorder", - "digest 0.9.0", - "rand_core 0.5.1", - "subtle", - "zeroize", -] - -[[package]] -name = "curve25519-dalek" -version = "4.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89b8c6a2e4b1f45971ad09761aafb85514a84744b67a95e32c3cc1352d1f65c" -dependencies = [ - "cfg-if", - "cpufeatures", - "curve25519-dalek-derive", - "digest 0.10.7", - "fiat-crypto", - "platforms 3.1.2", - "rustc_version 0.4.0", - "subtle", - "zeroize", -] - -[[package]] -name = "curve25519-dalek-derive" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "cxx" -version = "1.0.110" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7129e341034ecb940c9072817cd9007974ea696844fc4dd582dc1653a7fbe2e8" -dependencies = [ - "cc", - "cxxbridge-flags", - "cxxbridge-macro", - "link-cplusplus", -] - -[[package]] -name = "cxx-build" -version = "1.0.110" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2a24f3f5f8eed71936f21e570436f024f5c2e25628f7496aa7ccd03b90109d5" -dependencies = [ - "cc", - "codespan-reporting", - "once_cell", - "proc-macro2", - "quote", - "scratch", - "syn 2.0.38", -] - -[[package]] -name = "cxxbridge-flags" -version = "1.0.110" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06fdd177fc61050d63f67f5bd6351fac6ab5526694ea8e359cd9cd3b75857f44" - -[[package]] -name = "cxxbridge-macro" -version = "1.0.110" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "587663dd5fb3d10932c8aecfe7c844db1bcf0aee93eeab08fac13dc1212c2e7f" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "darling" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" -dependencies = [ - "darling_core", - "darling_macro", -] - -[[package]] -name = "darling_core" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim", - "syn 1.0.109", -] - -[[package]] -name = "darling_macro" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" -dependencies = [ - "darling_core", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "data-encoding" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" - -[[package]] -name = "data-encoding-macro" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c904b33cc60130e1aeea4956ab803d08a3f4a0ca82d64ed757afac3891f2bb99" -dependencies = [ - "data-encoding", - "data-encoding-macro-internal", -] - -[[package]] -name = "data-encoding-macro-internal" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fdf3fce3ce863539ec1d7fd1b6dcc3c645663376b43ed376bbf887733e4f772" -dependencies = [ - "data-encoding", - "syn 1.0.109", -] - -[[package]] -name = "der" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" -dependencies = [ - "const-oid", - "pem-rfc7468", - "zeroize", -] - -[[package]] -name = "der" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" -dependencies = [ - "const-oid", - "zeroize", -] - -[[package]] -name = "der-parser" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe398ac75057914d7d07307bf67dc7f3f574a26783b4fc7805a20ffa9f506e82" -dependencies = [ - "asn1-rs 0.3.1", - "displaydoc", - "nom", - "num-bigint", - "num-traits", - "rusticata-macros", -] - -[[package]] -name = "der-parser" -version = "8.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbd676fbbab537128ef0278adb5576cf363cff6aa22a7b24effe97347cfab61e" -dependencies = [ - "asn1-rs 0.5.2", - "displaydoc", - "nom", - "num-bigint", - "num-traits", - "rusticata-macros", -] - -[[package]] -name = "deranged" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" -dependencies = [ - "powerfmt", -] - -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "derive-syn-parse" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79116f119dd1dba1abf1f3405f03b9b0e79a27a3883864bfebded8a3dc768cd" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "derive_builder" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07adf7be193b71cc36b193d0f5fe60b918a3a9db4dad0449f57bcfd519704a3" -dependencies = [ - "derive_builder_macro", -] - -[[package]] -name = "derive_builder_core" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f91d4cfa921f1c05904dc3c57b4a32c38aed3340cce209f3a6fd1478babafc4" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "derive_builder_macro" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f0314b72bed045f3a68671b3c86328386762c93f82d98c65c3cb5e5f573dd68" -dependencies = [ - "derive_builder_core", - "syn 1.0.109", -] - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version 0.4.0", - "syn 1.0.109", -] - -[[package]] -name = "difflib" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" - -[[package]] -name = "digest" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" -dependencies = [ - "generic-array 0.12.4", -] - -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer 0.10.4", - "const-oid", - "crypto-common", - "subtle", -] - -[[package]] -name = "directories" -version = "4.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f51c5d4ddabd36886dd3e1438cb358cdcb0d7c499cb99cb4ac2e38e18b5cb210" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "directories-next" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc" -dependencies = [ - "cfg-if", - "dirs-sys-next", -] - -[[package]] -name = "dirs-sys" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - -[[package]] -name = "dirs-sys-next" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" -dependencies = [ - "libc", - "redox_users", - "winapi", -] - -[[package]] -name = "displaydoc" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "downcast" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" - -[[package]] -name = "downcast-rs" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" - -[[package]] -name = "dtoa" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" - -[[package]] -name = "dyn-clonable" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e9232f0e607a262ceb9bd5141a3dfb3e4db6994b31989bbfd845878cba59fd4" -dependencies = [ - "dyn-clonable-impl", - "dyn-clone", -] - -[[package]] -name = "dyn-clonable-impl" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "558e40ea573c374cf53507fd240b7ee2f5477df7cfebdb97323ec61c719399c5" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "dyn-clone" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d2f3407d9a573d666de4b5bdf10569d73ca9478087346697dcbae6244bfbcd" - -[[package]] -name = "ecdsa" -version = "0.14.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" -dependencies = [ - "der 0.6.1", - "elliptic-curve 0.12.3", - "rfc6979 0.3.1", - "signature 1.6.4", -] - -[[package]] -name = "ecdsa" -version = "0.16.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" -dependencies = [ - "der 0.7.8", - "digest 0.10.7", - "elliptic-curve 0.13.6", - "rfc6979 0.4.0", - "signature 2.1.0", - "spki 0.7.2", -] - -[[package]] -name = "ed25519" -version = "1.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" -dependencies = [ - "signature 1.6.4", -] - -[[package]] -name = "ed25519" -version = "2.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" -dependencies = [ - "pkcs8 0.10.2", - "signature 2.1.0", -] - -[[package]] -name = "ed25519-dalek" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" -dependencies = [ - "curve25519-dalek 3.2.0", - "ed25519 1.5.3", - "sha2 0.9.9", - "zeroize", -] - -[[package]] -name = "ed25519-dalek" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" -dependencies = [ - "curve25519-dalek 4.1.1", - "ed25519 2.2.3", - "rand_core 0.6.4", - "serde", - "sha2 0.10.8", - "zeroize", -] - -[[package]] -name = "ed25519-zebra" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" -dependencies = [ - "curve25519-dalek 3.2.0", - "hashbrown 0.12.3", - "hex", - "rand_core 0.6.4", - "sha2 0.9.9", - "zeroize", -] - -[[package]] -name = "either" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" - -[[package]] -name = "elliptic-curve" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" -dependencies = [ - "base16ct 0.1.1", - "crypto-bigint 0.4.9", - "der 0.6.1", - "digest 0.10.7", - "ff 0.12.1", - "generic-array 0.14.7", - "group 0.12.1", - "hkdf", - "pem-rfc7468", - "pkcs8 0.9.0", - "rand_core 0.6.4", - "sec1 0.3.0", - "subtle", - "zeroize", -] - -[[package]] -name = "elliptic-curve" -version = "0.13.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" -dependencies = [ - "base16ct 0.2.0", - "crypto-bigint 0.5.3", - "digest 0.10.7", - "ff 0.13.0", - "generic-array 0.14.7", - "group 0.13.0", - "pkcs8 0.10.2", - "rand_core 0.6.4", - "sec1 0.7.3", - "subtle", - "zeroize", -] - -[[package]] -name = "encode_unicode" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" - -[[package]] -name = "enum-as-inner" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "enumflags2" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5998b4f30320c9d93aed72f63af821bfdac50465b75428fce77b48ec482c3939" -dependencies = [ - "enumflags2_derive", -] - -[[package]] -name = "enumflags2_derive" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "enumn" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "env_logger" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" -dependencies = [ - "atty", - "humantime", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "env_logger" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" -dependencies = [ - "humantime", - "is-terminal", - "log", - "regex", - "termcolor", -] - -[[package]] -name = "environmental" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "errno" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" -dependencies = [ - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "event-listener" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" - -[[package]] -name = "exit-future" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e43f2f1833d64e33f15592464d6fdd70f349dda7b1a53088eb83cd94014008c5" -dependencies = [ - "futures", -] - -[[package]] -name = "expander" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a718c0675c555c5f976fff4ea9e2c150fa06cefa201cadef87cfbf9324075881" -dependencies = [ - "blake3", - "fs-err", - "proc-macro2", - "quote", -] - -[[package]] -name = "expander" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3774182a5df13c3d1690311ad32fbe913feef26baba609fa2dd5f72042bd2ab6" -dependencies = [ - "blake2", - "fs-err", - "proc-macro2", - "quote", -] - -[[package]] -name = "expander" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f360349150728553f92e4c997a16af8915f418d3a0f21b440d34c5632f16ed84" -dependencies = [ - "blake2", - "fs-err", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "expander" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f86a749cf851891866c10515ef6c299b5c69661465e9c3bbe7e07a2b77fb0f7" -dependencies = [ - "blake2", - "fs-err", - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "fake-simd" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" - -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - -[[package]] -name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - -[[package]] -name = "fastrand" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" - -[[package]] -name = "fatality" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ad875162843b0d046276327afe0136e9ed3a23d5a754210fb6f1f33610d39ab" -dependencies = [ - "fatality-proc-macro", - "thiserror", -] - -[[package]] -name = "fatality-proc-macro" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5aa1e3ae159e592ad222dc90c5acbad632b527779ba88486abe92782ab268bd" -dependencies = [ - "expander 0.0.4", - "indexmap 1.9.3", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", - "thiserror", -] - -[[package]] -name = "fdlimit" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c4c9e43643f5a3be4ca5b67d26b98031ff9db6806c3440ae32e02e3ceac3f1b" -dependencies = [ - "libc", -] - -[[package]] -name = "ff" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" -dependencies = [ - "rand_core 0.6.4", - "subtle", -] - -[[package]] -name = "ff" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" -dependencies = [ - "rand_core 0.6.4", - "subtle", -] - -[[package]] -name = "fiat-crypto" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a481586acf778f1b1455424c343f71124b048ffa5f4fc3f8f6ae9dc432dcb3c7" - -[[package]] -name = "file-per-thread-logger" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84f2e425d9790201ba4af4630191feac6dcc98765b118d4d18e91d23c2353866" -dependencies = [ - "env_logger 0.10.0", - "log", -] - -[[package]] -name = "filetime" -version = "0.2.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall 0.3.5", - "windows-sys 0.48.0", -] - -[[package]] -name = "finality-grandpa" -version = "0.16.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36530797b9bf31cd4ff126dcfee8170f86b00cfdcea3269d73133cc0415945c3" -dependencies = [ - "either", - "futures", - "futures-timer", - "log", - "num-traits", - "parity-scale-codec", - "parking_lot 0.12.1", - "scale-info", -] - -[[package]] -name = "fixed-hash" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" -dependencies = [ - "byteorder", - "rand 0.8.5", - "rustc-hex", - "static_assertions", -] - -[[package]] -name = "fixedbitset" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" - -[[package]] -name = "flate2" -version = "1.0.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" -dependencies = [ - "crc32fast", - "libz-sys", - "miniz_oxide", -] - -[[package]] -name = "float-cmp" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" -dependencies = [ - "num-traits", -] - -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - -[[package]] -name = "fork-tree" -version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "parity-scale-codec", -] - -[[package]] -name = "form_urlencoded" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" -dependencies = [ - "percent-encoding", -] - -[[package]] -name = "fragile" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" - -[[package]] -name = "frame-benchmarking" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-support", - "frame-support-procedural", - "frame-system", - "linregress", - "log", - "parity-scale-codec", - "paste", - "scale-info", - "serde", - "sp-api", - "sp-application-crypto", - "sp-core", - "sp-io", - "sp-runtime", - "sp-runtime-interface", - "sp-std", - "sp-storage", - "static_assertions", -] - -[[package]] -name = "frame-benchmarking-cli" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "Inflector", - "array-bytes 4.2.0", - "chrono", - "clap", - "comfy-table", - "frame-benchmarking", - "frame-support", - "frame-system", - "gethostname", - "handlebars", - "itertools 0.10.5", - "lazy_static", - "linked-hash-map", - "log", - "parity-scale-codec", - "rand 0.8.5", - "rand_pcg", - "sc-block-builder", - "sc-cli", - "sc-client-api", - "sc-client-db", - "sc-executor", - "sc-service", - "sc-sysinfo", - "serde", - "serde_json", - "sp-api", - "sp-blockchain", - "sp-core", - "sp-database", - "sp-externalities", - "sp-inherents", - "sp-keystore", - "sp-runtime", - "sp-state-machine", - "sp-std", - "sp-storage", - "sp-trie", - "thiserror", - "thousands", -] - -[[package]] -name = "frame-election-provider-solution-type" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "frame-election-provider-support" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-election-provider-solution-type", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-arithmetic", - "sp-core", - "sp-npos-elections", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "frame-executive" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-support", - "frame-system", - "frame-try-runtime", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "sp-tracing", -] - -[[package]] -name = "frame-metadata" -version = "15.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "878babb0b136e731cc77ec2fd883ff02745ff21e6fb662729953d44923df009c" -dependencies = [ - "cfg-if", - "parity-scale-codec", - "scale-info", - "serde", -] - -[[package]] -name = "frame-remote-externalities" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "async-recursion", - "futures", - "indicatif", - "jsonrpsee", - "log", - "parity-scale-codec", - "serde", - "sp-core", - "sp-io", - "sp-runtime", - "spinners", - "substrate-rpc-client", - "tokio", - "tokio-retry", -] - -[[package]] -name = "frame-support" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "bitflags 1.3.2", - "environmental", - "frame-metadata", - "frame-support-procedural", - "impl-trait-for-tuples", - "k256", - "log", - "once_cell", - "parity-scale-codec", - "paste", - "scale-info", - "serde", - "smallvec", - "sp-api", - "sp-arithmetic", - "sp-core", - "sp-core-hashing-proc-macro", - "sp-debug-derive", - "sp-inherents", - "sp-io", - "sp-runtime", - "sp-staking", - "sp-state-machine", - "sp-std", - "sp-tracing", - "sp-weights", - "tt-call", -] - -[[package]] -name = "frame-support-procedural" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "Inflector", - "cfg-expr", - "derive-syn-parse", - "frame-support-procedural-tools", - "itertools 0.10.5", - "proc-macro-warning", - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "frame-support-procedural-tools" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-support-procedural-tools-derive", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "frame-support-procedural-tools-derive" -version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "frame-system" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "cfg-if", - "frame-support", - "log", - "parity-scale-codec", - "scale-info", - "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "sp-version", - "sp-weights", -] - -[[package]] -name = "frame-system-benchmarking" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "frame-system-rpc-runtime-api" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "parity-scale-codec", - "sp-api", -] - -[[package]] -name = "frame-try-runtime" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-support", - "parity-scale-codec", - "sp-api", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "fs-err" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0845fa252299212f0389d64ba26f34fa32cfe41588355f21ed507c59a0f64541" - -[[package]] -name = "fs2" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "fs4" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" -dependencies = [ - "rustix 0.38.21", - "windows-sys 0.48.0", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - -[[package]] -name = "futures" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" - -[[package]] -name = "futures-executor" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", - "num_cpus", -] - -[[package]] -name = "futures-io" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" - -[[package]] -name = "futures-lite" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" -dependencies = [ - "fastrand 1.9.0", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite 0.2.13", - "waker-fn", -] - -[[package]] -name = "futures-macro" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "futures-rustls" -version = "0.22.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2411eed028cdf8c8034eaf21f9915f956b6c3abec4d4c7949ee67f0721127bd" -dependencies = [ - "futures-io", - "rustls 0.20.9", - "webpki 0.22.4", -] - -[[package]] -name = "futures-sink" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" - -[[package]] -name = "futures-task" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" - -[[package]] -name = "futures-timer" -version = "3.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" - -[[package]] -name = "futures-util" -version = "0.3.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite 0.2.13", - "pin-utils", - "slab", -] - -[[package]] -name = "fxhash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder", -] - -[[package]] -name = "generic-array" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" -dependencies = [ - "typenum", -] - -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", - "zeroize", -] - -[[package]] -name = "gethostname" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - -[[package]] -name = "getrandom" -version = "0.2.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" -dependencies = [ - "cfg-if", - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", -] - -[[package]] -name = "ghash" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" -dependencies = [ - "opaque-debug 0.3.0", - "polyval 0.5.3", -] - -[[package]] -name = "ghash" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" -dependencies = [ - "opaque-debug 0.3.0", - "polyval 0.6.1", -] - -[[package]] -name = "gimli" -version = "0.27.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" -dependencies = [ - "fallible-iterator", - "indexmap 1.9.3", - "stable_deref_trait", -] - -[[package]] -name = "gimli" -version = "0.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" - -[[package]] -name = "glob" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" - -[[package]] -name = "globset" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" -dependencies = [ - "aho-corasick", - "bstr 1.7.0", - "fnv", - "log", - "regex", -] - -[[package]] -name = "group" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" -dependencies = [ - "ff 0.12.1", - "rand_core 0.6.4", - "subtle", -] - -[[package]] -name = "group" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" -dependencies = [ - "ff 0.13.0", - "rand_core 0.6.4", - "subtle", -] - -[[package]] -name = "h2" -version = "0.3.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http", - "indexmap 1.9.3", - "slab", - "tokio", - "tokio-util", - "tracing", -] - -[[package]] -name = "half" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" - -[[package]] -name = "handlebars" -version = "4.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c39b3bc2a8f715298032cf5087e58573809374b08160aa7d750582bdb82d2683" -dependencies = [ - "log", - "pest", - "pest_derive", - "serde", - "serde_json", - "thiserror", -] - -[[package]] -name = "hash-db" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e7d7786361d7425ae2fe4f9e407eb0efaa0840f5212d109cc018c40c35c6ab4" - -[[package]] -name = "hash256-std-hasher" -version = "0.15.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" -dependencies = [ - "crunchy", -] - -[[package]] -name = "hashbrown" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -dependencies = [ - "ahash 0.7.7", -] - -[[package]] -name = "hashbrown" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" -dependencies = [ - "ahash 0.8.3", -] - -[[package]] -name = "hashbrown" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" - -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - -[[package]] -name = "hermit-abi" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" - -[[package]] -name = "hex" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" - -[[package]] -name = "hex-literal" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" - -[[package]] -name = "hex-literal" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" - -[[package]] -name = "hkdf" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" -dependencies = [ - "hmac 0.12.1", -] - -[[package]] -name = "hmac" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" -dependencies = [ - "crypto-mac 0.8.0", - "digest 0.9.0", -] - -[[package]] -name = "hmac" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" -dependencies = [ - "crypto-mac 0.11.1", - "digest 0.9.0", -] - -[[package]] -name = "hmac" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "hmac-drbg" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" -dependencies = [ - "digest 0.9.0", - "generic-array 0.14.7", - "hmac 0.8.1", -] - -[[package]] -name = "home" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" -dependencies = [ - "windows-sys 0.48.0", -] - -[[package]] -name = "hostname" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" -dependencies = [ - "libc", - "match_cfg", - "winapi", -] - -[[package]] -name = "http" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - -[[package]] -name = "http-body" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" -dependencies = [ - "bytes", - "http", - "pin-project-lite 0.2.13", -] - -[[package]] -name = "http-range-header" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" - -[[package]] -name = "httparse" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" - -[[package]] -name = "httpdate" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" - -[[package]] -name = "humantime" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" - -[[package]] -name = "hyper" -version = "0.14.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite 0.2.13", - "socket2 0.4.10", - "tokio", - "tower-service", - "tracing", - "want", -] - -[[package]] -name = "hyper-rustls" -version = "0.23.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" -dependencies = [ - "http", - "hyper", - "log", - "rustls 0.20.9", - "rustls-native-certs", - "tokio", - "tokio-rustls 0.23.4", -] - -[[package]] -name = "hyper-rustls" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" -dependencies = [ - "futures-util", - "http", - "hyper", - "log", - "rustls 0.21.8", - "rustls-native-certs", - "tokio", - "tokio-rustls 0.24.1", - "webpki-roots 0.25.2", -] - -[[package]] -name = "iana-time-zone" -version = "0.1.58" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - -[[package]] -name = "ident_case" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" - -[[package]] -name = "idna" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "idna" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - -[[package]] -name = "if-addrs" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbc0fa01ffc752e9dbc72818cdb072cd028b86be5e09dd04c5a643704fe101a9" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "if-watch" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb892e5777fe09e16f3d44de7802f4daa7267ecbe8c466f19d94e25bb0c303e" -dependencies = [ - "async-io", - "core-foundation", - "fnv", - "futures", - "if-addrs", - "ipnet", - "log", - "rtnetlink", - "system-configuration", - "tokio", - "windows", -] - -[[package]] -name = "impl-codec" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" -dependencies = [ - "parity-scale-codec", -] - -[[package]] -name = "impl-serde" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" -dependencies = [ - "serde", -] - -[[package]] -name = "impl-trait-for-tuples" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "indexmap" -version = "1.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" -dependencies = [ - "autocfg", - "hashbrown 0.12.3", - "serde", -] - -[[package]] -name = "indexmap" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" -dependencies = [ - "equivalent", - "hashbrown 0.14.2", -] - -[[package]] -name = "indicatif" -version = "0.17.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb28741c9db9a713d93deb3bb9515c20788cef5815265bee4980e87bde7e0f25" -dependencies = [ - "console", - "instant", - "number_prefix", - "portable-atomic", - "unicode-width", -] - -[[package]] -name = "inout" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" -dependencies = [ - "generic-array 0.14.7", -] - -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "integer-encoding" -version = "3.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bb03732005da905c88227371639bf1ad885cc712789c011c31c5fb3ab3ccf02" - -[[package]] -name = "integer-sqrt" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" -dependencies = [ - "num-traits", -] - -[[package]] -name = "integration-tests" -version = "0.1.0" -dependencies = [ - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "frame-support", - "frame-system", - "pallet-assets", - "pallet-balances", - "pallet-funding", - "pallet-im-online", - "pallet-message-queue", - "pallet-staking", - "pallet-xcm", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "penpal-runtime", - "polimec-parachain-runtime", - "polkadot-core-primitives", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime", - "polkadot-runtime-constants", - "polkadot-runtime-parachains", - "polkadot-service", - "sc-consensus-grandpa", - "scale-info", - "sp-authority-discovery", - "sp-consensus-babe", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "statemint-runtime", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-emulator", - "xcm-executor", -] - -[[package]] -name = "interceptor" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e8a11ae2da61704edada656798b61c94b35ecac2c58eb955156987d5e6be90b" -dependencies = [ - "async-trait", - "bytes", - "log", - "rand 0.8.5", - "rtcp", - "rtp", - "thiserror", - "tokio", - "waitgroup", - "webrtc-srtp", - "webrtc-util", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi 0.3.3", - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "ip_network" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa2f047c0a98b2f299aa5d6d7088443570faae494e9ae1305e48be000c9e0eb1" - -[[package]] -name = "ipconfig" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" -dependencies = [ - "socket2 0.5.5", - "widestring", - "windows-sys 0.48.0", - "winreg", -] - -[[package]] -name = "ipnet" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" - -[[package]] -name = "is-terminal" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi 0.3.3", - "rustix 0.38.21", - "windows-sys 0.48.0", -] - -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - -[[package]] -name = "itertools" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" -dependencies = [ - "either", -] - -[[package]] -name = "itoa" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" - -[[package]] -name = "jobserver" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" -dependencies = [ - "libc", -] - -[[package]] -name = "js-sys" -version = "0.3.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "jsonrpsee" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "367a292944c07385839818bb71c8d76611138e2dedb0677d035b8da21d29c78b" -dependencies = [ - "jsonrpsee-core", - "jsonrpsee-http-client", - "jsonrpsee-proc-macros", - "jsonrpsee-server", - "jsonrpsee-types", - "jsonrpsee-ws-client", - "tracing", -] - -[[package]] -name = "jsonrpsee-client-transport" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8b3815d9f5d5de348e5f162b316dc9cdf4548305ebb15b4eb9328e66cf27d7a" -dependencies = [ - "futures-util", - "http", - "jsonrpsee-core", - "jsonrpsee-types", - "pin-project", - "rustls-native-certs", - "soketto", - "thiserror", - "tokio", - "tokio-rustls 0.24.1", - "tokio-util", - "tracing", - "webpki-roots 0.25.2", -] - -[[package]] -name = "jsonrpsee-core" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b5dde66c53d6dcdc8caea1874a45632ec0fcf5b437789f1e45766a1512ce803" -dependencies = [ - "anyhow", - "arrayvec 0.7.4", - "async-lock", - "async-trait", - "beef", - "futures-channel", - "futures-timer", - "futures-util", - "globset", - "hyper", - "jsonrpsee-types", - "parking_lot 0.12.1", - "rand 0.8.5", - "rustc-hash", - "serde", - "serde_json", - "soketto", - "thiserror", - "tokio", - "tracing", -] - -[[package]] -name = "jsonrpsee-http-client" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e5f9fabdd5d79344728521bb65e3106b49ec405a78b66fbff073b72b389fa43" -dependencies = [ - "async-trait", - "hyper", - "hyper-rustls 0.24.2", - "jsonrpsee-core", - "jsonrpsee-types", - "rustc-hash", - "serde", - "serde_json", - "thiserror", - "tokio", - "tracing", -] - -[[package]] -name = "jsonrpsee-proc-macros" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44e8ab85614a08792b9bff6c8feee23be78c98d0182d4c622c05256ab553892a" -dependencies = [ - "heck", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "jsonrpsee-server" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4d945a6008c9b03db3354fb3c83ee02d2faa9f2e755ec1dfb69c3551b8f4ba" -dependencies = [ - "futures-channel", - "futures-util", - "http", - "hyper", - "jsonrpsee-core", - "jsonrpsee-types", - "serde", - "serde_json", - "soketto", - "tokio", - "tokio-stream", - "tokio-util", - "tower", - "tracing", -] - -[[package]] -name = "jsonrpsee-types" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245ba8e5aa633dd1c1e4fae72bce06e71f42d34c14a2767c6b4d173b57bee5e5" -dependencies = [ - "anyhow", - "beef", - "serde", - "serde_json", - "thiserror", - "tracing", -] - -[[package]] -name = "jsonrpsee-ws-client" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e1b3975ed5d73f456478681a417128597acd6a2487855fdb7b4a3d4d195bf5e" -dependencies = [ - "http", - "jsonrpsee-client-transport", - "jsonrpsee-core", - "jsonrpsee-types", -] - -[[package]] -name = "k256" -version = "0.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" -dependencies = [ - "cfg-if", - "ecdsa 0.16.8", - "elliptic-curve 0.13.6", - "once_cell", - "sha2 0.10.8", -] - -[[package]] -name = "keccak" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" -dependencies = [ - "cpufeatures", -] - -[[package]] -name = "kusama-runtime" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "bitvec", - "frame-benchmarking", - "frame-election-provider-support", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal 0.4.1", - "kusama-runtime-constants", - "log", - "pallet-authority-discovery", - "pallet-authorship", - "pallet-babe", - "pallet-bags-list", - "pallet-balances", - "pallet-bounties", - "pallet-child-bounties", - "pallet-collective", - "pallet-conviction-voting", - "pallet-democracy", - "pallet-election-provider-multi-phase", - "pallet-election-provider-support-benchmarking", - "pallet-elections-phragmen", - "pallet-fast-unstake", - "pallet-grandpa", - "pallet-identity", - "pallet-im-online", - "pallet-indices", - "pallet-membership", - "pallet-message-queue", - "pallet-multisig", - "pallet-nis", - "pallet-nomination-pools", - "pallet-nomination-pools-benchmarking", - "pallet-nomination-pools-runtime-api", - "pallet-offences", - "pallet-offences-benchmarking", - "pallet-preimage", - "pallet-proxy", - "pallet-ranked-collective", - "pallet-recovery", - "pallet-referenda", - "pallet-scheduler", - "pallet-session", - "pallet-session-benchmarking", - "pallet-society", - "pallet-staking", - "pallet-staking-runtime-api", - "pallet-timestamp", - "pallet-tips", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-treasury", - "pallet-utility", - "pallet-vesting", - "pallet-whitelist", - "pallet-xcm", - "pallet-xcm-benchmarks", - "parity-scale-codec", - "polkadot-primitives", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "rustc-hex", - "scale-info", - "serde", - "serde_derive", - "smallvec", - "sp-api", - "sp-arithmetic", - "sp-authority-discovery", - "sp-block-builder", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-core", - "sp-inherents", - "sp-io", - "sp-mmr-primitives", - "sp-npos-elections", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", - "sp-transaction-pool", - "sp-version", - "static_assertions", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "kusama-runtime-constants" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "frame-support", - "polkadot-primitives", - "polkadot-runtime-common", - "smallvec", - "sp-core", - "sp-runtime", - "sp-weights", -] - -[[package]] -name = "kvdb" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7d770dcb02bf6835887c3a979b5107a04ff4bbde97a5f0928d27404a155add9" -dependencies = [ - "smallvec", -] - -[[package]] -name = "kvdb-memorydb" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf7a85fe66f9ff9cd74e169fdd2c94c6e1e74c412c99a73b4df3200b5d3760b2" -dependencies = [ - "kvdb", - "parking_lot 0.12.1", -] - -[[package]] -name = "kvdb-rocksdb" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b644c70b92285f66bfc2032922a79000ea30af7bc2ab31902992a5dcb9b434f6" -dependencies = [ - "kvdb", - "num_cpus", - "parking_lot 0.12.1", - "regex", - "rocksdb", - "smallvec", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "lazycell" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" - -[[package]] -name = "libc" -version = "0.2.149" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" - -[[package]] -name = "libloading" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" -dependencies = [ - "cfg-if", - "winapi", -] - -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - -[[package]] -name = "libp2p" -version = "0.51.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f210d259724eae82005b5c48078619b7745edb7b76de370b03f8ba59ea103097" -dependencies = [ - "bytes", - "futures", - "futures-timer", - "getrandom 0.2.10", - "instant", - "libp2p-allow-block-list", - "libp2p-connection-limits", - "libp2p-core", - "libp2p-dns", - "libp2p-identify", - "libp2p-identity", - "libp2p-kad", - "libp2p-mdns", - "libp2p-metrics", - "libp2p-noise", - "libp2p-ping", - "libp2p-quic", - "libp2p-request-response", - "libp2p-swarm", - "libp2p-tcp", - "libp2p-wasm-ext", - "libp2p-webrtc", - "libp2p-websocket", - "libp2p-yamux", - "multiaddr", - "pin-project", -] - -[[package]] -name = "libp2p-allow-block-list" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "510daa05efbc25184458db837f6f9a5143888f1caa742426d92e1833ddd38a50" -dependencies = [ - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", - "void", -] - -[[package]] -name = "libp2p-connection-limits" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4caa33f1d26ed664c4fe2cca81a08c8e07d4c1c04f2f4ac7655c2dd85467fda0" -dependencies = [ - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", - "void", -] - -[[package]] -name = "libp2p-core" -version = "0.39.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c1df63c0b582aa434fb09b2d86897fa2b419ffeccf934b36f87fcedc8e835c2" -dependencies = [ - "either", - "fnv", - "futures", - "futures-timer", - "instant", - "libp2p-identity", - "log", - "multiaddr", - "multihash 0.17.0", - "multistream-select", - "once_cell", - "parking_lot 0.12.1", - "pin-project", - "quick-protobuf", - "rand 0.8.5", - "rw-stream-sink", - "smallvec", - "thiserror", - "unsigned-varint", - "void", -] - -[[package]] -name = "libp2p-dns" -version = "0.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146ff7034daae62077c415c2376b8057368042df6ab95f5432ad5e88568b1554" -dependencies = [ - "futures", - "libp2p-core", - "log", - "parking_lot 0.12.1", - "smallvec", - "trust-dns-resolver", -] - -[[package]] -name = "libp2p-identify" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5455f472243e63b9c497ff320ded0314254a9eb751799a39c283c6f20b793f3c" -dependencies = [ - "asynchronous-codec", - "either", - "futures", - "futures-timer", - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", - "log", - "lru 0.10.1", - "quick-protobuf", - "quick-protobuf-codec", - "smallvec", - "thiserror", - "void", -] - -[[package]] -name = "libp2p-identity" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "276bb57e7af15d8f100d3c11cbdd32c6752b7eef4ba7a18ecf464972c07abcce" -dependencies = [ - "bs58", - "ed25519-dalek 2.0.0", - "log", - "multiaddr", - "multihash 0.17.0", - "quick-protobuf", - "rand 0.8.5", - "sha2 0.10.8", - "thiserror", - "zeroize", -] - -[[package]] -name = "libp2p-kad" -version = "0.43.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39d5ef876a2b2323d63c258e63c2f8e36f205fe5a11f0b3095d59635650790ff" -dependencies = [ - "arrayvec 0.7.4", - "asynchronous-codec", - "bytes", - "either", - "fnv", - "futures", - "futures-timer", - "instant", - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", - "log", - "quick-protobuf", - "rand 0.8.5", - "sha2 0.10.8", - "smallvec", - "thiserror", - "uint", - "unsigned-varint", - "void", -] - -[[package]] -name = "libp2p-mdns" -version = "0.43.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19983e1f949f979a928f2c603de1cf180cc0dc23e4ac93a62651ccb18341460b" -dependencies = [ - "data-encoding", - "futures", - "if-watch", - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", - "log", - "rand 0.8.5", - "smallvec", - "socket2 0.4.10", - "tokio", - "trust-dns-proto", - "void", -] - -[[package]] -name = "libp2p-metrics" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a42ec91e227d7d0dafa4ce88b333cdf5f277253873ab087555c92798db2ddd46" -dependencies = [ - "libp2p-core", - "libp2p-identify", - "libp2p-kad", - "libp2p-ping", - "libp2p-swarm", - "prometheus-client", -] - -[[package]] -name = "libp2p-noise" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3673da89d29936bc6435bafc638e2f184180d554ce844db65915113f86ec5e" -dependencies = [ - "bytes", - "curve25519-dalek 3.2.0", - "futures", - "libp2p-core", - "libp2p-identity", - "log", - "once_cell", - "quick-protobuf", - "rand 0.8.5", - "sha2 0.10.8", - "snow", - "static_assertions", - "thiserror", - "x25519-dalek 1.1.1", - "zeroize", -] - -[[package]] -name = "libp2p-ping" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e57759c19c28a73ef1eb3585ca410cefb72c1a709fcf6de1612a378e4219202" -dependencies = [ - "either", - "futures", - "futures-timer", - "instant", - "libp2p-core", - "libp2p-swarm", - "log", - "rand 0.8.5", - "void", -] - -[[package]] -name = "libp2p-quic" -version = "0.7.0-alpha.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6b26abd81cd2398382a1edfe739b539775be8a90fa6914f39b2ab49571ec735" -dependencies = [ - "bytes", - "futures", - "futures-timer", - "if-watch", - "libp2p-core", - "libp2p-identity", - "libp2p-tls", - "log", - "parking_lot 0.12.1", - "quinn-proto", - "rand 0.8.5", - "rustls 0.20.9", - "thiserror", - "tokio", -] - -[[package]] -name = "libp2p-request-response" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffdb374267d42dc5ed5bc53f6e601d4a64ac5964779c6e40bb9e4f14c1e30d5" -dependencies = [ - "async-trait", - "futures", - "instant", - "libp2p-core", - "libp2p-identity", - "libp2p-swarm", - "rand 0.8.5", - "smallvec", -] - -[[package]] -name = "libp2p-swarm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "903b3d592d7694e56204d211f29d31bc004be99386644ba8731fc3e3ef27b296" -dependencies = [ - "either", - "fnv", - "futures", - "futures-timer", - "instant", - "libp2p-core", - "libp2p-identity", - "libp2p-swarm-derive", - "log", - "rand 0.8.5", - "smallvec", - "tokio", - "void", -] - -[[package]] -name = "libp2p-swarm-derive" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fba456131824ab6acd4c7bf61e9c0f0a3014b5fc9868ccb8e10d344594cdc4f" -dependencies = [ - "heck", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "libp2p-tcp" -version = "0.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33d33698596d7722d85d3ab0c86c2c322254fce1241e91208e3679b4eb3026cf" -dependencies = [ - "futures", - "futures-timer", - "if-watch", - "libc", - "libp2p-core", - "log", - "socket2 0.4.10", - "tokio", -] - -[[package]] -name = "libp2p-tls" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff08d13d0dc66e5e9ba6279c1de417b84fa0d0adc3b03e5732928c180ec02781" -dependencies = [ - "futures", - "futures-rustls", - "libp2p-core", - "libp2p-identity", - "rcgen 0.10.0", - "ring 0.16.20", - "rustls 0.20.9", - "thiserror", - "webpki 0.22.4", - "x509-parser 0.14.0", - "yasna", -] - -[[package]] -name = "libp2p-wasm-ext" -version = "0.39.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77dff9d32353a5887adb86c8afc1de1a94d9e8c3bc6df8b2201d7cdf5c848f43" -dependencies = [ - "futures", - "js-sys", - "libp2p-core", - "parity-send-wrapper", - "wasm-bindgen", - "wasm-bindgen-futures", -] - -[[package]] -name = "libp2p-webrtc" -version = "0.4.0-alpha.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dba48592edbc2f60b4bc7c10d65445b0c3964c07df26fdf493b6880d33be36f8" -dependencies = [ - "async-trait", - "asynchronous-codec", - "bytes", - "futures", - "futures-timer", - "hex", - "if-watch", - "libp2p-core", - "libp2p-identity", - "libp2p-noise", - "log", - "multihash 0.17.0", - "quick-protobuf", - "quick-protobuf-codec", - "rand 0.8.5", - "rcgen 0.9.3", - "serde", - "stun", - "thiserror", - "tinytemplate", - "tokio", - "tokio-util", - "webrtc", -] - -[[package]] -name = "libp2p-websocket" -version = "0.41.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "111273f7b3d3510524c752e8b7a5314b7f7a1fee7e68161c01a7d72cbb06db9f" -dependencies = [ - "either", - "futures", - "futures-rustls", - "libp2p-core", - "log", - "parking_lot 0.12.1", - "quicksink", - "rw-stream-sink", - "soketto", - "url", - "webpki-roots 0.22.6", -] - -[[package]] -name = "libp2p-yamux" -version = "0.43.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dcd21d950662700a385d4c6d68e2f5f54d778e97068cdd718522222ef513bda" -dependencies = [ - "futures", - "libp2p-core", - "log", - "thiserror", - "yamux", -] - -[[package]] -name = "librocksdb-sys" -version = "0.11.0+8.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3386f101bcb4bd252d8e9d2fb41ec3b0862a15a62b478c355b2982efa469e3e" -dependencies = [ - "bindgen", - "bzip2-sys", - "cc", - "glob", - "libc", - "libz-sys", - "tikv-jemalloc-sys", -] - -[[package]] -name = "libsecp256k1" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b09eff1b35ed3b33b877ced3a691fc7a481919c7e29c53c906226fcf55e2a1" -dependencies = [ - "arrayref", - "base64 0.13.1", - "digest 0.9.0", - "hmac-drbg", - "libsecp256k1-core", - "libsecp256k1-gen-ecmult", - "libsecp256k1-gen-genmult", - "rand 0.8.5", - "serde", - "sha2 0.9.9", - "typenum", -] - -[[package]] -name = "libsecp256k1-core" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" -dependencies = [ - "crunchy", - "digest 0.9.0", - "subtle", -] - -[[package]] -name = "libsecp256k1-gen-ecmult" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809" -dependencies = [ - "libsecp256k1-core", -] - -[[package]] -name = "libsecp256k1-gen-genmult" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c" -dependencies = [ - "libsecp256k1-core", -] - -[[package]] -name = "libz-sys" -version = "1.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" -dependencies = [ - "cc", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "link-cplusplus" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9" -dependencies = [ - "cc", -] - -[[package]] -name = "linked-hash-map" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" - -[[package]] -name = "linked_hash_set" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47186c6da4d81ca383c7c47c1bfc80f4b95f4720514d860a5407aaf4233f9588" -dependencies = [ - "linked-hash-map", -] - -[[package]] -name = "linregress" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4de04dcecc58d366391f9920245b85ffa684558a5ef6e7736e754347c3aea9c2" -dependencies = [ - "nalgebra", -] - -[[package]] -name = "linux-raw-sys" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" - -[[package]] -name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - -[[package]] -name = "linux-raw-sys" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" - -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "log" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" - -[[package]] -name = "lru" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" -dependencies = [ - "hashbrown 0.12.3", -] - -[[package]] -name = "lru" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71e7d46de488603ffdd5f30afbc64fbba2378214a2c3a2fb83abf3d33126df17" -dependencies = [ - "hashbrown 0.13.2", -] - -[[package]] -name = "lru" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670" -dependencies = [ - "hashbrown 0.13.2", -] - -[[package]] -name = "lru-cache" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" -dependencies = [ - "linked-hash-map", -] - -[[package]] -name = "lz4" -version = "1.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e9e2dd86df36ce760a60f6ff6ad526f7ba1f14ba0356f8254fb6905e6494df1" -dependencies = [ - "libc", - "lz4-sys", -] - -[[package]] -name = "lz4-sys" -version = "1.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d27b317e207b10f69f5e75494119e391a96f48861ae870d1da6edac98ca900" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "mach" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" -dependencies = [ - "libc", -] - -[[package]] -name = "maplit" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" - -[[package]] -name = "match_cfg" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" - -[[package]] -name = "matchers" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" -dependencies = [ - "regex-automata 0.1.10", -] - -[[package]] -name = "matches" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" - -[[package]] -name = "matrixmultiply" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7574c1cf36da4798ab73da5b215bbf444f50718207754cb522201d78d1cd0ff2" -dependencies = [ - "autocfg", - "rawpointer", -] - -[[package]] -name = "md-5" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" -dependencies = [ - "cfg-if", - "digest 0.10.7", -] - -[[package]] -name = "memchr" -version = "2.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" - -[[package]] -name = "memfd" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" -dependencies = [ - "rustix 0.38.21", -] - -[[package]] -name = "memmap2" -version = "0.5.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" -dependencies = [ - "libc", -] - -[[package]] -name = "memoffset" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" -dependencies = [ - "autocfg", -] - -[[package]] -name = "memoffset" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" -dependencies = [ - "autocfg", -] - -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] - -[[package]] -name = "memory-db" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808b50db46293432a45e63bc15ea51e0ab4c0a1647b8eb114e31a3e698dd6fbe" -dependencies = [ - "hash-db", -] - -[[package]] -name = "memory_units" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" - -[[package]] -name = "merlin" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e261cf0f8b3c42ded9f7d2bb59dea03aa52bc8a1cbc7482f9fc3fd1229d3b42" -dependencies = [ - "byteorder", - "keccak", - "rand_core 0.5.1", - "zeroize", -] - -[[package]] -name = "mick-jaeger" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69672161530e8aeca1d1400fbf3f1a1747ff60ea604265a4e906c2442df20532" -dependencies = [ - "futures", - "rand 0.8.5", - "thrift", -] - -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - -[[package]] -name = "miniz_oxide" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" -dependencies = [ - "adler", -] - -[[package]] -name = "mio" -version = "0.8.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" -dependencies = [ - "libc", - "wasi 0.11.0+wasi-snapshot-preview1", - "windows-sys 0.48.0", -] - -[[package]] -name = "mmr-gadget" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "futures", - "log", - "parity-scale-codec", - "sc-client-api", - "sc-offchain", - "sp-api", - "sp-blockchain", - "sp-consensus", - "sp-consensus-beefy", - "sp-core", - "sp-mmr-primitives", - "sp-runtime", -] - -[[package]] -name = "mmr-rpc" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "anyhow", - "jsonrpsee", - "parity-scale-codec", - "serde", - "sp-api", - "sp-blockchain", - "sp-core", - "sp-mmr-primitives", - "sp-runtime", -] - -[[package]] -name = "mockall" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c84490118f2ee2d74570d114f3d0493cbf02790df303d2707606c3e14e07c96" -dependencies = [ - "cfg-if", - "downcast", - "fragile", - "lazy_static", - "mockall_derive", - "predicates", - "predicates-tree", -] - -[[package]] -name = "mockall_derive" -version = "0.11.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ce75669015c4f47b289fd4d4f56e894e4c96003ffdf3ac51313126f94c6cbb" -dependencies = [ - "cfg-if", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "multiaddr" -version = "0.17.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b36f567c7099511fa8612bbbb52dda2419ce0bdbacf31714e3a5ffdb766d3bd" -dependencies = [ - "arrayref", - "byteorder", - "data-encoding", - "log", - "multibase", - "multihash 0.17.0", - "percent-encoding", - "serde", - "static_assertions", - "unsigned-varint", - "url", -] - -[[package]] -name = "multibase" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b3539ec3c1f04ac9748a260728e855f261b4977f5c3406612c884564f329404" -dependencies = [ - "base-x", - "data-encoding", - "data-encoding-macro", -] - -[[package]] -name = "multihash" -version = "0.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c346cf9999c631f002d8f977c4eaeaa0e6386f16007202308d0b3757522c2cc" -dependencies = [ - "blake2b_simd", - "blake2s_simd", - "blake3", - "core2", - "digest 0.10.7", - "multihash-derive", - "sha2 0.10.8", - "sha3", - "unsigned-varint", -] - -[[package]] -name = "multihash" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" -dependencies = [ - "core2", - "digest 0.10.7", - "multihash-derive", - "sha2 0.10.8", - "unsigned-varint", -] - -[[package]] -name = "multihash-derive" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc076939022111618a5026d3be019fd8b366e76314538ff9a1b59ffbcbf98bcd" -dependencies = [ - "proc-macro-crate", - "proc-macro-error", - "proc-macro2", - "quote", - "syn 1.0.109", - "synstructure", -] - -[[package]] -name = "multimap" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" - -[[package]] -name = "multistream-select" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8552ab875c1313b97b8d20cb857b9fd63e2d1d6a0a1b53ce9821e575405f27a" -dependencies = [ - "bytes", - "futures", - "log", - "pin-project", - "smallvec", - "unsigned-varint", -] - -[[package]] -name = "nalgebra" -version = "0.32.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307ed9b18cc2423f29e83f84fd23a8e73628727990181f18641a8b5dc2ab1caa" -dependencies = [ - "approx", - "matrixmultiply", - "nalgebra-macros", - "num-complex", - "num-rational", - "num-traits", - "simba", - "typenum", -] - -[[package]] -name = "nalgebra-macros" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91761aed67d03ad966ef783ae962ef9bbaca728d2dd7ceb7939ec110fffad998" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "names" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7d66043b25d4a6cccb23619d10c19c25304b355a7dccd4a8e11423dd2382146" -dependencies = [ - "rand 0.8.5", -] - -[[package]] -name = "nanorand" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" - -[[package]] -name = "netlink-packet-core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345b8ab5bd4e71a2986663e88c56856699d060e78e152e6e9d7966fcd5491297" -dependencies = [ - "anyhow", - "byteorder", - "libc", - "netlink-packet-utils", -] - -[[package]] -name = "netlink-packet-route" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9ea4302b9759a7a88242299225ea3688e63c85ea136371bb6cf94fd674efaab" -dependencies = [ - "anyhow", - "bitflags 1.3.2", - "byteorder", - "libc", - "netlink-packet-core", - "netlink-packet-utils", -] - -[[package]] -name = "netlink-packet-utils" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ede8a08c71ad5a95cdd0e4e52facd37190977039a4704eb82a283f713747d34" -dependencies = [ - "anyhow", - "byteorder", - "paste", - "thiserror", -] - -[[package]] -name = "netlink-proto" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65b4b14489ab424703c092062176d52ba55485a89c076b4f9db05092b7223aa6" -dependencies = [ - "bytes", - "futures", - "log", - "netlink-packet-core", - "netlink-sys", - "thiserror", - "tokio", -] - -[[package]] -name = "netlink-sys" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6471bf08e7ac0135876a9581bf3217ef0333c191c128d34878079f42ee150411" -dependencies = [ - "bytes", - "futures", - "libc", - "log", - "tokio", -] - -[[package]] -name = "nix" -version = "0.24.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" -dependencies = [ - "bitflags 1.3.2", - "cfg-if", - "libc", - "memoffset 0.6.5", -] - -[[package]] -name = "nohash-hasher" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" - -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - -[[package]] -name = "normalize-line-endings" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" - -[[package]] -name = "num-bigint" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-complex" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" -dependencies = [ - "num-traits", -] - -[[package]] -name = "num-format" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" -dependencies = [ - "arrayvec 0.7.4", - "itoa", -] - -[[package]] -name = "num-integer" -version = "0.1.45" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" -dependencies = [ - "autocfg", - "num-bigint", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" -dependencies = [ - "autocfg", -] - -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi 0.3.3", - "libc", -] - -[[package]] -name = "number_prefix" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" - -[[package]] -name = "object" -version = "0.30.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" -dependencies = [ - "crc32fast", - "hashbrown 0.13.2", - "indexmap 1.9.3", - "memchr", -] - -[[package]] -name = "object" -version = "0.32.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" -dependencies = [ - "memchr", -] - -[[package]] -name = "oid-registry" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38e20717fa0541f39bd146692035c37bedfa532b3e5071b35761082407546b2a" -dependencies = [ - "asn1-rs 0.3.1", -] - -[[package]] -name = "oid-registry" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff" -dependencies = [ - "asn1-rs 0.5.2", -] - -[[package]] -name = "once_cell" -version = "1.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" - -[[package]] -name = "oorandom" -version = "11.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" - -[[package]] -name = "opaque-debug" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" - -[[package]] -name = "opaque-debug" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" - -[[package]] -name = "openssl-probe" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" - -[[package]] -name = "orchestra" -version = "0.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "227585216d05ba65c7ab0a0450a3cf2cbd81a98862a54c4df8e14d5ac6adb015" -dependencies = [ - "async-trait", - "dyn-clonable", - "futures", - "futures-timer", - "orchestra-proc-macro", - "pin-project", - "prioritized-metered-channel", - "thiserror", - "tracing", -] - -[[package]] -name = "orchestra-proc-macro" -version = "0.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2871aadd82a2c216ee68a69837a526dfe788ecbe74c4c5038a6acdbff6653066" -dependencies = [ - "expander 0.0.6", - "itertools 0.10.5", - "petgraph", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "ordered-float" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3305af35278dd29f46fcdd139e0b1fbfae2153f0e5928b39b035542dd31e37b7" -dependencies = [ - "num-traits", -] - -[[package]] -name = "p256" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" -dependencies = [ - "ecdsa 0.14.8", - "elliptic-curve 0.12.3", - "sha2 0.10.8", -] - -[[package]] -name = "p384" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa" -dependencies = [ - "ecdsa 0.14.8", - "elliptic-curve 0.12.3", - "sha2 0.10.8", -] - -[[package]] -name = "pallet-asset-tx-payment" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "pallet-transaction-payment", - "parity-scale-codec", - "scale-info", - "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-assets" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-aura" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-support", - "frame-system", - "pallet-timestamp", - "parity-scale-codec", - "scale-info", - "sp-application-crypto", - "sp-consensus-aura", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-authority-discovery" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-support", - "frame-system", - "pallet-session", - "parity-scale-codec", - "scale-info", - "sp-application-crypto", - "sp-authority-discovery", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-authorship" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-support", - "frame-system", - "impl-trait-for-tuples", - "parity-scale-codec", - "scale-info", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-babe" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "pallet-authorship", - "pallet-session", - "pallet-timestamp", - "parity-scale-codec", - "scale-info", - "sp-application-crypto", - "sp-consensus-babe", - "sp-core", - "sp-io", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", -] - -[[package]] -name = "pallet-bags-list" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-election-provider-support", - "frame-support", - "frame-system", - "log", - "pallet-balances", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "sp-tracing", -] - -[[package]] -name = "pallet-balances" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-beefy" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-support", - "frame-system", - "pallet-authorship", - "pallet-session", - "parity-scale-codec", - "scale-info", - "serde", - "sp-consensus-beefy", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", -] - -[[package]] -name = "pallet-beefy-mmr" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "array-bytes 4.2.0", - "binary-merkle-tree", - "frame-support", - "frame-system", - "log", - "pallet-beefy", - "pallet-mmr", - "pallet-session", - "parity-scale-codec", - "scale-info", - "serde", - "sp-api", - "sp-consensus-beefy", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-bounties" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "pallet-treasury", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-child-bounties" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "pallet-bounties", - "pallet-treasury", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-collator-selection" -version = "3.0.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "pallet-authorship", - "pallet-session", - "parity-scale-codec", - "rand 0.8.5", - "scale-info", - "sp-runtime", - "sp-staking", - "sp-std", -] - -[[package]] -name = "pallet-collective" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-conviction-voting" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "assert_matches", - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "serde", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-democracy" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-election-provider-multi-phase" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-election-provider-support", - "frame-support", - "frame-system", - "log", - "pallet-election-provider-support-benchmarking", - "parity-scale-codec", - "rand 0.8.5", - "scale-info", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-npos-elections", - "sp-runtime", - "sp-std", - "strum", -] - -[[package]] -name = "pallet-election-provider-support-benchmarking" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-election-provider-support", - "frame-system", - "parity-scale-codec", - "sp-npos-elections", - "sp-runtime", -] - -[[package]] -name = "pallet-elections-phragmen" -version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-npos-elections", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-fast-unstake" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-election-provider-support", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-io", - "sp-runtime", - "sp-staking", - "sp-std", -] - -[[package]] -name = "pallet-funding" -version = "0.1.0" -dependencies = [ - "assert_matches2", - "frame-benchmarking", - "frame-support", - "frame-system", - "itertools 0.11.0", - "log", - "pallet-assets", - "pallet-balances", - "pallet-insecure-randomness-collective-flip", - "pallet-linear-release", - "pallet-timestamp", - "pallet-xcm", - "parachains-common", - "parity-scale-codec", - "polimec-traits", - "polimec-xcm-executor", - "polkadot-parachain", - "polkadot-runtime", - "polkadot-runtime-parachains", - "scale-info", - "serde", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "pallet-grandpa" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "pallet-authorship", - "pallet-session", - "parity-scale-codec", - "scale-info", - "sp-application-crypto", - "sp-consensus-grandpa", - "sp-core", - "sp-io", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", -] - -[[package]] -name = "pallet-identity" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "enumflags2", - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-im-online" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "pallet-authorship", - "parity-scale-codec", - "scale-info", - "sp-application-crypto", - "sp-core", - "sp-io", - "sp-runtime", - "sp-staking", - "sp-std", -] - -[[package]] -name = "pallet-indices" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-keyring", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-insecure-randomness-collective-flip" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-support", - "frame-system", - "parity-scale-codec", - "safe-mix", - "scale-info", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-linear-release" -version = "4.0.0-dev" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "pallet-balances", - "pallet-funding", - "parity-scale-codec", - "polimec-traits", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "xcm-builder", -] - -[[package]] -name = "pallet-membership" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-message-queue" -version = "7.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "sp-weights", -] - -[[package]] -name = "pallet-mmr" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-mmr-primitives", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-multisig" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-nfts" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "enumflags2", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-nfts-runtime-api" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-support", - "pallet-nfts", - "parity-scale-codec", - "sp-api", -] - -[[package]] -name = "pallet-nis" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-arithmetic", - "sp-core", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-nomination-pools" -version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-staking", - "sp-std", -] - -[[package]] -name = "pallet-nomination-pools-benchmarking" -version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-election-provider-support", - "frame-support", - "frame-system", - "pallet-bags-list", - "pallet-nomination-pools", - "pallet-staking", - "parity-scale-codec", - "scale-info", - "sp-runtime", - "sp-runtime-interface", - "sp-staking", - "sp-std", -] - -[[package]] -name = "pallet-nomination-pools-runtime-api" -version = "1.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "pallet-nomination-pools", - "parity-scale-codec", - "sp-api", - "sp-std", -] - -[[package]] -name = "pallet-offences" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-support", - "frame-system", - "log", - "pallet-balances", - "parity-scale-codec", - "scale-info", - "serde", - "sp-runtime", - "sp-staking", - "sp-std", -] - -[[package]] -name = "pallet-offences-benchmarking" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-election-provider-support", - "frame-support", - "frame-system", - "log", - "pallet-babe", - "pallet-balances", - "pallet-grandpa", - "pallet-im-online", - "pallet-offences", - "pallet-session", - "pallet-staking", - "parity-scale-codec", - "scale-info", - "sp-runtime", - "sp-staking", - "sp-std", -] - -[[package]] -name = "pallet-parachain-staking" -version = "0.1.0" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "pallet-aura", - "pallet-authorship", - "pallet-balances", - "pallet-session", - "pallet-timestamp", - "parity-scale-codec", - "scale-info", - "serde", - "similar-asserts", - "sp-consensus-aura", - "sp-core", - "sp-io", - "sp-runtime", - "sp-staking", - "sp-std", - "substrate-fixed", -] - -[[package]] -name = "pallet-preimage" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-proxy" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-ranked-collective" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-recovery" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-referenda" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "assert_matches", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "serde", - "sp-arithmetic", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-sandbox" -version = "0.1.0" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "pallet-assets", - "pallet-balances", - "pallet-funding", - "pallet-insecure-randomness-collective-flip", - "parachains-common", - "parity-scale-codec", - "scale-info", - "serde", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-scheduler" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-io", - "sp-runtime", - "sp-std", - "sp-weights", -] - -[[package]] -name = "pallet-session" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-support", - "frame-system", - "impl-trait-for-tuples", - "log", - "pallet-timestamp", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", - "sp-trie", -] - -[[package]] -name = "pallet-session-benchmarking" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "pallet-session", - "pallet-staking", - "rand 0.8.5", - "sp-runtime", - "sp-session", - "sp-std", -] - -[[package]] -name = "pallet-society" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-support", - "frame-system", - "parity-scale-codec", - "rand_chacha 0.2.2", - "scale-info", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-staking" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-election-provider-support", - "frame-support", - "frame-system", - "log", - "pallet-authorship", - "pallet-session", - "parity-scale-codec", - "rand_chacha 0.2.2", - "scale-info", - "serde", - "sp-application-crypto", - "sp-io", - "sp-runtime", - "sp-staking", - "sp-std", -] - -[[package]] -name = "pallet-staking-reward-curve" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "pallet-staking-reward-fn" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "log", - "sp-arithmetic", -] - -[[package]] -name = "pallet-staking-runtime-api" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "parity-scale-codec", - "sp-api", -] - -[[package]] -name = "pallet-state-trie-migration" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-sudo" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-timestamp" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-inherents", - "sp-io", - "sp-runtime", - "sp-std", - "sp-timestamp", -] - -[[package]] -name = "pallet-tips" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "pallet-treasury", - "parity-scale-codec", - "scale-info", - "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-transaction-payment" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-transaction-payment-rpc" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "jsonrpsee", - "pallet-transaction-payment-rpc-runtime-api", - "parity-scale-codec", - "sp-api", - "sp-blockchain", - "sp-core", - "sp-rpc", - "sp-runtime", - "sp-weights", -] - -[[package]] -name = "pallet-transaction-payment-rpc-runtime-api" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "pallet-transaction-payment", - "parity-scale-codec", - "sp-api", - "sp-runtime", - "sp-weights", -] - -[[package]] -name = "pallet-treasury" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "impl-trait-for-tuples", - "pallet-balances", - "parity-scale-codec", - "scale-info", - "serde", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-uniques" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-utility" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-vesting" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-whitelist" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-xcm" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "bounded-collections", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "xcm", - "xcm-executor", -] - -[[package]] -name = "pallet-xcm-benchmarks" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-io", - "sp-runtime", - "sp-std", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "parachain-info" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "cumulus-primitives-core", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "parachains-common" -version = "1.0.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "cumulus-primitives-utility", - "frame-support", - "frame-system", - "pallet-asset-tx-payment", - "pallet-assets", - "pallet-authorship", - "pallet-balances", - "pallet-collator-selection", - "parity-scale-codec", - "polkadot-primitives", - "scale-info", - "sp-consensus-aura", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "parity-db" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59e9ab494af9e6e813c72170f0d3c1de1500990d62c97cc05cc7576f91aa402f" -dependencies = [ - "blake2", - "crc32fast", - "fs2", - "hex", - "libc", - "log", - "lz4", - "memmap2", - "parking_lot 0.12.1", - "rand 0.8.5", - "siphasher", - "snap", -] - -[[package]] -name = "parity-scale-codec" -version = "3.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" -dependencies = [ - "arrayvec 0.7.4", - "bitvec", - "byte-slice-cast", - "bytes", - "impl-trait-for-tuples", - "parity-scale-codec-derive", - "serde", -] - -[[package]] -name = "parity-scale-codec-derive" -version = "3.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "parity-send-wrapper" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" - -[[package]] -name = "parity-wasm" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" - -[[package]] -name = "parking" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" - -[[package]] -name = "parking_lot" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" -dependencies = [ - "instant", - "lock_api", - "parking_lot_core 0.8.6", -] - -[[package]] -name = "parking_lot" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" -dependencies = [ - "lock_api", - "parking_lot_core 0.9.9", -] - -[[package]] -name = "parking_lot_core" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" -dependencies = [ - "cfg-if", - "instant", - "libc", - "redox_syscall 0.2.16", - "smallvec", - "winapi", -] - -[[package]] -name = "parking_lot_core" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall 0.4.1", - "smallvec", - "windows-targets 0.48.5", -] - -[[package]] -name = "partial_sort" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" - -[[package]] -name = "paste" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" - -[[package]] -name = "pbkdf2" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" -dependencies = [ - "crypto-mac 0.11.1", -] - -[[package]] -name = "pbkdf2" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - -[[package]] -name = "pem" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" -dependencies = [ - "base64 0.13.1", -] - -[[package]] -name = "pem-rfc7468" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d159833a9105500e0398934e205e0773f0b27529557134ecfc51c27646adac" -dependencies = [ - "base64ct", -] - -[[package]] -name = "penpal-runtime" -version = "0.9.27" -dependencies = [ - "cumulus-pallet-aura-ext", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-session-benchmarking", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "cumulus-primitives-timestamp", - "cumulus-primitives-utility", - "frame-benchmarking", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal 0.4.1", - "log", - "pallet-asset-tx-payment", - "pallet-assets", - "pallet-aura", - "pallet-authorship", - "pallet-balances", - "pallet-collator-selection", - "pallet-session", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-xcm", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "polimec-receiver", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime-common", - "scale-info", - "smallvec", - "sp-api", - "sp-block-builder", - "sp-consensus-aura", - "sp-core", - "sp-inherents", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "percent-encoding" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" - -[[package]] -name = "pest" -version = "2.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" -dependencies = [ - "memchr", - "thiserror", - "ucd-trie", -] - -[[package]] -name = "pest_derive" -version = "2.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" -dependencies = [ - "pest", - "pest_generator", -] - -[[package]] -name = "pest_generator" -version = "2.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" -dependencies = [ - "pest", - "pest_meta", - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "pest_meta" -version = "2.7.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" -dependencies = [ - "once_cell", - "pest", - "sha2 0.10.8", -] - -[[package]] -name = "petgraph" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" -dependencies = [ - "fixedbitset", - "indexmap 2.0.2", -] - -[[package]] -name = "pin-project" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "pin-project-lite" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" - -[[package]] -name = "pin-project-lite" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pkcs8" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" -dependencies = [ - "der 0.6.1", - "spki 0.6.0", -] - -[[package]] -name = "pkcs8" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" -dependencies = [ - "der 0.7.8", - "spki 0.7.2", -] - -[[package]] -name = "pkg-config" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" - -[[package]] -name = "platforms" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d0eef3571242013a0d5dc84861c3ae4a652e56e12adf8bdc26ff5f8cb34c94" - -[[package]] -name = "platforms" -version = "3.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4503fa043bf02cee09a9582e9554b4c6403b2ef55e4612e96561d294419429f8" - -[[package]] -name = "plotters" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" -dependencies = [ - "num-traits", - "plotters-backend", - "plotters-svg", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "plotters-backend" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" - -[[package]] -name = "plotters-svg" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" -dependencies = [ - "plotters-backend", -] - -[[package]] -name = "polimec-base-runtime" -version = "0.1.0" -dependencies = [ - "cumulus-pallet-aura-ext", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-session-benchmarking", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "cumulus-primitives-timestamp", - "cumulus-primitives-utility", - "frame-benchmarking", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal 0.3.4", - "log", - "pallet-aura", - "pallet-authorship", - "pallet-balances", - "pallet-parachain-staking", - "pallet-session", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-treasury", - "pallet-xcm", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime-common", - "scale-info", - "shared-configuration", - "smallvec", - "sp-api", - "sp-arithmetic", - "sp-block-builder", - "sp-consensus-aura", - "sp-core", - "sp-inherents", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "polimec-parachain-node" -version = "0.1.0" -dependencies = [ - "clap", - "color-print", - "cumulus-client-cli", - "cumulus-client-consensus-aura", - "cumulus-client-consensus-common", - "cumulus-client-network", - "cumulus-client-service", - "cumulus-primitives-core", - "cumulus-primitives-parachain-inherent", - "cumulus-relay-chain-inprocess-interface", - "cumulus-relay-chain-interface", - "cumulus-relay-chain-minimal-node", - "frame-benchmarking", - "frame-benchmarking-cli", - "hex-literal 0.3.4", - "jsonrpsee", - "log", - "pallet-funding", - "pallet-transaction-payment-rpc", - "parachains-common", - "parity-scale-codec", - "polimec-base-runtime", - "polimec-parachain-runtime", - "polkadot-cli", - "polkadot-primitives", - "polkadot-service", - "sc-basic-authorship", - "sc-chain-spec", - "sc-cli", - "sc-client-api", - "sc-consensus", - "sc-executor", - "sc-network", - "sc-network-common", - "sc-network-sync", - "sc-rpc", - "sc-rpc-api", - "sc-service", - "sc-sysinfo", - "sc-telemetry", - "sc-tracing", - "sc-transaction-pool", - "sc-transaction-pool-api", - "serde", - "sp-api", - "sp-block-builder", - "sp-blockchain", - "sp-consensus-aura", - "sp-core", - "sp-io", - "sp-keystore", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-timestamp", - "sp-transaction-pool", - "substrate-build-script-utils", - "substrate-frame-rpc-system", - "substrate-prometheus-endpoint", - "try-runtime-cli", - "xcm", -] - -[[package]] -name = "polimec-parachain-runtime" -version = "0.1.0" -dependencies = [ - "cumulus-pallet-aura-ext", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-session-benchmarking", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "cumulus-primitives-timestamp", - "cumulus-primitives-utility", - "frame-benchmarking", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal 0.3.4", - "log", - "pallet-asset-tx-payment", - "pallet-assets", - "pallet-aura", - "pallet-authorship", - "pallet-balances", - "pallet-collective", - "pallet-democracy", - "pallet-funding", - "pallet-insecure-randomness-collective-flip", - "pallet-linear-release", - "pallet-multisig", - "pallet-parachain-staking", - "pallet-preimage", - "pallet-scheduler", - "pallet-session", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-treasury", - "pallet-utility", - "pallet-vesting", - "pallet-xcm", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "polimec-xcm-executor", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime-common", - "scale-info", - "serde", - "shared-configuration", - "smallvec", - "sp-api", - "sp-block-builder", - "sp-consensus-aura", - "sp-core", - "sp-inherents", - "sp-io", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "polimec-standalone-node" -version = "0.1.0" -dependencies = [ - "clap", - "frame-benchmarking", - "frame-benchmarking-cli", - "frame-system", - "futures", - "jsonrpsee", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc", - "polimec-standalone-runtime", - "sc-basic-authorship", - "sc-chain-spec", - "sc-cli", - "sc-client-api", - "sc-consensus", - "sc-consensus-aura", - "sc-consensus-grandpa", - "sc-executor", - "sc-keystore", - "sc-network", - "sc-rpc", - "sc-rpc-api", - "sc-service", - "sc-telemetry", - "sc-transaction-pool", - "sc-transaction-pool-api", - "serde", - "sp-api", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-consensus-aura", - "sp-consensus-grandpa", - "sp-core", - "sp-inherents", - "sp-io", - "sp-keyring", - "sp-runtime", - "sp-timestamp", - "substrate-build-script-utils", - "substrate-frame-rpc-system", - "try-runtime-cli", -] - -[[package]] -name = "polimec-standalone-runtime" -version = "0.1.0" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "polimec-xcm-executor" -version = "0.1.0" -dependencies = [ - "environmental", - "frame-benchmarking", - "frame-support", - "impl-trait-for-tuples", - "log", - "parity-scale-codec", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "sp-weights", - "xcm", - "xcm-executor", -] - -[[package]] -name = "polkadot-approval-distribution" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "futures", - "polkadot-node-jaeger", - "polkadot-node-metrics", - "polkadot-node-network-protocol", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-primitives", - "rand 0.8.5", - "tracing-gum", -] - -[[package]] -name = "polkadot-availability-bitfield-distribution" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "futures", - "polkadot-node-network-protocol", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "rand 0.8.5", - "tracing-gum", -] - -[[package]] -name = "polkadot-availability-distribution" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "derive_more", - "fatality", - "futures", - "lru 0.9.0", - "parity-scale-codec", - "polkadot-erasure-coding", - "polkadot-node-network-protocol", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "rand 0.8.5", - "sp-core", - "sp-keystore", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-availability-recovery" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "fatality", - "futures", - "lru 0.9.0", - "parity-scale-codec", - "polkadot-erasure-coding", - "polkadot-node-network-protocol", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "rand 0.8.5", - "sc-network", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-cli" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "clap", - "frame-benchmarking-cli", - "futures", - "log", - "polkadot-client", - "polkadot-node-core-pvf-worker", - "polkadot-node-metrics", - "polkadot-performance-test", - "polkadot-service", - "sc-cli", - "sc-executor", - "sc-service", - "sc-storage-monitor", - "sc-sysinfo", - "sc-tracing", - "sp-core", - "sp-io", - "sp-keyring", - "sp-maybe-compressed-blob", - "substrate-build-script-utils", - "thiserror", - "try-runtime-cli", -] - -[[package]] -name = "polkadot-client" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "async-trait", - "frame-benchmarking", - "frame-benchmarking-cli", - "frame-system", - "frame-system-rpc-runtime-api", - "futures", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "polkadot-core-primitives", - "polkadot-node-core-parachains-inherent", - "polkadot-primitives", - "polkadot-runtime", - "polkadot-runtime-common", - "sc-client-api", - "sc-consensus", - "sc-executor", - "sc-service", - "sp-api", - "sp-authority-discovery", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-consensus-grandpa", - "sp-core", - "sp-inherents", - "sp-keyring", - "sp-mmr-primitives", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-storage", - "sp-timestamp", - "sp-transaction-pool", -] - -[[package]] -name = "polkadot-collator-protocol" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "always-assert", - "bitvec", - "fatality", - "futures", - "futures-timer", - "polkadot-node-network-protocol", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "sp-core", - "sp-keystore", - "sp-runtime", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-core-primitives" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "polkadot-dispute-distribution" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "derive_more", - "fatality", - "futures", - "futures-timer", - "indexmap 1.9.3", - "lru 0.9.0", - "parity-scale-codec", - "polkadot-erasure-coding", - "polkadot-node-network-protocol", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "sc-network", - "sp-application-crypto", - "sp-keystore", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-erasure-coding" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "parity-scale-codec", - "polkadot-node-primitives", - "polkadot-primitives", - "reed-solomon-novelpoly", - "sp-core", - "sp-trie", - "thiserror", -] - -[[package]] -name = "polkadot-gossip-support" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "futures", - "futures-timer", - "polkadot-node-network-protocol", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "rand 0.8.5", - "rand_chacha 0.3.1", - "sc-network", - "sp-application-crypto", - "sp-core", - "sp-keystore", - "tracing-gum", -] - -[[package]] -name = "polkadot-network-bridge" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "always-assert", - "async-trait", - "bytes", - "fatality", - "futures", - "parity-scale-codec", - "parking_lot 0.12.1", - "polkadot-node-metrics", - "polkadot-node-network-protocol", - "polkadot-node-subsystem", - "polkadot-overseer", - "polkadot-primitives", - "sc-network", - "sp-consensus", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-collation-generation" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "futures", - "parity-scale-codec", - "polkadot-erasure-coding", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "sp-core", - "sp-maybe-compressed-blob", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-approval-voting" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "bitvec", - "derive_more", - "futures", - "futures-timer", - "kvdb", - "lru 0.9.0", - "merlin", - "parity-scale-codec", - "polkadot-node-jaeger", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-overseer", - "polkadot-primitives", - "sc-keystore", - "schnorrkel", - "sp-application-crypto", - "sp-consensus", - "sp-consensus-slots", - "sp-runtime", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-av-store" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "bitvec", - "futures", - "futures-timer", - "kvdb", - "parity-scale-codec", - "polkadot-erasure-coding", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-overseer", - "polkadot-primitives", - "sp-consensus", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-backing" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "bitvec", - "fatality", - "futures", - "polkadot-erasure-coding", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "polkadot-statement-table", - "sp-keystore", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-bitfield-signing" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "futures", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "sp-keystore", - "thiserror", - "tracing-gum", - "wasm-timer", -] - -[[package]] -name = "polkadot-node-core-candidate-validation" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "async-trait", - "futures", - "futures-timer", - "parity-scale-codec", - "polkadot-node-core-pvf", - "polkadot-node-metrics", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-parachain", - "polkadot-primitives", - "sp-maybe-compressed-blob", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-chain-api" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "futures", - "polkadot-node-metrics", - "polkadot-node-subsystem", - "polkadot-primitives", - "sc-client-api", - "sc-consensus-babe", - "sp-blockchain", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-chain-selection" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "futures", - "futures-timer", - "kvdb", - "parity-scale-codec", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-dispute-coordinator" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "fatality", - "futures", - "kvdb", - "lru 0.9.0", - "parity-scale-codec", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "sc-keystore", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-parachains-inherent" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "async-trait", - "futures", - "futures-timer", - "polkadot-node-subsystem", - "polkadot-overseer", - "polkadot-primitives", - "sp-blockchain", - "sp-inherents", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-provisioner" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "bitvec", - "fatality", - "futures", - "futures-timer", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "rand 0.8.5", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-pvf" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "always-assert", - "futures", - "futures-timer", - "libc", - "parity-scale-codec", - "pin-project", - "polkadot-core-primitives", - "polkadot-node-metrics", - "polkadot-node-primitives", - "polkadot-parachain", - "polkadot-primitives", - "rand 0.8.5", - "slotmap", - "sp-core", - "sp-maybe-compressed-blob", - "sp-tracing", - "sp-wasm-interface", - "substrate-build-script-utils", - "tokio", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-pvf-checker" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "futures", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-overseer", - "polkadot-primitives", - "sp-keystore", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-pvf-worker" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "assert_matches", - "cpu-time", - "futures", - "libc", - "parity-scale-codec", - "polkadot-node-core-pvf", - "polkadot-parachain", - "polkadot-primitives", - "rayon", - "sc-executor", - "sc-executor-common", - "sc-executor-wasmtime", - "sp-core", - "sp-externalities", - "sp-io", - "sp-maybe-compressed-blob", - "sp-tracing", - "substrate-build-script-utils", - "tempfile", - "tikv-jemalloc-ctl", - "tokio", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-core-runtime-api" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "futures", - "lru 0.9.0", - "polkadot-node-metrics", - "polkadot-node-subsystem", - "polkadot-node-subsystem-types", - "polkadot-primitives", - "sp-consensus-babe", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-jaeger" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "lazy_static", - "log", - "mick-jaeger", - "parity-scale-codec", - "parking_lot 0.12.1", - "polkadot-node-primitives", - "polkadot-primitives", - "sc-network", - "sp-core", - "thiserror", - "tokio", -] - -[[package]] -name = "polkadot-node-metrics" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "bs58", - "futures", - "futures-timer", - "log", - "parity-scale-codec", - "polkadot-primitives", - "prioritized-metered-channel", - "sc-cli", - "sc-service", - "sc-tracing", - "substrate-prometheus-endpoint", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-network-protocol" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "async-channel", - "async-trait", - "derive_more", - "fatality", - "futures", - "hex", - "parity-scale-codec", - "polkadot-node-jaeger", - "polkadot-node-primitives", - "polkadot-primitives", - "rand 0.8.5", - "sc-authority-discovery", - "sc-network", - "strum", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-node-primitives" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "bounded-vec", - "futures", - "parity-scale-codec", - "polkadot-parachain", - "polkadot-primitives", - "schnorrkel", - "serde", - "sp-application-crypto", - "sp-consensus-babe", - "sp-core", - "sp-keystore", - "sp-maybe-compressed-blob", - "sp-runtime", - "thiserror", - "zstd 0.11.2+zstd.1.5.2", -] - -[[package]] -name = "polkadot-node-subsystem" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "polkadot-node-jaeger", - "polkadot-node-subsystem-types", - "polkadot-overseer", -] - -[[package]] -name = "polkadot-node-subsystem-types" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "async-trait", - "derive_more", - "futures", - "orchestra", - "polkadot-node-jaeger", - "polkadot-node-network-protocol", - "polkadot-node-primitives", - "polkadot-primitives", - "polkadot-statement-table", - "sc-network", - "smallvec", - "sp-api", - "sp-authority-discovery", - "sp-consensus-babe", - "substrate-prometheus-endpoint", - "thiserror", -] - -[[package]] -name = "polkadot-node-subsystem-util" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "async-trait", - "derive_more", - "fatality", - "futures", - "futures-channel", - "itertools 0.10.5", - "kvdb", - "lru 0.9.0", - "parity-db", - "parity-scale-codec", - "parking_lot 0.11.2", - "pin-project", - "polkadot-node-jaeger", - "polkadot-node-metrics", - "polkadot-node-network-protocol", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-overseer", - "polkadot-primitives", - "prioritized-metered-channel", - "rand 0.8.5", - "sp-application-crypto", - "sp-core", - "sp-keystore", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-overseer" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "async-trait", - "futures", - "futures-timer", - "lru 0.9.0", - "orchestra", - "parking_lot 0.12.1", - "polkadot-node-metrics", - "polkadot-node-network-protocol", - "polkadot-node-primitives", - "polkadot-node-subsystem-types", - "polkadot-primitives", - "sc-client-api", - "sp-api", - "sp-core", - "tikv-jemalloc-ctl", - "tracing-gum", -] - -[[package]] -name = "polkadot-parachain" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "bounded-collections", - "derive_more", - "frame-support", - "parity-scale-codec", - "polkadot-core-primitives", - "scale-info", - "serde", - "sp-core", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "polkadot-performance-test" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "env_logger 0.9.3", - "kusama-runtime", - "log", - "polkadot-erasure-coding", - "polkadot-node-core-pvf-worker", - "polkadot-node-primitives", - "polkadot-primitives", - "quote", - "sc-executor-common", - "sp-maybe-compressed-blob", - "thiserror", -] - -[[package]] -name = "polkadot-primitives" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "bitvec", - "hex-literal 0.4.1", - "parity-scale-codec", - "polkadot-core-primitives", - "polkadot-parachain", - "scale-info", - "serde", - "sp-api", - "sp-application-crypto", - "sp-arithmetic", - "sp-authority-discovery", - "sp-consensus-slots", - "sp-core", - "sp-inherents", - "sp-io", - "sp-keystore", - "sp-runtime", - "sp-staking", - "sp-std", -] - -[[package]] -name = "polkadot-rpc" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "jsonrpsee", - "mmr-rpc", - "pallet-transaction-payment-rpc", - "polkadot-primitives", - "sc-chain-spec", - "sc-client-api", - "sc-consensus-babe", - "sc-consensus-babe-rpc", - "sc-consensus-beefy", - "sc-consensus-beefy-rpc", - "sc-consensus-epochs", - "sc-consensus-grandpa", - "sc-consensus-grandpa-rpc", - "sc-rpc", - "sc-sync-state-rpc", - "sc-transaction-pool-api", - "sp-api", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-keystore", - "sp-runtime", - "substrate-frame-rpc-system", - "substrate-state-trie-migration-rpc", -] - -[[package]] -name = "polkadot-runtime" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "bitvec", - "frame-benchmarking", - "frame-election-provider-support", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal 0.4.1", - "log", - "pallet-authority-discovery", - "pallet-authorship", - "pallet-babe", - "pallet-bags-list", - "pallet-balances", - "pallet-bounties", - "pallet-child-bounties", - "pallet-collective", - "pallet-conviction-voting", - "pallet-democracy", - "pallet-election-provider-multi-phase", - "pallet-election-provider-support-benchmarking", - "pallet-elections-phragmen", - "pallet-fast-unstake", - "pallet-grandpa", - "pallet-identity", - "pallet-im-online", - "pallet-indices", - "pallet-membership", - "pallet-message-queue", - "pallet-multisig", - "pallet-nomination-pools", - "pallet-nomination-pools-benchmarking", - "pallet-nomination-pools-runtime-api", - "pallet-offences", - "pallet-offences-benchmarking", - "pallet-preimage", - "pallet-proxy", - "pallet-referenda", - "pallet-scheduler", - "pallet-session", - "pallet-session-benchmarking", - "pallet-staking", - "pallet-staking-reward-curve", - "pallet-staking-runtime-api", - "pallet-timestamp", - "pallet-tips", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-treasury", - "pallet-utility", - "pallet-vesting", - "pallet-whitelist", - "pallet-xcm", - "parity-scale-codec", - "polkadot-primitives", - "polkadot-runtime-common", - "polkadot-runtime-constants", - "polkadot-runtime-parachains", - "rustc-hex", - "scale-info", - "serde", - "serde_derive", - "smallvec", - "sp-api", - "sp-arithmetic", - "sp-authority-discovery", - "sp-block-builder", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-core", - "sp-inherents", - "sp-io", - "sp-mmr-primitives", - "sp-npos-elections", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", - "sp-transaction-pool", - "sp-version", - "static_assertions", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "polkadot-runtime-common" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "bitvec", - "frame-benchmarking", - "frame-election-provider-support", - "frame-support", - "frame-system", - "impl-trait-for-tuples", - "libsecp256k1", - "log", - "pallet-authorship", - "pallet-babe", - "pallet-balances", - "pallet-election-provider-multi-phase", - "pallet-fast-unstake", - "pallet-session", - "pallet-staking", - "pallet-staking-reward-fn", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-treasury", - "pallet-vesting", - "parity-scale-codec", - "polkadot-primitives", - "polkadot-runtime-parachains", - "rustc-hex", - "scale-info", - "serde", - "serde_derive", - "slot-range-helper", - "sp-api", - "sp-core", - "sp-inherents", - "sp-io", - "sp-npos-elections", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", - "static_assertions", - "xcm", -] - -[[package]] -name = "polkadot-runtime-constants" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "frame-support", - "polkadot-primitives", - "polkadot-runtime-common", - "smallvec", - "sp-core", - "sp-runtime", - "sp-weights", -] - -[[package]] -name = "polkadot-runtime-metrics" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "bs58", - "parity-scale-codec", - "polkadot-primitives", - "sp-std", - "sp-tracing", -] - -[[package]] -name = "polkadot-runtime-parachains" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "bitflags 1.3.2", - "bitvec", - "derive_more", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "pallet-authority-discovery", - "pallet-authorship", - "pallet-babe", - "pallet-balances", - "pallet-message-queue", - "pallet-session", - "pallet-staking", - "pallet-timestamp", - "pallet-vesting", - "parity-scale-codec", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime-metrics", - "rand 0.8.5", - "rand_chacha 0.3.1", - "rustc-hex", - "scale-info", - "serde", - "sp-api", - "sp-application-crypto", - "sp-core", - "sp-inherents", - "sp-io", - "sp-keystore", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", - "static_assertions", - "xcm", - "xcm-executor", -] - -[[package]] -name = "polkadot-service" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "async-trait", - "frame-benchmarking-cli", - "frame-support", - "frame-system-rpc-runtime-api", - "futures", - "hex-literal 0.4.1", - "kusama-runtime", - "kvdb", - "kvdb-rocksdb", - "log", - "lru 0.9.0", - "mmr-gadget", - "pallet-babe", - "pallet-im-online", - "pallet-staking", - "pallet-transaction-payment-rpc-runtime-api", - "parity-db", - "polkadot-approval-distribution", - "polkadot-availability-bitfield-distribution", - "polkadot-availability-distribution", - "polkadot-availability-recovery", - "polkadot-client", - "polkadot-collator-protocol", - "polkadot-dispute-distribution", - "polkadot-gossip-support", - "polkadot-network-bridge", - "polkadot-node-collation-generation", - "polkadot-node-core-approval-voting", - "polkadot-node-core-av-store", - "polkadot-node-core-backing", - "polkadot-node-core-bitfield-signing", - "polkadot-node-core-candidate-validation", - "polkadot-node-core-chain-api", - "polkadot-node-core-chain-selection", - "polkadot-node-core-dispute-coordinator", - "polkadot-node-core-parachains-inherent", - "polkadot-node-core-provisioner", - "polkadot-node-core-pvf-checker", - "polkadot-node-core-runtime-api", - "polkadot-node-network-protocol", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-types", - "polkadot-node-subsystem-util", - "polkadot-overseer", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-rpc", - "polkadot-runtime", - "polkadot-runtime-constants", - "polkadot-runtime-parachains", - "polkadot-statement-distribution", - "rococo-runtime", - "sc-authority-discovery", - "sc-basic-authorship", - "sc-block-builder", - "sc-chain-spec", - "sc-client-api", - "sc-client-db", - "sc-consensus", - "sc-consensus-babe", - "sc-consensus-beefy", - "sc-consensus-grandpa", - "sc-consensus-slots", - "sc-executor", - "sc-keystore", - "sc-network", - "sc-network-common", - "sc-network-sync", - "sc-offchain", - "sc-service", - "sc-sync-state-rpc", - "sc-sysinfo", - "sc-telemetry", - "sc-transaction-pool", - "serde", - "serde_json", - "sp-api", - "sp-authority-discovery", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-consensus-grandpa", - "sp-core", - "sp-inherents", - "sp-io", - "sp-keystore", - "sp-mmr-primitives", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-state-machine", - "sp-storage", - "sp-timestamp", - "sp-transaction-pool", - "sp-trie", - "substrate-prometheus-endpoint", - "thiserror", - "tracing-gum", - "westend-runtime", -] - -[[package]] -name = "polkadot-statement-distribution" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "arrayvec 0.5.2", - "fatality", - "futures", - "indexmap 1.9.3", - "parity-scale-codec", - "polkadot-node-network-protocol", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-node-subsystem-util", - "polkadot-primitives", - "sp-keystore", - "sp-staking", - "thiserror", - "tracing-gum", -] - -[[package]] -name = "polkadot-statement-table" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "parity-scale-codec", - "polkadot-primitives", - "sp-core", -] - -[[package]] -name = "polkadot-test-runtime" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "bitvec", - "frame-election-provider-support", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-rpc-runtime-api", - "log", - "pallet-authority-discovery", - "pallet-authorship", - "pallet-babe", - "pallet-balances", - "pallet-grandpa", - "pallet-indices", - "pallet-offences", - "pallet-session", - "pallet-staking", - "pallet-staking-reward-curve", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-vesting", - "pallet-xcm", - "parity-scale-codec", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "rustc-hex", - "scale-info", - "serde", - "serde_derive", - "smallvec", - "sp-api", - "sp-authority-discovery", - "sp-block-builder", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-core", - "sp-inherents", - "sp-io", - "sp-mmr-primitives", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", - "test-runtime-constants", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "polkadot-test-service" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "frame-benchmarking", - "frame-system", - "futures", - "hex", - "pallet-balances", - "pallet-staking", - "pallet-transaction-payment", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-overseer", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-rpc", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "polkadot-service", - "polkadot-test-runtime", - "rand 0.8.5", - "sc-authority-discovery", - "sc-chain-spec", - "sc-cli", - "sc-client-api", - "sc-consensus", - "sc-consensus-babe", - "sc-consensus-grandpa", - "sc-executor", - "sc-network", - "sc-service", - "sc-tracing", - "sc-transaction-pool", - "sp-arithmetic", - "sp-authority-discovery", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-consensus-grandpa", - "sp-core", - "sp-inherents", - "sp-keyring", - "sp-runtime", - "sp-state-machine", - "substrate-test-client", - "tempfile", - "test-runtime-constants", - "tokio", - "tracing-gum", -] - -[[package]] -name = "polling" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" -dependencies = [ - "autocfg", - "bitflags 1.3.2", - "cfg-if", - "concurrent-queue", - "libc", - "log", - "pin-project-lite 0.2.13", - "windows-sys 0.48.0", -] - -[[package]] -name = "poly1305" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" -dependencies = [ - "cpufeatures", - "opaque-debug 0.3.0", - "universal-hash 0.4.1", -] - -[[package]] -name = "polyval" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" -dependencies = [ - "cfg-if", - "cpufeatures", - "opaque-debug 0.3.0", - "universal-hash 0.4.1", -] - -[[package]] -name = "polyval" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52cff9d1d4dee5fe6d03729099f4a310a41179e0a10dbf542039873f2e826fb" -dependencies = [ - "cfg-if", - "cpufeatures", - "opaque-debug 0.3.0", - "universal-hash 0.5.1", -] - -[[package]] -name = "portable-atomic" -version = "1.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b" - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - -[[package]] -name = "predicates" -version = "2.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59230a63c37f3e18569bdb90e4a89cbf5bf8b06fea0b84e65ea10cc4df47addd" -dependencies = [ - "difflib", - "float-cmp", - "itertools 0.10.5", - "normalize-line-endings", - "predicates-core", - "regex", -] - -[[package]] -name = "predicates-core" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" - -[[package]] -name = "predicates-tree" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" -dependencies = [ - "predicates-core", - "termtree", -] - -[[package]] -name = "prettyplease" -version = "0.1.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" -dependencies = [ - "proc-macro2", - "syn 1.0.109", -] - -[[package]] -name = "prettyplease" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" -dependencies = [ - "proc-macro2", - "syn 2.0.38", -] - -[[package]] -name = "primitive-types" -version = "0.12.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" -dependencies = [ - "fixed-hash", - "impl-codec", - "impl-serde", - "scale-info", - "uint", -] - -[[package]] -name = "prioritized-metered-channel" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "382698e48a268c832d0b181ed438374a6bb708a82a8ca273bb0f61c74cf209c4" -dependencies = [ - "coarsetime", - "crossbeam-queue", - "derive_more", - "futures", - "futures-timer", - "nanorand", - "thiserror", - "tracing", -] - -[[package]] -name = "proc-macro-crate" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" -dependencies = [ - "once_cell", - "toml_edit", -] - -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn 1.0.109", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - -[[package]] -name = "proc-macro-warning" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e99670bafb56b9a106419397343bdbc8b8742c3cc449fec6345f86173f47cd4" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "proc-macro2" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "prometheus" -version = "0.13.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "449811d15fbdf5ceb5c1144416066429cf82316e2ec8ce0c1f6f8a02e7bbcf8c" -dependencies = [ - "cfg-if", - "fnv", - "lazy_static", - "memchr", - "parking_lot 0.12.1", - "thiserror", -] - -[[package]] -name = "prometheus-client" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6fa99d535dd930d1249e6c79cb3c2915f9172a540fe2b02a4c8f9ca954721e" -dependencies = [ - "dtoa", - "itoa", - "parking_lot 0.12.1", - "prometheus-client-derive-encode", -] - -[[package]] -name = "prometheus-client-derive-encode" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "prost" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-build" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" -dependencies = [ - "bytes", - "heck", - "itertools 0.10.5", - "lazy_static", - "log", - "multimap", - "petgraph", - "prettyplease 0.1.25", - "prost", - "prost-types", - "regex", - "syn 1.0.109", - "tempfile", - "which", -] - -[[package]] -name = "prost-derive" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" -dependencies = [ - "anyhow", - "itertools 0.10.5", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "prost-types" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" -dependencies = [ - "prost", -] - -[[package]] -name = "psm" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" -dependencies = [ - "cc", -] - -[[package]] -name = "quick-error" -version = "1.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" - -[[package]] -name = "quick-protobuf" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6da84cc204722a989e01ba2f6e1e276e190f22263d0cb6ce8526fcdb0d2e1f" -dependencies = [ - "byteorder", -] - -[[package]] -name = "quick-protobuf-codec" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1693116345026436eb2f10b677806169c1a1260c1c60eaaffe3fb5a29ae23d8b" -dependencies = [ - "asynchronous-codec", - "bytes", - "quick-protobuf", - "thiserror", - "unsigned-varint", -] - -[[package]] -name = "quicksink" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77de3c815e5a160b1539c6592796801df2043ae35e123b46d73380cfa57af858" -dependencies = [ - "futures-core", - "futures-sink", - "pin-project-lite 0.1.12", -] - -[[package]] -name = "quinn-proto" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b0b33c13a79f669c85defaf4c275dc86a0c0372807d0ca3d78e0bb87274863" -dependencies = [ - "bytes", - "rand 0.8.5", - "ring 0.16.20", - "rustc-hash", - "rustls 0.20.9", - "slab", - "thiserror", - "tinyvec", - "tracing", - "webpki 0.22.4", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.4", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom 0.2.10", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", -] - -[[package]] -name = "rand_pcg" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59cad018caf63deb318e5a4586d99a24424a364f40f1e5778c29aca23f4fc73e" -dependencies = [ - "rand_core 0.6.4", -] - -[[package]] -name = "rawpointer" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" - -[[package]] -name = "rayon" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" -dependencies = [ - "crossbeam-deque", - "crossbeam-utils", -] - -[[package]] -name = "rcgen" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" -dependencies = [ - "pem", - "ring 0.16.20", - "time", - "x509-parser 0.13.2", - "yasna", -] - -[[package]] -name = "rcgen" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" -dependencies = [ - "pem", - "ring 0.16.20", - "time", - "yasna", -] - -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_syscall" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_syscall" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" -dependencies = [ - "bitflags 1.3.2", -] - -[[package]] -name = "redox_users" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" -dependencies = [ - "getrandom 0.2.10", - "redox_syscall 0.2.16", - "thiserror", -] - -[[package]] -name = "reed-solomon-novelpoly" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58130877ca403ab42c864fbac74bb319a0746c07a634a92a5cfc7f54af272582" -dependencies = [ - "derive_more", - "fs-err", - "itertools 0.11.0", - "static_init", - "thiserror", -] - -[[package]] -name = "ref-cast" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acde58d073e9c79da00f2b5b84eed919c8326832648a5b109b3fce1bb1175280" -dependencies = [ - "ref-cast-impl", -] - -[[package]] -name = "ref-cast-impl" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7473c2cfcf90008193dd0e3e16599455cb601a9fce322b5bb55de799664925" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "regalloc2" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80535183cae11b149d618fbd3c37e38d7cda589d82d7769e196ca9a9042d7621" -dependencies = [ - "fxhash", - "log", - "slice-group-by", - "smallvec", -] - -[[package]] -name = "regex" -version = "1.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata 0.4.3", - "regex-syntax 0.8.2", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", -] - -[[package]] -name = "regex-automata" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax 0.8.2", -] - -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - -[[package]] -name = "regex-syntax" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" - -[[package]] -name = "resolv-conf" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" -dependencies = [ - "hostname", - "quick-error", -] - -[[package]] -name = "rfc6979" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" -dependencies = [ - "crypto-bigint 0.4.9", - "hmac 0.12.1", - "zeroize", -] - -[[package]] -name = "rfc6979" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" -dependencies = [ - "hmac 0.12.1", - "subtle", -] - -[[package]] -name = "ring" -version = "0.16.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" -dependencies = [ - "cc", - "libc", - "once_cell", - "spin 0.5.2", - "untrusted 0.7.1", - "web-sys", - "winapi", -] - -[[package]] -name = "ring" -version = "0.17.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" -dependencies = [ - "cc", - "getrandom 0.2.10", - "libc", - "spin 0.9.8", - "untrusted 0.9.0", - "windows-sys 0.48.0", -] - -[[package]] -name = "rocksdb" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb6f170a4041d50a0ce04b0d2e14916d6ca863ea2e422689a5b694395d299ffe" -dependencies = [ - "libc", - "librocksdb-sys", -] - -[[package]] -name = "rococo-runtime" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "binary-merkle-tree", - "frame-benchmarking", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal 0.4.1", - "log", - "pallet-authority-discovery", - "pallet-authorship", - "pallet-babe", - "pallet-balances", - "pallet-beefy", - "pallet-beefy-mmr", - "pallet-bounties", - "pallet-child-bounties", - "pallet-collective", - "pallet-democracy", - "pallet-elections-phragmen", - "pallet-grandpa", - "pallet-identity", - "pallet-im-online", - "pallet-indices", - "pallet-membership", - "pallet-message-queue", - "pallet-mmr", - "pallet-multisig", - "pallet-nis", - "pallet-offences", - "pallet-preimage", - "pallet-proxy", - "pallet-recovery", - "pallet-scheduler", - "pallet-session", - "pallet-society", - "pallet-staking", - "pallet-state-trie-migration", - "pallet-sudo", - "pallet-timestamp", - "pallet-tips", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-treasury", - "pallet-utility", - "pallet-vesting", - "pallet-xcm", - "pallet-xcm-benchmarks", - "parity-scale-codec", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "rococo-runtime-constants", - "scale-info", - "serde", - "serde_derive", - "smallvec", - "sp-api", - "sp-authority-discovery", - "sp-block-builder", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-core", - "sp-inherents", - "sp-io", - "sp-mmr-primitives", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", - "sp-transaction-pool", - "sp-version", - "static_assertions", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "rococo-runtime-constants" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "frame-support", - "polkadot-primitives", - "polkadot-runtime-common", - "smallvec", - "sp-core", - "sp-runtime", - "sp-weights", -] - -[[package]] -name = "rpassword" -version = "7.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6678cf63ab3491898c0d021b493c94c9b221d91295294a2a5746eacbe5928322" -dependencies = [ - "libc", - "rtoolbox", - "winapi", -] - -[[package]] -name = "rtcp" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1919efd6d4a6a85d13388f9487549bb8e359f17198cc03ffd72f79b553873691" -dependencies = [ - "bytes", - "thiserror", - "webrtc-util", -] - -[[package]] -name = "rtnetlink" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322c53fd76a18698f1c27381d58091de3a043d356aa5bd0d510608b565f469a0" -dependencies = [ - "futures", - "log", - "netlink-packet-route", - "netlink-proto", - "nix", - "thiserror", - "tokio", -] - -[[package]] -name = "rtoolbox" -version = "0.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034e22c514f5c0cb8a10ff341b9b048b5ceb21591f31c8f44c43b960f9b3524a" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "rtp" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2a095411ff00eed7b12e4c6a118ba984d113e1079582570d56a5ee723f11f80" -dependencies = [ - "async-trait", - "bytes", - "rand 0.8.5", - "serde", - "thiserror", - "webrtc-util", -] - -[[package]] -name = "rustc-demangle" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - -[[package]] -name = "rustc-hex" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver 0.9.0", -] - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver 1.0.20", -] - -[[package]] -name = "rusticata-macros" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" -dependencies = [ - "nom", -] - -[[package]] -name = "rustix" -version = "0.36.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "305efbd14fde4139eb501df5f136994bb520b033fa9fbdce287507dc23b8c7ed" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.1.4", - "windows-sys 0.45.0", -] - -[[package]] -name = "rustix" -version = "0.37.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.8", - "windows-sys 0.48.0", -] - -[[package]] -name = "rustix" -version = "0.38.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" -dependencies = [ - "bitflags 2.4.1", - "errno", - "libc", - "linux-raw-sys 0.4.10", - "windows-sys 0.48.0", -] - -[[package]] -name = "rustls" -version = "0.19.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" -dependencies = [ - "base64 0.13.1", - "log", - "ring 0.16.20", - "sct 0.6.1", - "webpki 0.21.4", -] - -[[package]] -name = "rustls" -version = "0.20.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" -dependencies = [ - "log", - "ring 0.16.20", - "sct 0.7.1", - "webpki 0.22.4", -] - -[[package]] -name = "rustls" -version = "0.21.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" -dependencies = [ - "log", - "ring 0.17.5", - "rustls-webpki", - "sct 0.7.1", -] - -[[package]] -name = "rustls-native-certs" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" -dependencies = [ - "openssl-probe", - "rustls-pemfile", - "schannel", - "security-framework", -] - -[[package]] -name = "rustls-pemfile" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" -dependencies = [ - "base64 0.21.5", -] - -[[package]] -name = "rustls-webpki" -version = "0.101.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" -dependencies = [ - "ring 0.17.5", - "untrusted 0.9.0", -] - -[[package]] -name = "rustversion" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" - -[[package]] -name = "rw-stream-sink" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26338f5e09bb721b85b135ea05af7767c90b52f6de4f087d4f4a3a9d64e7dc04" -dependencies = [ - "futures", - "pin-project", - "static_assertions", -] - -[[package]] -name = "ryu" -version = "1.0.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" - -[[package]] -name = "safe-mix" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d3d055a2582e6b00ed7a31c1524040aa391092bf636328350813f3a0605215c" -dependencies = [ - "rustc_version 0.2.3", -] - -[[package]] -name = "safe_arch" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f398075ce1e6a179b46f51bd88d0598b92b00d3551f1a2d4ac49e771b56ac354" -dependencies = [ - "bytemuck", -] - -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "sc-allocator" -version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "log", - "sp-core", - "sp-wasm-interface", - "thiserror", -] - -[[package]] -name = "sc-authority-discovery" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "async-trait", - "futures", - "futures-timer", - "ip_network", - "libp2p", - "log", - "multihash 0.17.0", - "parity-scale-codec", - "prost", - "prost-build", - "rand 0.8.5", - "sc-client-api", - "sc-network", - "sc-network-common", - "sp-api", - "sp-authority-discovery", - "sp-blockchain", - "sp-core", - "sp-keystore", - "sp-runtime", - "substrate-prometheus-endpoint", - "thiserror", -] - -[[package]] -name = "sc-basic-authorship" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "futures", - "futures-timer", - "log", - "parity-scale-codec", - "sc-block-builder", - "sc-client-api", - "sc-proposer-metrics", - "sc-telemetry", - "sc-transaction-pool-api", - "sp-api", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-inherents", - "sp-runtime", - "substrate-prometheus-endpoint", -] - -[[package]] -name = "sc-block-builder" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "parity-scale-codec", - "sc-client-api", - "sp-api", - "sp-block-builder", - "sp-blockchain", - "sp-core", - "sp-inherents", - "sp-runtime", -] - -[[package]] -name = "sc-chain-spec" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "memmap2", - "sc-chain-spec-derive", - "sc-client-api", - "sc-executor", - "sc-network", - "sc-telemetry", - "serde", - "serde_json", - "sp-blockchain", - "sp-core", - "sp-runtime", - "sp-state-machine", -] - -[[package]] -name = "sc-chain-spec-derive" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "sc-cli" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "array-bytes 4.2.0", - "chrono", - "clap", - "fdlimit", - "futures", - "libp2p-identity", - "log", - "names", - "parity-scale-codec", - "rand 0.8.5", - "regex", - "rpassword", - "sc-client-api", - "sc-client-db", - "sc-keystore", - "sc-network", - "sc-network-common", - "sc-service", - "sc-telemetry", - "sc-tracing", - "sc-utils", - "serde", - "serde_json", - "sp-blockchain", - "sp-core", - "sp-keyring", - "sp-keystore", - "sp-panic-handler", - "sp-runtime", - "sp-version", - "thiserror", - "tiny-bip39", - "tokio", -] - -[[package]] -name = "sc-client-api" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "fnv", - "futures", - "log", - "parity-scale-codec", - "parking_lot 0.12.1", - "sc-executor", - "sc-transaction-pool-api", - "sc-utils", - "sp-api", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-database", - "sp-externalities", - "sp-keystore", - "sp-runtime", - "sp-state-machine", - "sp-statement-store", - "sp-storage", - "substrate-prometheus-endpoint", -] - -[[package]] -name = "sc-client-db" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "hash-db", - "kvdb", - "kvdb-memorydb", - "kvdb-rocksdb", - "linked-hash-map", - "log", - "parity-db", - "parity-scale-codec", - "parking_lot 0.12.1", - "sc-client-api", - "sc-state-db", - "schnellru", - "sp-arithmetic", - "sp-blockchain", - "sp-core", - "sp-database", - "sp-runtime", - "sp-state-machine", - "sp-trie", -] - -[[package]] -name = "sc-consensus" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "async-trait", - "futures", - "futures-timer", - "libp2p-identity", - "log", - "mockall", - "parking_lot 0.12.1", - "sc-client-api", - "sc-utils", - "serde", - "sp-api", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-runtime", - "sp-state-machine", - "substrate-prometheus-endpoint", - "thiserror", -] - -[[package]] -name = "sc-consensus-aura" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "async-trait", - "futures", - "log", - "parity-scale-codec", - "sc-block-builder", - "sc-client-api", - "sc-consensus", - "sc-consensus-slots", - "sc-telemetry", - "sp-api", - "sp-application-crypto", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-consensus-aura", - "sp-consensus-slots", - "sp-core", - "sp-inherents", - "sp-keystore", - "sp-runtime", - "substrate-prometheus-endpoint", - "thiserror", -] - -[[package]] -name = "sc-consensus-babe" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "async-trait", - "fork-tree", - "futures", - "log", - "num-bigint", - "num-rational", - "num-traits", - "parity-scale-codec", - "parking_lot 0.12.1", - "sc-client-api", - "sc-consensus", - "sc-consensus-epochs", - "sc-consensus-slots", - "sc-keystore", - "sc-telemetry", - "scale-info", - "sp-api", - "sp-application-crypto", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-consensus-slots", - "sp-core", - "sp-inherents", - "sp-keystore", - "sp-runtime", - "substrate-prometheus-endpoint", - "thiserror", -] - -[[package]] -name = "sc-consensus-babe-rpc" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "futures", - "jsonrpsee", - "sc-consensus-babe", - "sc-consensus-epochs", - "sc-rpc-api", - "serde", - "sp-api", - "sp-application-crypto", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-core", - "sp-keystore", - "sp-runtime", - "thiserror", -] - -[[package]] -name = "sc-consensus-beefy" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "array-bytes 4.2.0", - "async-channel", - "async-trait", - "fnv", - "futures", - "log", - "parity-scale-codec", - "parking_lot 0.12.1", - "sc-client-api", - "sc-consensus", - "sc-keystore", - "sc-network", - "sc-network-common", - "sc-network-gossip", - "sc-network-sync", - "sc-utils", - "sp-api", - "sp-application-crypto", - "sp-arithmetic", - "sp-blockchain", - "sp-consensus", - "sp-consensus-beefy", - "sp-core", - "sp-keystore", - "sp-mmr-primitives", - "sp-runtime", - "substrate-prometheus-endpoint", - "thiserror", - "wasm-timer", -] - -[[package]] -name = "sc-consensus-beefy-rpc" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "futures", - "jsonrpsee", - "log", - "parity-scale-codec", - "parking_lot 0.12.1", - "sc-consensus-beefy", - "sc-rpc", - "serde", - "sp-consensus-beefy", - "sp-core", - "sp-runtime", - "thiserror", -] - -[[package]] -name = "sc-consensus-epochs" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "fork-tree", - "parity-scale-codec", - "sc-client-api", - "sc-consensus", - "sp-blockchain", - "sp-runtime", -] - -[[package]] -name = "sc-consensus-grandpa" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "ahash 0.8.3", - "array-bytes 4.2.0", - "async-trait", - "dyn-clone", - "finality-grandpa", - "fork-tree", - "futures", - "futures-timer", - "log", - "parity-scale-codec", - "parking_lot 0.12.1", - "rand 0.8.5", - "sc-block-builder", - "sc-chain-spec", - "sc-client-api", - "sc-consensus", - "sc-network", - "sc-network-common", - "sc-network-gossip", - "sc-telemetry", - "sc-utils", - "serde_json", - "sp-api", - "sp-application-crypto", - "sp-arithmetic", - "sp-blockchain", - "sp-consensus", - "sp-consensus-grandpa", - "sp-core", - "sp-keystore", - "sp-runtime", - "substrate-prometheus-endpoint", - "thiserror", -] - -[[package]] -name = "sc-consensus-grandpa-rpc" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "finality-grandpa", - "futures", - "jsonrpsee", - "log", - "parity-scale-codec", - "sc-client-api", - "sc-consensus-grandpa", - "sc-rpc", - "serde", - "sp-blockchain", - "sp-core", - "sp-runtime", - "thiserror", -] - -[[package]] -name = "sc-consensus-slots" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "async-trait", - "futures", - "futures-timer", - "log", - "parity-scale-codec", - "sc-client-api", - "sc-consensus", - "sc-telemetry", - "sp-arithmetic", - "sp-blockchain", - "sp-consensus", - "sp-consensus-slots", - "sp-core", - "sp-inherents", - "sp-runtime", - "sp-state-machine", -] - -[[package]] -name = "sc-executor" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "lru 0.8.1", - "parity-scale-codec", - "parking_lot 0.12.1", - "sc-executor-common", - "sc-executor-wasmtime", - "sp-api", - "sp-core", - "sp-externalities", - "sp-io", - "sp-panic-handler", - "sp-runtime-interface", - "sp-trie", - "sp-version", - "sp-wasm-interface", - "tracing", -] - -[[package]] -name = "sc-executor-common" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "sc-allocator", - "sp-maybe-compressed-blob", - "sp-wasm-interface", - "thiserror", - "wasm-instrument", -] - -[[package]] -name = "sc-executor-wasmtime" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "anyhow", - "cfg-if", - "libc", - "log", - "once_cell", - "rustix 0.36.17", - "sc-allocator", - "sc-executor-common", - "sp-runtime-interface", - "sp-wasm-interface", - "wasmtime", -] - -[[package]] -name = "sc-informant" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "ansi_term", - "futures", - "futures-timer", - "log", - "sc-client-api", - "sc-network", - "sc-network-common", - "sp-blockchain", - "sp-runtime", -] - -[[package]] -name = "sc-keystore" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "array-bytes 4.2.0", - "parking_lot 0.12.1", - "serde_json", - "sp-application-crypto", - "sp-core", - "sp-keystore", - "thiserror", -] - -[[package]] -name = "sc-network" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "array-bytes 4.2.0", - "async-channel", - "async-trait", - "asynchronous-codec", - "bytes", - "either", - "fnv", - "futures", - "futures-timer", - "ip_network", - "libp2p", - "linked_hash_set", - "log", - "lru 0.8.1", - "mockall", - "parity-scale-codec", - "parking_lot 0.12.1", - "pin-project", - "rand 0.8.5", - "sc-block-builder", - "sc-client-api", - "sc-consensus", - "sc-network-common", - "sc-peerset", - "sc-utils", - "serde", - "serde_json", - "smallvec", - "snow", - "sp-arithmetic", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-runtime", - "substrate-prometheus-endpoint", - "thiserror", - "unsigned-varint", - "zeroize", -] - -[[package]] -name = "sc-network-bitswap" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "async-channel", - "cid", - "futures", - "libp2p-identity", - "log", - "prost", - "prost-build", - "sc-client-api", - "sc-network", - "sc-network-common", - "sp-blockchain", - "sp-runtime", - "thiserror", - "unsigned-varint", -] - -[[package]] -name = "sc-network-common" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "array-bytes 4.2.0", - "async-trait", - "bitflags 1.3.2", - "bytes", - "futures", - "futures-timer", - "libp2p-identity", - "parity-scale-codec", - "prost-build", - "sc-consensus", - "sc-peerset", - "sc-utils", - "serde", - "smallvec", - "sp-blockchain", - "sp-consensus", - "sp-consensus-grandpa", - "sp-runtime", - "substrate-prometheus-endpoint", - "thiserror", - "zeroize", -] - -[[package]] -name = "sc-network-gossip" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "ahash 0.8.3", - "futures", - "futures-timer", - "libp2p", - "log", - "lru 0.8.1", - "sc-network", - "sc-network-common", - "sc-peerset", - "sp-runtime", - "substrate-prometheus-endpoint", - "tracing", -] - -[[package]] -name = "sc-network-light" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "array-bytes 4.2.0", - "async-channel", - "futures", - "libp2p-identity", - "log", - "parity-scale-codec", - "prost", - "prost-build", - "sc-client-api", - "sc-network", - "sc-network-common", - "sc-peerset", - "sp-blockchain", - "sp-core", - "sp-runtime", - "thiserror", -] - -[[package]] -name = "sc-network-sync" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "array-bytes 4.2.0", - "async-channel", - "async-trait", - "fork-tree", - "futures", - "futures-timer", - "libp2p", - "log", - "lru 0.8.1", - "mockall", - "parity-scale-codec", - "prost", - "prost-build", - "sc-client-api", - "sc-consensus", - "sc-network", - "sc-network-common", - "sc-peerset", - "sc-utils", - "smallvec", - "sp-arithmetic", - "sp-blockchain", - "sp-consensus", - "sp-consensus-grandpa", - "sp-core", - "sp-runtime", - "substrate-prometheus-endpoint", - "thiserror", -] - -[[package]] -name = "sc-network-transactions" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "array-bytes 4.2.0", - "futures", - "libp2p", - "log", - "parity-scale-codec", - "pin-project", - "sc-network", - "sc-network-common", - "sc-peerset", - "sc-utils", - "sp-consensus", - "sp-runtime", - "substrate-prometheus-endpoint", -] - -[[package]] -name = "sc-offchain" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "array-bytes 4.2.0", - "bytes", - "fnv", - "futures", - "futures-timer", - "hyper", - "hyper-rustls 0.23.2", - "libp2p", - "num_cpus", - "once_cell", - "parity-scale-codec", - "parking_lot 0.12.1", - "rand 0.8.5", - "sc-client-api", - "sc-network", - "sc-network-common", - "sc-peerset", - "sc-utils", - "sp-api", - "sp-core", - "sp-offchain", - "sp-runtime", - "threadpool", - "tracing", -] - -[[package]] -name = "sc-peerset" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "futures", - "libp2p-identity", - "log", - "parking_lot 0.12.1", - "partial_sort", - "sc-utils", - "serde_json", - "sp-arithmetic", - "wasm-timer", -] - -[[package]] -name = "sc-proposer-metrics" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "log", - "substrate-prometheus-endpoint", -] - -[[package]] -name = "sc-rpc" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "futures", - "jsonrpsee", - "log", - "parity-scale-codec", - "parking_lot 0.12.1", - "sc-block-builder", - "sc-chain-spec", - "sc-client-api", - "sc-rpc-api", - "sc-tracing", - "sc-transaction-pool-api", - "sc-utils", - "serde_json", - "sp-api", - "sp-blockchain", - "sp-core", - "sp-keystore", - "sp-offchain", - "sp-rpc", - "sp-runtime", - "sp-session", - "sp-statement-store", - "sp-version", - "tokio", -] - -[[package]] -name = "sc-rpc-api" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "jsonrpsee", - "parity-scale-codec", - "sc-chain-spec", - "sc-transaction-pool-api", - "scale-info", - "serde", - "serde_json", - "sp-core", - "sp-rpc", - "sp-runtime", - "sp-version", - "thiserror", -] - -[[package]] -name = "sc-rpc-server" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "http", - "jsonrpsee", - "log", - "serde_json", - "substrate-prometheus-endpoint", - "tokio", - "tower", - "tower-http", -] - -[[package]] -name = "sc-rpc-spec-v2" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "array-bytes 4.2.0", - "futures", - "futures-util", - "hex", - "jsonrpsee", - "log", - "parity-scale-codec", - "parking_lot 0.12.1", - "sc-chain-spec", - "sc-client-api", - "sc-transaction-pool-api", - "serde", - "sp-api", - "sp-blockchain", - "sp-core", - "sp-runtime", - "sp-version", - "thiserror", - "tokio-stream", -] - -[[package]] -name = "sc-service" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "async-trait", - "directories", - "exit-future", - "futures", - "futures-timer", - "jsonrpsee", - "log", - "parity-scale-codec", - "parking_lot 0.12.1", - "pin-project", - "rand 0.8.5", - "sc-block-builder", - "sc-chain-spec", - "sc-client-api", - "sc-client-db", - "sc-consensus", - "sc-executor", - "sc-informant", - "sc-keystore", - "sc-network", - "sc-network-bitswap", - "sc-network-common", - "sc-network-light", - "sc-network-sync", - "sc-network-transactions", - "sc-offchain", - "sc-rpc", - "sc-rpc-server", - "sc-rpc-spec-v2", - "sc-storage-monitor", - "sc-sysinfo", - "sc-telemetry", - "sc-tracing", - "sc-transaction-pool", - "sc-transaction-pool-api", - "sc-utils", - "serde", - "serde_json", - "sp-api", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-externalities", - "sp-keystore", - "sp-runtime", - "sp-session", - "sp-state-machine", - "sp-storage", - "sp-transaction-pool", - "sp-transaction-storage-proof", - "sp-trie", - "sp-version", - "static_init", - "substrate-prometheus-endpoint", - "tempfile", - "thiserror", - "tokio", - "tracing", - "tracing-futures", -] - -[[package]] -name = "sc-state-db" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "log", - "parity-scale-codec", - "parking_lot 0.12.1", - "sp-core", -] - -[[package]] -name = "sc-storage-monitor" -version = "0.1.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "clap", - "fs4", - "futures", - "log", - "sc-client-db", - "sc-utils", - "sp-core", - "thiserror", - "tokio", -] - -[[package]] -name = "sc-sync-state-rpc" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "jsonrpsee", - "parity-scale-codec", - "sc-chain-spec", - "sc-client-api", - "sc-consensus-babe", - "sc-consensus-epochs", - "sc-consensus-grandpa", - "serde", - "serde_json", - "sp-blockchain", - "sp-runtime", - "thiserror", -] - -[[package]] -name = "sc-sysinfo" -version = "6.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "futures", - "libc", - "log", - "rand 0.8.5", - "rand_pcg", - "regex", - "sc-telemetry", - "serde", - "serde_json", - "sp-core", - "sp-io", - "sp-std", -] - -[[package]] -name = "sc-telemetry" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "chrono", - "futures", - "libp2p", - "log", - "parking_lot 0.12.1", - "pin-project", - "rand 0.8.5", - "sc-utils", - "serde", - "serde_json", - "thiserror", - "wasm-timer", -] - -[[package]] -name = "sc-tracing" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "ansi_term", - "atty", - "chrono", - "lazy_static", - "libc", - "log", - "once_cell", - "parking_lot 0.12.1", - "regex", - "rustc-hash", - "sc-client-api", - "sc-rpc-server", - "sc-tracing-proc-macro", - "serde", - "sp-api", - "sp-blockchain", - "sp-core", - "sp-rpc", - "sp-runtime", - "sp-tracing", - "thiserror", - "tracing", - "tracing-log", - "tracing-subscriber", -] - -[[package]] -name = "sc-tracing-proc-macro" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "sc-transaction-pool" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "async-trait", - "futures", - "futures-timer", - "linked-hash-map", - "log", - "num-traits", - "parity-scale-codec", - "parking_lot 0.12.1", - "sc-client-api", - "sc-transaction-pool-api", - "sc-utils", - "serde", - "sp-api", - "sp-blockchain", - "sp-core", - "sp-runtime", - "sp-tracing", - "sp-transaction-pool", - "substrate-prometheus-endpoint", - "thiserror", -] - -[[package]] -name = "sc-transaction-pool-api" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "async-trait", - "futures", - "log", - "serde", - "sp-blockchain", - "sp-runtime", - "thiserror", -] - -[[package]] -name = "sc-utils" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "async-channel", - "futures", - "futures-timer", - "lazy_static", - "log", - "parking_lot 0.12.1", - "prometheus", - "sp-arithmetic", -] - -[[package]] -name = "scale-info" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" -dependencies = [ - "bitvec", - "cfg-if", - "derive_more", - "parity-scale-codec", - "scale-info-derive", - "serde", -] - -[[package]] -name = "scale-info-derive" -version = "2.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" -dependencies = [ - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "schannel" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" -dependencies = [ - "windows-sys 0.48.0", -] - -[[package]] -name = "schnellru" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "772575a524feeb803e5b0fcbc6dd9f367e579488197c94c6e4023aad2305774d" -dependencies = [ - "ahash 0.8.3", - "cfg-if", - "hashbrown 0.13.2", -] - -[[package]] -name = "schnorrkel" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862" -dependencies = [ - "arrayref", - "arrayvec 0.5.2", - "curve25519-dalek 2.1.3", - "getrandom 0.1.16", - "merlin", - "rand 0.7.3", - "rand_core 0.5.1", - "sha2 0.8.2", - "subtle", - "zeroize", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "scratch" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" - -[[package]] -name = "sct" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" -dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", -] - -[[package]] -name = "sct" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" -dependencies = [ - "ring 0.17.5", - "untrusted 0.9.0", -] - -[[package]] -name = "sdp" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d22a5ef407871893fd72b4562ee15e4742269b173959db4b8df6f538c414e13" -dependencies = [ - "rand 0.8.5", - "substring", - "thiserror", - "url", -] - -[[package]] -name = "sec1" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" -dependencies = [ - "base16ct 0.1.1", - "der 0.6.1", - "generic-array 0.14.7", - "pkcs8 0.9.0", - "subtle", - "zeroize", -] - -[[package]] -name = "sec1" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" -dependencies = [ - "base16ct 0.2.0", - "der 0.7.8", - "generic-array 0.14.7", - "pkcs8 0.10.2", - "subtle", - "zeroize", -] - -[[package]] -name = "secp256k1" -version = "0.24.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" -dependencies = [ - "secp256k1-sys", -] - -[[package]] -name = "secp256k1-sys" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" -dependencies = [ - "cc", -] - -[[package]] -name = "secrecy" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" -dependencies = [ - "zeroize", -] - -[[package]] -name = "security-framework" -version = "2.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "semver" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a3186ec9e65071a2095434b1f5bb24838d4e8e130f584c790f6033c79943537" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" -dependencies = [ - "serde", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - -[[package]] -name = "serde" -version = "1.0.190" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.190" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "serde_json" -version = "1.0.107" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "serde_spanned" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" -dependencies = [ - "serde", -] - -[[package]] -name = "sha-1" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug 0.3.0", -] - -[[package]] -name = "sha1" -version = "0.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.7", -] - -[[package]] -name = "sha2" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" -dependencies = [ - "block-buffer 0.7.3", - "digest 0.8.1", - "fake-simd", - "opaque-debug 0.2.3", -] - -[[package]] -name = "sha2" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" -dependencies = [ - "block-buffer 0.9.0", - "cfg-if", - "cpufeatures", - "digest 0.9.0", - "opaque-debug 0.3.0", -] - -[[package]] -name = "sha2" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" -dependencies = [ - "cfg-if", - "cpufeatures", - "digest 0.10.7", -] - -[[package]] -name = "sha3" -version = "0.10.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" -dependencies = [ - "digest 0.10.7", - "keccak", -] - -[[package]] -name = "sharded-slab" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "shared-configuration" -version = "0.1.0" -dependencies = [ - "frame-support", - "frame-system", - "pallet-funding", - "parachains-common", - "smallvec", - "sp-arithmetic", - "sp-std", -] - -[[package]] -name = "shlex" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" - -[[package]] -name = "signal-hook-registry" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" -dependencies = [ - "libc", -] - -[[package]] -name = "signature" -version = "1.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" -dependencies = [ - "digest 0.10.7", - "rand_core 0.6.4", -] - -[[package]] -name = "signature" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" -dependencies = [ - "digest 0.10.7", - "rand_core 0.6.4", -] - -[[package]] -name = "simba" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "061507c94fc6ab4ba1c9a0305018408e312e17c041eb63bef8aa726fa33aceae" -dependencies = [ - "approx", - "num-complex", - "num-traits", - "paste", - "wide", -] - -[[package]] -name = "similar" -version = "2.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aeaf503862c419d66959f5d7ca015337d864e9c49485d771b732e2a20453597" -dependencies = [ - "bstr 0.2.17", - "unicode-segmentation", -] - -[[package]] -name = "similar-asserts" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e041bb827d1bfca18f213411d51b665309f1afb37a04a5d1464530e13779fc0f" -dependencies = [ - "console", - "similar", -] - -[[package]] -name = "siphasher" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" - -[[package]] -name = "slab" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] - -[[package]] -name = "slice-group-by" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" - -[[package]] -name = "slot-range-helper" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "enumn", - "parity-scale-codec", - "paste", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "slotmap" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1e08e261d0e8f5c43123b7adf3e4ca1690d655377ac93a03b2c9d3e98de1342" -dependencies = [ - "version_check", -] - -[[package]] -name = "smallvec" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" - -[[package]] -name = "snap" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e9f0ab6ef7eb7353d9119c170a436d1bf248eea575ac42d19d12f4e34130831" - -[[package]] -name = "snow" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9d1425eb528a21de2755c75af4c9b5d57f50a0d4c3b7f1828a4cd03f8ba155" -dependencies = [ - "aes-gcm 0.9.4", - "blake2", - "chacha20poly1305", - "curve25519-dalek 4.1.1", - "rand_core 0.6.4", - "ring 0.16.20", - "rustc_version 0.4.0", - "sha2 0.10.8", - "subtle", -] - -[[package]] -name = "socket2" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "socket2" -version = "0.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" -dependencies = [ - "libc", - "windows-sys 0.48.0", -] - -[[package]] -name = "soketto" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" -dependencies = [ - "base64 0.13.1", - "bytes", - "flate2", - "futures", - "http", - "httparse", - "log", - "rand 0.8.5", - "sha-1", -] - -[[package]] -name = "sp-api" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "hash-db", - "log", - "parity-scale-codec", - "scale-info", - "sp-api-proc-macro", - "sp-core", - "sp-metadata-ir", - "sp-runtime", - "sp-state-machine", - "sp-std", - "sp-trie", - "sp-version", - "thiserror", -] - -[[package]] -name = "sp-api-proc-macro" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "Inflector", - "blake2", - "expander 1.0.0", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "sp-application-crypto" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "parity-scale-codec", - "scale-info", - "serde", - "sp-core", - "sp-io", - "sp-std", -] - -[[package]] -name = "sp-arithmetic" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "integer-sqrt", - "num-traits", - "parity-scale-codec", - "scale-info", - "serde", - "sp-std", - "static_assertions", -] - -[[package]] -name = "sp-authority-discovery" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-application-crypto", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "sp-block-builder" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "parity-scale-codec", - "sp-api", - "sp-inherents", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "sp-blockchain" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "futures", - "log", - "lru 0.8.1", - "parity-scale-codec", - "parking_lot 0.12.1", - "sp-api", - "sp-consensus", - "sp-database", - "sp-runtime", - "sp-state-machine", - "thiserror", -] - -[[package]] -name = "sp-consensus" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "async-trait", - "futures", - "log", - "sp-core", - "sp-inherents", - "sp-runtime", - "sp-state-machine", - "thiserror", -] - -[[package]] -name = "sp-consensus-aura" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "async-trait", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-application-crypto", - "sp-consensus", - "sp-consensus-slots", - "sp-inherents", - "sp-runtime", - "sp-std", - "sp-timestamp", -] - -[[package]] -name = "sp-consensus-babe" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "async-trait", - "parity-scale-codec", - "scale-info", - "serde", - "sp-api", - "sp-application-crypto", - "sp-consensus", - "sp-consensus-slots", - "sp-core", - "sp-inherents", - "sp-keystore", - "sp-runtime", - "sp-std", - "sp-timestamp", -] - -[[package]] -name = "sp-consensus-beefy" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "lazy_static", - "parity-scale-codec", - "scale-info", - "serde", - "sp-api", - "sp-application-crypto", - "sp-core", - "sp-io", - "sp-mmr-primitives", - "sp-runtime", - "sp-std", - "strum", -] - -[[package]] -name = "sp-consensus-grandpa" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "finality-grandpa", - "log", - "parity-scale-codec", - "scale-info", - "serde", - "sp-api", - "sp-application-crypto", - "sp-core", - "sp-keystore", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "sp-consensus-slots" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "parity-scale-codec", - "scale-info", - "serde", - "sp-std", - "sp-timestamp", -] - -[[package]] -name = "sp-core" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "array-bytes 4.2.0", - "bitflags 1.3.2", - "blake2", - "bounded-collections", - "bs58", - "dyn-clonable", - "ed25519-zebra", - "futures", - "hash-db", - "hash256-std-hasher", - "impl-serde", - "lazy_static", - "libsecp256k1", - "log", - "merlin", - "parity-scale-codec", - "parking_lot 0.12.1", - "paste", - "primitive-types", - "rand 0.8.5", - "regex", - "scale-info", - "schnorrkel", - "secp256k1", - "secrecy", - "serde", - "sp-core-hashing", - "sp-debug-derive", - "sp-externalities", - "sp-runtime-interface", - "sp-std", - "sp-storage", - "ss58-registry", - "substrate-bip39", - "thiserror", - "tiny-bip39", - "zeroize", -] - -[[package]] -name = "sp-core-hashing" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "blake2b_simd", - "byteorder", - "digest 0.10.7", - "sha2 0.10.8", - "sha3", - "sp-std", - "twox-hash", -] - -[[package]] -name = "sp-core-hashing-proc-macro" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "proc-macro2", - "quote", - "sp-core-hashing", - "syn 2.0.38", -] - -[[package]] -name = "sp-database" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "kvdb", - "parking_lot 0.12.1", -] - -[[package]] -name = "sp-debug-derive" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "sp-externalities" -version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "environmental", - "parity-scale-codec", - "sp-std", - "sp-storage", -] - -[[package]] -name = "sp-inherents" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "async-trait", - "impl-trait-for-tuples", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-runtime", - "sp-std", - "thiserror", -] - -[[package]] -name = "sp-io" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "bytes", - "ed25519 1.5.3", - "ed25519-dalek 1.0.1", - "futures", - "libsecp256k1", - "log", - "parity-scale-codec", - "rustversion", - "secp256k1", - "sp-core", - "sp-externalities", - "sp-keystore", - "sp-runtime-interface", - "sp-state-machine", - "sp-std", - "sp-tracing", - "sp-trie", - "tracing", - "tracing-core", -] - -[[package]] -name = "sp-keyring" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "lazy_static", - "sp-core", - "sp-runtime", - "strum", -] - -[[package]] -name = "sp-keystore" -version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "futures", - "parity-scale-codec", - "parking_lot 0.12.1", - "serde", - "sp-core", - "sp-externalities", - "thiserror", -] - -[[package]] -name = "sp-maybe-compressed-blob" -version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "thiserror", - "zstd 0.12.4", -] - -[[package]] -name = "sp-metadata-ir" -version = "0.1.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-metadata", - "parity-scale-codec", - "scale-info", - "sp-std", -] - -[[package]] -name = "sp-mmr-primitives" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "ckb-merkle-mountain-range", - "log", - "parity-scale-codec", - "scale-info", - "serde", - "sp-api", - "sp-core", - "sp-debug-derive", - "sp-runtime", - "sp-std", - "thiserror", -] - -[[package]] -name = "sp-npos-elections" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "parity-scale-codec", - "scale-info", - "serde", - "sp-arithmetic", - "sp-core", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "sp-offchain" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "sp-api", - "sp-core", - "sp-runtime", -] - -[[package]] -name = "sp-panic-handler" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "backtrace", - "lazy_static", - "regex", -] - -[[package]] -name = "sp-rpc" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "rustc-hash", - "serde", - "sp-core", -] - -[[package]] -name = "sp-runtime" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "either", - "hash256-std-hasher", - "impl-trait-for-tuples", - "log", - "parity-scale-codec", - "paste", - "rand 0.8.5", - "scale-info", - "serde", - "sp-application-crypto", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-std", - "sp-weights", -] - -[[package]] -name = "sp-runtime-interface" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "bytes", - "impl-trait-for-tuples", - "parity-scale-codec", - "primitive-types", - "sp-externalities", - "sp-runtime-interface-proc-macro", - "sp-std", - "sp-storage", - "sp-tracing", - "sp-wasm-interface", - "static_assertions", -] - -[[package]] -name = "sp-runtime-interface-proc-macro" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "Inflector", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "sp-session" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-core", - "sp-runtime", - "sp-staking", - "sp-std", -] - -[[package]] -name = "sp-staking" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "parity-scale-codec", - "scale-info", - "serde", - "sp-core", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "sp-state-machine" -version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "hash-db", - "log", - "parity-scale-codec", - "parking_lot 0.12.1", - "rand 0.8.5", - "smallvec", - "sp-core", - "sp-externalities", - "sp-panic-handler", - "sp-std", - "sp-trie", - "thiserror", - "tracing", -] - -[[package]] -name = "sp-statement-store" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "log", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-application-crypto", - "sp-core", - "sp-externalities", - "sp-runtime", - "sp-runtime-interface", - "sp-std", - "thiserror", -] - -[[package]] -name = "sp-std" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" - -[[package]] -name = "sp-storage" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "impl-serde", - "parity-scale-codec", - "ref-cast", - "serde", - "sp-debug-derive", - "sp-std", -] - -[[package]] -name = "sp-timestamp" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "async-trait", - "futures-timer", - "log", - "parity-scale-codec", - "sp-inherents", - "sp-runtime", - "sp-std", - "thiserror", -] - -[[package]] -name = "sp-tracing" -version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "parity-scale-codec", - "sp-std", - "tracing", - "tracing-core", - "tracing-subscriber", -] - -[[package]] -name = "sp-transaction-pool" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "sp-api", - "sp-runtime", -] - -[[package]] -name = "sp-transaction-storage-proof" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "async-trait", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-inherents", - "sp-runtime", - "sp-std", - "sp-trie", -] - -[[package]] -name = "sp-trie" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "ahash 0.8.3", - "hash-db", - "hashbrown 0.13.2", - "lazy_static", - "memory-db", - "nohash-hasher", - "parity-scale-codec", - "parking_lot 0.12.1", - "scale-info", - "schnellru", - "sp-core", - "sp-std", - "thiserror", - "tracing", - "trie-db", - "trie-root", -] - -[[package]] -name = "sp-version" -version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "impl-serde", - "parity-scale-codec", - "parity-wasm", - "scale-info", - "serde", - "sp-core-hashing-proc-macro", - "sp-runtime", - "sp-std", - "sp-version-proc-macro", - "thiserror", -] - -[[package]] -name = "sp-version-proc-macro" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "parity-scale-codec", - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "sp-wasm-interface" -version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "anyhow", - "impl-trait-for-tuples", - "log", - "parity-scale-codec", - "sp-std", - "wasmi", - "wasmtime", -] - -[[package]] -name = "sp-weights" -version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "parity-scale-codec", - "scale-info", - "serde", - "smallvec", - "sp-arithmetic", - "sp-core", - "sp-debug-derive", - "sp-std", -] - -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - -[[package]] -name = "spinners" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08615eea740067d9899969bc2891c68a19c315cb1f66640af9a9ecb91b13bcab" -dependencies = [ - "lazy_static", - "maplit", - "strum", -] - -[[package]] -name = "spki" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" -dependencies = [ - "base64ct", - "der 0.6.1", -] - -[[package]] -name = "spki" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" -dependencies = [ - "base64ct", - "der 0.7.8", -] - -[[package]] -name = "ss58-registry" -version = "1.43.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e6915280e2d0db8911e5032a5c275571af6bdded2916abd691a659be25d3439" -dependencies = [ - "Inflector", - "num-format", - "proc-macro2", - "quote", - "serde", - "serde_json", - "unicode-xid", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "statemint-runtime" -version = "1.0.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "assets-common", - "cumulus-pallet-aura-ext", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-session-benchmarking", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "cumulus-primitives-timestamp", - "cumulus-primitives-utility", - "frame-benchmarking", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "hex-literal 0.4.1", - "log", - "pallet-asset-tx-payment", - "pallet-assets", - "pallet-aura", - "pallet-authorship", - "pallet-balances", - "pallet-collator-selection", - "pallet-multisig", - "pallet-nfts", - "pallet-nfts-runtime-api", - "pallet-proxy", - "pallet-session", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-uniques", - "pallet-utility", - "pallet-xcm", - "pallet-xcm-benchmarks", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "polkadot-core-primitives", - "polkadot-parachain", - "polkadot-runtime-common", - "polkadot-runtime-constants", - "scale-info", - "smallvec", - "sp-api", - "sp-block-builder", - "sp-consensus-aura", - "sp-core", - "sp-inherents", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "sp-weights", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - -[[package]] -name = "static_init" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a2a1c578e98c1c16fc3b8ec1328f7659a500737d7a0c6d625e73e830ff9c1f6" -dependencies = [ - "bitflags 1.3.2", - "cfg_aliases", - "libc", - "parking_lot 0.11.2", - "parking_lot_core 0.8.6", - "static_init_macro", - "winapi", -] - -[[package]] -name = "static_init_macro" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a2595fc3aa78f2d0e45dd425b22282dd863273761cc77780914b2cf3003acf" -dependencies = [ - "cfg_aliases", - "memchr", - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - -[[package]] -name = "strum" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" -dependencies = [ - "strum_macros", -] - -[[package]] -name = "strum_macros" -version = "0.24.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "rustversion", - "syn 1.0.109", -] - -[[package]] -name = "stun" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7e94b1ec00bad60e6410e058b52f1c66de3dc5fe4d62d09b3e52bb7d3b73e25" -dependencies = [ - "base64 0.13.1", - "crc", - "lazy_static", - "md-5", - "rand 0.8.5", - "ring 0.16.20", - "subtle", - "thiserror", - "tokio", - "url", - "webrtc-util", -] - -[[package]] -name = "substrate-bip39" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49eee6965196b32f882dd2ee85a92b1dbead41b04e53907f269de3b0dc04733c" -dependencies = [ - "hmac 0.11.0", - "pbkdf2 0.8.0", - "schnorrkel", - "sha2 0.9.9", - "zeroize", -] - -[[package]] -name = "substrate-build-script-utils" -version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "platforms 2.0.0", -] - -[[package]] -name = "substrate-fixed" -version = "0.5.9" -source = "git+https://github.com/encointer/substrate-fixed#a75f3ba3f7c7893fb420500639cc055f964b1b88" -dependencies = [ - "parity-scale-codec", - "scale-info", - "serde", - "substrate-typenum", -] - -[[package]] -name = "substrate-frame-rpc-system" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "frame-system-rpc-runtime-api", - "futures", - "jsonrpsee", - "log", - "parity-scale-codec", - "sc-rpc-api", - "sc-transaction-pool-api", - "sp-api", - "sp-block-builder", - "sp-blockchain", - "sp-core", - "sp-runtime", -] - -[[package]] -name = "substrate-prometheus-endpoint" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "hyper", - "log", - "prometheus", - "thiserror", - "tokio", -] - -[[package]] -name = "substrate-rpc-client" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "async-trait", - "jsonrpsee", - "log", - "sc-rpc-api", - "serde", - "sp-runtime", -] - -[[package]] -name = "substrate-state-trie-migration-rpc" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "jsonrpsee", - "log", - "parity-scale-codec", - "sc-client-api", - "sc-rpc-api", - "scale-info", - "serde", - "sp-core", - "sp-runtime", - "sp-state-machine", - "sp-trie", - "trie-db", -] - -[[package]] -name = "substrate-test-client" -version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "array-bytes 4.2.0", - "async-trait", - "futures", - "parity-scale-codec", - "sc-client-api", - "sc-client-db", - "sc-consensus", - "sc-executor", - "sc-offchain", - "sc-service", - "serde", - "serde_json", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-keyring", - "sp-keystore", - "sp-runtime", - "sp-state-machine", -] - -[[package]] -name = "substrate-typenum" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f0091e93c2c75b233ae39424c52cb8a662c0811fb68add149e20e5d7e8a788" -dependencies = [ - "parity-scale-codec", - "scale-info", -] - -[[package]] -name = "substrate-wasm-builder" -version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "ansi_term", - "build-helper", - "cargo_metadata", - "filetime", - "sp-maybe-compressed-blob", - "strum", - "tempfile", - "toml 0.7.8", - "walkdir", - "wasm-opt", -] - -[[package]] -name = "substring" -version = "1.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ee6433ecef213b2e72f587ef64a2f5943e7cd16fbd82dbe8bc07486c534c86" -dependencies = [ - "autocfg", -] - -[[package]] -name = "subtle" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "synstructure" -version = "0.12.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", - "unicode-xid", -] - -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "target-lexicon" -version = "0.12.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a" - -[[package]] -name = "tempfile" -version = "3.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" -dependencies = [ - "cfg-if", - "fastrand 2.0.1", - "redox_syscall 0.4.1", - "rustix 0.38.21", - "windows-sys 0.48.0", -] - -[[package]] -name = "termcolor" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" -dependencies = [ - "winapi-util", -] - -[[package]] -name = "termtree" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" - -[[package]] -name = "test-runtime-constants" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "frame-support", - "polkadot-primitives", - "polkadot-runtime-common", - "smallvec", - "sp-core", - "sp-runtime", - "sp-weights", -] - -[[package]] -name = "thiserror" -version = "1.0.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "thousands" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820" - -[[package]] -name = "thread_local" -version = "1.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" -dependencies = [ - "cfg-if", - "once_cell", -] - -[[package]] -name = "threadpool" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" -dependencies = [ - "num_cpus", -] - -[[package]] -name = "thrift" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b82ca8f46f95b3ce96081fe3dd89160fdea970c254bb72925255d1b62aae692e" -dependencies = [ - "byteorder", - "integer-encoding", - "log", - "ordered-float", - "threadpool", -] - -[[package]] -name = "tikv-jemalloc-ctl" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "619bfed27d807b54f7f776b9430d4f8060e66ee138a28632ca898584d462c31c" -dependencies = [ - "libc", - "paste", - "tikv-jemalloc-sys", -] - -[[package]] -name = "tikv-jemalloc-sys" -version = "0.5.4+5.3.0-patched" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" -dependencies = [ - "cc", - "libc", -] - -[[package]] -name = "time" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" -dependencies = [ - "deranged", - "itoa", - "powerfmt", - "serde", - "time-core", - "time-macros", -] - -[[package]] -name = "time-core" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" - -[[package]] -name = "time-macros" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" -dependencies = [ - "time-core", -] - -[[package]] -name = "tiny-bip39" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62cc94d358b5a1e84a5cb9109f559aa3c4d634d2b1b4de3d0fa4adc7c78e2861" -dependencies = [ - "anyhow", - "hmac 0.12.1", - "once_cell", - "pbkdf2 0.11.0", - "rand 0.8.5", - "rustc-hash", - "sha2 0.10.8", - "thiserror", - "unicode-normalization", - "wasm-bindgen", - "zeroize", -] - -[[package]] -name = "tinytemplate" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" -dependencies = [ - "serde", - "serde_json", -] - -[[package]] -name = "tinyvec" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - -[[package]] -name = "tokio" -version = "1.33.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" -dependencies = [ - "backtrace", - "bytes", - "libc", - "mio", - "num_cpus", - "parking_lot 0.12.1", - "pin-project-lite 0.2.13", - "signal-hook-registry", - "socket2 0.5.5", - "tokio-macros", - "windows-sys 0.48.0", -] - -[[package]] -name = "tokio-macros" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "tokio-retry" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f57eb36ecbe0fc510036adff84824dd3c24bb781e21bfa67b69d556aa85214f" -dependencies = [ - "pin-project", - "rand 0.8.5", - "tokio", -] - -[[package]] -name = "tokio-rustls" -version = "0.23.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" -dependencies = [ - "rustls 0.20.9", - "tokio", - "webpki 0.22.4", -] - -[[package]] -name = "tokio-rustls" -version = "0.24.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" -dependencies = [ - "rustls 0.21.8", - "tokio", -] - -[[package]] -name = "tokio-stream" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" -dependencies = [ - "futures-core", - "pin-project-lite 0.2.13", - "tokio", - "tokio-util", -] - -[[package]] -name = "tokio-util" -version = "0.7.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" -dependencies = [ - "bytes", - "futures-core", - "futures-io", - "futures-sink", - "pin-project-lite 0.2.13", - "tokio", - "tracing", -] - -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - -[[package]] -name = "toml" -version = "0.7.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime", - "toml_edit", -] - -[[package]] -name = "toml_datetime" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" -dependencies = [ - "serde", -] - -[[package]] -name = "toml_edit" -version = "0.19.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" -dependencies = [ - "indexmap 2.0.2", - "serde", - "serde_spanned", - "toml_datetime", - "winnow", -] - -[[package]] -name = "tower" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" -dependencies = [ - "tower-layer", - "tower-service", - "tracing", -] - -[[package]] -name = "tower-http" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" -dependencies = [ - "bitflags 2.4.1", - "bytes", - "futures-core", - "futures-util", - "http", - "http-body", - "http-range-header", - "pin-project-lite 0.2.13", - "tower-layer", - "tower-service", -] - -[[package]] -name = "tower-layer" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" - -[[package]] -name = "tower-service" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" - -[[package]] -name = "tracing" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" -dependencies = [ - "log", - "pin-project-lite 0.2.13", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", - "valuable", -] - -[[package]] -name = "tracing-futures" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" -dependencies = [ - "pin-project", - "tracing", -] - -[[package]] -name = "tracing-gum" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "polkadot-node-jaeger", - "polkadot-primitives", - "tracing", - "tracing-gum-proc-macro", -] - -[[package]] -name = "tracing-gum-proc-macro" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "expander 2.0.0", - "proc-macro-crate", - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "tracing-log" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" -dependencies = [ - "log", - "once_cell", - "tracing-core", -] - -[[package]] -name = "tracing-serde" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" -dependencies = [ - "serde", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.2.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" -dependencies = [ - "ansi_term", - "chrono", - "lazy_static", - "matchers", - "parking_lot 0.11.2", - "regex", - "serde", - "serde_json", - "sharded-slab", - "smallvec", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", - "tracing-serde", -] - -[[package]] -name = "trie-db" -version = "0.27.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "767abe6ffed88a1889671a102c2861ae742726f52e0a5a425b92c9fbfa7e9c85" -dependencies = [ - "hash-db", - "hashbrown 0.13.2", - "log", - "rustc-hex", - "smallvec", -] - -[[package]] -name = "trie-root" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4ed310ef5ab98f5fa467900ed906cb9232dd5376597e00fd4cba2a449d06c0b" -dependencies = [ - "hash-db", -] - -[[package]] -name = "trust-dns-proto" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f7f83d1e4a0e4358ac54c5c3681e5d7da5efc5a7a632c90bb6d6669ddd9bc26" -dependencies = [ - "async-trait", - "cfg-if", - "data-encoding", - "enum-as-inner", - "futures-channel", - "futures-io", - "futures-util", - "idna 0.2.3", - "ipnet", - "lazy_static", - "rand 0.8.5", - "smallvec", - "socket2 0.4.10", - "thiserror", - "tinyvec", - "tokio", - "tracing", - "url", -] - -[[package]] -name = "trust-dns-resolver" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aff21aa4dcefb0a1afbfac26deb0adc93888c7d295fb63ab273ef276ba2b7cfe" -dependencies = [ - "cfg-if", - "futures-util", - "ipconfig", - "lazy_static", - "lru-cache", - "parking_lot 0.12.1", - "resolv-conf", - "smallvec", - "thiserror", - "tokio", - "tracing", - "trust-dns-proto", -] - -[[package]] -name = "try-lock" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" - -[[package]] -name = "try-runtime-cli" -version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" -dependencies = [ - "async-trait", - "clap", - "frame-remote-externalities", - "frame-try-runtime", - "hex", - "log", - "parity-scale-codec", - "sc-cli", - "sc-executor", - "sc-service", - "serde", - "serde_json", - "sp-api", - "sp-consensus-aura", - "sp-consensus-babe", - "sp-core", - "sp-debug-derive", - "sp-externalities", - "sp-inherents", - "sp-io", - "sp-keystore", - "sp-rpc", - "sp-runtime", - "sp-state-machine", - "sp-timestamp", - "sp-transaction-storage-proof", - "sp-version", - "sp-weights", - "substrate-rpc-client", - "zstd 0.12.4", -] - -[[package]] -name = "tt-call" -version = "1.0.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f195fd851901624eee5a58c4bb2b4f06399148fcd0ed336e6f1cb60a9881df" - -[[package]] -name = "turn" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4712ee30d123ec7ae26d1e1b218395a16c87cdbaf4b3925d170d684af62ea5e8" -dependencies = [ - "async-trait", - "base64 0.13.1", - "futures", - "log", - "md-5", - "rand 0.8.5", - "ring 0.16.20", - "stun", - "thiserror", - "tokio", - "webrtc-util", -] - -[[package]] -name = "twox-hash" -version = "1.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" -dependencies = [ - "cfg-if", - "digest 0.10.7", - "rand 0.8.5", - "static_assertions", -] - -[[package]] -name = "typenum" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" - -[[package]] -name = "ucd-trie" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" - -[[package]] -name = "uint" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" -dependencies = [ - "byteorder", - "crunchy", - "hex", - "static_assertions", -] - -[[package]] -name = "unicode-bidi" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unicode-normalization" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" -dependencies = [ - "tinyvec", -] - -[[package]] -name = "unicode-segmentation" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" - -[[package]] -name = "unicode-width" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" - -[[package]] -name = "unicode-xid" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" - -[[package]] -name = "universal-hash" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" -dependencies = [ - "generic-array 0.14.7", - "subtle", -] - -[[package]] -name = "universal-hash" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" -dependencies = [ - "crypto-common", - "subtle", -] - -[[package]] -name = "unsigned-varint" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6889a77d49f1f013504cec6bf97a2c730394adedaeb1deb5ea08949a50541105" -dependencies = [ - "asynchronous-codec", - "bytes", - "futures-io", - "futures-util", -] - -[[package]] -name = "untrusted" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" - -[[package]] -name = "untrusted" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" - -[[package]] -name = "url" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" -dependencies = [ - "form_urlencoded", - "idna 0.4.0", - "percent-encoding", -] - -[[package]] -name = "utf8parse" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" - -[[package]] -name = "uuid" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" -dependencies = [ - "getrandom 0.2.10", -] - -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - -[[package]] -name = "void" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" - -[[package]] -name = "waitgroup" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1f50000a783467e6c0200f9d10642f4bc424e39efc1b770203e88b488f79292" -dependencies = [ - "atomic-waker", -] - -[[package]] -name = "waker-fn" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" - -[[package]] -name = "walkdir" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" -dependencies = [ - "same-file", - "winapi-util", -] - -[[package]] -name = "want" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" -dependencies = [ - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasm-bindgen" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn 2.0.38", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.87" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" - -[[package]] -name = "wasm-instrument" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa1dafb3e60065305741e83db35c6c2584bb3725b692b5b66148a38d72ace6cd" -dependencies = [ - "parity-wasm", -] - -[[package]] -name = "wasm-opt" -version = "0.112.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87fef6d0d508f08334e0ab0e6877feb4c0ecb3956bcf2cb950699b22fedf3e9c" -dependencies = [ - "anyhow", - "libc", - "strum", - "strum_macros", - "tempfile", - "thiserror", - "wasm-opt-cxx-sys", - "wasm-opt-sys", -] - -[[package]] -name = "wasm-opt-cxx-sys" -version = "0.112.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc816bbc1596c8f2e8127e137a760c798023ef3d378f2ae51f0f1840e2dfa445" -dependencies = [ - "anyhow", - "cxx", - "cxx-build", - "wasm-opt-sys", -] - -[[package]] -name = "wasm-opt-sys" -version = "0.112.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40199e4f68ef1071b3c6d0bd8026a12b481865d4b9e49c156932ea9a6234dd14" -dependencies = [ - "anyhow", - "cc", - "cxx", - "cxx-build", -] - -[[package]] -name = "wasm-timer" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" -dependencies = [ - "futures", - "js-sys", - "parking_lot 0.11.2", - "pin-utils", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - -[[package]] -name = "wasmi" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06c326c93fbf86419608361a2c925a31754cf109da1b8b55737070b4d6669422" -dependencies = [ - "parity-wasm", - "wasmi-validation", - "wasmi_core", -] - -[[package]] -name = "wasmi-validation" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ff416ad1ff0c42e5a926ed5d5fab74c0f098749aa0ad8b2a34b982ce0e867b" -dependencies = [ - "parity-wasm", -] - -[[package]] -name = "wasmi_core" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d20cb3c59b788653d99541c646c561c9dd26506f25c0cebfe810659c54c6d7" -dependencies = [ - "downcast-rs", - "libm", - "memory_units", - "num-rational", - "num-traits", -] - -[[package]] -name = "wasmparser" -version = "0.102.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48134de3d7598219ab9eaf6b91b15d8e50d31da76b8519fe4ecfcec2cf35104b" -dependencies = [ - "indexmap 1.9.3", - "url", -] - -[[package]] -name = "wasmtime" -version = "8.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f907fdead3153cb9bfb7a93bbd5b62629472dc06dee83605358c64c52ed3dda9" -dependencies = [ - "anyhow", - "bincode", - "cfg-if", - "indexmap 1.9.3", - "libc", - "log", - "object 0.30.4", - "once_cell", - "paste", - "psm", - "rayon", - "serde", - "target-lexicon", - "wasmparser", - "wasmtime-cache", - "wasmtime-cranelift", - "wasmtime-environ", - "wasmtime-jit", - "wasmtime-runtime", - "windows-sys 0.45.0", -] - -[[package]] -name = "wasmtime-asm-macros" -version = "8.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3b9daa7c14cd4fa3edbf69de994408d5f4b7b0959ac13fa69d465f6597f810d" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "wasmtime-cache" -version = "8.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c86437fa68626fe896e5afc69234bb2b5894949083586535f200385adfd71213" -dependencies = [ - "anyhow", - "base64 0.21.5", - "bincode", - "directories-next", - "file-per-thread-logger", - "log", - "rustix 0.36.17", - "serde", - "sha2 0.10.8", - "toml 0.5.11", - "windows-sys 0.45.0", - "zstd 0.11.2+zstd.1.5.2", -] - -[[package]] -name = "wasmtime-cranelift" -version = "8.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1cefde0cce8cb700b1b21b6298a3837dba46521affd7b8c38a9ee2c869eee04" -dependencies = [ - "anyhow", - "cranelift-codegen", - "cranelift-entity", - "cranelift-frontend", - "cranelift-native", - "cranelift-wasm", - "gimli 0.27.3", - "log", - "object 0.30.4", - "target-lexicon", - "thiserror", - "wasmparser", - "wasmtime-cranelift-shared", - "wasmtime-environ", -] - -[[package]] -name = "wasmtime-cranelift-shared" -version = "8.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd041e382ef5aea1b9fc78442394f1a4f6d676ce457e7076ca4cb3f397882f8b" -dependencies = [ - "anyhow", - "cranelift-codegen", - "cranelift-native", - "gimli 0.27.3", - "object 0.30.4", - "target-lexicon", - "wasmtime-environ", -] - -[[package]] -name = "wasmtime-environ" -version = "8.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a990198cee4197423045235bf89d3359e69bd2ea031005f4c2d901125955c949" -dependencies = [ - "anyhow", - "cranelift-entity", - "gimli 0.27.3", - "indexmap 1.9.3", - "log", - "object 0.30.4", - "serde", - "target-lexicon", - "thiserror", - "wasmparser", - "wasmtime-types", -] - -[[package]] -name = "wasmtime-jit" -version = "8.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de48df552cfca1c9b750002d3e07b45772dd033b0b206d5c0968496abf31244" -dependencies = [ - "addr2line 0.19.0", - "anyhow", - "bincode", - "cfg-if", - "cpp_demangle", - "gimli 0.27.3", - "log", - "object 0.30.4", - "rustc-demangle", - "serde", - "target-lexicon", - "wasmtime-environ", - "wasmtime-jit-debug", - "wasmtime-jit-icache-coherence", - "wasmtime-runtime", - "windows-sys 0.45.0", -] - -[[package]] -name = "wasmtime-jit-debug" -version = "8.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0554b84c15a27d76281d06838aed94e13a77d7bf604bbbaf548aa20eb93846" -dependencies = [ - "object 0.30.4", - "once_cell", - "rustix 0.36.17", -] - -[[package]] -name = "wasmtime-jit-icache-coherence" -version = "8.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aecae978b13f7f67efb23bd827373ace4578f2137ec110bbf6a4a7cde4121bbd" -dependencies = [ - "cfg-if", - "libc", - "windows-sys 0.45.0", -] - -[[package]] -name = "wasmtime-runtime" -version = "8.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "658cf6f325232b6760e202e5255d823da5e348fdea827eff0a2a22319000b441" -dependencies = [ - "anyhow", - "cc", - "cfg-if", - "indexmap 1.9.3", - "libc", - "log", - "mach", - "memfd", - "memoffset 0.8.0", - "paste", - "rand 0.8.5", - "rustix 0.36.17", - "wasmtime-asm-macros", - "wasmtime-environ", - "wasmtime-jit-debug", - "windows-sys 0.45.0", -] - -[[package]] -name = "wasmtime-types" -version = "8.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4f6fffd2a1011887d57f07654dd112791e872e3ff4a2e626aee8059ee17f06f" -dependencies = [ - "cranelift-entity", - "serde", - "thiserror", - "wasmparser", -] - -[[package]] -name = "web-sys" -version = "0.3.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "webpki" -version = "0.21.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" -dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", -] - -[[package]] -name = "webpki" -version = "0.22.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" -dependencies = [ - "ring 0.17.5", - "untrusted 0.9.0", -] - -[[package]] -name = "webpki-roots" -version = "0.22.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" -dependencies = [ - "webpki 0.22.4", -] - -[[package]] -name = "webpki-roots" -version = "0.25.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" - -[[package]] -name = "webrtc" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3bc9049bdb2cea52f5fd4f6f728184225bdb867ed0dc2410eab6df5bdd67bb" -dependencies = [ - "arc-swap", - "async-trait", - "bytes", - "hex", - "interceptor", - "lazy_static", - "log", - "rand 0.8.5", - "rcgen 0.9.3", - "regex", - "ring 0.16.20", - "rtcp", - "rtp", - "rustls 0.19.1", - "sdp", - "serde", - "serde_json", - "sha2 0.10.8", - "stun", - "thiserror", - "time", - "tokio", - "turn", - "url", - "waitgroup", - "webrtc-data", - "webrtc-dtls", - "webrtc-ice", - "webrtc-mdns", - "webrtc-media", - "webrtc-sctp", - "webrtc-srtp", - "webrtc-util", -] - -[[package]] -name = "webrtc-data" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ef36a4d12baa6e842582fe9ec16a57184ba35e1a09308307b67d43ec8883100" -dependencies = [ - "bytes", - "derive_builder", - "log", - "thiserror", - "tokio", - "webrtc-sctp", - "webrtc-util", -] - -[[package]] -name = "webrtc-dtls" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a00f4242f2db33307347bd5be53263c52a0331c96c14292118c9a6bb48d267" -dependencies = [ - "aes 0.6.0", - "aes-gcm 0.10.3", - "async-trait", - "bincode", - "block-modes", - "byteorder", - "ccm", - "curve25519-dalek 3.2.0", - "der-parser 8.2.0", - "elliptic-curve 0.12.3", - "hkdf", - "hmac 0.12.1", - "log", - "p256", - "p384", - "rand 0.8.5", - "rand_core 0.6.4", - "rcgen 0.10.0", - "ring 0.16.20", - "rustls 0.19.1", - "sec1 0.3.0", - "serde", - "sha1", - "sha2 0.10.8", - "signature 1.6.4", - "subtle", - "thiserror", - "tokio", - "webpki 0.21.4", - "webrtc-util", - "x25519-dalek 2.0.0", - "x509-parser 0.13.2", -] - -[[package]] -name = "webrtc-ice" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465a03cc11e9a7d7b4f9f99870558fe37a102b65b93f8045392fef7c67b39e80" -dependencies = [ - "arc-swap", - "async-trait", - "crc", - "log", - "rand 0.8.5", - "serde", - "serde_json", - "stun", - "thiserror", - "tokio", - "turn", - "url", - "uuid", - "waitgroup", - "webrtc-mdns", - "webrtc-util", -] - -[[package]] -name = "webrtc-mdns" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f08dfd7a6e3987e255c4dbe710dde5d94d0f0574f8a21afa95d171376c143106" -dependencies = [ - "log", - "socket2 0.4.10", - "thiserror", - "tokio", - "webrtc-util", -] - -[[package]] -name = "webrtc-media" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f72e1650a8ae006017d1a5280efb49e2610c19ccc3c0905b03b648aee9554991" -dependencies = [ - "byteorder", - "bytes", - "rand 0.8.5", - "rtp", - "thiserror", -] - -[[package]] -name = "webrtc-sctp" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d47adcd9427eb3ede33d5a7f3424038f63c965491beafcc20bc650a2f6679c0" -dependencies = [ - "arc-swap", - "async-trait", - "bytes", - "crc", - "log", - "rand 0.8.5", - "thiserror", - "tokio", - "webrtc-util", -] - -[[package]] -name = "webrtc-srtp" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6183edc4c1c6c0175f8812eefdce84dfa0aea9c3ece71c2bf6ddd3c964de3da5" -dependencies = [ - "aead 0.4.3", - "aes 0.7.5", - "aes-gcm 0.9.4", - "async-trait", - "byteorder", - "bytes", - "ctr 0.8.0", - "hmac 0.11.0", - "log", - "rtcp", - "rtp", - "sha-1", - "subtle", - "thiserror", - "tokio", - "webrtc-util", -] - -[[package]] -name = "webrtc-util" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93f1db1727772c05cf7a2cfece52c3aca8045ca1e176cd517d323489aa3c6d87" -dependencies = [ - "async-trait", - "bitflags 1.3.2", - "bytes", - "cc", - "ipnet", - "lazy_static", - "libc", - "log", - "nix", - "rand 0.8.5", - "thiserror", - "tokio", - "winapi", -] - -[[package]] -name = "westend-runtime" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "bitvec", - "frame-benchmarking", - "frame-election-provider-support", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal 0.4.1", - "log", - "pallet-authority-discovery", - "pallet-authorship", - "pallet-babe", - "pallet-bags-list", - "pallet-balances", - "pallet-collective", - "pallet-democracy", - "pallet-election-provider-multi-phase", - "pallet-election-provider-support-benchmarking", - "pallet-elections-phragmen", - "pallet-fast-unstake", - "pallet-grandpa", - "pallet-identity", - "pallet-im-online", - "pallet-indices", - "pallet-membership", - "pallet-message-queue", - "pallet-multisig", - "pallet-nomination-pools", - "pallet-nomination-pools-benchmarking", - "pallet-nomination-pools-runtime-api", - "pallet-offences", - "pallet-offences-benchmarking", - "pallet-preimage", - "pallet-proxy", - "pallet-recovery", - "pallet-scheduler", - "pallet-session", - "pallet-session-benchmarking", - "pallet-society", - "pallet-staking", - "pallet-staking-reward-curve", - "pallet-staking-runtime-api", - "pallet-state-trie-migration", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-treasury", - "pallet-utility", - "pallet-vesting", - "pallet-xcm", - "pallet-xcm-benchmarks", - "parity-scale-codec", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "rustc-hex", - "scale-info", - "serde", - "serde_derive", - "smallvec", - "sp-api", - "sp-authority-discovery", - "sp-block-builder", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-core", - "sp-inherents", - "sp-io", - "sp-mmr-primitives", - "sp-npos-elections", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", - "westend-runtime-constants", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "westend-runtime-constants" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "frame-support", - "polkadot-primitives", - "polkadot-runtime-common", - "smallvec", - "sp-core", - "sp-runtime", - "sp-weights", -] - -[[package]] -name = "which" -version = "4.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" -dependencies = [ - "either", - "home", - "once_cell", - "rustix 0.38.21", -] - -[[package]] -name = "wide" -version = "0.7.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68938b57b33da363195412cfc5fc37c9ed49aa9cfe2156fde64b8d2c9498242" -dependencies = [ - "bytemuck", - "safe_arch", -] - -[[package]] -name = "widestring" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows" -version = "0.51.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" -dependencies = [ - "windows-core", - "windows-targets 0.48.5", -] - -[[package]] -name = "windows-core" -version = "0.51.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" -dependencies = [ - "windows-targets 0.48.5", -] - -[[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.5", -] - -[[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", -] - -[[package]] -name = "windows-targets" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" -dependencies = [ - "windows_aarch64_gnullvm 0.48.5", - "windows_aarch64_msvc 0.48.5", - "windows_i686_gnu 0.48.5", - "windows_i686_msvc 0.48.5", - "windows_x86_64_gnu 0.48.5", - "windows_x86_64_gnullvm 0.48.5", - "windows_x86_64_msvc 0.48.5", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" - -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - -[[package]] -name = "windows_i686_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" - -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - -[[package]] -name = "windows_i686_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.48.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" - -[[package]] -name = "winnow" -version = "0.5.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3b801d0e0a6726477cc207f60162da452f3a95adb368399bef20a946e06f65c" -dependencies = [ - "memchr", -] - -[[package]] -name = "winreg" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - -[[package]] -name = "wyz" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" -dependencies = [ - "tap", -] - -[[package]] -name = "x25519-dalek" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f" -dependencies = [ - "curve25519-dalek 3.2.0", - "rand_core 0.5.1", - "zeroize", -] - -[[package]] -name = "x25519-dalek" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb66477291e7e8d2b0ff1bcb900bf29489a9692816d79874bea351e7a8b6de96" -dependencies = [ - "curve25519-dalek 4.1.1", - "rand_core 0.6.4", - "serde", - "zeroize", -] - -[[package]] -name = "x509-parser" -version = "0.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb9bace5b5589ffead1afb76e43e34cff39cd0f3ce7e170ae0c29e53b88eb1c" -dependencies = [ - "asn1-rs 0.3.1", - "base64 0.13.1", - "data-encoding", - "der-parser 7.0.0", - "lazy_static", - "nom", - "oid-registry 0.4.0", - "ring 0.16.20", - "rusticata-macros", - "thiserror", - "time", -] - -[[package]] -name = "x509-parser" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0ecbeb7b67ce215e40e3cc7f2ff902f94a223acf44995934763467e7b1febc8" -dependencies = [ - "asn1-rs 0.5.2", - "base64 0.13.1", - "data-encoding", - "der-parser 8.2.0", - "lazy_static", - "nom", - "oid-registry 0.6.1", - "rusticata-macros", - "thiserror", - "time", -] - -[[package]] -name = "xcm" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "bounded-collections", - "derivative", - "impl-trait-for-tuples", - "log", - "parity-scale-codec", - "scale-info", - "serde", - "sp-weights", - "xcm-procedural", -] - -[[package]] -name = "xcm-builder" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "frame-support", - "frame-system", - "impl-trait-for-tuples", - "log", - "pallet-transaction-payment", - "parity-scale-codec", - "polkadot-parachain", - "scale-info", - "sp-arithmetic", - "sp-io", - "sp-runtime", - "sp-std", - "sp-weights", - "xcm", - "xcm-executor", -] - -[[package]] -name = "xcm-emulator" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" -dependencies = [ - "casey", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "cumulus-primitives-parachain-inherent", - "cumulus-test-relay-sproof-builder", - "cumulus-test-service", - "frame-support", - "frame-system", - "log", - "pallet-balances", - "pallet-message-queue", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "paste", - "polkadot-primitives", - "polkadot-runtime-parachains", - "quote", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-std", - "sp-trie", - "xcm", - "xcm-executor", -] - -[[package]] -name = "xcm-executor" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "environmental", - "frame-benchmarking", - "frame-support", - "impl-trait-for-tuples", - "log", - "parity-scale-codec", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "sp-weights", - "xcm", -] - -[[package]] -name = "xcm-procedural" -version = "0.9.43" -source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" -dependencies = [ - "Inflector", - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "yamux" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d9ba232399af1783a58d8eb26f6b5006fbefe2dc9ef36bd283324792d03ea5" -dependencies = [ - "futures", - "log", - "nohash-hasher", - "parking_lot 0.12.1", - "rand 0.8.5", - "static_assertions", -] - -[[package]] -name = "yasna" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" -dependencies = [ - "time", -] - -[[package]] -name = "zeroize" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" -dependencies = [ - "zeroize_derive", -] - -[[package]] -name = "zeroize_derive" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - -[[package]] -name = "zstd" -version = "0.11.2+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" -dependencies = [ - "zstd-safe 5.0.2+zstd.1.5.2", -] - -[[package]] -name = "zstd" -version = "0.12.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" -dependencies = [ - "zstd-safe 6.0.6", -] - -[[package]] -name = "zstd-safe" -version = "5.0.2+zstd.1.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" -dependencies = [ - "libc", - "zstd-sys", -] - -[[package]] -name = "zstd-safe" -version = "6.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" -dependencies = [ - "libc", - "zstd-sys", -] - -[[package]] -name = "zstd-sys" -version = "2.0.9+zstd.1.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" -dependencies = [ - "cc", - "pkg-config", -] diff --git a/integration-tests/src/tests/basic_comms.rs b/integration-tests/src/tests/basic_comms.rs index dcf40cf1b..19e62e1c0 100644 --- a/integration-tests/src/tests/basic_comms.rs +++ b/integration-tests/src/tests/basic_comms.rs @@ -31,6 +31,7 @@ fn dmp() { }); Polimec::execute_with(|| { + let events = Polimec::events(); assert_expected_events!( Polimec, vec![ diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 292b20b0f..60be780b2 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -1920,7 +1920,10 @@ impl Pallet { ensure!(project_details.status == ProjectStatus::FundingSuccessful, Error::::NotAllowed); ensure!( project_details.hrmp_channel_status == - HRMPChannelStatus { project_to_polimec: ChannelStatus::Open, polimec_to_project: ChannelStatus::Open }, + HRMPChannelStatus { + project_to_polimec: ChannelStatus::Open, + polimec_to_project: ChannelStatus::Open + }, Error::::CommsNotEstablished ); if project_details.migration_readiness_check.is_none() { @@ -2000,7 +2003,9 @@ impl Pallet { // TODO: check if this is too low performance. Maybe we want a new map of query_id -> project_id let (project_id, mut project_details, mut migration_check) = ProjectsDetails::::iter() .find_map(|(project_id, details)| { - if let Some(check @ MigrationReadinessCheck { holding_check, pallet_check }) = details.migration_readiness_check { + if let Some(check @ MigrationReadinessCheck { holding_check, pallet_check }) = + details.migration_readiness_check + { if holding_check.0 == query_id || pallet_check.0 == query_id { return Some((project_id, details, check.clone())) } @@ -2045,7 +2050,7 @@ impl Pallet { _ => { migration_check.holding_check.1 = CheckOutcome::Failed; Self::deposit_event(Event::::MigrationCheckResponseRejected { query_id, response }); - } + }, } }, @@ -2079,7 +2084,6 @@ impl Pallet { // * Update storage * - // * Emit events * Self::deposit_event(Event::::MigrationStarted { project_id }); diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index fb5d70e2e..781bea056 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -194,8 +194,8 @@ impl< assert_eq!(reserved, plmc_amount); }); } - println!("NEXT") - } + println!("NEXT") + } pub fn mint_plmc_to(&mut self, mapping: Vec>) { self.execute(|| { diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 44b65cb05..e9446ad92 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -310,6 +310,9 @@ parameter_types! { pub const MinVestedTransfer: u64 = 256 * 2; pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); + pub PolimecReceiverInfo: xcm::v3::PalletInfo = xcm::v3::PalletInfo::new( + 51, "PolimecReceiver".into(), "polimec_receiver".into(), 0, 1, 0 + ).unwrap(); } impl pallet_linear_release::Config for TestRuntime { type Balance = Balance; @@ -363,6 +366,7 @@ impl Config for TestRuntime { type TreasuryAccount = TreasuryAccount; type Vesting = Vesting; type WeightInfo = weights::SubstrateWeight; + type PolimecReceiverInfo = PolimecReceiverInfo; } // Build genesis storage according to the mock runtime. diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index ad64b6fad..75116ff7e 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -205,8 +205,8 @@ pub mod storage_types { pub parachain_id: Option, /// Migration readiness check pub migration_readiness_check: Option, - /// HRMP Channel status - pub hrmp_channel_status: HRMPChannelStatus, + /// HRMP Channel status + pub hrmp_channel_status: HRMPChannelStatus, } /// Tells on_initialize what to do with the project #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] @@ -695,19 +695,19 @@ pub mod inner_types { Failed, } - #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] - pub struct HRMPChannelStatus { - pub project_to_polimec: ChannelStatus, - pub polimec_to_project: ChannelStatus, - } - - #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] - pub enum ChannelStatus { - /// hrmp channel is closed. - Closed, - /// hrmp channel is open. - Open, - /// request for a hrmp channel was sent to the relay. Waiting for response. - AwaitingAcceptance, - } + #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] + pub struct HRMPChannelStatus { + pub project_to_polimec: ChannelStatus, + pub polimec_to_project: ChannelStatus, + } + + #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] + pub enum ChannelStatus { + /// hrmp channel is closed. + Closed, + /// hrmp channel is open. + Open, + /// request for a hrmp channel was sent to the relay. Waiting for response. + AwaitingAcceptance, + } } From 85e817f727465a54e590558632ad4c2ca3fffc0a Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 8 Nov 2023 17:10:47 +0100 Subject: [PATCH 012/212] add cargo lock --- Cargo.lock | 15046 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 15046 insertions(+) create mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 000000000..1c94625c7 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,15046 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + +[[package]] +name = "addr2line" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" +dependencies = [ + "gimli 0.27.3", +] + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli 0.28.0", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aead" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" +dependencies = [ + "generic-array 0.14.7", +] + +[[package]] +name = "aead" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" +dependencies = [ + "generic-array 0.14.7", + "rand_core 0.6.4", +] + +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common", + "generic-array 0.14.7", +] + +[[package]] +name = "aes" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" +dependencies = [ + "aes-soft", + "aesni", + "cipher 0.2.5", +] + +[[package]] +name = "aes" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" +dependencies = [ + "cfg-if", + "cipher 0.3.0", + "cpufeatures", + "opaque-debug 0.3.0", +] + +[[package]] +name = "aes" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac1f845298e95f983ff1944b728ae08b8cebab80d684f0a832ed0fc74dfa27e2" +dependencies = [ + "cfg-if", + "cipher 0.4.4", + "cpufeatures", +] + +[[package]] +name = "aes-gcm" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df5f85a83a7d8b0442b6aa7b504b8212c1733da07b98aae43d4bc21b2cb3cdf6" +dependencies = [ + "aead 0.4.3", + "aes 0.7.5", + "cipher 0.3.0", + "ctr 0.8.0", + "ghash 0.4.4", + "subtle", +] + +[[package]] +name = "aes-gcm" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" +dependencies = [ + "aead 0.5.2", + "aes 0.8.3", + "cipher 0.4.4", + "ctr 0.9.2", + "ghash 0.5.0", + "subtle", +] + +[[package]] +name = "aes-soft" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" +dependencies = [ + "cipher 0.2.5", + "opaque-debug 0.3.0", +] + +[[package]] +name = "aesni" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" +dependencies = [ + "cipher 0.2.5", + "opaque-debug 0.3.0", +] + +[[package]] +name = "ahash" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" +dependencies = [ + "getrandom 0.2.11", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +dependencies = [ + "cfg-if", + "getrandom 0.2.11", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "always-assert" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4436e0292ab1bb631b42973c61205e704475fe8126af845c8d923c0996328127" + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anstream" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" + +[[package]] +name = "anstyle-parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" +dependencies = [ + "anstyle", + "windows-sys 0.48.0", +] + +[[package]] +name = "anyhow" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" + +[[package]] +name = "approx" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6" +dependencies = [ + "num-traits", +] + +[[package]] +name = "arc-swap" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" + +[[package]] +name = "array-bytes" +version = "4.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52f63c5c1316a16a4b35eaac8b76a98248961a533f061684cb2a7cb0eafb6c6" + +[[package]] +name = "array-bytes" +version = "6.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de17a919934ad8c5cc99a1a74de4e2dab95d6121a8f27f94755ff525b630382c" + +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "asn1-rs" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30ff05a702273012438132f449575dbc804e27b2f3cbe3069aa237d26c98fa33" +dependencies = [ + "asn1-rs-derive 0.1.0", + "asn1-rs-impl", + "displaydoc", + "nom", + "num-traits", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "asn1-rs" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6fd5ddaf0351dff5b8da21b2fb4ff8e08ddd02857f0bf69c47639106c0fff0" +dependencies = [ + "asn1-rs-derive 0.4.0", + "asn1-rs-impl", + "displaydoc", + "nom", + "num-traits", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "asn1-rs-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db8b7511298d5b7784b40b092d9e9dcd3a627a5707e4b5e507931ab0d44eeebf" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "synstructure", +] + +[[package]] +name = "asn1-rs-derive" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "726535892e8eae7e70657b4c8ea93d26b8553afb1ce617caee529ef96d7dee6c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "synstructure", +] + +[[package]] +name = "asn1-rs-impl" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2777730b2039ac0f95f093556e61b6d26cebed5393ca6f152717777cec3a42ed" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "assert_matches" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" + +[[package]] +name = "assert_matches2" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15832d94c458da98cac0ffa6eca52cc19c2a3c6c951058500a5ae8f01f0fdf56" + +[[package]] +name = "assets-common" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "cumulus-primitives-core", + "frame-support", + "log", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-std", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "async-channel" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" +dependencies = [ + "concurrent-queue", + "event-listener", + "futures-core", +] + +[[package]] +name = "async-io" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" +dependencies = [ + "async-lock", + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-lite", + "log", + "parking", + "polling", + "rustix 0.37.27", + "slab", + "socket2 0.4.10", + "waker-fn", +] + +[[package]] +name = "async-lock" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" +dependencies = [ + "event-listener", +] + +[[package]] +name = "async-recursion" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "async-trait" +version = "0.1.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "asynchronous-codec" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4057f2c32adbb2fc158e22fb38433c8e9bbf76b75a4732c7c0cbaf695fb65568" +dependencies = [ + "bytes", + "futures-sink", + "futures-util", + "memchr", + "pin-project-lite 0.2.13", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line 0.21.0", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object 0.32.1", + "rustc-demangle", +] + +[[package]] +name = "base-x" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" + +[[package]] +name = "base16ct" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349a06037c7bf932dd7e7d1f653678b2038b9ad46a74102f1fc7bd7872678cce" + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" + +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + +[[package]] +name = "beef" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" +dependencies = [ + "serde", +] + +[[package]] +name = "binary-merkle-tree" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "hash-db", + "log", +] + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bindgen" +version = "0.65.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5" +dependencies = [ + "bitflags 1.3.2", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "peeking_take_while", + "prettyplease 0.2.15", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.39", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "blake2b_simd" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23285ad32269793932e830392f2fe2f83e26488fd3ec778883a93c8323735780" +dependencies = [ + "arrayref", + "arrayvec 0.7.4", + "constant_time_eq", +] + +[[package]] +name = "blake2s_simd" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94230421e395b9920d23df13ea5d77a20e1725331f90fbbf6df6040b33f756ae" +dependencies = [ + "arrayref", + "arrayvec 0.7.4", + "constant_time_eq", +] + +[[package]] +name = "blake3" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0231f06152bf547e9c2b5194f247cd97aacf6dcd8b15d8e5ec0663f64580da87" +dependencies = [ + "arrayref", + "arrayvec 0.7.4", + "cc", + "cfg-if", + "constant_time_eq", +] + +[[package]] +name = "block-buffer" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" +dependencies = [ + "block-padding 0.1.5", + "byte-tools", + "byteorder", + "generic-array 0.12.4", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array 0.14.7", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array 0.14.7", +] + +[[package]] +name = "block-modes" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a0e8073e8baa88212fb5823574c02ebccb395136ba9a164ab89379ec6072f0" +dependencies = [ + "block-padding 0.2.1", + "cipher 0.2.5", +] + +[[package]] +name = "block-padding" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" +dependencies = [ + "byte-tools", +] + +[[package]] +name = "block-padding" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" + +[[package]] +name = "bounded-collections" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca548b6163b872067dc5eb82fd130c56881435e30367d2073594a3d9744120dd" +dependencies = [ + "log", + "parity-scale-codec", + "scale-info", + "serde", +] + +[[package]] +name = "bounded-vec" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68534a48cbf63a4b1323c433cf21238c9ec23711e0df13b08c33e5c2082663ce" +dependencies = [ + "thiserror", +] + +[[package]] +name = "bs58" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" + +[[package]] +name = "bstr" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223" +dependencies = [ + "lazy_static", + "memchr", + "regex-automata 0.1.10", +] + +[[package]] +name = "bstr" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c79ad7fb2dd38f3dabd76b09c6a5a20c038fc0213ef1e9afd30eb777f120f019" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "build-helper" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdce191bf3fa4995ce948c8c83b4640a1745457a149e73c6db75b4ffe36aad5f" +dependencies = [ + "semver 0.6.0", +] + +[[package]] +name = "bumpalo" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" + +[[package]] +name = "byte-slice-cast" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3ac9f8b63eca6fd385229b3675f6cc0dc5c8a5c8a54a59d4f52ffd670d87b0c" + +[[package]] +name = "byte-tools" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" + +[[package]] +name = "bytemuck" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" + +[[package]] +name = "bzip2-sys" +version = "0.1.11+1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + +[[package]] +name = "camino" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-platform" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12024c4645c97566567129c204f65d5815a8c9aecf30fcbe682b2fe034996d36" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo_metadata" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" +dependencies = [ + "camino", + "cargo-platform", + "semver 1.0.20", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "casey" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614586263949597dcc18675da12ef9b429135e13628d92eb8b8c6fa50ca5656b" +dependencies = [ + "syn 1.0.109", +] + +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "jobserver", + "libc", +] + +[[package]] +name = "ccm" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aca1a8fbc20b50ac9673ff014abfb2b5f4085ee1a850d408f14a159c5853ac7" +dependencies = [ + "aead 0.3.2", + "cipher 0.2.5", + "subtle", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-expr" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03915af431787e6ffdcc74c645077518c6b6e01f80b761e0fbbfa288536311b3" +dependencies = [ + "smallvec", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + +[[package]] +name = "chacha20" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" +dependencies = [ + "cfg-if", + "cipher 0.3.0", + "cpufeatures", + "zeroize", +] + +[[package]] +name = "chacha20poly1305" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" +dependencies = [ + "aead 0.4.3", + "chacha20", + "cipher 0.3.0", + "poly1305", + "zeroize", +] + +[[package]] +name = "chrono" +version = "0.4.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-targets 0.48.5", +] + +[[package]] +name = "ciborium" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" + +[[package]] +name = "ciborium-ll" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" +dependencies = [ + "ciborium-io", + "half", +] + +[[package]] +name = "cid" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ed9c8b2d17acb8110c46f1da5bf4a696d745e1474a16db0cd2b49cd0249bf2" +dependencies = [ + "core2", + "multibase", + "multihash 0.16.3", + "serde", + "unsigned-varint", +] + +[[package]] +name = "cipher" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" +dependencies = [ + "generic-array 0.14.7", +] + +[[package]] +name = "cipher" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" +dependencies = [ + "generic-array 0.14.7", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", +] + +[[package]] +name = "ckb-merkle-mountain-range" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ccb671c5921be8a84686e6212ca184cb1d7c51cadcdbfcbd1cc3f042f5dfb8" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "clang-sys" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "clap" +version = "4.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac495e00dcec98c83465d5ad66c5c4fabd652fd6686e7c6269b117e729a6f17b" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c77ed9a32a62e6ca27175d00d29d05ca32e396ea1eb5fb01d8256b669cec7663" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "clap_lex" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" + +[[package]] +name = "coarsetime" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71367d3385c716342014ad17e3d19f7788ae514885a1f4c24f500260fb365e1a" +dependencies = [ + "libc", + "once_cell", + "wasi 0.11.0+wasi-snapshot-preview1", + "wasm-bindgen", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "color-print" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a858372ff14bab9b1b30ea504f2a4bc534582aee3e42ba2d41d2a7baba63d5d" +dependencies = [ + "color-print-proc-macro", +] + +[[package]] +name = "color-print-proc-macro" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57e37866456a721d0a404439a1adae37a31be4e0055590d053dfe6981e05003f" +dependencies = [ + "nom", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + +[[package]] +name = "comfy-table" +version = "6.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e959d788268e3bf9d35ace83e81b124190378e4c91c9067524675e33394b8ba" +dependencies = [ + "strum", + "strum_macros", + "unicode-width", +] + +[[package]] +name = "concurrent-queue" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f057a694a54f12365049b0958a1685bb52d567f5593b355fbf685838e873d400" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "console" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" +dependencies = [ + "encode_unicode", + "lazy_static", + "libc", + "unicode-width", + "windows-sys 0.45.0", +] + +[[package]] +name = "const-oid" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" + +[[package]] +name = "constant_time_eq" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" + +[[package]] +name = "core2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" +dependencies = [ + "memchr", +] + +[[package]] +name = "cpp_demangle" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "cpu-time" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9e393a7668fe1fad3075085b86c781883000b4ede868f43627b34a87c8b7ded" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "cpufeatures" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +dependencies = [ + "libc", +] + +[[package]] +name = "cranelift-bforest" +version = "0.95.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1277fbfa94bc82c8ec4af2ded3e639d49ca5f7f3c7eeab2c66accd135ece4e70" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen" +version = "0.95.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6e8c31ad3b2270e9aeec38723888fe1b0ace3bea2b06b3f749ccf46661d3220" +dependencies = [ + "bumpalo", + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-entity", + "cranelift-isle", + "gimli 0.27.3", + "hashbrown 0.13.2", + "log", + "regalloc2", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.95.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8ac5ac30d62b2d66f12651f6b606dbdfd9c2cfd0908de6b387560a277c5c9da" +dependencies = [ + "cranelift-codegen-shared", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.95.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd82b8b376247834b59ed9bdc0ddeb50f517452827d4a11bccf5937b213748b8" + +[[package]] +name = "cranelift-entity" +version = "0.95.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40099d38061b37e505e63f89bab52199037a72b931ad4868d9089ff7268660b0" +dependencies = [ + "serde", +] + +[[package]] +name = "cranelift-frontend" +version = "0.95.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64a25d9d0a0ae3079c463c34115ec59507b4707175454f0eee0891e83e30e82d" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-isle" +version = "0.95.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80de6a7d0486e4acbd5f9f87ec49912bf4c8fb6aea00087b989685460d4469ba" + +[[package]] +name = "cranelift-native" +version = "0.95.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb6b03e0e03801c4b3fd8ce0758a94750c07a44e7944cc0ffbf0d3f2e7c79b00" +dependencies = [ + "cranelift-codegen", + "libc", + "target-lexicon", +] + +[[package]] +name = "cranelift-wasm" +version = "0.95.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff3220489a3d928ad91e59dd7aeaa8b3de18afb554a6211213673a71c90737ac" +dependencies = [ + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "itertools 0.10.5", + "log", + "smallvec", + "wasmparser", + "wasmtime-types", +] + +[[package]] +name = "crc" +version = "3.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86ec7a15cbe22e59248fc7eadb1907dab5ba09372595da4d73dd805ed4417dfe" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + +[[package]] +name = "crc32fast" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "criterion" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" +dependencies = [ + "anes", + "cast", + "ciborium", + "clap", + "criterion-plot", + "futures", + "is-terminal", + "itertools 0.10.5", + "num-traits", + "once_cell", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_derive", + "serde_json", + "tinytemplate", + "tokio", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" +dependencies = [ + "cast", + "itertools 0.10.5", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset 0.9.0", + "scopeguard", +] + +[[package]] +name = "crossbeam-queue" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-bigint" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" +dependencies = [ + "generic-array 0.14.7", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-bigint" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" +dependencies = [ + "generic-array 0.14.7", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array 0.14.7", + "rand_core 0.6.4", + "typenum", +] + +[[package]] +name = "crypto-mac" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" +dependencies = [ + "generic-array 0.14.7", + "subtle", +] + +[[package]] +name = "crypto-mac" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +dependencies = [ + "generic-array 0.14.7", + "subtle", +] + +[[package]] +name = "ctr" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "049bb91fb4aaf0e3c7efa6cd5ef877dbbbd15b39dad06d9948de4ec8a75761ea" +dependencies = [ + "cipher 0.3.0", +] + +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher 0.4.4", +] + +[[package]] +name = "cumulus-client-cli" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "clap", + "parity-scale-codec", + "sc-chain-spec", + "sc-cli", + "sc-service", + "sp-core", + "sp-runtime", + "url", +] + +[[package]] +name = "cumulus-client-collator" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "cumulus-client-consensus-common", + "cumulus-client-network", + "cumulus-primitives-core", + "futures", + "parity-scale-codec", + "parking_lot 0.12.1", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-overseer", + "polkadot-primitives", + "sc-client-api", + "sp-api", + "sp-consensus", + "sp-core", + "sp-runtime", + "tracing", +] + +[[package]] +name = "cumulus-client-consensus-aura" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "async-trait", + "cumulus-client-collator", + "cumulus-client-consensus-common", + "cumulus-client-consensus-proposer", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-relay-chain-interface", + "futures", + "parity-scale-codec", + "polkadot-node-primitives", + "polkadot-overseer", + "polkadot-primitives", + "sc-client-api", + "sc-consensus", + "sc-consensus-aura", + "sc-consensus-slots", + "sc-telemetry", + "sp-api", + "sp-application-crypto", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-keystore", + "sp-runtime", + "sp-state-machine", + "sp-timestamp", + "substrate-prometheus-endpoint", + "tracing", +] + +[[package]] +name = "cumulus-client-consensus-common" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "async-trait", + "cumulus-client-pov-recovery", + "cumulus-primitives-core", + "cumulus-relay-chain-interface", + "dyn-clone", + "futures", + "log", + "parity-scale-codec", + "polkadot-primitives", + "sc-client-api", + "sc-consensus", + "schnellru", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-runtime", + "sp-trie", + "substrate-prometheus-endpoint", + "tracing", +] + +[[package]] +name = "cumulus-client-consensus-proposer" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "anyhow", + "async-trait", + "cumulus-primitives-parachain-inherent", + "sp-consensus", + "sp-inherents", + "sp-runtime", + "sp-state-machine", + "thiserror", +] + +[[package]] +name = "cumulus-client-consensus-relay-chain" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "async-trait", + "cumulus-client-consensus-common", + "cumulus-primitives-core", + "cumulus-relay-chain-interface", + "futures", + "parking_lot 0.12.1", + "sc-consensus", + "sp-api", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-inherents", + "sp-runtime", + "substrate-prometheus-endpoint", + "tracing", +] + +[[package]] +name = "cumulus-client-network" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "async-trait", + "cumulus-relay-chain-interface", + "futures", + "futures-timer", + "parity-scale-codec", + "parking_lot 0.12.1", + "polkadot-node-primitives", + "polkadot-parachain", + "polkadot-primitives", + "sc-client-api", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-runtime", + "sp-state-machine", + "tracing", +] + +[[package]] +name = "cumulus-client-pov-recovery" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "async-trait", + "cumulus-primitives-core", + "cumulus-relay-chain-interface", + "futures", + "futures-timer", + "parity-scale-codec", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-overseer", + "polkadot-primitives", + "rand 0.8.5", + "sc-client-api", + "sc-consensus", + "sp-consensus", + "sp-maybe-compressed-blob", + "sp-runtime", + "tracing", +] + +[[package]] +name = "cumulus-client-service" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "cumulus-client-cli", + "cumulus-client-collator", + "cumulus-client-consensus-common", + "cumulus-client-network", + "cumulus-client-pov-recovery", + "cumulus-primitives-core", + "cumulus-relay-chain-inprocess-interface", + "cumulus-relay-chain-interface", + "cumulus-relay-chain-minimal-node", + "futures", + "polkadot-primitives", + "sc-client-api", + "sc-consensus", + "sc-network", + "sc-network-sync", + "sc-network-transactions", + "sc-rpc", + "sc-service", + "sc-sysinfo", + "sc-telemetry", + "sc-transaction-pool", + "sc-utils", + "sp-api", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-runtime", + "sp-transaction-pool", +] + +[[package]] +name = "cumulus-pallet-aura-ext" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "frame-support", + "frame-system", + "pallet-aura", + "parity-scale-codec", + "scale-info", + "sp-application-crypto", + "sp-consensus-aura", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "cumulus-pallet-dmp-queue" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "cumulus-primitives-core", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std", + "xcm", +] + +[[package]] +name = "cumulus-pallet-parachain-system" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "bytes", + "cumulus-pallet-parachain-system-proc-macro", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "environmental", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "polkadot-parachain", + "scale-info", + "sp-core", + "sp-externalities", + "sp-inherents", + "sp-io", + "sp-runtime", + "sp-state-machine", + "sp-std", + "sp-trie", + "sp-version", + "xcm", +] + +[[package]] +name = "cumulus-pallet-parachain-system-proc-macro" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "cumulus-pallet-session-benchmarking" +version = "3.0.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "pallet-session", + "parity-scale-codec", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "cumulus-pallet-xcm" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "cumulus-primitives-core", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std", + "xcm", +] + +[[package]] +name = "cumulus-pallet-xcmp-queue" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "cumulus-primitives-core", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "polkadot-runtime-common", + "rand_chacha 0.3.1", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std", + "xcm", + "xcm-executor", +] + +[[package]] +name = "cumulus-primitives-core" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-primitives", + "scale-info", + "sp-api", + "sp-runtime", + "sp-std", + "sp-trie", + "xcm", +] + +[[package]] +name = "cumulus-primitives-parachain-inherent" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "async-trait", + "cumulus-primitives-core", + "cumulus-relay-chain-interface", + "cumulus-test-relay-sproof-builder", + "parity-scale-codec", + "sc-client-api", + "scale-info", + "sp-api", + "sp-core", + "sp-inherents", + "sp-runtime", + "sp-state-machine", + "sp-std", + "sp-storage", + "sp-trie", + "tracing", +] + +[[package]] +name = "cumulus-primitives-timestamp" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "cumulus-primitives-core", + "futures", + "parity-scale-codec", + "sp-inherents", + "sp-std", + "sp-timestamp", +] + +[[package]] +name = "cumulus-primitives-utility" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "cumulus-primitives-core", + "frame-support", + "log", + "parity-scale-codec", + "polkadot-runtime-common", + "sp-io", + "sp-runtime", + "sp-std", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "cumulus-relay-chain-inprocess-interface" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "async-trait", + "cumulus-primitives-core", + "cumulus-relay-chain-interface", + "futures", + "futures-timer", + "polkadot-cli", + "polkadot-client", + "polkadot-service", + "sc-cli", + "sc-client-api", + "sc-sysinfo", + "sc-telemetry", + "sc-tracing", + "sp-api", + "sp-consensus", + "sp-core", + "sp-runtime", + "sp-state-machine", +] + +[[package]] +name = "cumulus-relay-chain-interface" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "async-trait", + "cumulus-primitives-core", + "futures", + "jsonrpsee-core", + "parity-scale-codec", + "polkadot-overseer", + "sc-client-api", + "sp-api", + "sp-blockchain", + "sp-state-machine", + "thiserror", +] + +[[package]] +name = "cumulus-relay-chain-minimal-node" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "array-bytes 6.2.0", + "async-trait", + "cumulus-primitives-core", + "cumulus-relay-chain-interface", + "cumulus-relay-chain-rpc-interface", + "futures", + "lru 0.9.0", + "polkadot-availability-recovery", + "polkadot-collator-protocol", + "polkadot-core-primitives", + "polkadot-network-bridge", + "polkadot-node-collation-generation", + "polkadot-node-core-runtime-api", + "polkadot-node-network-protocol", + "polkadot-node-subsystem-util", + "polkadot-overseer", + "polkadot-primitives", + "sc-authority-discovery", + "sc-client-api", + "sc-network", + "sc-network-common", + "sc-service", + "sc-tracing", + "sc-utils", + "sp-api", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-runtime", + "tokio", + "tracing", +] + +[[package]] +name = "cumulus-relay-chain-rpc-interface" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "async-trait", + "cumulus-primitives-core", + "cumulus-relay-chain-interface", + "futures", + "futures-timer", + "jsonrpsee", + "lru 0.9.0", + "parity-scale-codec", + "polkadot-overseer", + "sc-client-api", + "sc-rpc-api", + "sc-service", + "serde", + "serde_json", + "sp-api", + "sp-authority-discovery", + "sp-consensus-babe", + "sp-core", + "sp-state-machine", + "sp-storage", + "tokio", + "tracing", + "url", +] + +[[package]] +name = "cumulus-test-relay-sproof-builder" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "cumulus-primitives-core", + "parity-scale-codec", + "polkadot-primitives", + "sp-runtime", + "sp-state-machine", + "sp-std", +] + +[[package]] +name = "cumulus-test-relay-validation-worker-provider" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "polkadot-node-core-pvf-worker", + "toml 0.7.8", +] + +[[package]] +name = "cumulus-test-runtime" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "cumulus-pallet-parachain-system", + "cumulus-primitives-core", + "cumulus-primitives-timestamp", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "pallet-balances", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-block-builder", + "sp-core", + "sp-inherents", + "sp-io", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", +] + +[[package]] +name = "cumulus-test-service" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "async-trait", + "clap", + "criterion", + "cumulus-client-cli", + "cumulus-client-consensus-common", + "cumulus-client-consensus-relay-chain", + "cumulus-client-pov-recovery", + "cumulus-client-service", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-relay-chain-inprocess-interface", + "cumulus-relay-chain-interface", + "cumulus-relay-chain-minimal-node", + "cumulus-test-relay-validation-worker-provider", + "cumulus-test-runtime", + "frame-system", + "frame-system-rpc-runtime-api", + "jsonrpsee", + "pallet-transaction-payment", + "parachains-common", + "parity-scale-codec", + "polkadot-cli", + "polkadot-node-subsystem", + "polkadot-overseer", + "polkadot-primitives", + "polkadot-service", + "polkadot-test-service", + "rand 0.8.5", + "sc-basic-authorship", + "sc-chain-spec", + "sc-cli", + "sc-client-api", + "sc-consensus", + "sc-executor", + "sc-network", + "sc-service", + "sc-telemetry", + "sc-tracing", + "sc-transaction-pool", + "sc-transaction-pool-api", + "serde", + "sp-arithmetic", + "sp-blockchain", + "sp-core", + "sp-io", + "sp-keyring", + "sp-runtime", + "sp-state-machine", + "sp-timestamp", + "sp-tracing", + "sp-trie", + "substrate-test-client", + "tokio", + "tracing", + "url", +] + +[[package]] +name = "curve25519-dalek" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a9b85542f99a2dfa2a1b8e192662741c9859a846b296bef1c92ef9b58b5a216" +dependencies = [ + "byteorder", + "digest 0.8.1", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b9fdf9972b2bd6af2d913799d9ebc165ea4d2e65878e329d9c6b372c4491b61" +dependencies = [ + "byteorder", + "digest 0.9.0", + "rand_core 0.5.1", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek" +version = "4.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89b8c6a2e4b1f45971ad09761aafb85514a84744b67a95e32c3cc1352d1f65c" +dependencies = [ + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", + "fiat-crypto", + "platforms 3.2.0", + "rustc_version 0.4.0", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "cxx" +version = "1.0.110" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7129e341034ecb940c9072817cd9007974ea696844fc4dd582dc1653a7fbe2e8" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.110" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2a24f3f5f8eed71936f21e570436f024f5c2e25628f7496aa7ccd03b90109d5" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn 2.0.39", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.110" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06fdd177fc61050d63f67f5bd6351fac6ab5526694ea8e359cd9cd3b75857f44" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.110" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "587663dd5fb3d10932c8aecfe7c844db1bcf0aee93eeab08fac13dc1212c2e7f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "darling" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 1.0.109", +] + +[[package]] +name = "darling_macro" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" +dependencies = [ + "darling_core", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "data-encoding" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" + +[[package]] +name = "data-encoding-macro" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c904b33cc60130e1aeea4956ab803d08a3f4a0ca82d64ed757afac3891f2bb99" +dependencies = [ + "data-encoding", + "data-encoding-macro-internal", +] + +[[package]] +name = "data-encoding-macro-internal" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fdf3fce3ce863539ec1d7fd1b6dcc3c645663376b43ed376bbf887733e4f772" +dependencies = [ + "data-encoding", + "syn 1.0.109", +] + +[[package]] +name = "der" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a467a65c5e759bce6e65eaf91cc29f466cdc57cb65777bd646872a8a1fd4de" +dependencies = [ + "const-oid", + "pem-rfc7468", + "zeroize", +] + +[[package]] +name = "der" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fffa369a668c8af7dbf8b5e56c9f744fbd399949ed171606040001947de40b1c" +dependencies = [ + "const-oid", + "zeroize", +] + +[[package]] +name = "der-parser" +version = "7.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe398ac75057914d7d07307bf67dc7f3f574a26783b4fc7805a20ffa9f506e82" +dependencies = [ + "asn1-rs 0.3.1", + "displaydoc", + "nom", + "num-bigint", + "num-traits", + "rusticata-macros", +] + +[[package]] +name = "der-parser" +version = "8.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbd676fbbab537128ef0278adb5576cf363cff6aa22a7b24effe97347cfab61e" +dependencies = [ + "asn1-rs 0.5.2", + "displaydoc", + "nom", + "num-bigint", + "num-traits", + "rusticata-macros", +] + +[[package]] +name = "deranged" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive-syn-parse" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79116f119dd1dba1abf1f3405f03b9b0e79a27a3883864bfebded8a3dc768cd" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_builder" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d07adf7be193b71cc36b193d0f5fe60b918a3a9db4dad0449f57bcfd519704a3" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f91d4cfa921f1c05904dc3c57b4a32c38aed3340cce209f3a6fd1478babafc4" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_builder_macro" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f0314b72bed045f3a68671b3c86328386762c93f82d98c65c3cb5e5f573dd68" +dependencies = [ + "derive_builder_core", + "syn 1.0.109", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version 0.4.0", + "syn 1.0.109", +] + +[[package]] +name = "difflib" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" + +[[package]] +name = "digest" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +dependencies = [ + "generic-array 0.12.4", +] + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array 0.14.7", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "const-oid", + "crypto-common", + "subtle", +] + +[[package]] +name = "directories" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f51c5d4ddabd36886dd3e1438cb358cdcb0d7c499cb99cb4ac2e38e18b5cb210" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "directories-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "displaydoc" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "downcast" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" + +[[package]] +name = "downcast-rs" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" + +[[package]] +name = "dtoa" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653" + +[[package]] +name = "dyn-clonable" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e9232f0e607a262ceb9bd5141a3dfb3e4db6994b31989bbfd845878cba59fd4" +dependencies = [ + "dyn-clonable-impl", + "dyn-clone", +] + +[[package]] +name = "dyn-clonable-impl" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "558e40ea573c374cf53507fd240b7ee2f5477df7cfebdb97323ec61c719399c5" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "dyn-clone" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "545b22097d44f8a9581187cdf93de7a71e4722bf51200cfaba810865b49a495d" + +[[package]] +name = "ecdsa" +version = "0.14.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413301934810f597c1d19ca71c8710e99a3f1ba28a0d2ebc01551a2daeea3c5c" +dependencies = [ + "der 0.6.1", + "elliptic-curve 0.12.3", + "rfc6979 0.3.1", + "signature 1.6.4", +] + +[[package]] +name = "ecdsa" +version = "0.16.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" +dependencies = [ + "der 0.7.8", + "digest 0.10.7", + "elliptic-curve 0.13.6", + "rfc6979 0.4.0", + "signature 2.1.0", + "spki 0.7.2", +] + +[[package]] +name = "ed25519" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91cff35c70bba8a626e3185d8cd48cc11b5437e1a5bcd15b9b5fa3c64b6dfee7" +dependencies = [ + "signature 1.6.4", +] + +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "pkcs8 0.10.2", + "signature 2.1.0", +] + +[[package]] +name = "ed25519-dalek" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" +dependencies = [ + "curve25519-dalek 3.2.0", + "ed25519 1.5.3", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "ed25519-dalek" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" +dependencies = [ + "curve25519-dalek 4.1.1", + "ed25519 2.2.3", + "rand_core 0.6.4", + "serde", + "sha2 0.10.8", + "zeroize", +] + +[[package]] +name = "ed25519-zebra" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c24f403d068ad0b359e577a77f92392118be3f3c927538f2bb544a5ecd828c6" +dependencies = [ + "curve25519-dalek 3.2.0", + "hashbrown 0.12.3", + "hex", + "rand_core 0.6.4", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "elliptic-curve" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7bb888ab5300a19b8e5bceef25ac745ad065f3c9f7efc6de1b91958110891d3" +dependencies = [ + "base16ct 0.1.1", + "crypto-bigint 0.4.9", + "der 0.6.1", + "digest 0.10.7", + "ff 0.12.1", + "generic-array 0.14.7", + "group 0.12.1", + "hkdf", + "pem-rfc7468", + "pkcs8 0.9.0", + "rand_core 0.6.4", + "sec1 0.3.0", + "subtle", + "zeroize", +] + +[[package]] +name = "elliptic-curve" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" +dependencies = [ + "base16ct 0.2.0", + "crypto-bigint 0.5.3", + "digest 0.10.7", + "ff 0.13.0", + "generic-array 0.14.7", + "group 0.13.0", + "pkcs8 0.10.2", + "rand_core 0.6.4", + "sec1 0.7.3", + "subtle", + "zeroize", +] + +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + +[[package]] +name = "enum-as-inner" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "enumflags2" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5998b4f30320c9d93aed72f63af821bfdac50465b75428fce77b48ec482c3939" +dependencies = [ + "enumflags2_derive", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "enumn" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "env_logger" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "env_logger" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +dependencies = [ + "humantime", + "is-terminal", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "environmental" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c18ee0ed65a5f1f81cac6b1d213b69c35fa47d4252ad41f1486dbd8226fe36e" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + +[[package]] +name = "exit-future" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e43f2f1833d64e33f15592464d6fdd70f349dda7b1a53088eb83cd94014008c5" +dependencies = [ + "futures", +] + +[[package]] +name = "expander" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a718c0675c555c5f976fff4ea9e2c150fa06cefa201cadef87cfbf9324075881" +dependencies = [ + "blake3", + "fs-err", + "proc-macro2", + "quote", +] + +[[package]] +name = "expander" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3774182a5df13c3d1690311ad32fbe913feef26baba609fa2dd5f72042bd2ab6" +dependencies = [ + "blake2", + "fs-err", + "proc-macro2", + "quote", +] + +[[package]] +name = "expander" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f360349150728553f92e4c997a16af8915f418d3a0f21b440d34c5632f16ed84" +dependencies = [ + "blake2", + "fs-err", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "expander" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f86a749cf851891866c10515ef6c299b5c69661465e9c3bbe7e07a2b77fb0f7" +dependencies = [ + "blake2", + "fs-err", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "fake-simd" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" + +[[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + +[[package]] +name = "fastrand" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] + +[[package]] +name = "fastrand" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" + +[[package]] +name = "fatality" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ad875162843b0d046276327afe0136e9ed3a23d5a754210fb6f1f33610d39ab" +dependencies = [ + "fatality-proc-macro", + "thiserror", +] + +[[package]] +name = "fatality-proc-macro" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5aa1e3ae159e592ad222dc90c5acbad632b527779ba88486abe92782ab268bd" +dependencies = [ + "expander 0.0.4", + "indexmap 1.9.3", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", + "thiserror", +] + +[[package]] +name = "fdlimit" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c4c9e43643f5a3be4ca5b67d26b98031ff9db6806c3440ae32e02e3ceac3f1b" +dependencies = [ + "libc", +] + +[[package]] +name = "ff" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d013fc25338cc558c5c2cfbad646908fb23591e2404481826742b651c9af7160" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "ff" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded41244b729663b1e574f1b4fb731469f69f79c17667b5d776b16cda0479449" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "fiat-crypto" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a481586acf778f1b1455424c343f71124b048ffa5f4fc3f8f6ae9dc432dcb3c7" + +[[package]] +name = "file-per-thread-logger" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84f2e425d9790201ba4af4630191feac6dcc98765b118d4d18e91d23c2353866" +dependencies = [ + "env_logger 0.10.0", + "log", +] + +[[package]] +name = "filetime" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4029edd3e734da6fe05b6cd7bd2960760a616bd2ddd0d59a0124746d6272af0" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.3.5", + "windows-sys 0.48.0", +] + +[[package]] +name = "finality-grandpa" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36530797b9bf31cd4ff126dcfee8170f86b00cfdcea3269d73133cc0415945c3" +dependencies = [ + "either", + "futures", + "futures-timer", + "log", + "num-traits", + "parity-scale-codec", + "parking_lot 0.12.1", + "scale-info", +] + +[[package]] +name = "fixed-hash" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835c052cb0c08c1acf6ffd71c022172e18723949c8282f2b9f27efbc51e64534" +dependencies = [ + "byteorder", + "rand 0.8.5", + "rustc-hex", + "static_assertions", +] + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "flate2" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" +dependencies = [ + "crc32fast", + "libz-sys", + "miniz_oxide", +] + +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" +dependencies = [ + "num-traits", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "fork-tree" +version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "form_urlencoded" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "fragile" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" + +[[package]] +name = "frame-benchmarking" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-support", + "frame-support-procedural", + "frame-system", + "linregress", + "log", + "parity-scale-codec", + "paste", + "scale-info", + "serde", + "sp-api", + "sp-application-crypto", + "sp-core", + "sp-io", + "sp-runtime", + "sp-runtime-interface", + "sp-std", + "sp-storage", + "static_assertions", +] + +[[package]] +name = "frame-benchmarking-cli" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "Inflector", + "array-bytes 4.2.0", + "chrono", + "clap", + "comfy-table", + "frame-benchmarking", + "frame-support", + "frame-system", + "gethostname", + "handlebars", + "itertools 0.10.5", + "lazy_static", + "linked-hash-map", + "log", + "parity-scale-codec", + "rand 0.8.5", + "rand_pcg", + "sc-block-builder", + "sc-cli", + "sc-client-api", + "sc-client-db", + "sc-executor", + "sc-service", + "sc-sysinfo", + "serde", + "serde_json", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-database", + "sp-externalities", + "sp-inherents", + "sp-keystore", + "sp-runtime", + "sp-state-machine", + "sp-std", + "sp-storage", + "sp-trie", + "thiserror", + "thousands", +] + +[[package]] +name = "frame-election-provider-solution-type" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "frame-election-provider-support" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-election-provider-solution-type", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-arithmetic", + "sp-core", + "sp-npos-elections", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "frame-executive" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-support", + "frame-system", + "frame-try-runtime", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-tracing", +] + +[[package]] +name = "frame-metadata" +version = "15.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "878babb0b136e731cc77ec2fd883ff02745ff21e6fb662729953d44923df009c" +dependencies = [ + "cfg-if", + "parity-scale-codec", + "scale-info", + "serde", +] + +[[package]] +name = "frame-remote-externalities" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "async-recursion", + "futures", + "indicatif", + "jsonrpsee", + "log", + "parity-scale-codec", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "spinners", + "substrate-rpc-client", + "tokio", + "tokio-retry", +] + +[[package]] +name = "frame-support" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "bitflags 1.3.2", + "environmental", + "frame-metadata", + "frame-support-procedural", + "impl-trait-for-tuples", + "k256", + "log", + "once_cell", + "parity-scale-codec", + "paste", + "scale-info", + "serde", + "smallvec", + "sp-api", + "sp-arithmetic", + "sp-core", + "sp-core-hashing-proc-macro", + "sp-debug-derive", + "sp-inherents", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-state-machine", + "sp-std", + "sp-tracing", + "sp-weights", + "tt-call", +] + +[[package]] +name = "frame-support-procedural" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "Inflector", + "cfg-expr", + "derive-syn-parse", + "frame-support-procedural-tools", + "itertools 0.10.5", + "proc-macro-warning", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "frame-support-procedural-tools" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-support-procedural-tools-derive", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "frame-support-procedural-tools-derive" +version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "frame-system" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "cfg-if", + "frame-support", + "log", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-version", + "sp-weights", +] + +[[package]] +name = "frame-system-benchmarking" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "frame-system-rpc-runtime-api" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "parity-scale-codec", + "sp-api", +] + +[[package]] +name = "frame-try-runtime" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-support", + "parity-scale-codec", + "sp-api", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "fs-err" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0845fa252299212f0389d64ba26f34fa32cfe41588355f21ed507c59a0f64541" + +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "fs4" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" +dependencies = [ + "rustix 0.38.21", + "windows-sys 0.48.0", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" + +[[package]] +name = "futures-executor" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", + "num_cpus", +] + +[[package]] +name = "futures-io" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" + +[[package]] +name = "futures-lite" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" +dependencies = [ + "fastrand 1.9.0", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite 0.2.13", + "waker-fn", +] + +[[package]] +name = "futures-macro" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "futures-rustls" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2411eed028cdf8c8034eaf21f9915f956b6c3abec4d4c7949ee67f0721127bd" +dependencies = [ + "futures-io", + "rustls 0.20.9", + "webpki 0.22.4", +] + +[[package]] +name = "futures-sink" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" + +[[package]] +name = "futures-task" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" + +[[package]] +name = "futures-timer" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" + +[[package]] +name = "futures-util" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite 0.2.13", + "pin-utils", + "slab", +] + +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + +[[package]] +name = "generic-array" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +dependencies = [ + "typenum", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", + "zeroize", +] + +[[package]] +name = "gethostname" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "ghash" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1583cc1656d7839fd3732b80cf4f38850336cdb9b8ded1cd399ca62958de3c99" +dependencies = [ + "opaque-debug 0.3.0", + "polyval 0.5.3", +] + +[[package]] +name = "ghash" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d930750de5717d2dd0b8c0d42c076c0e884c81a73e6cab859bbd2339c71e3e40" +dependencies = [ + "opaque-debug 0.3.0", + "polyval 0.6.1", +] + +[[package]] +name = "gimli" +version = "0.27.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +dependencies = [ + "fallible-iterator", + "indexmap 1.9.3", + "stable_deref_trait", +] + +[[package]] +name = "gimli" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "globset" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" +dependencies = [ + "aho-corasick", + "bstr 1.7.0", + "fnv", + "log", + "regex", +] + +[[package]] +name = "group" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfbfb3a6cfbd390d5c9564ab283a0349b9b9fcd46a706c1eb10e0db70bfbac7" +dependencies = [ + "ff 0.12.1", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff 0.13.0", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "h2" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap 1.9.3", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "half" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" + +[[package]] +name = "handlebars" +version = "4.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39b3bc2a8f715298032cf5087e58573809374b08160aa7d750582bdb82d2683" +dependencies = [ + "log", + "pest", + "pest_derive", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "hash-db" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e7d7786361d7425ae2fe4f9e407eb0efaa0840f5212d109cc018c40c35c6ab4" + +[[package]] +name = "hash256-std-hasher" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92c171d55b98633f4ed3860808f004099b36c1cc29c42cfc53aa8591b21efcf2" +dependencies = [ + "crunchy", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash 0.7.7", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash 0.8.6", +] + +[[package]] +name = "hashbrown" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-literal" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0" + +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + +[[package]] +name = "hkdf" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" +dependencies = [ + "hmac 0.12.1", +] + +[[package]] +name = "hmac" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" +dependencies = [ + "crypto-mac 0.8.0", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +dependencies = [ + "crypto-mac 0.11.1", + "digest 0.9.0", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "hmac-drbg" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" +dependencies = [ + "digest 0.9.0", + "generic-array 0.14.7", + "hmac 0.8.1", +] + +[[package]] +name = "home" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "hostname" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" +dependencies = [ + "libc", + "match_cfg", + "winapi", +] + +[[package]] +name = "http" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite 0.2.13", +] + +[[package]] +name = "http-range-header" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "hyper" +version = "0.14.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite 0.2.13", + "socket2 0.4.10", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1788965e61b367cd03a62950836d5cd41560c3577d90e40e0819373194d1661c" +dependencies = [ + "http", + "hyper", + "log", + "rustls 0.20.9", + "rustls-native-certs", + "tokio", + "tokio-rustls 0.23.4", +] + +[[package]] +name = "hyper-rustls" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +dependencies = [ + "futures-util", + "http", + "hyper", + "log", + "rustls 0.21.8", + "rustls-native-certs", + "tokio", + "tokio-rustls 0.24.1", + "webpki-roots 0.25.2", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "idna" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "if-addrs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbc0fa01ffc752e9dbc72818cdb072cd028b86be5e09dd04c5a643704fe101a9" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "if-watch" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb892e5777fe09e16f3d44de7802f4daa7267ecbe8c466f19d94e25bb0c303e" +dependencies = [ + "async-io", + "core-foundation", + "fnv", + "futures", + "if-addrs", + "ipnet", + "log", + "rtnetlink", + "system-configuration", + "tokio", + "windows", +] + +[[package]] +name = "impl-codec" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba6a270039626615617f3f36d15fc827041df3b78c439da2cadfa47455a77f2f" +dependencies = [ + "parity-scale-codec", +] + +[[package]] +name = "impl-serde" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc88fc67028ae3db0c853baa36269d398d5f45b6982f95549ff5def78c935cd" +dependencies = [ + "serde", +] + +[[package]] +name = "impl-trait-for-tuples" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d7a9f6330b71fea57921c9b61c47ee6e84f72d394754eff6163ae67e7395eb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +dependencies = [ + "equivalent", + "hashbrown 0.14.2", +] + +[[package]] +name = "indicatif" +version = "0.17.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb28741c9db9a713d93deb3bb9515c20788cef5815265bee4980e87bde7e0f25" +dependencies = [ + "console", + "instant", + "number_prefix", + "portable-atomic", + "unicode-width", +] + +[[package]] +name = "inout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" +dependencies = [ + "generic-array 0.14.7", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "integer-encoding" +version = "3.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bb03732005da905c88227371639bf1ad885cc712789c011c31c5fb3ab3ccf02" + +[[package]] +name = "integer-sqrt" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "276ec31bcb4a9ee45f58bec6f9ec700ae4cf4f4f8f2fa7e06cb406bd5ffdd770" +dependencies = [ + "num-traits", +] + +[[package]] +name = "integration-tests" +version = "0.1.0" +dependencies = [ + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "frame-support", + "frame-system", + "pallet-assets", + "pallet-balances", + "pallet-funding", + "pallet-im-online", + "pallet-message-queue", + "pallet-staking", + "pallet-xcm", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "penpal-runtime", + "polimec-parachain-runtime", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime", + "polkadot-runtime-constants", + "polkadot-runtime-parachains", + "polkadot-service", + "sc-consensus-grandpa", + "scale-info", + "sp-authority-discovery", + "sp-consensus-babe", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "statemint-runtime", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-emulator", + "xcm-executor", +] + +[[package]] +name = "interceptor" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e8a11ae2da61704edada656798b61c94b35ecac2c58eb955156987d5e6be90b" +dependencies = [ + "async-trait", + "bytes", + "log", + "rand 0.8.5", + "rtcp", + "rtp", + "thiserror", + "tokio", + "waitgroup", + "webrtc-srtp", + "webrtc-util", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi 0.3.3", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "ip_network" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2f047c0a98b2f299aa5d6d7088443570faae494e9ae1305e48be000c9e0eb1" + +[[package]] +name = "ipconfig" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" +dependencies = [ + "socket2 0.5.5", + "widestring", + "windows-sys 0.48.0", + "winreg", +] + +[[package]] +name = "ipnet" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" + +[[package]] +name = "is-terminal" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +dependencies = [ + "hermit-abi 0.3.3", + "rustix 0.38.21", + "windows-sys 0.48.0", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" + +[[package]] +name = "jobserver" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +dependencies = [ + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "jsonrpsee" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "367a292944c07385839818bb71c8d76611138e2dedb0677d035b8da21d29c78b" +dependencies = [ + "jsonrpsee-core", + "jsonrpsee-http-client", + "jsonrpsee-proc-macros", + "jsonrpsee-server", + "jsonrpsee-types", + "jsonrpsee-ws-client", + "tracing", +] + +[[package]] +name = "jsonrpsee-client-transport" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8b3815d9f5d5de348e5f162b316dc9cdf4548305ebb15b4eb9328e66cf27d7a" +dependencies = [ + "futures-util", + "http", + "jsonrpsee-core", + "jsonrpsee-types", + "pin-project", + "rustls-native-certs", + "soketto", + "thiserror", + "tokio", + "tokio-rustls 0.24.1", + "tokio-util", + "tracing", + "webpki-roots 0.25.2", +] + +[[package]] +name = "jsonrpsee-core" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b5dde66c53d6dcdc8caea1874a45632ec0fcf5b437789f1e45766a1512ce803" +dependencies = [ + "anyhow", + "arrayvec 0.7.4", + "async-lock", + "async-trait", + "beef", + "futures-channel", + "futures-timer", + "futures-util", + "globset", + "hyper", + "jsonrpsee-types", + "parking_lot 0.12.1", + "rand 0.8.5", + "rustc-hash", + "serde", + "serde_json", + "soketto", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "jsonrpsee-http-client" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e5f9fabdd5d79344728521bb65e3106b49ec405a78b66fbff073b72b389fa43" +dependencies = [ + "async-trait", + "hyper", + "hyper-rustls 0.24.2", + "jsonrpsee-core", + "jsonrpsee-types", + "rustc-hash", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "jsonrpsee-proc-macros" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44e8ab85614a08792b9bff6c8feee23be78c98d0182d4c622c05256ab553892a" +dependencies = [ + "heck", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "jsonrpsee-server" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4d945a6008c9b03db3354fb3c83ee02d2faa9f2e755ec1dfb69c3551b8f4ba" +dependencies = [ + "futures-channel", + "futures-util", + "http", + "hyper", + "jsonrpsee-core", + "jsonrpsee-types", + "serde", + "serde_json", + "soketto", + "tokio", + "tokio-stream", + "tokio-util", + "tower", + "tracing", +] + +[[package]] +name = "jsonrpsee-types" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245ba8e5aa633dd1c1e4fae72bce06e71f42d34c14a2767c6b4d173b57bee5e5" +dependencies = [ + "anyhow", + "beef", + "serde", + "serde_json", + "thiserror", + "tracing", +] + +[[package]] +name = "jsonrpsee-ws-client" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e1b3975ed5d73f456478681a417128597acd6a2487855fdb7b4a3d4d195bf5e" +dependencies = [ + "http", + "jsonrpsee-client-transport", + "jsonrpsee-core", + "jsonrpsee-types", +] + +[[package]] +name = "k256" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +dependencies = [ + "cfg-if", + "ecdsa 0.16.8", + "elliptic-curve 0.13.6", + "once_cell", + "sha2 0.10.8", +] + +[[package]] +name = "keccak" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "kusama-runtime" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "bitvec", + "frame-benchmarking", + "frame-election-provider-support", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal 0.4.1", + "kusama-runtime-constants", + "log", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", + "pallet-bags-list", + "pallet-balances", + "pallet-bounties", + "pallet-child-bounties", + "pallet-collective", + "pallet-conviction-voting", + "pallet-democracy", + "pallet-election-provider-multi-phase", + "pallet-election-provider-support-benchmarking", + "pallet-elections-phragmen", + "pallet-fast-unstake", + "pallet-grandpa", + "pallet-identity", + "pallet-im-online", + "pallet-indices", + "pallet-membership", + "pallet-message-queue", + "pallet-multisig", + "pallet-nis", + "pallet-nomination-pools", + "pallet-nomination-pools-benchmarking", + "pallet-nomination-pools-runtime-api", + "pallet-offences", + "pallet-offences-benchmarking", + "pallet-preimage", + "pallet-proxy", + "pallet-ranked-collective", + "pallet-recovery", + "pallet-referenda", + "pallet-scheduler", + "pallet-session", + "pallet-session-benchmarking", + "pallet-society", + "pallet-staking", + "pallet-staking-runtime-api", + "pallet-timestamp", + "pallet-tips", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", + "pallet-utility", + "pallet-vesting", + "pallet-whitelist", + "pallet-xcm", + "pallet-xcm-benchmarks", + "parity-scale-codec", + "polkadot-primitives", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "rustc-hex", + "scale-info", + "serde", + "serde_derive", + "smallvec", + "sp-api", + "sp-arithmetic", + "sp-authority-discovery", + "sp-block-builder", + "sp-consensus-babe", + "sp-consensus-beefy", + "sp-core", + "sp-inherents", + "sp-io", + "sp-mmr-primitives", + "sp-npos-elections", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "sp-transaction-pool", + "sp-version", + "static_assertions", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "kusama-runtime-constants" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "frame-support", + "polkadot-primitives", + "polkadot-runtime-common", + "smallvec", + "sp-core", + "sp-runtime", + "sp-weights", +] + +[[package]] +name = "kvdb" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7d770dcb02bf6835887c3a979b5107a04ff4bbde97a5f0928d27404a155add9" +dependencies = [ + "smallvec", +] + +[[package]] +name = "kvdb-memorydb" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7a85fe66f9ff9cd74e169fdd2c94c6e1e74c412c99a73b4df3200b5d3760b2" +dependencies = [ + "kvdb", + "parking_lot 0.12.1", +] + +[[package]] +name = "kvdb-rocksdb" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b644c70b92285f66bfc2032922a79000ea30af7bc2ab31902992a5dcb9b434f6" +dependencies = [ + "kvdb", + "num_cpus", + "parking_lot 0.12.1", + "regex", + "rocksdb", + "smallvec", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.2.150" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" + +[[package]] +name = "libloading" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "libp2p" +version = "0.51.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f210d259724eae82005b5c48078619b7745edb7b76de370b03f8ba59ea103097" +dependencies = [ + "bytes", + "futures", + "futures-timer", + "getrandom 0.2.11", + "instant", + "libp2p-allow-block-list", + "libp2p-connection-limits", + "libp2p-core", + "libp2p-dns", + "libp2p-identify", + "libp2p-identity", + "libp2p-kad", + "libp2p-mdns", + "libp2p-metrics", + "libp2p-noise", + "libp2p-ping", + "libp2p-quic", + "libp2p-request-response", + "libp2p-swarm", + "libp2p-tcp", + "libp2p-wasm-ext", + "libp2p-webrtc", + "libp2p-websocket", + "libp2p-yamux", + "multiaddr", + "pin-project", +] + +[[package]] +name = "libp2p-allow-block-list" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "510daa05efbc25184458db837f6f9a5143888f1caa742426d92e1833ddd38a50" +dependencies = [ + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "void", +] + +[[package]] +name = "libp2p-connection-limits" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4caa33f1d26ed664c4fe2cca81a08c8e07d4c1c04f2f4ac7655c2dd85467fda0" +dependencies = [ + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "void", +] + +[[package]] +name = "libp2p-core" +version = "0.39.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c1df63c0b582aa434fb09b2d86897fa2b419ffeccf934b36f87fcedc8e835c2" +dependencies = [ + "either", + "fnv", + "futures", + "futures-timer", + "instant", + "libp2p-identity", + "log", + "multiaddr", + "multihash 0.17.0", + "multistream-select", + "once_cell", + "parking_lot 0.12.1", + "pin-project", + "quick-protobuf", + "rand 0.8.5", + "rw-stream-sink", + "smallvec", + "thiserror", + "unsigned-varint", + "void", +] + +[[package]] +name = "libp2p-dns" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "146ff7034daae62077c415c2376b8057368042df6ab95f5432ad5e88568b1554" +dependencies = [ + "futures", + "libp2p-core", + "log", + "parking_lot 0.12.1", + "smallvec", + "trust-dns-resolver", +] + +[[package]] +name = "libp2p-identify" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5455f472243e63b9c497ff320ded0314254a9eb751799a39c283c6f20b793f3c" +dependencies = [ + "asynchronous-codec", + "either", + "futures", + "futures-timer", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "log", + "lru 0.10.1", + "quick-protobuf", + "quick-protobuf-codec", + "smallvec", + "thiserror", + "void", +] + +[[package]] +name = "libp2p-identity" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "276bb57e7af15d8f100d3c11cbdd32c6752b7eef4ba7a18ecf464972c07abcce" +dependencies = [ + "bs58", + "ed25519-dalek 2.0.0", + "log", + "multiaddr", + "multihash 0.17.0", + "quick-protobuf", + "rand 0.8.5", + "sha2 0.10.8", + "thiserror", + "zeroize", +] + +[[package]] +name = "libp2p-kad" +version = "0.43.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39d5ef876a2b2323d63c258e63c2f8e36f205fe5a11f0b3095d59635650790ff" +dependencies = [ + "arrayvec 0.7.4", + "asynchronous-codec", + "bytes", + "either", + "fnv", + "futures", + "futures-timer", + "instant", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "log", + "quick-protobuf", + "rand 0.8.5", + "sha2 0.10.8", + "smallvec", + "thiserror", + "uint", + "unsigned-varint", + "void", +] + +[[package]] +name = "libp2p-mdns" +version = "0.43.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19983e1f949f979a928f2c603de1cf180cc0dc23e4ac93a62651ccb18341460b" +dependencies = [ + "data-encoding", + "futures", + "if-watch", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "log", + "rand 0.8.5", + "smallvec", + "socket2 0.4.10", + "tokio", + "trust-dns-proto", + "void", +] + +[[package]] +name = "libp2p-metrics" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a42ec91e227d7d0dafa4ce88b333cdf5f277253873ab087555c92798db2ddd46" +dependencies = [ + "libp2p-core", + "libp2p-identify", + "libp2p-kad", + "libp2p-ping", + "libp2p-swarm", + "prometheus-client", +] + +[[package]] +name = "libp2p-noise" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3673da89d29936bc6435bafc638e2f184180d554ce844db65915113f86ec5e" +dependencies = [ + "bytes", + "curve25519-dalek 3.2.0", + "futures", + "libp2p-core", + "libp2p-identity", + "log", + "once_cell", + "quick-protobuf", + "rand 0.8.5", + "sha2 0.10.8", + "snow", + "static_assertions", + "thiserror", + "x25519-dalek 1.1.1", + "zeroize", +] + +[[package]] +name = "libp2p-ping" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e57759c19c28a73ef1eb3585ca410cefb72c1a709fcf6de1612a378e4219202" +dependencies = [ + "either", + "futures", + "futures-timer", + "instant", + "libp2p-core", + "libp2p-swarm", + "log", + "rand 0.8.5", + "void", +] + +[[package]] +name = "libp2p-quic" +version = "0.7.0-alpha.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6b26abd81cd2398382a1edfe739b539775be8a90fa6914f39b2ab49571ec735" +dependencies = [ + "bytes", + "futures", + "futures-timer", + "if-watch", + "libp2p-core", + "libp2p-identity", + "libp2p-tls", + "log", + "parking_lot 0.12.1", + "quinn-proto", + "rand 0.8.5", + "rustls 0.20.9", + "thiserror", + "tokio", +] + +[[package]] +name = "libp2p-request-response" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffdb374267d42dc5ed5bc53f6e601d4a64ac5964779c6e40bb9e4f14c1e30d5" +dependencies = [ + "async-trait", + "futures", + "instant", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "rand 0.8.5", + "smallvec", +] + +[[package]] +name = "libp2p-swarm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "903b3d592d7694e56204d211f29d31bc004be99386644ba8731fc3e3ef27b296" +dependencies = [ + "either", + "fnv", + "futures", + "futures-timer", + "instant", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm-derive", + "log", + "rand 0.8.5", + "smallvec", + "tokio", + "void", +] + +[[package]] +name = "libp2p-swarm-derive" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fba456131824ab6acd4c7bf61e9c0f0a3014b5fc9868ccb8e10d344594cdc4f" +dependencies = [ + "heck", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "libp2p-tcp" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33d33698596d7722d85d3ab0c86c2c322254fce1241e91208e3679b4eb3026cf" +dependencies = [ + "futures", + "futures-timer", + "if-watch", + "libc", + "libp2p-core", + "log", + "socket2 0.4.10", + "tokio", +] + +[[package]] +name = "libp2p-tls" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff08d13d0dc66e5e9ba6279c1de417b84fa0d0adc3b03e5732928c180ec02781" +dependencies = [ + "futures", + "futures-rustls", + "libp2p-core", + "libp2p-identity", + "rcgen 0.10.0", + "ring 0.16.20", + "rustls 0.20.9", + "thiserror", + "webpki 0.22.4", + "x509-parser 0.14.0", + "yasna", +] + +[[package]] +name = "libp2p-wasm-ext" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77dff9d32353a5887adb86c8afc1de1a94d9e8c3bc6df8b2201d7cdf5c848f43" +dependencies = [ + "futures", + "js-sys", + "libp2p-core", + "parity-send-wrapper", + "wasm-bindgen", + "wasm-bindgen-futures", +] + +[[package]] +name = "libp2p-webrtc" +version = "0.4.0-alpha.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dba48592edbc2f60b4bc7c10d65445b0c3964c07df26fdf493b6880d33be36f8" +dependencies = [ + "async-trait", + "asynchronous-codec", + "bytes", + "futures", + "futures-timer", + "hex", + "if-watch", + "libp2p-core", + "libp2p-identity", + "libp2p-noise", + "log", + "multihash 0.17.0", + "quick-protobuf", + "quick-protobuf-codec", + "rand 0.8.5", + "rcgen 0.9.3", + "serde", + "stun", + "thiserror", + "tinytemplate", + "tokio", + "tokio-util", + "webrtc", +] + +[[package]] +name = "libp2p-websocket" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "111273f7b3d3510524c752e8b7a5314b7f7a1fee7e68161c01a7d72cbb06db9f" +dependencies = [ + "either", + "futures", + "futures-rustls", + "libp2p-core", + "log", + "parking_lot 0.12.1", + "quicksink", + "rw-stream-sink", + "soketto", + "url", + "webpki-roots 0.22.6", +] + +[[package]] +name = "libp2p-yamux" +version = "0.43.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd21d950662700a385d4c6d68e2f5f54d778e97068cdd718522222ef513bda" +dependencies = [ + "futures", + "libp2p-core", + "log", + "thiserror", + "yamux", +] + +[[package]] +name = "libredox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +dependencies = [ + "bitflags 2.4.1", + "libc", + "redox_syscall 0.4.1", +] + +[[package]] +name = "librocksdb-sys" +version = "0.11.0+8.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3386f101bcb4bd252d8e9d2fb41ec3b0862a15a62b478c355b2982efa469e3e" +dependencies = [ + "bindgen", + "bzip2-sys", + "cc", + "glob", + "libc", + "libz-sys", + "tikv-jemalloc-sys", +] + +[[package]] +name = "libsecp256k1" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95b09eff1b35ed3b33b877ced3a691fc7a481919c7e29c53c906226fcf55e2a1" +dependencies = [ + "arrayref", + "base64 0.13.1", + "digest 0.9.0", + "hmac-drbg", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", + "rand 0.8.5", + "serde", + "sha2 0.9.9", + "typenum", +] + +[[package]] +name = "libsecp256k1-core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" +dependencies = [ + "crunchy", + "digest 0.9.0", + "subtle", +] + +[[package]] +name = "libsecp256k1-gen-ecmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "libsecp256k1-gen-genmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "libz-sys" +version = "1.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "link-cplusplus" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9" +dependencies = [ + "cc", +] + +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + +[[package]] +name = "linked_hash_set" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47186c6da4d81ca383c7c47c1bfc80f4b95f4720514d860a5407aaf4233f9588" +dependencies = [ + "linked-hash-map", +] + +[[package]] +name = "linregress" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4de04dcecc58d366391f9920245b85ffa684558a5ef6e7736e754347c3aea9c2" +dependencies = [ + "nalgebra", +] + +[[package]] +name = "linux-raw-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" + +[[package]] +name = "linux-raw-sys" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" + +[[package]] +name = "linux-raw-sys" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" + +[[package]] +name = "lock_api" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "lru" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6e8aaa3f231bb4bd57b84b2d5dc3ae7f350265df8aa96492e0bc394a1571909" +dependencies = [ + "hashbrown 0.12.3", +] + +[[package]] +name = "lru" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e7d46de488603ffdd5f30afbc64fbba2378214a2c3a2fb83abf3d33126df17" +dependencies = [ + "hashbrown 0.13.2", +] + +[[package]] +name = "lru" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "718e8fae447df0c7e1ba7f5189829e63fd536945c8988d61444c19039f16b670" +dependencies = [ + "hashbrown 0.13.2", +] + +[[package]] +name = "lru-cache" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" +dependencies = [ + "linked-hash-map", +] + +[[package]] +name = "lz4" +version = "1.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e9e2dd86df36ce760a60f6ff6ad526f7ba1f14ba0356f8254fb6905e6494df1" +dependencies = [ + "libc", + "lz4-sys", +] + +[[package]] +name = "lz4-sys" +version = "1.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d27b317e207b10f69f5e75494119e391a96f48861ae870d1da6edac98ca900" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + +[[package]] +name = "maplit" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" + +[[package]] +name = "match_cfg" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" + +[[package]] +name = "matchers" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f099785f7595cc4b4553a174ce30dd7589ef93391ff414dbb67f62392b9e0ce1" +dependencies = [ + "regex-automata 0.1.10", +] + +[[package]] +name = "matches" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" + +[[package]] +name = "matrixmultiply" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7574c1cf36da4798ab73da5b215bbf444f50718207754cb522201d78d1cd0ff2" +dependencies = [ + "autocfg", + "rawpointer", +] + +[[package]] +name = "md-5" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf" +dependencies = [ + "cfg-if", + "digest 0.10.7", +] + +[[package]] +name = "memchr" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" + +[[package]] +name = "memfd" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" +dependencies = [ + "rustix 0.38.21", +] + +[[package]] +name = "memmap2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" +dependencies = [ + "libc", +] + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "memoffset" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d61c719bcfbcf5d62b3a09efa6088de8c54bc0bfcd3ea7ae39fcc186108b8de1" +dependencies = [ + "autocfg", +] + +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "memory-db" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808b50db46293432a45e63bc15ea51e0ab4c0a1647b8eb114e31a3e698dd6fbe" +dependencies = [ + "hash-db", +] + +[[package]] +name = "memory_units" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3" + +[[package]] +name = "merlin" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e261cf0f8b3c42ded9f7d2bb59dea03aa52bc8a1cbc7482f9fc3fd1229d3b42" +dependencies = [ + "byteorder", + "keccak", + "rand_core 0.5.1", + "zeroize", +] + +[[package]] +name = "mick-jaeger" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69672161530e8aeca1d1400fbf3f1a1747ff60ea604265a4e906c2442df20532" +dependencies = [ + "futures", + "rand 0.8.5", + "thrift", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" +dependencies = [ + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.48.0", +] + +[[package]] +name = "mmr-gadget" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "futures", + "log", + "parity-scale-codec", + "sc-client-api", + "sc-offchain", + "sp-api", + "sp-blockchain", + "sp-consensus", + "sp-consensus-beefy", + "sp-core", + "sp-mmr-primitives", + "sp-runtime", +] + +[[package]] +name = "mmr-rpc" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "anyhow", + "jsonrpsee", + "parity-scale-codec", + "serde", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-mmr-primitives", + "sp-runtime", +] + +[[package]] +name = "mockall" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c84490118f2ee2d74570d114f3d0493cbf02790df303d2707606c3e14e07c96" +dependencies = [ + "cfg-if", + "downcast", + "fragile", + "lazy_static", + "mockall_derive", + "predicates", + "predicates-tree", +] + +[[package]] +name = "mockall_derive" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ce75669015c4f47b289fd4d4f56e894e4c96003ffdf3ac51313126f94c6cbb" +dependencies = [ + "cfg-if", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "multiaddr" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b36f567c7099511fa8612bbbb52dda2419ce0bdbacf31714e3a5ffdb766d3bd" +dependencies = [ + "arrayref", + "byteorder", + "data-encoding", + "log", + "multibase", + "multihash 0.17.0", + "percent-encoding", + "serde", + "static_assertions", + "unsigned-varint", + "url", +] + +[[package]] +name = "multibase" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b3539ec3c1f04ac9748a260728e855f261b4977f5c3406612c884564f329404" +dependencies = [ + "base-x", + "data-encoding", + "data-encoding-macro", +] + +[[package]] +name = "multihash" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c346cf9999c631f002d8f977c4eaeaa0e6386f16007202308d0b3757522c2cc" +dependencies = [ + "blake2b_simd", + "blake2s_simd", + "blake3", + "core2", + "digest 0.10.7", + "multihash-derive", + "sha2 0.10.8", + "sha3", + "unsigned-varint", +] + +[[package]] +name = "multihash" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" +dependencies = [ + "core2", + "digest 0.10.7", + "multihash-derive", + "sha2 0.10.8", + "unsigned-varint", +] + +[[package]] +name = "multihash-derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc076939022111618a5026d3be019fd8b366e76314538ff9a1b59ffbcbf98bcd" +dependencies = [ + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.109", + "synstructure", +] + +[[package]] +name = "multimap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" + +[[package]] +name = "multistream-select" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8552ab875c1313b97b8d20cb857b9fd63e2d1d6a0a1b53ce9821e575405f27a" +dependencies = [ + "bytes", + "futures", + "log", + "pin-project", + "smallvec", + "unsigned-varint", +] + +[[package]] +name = "nalgebra" +version = "0.32.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "307ed9b18cc2423f29e83f84fd23a8e73628727990181f18641a8b5dc2ab1caa" +dependencies = [ + "approx", + "matrixmultiply", + "nalgebra-macros", + "num-complex", + "num-rational", + "num-traits", + "simba", + "typenum", +] + +[[package]] +name = "nalgebra-macros" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91761aed67d03ad966ef783ae962ef9bbaca728d2dd7ceb7939ec110fffad998" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "names" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7d66043b25d4a6cccb23619d10c19c25304b355a7dccd4a8e11423dd2382146" +dependencies = [ + "rand 0.8.5", +] + +[[package]] +name = "nanorand" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3" + +[[package]] +name = "netlink-packet-core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "345b8ab5bd4e71a2986663e88c56856699d060e78e152e6e9d7966fcd5491297" +dependencies = [ + "anyhow", + "byteorder", + "libc", + "netlink-packet-utils", +] + +[[package]] +name = "netlink-packet-route" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9ea4302b9759a7a88242299225ea3688e63c85ea136371bb6cf94fd674efaab" +dependencies = [ + "anyhow", + "bitflags 1.3.2", + "byteorder", + "libc", + "netlink-packet-core", + "netlink-packet-utils", +] + +[[package]] +name = "netlink-packet-utils" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ede8a08c71ad5a95cdd0e4e52facd37190977039a4704eb82a283f713747d34" +dependencies = [ + "anyhow", + "byteorder", + "paste", + "thiserror", +] + +[[package]] +name = "netlink-proto" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65b4b14489ab424703c092062176d52ba55485a89c076b4f9db05092b7223aa6" +dependencies = [ + "bytes", + "futures", + "log", + "netlink-packet-core", + "netlink-sys", + "thiserror", + "tokio", +] + +[[package]] +name = "netlink-sys" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6471bf08e7ac0135876a9581bf3217ef0333c191c128d34878079f42ee150411" +dependencies = [ + "bytes", + "futures", + "libc", + "log", + "tokio", +] + +[[package]] +name = "nix" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", + "memoffset 0.6.5", +] + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "normalize-line-endings" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" + +[[package]] +name = "num-bigint" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-complex" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-format" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3" +dependencies = [ + "arrayvec 0.7.4", + "itoa", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi 0.3.3", + "libc", +] + +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + +[[package]] +name = "object" +version = "0.30.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03b4680b86d9cfafba8fc491dc9b6df26b68cf40e9e6cd73909194759a63c385" +dependencies = [ + "crc32fast", + "hashbrown 0.13.2", + "indexmap 1.9.3", + "memchr", +] + +[[package]] +name = "object" +version = "0.32.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +dependencies = [ + "memchr", +] + +[[package]] +name = "oid-registry" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38e20717fa0541f39bd146692035c37bedfa532b3e5071b35761082407546b2a" +dependencies = [ + "asn1-rs 0.3.1", +] + +[[package]] +name = "oid-registry" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bedf36ffb6ba96c2eb7144ef6270557b52e54b20c0a8e1eb2ff99a6c6959bff" +dependencies = [ + "asn1-rs 0.5.2", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "oorandom" +version = "11.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" + +[[package]] +name = "opaque-debug" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "orchestra" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "227585216d05ba65c7ab0a0450a3cf2cbd81a98862a54c4df8e14d5ac6adb015" +dependencies = [ + "async-trait", + "dyn-clonable", + "futures", + "futures-timer", + "orchestra-proc-macro", + "pin-project", + "prioritized-metered-channel", + "thiserror", + "tracing", +] + +[[package]] +name = "orchestra-proc-macro" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2871aadd82a2c216ee68a69837a526dfe788ecbe74c4c5038a6acdbff6653066" +dependencies = [ + "expander 0.0.6", + "itertools 0.10.5", + "petgraph", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "ordered-float" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3305af35278dd29f46fcdd139e0b1fbfae2153f0e5928b39b035542dd31e37b7" +dependencies = [ + "num-traits", +] + +[[package]] +name = "p256" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51f44edd08f51e2ade572f141051021c5af22677e42b7dd28a88155151c33594" +dependencies = [ + "ecdsa 0.14.8", + "elliptic-curve 0.12.3", + "sha2 0.10.8", +] + +[[package]] +name = "p384" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc8c5bf642dde52bb9e87c0ecd8ca5a76faac2eeed98dedb7c717997e1080aa" +dependencies = [ + "ecdsa 0.14.8", + "elliptic-curve 0.12.3", + "sha2 0.10.8", +] + +[[package]] +name = "pallet-asset-tx-payment" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "pallet-transaction-payment", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-assets" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-aura" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-support", + "frame-system", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-application-crypto", + "sp-consensus-aura", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-authority-discovery" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-support", + "frame-system", + "pallet-session", + "parity-scale-codec", + "scale-info", + "sp-application-crypto", + "sp-authority-discovery", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-authorship" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-babe" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-authorship", + "pallet-session", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-application-crypto", + "sp-consensus-babe", + "sp-core", + "sp-io", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", +] + +[[package]] +name = "pallet-bags-list" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-tracing", +] + +[[package]] +name = "pallet-balances" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-beefy" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-support", + "frame-system", + "pallet-authorship", + "pallet-session", + "parity-scale-codec", + "scale-info", + "serde", + "sp-consensus-beefy", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", +] + +[[package]] +name = "pallet-beefy-mmr" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "array-bytes 4.2.0", + "binary-merkle-tree", + "frame-support", + "frame-system", + "log", + "pallet-beefy", + "pallet-mmr", + "pallet-session", + "parity-scale-codec", + "scale-info", + "serde", + "sp-api", + "sp-consensus-beefy", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-bounties" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-treasury", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-child-bounties" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-bounties", + "pallet-treasury", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-collator-selection" +version = "3.0.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-authorship", + "pallet-session", + "parity-scale-codec", + "rand 0.8.5", + "scale-info", + "sp-runtime", + "sp-staking", + "sp-std", +] + +[[package]] +name = "pallet-collective" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-conviction-voting" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "assert_matches", + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "serde", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-democracy" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-election-provider-multi-phase" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-election-provider-support-benchmarking", + "parity-scale-codec", + "rand 0.8.5", + "scale-info", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-npos-elections", + "sp-runtime", + "sp-std", + "strum", +] + +[[package]] +name = "pallet-election-provider-support-benchmarking" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-system", + "parity-scale-codec", + "sp-npos-elections", + "sp-runtime", +] + +[[package]] +name = "pallet-elections-phragmen" +version = "5.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-npos-elections", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-fast-unstake" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-std", +] + +[[package]] +name = "pallet-funding" +version = "0.1.0" +dependencies = [ + "assert_matches2", + "frame-benchmarking", + "frame-support", + "frame-system", + "itertools 0.11.0", + "log", + "pallet-assets", + "pallet-balances", + "pallet-insecure-randomness-collective-flip", + "pallet-linear-release", + "pallet-timestamp", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "polimec-traits", + "polimec-xcm-executor", + "polkadot-parachain", + "polkadot-runtime", + "polkadot-runtime-parachains", + "scale-info", + "serde", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "pallet-grandpa" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-authorship", + "pallet-session", + "parity-scale-codec", + "scale-info", + "sp-application-crypto", + "sp-consensus-grandpa", + "sp-core", + "sp-io", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", +] + +[[package]] +name = "pallet-identity" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "enumflags2", + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-im-online" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-authorship", + "parity-scale-codec", + "scale-info", + "sp-application-crypto", + "sp-core", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-std", +] + +[[package]] +name = "pallet-indices" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-keyring", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-insecure-randomness-collective-flip" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec", + "safe-mix", + "scale-info", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-linear-release" +version = "4.0.0-dev" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "pallet-funding", + "parity-scale-codec", + "polimec-traits", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "xcm-builder", +] + +[[package]] +name = "pallet-membership" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-message-queue" +version = "7.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-weights", +] + +[[package]] +name = "pallet-mmr" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-mmr-primitives", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-multisig" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-nfts" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "enumflags2", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-nfts-runtime-api" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-support", + "pallet-nfts", + "parity-scale-codec", + "sp-api", +] + +[[package]] +name = "pallet-nis" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-arithmetic", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-nomination-pools" +version = "1.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-std", +] + +[[package]] +name = "pallet-nomination-pools-benchmarking" +version = "1.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "pallet-bags-list", + "pallet-nomination-pools", + "pallet-staking", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-runtime-interface", + "sp-staking", + "sp-std", +] + +[[package]] +name = "pallet-nomination-pools-runtime-api" +version = "1.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "pallet-nomination-pools", + "parity-scale-codec", + "sp-api", + "sp-std", +] + +[[package]] +name = "pallet-offences" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-support", + "frame-system", + "log", + "pallet-balances", + "parity-scale-codec", + "scale-info", + "serde", + "sp-runtime", + "sp-staking", + "sp-std", +] + +[[package]] +name = "pallet-offences-benchmarking" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-babe", + "pallet-balances", + "pallet-grandpa", + "pallet-im-online", + "pallet-offences", + "pallet-session", + "pallet-staking", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-staking", + "sp-std", +] + +[[package]] +name = "pallet-parachain-staking" +version = "0.1.0" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-session", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "serde", + "similar-asserts", + "sp-consensus-aura", + "sp-core", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-std", + "substrate-fixed", +] + +[[package]] +name = "pallet-preimage" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-proxy" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-ranked-collective" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-recovery" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-referenda" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "assert_matches", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "serde", + "sp-arithmetic", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-sandbox" +version = "0.1.0" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "pallet-assets", + "pallet-balances", + "pallet-funding", + "pallet-insecure-randomness-collective-flip", + "parachains-common", + "parity-scale-codec", + "scale-info", + "serde", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-scheduler" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std", + "sp-weights", +] + +[[package]] +name = "pallet-session" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "log", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "sp-trie", +] + +[[package]] +name = "pallet-session-benchmarking" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "pallet-session", + "pallet-staking", + "rand 0.8.5", + "sp-runtime", + "sp-session", + "sp-std", +] + +[[package]] +name = "pallet-society" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec", + "rand_chacha 0.2.2", + "scale-info", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-staking" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "log", + "pallet-authorship", + "pallet-session", + "parity-scale-codec", + "rand_chacha 0.2.2", + "scale-info", + "serde", + "sp-application-crypto", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-std", +] + +[[package]] +name = "pallet-staking-reward-curve" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "pallet-staking-reward-fn" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "log", + "sp-arithmetic", +] + +[[package]] +name = "pallet-staking-runtime-api" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "parity-scale-codec", + "sp-api", +] + +[[package]] +name = "pallet-state-trie-migration" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-sudo" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-timestamp" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-inherents", + "sp-io", + "sp-runtime", + "sp-std", + "sp-timestamp", +] + +[[package]] +name = "pallet-tips" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-treasury", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-transaction-payment" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-transaction-payment-rpc" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "jsonrpsee", + "pallet-transaction-payment-rpc-runtime-api", + "parity-scale-codec", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-rpc", + "sp-runtime", + "sp-weights", +] + +[[package]] +name = "pallet-transaction-payment-rpc-runtime-api" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "pallet-transaction-payment", + "parity-scale-codec", + "sp-api", + "sp-runtime", + "sp-weights", +] + +[[package]] +name = "pallet-treasury" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "pallet-balances", + "parity-scale-codec", + "scale-info", + "serde", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-uniques" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-utility" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-vesting" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-whitelist" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-xcm" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "bounded-collections", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "xcm", + "xcm-executor", +] + +[[package]] +name = "pallet-xcm-benchmarks" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-io", + "sp-runtime", + "sp-std", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "parachain-info" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "cumulus-primitives-core", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "parachains-common" +version = "1.0.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "cumulus-primitives-utility", + "frame-support", + "frame-system", + "pallet-asset-tx-payment", + "pallet-assets", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "parity-scale-codec", + "polkadot-primitives", + "scale-info", + "sp-consensus-aura", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "parity-db" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59e9ab494af9e6e813c72170f0d3c1de1500990d62c97cc05cc7576f91aa402f" +dependencies = [ + "blake2", + "crc32fast", + "fs2", + "hex", + "libc", + "log", + "lz4", + "memmap2", + "parking_lot 0.12.1", + "rand 0.8.5", + "siphasher", + "snap", +] + +[[package]] +name = "parity-scale-codec" +version = "3.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" +dependencies = [ + "arrayvec 0.7.4", + "bitvec", + "byte-slice-cast", + "bytes", + "impl-trait-for-tuples", + "parity-scale-codec-derive", + "serde", +] + +[[package]] +name = "parity-scale-codec-derive" +version = "3.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "parity-send-wrapper" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f" + +[[package]] +name = "parity-wasm" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" + +[[package]] +name = "parking" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core 0.8.6", +] + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core 0.9.9", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall 0.2.16", + "smallvec", + "winapi", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.4.1", + "smallvec", + "windows-targets 0.48.5", +] + +[[package]] +name = "partial_sort" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" + +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "pbkdf2" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" +dependencies = [ + "crypto-mac 0.11.1", +] + +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "pem" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" +dependencies = [ + "base64 0.13.1", +] + +[[package]] +name = "pem-rfc7468" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d159833a9105500e0398934e205e0773f0b27529557134ecfc51c27646adac" +dependencies = [ + "base64ct", +] + +[[package]] +name = "penpal-runtime" +version = "0.9.27" +dependencies = [ + "cumulus-pallet-aura-ext", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-session-benchmarking", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-timestamp", + "cumulus-primitives-utility", + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal 0.4.1", + "log", + "pallet-asset-tx-payment", + "pallet-assets", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-session", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-xcm", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "polimec-receiver", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime-common", + "scale-info", + "smallvec", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "percent-encoding" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" + +[[package]] +name = "pest" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" +dependencies = [ + "memchr", + "thiserror", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "pest_meta" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" +dependencies = [ + "once_cell", + "pest", + "sha2 0.10.8", +] + +[[package]] +name = "petgraph" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +dependencies = [ + "fixedbitset", + "indexmap 2.1.0", +] + +[[package]] +name = "pin-project" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "pin-project-lite" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkcs8" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eca2c590a5f85da82668fa685c09ce2888b9430e83299debf1f34b65fd4a4ba" +dependencies = [ + "der 0.6.1", + "spki 0.6.0", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der 0.7.8", + "spki 0.7.2", +] + +[[package]] +name = "pkg-config" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" + +[[package]] +name = "platforms" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8d0eef3571242013a0d5dc84861c3ae4a652e56e12adf8bdc26ff5f8cb34c94" + +[[package]] +name = "platforms" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" + +[[package]] +name = "plotters" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" + +[[package]] +name = "plotters-svg" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +dependencies = [ + "plotters-backend", +] + +[[package]] +name = "polimec-base-runtime" +version = "0.1.0" +dependencies = [ + "cumulus-pallet-aura-ext", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-session-benchmarking", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-timestamp", + "cumulus-primitives-utility", + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal 0.3.4", + "log", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-parachain-staking", + "pallet-session", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", + "pallet-xcm", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime-common", + "scale-info", + "shared-configuration", + "smallvec", + "sp-api", + "sp-arithmetic", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "polimec-parachain-node" +version = "0.1.0" +dependencies = [ + "clap", + "color-print", + "cumulus-client-cli", + "cumulus-client-consensus-aura", + "cumulus-client-consensus-common", + "cumulus-client-network", + "cumulus-client-service", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-relay-chain-inprocess-interface", + "cumulus-relay-chain-interface", + "cumulus-relay-chain-minimal-node", + "frame-benchmarking", + "frame-benchmarking-cli", + "hex-literal 0.3.4", + "jsonrpsee", + "log", + "pallet-funding", + "pallet-transaction-payment-rpc", + "parachains-common", + "parity-scale-codec", + "polimec-base-runtime", + "polimec-parachain-runtime", + "polkadot-cli", + "polkadot-primitives", + "polkadot-service", + "sc-basic-authorship", + "sc-chain-spec", + "sc-cli", + "sc-client-api", + "sc-consensus", + "sc-executor", + "sc-network", + "sc-network-common", + "sc-network-sync", + "sc-rpc", + "sc-rpc-api", + "sc-service", + "sc-sysinfo", + "sc-telemetry", + "sc-tracing", + "sc-transaction-pool", + "sc-transaction-pool-api", + "serde", + "sp-api", + "sp-block-builder", + "sp-blockchain", + "sp-consensus-aura", + "sp-core", + "sp-io", + "sp-keystore", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-timestamp", + "sp-transaction-pool", + "substrate-build-script-utils", + "substrate-frame-rpc-system", + "substrate-prometheus-endpoint", + "try-runtime-cli", + "xcm", +] + +[[package]] +name = "polimec-parachain-runtime" +version = "0.1.0" +dependencies = [ + "cumulus-pallet-aura-ext", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-session-benchmarking", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-timestamp", + "cumulus-primitives-utility", + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal 0.3.4", + "log", + "pallet-asset-tx-payment", + "pallet-assets", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collective", + "pallet-democracy", + "pallet-funding", + "pallet-insecure-randomness-collective-flip", + "pallet-linear-release", + "pallet-multisig", + "pallet-parachain-staking", + "pallet-preimage", + "pallet-scheduler", + "pallet-session", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", + "pallet-utility", + "pallet-vesting", + "pallet-xcm", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "polimec-xcm-executor", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime-common", + "scale-info", + "serde", + "shared-configuration", + "smallvec", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-io", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "polimec-receiver" +version = "0.1.0" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", +] + +[[package]] +name = "polimec-traits" +version = "0.1.0" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "polimec-xcm-executor" +version = "0.1.0" +dependencies = [ + "environmental", + "frame-benchmarking", + "frame-support", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-weights", + "xcm", + "xcm-executor", +] + +[[package]] +name = "polkadot-approval-distribution" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "futures", + "polkadot-node-jaeger", + "polkadot-node-metrics", + "polkadot-node-network-protocol", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-primitives", + "rand 0.8.5", + "tracing-gum", +] + +[[package]] +name = "polkadot-availability-bitfield-distribution" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "futures", + "polkadot-node-network-protocol", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "rand 0.8.5", + "tracing-gum", +] + +[[package]] +name = "polkadot-availability-distribution" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "derive_more", + "fatality", + "futures", + "lru 0.9.0", + "parity-scale-codec", + "polkadot-erasure-coding", + "polkadot-node-network-protocol", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "rand 0.8.5", + "sp-core", + "sp-keystore", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-availability-recovery" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "fatality", + "futures", + "lru 0.9.0", + "parity-scale-codec", + "polkadot-erasure-coding", + "polkadot-node-network-protocol", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "rand 0.8.5", + "sc-network", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-cli" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "clap", + "frame-benchmarking-cli", + "futures", + "log", + "polkadot-client", + "polkadot-node-core-pvf-worker", + "polkadot-node-metrics", + "polkadot-performance-test", + "polkadot-service", + "sc-cli", + "sc-executor", + "sc-service", + "sc-storage-monitor", + "sc-sysinfo", + "sc-tracing", + "sp-core", + "sp-io", + "sp-keyring", + "sp-maybe-compressed-blob", + "substrate-build-script-utils", + "thiserror", + "try-runtime-cli", +] + +[[package]] +name = "polkadot-client" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "async-trait", + "frame-benchmarking", + "frame-benchmarking-cli", + "frame-system", + "frame-system-rpc-runtime-api", + "futures", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "polkadot-core-primitives", + "polkadot-node-core-parachains-inherent", + "polkadot-primitives", + "polkadot-runtime", + "polkadot-runtime-common", + "sc-client-api", + "sc-consensus", + "sc-executor", + "sc-service", + "sp-api", + "sp-authority-discovery", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-consensus-beefy", + "sp-consensus-grandpa", + "sp-core", + "sp-inherents", + "sp-keyring", + "sp-mmr-primitives", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-storage", + "sp-timestamp", + "sp-transaction-pool", +] + +[[package]] +name = "polkadot-collator-protocol" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "always-assert", + "bitvec", + "fatality", + "futures", + "futures-timer", + "polkadot-node-network-protocol", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "sp-core", + "sp-keystore", + "sp-runtime", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-core-primitives" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "polkadot-dispute-distribution" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "derive_more", + "fatality", + "futures", + "futures-timer", + "indexmap 1.9.3", + "lru 0.9.0", + "parity-scale-codec", + "polkadot-erasure-coding", + "polkadot-node-network-protocol", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "sc-network", + "sp-application-crypto", + "sp-keystore", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-erasure-coding" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "parity-scale-codec", + "polkadot-node-primitives", + "polkadot-primitives", + "reed-solomon-novelpoly", + "sp-core", + "sp-trie", + "thiserror", +] + +[[package]] +name = "polkadot-gossip-support" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "futures", + "futures-timer", + "polkadot-node-network-protocol", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "rand 0.8.5", + "rand_chacha 0.3.1", + "sc-network", + "sp-application-crypto", + "sp-core", + "sp-keystore", + "tracing-gum", +] + +[[package]] +name = "polkadot-network-bridge" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "always-assert", + "async-trait", + "bytes", + "fatality", + "futures", + "parity-scale-codec", + "parking_lot 0.12.1", + "polkadot-node-metrics", + "polkadot-node-network-protocol", + "polkadot-node-subsystem", + "polkadot-overseer", + "polkadot-primitives", + "sc-network", + "sp-consensus", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-collation-generation" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "futures", + "parity-scale-codec", + "polkadot-erasure-coding", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "sp-core", + "sp-maybe-compressed-blob", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-approval-voting" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "bitvec", + "derive_more", + "futures", + "futures-timer", + "kvdb", + "lru 0.9.0", + "merlin", + "parity-scale-codec", + "polkadot-node-jaeger", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-overseer", + "polkadot-primitives", + "sc-keystore", + "schnorrkel", + "sp-application-crypto", + "sp-consensus", + "sp-consensus-slots", + "sp-runtime", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-av-store" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "bitvec", + "futures", + "futures-timer", + "kvdb", + "parity-scale-codec", + "polkadot-erasure-coding", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-overseer", + "polkadot-primitives", + "sp-consensus", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-backing" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "bitvec", + "fatality", + "futures", + "polkadot-erasure-coding", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "polkadot-statement-table", + "sp-keystore", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-bitfield-signing" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "futures", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "sp-keystore", + "thiserror", + "tracing-gum", + "wasm-timer", +] + +[[package]] +name = "polkadot-node-core-candidate-validation" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "async-trait", + "futures", + "futures-timer", + "parity-scale-codec", + "polkadot-node-core-pvf", + "polkadot-node-metrics", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-parachain", + "polkadot-primitives", + "sp-maybe-compressed-blob", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-chain-api" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "futures", + "polkadot-node-metrics", + "polkadot-node-subsystem", + "polkadot-primitives", + "sc-client-api", + "sc-consensus-babe", + "sp-blockchain", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-chain-selection" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "futures", + "futures-timer", + "kvdb", + "parity-scale-codec", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-dispute-coordinator" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "fatality", + "futures", + "kvdb", + "lru 0.9.0", + "parity-scale-codec", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "sc-keystore", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-parachains-inherent" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "async-trait", + "futures", + "futures-timer", + "polkadot-node-subsystem", + "polkadot-overseer", + "polkadot-primitives", + "sp-blockchain", + "sp-inherents", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-provisioner" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "bitvec", + "fatality", + "futures", + "futures-timer", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "rand 0.8.5", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-pvf" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "always-assert", + "futures", + "futures-timer", + "libc", + "parity-scale-codec", + "pin-project", + "polkadot-core-primitives", + "polkadot-node-metrics", + "polkadot-node-primitives", + "polkadot-parachain", + "polkadot-primitives", + "rand 0.8.5", + "slotmap", + "sp-core", + "sp-maybe-compressed-blob", + "sp-tracing", + "sp-wasm-interface", + "substrate-build-script-utils", + "tokio", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-pvf-checker" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "futures", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-overseer", + "polkadot-primitives", + "sp-keystore", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-pvf-worker" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "assert_matches", + "cpu-time", + "futures", + "libc", + "parity-scale-codec", + "polkadot-node-core-pvf", + "polkadot-parachain", + "polkadot-primitives", + "rayon", + "sc-executor", + "sc-executor-common", + "sc-executor-wasmtime", + "sp-core", + "sp-externalities", + "sp-io", + "sp-maybe-compressed-blob", + "sp-tracing", + "substrate-build-script-utils", + "tempfile", + "tikv-jemalloc-ctl", + "tokio", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-core-runtime-api" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "futures", + "lru 0.9.0", + "polkadot-node-metrics", + "polkadot-node-subsystem", + "polkadot-node-subsystem-types", + "polkadot-primitives", + "sp-consensus-babe", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-jaeger" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "lazy_static", + "log", + "mick-jaeger", + "parity-scale-codec", + "parking_lot 0.12.1", + "polkadot-node-primitives", + "polkadot-primitives", + "sc-network", + "sp-core", + "thiserror", + "tokio", +] + +[[package]] +name = "polkadot-node-metrics" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "bs58", + "futures", + "futures-timer", + "log", + "parity-scale-codec", + "polkadot-primitives", + "prioritized-metered-channel", + "sc-cli", + "sc-service", + "sc-tracing", + "substrate-prometheus-endpoint", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-network-protocol" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "async-channel", + "async-trait", + "derive_more", + "fatality", + "futures", + "hex", + "parity-scale-codec", + "polkadot-node-jaeger", + "polkadot-node-primitives", + "polkadot-primitives", + "rand 0.8.5", + "sc-authority-discovery", + "sc-network", + "strum", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-node-primitives" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "bounded-vec", + "futures", + "parity-scale-codec", + "polkadot-parachain", + "polkadot-primitives", + "schnorrkel", + "serde", + "sp-application-crypto", + "sp-consensus-babe", + "sp-core", + "sp-keystore", + "sp-maybe-compressed-blob", + "sp-runtime", + "thiserror", + "zstd 0.11.2+zstd.1.5.2", +] + +[[package]] +name = "polkadot-node-subsystem" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "polkadot-node-jaeger", + "polkadot-node-subsystem-types", + "polkadot-overseer", +] + +[[package]] +name = "polkadot-node-subsystem-types" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "async-trait", + "derive_more", + "futures", + "orchestra", + "polkadot-node-jaeger", + "polkadot-node-network-protocol", + "polkadot-node-primitives", + "polkadot-primitives", + "polkadot-statement-table", + "sc-network", + "smallvec", + "sp-api", + "sp-authority-discovery", + "sp-consensus-babe", + "substrate-prometheus-endpoint", + "thiserror", +] + +[[package]] +name = "polkadot-node-subsystem-util" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "async-trait", + "derive_more", + "fatality", + "futures", + "futures-channel", + "itertools 0.10.5", + "kvdb", + "lru 0.9.0", + "parity-db", + "parity-scale-codec", + "parking_lot 0.11.2", + "pin-project", + "polkadot-node-jaeger", + "polkadot-node-metrics", + "polkadot-node-network-protocol", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-overseer", + "polkadot-primitives", + "prioritized-metered-channel", + "rand 0.8.5", + "sp-application-crypto", + "sp-core", + "sp-keystore", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-overseer" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "async-trait", + "futures", + "futures-timer", + "lru 0.9.0", + "orchestra", + "parking_lot 0.12.1", + "polkadot-node-metrics", + "polkadot-node-network-protocol", + "polkadot-node-primitives", + "polkadot-node-subsystem-types", + "polkadot-primitives", + "sc-client-api", + "sp-api", + "sp-core", + "tikv-jemalloc-ctl", + "tracing-gum", +] + +[[package]] +name = "polkadot-parachain" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "bounded-collections", + "derive_more", + "frame-support", + "parity-scale-codec", + "polkadot-core-primitives", + "scale-info", + "serde", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "polkadot-performance-test" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "env_logger 0.9.3", + "kusama-runtime", + "log", + "polkadot-erasure-coding", + "polkadot-node-core-pvf-worker", + "polkadot-node-primitives", + "polkadot-primitives", + "quote", + "sc-executor-common", + "sp-maybe-compressed-blob", + "thiserror", +] + +[[package]] +name = "polkadot-primitives" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "bitvec", + "hex-literal 0.4.1", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain", + "scale-info", + "serde", + "sp-api", + "sp-application-crypto", + "sp-arithmetic", + "sp-authority-discovery", + "sp-consensus-slots", + "sp-core", + "sp-inherents", + "sp-io", + "sp-keystore", + "sp-runtime", + "sp-staking", + "sp-std", +] + +[[package]] +name = "polkadot-rpc" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "jsonrpsee", + "mmr-rpc", + "pallet-transaction-payment-rpc", + "polkadot-primitives", + "sc-chain-spec", + "sc-client-api", + "sc-consensus-babe", + "sc-consensus-babe-rpc", + "sc-consensus-beefy", + "sc-consensus-beefy-rpc", + "sc-consensus-epochs", + "sc-consensus-grandpa", + "sc-consensus-grandpa-rpc", + "sc-rpc", + "sc-sync-state-rpc", + "sc-transaction-pool-api", + "sp-api", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-keystore", + "sp-runtime", + "substrate-frame-rpc-system", + "substrate-state-trie-migration-rpc", +] + +[[package]] +name = "polkadot-runtime" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "bitvec", + "frame-benchmarking", + "frame-election-provider-support", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal 0.4.1", + "log", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", + "pallet-bags-list", + "pallet-balances", + "pallet-bounties", + "pallet-child-bounties", + "pallet-collective", + "pallet-conviction-voting", + "pallet-democracy", + "pallet-election-provider-multi-phase", + "pallet-election-provider-support-benchmarking", + "pallet-elections-phragmen", + "pallet-fast-unstake", + "pallet-grandpa", + "pallet-identity", + "pallet-im-online", + "pallet-indices", + "pallet-membership", + "pallet-message-queue", + "pallet-multisig", + "pallet-nomination-pools", + "pallet-nomination-pools-benchmarking", + "pallet-nomination-pools-runtime-api", + "pallet-offences", + "pallet-offences-benchmarking", + "pallet-preimage", + "pallet-proxy", + "pallet-referenda", + "pallet-scheduler", + "pallet-session", + "pallet-session-benchmarking", + "pallet-staking", + "pallet-staking-reward-curve", + "pallet-staking-runtime-api", + "pallet-timestamp", + "pallet-tips", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", + "pallet-utility", + "pallet-vesting", + "pallet-whitelist", + "pallet-xcm", + "parity-scale-codec", + "polkadot-primitives", + "polkadot-runtime-common", + "polkadot-runtime-constants", + "polkadot-runtime-parachains", + "rustc-hex", + "scale-info", + "serde", + "serde_derive", + "smallvec", + "sp-api", + "sp-arithmetic", + "sp-authority-discovery", + "sp-block-builder", + "sp-consensus-babe", + "sp-consensus-beefy", + "sp-core", + "sp-inherents", + "sp-io", + "sp-mmr-primitives", + "sp-npos-elections", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "sp-transaction-pool", + "sp-version", + "static_assertions", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "polkadot-runtime-common" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "bitvec", + "frame-benchmarking", + "frame-election-provider-support", + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "libsecp256k1", + "log", + "pallet-authorship", + "pallet-babe", + "pallet-balances", + "pallet-election-provider-multi-phase", + "pallet-fast-unstake", + "pallet-session", + "pallet-staking", + "pallet-staking-reward-fn", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-treasury", + "pallet-vesting", + "parity-scale-codec", + "polkadot-primitives", + "polkadot-runtime-parachains", + "rustc-hex", + "scale-info", + "serde", + "serde_derive", + "slot-range-helper", + "sp-api", + "sp-core", + "sp-inherents", + "sp-io", + "sp-npos-elections", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "static_assertions", + "xcm", +] + +[[package]] +name = "polkadot-runtime-constants" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "frame-support", + "polkadot-primitives", + "polkadot-runtime-common", + "smallvec", + "sp-core", + "sp-runtime", + "sp-weights", +] + +[[package]] +name = "polkadot-runtime-metrics" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "bs58", + "parity-scale-codec", + "polkadot-primitives", + "sp-std", + "sp-tracing", +] + +[[package]] +name = "polkadot-runtime-parachains" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "bitflags 1.3.2", + "bitvec", + "derive_more", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", + "pallet-balances", + "pallet-message-queue", + "pallet-session", + "pallet-staking", + "pallet-timestamp", + "pallet-vesting", + "parity-scale-codec", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime-metrics", + "rand 0.8.5", + "rand_chacha 0.3.1", + "rustc-hex", + "scale-info", + "serde", + "sp-api", + "sp-application-crypto", + "sp-core", + "sp-inherents", + "sp-io", + "sp-keystore", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "static_assertions", + "xcm", + "xcm-executor", +] + +[[package]] +name = "polkadot-service" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "async-trait", + "frame-benchmarking-cli", + "frame-support", + "frame-system-rpc-runtime-api", + "futures", + "hex-literal 0.4.1", + "kusama-runtime", + "kvdb", + "kvdb-rocksdb", + "log", + "lru 0.9.0", + "mmr-gadget", + "pallet-babe", + "pallet-im-online", + "pallet-staking", + "pallet-transaction-payment-rpc-runtime-api", + "parity-db", + "polkadot-approval-distribution", + "polkadot-availability-bitfield-distribution", + "polkadot-availability-distribution", + "polkadot-availability-recovery", + "polkadot-client", + "polkadot-collator-protocol", + "polkadot-dispute-distribution", + "polkadot-gossip-support", + "polkadot-network-bridge", + "polkadot-node-collation-generation", + "polkadot-node-core-approval-voting", + "polkadot-node-core-av-store", + "polkadot-node-core-backing", + "polkadot-node-core-bitfield-signing", + "polkadot-node-core-candidate-validation", + "polkadot-node-core-chain-api", + "polkadot-node-core-chain-selection", + "polkadot-node-core-dispute-coordinator", + "polkadot-node-core-parachains-inherent", + "polkadot-node-core-provisioner", + "polkadot-node-core-pvf-checker", + "polkadot-node-core-runtime-api", + "polkadot-node-network-protocol", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-types", + "polkadot-node-subsystem-util", + "polkadot-overseer", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-rpc", + "polkadot-runtime", + "polkadot-runtime-constants", + "polkadot-runtime-parachains", + "polkadot-statement-distribution", + "rococo-runtime", + "sc-authority-discovery", + "sc-basic-authorship", + "sc-block-builder", + "sc-chain-spec", + "sc-client-api", + "sc-client-db", + "sc-consensus", + "sc-consensus-babe", + "sc-consensus-beefy", + "sc-consensus-grandpa", + "sc-consensus-slots", + "sc-executor", + "sc-keystore", + "sc-network", + "sc-network-common", + "sc-network-sync", + "sc-offchain", + "sc-service", + "sc-sync-state-rpc", + "sc-sysinfo", + "sc-telemetry", + "sc-transaction-pool", + "serde", + "serde_json", + "sp-api", + "sp-authority-discovery", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-consensus-beefy", + "sp-consensus-grandpa", + "sp-core", + "sp-inherents", + "sp-io", + "sp-keystore", + "sp-mmr-primitives", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-state-machine", + "sp-storage", + "sp-timestamp", + "sp-transaction-pool", + "sp-trie", + "substrate-prometheus-endpoint", + "thiserror", + "tracing-gum", + "westend-runtime", +] + +[[package]] +name = "polkadot-statement-distribution" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "arrayvec 0.5.2", + "fatality", + "futures", + "indexmap 1.9.3", + "parity-scale-codec", + "polkadot-node-network-protocol", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-node-subsystem-util", + "polkadot-primitives", + "sp-keystore", + "sp-staking", + "thiserror", + "tracing-gum", +] + +[[package]] +name = "polkadot-statement-table" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "parity-scale-codec", + "polkadot-primitives", + "sp-core", +] + +[[package]] +name = "polkadot-test-runtime" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "bitvec", + "frame-election-provider-support", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "log", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", + "pallet-balances", + "pallet-grandpa", + "pallet-indices", + "pallet-offences", + "pallet-session", + "pallet-staking", + "pallet-staking-reward-curve", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-vesting", + "pallet-xcm", + "parity-scale-codec", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "rustc-hex", + "scale-info", + "serde", + "serde_derive", + "smallvec", + "sp-api", + "sp-authority-discovery", + "sp-block-builder", + "sp-consensus-babe", + "sp-consensus-beefy", + "sp-core", + "sp-inherents", + "sp-io", + "sp-mmr-primitives", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", + "test-runtime-constants", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "polkadot-test-service" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "frame-benchmarking", + "frame-system", + "futures", + "hex", + "pallet-balances", + "pallet-staking", + "pallet-transaction-payment", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-overseer", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-rpc", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "polkadot-service", + "polkadot-test-runtime", + "rand 0.8.5", + "sc-authority-discovery", + "sc-chain-spec", + "sc-cli", + "sc-client-api", + "sc-consensus", + "sc-consensus-babe", + "sc-consensus-grandpa", + "sc-executor", + "sc-network", + "sc-service", + "sc-tracing", + "sc-transaction-pool", + "sp-arithmetic", + "sp-authority-discovery", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-consensus-grandpa", + "sp-core", + "sp-inherents", + "sp-keyring", + "sp-runtime", + "sp-state-machine", + "substrate-test-client", + "tempfile", + "test-runtime-constants", + "tokio", + "tracing-gum", +] + +[[package]] +name = "polling" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" +dependencies = [ + "autocfg", + "bitflags 1.3.2", + "cfg-if", + "concurrent-queue", + "libc", + "log", + "pin-project-lite 0.2.13", + "windows-sys 0.48.0", +] + +[[package]] +name = "poly1305" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" +dependencies = [ + "cpufeatures", + "opaque-debug 0.3.0", + "universal-hash 0.4.1", +] + +[[package]] +name = "polyval" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" +dependencies = [ + "cfg-if", + "cpufeatures", + "opaque-debug 0.3.0", + "universal-hash 0.4.1", +] + +[[package]] +name = "polyval" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52cff9d1d4dee5fe6d03729099f4a310a41179e0a10dbf542039873f2e826fb" +dependencies = [ + "cfg-if", + "cpufeatures", + "opaque-debug 0.3.0", + "universal-hash 0.5.1", +] + +[[package]] +name = "portable-atomic" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bccab0e7fd7cc19f820a1c8c91720af652d0c88dc9664dd72aef2614f04af3b" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "predicates" +version = "2.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59230a63c37f3e18569bdb90e4a89cbf5bf8b06fea0b84e65ea10cc4df47addd" +dependencies = [ + "difflib", + "float-cmp", + "itertools 0.10.5", + "normalize-line-endings", + "predicates-core", + "regex", +] + +[[package]] +name = "predicates-core" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b794032607612e7abeb4db69adb4e33590fa6cf1149e95fd7cb00e634b92f174" + +[[package]] +name = "predicates-tree" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "368ba315fb8c5052ab692e68a0eefec6ec57b23a36959c14496f0b0df2c0cecf" +dependencies = [ + "predicates-core", + "termtree", +] + +[[package]] +name = "prettyplease" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8646e95016a7a6c4adea95bafa8a16baab64b583356217f2c85db4a39d9a86" +dependencies = [ + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "prettyplease" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" +dependencies = [ + "proc-macro2", + "syn 2.0.39", +] + +[[package]] +name = "primitive-types" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b34d9fd68ae0b74a41b21c03c2f62847aa0ffea044eee893b4c140b37e244e2" +dependencies = [ + "fixed-hash", + "impl-codec", + "impl-serde", + "scale-info", + "uint", +] + +[[package]] +name = "prioritized-metered-channel" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "382698e48a268c832d0b181ed438374a6bb708a82a8ca273bb0f61c74cf209c4" +dependencies = [ + "coarsetime", + "crossbeam-queue", + "derive_more", + "futures", + "futures-timer", + "nanorand", + "thiserror", + "tracing", +] + +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro-warning" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e99670bafb56b9a106419397343bdbc8b8742c3cc449fec6345f86173f47cd4" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "proc-macro2" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prometheus" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "449811d15fbdf5ceb5c1144416066429cf82316e2ec8ce0c1f6f8a02e7bbcf8c" +dependencies = [ + "cfg-if", + "fnv", + "lazy_static", + "memchr", + "parking_lot 0.12.1", + "thiserror", +] + +[[package]] +name = "prometheus-client" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d6fa99d535dd930d1249e6c79cb3c2915f9172a540fe2b02a4c8f9ca954721e" +dependencies = [ + "dtoa", + "itoa", + "parking_lot 0.12.1", + "prometheus-client-derive-encode", +] + +[[package]] +name = "prometheus-client-derive-encode" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "prost" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" +dependencies = [ + "bytes", + "heck", + "itertools 0.10.5", + "lazy_static", + "log", + "multimap", + "petgraph", + "prettyplease 0.1.25", + "prost", + "prost-types", + "regex", + "syn 1.0.109", + "tempfile", + "which", +] + +[[package]] +name = "prost-derive" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" +dependencies = [ + "anyhow", + "itertools 0.10.5", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "prost-types" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" +dependencies = [ + "prost", +] + +[[package]] +name = "psm" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5787f7cda34e3033a72192c018bc5883100330f362ef279a8cbccfce8bb4e874" +dependencies = [ + "cc", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quick-protobuf" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d6da84cc204722a989e01ba2f6e1e276e190f22263d0cb6ce8526fcdb0d2e1f" +dependencies = [ + "byteorder", +] + +[[package]] +name = "quick-protobuf-codec" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1693116345026436eb2f10b677806169c1a1260c1c60eaaffe3fb5a29ae23d8b" +dependencies = [ + "asynchronous-codec", + "bytes", + "quick-protobuf", + "thiserror", + "unsigned-varint", +] + +[[package]] +name = "quicksink" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77de3c815e5a160b1539c6592796801df2043ae35e123b46d73380cfa57af858" +dependencies = [ + "futures-core", + "futures-sink", + "pin-project-lite 0.1.12", +] + +[[package]] +name = "quinn-proto" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94b0b33c13a79f669c85defaf4c275dc86a0c0372807d0ca3d78e0bb87274863" +dependencies = [ + "bytes", + "rand 0.8.5", + "ring 0.16.20", + "rustc-hash", + "rustls 0.20.9", + "slab", + "thiserror", + "tinyvec", + "tracing", + "webpki 0.22.4", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha 0.2.2", + "rand_core 0.5.1", + "rand_hc", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.11", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "rand_pcg" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59cad018caf63deb318e5a4586d99a24424a364f40f1e5778c29aca23f4fc73e" +dependencies = [ + "rand_core 0.6.4", +] + +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + +[[package]] +name = "rayon" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "rcgen" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" +dependencies = [ + "pem", + "ring 0.16.20", + "time", + "x509-parser 0.13.2", + "yasna", +] + +[[package]] +name = "rcgen" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" +dependencies = [ + "pem", + "ring 0.16.20", + "time", + "yasna", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_users" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" +dependencies = [ + "getrandom 0.2.11", + "libredox", + "thiserror", +] + +[[package]] +name = "reed-solomon-novelpoly" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58130877ca403ab42c864fbac74bb319a0746c07a634a92a5cfc7f54af272582" +dependencies = [ + "derive_more", + "fs-err", + "itertools 0.11.0", + "static_init", + "thiserror", +] + +[[package]] +name = "ref-cast" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acde58d073e9c79da00f2b5b84eed919c8326832648a5b109b3fce1bb1175280" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7473c2cfcf90008193dd0e3e16599455cb601a9fce322b5bb55de799664925" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "regalloc2" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80535183cae11b149d618fbd3c37e38d7cda589d82d7769e196ca9a9042d7621" +dependencies = [ + "fxhash", + "log", + "slice-group-by", + "smallvec", +] + +[[package]] +name = "regex" +version = "1.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata 0.4.3", + "regex-syntax 0.8.2", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.2", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "resolv-conf" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" +dependencies = [ + "hostname", + "quick-error", +] + +[[package]] +name = "rfc6979" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7743f17af12fa0b03b803ba12cd6a8d9483a587e89c69445e3909655c0b9fabb" +dependencies = [ + "crypto-bigint 0.4.9", + "hmac 0.12.1", + "zeroize", +] + +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac 0.12.1", + "subtle", +] + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin 0.5.2", + "untrusted 0.7.1", + "web-sys", + "winapi", +] + +[[package]] +name = "ring" +version = "0.17.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" +dependencies = [ + "cc", + "getrandom 0.2.11", + "libc", + "spin 0.9.8", + "untrusted 0.9.0", + "windows-sys 0.48.0", +] + +[[package]] +name = "rocksdb" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb6f170a4041d50a0ce04b0d2e14916d6ca863ea2e422689a5b694395d299ffe" +dependencies = [ + "libc", + "librocksdb-sys", +] + +[[package]] +name = "rococo-runtime" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "binary-merkle-tree", + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal 0.4.1", + "log", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", + "pallet-balances", + "pallet-beefy", + "pallet-beefy-mmr", + "pallet-bounties", + "pallet-child-bounties", + "pallet-collective", + "pallet-democracy", + "pallet-elections-phragmen", + "pallet-grandpa", + "pallet-identity", + "pallet-im-online", + "pallet-indices", + "pallet-membership", + "pallet-message-queue", + "pallet-mmr", + "pallet-multisig", + "pallet-nis", + "pallet-offences", + "pallet-preimage", + "pallet-proxy", + "pallet-recovery", + "pallet-scheduler", + "pallet-session", + "pallet-society", + "pallet-staking", + "pallet-state-trie-migration", + "pallet-sudo", + "pallet-timestamp", + "pallet-tips", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", + "pallet-utility", + "pallet-vesting", + "pallet-xcm", + "pallet-xcm-benchmarks", + "parity-scale-codec", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "rococo-runtime-constants", + "scale-info", + "serde", + "serde_derive", + "smallvec", + "sp-api", + "sp-authority-discovery", + "sp-block-builder", + "sp-consensus-babe", + "sp-consensus-beefy", + "sp-core", + "sp-inherents", + "sp-io", + "sp-mmr-primitives", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "sp-transaction-pool", + "sp-version", + "static_assertions", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "rococo-runtime-constants" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "frame-support", + "polkadot-primitives", + "polkadot-runtime-common", + "smallvec", + "sp-core", + "sp-runtime", + "sp-weights", +] + +[[package]] +name = "rpassword" +version = "7.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6678cf63ab3491898c0d021b493c94c9b221d91295294a2a5746eacbe5928322" +dependencies = [ + "libc", + "rtoolbox", + "winapi", +] + +[[package]] +name = "rtcp" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1919efd6d4a6a85d13388f9487549bb8e359f17198cc03ffd72f79b553873691" +dependencies = [ + "bytes", + "thiserror", + "webrtc-util", +] + +[[package]] +name = "rtnetlink" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322c53fd76a18698f1c27381d58091de3a043d356aa5bd0d510608b565f469a0" +dependencies = [ + "futures", + "log", + "netlink-packet-route", + "netlink-proto", + "nix", + "thiserror", + "tokio", +] + +[[package]] +name = "rtoolbox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "034e22c514f5c0cb8a10ff341b9b048b5ceb21591f31c8f44c43b960f9b3524a" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "rtp" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2a095411ff00eed7b12e4c6a118ba984d113e1079582570d56a5ee723f11f80" +dependencies = [ + "async-trait", + "bytes", + "rand 0.8.5", + "serde", + "thiserror", + "webrtc-util", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc-hex" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e75f6a532d0fd9f7f13144f392b6ad56a32696bfcd9c78f797f16bbb6f072d6" + +[[package]] +name = "rustc_version" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" +dependencies = [ + "semver 0.9.0", +] + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver 1.0.20", +] + +[[package]] +name = "rusticata-macros" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" +dependencies = [ + "nom", +] + +[[package]] +name = "rustix" +version = "0.36.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "305efbd14fde4139eb501df5f136994bb520b033fa9fbdce287507dc23b8c7ed" +dependencies = [ + "bitflags 1.3.2", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys 0.1.4", + "windows-sys 0.45.0", +] + +[[package]] +name = "rustix" +version = "0.37.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" +dependencies = [ + "bitflags 1.3.2", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys 0.3.8", + "windows-sys 0.48.0", +] + +[[package]] +name = "rustix" +version = "0.38.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" +dependencies = [ + "bitflags 2.4.1", + "errno", + "libc", + "linux-raw-sys 0.4.11", + "windows-sys 0.48.0", +] + +[[package]] +name = "rustls" +version = "0.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" +dependencies = [ + "base64 0.13.1", + "log", + "ring 0.16.20", + "sct 0.6.1", + "webpki 0.21.4", +] + +[[package]] +name = "rustls" +version = "0.20.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" +dependencies = [ + "log", + "ring 0.16.20", + "sct 0.7.1", + "webpki 0.22.4", +] + +[[package]] +name = "rustls" +version = "0.21.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" +dependencies = [ + "log", + "ring 0.17.5", + "rustls-webpki", + "sct 0.7.1", +] + +[[package]] +name = "rustls-native-certs" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +dependencies = [ + "base64 0.21.5", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring 0.17.5", + "untrusted 0.9.0", +] + +[[package]] +name = "rustversion" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" + +[[package]] +name = "rw-stream-sink" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26338f5e09bb721b85b135ea05af7767c90b52f6de4f087d4f4a3a9d64e7dc04" +dependencies = [ + "futures", + "pin-project", + "static_assertions", +] + +[[package]] +name = "ryu" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" + +[[package]] +name = "safe-mix" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d3d055a2582e6b00ed7a31c1524040aa391092bf636328350813f3a0605215c" +dependencies = [ + "rustc_version 0.2.3", +] + +[[package]] +name = "safe_arch" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f398075ce1e6a179b46f51bd88d0598b92b00d3551f1a2d4ac49e771b56ac354" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "sc-allocator" +version = "4.1.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "log", + "sp-core", + "sp-wasm-interface", + "thiserror", +] + +[[package]] +name = "sc-authority-discovery" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "async-trait", + "futures", + "futures-timer", + "ip_network", + "libp2p", + "log", + "multihash 0.17.0", + "parity-scale-codec", + "prost", + "prost-build", + "rand 0.8.5", + "sc-client-api", + "sc-network", + "sc-network-common", + "sp-api", + "sp-authority-discovery", + "sp-blockchain", + "sp-core", + "sp-keystore", + "sp-runtime", + "substrate-prometheus-endpoint", + "thiserror", +] + +[[package]] +name = "sc-basic-authorship" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "futures", + "futures-timer", + "log", + "parity-scale-codec", + "sc-block-builder", + "sc-client-api", + "sc-proposer-metrics", + "sc-telemetry", + "sc-transaction-pool-api", + "sp-api", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-inherents", + "sp-runtime", + "substrate-prometheus-endpoint", +] + +[[package]] +name = "sc-block-builder" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "parity-scale-codec", + "sc-client-api", + "sp-api", + "sp-block-builder", + "sp-blockchain", + "sp-core", + "sp-inherents", + "sp-runtime", +] + +[[package]] +name = "sc-chain-spec" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "memmap2", + "sc-chain-spec-derive", + "sc-client-api", + "sc-executor", + "sc-network", + "sc-telemetry", + "serde", + "serde_json", + "sp-blockchain", + "sp-core", + "sp-runtime", + "sp-state-machine", +] + +[[package]] +name = "sc-chain-spec-derive" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "sc-cli" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "array-bytes 4.2.0", + "chrono", + "clap", + "fdlimit", + "futures", + "libp2p-identity", + "log", + "names", + "parity-scale-codec", + "rand 0.8.5", + "regex", + "rpassword", + "sc-client-api", + "sc-client-db", + "sc-keystore", + "sc-network", + "sc-network-common", + "sc-service", + "sc-telemetry", + "sc-tracing", + "sc-utils", + "serde", + "serde_json", + "sp-blockchain", + "sp-core", + "sp-keyring", + "sp-keystore", + "sp-panic-handler", + "sp-runtime", + "sp-version", + "thiserror", + "tiny-bip39", + "tokio", +] + +[[package]] +name = "sc-client-api" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "fnv", + "futures", + "log", + "parity-scale-codec", + "parking_lot 0.12.1", + "sc-executor", + "sc-transaction-pool-api", + "sc-utils", + "sp-api", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-database", + "sp-externalities", + "sp-keystore", + "sp-runtime", + "sp-state-machine", + "sp-statement-store", + "sp-storage", + "substrate-prometheus-endpoint", +] + +[[package]] +name = "sc-client-db" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "hash-db", + "kvdb", + "kvdb-memorydb", + "kvdb-rocksdb", + "linked-hash-map", + "log", + "parity-db", + "parity-scale-codec", + "parking_lot 0.12.1", + "sc-client-api", + "sc-state-db", + "schnellru", + "sp-arithmetic", + "sp-blockchain", + "sp-core", + "sp-database", + "sp-runtime", + "sp-state-machine", + "sp-trie", +] + +[[package]] +name = "sc-consensus" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "async-trait", + "futures", + "futures-timer", + "libp2p-identity", + "log", + "mockall", + "parking_lot 0.12.1", + "sc-client-api", + "sc-utils", + "serde", + "sp-api", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-runtime", + "sp-state-machine", + "substrate-prometheus-endpoint", + "thiserror", +] + +[[package]] +name = "sc-consensus-aura" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "async-trait", + "futures", + "log", + "parity-scale-codec", + "sc-block-builder", + "sc-client-api", + "sc-consensus", + "sc-consensus-slots", + "sc-telemetry", + "sp-api", + "sp-application-crypto", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-consensus-aura", + "sp-consensus-slots", + "sp-core", + "sp-inherents", + "sp-keystore", + "sp-runtime", + "substrate-prometheus-endpoint", + "thiserror", +] + +[[package]] +name = "sc-consensus-babe" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "async-trait", + "fork-tree", + "futures", + "log", + "num-bigint", + "num-rational", + "num-traits", + "parity-scale-codec", + "parking_lot 0.12.1", + "sc-client-api", + "sc-consensus", + "sc-consensus-epochs", + "sc-consensus-slots", + "sc-keystore", + "sc-telemetry", + "scale-info", + "sp-api", + "sp-application-crypto", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-consensus-slots", + "sp-core", + "sp-inherents", + "sp-keystore", + "sp-runtime", + "substrate-prometheus-endpoint", + "thiserror", +] + +[[package]] +name = "sc-consensus-babe-rpc" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "futures", + "jsonrpsee", + "sc-consensus-babe", + "sc-consensus-epochs", + "sc-rpc-api", + "serde", + "sp-api", + "sp-application-crypto", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-core", + "sp-keystore", + "sp-runtime", + "thiserror", +] + +[[package]] +name = "sc-consensus-beefy" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "array-bytes 4.2.0", + "async-channel", + "async-trait", + "fnv", + "futures", + "log", + "parity-scale-codec", + "parking_lot 0.12.1", + "sc-client-api", + "sc-consensus", + "sc-keystore", + "sc-network", + "sc-network-common", + "sc-network-gossip", + "sc-network-sync", + "sc-utils", + "sp-api", + "sp-application-crypto", + "sp-arithmetic", + "sp-blockchain", + "sp-consensus", + "sp-consensus-beefy", + "sp-core", + "sp-keystore", + "sp-mmr-primitives", + "sp-runtime", + "substrate-prometheus-endpoint", + "thiserror", + "wasm-timer", +] + +[[package]] +name = "sc-consensus-beefy-rpc" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "futures", + "jsonrpsee", + "log", + "parity-scale-codec", + "parking_lot 0.12.1", + "sc-consensus-beefy", + "sc-rpc", + "serde", + "sp-consensus-beefy", + "sp-core", + "sp-runtime", + "thiserror", +] + +[[package]] +name = "sc-consensus-epochs" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "fork-tree", + "parity-scale-codec", + "sc-client-api", + "sc-consensus", + "sp-blockchain", + "sp-runtime", +] + +[[package]] +name = "sc-consensus-grandpa" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "ahash 0.8.6", + "array-bytes 4.2.0", + "async-trait", + "dyn-clone", + "finality-grandpa", + "fork-tree", + "futures", + "futures-timer", + "log", + "parity-scale-codec", + "parking_lot 0.12.1", + "rand 0.8.5", + "sc-block-builder", + "sc-chain-spec", + "sc-client-api", + "sc-consensus", + "sc-network", + "sc-network-common", + "sc-network-gossip", + "sc-telemetry", + "sc-utils", + "serde_json", + "sp-api", + "sp-application-crypto", + "sp-arithmetic", + "sp-blockchain", + "sp-consensus", + "sp-consensus-grandpa", + "sp-core", + "sp-keystore", + "sp-runtime", + "substrate-prometheus-endpoint", + "thiserror", +] + +[[package]] +name = "sc-consensus-grandpa-rpc" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "finality-grandpa", + "futures", + "jsonrpsee", + "log", + "parity-scale-codec", + "sc-client-api", + "sc-consensus-grandpa", + "sc-rpc", + "serde", + "sp-blockchain", + "sp-core", + "sp-runtime", + "thiserror", +] + +[[package]] +name = "sc-consensus-slots" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "async-trait", + "futures", + "futures-timer", + "log", + "parity-scale-codec", + "sc-client-api", + "sc-consensus", + "sc-telemetry", + "sp-arithmetic", + "sp-blockchain", + "sp-consensus", + "sp-consensus-slots", + "sp-core", + "sp-inherents", + "sp-runtime", + "sp-state-machine", +] + +[[package]] +name = "sc-executor" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "lru 0.8.1", + "parity-scale-codec", + "parking_lot 0.12.1", + "sc-executor-common", + "sc-executor-wasmtime", + "sp-api", + "sp-core", + "sp-externalities", + "sp-io", + "sp-panic-handler", + "sp-runtime-interface", + "sp-trie", + "sp-version", + "sp-wasm-interface", + "tracing", +] + +[[package]] +name = "sc-executor-common" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "sc-allocator", + "sp-maybe-compressed-blob", + "sp-wasm-interface", + "thiserror", + "wasm-instrument", +] + +[[package]] +name = "sc-executor-wasmtime" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "anyhow", + "cfg-if", + "libc", + "log", + "once_cell", + "rustix 0.36.17", + "sc-allocator", + "sc-executor-common", + "sp-runtime-interface", + "sp-wasm-interface", + "wasmtime", +] + +[[package]] +name = "sc-informant" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "ansi_term", + "futures", + "futures-timer", + "log", + "sc-client-api", + "sc-network", + "sc-network-common", + "sp-blockchain", + "sp-runtime", +] + +[[package]] +name = "sc-keystore" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "array-bytes 4.2.0", + "parking_lot 0.12.1", + "serde_json", + "sp-application-crypto", + "sp-core", + "sp-keystore", + "thiserror", +] + +[[package]] +name = "sc-network" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "array-bytes 4.2.0", + "async-channel", + "async-trait", + "asynchronous-codec", + "bytes", + "either", + "fnv", + "futures", + "futures-timer", + "ip_network", + "libp2p", + "linked_hash_set", + "log", + "lru 0.8.1", + "mockall", + "parity-scale-codec", + "parking_lot 0.12.1", + "pin-project", + "rand 0.8.5", + "sc-block-builder", + "sc-client-api", + "sc-consensus", + "sc-network-common", + "sc-peerset", + "sc-utils", + "serde", + "serde_json", + "smallvec", + "snow", + "sp-arithmetic", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-runtime", + "substrate-prometheus-endpoint", + "thiserror", + "unsigned-varint", + "zeroize", +] + +[[package]] +name = "sc-network-bitswap" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "async-channel", + "cid", + "futures", + "libp2p-identity", + "log", + "prost", + "prost-build", + "sc-client-api", + "sc-network", + "sc-network-common", + "sp-blockchain", + "sp-runtime", + "thiserror", + "unsigned-varint", +] + +[[package]] +name = "sc-network-common" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "array-bytes 4.2.0", + "async-trait", + "bitflags 1.3.2", + "bytes", + "futures", + "futures-timer", + "libp2p-identity", + "parity-scale-codec", + "prost-build", + "sc-consensus", + "sc-peerset", + "sc-utils", + "serde", + "smallvec", + "sp-blockchain", + "sp-consensus", + "sp-consensus-grandpa", + "sp-runtime", + "substrate-prometheus-endpoint", + "thiserror", + "zeroize", +] + +[[package]] +name = "sc-network-gossip" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "ahash 0.8.6", + "futures", + "futures-timer", + "libp2p", + "log", + "lru 0.8.1", + "sc-network", + "sc-network-common", + "sc-peerset", + "sp-runtime", + "substrate-prometheus-endpoint", + "tracing", +] + +[[package]] +name = "sc-network-light" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "array-bytes 4.2.0", + "async-channel", + "futures", + "libp2p-identity", + "log", + "parity-scale-codec", + "prost", + "prost-build", + "sc-client-api", + "sc-network", + "sc-network-common", + "sc-peerset", + "sp-blockchain", + "sp-core", + "sp-runtime", + "thiserror", +] + +[[package]] +name = "sc-network-sync" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "array-bytes 4.2.0", + "async-channel", + "async-trait", + "fork-tree", + "futures", + "futures-timer", + "libp2p", + "log", + "lru 0.8.1", + "mockall", + "parity-scale-codec", + "prost", + "prost-build", + "sc-client-api", + "sc-consensus", + "sc-network", + "sc-network-common", + "sc-peerset", + "sc-utils", + "smallvec", + "sp-arithmetic", + "sp-blockchain", + "sp-consensus", + "sp-consensus-grandpa", + "sp-core", + "sp-runtime", + "substrate-prometheus-endpoint", + "thiserror", +] + +[[package]] +name = "sc-network-transactions" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "array-bytes 4.2.0", + "futures", + "libp2p", + "log", + "parity-scale-codec", + "pin-project", + "sc-network", + "sc-network-common", + "sc-peerset", + "sc-utils", + "sp-consensus", + "sp-runtime", + "substrate-prometheus-endpoint", +] + +[[package]] +name = "sc-offchain" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "array-bytes 4.2.0", + "bytes", + "fnv", + "futures", + "futures-timer", + "hyper", + "hyper-rustls 0.23.2", + "libp2p", + "num_cpus", + "once_cell", + "parity-scale-codec", + "parking_lot 0.12.1", + "rand 0.8.5", + "sc-client-api", + "sc-network", + "sc-network-common", + "sc-peerset", + "sc-utils", + "sp-api", + "sp-core", + "sp-offchain", + "sp-runtime", + "threadpool", + "tracing", +] + +[[package]] +name = "sc-peerset" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "futures", + "libp2p-identity", + "log", + "parking_lot 0.12.1", + "partial_sort", + "sc-utils", + "serde_json", + "sp-arithmetic", + "wasm-timer", +] + +[[package]] +name = "sc-proposer-metrics" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "log", + "substrate-prometheus-endpoint", +] + +[[package]] +name = "sc-rpc" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "futures", + "jsonrpsee", + "log", + "parity-scale-codec", + "parking_lot 0.12.1", + "sc-block-builder", + "sc-chain-spec", + "sc-client-api", + "sc-rpc-api", + "sc-tracing", + "sc-transaction-pool-api", + "sc-utils", + "serde_json", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-keystore", + "sp-offchain", + "sp-rpc", + "sp-runtime", + "sp-session", + "sp-statement-store", + "sp-version", + "tokio", +] + +[[package]] +name = "sc-rpc-api" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "jsonrpsee", + "parity-scale-codec", + "sc-chain-spec", + "sc-transaction-pool-api", + "scale-info", + "serde", + "serde_json", + "sp-core", + "sp-rpc", + "sp-runtime", + "sp-version", + "thiserror", +] + +[[package]] +name = "sc-rpc-server" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "http", + "jsonrpsee", + "log", + "serde_json", + "substrate-prometheus-endpoint", + "tokio", + "tower", + "tower-http", +] + +[[package]] +name = "sc-rpc-spec-v2" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "array-bytes 4.2.0", + "futures", + "futures-util", + "hex", + "jsonrpsee", + "log", + "parity-scale-codec", + "parking_lot 0.12.1", + "sc-chain-spec", + "sc-client-api", + "sc-transaction-pool-api", + "serde", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-runtime", + "sp-version", + "thiserror", + "tokio-stream", +] + +[[package]] +name = "sc-service" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "async-trait", + "directories", + "exit-future", + "futures", + "futures-timer", + "jsonrpsee", + "log", + "parity-scale-codec", + "parking_lot 0.12.1", + "pin-project", + "rand 0.8.5", + "sc-block-builder", + "sc-chain-spec", + "sc-client-api", + "sc-client-db", + "sc-consensus", + "sc-executor", + "sc-informant", + "sc-keystore", + "sc-network", + "sc-network-bitswap", + "sc-network-common", + "sc-network-light", + "sc-network-sync", + "sc-network-transactions", + "sc-offchain", + "sc-rpc", + "sc-rpc-server", + "sc-rpc-spec-v2", + "sc-storage-monitor", + "sc-sysinfo", + "sc-telemetry", + "sc-tracing", + "sc-transaction-pool", + "sc-transaction-pool-api", + "sc-utils", + "serde", + "serde_json", + "sp-api", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-externalities", + "sp-keystore", + "sp-runtime", + "sp-session", + "sp-state-machine", + "sp-storage", + "sp-transaction-pool", + "sp-transaction-storage-proof", + "sp-trie", + "sp-version", + "static_init", + "substrate-prometheus-endpoint", + "tempfile", + "thiserror", + "tokio", + "tracing", + "tracing-futures", +] + +[[package]] +name = "sc-state-db" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "log", + "parity-scale-codec", + "parking_lot 0.12.1", + "sp-core", +] + +[[package]] +name = "sc-storage-monitor" +version = "0.1.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "clap", + "fs4", + "futures", + "log", + "sc-client-db", + "sc-utils", + "sp-core", + "thiserror", + "tokio", +] + +[[package]] +name = "sc-sync-state-rpc" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "jsonrpsee", + "parity-scale-codec", + "sc-chain-spec", + "sc-client-api", + "sc-consensus-babe", + "sc-consensus-epochs", + "sc-consensus-grandpa", + "serde", + "serde_json", + "sp-blockchain", + "sp-runtime", + "thiserror", +] + +[[package]] +name = "sc-sysinfo" +version = "6.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "futures", + "libc", + "log", + "rand 0.8.5", + "rand_pcg", + "regex", + "sc-telemetry", + "serde", + "serde_json", + "sp-core", + "sp-io", + "sp-std", +] + +[[package]] +name = "sc-telemetry" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "chrono", + "futures", + "libp2p", + "log", + "parking_lot 0.12.1", + "pin-project", + "rand 0.8.5", + "sc-utils", + "serde", + "serde_json", + "thiserror", + "wasm-timer", +] + +[[package]] +name = "sc-tracing" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "ansi_term", + "atty", + "chrono", + "lazy_static", + "libc", + "log", + "once_cell", + "parking_lot 0.12.1", + "regex", + "rustc-hash", + "sc-client-api", + "sc-rpc-server", + "sc-tracing-proc-macro", + "serde", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-rpc", + "sp-runtime", + "sp-tracing", + "thiserror", + "tracing", + "tracing-log", + "tracing-subscriber", +] + +[[package]] +name = "sc-tracing-proc-macro" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "sc-transaction-pool" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "async-trait", + "futures", + "futures-timer", + "linked-hash-map", + "log", + "num-traits", + "parity-scale-codec", + "parking_lot 0.12.1", + "sc-client-api", + "sc-transaction-pool-api", + "sc-utils", + "serde", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-runtime", + "sp-tracing", + "sp-transaction-pool", + "substrate-prometheus-endpoint", + "thiserror", +] + +[[package]] +name = "sc-transaction-pool-api" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "async-trait", + "futures", + "log", + "serde", + "sp-blockchain", + "sp-runtime", + "thiserror", +] + +[[package]] +name = "sc-utils" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "async-channel", + "futures", + "futures-timer", + "lazy_static", + "log", + "parking_lot 0.12.1", + "prometheus", + "sp-arithmetic", +] + +[[package]] +name = "scale-info" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" +dependencies = [ + "bitvec", + "cfg-if", + "derive_more", + "parity-scale-codec", + "scale-info-derive", + "serde", +] + +[[package]] +name = "scale-info-derive" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "schannel" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "schnellru" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "772575a524feeb803e5b0fcbc6dd9f367e579488197c94c6e4023aad2305774d" +dependencies = [ + "ahash 0.8.6", + "cfg-if", + "hashbrown 0.13.2", +] + +[[package]] +name = "schnorrkel" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "021b403afe70d81eea68f6ea12f6b3c9588e5d536a94c3bf80f15e7faa267862" +dependencies = [ + "arrayref", + "arrayvec 0.5.2", + "curve25519-dalek 2.1.3", + "getrandom 0.1.16", + "merlin", + "rand 0.7.3", + "rand_core 0.5.1", + "sha2 0.8.2", + "subtle", + "zeroize", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "scratch" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" + +[[package]] +name = "sct" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b362b83898e0e69f38515b82ee15aa80636befe47c3b6d3d89a911e78fc228ce" +dependencies = [ + "ring 0.16.20", + "untrusted 0.7.1", +] + +[[package]] +name = "sct" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +dependencies = [ + "ring 0.17.5", + "untrusted 0.9.0", +] + +[[package]] +name = "sdp" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d22a5ef407871893fd72b4562ee15e4742269b173959db4b8df6f538c414e13" +dependencies = [ + "rand 0.8.5", + "substring", + "thiserror", + "url", +] + +[[package]] +name = "sec1" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" +dependencies = [ + "base16ct 0.1.1", + "der 0.6.1", + "generic-array 0.14.7", + "pkcs8 0.9.0", + "subtle", + "zeroize", +] + +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct 0.2.0", + "der 0.7.8", + "generic-array 0.14.7", + "pkcs8 0.10.2", + "subtle", + "zeroize", +] + +[[package]] +name = "secp256k1" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1629c9c557ef9b293568b338dddfc8208c98a18c59d722a9d53f859d9c9b62" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83080e2c2fc1006e625be82e5d1eb6a43b7fd9578b617fcc55814daf286bba4b" +dependencies = [ + "cc", +] + +[[package]] +name = "secrecy" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bd1c54ea06cfd2f6b63219704de0b9b4f72dcc2b8fdef820be6cd799780e91e" +dependencies = [ + "zeroize", +] + +[[package]] +name = "security-framework" +version = "2.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a3186ec9e65071a2095434b1f5bb24838d4e8e130f584c790f6033c79943537" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +dependencies = [ + "serde", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" + +[[package]] +name = "serde" +version = "1.0.192" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.192" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "serde_json" +version = "1.0.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_spanned" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" +dependencies = [ + "serde", +] + +[[package]] +name = "sha-1" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + +[[package]] +name = "sha2" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" +dependencies = [ + "block-buffer 0.7.3", + "digest 0.8.1", + "fake-simd", + "opaque-debug 0.2.3", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug 0.3.0", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest 0.10.7", + "keccak", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shared-configuration" +version = "0.1.0" +dependencies = [ + "frame-support", + "frame-system", + "pallet-funding", + "parachains-common", + "smallvec", + "sp-arithmetic", + "sp-std", +] + +[[package]] +name = "shlex" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" + +[[package]] +name = "signal-hook-registry" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" +dependencies = [ + "libc", +] + +[[package]] +name = "signature" +version = "1.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74233d3b3b2f6d4b006dc19dee745e73e2a6bfb6f93607cd3b02bd5b00797d7c" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", +] + +[[package]] +name = "signature" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +dependencies = [ + "digest 0.10.7", + "rand_core 0.6.4", +] + +[[package]] +name = "simba" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "061507c94fc6ab4ba1c9a0305018408e312e17c041eb63bef8aa726fa33aceae" +dependencies = [ + "approx", + "num-complex", + "num-traits", + "paste", + "wide", +] + +[[package]] +name = "similar" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2aeaf503862c419d66959f5d7ca015337d864e9c49485d771b732e2a20453597" +dependencies = [ + "bstr 0.2.17", + "unicode-segmentation", +] + +[[package]] +name = "similar-asserts" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e041bb827d1bfca18f213411d51b665309f1afb37a04a5d1464530e13779fc0f" +dependencies = [ + "console", + "similar", +] + +[[package]] +name = "siphasher" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "slice-group-by" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" + +[[package]] +name = "slot-range-helper" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "enumn", + "parity-scale-codec", + "paste", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "slotmap" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1e08e261d0e8f5c43123b7adf3e4ca1690d655377ac93a03b2c9d3e98de1342" +dependencies = [ + "version_check", +] + +[[package]] +name = "smallvec" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" + +[[package]] +name = "snap" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e9f0ab6ef7eb7353d9119c170a436d1bf248eea575ac42d19d12f4e34130831" + +[[package]] +name = "snow" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c9d1425eb528a21de2755c75af4c9b5d57f50a0d4c3b7f1828a4cd03f8ba155" +dependencies = [ + "aes-gcm 0.9.4", + "blake2", + "chacha20poly1305", + "curve25519-dalek 4.1.1", + "rand_core 0.6.4", + "ring 0.16.20", + "rustc_version 0.4.0", + "sha2 0.10.8", + "subtle", +] + +[[package]] +name = "socket2" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "socket2" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "soketto" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" +dependencies = [ + "base64 0.13.1", + "bytes", + "flate2", + "futures", + "http", + "httparse", + "log", + "rand 0.8.5", + "sha-1", +] + +[[package]] +name = "sp-api" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "hash-db", + "log", + "parity-scale-codec", + "scale-info", + "sp-api-proc-macro", + "sp-core", + "sp-metadata-ir", + "sp-runtime", + "sp-state-machine", + "sp-std", + "sp-trie", + "sp-version", + "thiserror", +] + +[[package]] +name = "sp-api-proc-macro" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "Inflector", + "blake2", + "expander 1.0.0", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "sp-application-crypto" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-std", +] + +[[package]] +name = "sp-arithmetic" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "integer-sqrt", + "num-traits", + "parity-scale-codec", + "scale-info", + "serde", + "sp-std", + "static_assertions", +] + +[[package]] +name = "sp-authority-discovery" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-application-crypto", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-block-builder" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "parity-scale-codec", + "sp-api", + "sp-inherents", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-blockchain" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "futures", + "log", + "lru 0.8.1", + "parity-scale-codec", + "parking_lot 0.12.1", + "sp-api", + "sp-consensus", + "sp-database", + "sp-runtime", + "sp-state-machine", + "thiserror", +] + +[[package]] +name = "sp-consensus" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "async-trait", + "futures", + "log", + "sp-core", + "sp-inherents", + "sp-runtime", + "sp-state-machine", + "thiserror", +] + +[[package]] +name = "sp-consensus-aura" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "async-trait", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-application-crypto", + "sp-consensus", + "sp-consensus-slots", + "sp-inherents", + "sp-runtime", + "sp-std", + "sp-timestamp", +] + +[[package]] +name = "sp-consensus-babe" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "async-trait", + "parity-scale-codec", + "scale-info", + "serde", + "sp-api", + "sp-application-crypto", + "sp-consensus", + "sp-consensus-slots", + "sp-core", + "sp-inherents", + "sp-keystore", + "sp-runtime", + "sp-std", + "sp-timestamp", +] + +[[package]] +name = "sp-consensus-beefy" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "lazy_static", + "parity-scale-codec", + "scale-info", + "serde", + "sp-api", + "sp-application-crypto", + "sp-core", + "sp-io", + "sp-mmr-primitives", + "sp-runtime", + "sp-std", + "strum", +] + +[[package]] +name = "sp-consensus-grandpa" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "finality-grandpa", + "log", + "parity-scale-codec", + "scale-info", + "serde", + "sp-api", + "sp-application-crypto", + "sp-core", + "sp-keystore", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-consensus-slots" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-std", + "sp-timestamp", +] + +[[package]] +name = "sp-core" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "array-bytes 4.2.0", + "bitflags 1.3.2", + "blake2", + "bounded-collections", + "bs58", + "dyn-clonable", + "ed25519-zebra", + "futures", + "hash-db", + "hash256-std-hasher", + "impl-serde", + "lazy_static", + "libsecp256k1", + "log", + "merlin", + "parity-scale-codec", + "parking_lot 0.12.1", + "paste", + "primitive-types", + "rand 0.8.5", + "regex", + "scale-info", + "schnorrkel", + "secp256k1", + "secrecy", + "serde", + "sp-core-hashing", + "sp-debug-derive", + "sp-externalities", + "sp-runtime-interface", + "sp-std", + "sp-storage", + "ss58-registry", + "substrate-bip39", + "thiserror", + "tiny-bip39", + "zeroize", +] + +[[package]] +name = "sp-core-hashing" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "blake2b_simd", + "byteorder", + "digest 0.10.7", + "sha2 0.10.8", + "sha3", + "sp-std", + "twox-hash", +] + +[[package]] +name = "sp-core-hashing-proc-macro" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "proc-macro2", + "quote", + "sp-core-hashing", + "syn 2.0.39", +] + +[[package]] +name = "sp-database" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "kvdb", + "parking_lot 0.12.1", +] + +[[package]] +name = "sp-debug-derive" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "sp-externalities" +version = "0.13.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "environmental", + "parity-scale-codec", + "sp-std", + "sp-storage", +] + +[[package]] +name = "sp-inherents" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "async-trait", + "impl-trait-for-tuples", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", + "sp-std", + "thiserror", +] + +[[package]] +name = "sp-io" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "bytes", + "ed25519 1.5.3", + "ed25519-dalek 1.0.1", + "futures", + "libsecp256k1", + "log", + "parity-scale-codec", + "rustversion", + "secp256k1", + "sp-core", + "sp-externalities", + "sp-keystore", + "sp-runtime-interface", + "sp-state-machine", + "sp-std", + "sp-tracing", + "sp-trie", + "tracing", + "tracing-core", +] + +[[package]] +name = "sp-keyring" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "lazy_static", + "sp-core", + "sp-runtime", + "strum", +] + +[[package]] +name = "sp-keystore" +version = "0.13.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "futures", + "parity-scale-codec", + "parking_lot 0.12.1", + "serde", + "sp-core", + "sp-externalities", + "thiserror", +] + +[[package]] +name = "sp-maybe-compressed-blob" +version = "4.1.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "thiserror", + "zstd 0.12.4", +] + +[[package]] +name = "sp-metadata-ir" +version = "0.1.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-metadata", + "parity-scale-codec", + "scale-info", + "sp-std", +] + +[[package]] +name = "sp-mmr-primitives" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "ckb-merkle-mountain-range", + "log", + "parity-scale-codec", + "scale-info", + "serde", + "sp-api", + "sp-core", + "sp-debug-derive", + "sp-runtime", + "sp-std", + "thiserror", +] + +[[package]] +name = "sp-npos-elections" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-arithmetic", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-offchain" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "sp-api", + "sp-core", + "sp-runtime", +] + +[[package]] +name = "sp-panic-handler" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "backtrace", + "lazy_static", + "regex", +] + +[[package]] +name = "sp-rpc" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "rustc-hash", + "serde", + "sp-core", +] + +[[package]] +name = "sp-runtime" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "either", + "hash256-std-hasher", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "paste", + "rand 0.8.5", + "scale-info", + "serde", + "sp-application-crypto", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-std", + "sp-weights", +] + +[[package]] +name = "sp-runtime-interface" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "bytes", + "impl-trait-for-tuples", + "parity-scale-codec", + "primitive-types", + "sp-externalities", + "sp-runtime-interface-proc-macro", + "sp-std", + "sp-storage", + "sp-tracing", + "sp-wasm-interface", + "static_assertions", +] + +[[package]] +name = "sp-runtime-interface-proc-macro" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "Inflector", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "sp-session" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-core", + "sp-runtime", + "sp-staking", + "sp-std", +] + +[[package]] +name = "sp-staking" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "sp-state-machine" +version = "0.13.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "hash-db", + "log", + "parity-scale-codec", + "parking_lot 0.12.1", + "rand 0.8.5", + "smallvec", + "sp-core", + "sp-externalities", + "sp-panic-handler", + "sp-std", + "sp-trie", + "thiserror", + "tracing", +] + +[[package]] +name = "sp-statement-store" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "log", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-application-crypto", + "sp-core", + "sp-externalities", + "sp-runtime", + "sp-runtime-interface", + "sp-std", + "thiserror", +] + +[[package]] +name = "sp-std" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" + +[[package]] +name = "sp-storage" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "ref-cast", + "serde", + "sp-debug-derive", + "sp-std", +] + +[[package]] +name = "sp-timestamp" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "async-trait", + "futures-timer", + "log", + "parity-scale-codec", + "sp-inherents", + "sp-runtime", + "sp-std", + "thiserror", +] + +[[package]] +name = "sp-tracing" +version = "6.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "parity-scale-codec", + "sp-std", + "tracing", + "tracing-core", + "tracing-subscriber", +] + +[[package]] +name = "sp-transaction-pool" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "sp-api", + "sp-runtime", +] + +[[package]] +name = "sp-transaction-storage-proof" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "async-trait", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-inherents", + "sp-runtime", + "sp-std", + "sp-trie", +] + +[[package]] +name = "sp-trie" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "ahash 0.8.6", + "hash-db", + "hashbrown 0.13.2", + "lazy_static", + "memory-db", + "nohash-hasher", + "parity-scale-codec", + "parking_lot 0.12.1", + "scale-info", + "schnellru", + "sp-core", + "sp-std", + "thiserror", + "tracing", + "trie-db", + "trie-root", +] + +[[package]] +name = "sp-version" +version = "5.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "impl-serde", + "parity-scale-codec", + "parity-wasm", + "scale-info", + "serde", + "sp-core-hashing-proc-macro", + "sp-runtime", + "sp-std", + "sp-version-proc-macro", + "thiserror", +] + +[[package]] +name = "sp-version-proc-macro" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "parity-scale-codec", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "sp-wasm-interface" +version = "7.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "anyhow", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "sp-std", + "wasmi", + "wasmtime", +] + +[[package]] +name = "sp-weights" +version = "4.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "smallvec", + "sp-arithmetic", + "sp-core", + "sp-debug-derive", + "sp-std", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "spinners" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08615eea740067d9899969bc2891c68a19c315cb1f66640af9a9ecb91b13bcab" +dependencies = [ + "lazy_static", + "maplit", + "strum", +] + +[[package]] +name = "spki" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cf02bbac7a337dc36e4f5a693db6c21e7863f45070f7064577eb4367a3212b" +dependencies = [ + "base64ct", + "der 0.6.1", +] + +[[package]] +name = "spki" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1e996ef02c474957d681f1b05213dfb0abab947b446a62d37770b23500184a" +dependencies = [ + "base64ct", + "der 0.7.8", +] + +[[package]] +name = "ss58-registry" +version = "1.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6915280e2d0db8911e5032a5c275571af6bdded2916abd691a659be25d3439" +dependencies = [ + "Inflector", + "num-format", + "proc-macro2", + "quote", + "serde", + "serde_json", + "unicode-xid", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "statemint-runtime" +version = "1.0.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "assets-common", + "cumulus-pallet-aura-ext", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-session-benchmarking", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-timestamp", + "cumulus-primitives-utility", + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "hex-literal 0.4.1", + "log", + "pallet-asset-tx-payment", + "pallet-assets", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-multisig", + "pallet-nfts", + "pallet-nfts-runtime-api", + "pallet-proxy", + "pallet-session", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-uniques", + "pallet-utility", + "pallet-xcm", + "pallet-xcm-benchmarks", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-runtime-common", + "polkadot-runtime-constants", + "scale-info", + "smallvec", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "sp-weights", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "static_init" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a2a1c578e98c1c16fc3b8ec1328f7659a500737d7a0c6d625e73e830ff9c1f6" +dependencies = [ + "bitflags 1.3.2", + "cfg_aliases", + "libc", + "parking_lot 0.11.2", + "parking_lot_core 0.8.6", + "static_init_macro", + "winapi", +] + +[[package]] +name = "static_init_macro" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70a2595fc3aa78f2d0e45dd425b22282dd863273761cc77780914b2cf3003acf" +dependencies = [ + "cfg_aliases", + "memchr", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", +] + +[[package]] +name = "stun" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7e94b1ec00bad60e6410e058b52f1c66de3dc5fe4d62d09b3e52bb7d3b73e25" +dependencies = [ + "base64 0.13.1", + "crc", + "lazy_static", + "md-5", + "rand 0.8.5", + "ring 0.16.20", + "subtle", + "thiserror", + "tokio", + "url", + "webrtc-util", +] + +[[package]] +name = "substrate-bip39" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e620c7098893ba667438b47169c00aacdd9e7c10e042250ce2b60b087ec97328" +dependencies = [ + "hmac 0.11.0", + "pbkdf2 0.8.0", + "schnorrkel", + "sha2 0.9.9", + "zeroize", +] + +[[package]] +name = "substrate-build-script-utils" +version = "3.0.0" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "platforms 2.0.0", +] + +[[package]] +name = "substrate-fixed" +version = "0.5.9" +source = "git+https://github.com/encointer/substrate-fixed#a75f3ba3f7c7893fb420500639cc055f964b1b88" +dependencies = [ + "parity-scale-codec", + "scale-info", + "serde", + "substrate-typenum", +] + +[[package]] +name = "substrate-frame-rpc-system" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "frame-system-rpc-runtime-api", + "futures", + "jsonrpsee", + "log", + "parity-scale-codec", + "sc-rpc-api", + "sc-transaction-pool-api", + "sp-api", + "sp-block-builder", + "sp-blockchain", + "sp-core", + "sp-runtime", +] + +[[package]] +name = "substrate-prometheus-endpoint" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "hyper", + "log", + "prometheus", + "thiserror", + "tokio", +] + +[[package]] +name = "substrate-rpc-client" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "async-trait", + "jsonrpsee", + "log", + "sc-rpc-api", + "serde", + "sp-runtime", +] + +[[package]] +name = "substrate-state-trie-migration-rpc" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "jsonrpsee", + "log", + "parity-scale-codec", + "sc-client-api", + "sc-rpc-api", + "scale-info", + "serde", + "sp-core", + "sp-runtime", + "sp-state-machine", + "sp-trie", + "trie-db", +] + +[[package]] +name = "substrate-test-client" +version = "2.0.1" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "array-bytes 4.2.0", + "async-trait", + "futures", + "parity-scale-codec", + "sc-client-api", + "sc-client-db", + "sc-consensus", + "sc-executor", + "sc-offchain", + "sc-service", + "serde", + "serde_json", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-keyring", + "sp-keystore", + "sp-runtime", + "sp-state-machine", +] + +[[package]] +name = "substrate-typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f0091e93c2c75b233ae39424c52cb8a662c0811fb68add149e20e5d7e8a788" +dependencies = [ + "parity-scale-codec", + "scale-info", +] + +[[package]] +name = "substrate-wasm-builder" +version = "5.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "ansi_term", + "build-helper", + "cargo_metadata", + "filetime", + "sp-maybe-compressed-blob", + "strum", + "tempfile", + "toml 0.7.8", + "walkdir", + "wasm-opt", +] + +[[package]] +name = "substring" +version = "1.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ee6433ecef213b2e72f587ef64a2f5943e7cd16fbd82dbe8bc07486c534c86" +dependencies = [ + "autocfg", +] + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "unicode-xid", +] + +[[package]] +name = "system-configuration" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "target-lexicon" +version = "0.12.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a" + +[[package]] +name = "tempfile" +version = "3.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" +dependencies = [ + "cfg-if", + "fastrand 2.0.1", + "redox_syscall 0.4.1", + "rustix 0.38.21", + "windows-sys 0.48.0", +] + +[[package]] +name = "termcolor" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "termtree" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" + +[[package]] +name = "test-runtime-constants" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "frame-support", + "polkadot-primitives", + "polkadot-runtime-common", + "smallvec", + "sp-core", + "sp-runtime", + "sp-weights", +] + +[[package]] +name = "thiserror" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "thousands" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bf63baf9f5039dadc247375c29eb13706706cfde997d0330d05aa63a77d8820" + +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + +[[package]] +name = "thrift" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b82ca8f46f95b3ce96081fe3dd89160fdea970c254bb72925255d1b62aae692e" +dependencies = [ + "byteorder", + "integer-encoding", + "log", + "ordered-float", + "threadpool", +] + +[[package]] +name = "tikv-jemalloc-ctl" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "619bfed27d807b54f7f776b9430d4f8060e66ee138a28632ca898584d462c31c" +dependencies = [ + "libc", + "paste", + "tikv-jemalloc-sys", +] + +[[package]] +name = "tikv-jemalloc-sys" +version = "0.5.4+5.3.0-patched" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "time" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" +dependencies = [ + "deranged", + "itoa", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" +dependencies = [ + "time-core", +] + +[[package]] +name = "tiny-bip39" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62cc94d358b5a1e84a5cb9109f559aa3c4d634d2b1b4de3d0fa4adc7c78e2861" +dependencies = [ + "anyhow", + "hmac 0.12.1", + "once_cell", + "pbkdf2 0.11.0", + "rand 0.8.5", + "rustc-hash", + "sha2 0.10.8", + "thiserror", + "unicode-normalization", + "wasm-bindgen", + "zeroize", +] + +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "num_cpus", + "parking_lot 0.12.1", + "pin-project-lite 0.2.13", + "signal-hook-registry", + "socket2 0.5.5", + "tokio-macros", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-macros" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "tokio-retry" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f57eb36ecbe0fc510036adff84824dd3c24bb781e21bfa67b69d556aa85214f" +dependencies = [ + "pin-project", + "rand 0.8.5", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.23.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c43ee83903113e03984cb9e5cebe6c04a5116269e900e3ddba8f068a62adda59" +dependencies = [ + "rustls 0.20.9", + "tokio", + "webpki 0.22.4", +] + +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls 0.21.8", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +dependencies = [ + "futures-core", + "pin-project-lite 0.2.13", + "tokio", + "tokio-util", +] + +[[package]] +name = "tokio-util" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" +dependencies = [ + "bytes", + "futures-core", + "futures-io", + "futures-sink", + "pin-project-lite 0.2.13", + "tokio", + "tracing", +] + +[[package]] +name = "toml" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" +dependencies = [ + "serde", +] + +[[package]] +name = "toml" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +dependencies = [ + "indexmap 2.1.0", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" +dependencies = [ + "bitflags 2.4.1", + "bytes", + "futures-core", + "futures-util", + "http", + "http-body", + "http-range-header", + "pin-project-lite 0.2.13", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "log", + "pin-project-lite 0.2.13", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "pin-project", + "tracing", +] + +[[package]] +name = "tracing-gum" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "polkadot-node-jaeger", + "polkadot-primitives", + "tracing", + "tracing-gum-proc-macro", +] + +[[package]] +name = "tracing-gum-proc-macro" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "expander 2.0.0", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "tracing-log" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6b213177105856957181934e4920de57730fc69bf42c37ee5bb664d406d9e1" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e0d2eaa99c3c2e41547cfa109e910a68ea03823cccad4a0525dcbc9b01e8c71" +dependencies = [ + "ansi_term", + "chrono", + "lazy_static", + "matchers", + "parking_lot 0.11.2", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", +] + +[[package]] +name = "trie-db" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "767abe6ffed88a1889671a102c2861ae742726f52e0a5a425b92c9fbfa7e9c85" +dependencies = [ + "hash-db", + "hashbrown 0.13.2", + "log", + "rustc-hex", + "smallvec", +] + +[[package]] +name = "trie-root" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4ed310ef5ab98f5fa467900ed906cb9232dd5376597e00fd4cba2a449d06c0b" +dependencies = [ + "hash-db", +] + +[[package]] +name = "trust-dns-proto" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f7f83d1e4a0e4358ac54c5c3681e5d7da5efc5a7a632c90bb6d6669ddd9bc26" +dependencies = [ + "async-trait", + "cfg-if", + "data-encoding", + "enum-as-inner", + "futures-channel", + "futures-io", + "futures-util", + "idna 0.2.3", + "ipnet", + "lazy_static", + "rand 0.8.5", + "smallvec", + "socket2 0.4.10", + "thiserror", + "tinyvec", + "tokio", + "tracing", + "url", +] + +[[package]] +name = "trust-dns-resolver" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aff21aa4dcefb0a1afbfac26deb0adc93888c7d295fb63ab273ef276ba2b7cfe" +dependencies = [ + "cfg-if", + "futures-util", + "ipconfig", + "lazy_static", + "lru-cache", + "parking_lot 0.12.1", + "resolv-conf", + "smallvec", + "thiserror", + "tokio", + "tracing", + "trust-dns-proto", +] + +[[package]] +name = "try-lock" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" + +[[package]] +name = "try-runtime-cli" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.43#5e49f6e44820affccaf517fd22af564f4b495d40" +dependencies = [ + "async-trait", + "clap", + "frame-remote-externalities", + "frame-try-runtime", + "hex", + "log", + "parity-scale-codec", + "sc-cli", + "sc-executor", + "sc-service", + "serde", + "serde_json", + "sp-api", + "sp-consensus-aura", + "sp-consensus-babe", + "sp-core", + "sp-debug-derive", + "sp-externalities", + "sp-inherents", + "sp-io", + "sp-keystore", + "sp-rpc", + "sp-runtime", + "sp-state-machine", + "sp-timestamp", + "sp-transaction-storage-proof", + "sp-version", + "sp-weights", + "substrate-rpc-client", + "zstd 0.12.4", +] + +[[package]] +name = "tt-call" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f195fd851901624eee5a58c4bb2b4f06399148fcd0ed336e6f1cb60a9881df" + +[[package]] +name = "turn" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4712ee30d123ec7ae26d1e1b218395a16c87cdbaf4b3925d170d684af62ea5e8" +dependencies = [ + "async-trait", + "base64 0.13.1", + "futures", + "log", + "md-5", + "rand 0.8.5", + "ring 0.16.20", + "stun", + "thiserror", + "tokio", + "webrtc-util", +] + +[[package]] +name = "twox-hash" +version = "1.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" +dependencies = [ + "cfg-if", + "digest 0.10.7", + "rand 0.8.5", + "static_assertions", +] + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "ucd-trie" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9" + +[[package]] +name = "uint" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76f64bba2c53b04fcab63c01a7d7427eadc821e3bc48c34dc9ba29c501164b52" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + +[[package]] +name = "unicode-width" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "universal-hash" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" +dependencies = [ + "generic-array 0.14.7", + "subtle", +] + +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common", + "subtle", +] + +[[package]] +name = "unsigned-varint" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6889a77d49f1f013504cec6bf97a2c730394adedaeb1deb5ea08949a50541105" +dependencies = [ + "asynchronous-codec", + "bytes", + "futures-io", + "futures-util", +] + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +dependencies = [ + "form_urlencoded", + "idna 0.4.0", + "percent-encoding", +] + +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + +[[package]] +name = "uuid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" +dependencies = [ + "getrandom 0.2.11", +] + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" + +[[package]] +name = "waitgroup" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1f50000a783467e6c0200f9d10642f4bc424e39efc1b770203e88b488f79292" +dependencies = [ + "atomic-waker", +] + +[[package]] +name = "waker-fn" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" + +[[package]] +name = "walkdir" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.39", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" + +[[package]] +name = "wasm-instrument" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa1dafb3e60065305741e83db35c6c2584bb3725b692b5b66148a38d72ace6cd" +dependencies = [ + "parity-wasm", +] + +[[package]] +name = "wasm-opt" +version = "0.112.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87fef6d0d508f08334e0ab0e6877feb4c0ecb3956bcf2cb950699b22fedf3e9c" +dependencies = [ + "anyhow", + "libc", + "strum", + "strum_macros", + "tempfile", + "thiserror", + "wasm-opt-cxx-sys", + "wasm-opt-sys", +] + +[[package]] +name = "wasm-opt-cxx-sys" +version = "0.112.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc816bbc1596c8f2e8127e137a760c798023ef3d378f2ae51f0f1840e2dfa445" +dependencies = [ + "anyhow", + "cxx", + "cxx-build", + "wasm-opt-sys", +] + +[[package]] +name = "wasm-opt-sys" +version = "0.112.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40199e4f68ef1071b3c6d0bd8026a12b481865d4b9e49c156932ea9a6234dd14" +dependencies = [ + "anyhow", + "cc", + "cxx", + "cxx-build", +] + +[[package]] +name = "wasm-timer" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" +dependencies = [ + "futures", + "js-sys", + "parking_lot 0.11.2", + "pin-utils", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "wasmi" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06c326c93fbf86419608361a2c925a31754cf109da1b8b55737070b4d6669422" +dependencies = [ + "parity-wasm", + "wasmi-validation", + "wasmi_core", +] + +[[package]] +name = "wasmi-validation" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ff416ad1ff0c42e5a926ed5d5fab74c0f098749aa0ad8b2a34b982ce0e867b" +dependencies = [ + "parity-wasm", +] + +[[package]] +name = "wasmi_core" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d20cb3c59b788653d99541c646c561c9dd26506f25c0cebfe810659c54c6d7" +dependencies = [ + "downcast-rs", + "libm", + "memory_units", + "num-rational", + "num-traits", +] + +[[package]] +name = "wasmparser" +version = "0.102.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48134de3d7598219ab9eaf6b91b15d8e50d31da76b8519fe4ecfcec2cf35104b" +dependencies = [ + "indexmap 1.9.3", + "url", +] + +[[package]] +name = "wasmtime" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f907fdead3153cb9bfb7a93bbd5b62629472dc06dee83605358c64c52ed3dda9" +dependencies = [ + "anyhow", + "bincode", + "cfg-if", + "indexmap 1.9.3", + "libc", + "log", + "object 0.30.4", + "once_cell", + "paste", + "psm", + "rayon", + "serde", + "target-lexicon", + "wasmparser", + "wasmtime-cache", + "wasmtime-cranelift", + "wasmtime-environ", + "wasmtime-jit", + "wasmtime-runtime", + "windows-sys 0.45.0", +] + +[[package]] +name = "wasmtime-asm-macros" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3b9daa7c14cd4fa3edbf69de994408d5f4b7b0959ac13fa69d465f6597f810d" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "wasmtime-cache" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c86437fa68626fe896e5afc69234bb2b5894949083586535f200385adfd71213" +dependencies = [ + "anyhow", + "base64 0.21.5", + "bincode", + "directories-next", + "file-per-thread-logger", + "log", + "rustix 0.36.17", + "serde", + "sha2 0.10.8", + "toml 0.5.11", + "windows-sys 0.45.0", + "zstd 0.11.2+zstd.1.5.2", +] + +[[package]] +name = "wasmtime-cranelift" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1cefde0cce8cb700b1b21b6298a3837dba46521affd7b8c38a9ee2c869eee04" +dependencies = [ + "anyhow", + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "cranelift-native", + "cranelift-wasm", + "gimli 0.27.3", + "log", + "object 0.30.4", + "target-lexicon", + "thiserror", + "wasmparser", + "wasmtime-cranelift-shared", + "wasmtime-environ", +] + +[[package]] +name = "wasmtime-cranelift-shared" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd041e382ef5aea1b9fc78442394f1a4f6d676ce457e7076ca4cb3f397882f8b" +dependencies = [ + "anyhow", + "cranelift-codegen", + "cranelift-native", + "gimli 0.27.3", + "object 0.30.4", + "target-lexicon", + "wasmtime-environ", +] + +[[package]] +name = "wasmtime-environ" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a990198cee4197423045235bf89d3359e69bd2ea031005f4c2d901125955c949" +dependencies = [ + "anyhow", + "cranelift-entity", + "gimli 0.27.3", + "indexmap 1.9.3", + "log", + "object 0.30.4", + "serde", + "target-lexicon", + "thiserror", + "wasmparser", + "wasmtime-types", +] + +[[package]] +name = "wasmtime-jit" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de48df552cfca1c9b750002d3e07b45772dd033b0b206d5c0968496abf31244" +dependencies = [ + "addr2line 0.19.0", + "anyhow", + "bincode", + "cfg-if", + "cpp_demangle", + "gimli 0.27.3", + "log", + "object 0.30.4", + "rustc-demangle", + "serde", + "target-lexicon", + "wasmtime-environ", + "wasmtime-jit-debug", + "wasmtime-jit-icache-coherence", + "wasmtime-runtime", + "windows-sys 0.45.0", +] + +[[package]] +name = "wasmtime-jit-debug" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e0554b84c15a27d76281d06838aed94e13a77d7bf604bbbaf548aa20eb93846" +dependencies = [ + "object 0.30.4", + "once_cell", + "rustix 0.36.17", +] + +[[package]] +name = "wasmtime-jit-icache-coherence" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aecae978b13f7f67efb23bd827373ace4578f2137ec110bbf6a4a7cde4121bbd" +dependencies = [ + "cfg-if", + "libc", + "windows-sys 0.45.0", +] + +[[package]] +name = "wasmtime-runtime" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "658cf6f325232b6760e202e5255d823da5e348fdea827eff0a2a22319000b441" +dependencies = [ + "anyhow", + "cc", + "cfg-if", + "indexmap 1.9.3", + "libc", + "log", + "mach", + "memfd", + "memoffset 0.8.0", + "paste", + "rand 0.8.5", + "rustix 0.36.17", + "wasmtime-asm-macros", + "wasmtime-environ", + "wasmtime-jit-debug", + "windows-sys 0.45.0", +] + +[[package]] +name = "wasmtime-types" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4f6fffd2a1011887d57f07654dd112791e872e3ff4a2e626aee8059ee17f06f" +dependencies = [ + "cranelift-entity", + "serde", + "thiserror", + "wasmparser", +] + +[[package]] +name = "web-sys" +version = "0.3.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki" +version = "0.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e38c0608262c46d4a56202ebabdeb094cef7e560ca7a226c6bf055188aa4ea" +dependencies = [ + "ring 0.16.20", + "untrusted 0.7.1", +] + +[[package]] +name = "webpki" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" +dependencies = [ + "ring 0.17.5", + "untrusted 0.9.0", +] + +[[package]] +name = "webpki-roots" +version = "0.22.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" +dependencies = [ + "webpki 0.22.4", +] + +[[package]] +name = "webpki-roots" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14247bb57be4f377dfb94c72830b8ce8fc6beac03cf4bf7b9732eadd414123fc" + +[[package]] +name = "webrtc" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d3bc9049bdb2cea52f5fd4f6f728184225bdb867ed0dc2410eab6df5bdd67bb" +dependencies = [ + "arc-swap", + "async-trait", + "bytes", + "hex", + "interceptor", + "lazy_static", + "log", + "rand 0.8.5", + "rcgen 0.9.3", + "regex", + "ring 0.16.20", + "rtcp", + "rtp", + "rustls 0.19.1", + "sdp", + "serde", + "serde_json", + "sha2 0.10.8", + "stun", + "thiserror", + "time", + "tokio", + "turn", + "url", + "waitgroup", + "webrtc-data", + "webrtc-dtls", + "webrtc-ice", + "webrtc-mdns", + "webrtc-media", + "webrtc-sctp", + "webrtc-srtp", + "webrtc-util", +] + +[[package]] +name = "webrtc-data" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ef36a4d12baa6e842582fe9ec16a57184ba35e1a09308307b67d43ec8883100" +dependencies = [ + "bytes", + "derive_builder", + "log", + "thiserror", + "tokio", + "webrtc-sctp", + "webrtc-util", +] + +[[package]] +name = "webrtc-dtls" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a00f4242f2db33307347bd5be53263c52a0331c96c14292118c9a6bb48d267" +dependencies = [ + "aes 0.6.0", + "aes-gcm 0.10.3", + "async-trait", + "bincode", + "block-modes", + "byteorder", + "ccm", + "curve25519-dalek 3.2.0", + "der-parser 8.2.0", + "elliptic-curve 0.12.3", + "hkdf", + "hmac 0.12.1", + "log", + "p256", + "p384", + "rand 0.8.5", + "rand_core 0.6.4", + "rcgen 0.10.0", + "ring 0.16.20", + "rustls 0.19.1", + "sec1 0.3.0", + "serde", + "sha1", + "sha2 0.10.8", + "signature 1.6.4", + "subtle", + "thiserror", + "tokio", + "webpki 0.21.4", + "webrtc-util", + "x25519-dalek 2.0.0", + "x509-parser 0.13.2", +] + +[[package]] +name = "webrtc-ice" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465a03cc11e9a7d7b4f9f99870558fe37a102b65b93f8045392fef7c67b39e80" +dependencies = [ + "arc-swap", + "async-trait", + "crc", + "log", + "rand 0.8.5", + "serde", + "serde_json", + "stun", + "thiserror", + "tokio", + "turn", + "url", + "uuid", + "waitgroup", + "webrtc-mdns", + "webrtc-util", +] + +[[package]] +name = "webrtc-mdns" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f08dfd7a6e3987e255c4dbe710dde5d94d0f0574f8a21afa95d171376c143106" +dependencies = [ + "log", + "socket2 0.4.10", + "thiserror", + "tokio", + "webrtc-util", +] + +[[package]] +name = "webrtc-media" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f72e1650a8ae006017d1a5280efb49e2610c19ccc3c0905b03b648aee9554991" +dependencies = [ + "byteorder", + "bytes", + "rand 0.8.5", + "rtp", + "thiserror", +] + +[[package]] +name = "webrtc-sctp" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d47adcd9427eb3ede33d5a7f3424038f63c965491beafcc20bc650a2f6679c0" +dependencies = [ + "arc-swap", + "async-trait", + "bytes", + "crc", + "log", + "rand 0.8.5", + "thiserror", + "tokio", + "webrtc-util", +] + +[[package]] +name = "webrtc-srtp" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6183edc4c1c6c0175f8812eefdce84dfa0aea9c3ece71c2bf6ddd3c964de3da5" +dependencies = [ + "aead 0.4.3", + "aes 0.7.5", + "aes-gcm 0.9.4", + "async-trait", + "byteorder", + "bytes", + "ctr 0.8.0", + "hmac 0.11.0", + "log", + "rtcp", + "rtp", + "sha-1", + "subtle", + "thiserror", + "tokio", + "webrtc-util", +] + +[[package]] +name = "webrtc-util" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93f1db1727772c05cf7a2cfece52c3aca8045ca1e176cd517d323489aa3c6d87" +dependencies = [ + "async-trait", + "bitflags 1.3.2", + "bytes", + "cc", + "ipnet", + "lazy_static", + "libc", + "log", + "nix", + "rand 0.8.5", + "thiserror", + "tokio", + "winapi", +] + +[[package]] +name = "westend-runtime" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "bitvec", + "frame-benchmarking", + "frame-election-provider-support", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal 0.4.1", + "log", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", + "pallet-bags-list", + "pallet-balances", + "pallet-collective", + "pallet-democracy", + "pallet-election-provider-multi-phase", + "pallet-election-provider-support-benchmarking", + "pallet-elections-phragmen", + "pallet-fast-unstake", + "pallet-grandpa", + "pallet-identity", + "pallet-im-online", + "pallet-indices", + "pallet-membership", + "pallet-message-queue", + "pallet-multisig", + "pallet-nomination-pools", + "pallet-nomination-pools-benchmarking", + "pallet-nomination-pools-runtime-api", + "pallet-offences", + "pallet-offences-benchmarking", + "pallet-preimage", + "pallet-proxy", + "pallet-recovery", + "pallet-scheduler", + "pallet-session", + "pallet-session-benchmarking", + "pallet-society", + "pallet-staking", + "pallet-staking-reward-curve", + "pallet-staking-runtime-api", + "pallet-state-trie-migration", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-treasury", + "pallet-utility", + "pallet-vesting", + "pallet-xcm", + "pallet-xcm-benchmarks", + "parity-scale-codec", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "rustc-hex", + "scale-info", + "serde", + "serde_derive", + "smallvec", + "sp-api", + "sp-authority-discovery", + "sp-block-builder", + "sp-consensus-babe", + "sp-consensus-beefy", + "sp-core", + "sp-inherents", + "sp-io", + "sp-mmr-primitives", + "sp-npos-elections", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", + "westend-runtime-constants", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "westend-runtime-constants" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "frame-support", + "polkadot-primitives", + "polkadot-runtime-common", + "smallvec", + "sp-core", + "sp-runtime", + "sp-weights", +] + +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix 0.38.21", +] + +[[package]] +name = "wide" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c68938b57b33da363195412cfc5fc37c9ed49aa9cfe2156fde64b8d2c9498242" +dependencies = [ + "bytemuck", + "safe_arch", +] + +[[package]] +name = "widestring" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" +dependencies = [ + "windows-core", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-core" +version = "0.51.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +dependencies = [ + "windows-targets 0.48.5", +] + +[[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.5", +] + +[[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", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "winnow" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b" +dependencies = [ + "memchr", +] + +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "x25519-dalek" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a0c105152107e3b96f6a00a65e86ce82d9b125230e1c4302940eca58ff71f4f" +dependencies = [ + "curve25519-dalek 3.2.0", + "rand_core 0.5.1", + "zeroize", +] + +[[package]] +name = "x25519-dalek" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb66477291e7e8d2b0ff1bcb900bf29489a9692816d79874bea351e7a8b6de96" +dependencies = [ + "curve25519-dalek 4.1.1", + "rand_core 0.6.4", + "serde", + "zeroize", +] + +[[package]] +name = "x509-parser" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb9bace5b5589ffead1afb76e43e34cff39cd0f3ce7e170ae0c29e53b88eb1c" +dependencies = [ + "asn1-rs 0.3.1", + "base64 0.13.1", + "data-encoding", + "der-parser 7.0.0", + "lazy_static", + "nom", + "oid-registry 0.4.0", + "ring 0.16.20", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "x509-parser" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0ecbeb7b67ce215e40e3cc7f2ff902f94a223acf44995934763467e7b1febc8" +dependencies = [ + "asn1-rs 0.5.2", + "base64 0.13.1", + "data-encoding", + "der-parser 8.2.0", + "lazy_static", + "nom", + "oid-registry 0.6.1", + "rusticata-macros", + "thiserror", + "time", +] + +[[package]] +name = "xcm" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "bounded-collections", + "derivative", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "scale-info", + "serde", + "sp-weights", + "xcm-procedural", +] + +[[package]] +name = "xcm-builder" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "log", + "pallet-transaction-payment", + "parity-scale-codec", + "polkadot-parachain", + "scale-info", + "sp-arithmetic", + "sp-io", + "sp-runtime", + "sp-std", + "sp-weights", + "xcm", + "xcm-executor", +] + +[[package]] +name = "xcm-emulator" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v0.9.430#64c2fb8a60fde6ca90f140a88d17120e0fa180b2" +dependencies = [ + "casey", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-test-relay-sproof-builder", + "cumulus-test-service", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "pallet-message-queue", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "paste", + "polkadot-primitives", + "polkadot-runtime-parachains", + "quote", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-std", + "sp-trie", + "xcm", + "xcm-executor", +] + +[[package]] +name = "xcm-executor" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "environmental", + "frame-benchmarking", + "frame-support", + "impl-trait-for-tuples", + "log", + "parity-scale-codec", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "sp-weights", + "xcm", +] + +[[package]] +name = "xcm-procedural" +version = "0.9.43" +source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.43#ba42b9ce51d25bdaf52d2c61e0763a6e3da50d25" +dependencies = [ + "Inflector", + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "yamux" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d9ba232399af1783a58d8eb26f6b5006fbefe2dc9ef36bd283324792d03ea5" +dependencies = [ + "futures", + "log", + "nohash-hasher", + "parking_lot 0.12.1", + "rand 0.8.5", + "static_assertions", +] + +[[package]] +name = "yasna" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" +dependencies = [ + "time", +] + +[[package]] +name = "zerocopy" +version = "0.7.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8cd369a67c0edfef15010f980c3cbe45d7f651deac2cd67ce097cd801de16557" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2f140bda219a26ccc0cdb03dba58af72590c53b22642577d88a927bc5c87d6b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "zeroize" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + +[[package]] +name = "zstd" +version = "0.11.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +dependencies = [ + "zstd-safe 5.0.2+zstd.1.5.2", +] + +[[package]] +name = "zstd" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" +dependencies = [ + "zstd-safe 6.0.6", +] + +[[package]] +name = "zstd-safe" +version = "5.0.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-safe" +version = "6.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.9+zstd.1.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e16efa8a874a0481a574084d34cc26fdb3b99627480f785888deb6386506656" +dependencies = [ + "cc", + "pkg-config", +] From f76ad0ee00c21cdead4c26f1a18c49b43e147c4a Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 9 Nov 2023 11:17:25 +0100 Subject: [PATCH 013/212] dmp fix --- integration-tests/src/tests/basic_comms.rs | 4 ++-- integration-tests/src/tests/mod.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/integration-tests/src/tests/basic_comms.rs b/integration-tests/src/tests/basic_comms.rs index 19e62e1c0..2e0f82228 100644 --- a/integration-tests/src/tests/basic_comms.rs +++ b/integration-tests/src/tests/basic_comms.rs @@ -9,7 +9,7 @@ fn dmp() { remark: "Hello from Polkadot!".as_bytes().to_vec(), }); let sudo_origin = PolkadotOrigin::root(); - let para_id = 3344; + let para_id = Polimec::para_id(); let xcm = VersionedXcm::from(Xcm(vec![ UnpaidExecution { weight_limit: Unlimited, check_origin: None }, Transact { @@ -20,7 +20,7 @@ fn dmp() { ])); PolkadotRelay::execute_with(|| { - assert_ok!(PolkadotXcmPallet::send(sudo_origin, bx!(Parachain(para_id).into()), bx!(xcm),)); + assert_ok!(PolkadotXcmPallet::send(sudo_origin, bx!(Parachain(para_id.into()).into()), bx!(xcm),)); assert_expected_events!( PolkadotRelay, diff --git a/integration-tests/src/tests/mod.rs b/integration-tests/src/tests/mod.rs index 93a533d9c..95a8a8f84 100644 --- a/integration-tests/src/tests/mod.rs +++ b/integration-tests/src/tests/mod.rs @@ -1,4 +1,4 @@ mod basic_comms; -mod ct_migration; -mod defaults; mod reserve_backed_transfers; +mod defaults; +mod ct_migration; From 373345eeba438ddcff09d32877d979347f27aa6a Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 9 Nov 2023 11:53:12 +0100 Subject: [PATCH 014/212] formatting --- integration-tests/src/tests/basic_comms.rs | 1 - integration-tests/src/tests/ct_migration.rs | 6 -- integration-tests/src/tests/defaults.rs | 25 +------ integration-tests/src/tests/hrmp_flow.rs | 64 ----------------- integration-tests/src/tests/mod.rs | 4 +- pallets/funding/src/functions.rs | 15 ++-- pallets/funding/src/impls.rs | 8 +-- pallets/funding/src/lib.rs | 5 -- pallets/funding/src/mock.rs | 15 ++-- pallets/funding/src/tests.rs | 2 +- pallets/linear-release/src/impls.rs | 80 ++++++++++----------- pallets/xcm-executor/src/config.rs | 2 +- runtimes/README.md | 2 +- 13 files changed, 61 insertions(+), 168 deletions(-) delete mode 100644 integration-tests/src/tests/hrmp_flow.rs diff --git a/integration-tests/src/tests/basic_comms.rs b/integration-tests/src/tests/basic_comms.rs index 2e0f82228..d7ca133c6 100644 --- a/integration-tests/src/tests/basic_comms.rs +++ b/integration-tests/src/tests/basic_comms.rs @@ -31,7 +31,6 @@ fn dmp() { }); Polimec::execute_with(|| { - let events = Polimec::events(); assert_expected_events!( Polimec, vec![ diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index a768501a6..ef6e930fd 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -1,13 +1,7 @@ use crate::*; use polimec_parachain_runtime::PolimecFunding; -use std::cell::RefCell; use tests::defaults::*; -const MAX_REF_TIME: u64 = 700_000_000; -const MAX_PROOF_SIZE: u64 = 10_000; -pub const REF_TIME_THRESHOLD: u64 = 33; -pub const PROOF_SIZE_THRESHOLD: u64 = 33; - #[test] fn migration_check() { let mut inst = IntegrationInstantiator::new(None); diff --git a/integration-tests/src/tests/defaults.rs b/integration-tests/src/tests/defaults.rs index ee7a03dc8..072d4e57a 100644 --- a/integration-tests/src/tests/defaults.rs +++ b/integration-tests/src/tests/defaults.rs @@ -1,14 +1,12 @@ -use super::*; use frame_support::BoundedVec; pub use pallet_funding::instantiator::{BidParams, ContributionParams, UserToPLMCBalance, UserToUSDBalance}; use pallet_funding::{ - AcceptedFundingAsset, CurrencyMetadata, ParticipantsSize, PriceOf, ProjectMetadata, ProjectMetadataOf, TicketSize, + AcceptedFundingAsset, CurrencyMetadata, ParticipantsSize, ProjectMetadata, ProjectMetadataOf, TicketSize, }; use sp_core::H256; -use sp_runtime::traits::BlakeTwo256; use polimec_parachain_runtime::AccountId; -use sp_runtime::{traits::ConstU32, FixedPointNumber, Percent, Perquintill}; +use sp_runtime::{traits::ConstU32, FixedPointNumber, Perquintill}; pub const METADATA: &str = r#"METADATA { "whitepaper":"ipfs_url", @@ -70,24 +68,6 @@ pub fn buyer_4() -> AccountId { pub fn buyer_5() -> AccountId { Polimec::account_id_of("buyer_5") } -pub fn all_testing_accounts() -> Vec { - vec![ - issuer(), - eval_1(), - eval_2(), - eval_3(), - bidder_1(), - bidder_2(), - bidder_3(), - bidder_4(), - bidder_5(), - buyer_1(), - buyer_2(), - buyer_3(), - buyer_4(), - buyer_5(), - ] -} pub fn bounded_name() -> BoundedVec> { BoundedVec::try_from("Contribution Token TEST".as_bytes().to_vec()).unwrap() } @@ -159,7 +139,6 @@ pub fn default_contributors() -> Vec { } use crate::{Polimec, PolimecRuntime}; -use polimec_parachain_runtime::Runtime as T; #[test] fn something() { diff --git a/integration-tests/src/tests/hrmp_flow.rs b/integration-tests/src/tests/hrmp_flow.rs deleted file mode 100644 index 5d738b009..000000000 --- a/integration-tests/src/tests/hrmp_flow.rs +++ /dev/null @@ -1,64 +0,0 @@ -// use crate::*; - -// const MAX_REF_TIME: u64 = 700_000_000; -// const MAX_PROOF_SIZE: u64 = 10_000; -// pub const REF_TIME_THRESHOLD: u64 = 33; -// pub const PROOF_SIZE_THRESHOLD: u64 = 33; - -// use polkadot_runtime_parachains::{hrmp as parachain_hrmp, origin as parachains_origin, paras as parachains_paras}; - -// #[test] -// fn hrmp_notification() { -// let max_weight = Weight::from_parts(MAX_REF_TIME, MAX_PROOF_SIZE); -// let execution_dot: MultiAsset = (MultiLocation { parents: 0, interior: Here }, 1_0_000_000_000u128).into(); -// let call = polkadot_runtime::RuntimeCall::Hrmp(parachain_hrmp::Call::::hrmp_init_open_channel{ -// recipient: Polimec::para_id(), -// proposed_max_capacity: 1024, -// proposed_max_message_size: 1024 * 1024, -// }); -// // let hrmp_init_open_call = parachain_hrmp::Call::::hrmp_init_open_channel{ -// // recipient: Polimec::para_id(), -// // proposed_max_capacity: 1024, -// // proposed_max_message_size: 1024 * 1024, -// // }; -// let encoded_call = call.encode(); - -// PolkadotRelay::execute_with(||{ -// let x = parachains_paras::ParaLifecycles::::iter(); -// let y = 10; -// }); - -// let xcm = VersionedXcm::from(Xcm(vec![ -// WithdrawAsset(vec![execution_dot.clone()].into()), -// BuyExecution { fees: execution_dot.clone(), weight_limit: Unlimited }, -// Transact { origin_kind: OriginKind::Native, require_weight_at_most: max_weight, call: encoded_call.into() }, -// RefundSurplus, -// DepositAsset { -// assets: Wild(All), -// beneficiary: MultiLocation { -// parents: 0, -// interior: X1(Parachain(Penpal::para_id().into())), -// }, -// }, -// ])); - -// let penpal_sov_acc = PolkadotRelay::sovereign_account_id_of(Parachain(Penpal::para_id().into()).into()); -// PolkadotRelay::fund_accounts(vec![(penpal_sov_acc, 100_0_000_000_000u128)]); - -// Penpal::execute_with(|| { -// assert_ok!(PenpalXcmPallet::send(PenpalOrigin::root(), bx!(Penpal::parent_location().into()), bx!(xcm),)); -// println!("penpal events:"); -// dbg!(Penpal::events()) -// }); - -// PolkadotRelay::execute_with(|| { -// println!("polkadot events:"); -// dbg!(PolkadotRelay::events()); -// }); - -// Polimec::execute_with(|| { -// println!("polimec events:"); -// dbg!(Polimec::events()); -// }); - -// } diff --git a/integration-tests/src/tests/mod.rs b/integration-tests/src/tests/mod.rs index 95a8a8f84..93a533d9c 100644 --- a/integration-tests/src/tests/mod.rs +++ b/integration-tests/src/tests/mod.rs @@ -1,4 +1,4 @@ mod basic_comms; -mod reserve_backed_transfers; -mod defaults; mod ct_migration; +mod defaults; +mod reserve_backed_transfers; diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 60be780b2..6d6cc12fd 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -1903,16 +1903,10 @@ impl Pallet { ) -> DispatchResult { // * Get variables * let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; - let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; let parachain_id: u32 = project_details.parachain_id.ok_or(Error::::ImpossibleState)?.into(); let project_multilocation = ParentThen(X1(Parachain(parachain_id))); let now = >::block_number(); - let contribution_tokens_sold = project_metadata - .total_allocation_size - .0 - .saturating_add(project_metadata.total_allocation_size.1) - .saturating_sub(project_details.remaining_contribution_tokens.0) - .saturating_sub(project_details.remaining_contribution_tokens.1); + // TODO: check these values let max_weight = Weight::from_parts(700_000_000, 10_000); @@ -2038,12 +2032,13 @@ impl Pallet { MigrationReadinessCheck { holding_check: (_, CheckOutcome::AwaitingResponse), .. }, ) => { let ct_sold_as_u128: u128 = contribution_tokens_sold.try_into().map_err(|_| Error::::BadMath)?; - let expected_id = Concrete(MultiLocation { parents: 1, interior: X1(Parachain(para_id.into())) }); let assets: Vec = assets.into_inner(); let asset_1 = assets[0].clone(); - match asset_1 { - MultiAsset { id: expected_id, fun: Fungible(amount) } if amount >= ct_sold_as_u128 => { + MultiAsset { + id: Concrete(MultiLocation { parents: 1, interior: X1(Parachain(pid)) }), + fun: Fungible(amount), + } if amount >= ct_sold_as_u128 && pid == u32::from(para_id) => { migration_check.holding_check.1 = CheckOutcome::Passed; Self::deposit_event(Event::::MigrationCheckResponseAccepted { query_id, response }); }, diff --git a/pallets/funding/src/impls.rs b/pallets/funding/src/impls.rs index 4b2f2a0c5..9f1b637df 100644 --- a/pallets/funding/src/impls.rs +++ b/pallets/funding/src/impls.rs @@ -304,7 +304,7 @@ fn reward_or_slash_one_evaluation(project_id: T::ProjectIdentifier) - // TODO: This base weight and the one in all other functions below should be calculated with a benchmark let remaining = remaining_evaluations.count() as u64; - match project_details.evaluation_round_info.evaluators_outcome { + return match project_details.evaluation_round_info.evaluators_outcome { EvaluatorsOutcome::Rewarded(_) => { match Pallet::::do_evaluation_reward_payout_for( &T::PalletId::get().into_account_truncating(), @@ -321,7 +321,7 @@ fn reward_or_slash_one_evaluation(project_id: T::ProjectIdentifier) - }), }; - return Ok((base_weight.saturating_add(WeightInfoOf::::evaluation_reward_payout_for()), remaining)) + Ok((base_weight.saturating_add(WeightInfoOf::::evaluation_reward_payout_for()), remaining)) }, EvaluatorsOutcome::Slashed => { match Pallet::::do_evaluation_slash_for( @@ -339,13 +339,13 @@ fn reward_or_slash_one_evaluation(project_id: T::ProjectIdentifier) - }), }; - return Ok((base_weight.saturating_add(WeightInfoOf::::evaluation_slash_for()), remaining)) + Ok((base_weight.saturating_add(WeightInfoOf::::evaluation_slash_for()), remaining)) }, _ => { #[cfg(debug_assertions)] unreachable!("EvaluatorsOutcome should be either Slashed or Rewarded if this function is called"); #[cfg(not(debug_assertions))] - return Err(Error::::ImpossibleState.into()) + Err(Error::::ImpossibleState.into()) }, } } else { diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index fb1f5e74e..6c72fe2c2 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -173,7 +173,6 @@ #![cfg_attr(feature = "runtime-benchmarks", recursion_limit = "512")] use frame_support::{ - pallet_prelude::Weight, traits::{ tokens::{fungible, fungibles, Balance}, Randomness, @@ -181,7 +180,6 @@ use frame_support::{ BoundedVec, PalletId, }; pub use pallet::*; -use parity_scale_codec::Encode; use polkadot_parachain::primitives::Id as ParaId; use sp_arithmetic::traits::{One, Saturating}; use sp_runtime::{traits::AccountIdConversion, FixedPointNumber, FixedPointOperand, FixedU128}; @@ -1263,7 +1261,6 @@ pub mod pallet { #[cfg(all(feature = "testing-node", feature = "std"))] use frame_support::traits::{OnFinalize, OnIdle, OnInitialize, OriginTrait}; use pallet_xcm::ensure_response; - use polkadot_runtime_parachains::ensure_parachain; #[cfg(all(feature = "testing-node", feature = "std"))] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] @@ -1378,8 +1375,6 @@ pub mod pallet { pub mod xcm_executor_impl { use super::*; - use crate::ProjectStatus::FundingSuccessful; - use frame_support::pallet_prelude::Get; pub struct HrmpHandler(PhantomData); impl polimec_xcm_executor::HrmpHandler for HrmpHandler { diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index e9446ad92..f16492bff 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -18,7 +18,9 @@ //! Test environment for Funding pallet. +use super::*; use frame_support::{ + pallet_prelude::Weight, parameter_types, traits::{AsEnsureOriginWithArg, ConstU16, ConstU32, WithdrawReasons}, PalletId, @@ -35,10 +37,6 @@ use sp_runtime::{ use sp_std::collections::btree_map::BTreeMap; use system::EnsureSigned; -use crate as pallet_funding; - -use super::*; - type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; type Block = frame_system::mocking::MockBlock; @@ -65,7 +63,7 @@ frame_support::construct_runtime!( System: frame_system, RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip, Balances: pallet_balances, - FundingModule: pallet_funding, + FundingModule: crate, Vesting: pallet_linear_release, LocalAssets: pallet_assets::::{Pallet, Call, Storage, Event}, StatemintAssets: pallet_assets::::{Pallet, Call, Storage, Event, Config}, @@ -90,10 +88,7 @@ use frame_support::traits::{Everything, OriginTrait}; use frame_system::RawOrigin as SystemRawOrigin; use polkadot_parachain::primitives::Sibling; use sp_runtime::traits::Get; -use xcm_builder::{ - AccountId32Aliases, EnsureXcmOrigin, FixedWeightBounds, ParentIsPreset, SiblingParachainConvertsVia, - SignedToAccountId32, -}; +use xcm_builder::{EnsureXcmOrigin, FixedWeightBounds, ParentIsPreset, SiblingParachainConvertsVia}; use xcm_executor::traits::Convert; pub struct SignedToAccountIndex(PhantomData<(RuntimeOrigin, AccountId, Network)>); @@ -352,6 +347,7 @@ impl Config for TestRuntime { type Multiplier = Multiplier; type NativeCurrency = Balances; type PalletId = FundingPalletId; + type PolimecReceiverInfo = PolimecReceiverInfo; type PreImageLimit = ConstU32<1024>; type Price = FixedU128; type PriceProvider = ConstPriceProvider; @@ -366,7 +362,6 @@ impl Config for TestRuntime { type TreasuryAccount = TreasuryAccount; type Vesting = Vesting; type WeightInfo = weights::SubstrateWeight; - type PolimecReceiverInfo = PolimecReceiverInfo; } // Build genesis storage according to the mock runtime. diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 1d78f9fa6..f5df84eef 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -80,7 +80,7 @@ const BUYER_5: AccountId = 44; const BUYER_6: AccountId = 45; const BUYER_7: AccountId = 46; -const ASSET_UNIT: u128 = 10_u128.pow(10 as u32); +const ASSET_UNIT: u128 = 10_u128.pow(10u32); const USDT_STATEMINT_ID: crate::mock::AssetId = 1984u32; const USDT_UNIT: u128 = 10_000_000_000_u128; diff --git a/pallets/linear-release/src/impls.rs b/pallets/linear-release/src/impls.rs index 365b89a7f..b2f9a9393 100644 --- a/pallets/linear-release/src/impls.rs +++ b/pallets/linear-release/src/impls.rs @@ -257,6 +257,46 @@ impl ReleaseSchedule, ReasonOf> for Pallet { } } + fn vest( + who: AccountIdOf, + reason: ReasonOf, + ) -> Result<>::Balance, DispatchError> { + let prev_locked = T::Currency::balance_on_hold(&reason, &who); + Self::do_vest(who.clone(), reason)?; + let post_locked = T::Currency::balance_on_hold(&reason, &who); + + Ok(prev_locked.saturating_sub(post_locked)) + } + + fn add_release_schedule( + who: &T::AccountId, + locked: >::Balance, + per_block: >::Balance, + starting_block: Self::Moment, + reason: ReasonOf, + ) -> DispatchResult { + if locked.is_zero() { + return Ok(()) + } + + let vesting_schedule = VestingInfo::new(locked, per_block, starting_block); + // Check for `per_block` or `locked` of 0. + if !vesting_schedule.is_valid() { + return Err(Error::::InvalidScheduleParams.into()) + }; + + let mut schedules = Self::vesting(who, reason).unwrap_or_default(); + + // NOTE: we must push the new schedule so that `exec_action` + // will give the correct new locked amount. + ensure!(schedules.try_push(vesting_schedule).is_ok(), Error::::AtMaxVestingSchedules); + + let (schedules, _) = Self::exec_action(schedules.to_vec(), VestingAction::Passive)?; + + Self::write_vesting_schedule(who, schedules, reason)?; + Ok(()) + } + /// Adds a vesting schedule to a given account. /// /// If the account has `MaxVestingSchedules`, an Error is returned and nothing @@ -321,35 +361,6 @@ impl ReleaseSchedule, ReasonOf> for Pallet { Ok(()) } - fn add_release_schedule( - who: &T::AccountId, - locked: >::Balance, - per_block: >::Balance, - starting_block: Self::Moment, - reason: ReasonOf, - ) -> DispatchResult { - if locked.is_zero() { - return Ok(()) - } - - let vesting_schedule = VestingInfo::new(locked, per_block, starting_block); - // Check for `per_block` or `locked` of 0. - if !vesting_schedule.is_valid() { - return Err(Error::::InvalidScheduleParams.into()) - }; - - let mut schedules = Self::vesting(who, reason).unwrap_or_default(); - - // NOTE: we must push the new schedule so that `exec_action` - // will give the correct new locked amount. - ensure!(schedules.try_push(vesting_schedule).is_ok(), Error::::AtMaxVestingSchedules); - - let (schedules, _) = Self::exec_action(schedules.to_vec(), VestingAction::Passive)?; - - Self::write_vesting_schedule(who, schedules, reason)?; - Ok(()) - } - /// Remove a vesting schedule for a given account. fn remove_vesting_schedule(who: &T::AccountId, schedule_index: u32, reason: ReasonOf) -> DispatchResult { let schedules = Self::vesting(who, reason).ok_or(Error::::NotVesting)?; @@ -374,15 +385,4 @@ impl ReleaseSchedule, ReasonOf> for Pallet { Ok(()) } - - fn vest( - who: AccountIdOf, - reason: ReasonOf, - ) -> Result<>::Balance, DispatchError> { - let prev_locked = T::Currency::balance_on_hold(&reason, &who); - Self::do_vest(who.clone(), reason)?; - let post_locked = T::Currency::balance_on_hold(&reason, &who); - - Ok(prev_locked.saturating_sub(post_locked)) - } } diff --git a/pallets/xcm-executor/src/config.rs b/pallets/xcm-executor/src/config.rs index a7790f942..a50eb7ef3 100644 --- a/pallets/xcm-executor/src/config.rs +++ b/pallets/xcm-executor/src/config.rs @@ -19,7 +19,7 @@ use frame_support::{ dispatch::{Dispatchable, GetDispatchInfo, Parameter, PostDispatchInfo}, traits::{Contains, ContainsPair, Get, PalletsInfoAccess}, }; -use xcm::v3::{opaque::Instruction, prelude::*}; +use xcm::v3::prelude::*; use xcm_executor::traits::{ AssetExchange, AssetLock, CallDispatcher, ClaimAssets, ConvertOrigin, DropAssets, ExportXcm, FeeManager, OnResponse, ShouldExecute, TransactAsset, VersionChangeNotifier, WeightBounds, WeightTrader, diff --git a/runtimes/README.md b/runtimes/README.md index 7674bc34c..f1a63c0ec 100644 --- a/runtimes/README.md +++ b/runtimes/README.md @@ -8,7 +8,7 @@ In this folder, there are 3 (+1) runtimes + The "Testnet" runtime is the runtime that is used for the testnet node. -+ The "Base" runtime is the runtime that is used for the base node. It is basically the ["Substrate Cumulus Parachain Template"](https://github.com/substrate-developer-hub/substrate-parachain-template) but it includes the following extra pallets: ++ The "Base" runtime is the runtime that is used for the base node. It is basically the ["Substrate Cumulus Parachain Template"](https://github.com/substrate-developer-hub/substrate-parachain-template). It includes the following extra pallets: + `pallet_sudo` + `parachain_staking` by KILT + Useful as a starter parachain for the Polkadot/Kusama auction, then will be updated to the "Testnet" runtime. From 94f42291b31c260879897fd43fcc1d6267f51191 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 9 Nov 2023 12:49:50 +0100 Subject: [PATCH 015/212] small fixed --- pallets/polimec-receiver/README.md | 1 - pallets/xcm-executor/src/config.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 pallets/polimec-receiver/README.md diff --git a/pallets/polimec-receiver/README.md b/pallets/polimec-receiver/README.md deleted file mode 100644 index 5a6461233..000000000 --- a/pallets/polimec-receiver/README.md +++ /dev/null @@ -1 +0,0 @@ -License: Unlicense diff --git a/pallets/xcm-executor/src/config.rs b/pallets/xcm-executor/src/config.rs index a50eb7ef3..84450e4ff 100644 --- a/pallets/xcm-executor/src/config.rs +++ b/pallets/xcm-executor/src/config.rs @@ -107,6 +107,6 @@ pub trait Config { /// temporary measure until we properly account for proof size weights for XCM instructions. type SafeCallFilter: Contains; - /// Polimec's custom type for handling the `HrmpNewChannelOpenRequest` ans `HrmpChannelAccepted` instructions + /// Polimec's custom type for handling the `HrmpNewChannelOpenRequest` and `HrmpChannelAccepted` instructions type HrmpHandler: HrmpHandler; } From 6801c51fc01d6707fcdea507db0ef5d176b67558 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 9 Nov 2023 13:06:02 +0100 Subject: [PATCH 016/212] fixes --- pallets/funding/src/functions.rs | 6 +----- pallets/funding/src/lib.rs | 3 ++- pallets/funding/src/mock.rs | 3 --- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 6d6cc12fd..d16570da0 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -1982,6 +1982,7 @@ impl Pallet { ]); >::send_xcm(Here, project_multilocation, xcm).map_err(|_| Error::::XcmFailed)?; + // * Emit events * Self::deposit_event(Event::::MigrationReadinessCheckStarted { project_id, caller: caller.clone() }); Ok(()) @@ -1992,7 +1993,6 @@ impl Pallet { query_id: xcm::v3::QueryId, response: xcm::v3::Response, ) -> DispatchResult { - // * Get variables * use xcm::v3::prelude::*; // TODO: check if this is too low performance. Maybe we want a new map of query_id -> project_id let (project_id, mut project_details, mut migration_check) = ProjectsDetails::::iter() @@ -2022,10 +2022,8 @@ impl Pallet { .saturating_sub(project_details.remaining_contribution_tokens.0) .saturating_sub(project_details.remaining_contribution_tokens.1); - // * Validity checks * ensure!(project_details.parachain_id == Some(para_id), Error::::NotAllowed); - // * Update storage * match (response.clone(), migration_check) { ( Response::Assets(assets), @@ -2077,8 +2075,6 @@ impl Pallet { ensure!(caller == project_details.issuer, Error::::NotAllowed); ensure!(migration_readiness_check.is_ready(), Error::::NotAllowed); - // * Update storage * - // * Emit events * Self::deposit_event(Event::::MigrationStarted { project_id }); diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 6c72fe2c2..d8df1fdb1 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -753,7 +753,7 @@ pub mod pallet { para_id: ParaId, caller: T::AccountId, }, - /// A channel was accepted from a parachain to Polimec belonging to a project. A request has been sent to the relay for a polimec->project channel + /// A channel was accepted from a parachain to Polimec belonging to a project. A request has been sent to the relay for a Polimec->project channel HrmpChannelAccepted { project_id: T::ProjectIdentifier, para_id: ParaId, @@ -1146,6 +1146,7 @@ pub mod pallet { Self::do_start_migration_readiness_check(&caller, project_id) } + /// Called only by other chains through a query response xcm message #[pallet::call_index(23)] #[pallet::weight(Weight::from_parts(1000, 0))] pub fn migration_check_response( diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index f16492bff..585871fb7 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -83,7 +83,6 @@ pub const fn free_deposit() -> Balance { 0 * MICRO_PLMC } -//region DRAFT ZONE use frame_support::traits::{Everything, OriginTrait}; use frame_system::RawOrigin as SystemRawOrigin; use polkadot_parachain::primitives::Sibling; @@ -162,8 +161,6 @@ impl pallet_xcm::Config for TestRuntime { const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; } -//endregion - parameter_types! { pub const AssetDeposit: Balance = PLMC; // 1 UNIT deposit to create asset pub const AssetAccountDeposit: Balance = deposit(1, 16); From 258746f86ac0a5d54498d78275569ac1088e6c64 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 10 Nov 2023 09:44:51 +0100 Subject: [PATCH 017/212] save --- pallets/funding/src/functions.rs | 18 +++++++++++++++++- pallets/funding/src/lib.rs | 10 ++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index d16570da0..a85ff62f1 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -2066,7 +2066,7 @@ impl Pallet { Ok(()) } - pub fn do_migration(caller: AccountIdOf, project_id: T::ProjectIdentifier) -> DispatchResult { + pub fn do_start_migration(caller: AccountIdOf, project_id: T::ProjectIdentifier) -> DispatchResult { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let migration_readiness_check = project_details.migration_readiness_check.ok_or(Error::::NotAllowed)?; @@ -2080,6 +2080,22 @@ impl Pallet { Ok(()) } + + pub fn do_one_migration(caller: AccountIdOf, project_id: T::ProjectIdentifier, participant: AccountIdOf) -> DispatchResult { + // * Get variables * + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; + let migration_readiness_check = project_details.migration_readiness_check.ok_or(Error::::NotAllowed)?; + let maybe_bids = Bids::::iter_prefix_values((project_id, participant)); + let maybe_contributions = Contributions::::iter_prefix_values((project_id, participant)); + + // * Validity Checks * + ensure!(migration_readiness_check.is_ready(), Error::::NotAllowed); + + // * Update storage * + + + // * Emit events * + } } // Helper functions diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index d8df1fdb1..4646d0788 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1158,6 +1158,16 @@ pub mod pallet { Self::do_migration_check_response(location, query_id, response) } + + #[pallet::call_index(24)] + #[pallet::weight(Weight::from_part(1000, 0))] + pub fn start_migration( + origin: OriginFor, + project_id: T::ProjectIdentifier, + ) -> DispatchResult { + let caller = ensure_signed(origin)?; + Self::do_start_migration(&caller, project_id) + } } #[pallet::hooks] From 483dd10faff5f16ea96bfd1824ccfc2c75340b52 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 10 Nov 2023 15:49:22 +0100 Subject: [PATCH 018/212] compiling, unit converion to map --- pallets/funding/src/functions.rs | 41 +++++++++++++-------- pallets/funding/src/lib.rs | 38 ++++++++++--------- pallets/funding/src/traits.rs | 2 +- pallets/funding/src/types.rs | 2 +- pallets/parachain-staking/src/benchmarks.rs | 2 +- pallets/parachain-staking/src/lib.rs | 6 +-- 6 files changed, 52 insertions(+), 39 deletions(-) diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index a85ff62f1..83dedd3f2 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -2066,15 +2066,17 @@ impl Pallet { Ok(()) } - pub fn do_start_migration(caller: AccountIdOf, project_id: T::ProjectIdentifier) -> DispatchResult { + pub fn do_start_migration(caller: &AccountIdOf, project_id: T::ProjectIdentifier) -> DispatchResult { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let migration_readiness_check = project_details.migration_readiness_check.ok_or(Error::::NotAllowed)?; // * Validity Checks * - ensure!(caller == project_details.issuer, Error::::NotAllowed); + ensure!(caller.clone() == project_details.issuer, Error::::NotAllowed); ensure!(migration_readiness_check.is_ready(), Error::::NotAllowed); + // Start automated migration process + // * Emit events * Self::deposit_event(Event::::MigrationStarted { project_id }); @@ -2085,14 +2087,23 @@ impl Pallet { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let migration_readiness_check = project_details.migration_readiness_check.ok_or(Error::::NotAllowed)?; - let maybe_bids = Bids::::iter_prefix_values((project_id, participant)); - let maybe_contributions = Contributions::::iter_prefix_values((project_id, participant)); + let evaluations = Bids::::iter_prefix_values((project_id, participant.clone())); + let bids = Bids::::iter_prefix_values((project_id, participant.clone())); + let contributions = Contributions::::iter_prefix_values((project_id, participant.clone())); + let available_contribution_tokens = T::ContributionTokenCurrency::balance(project_id, &participant.clone()); // * Validity Checks * ensure!(migration_readiness_check.is_ready(), Error::::NotAllowed); - // * Update storage * + // * Process Data * + let mut migrations: Vec<(u128, u32)> = Vec::new(); + for contribution in contributions { + let multiplier = contribution.multiplier.calculate_vesting_duration::(); + let multiplier_local = ::BlockNumber::from(multiplier); + migrations.push((contribution.ct_amount.into(), multiplier_local.into())) + } + Ok(()) // * Emit events * } @@ -2110,7 +2121,7 @@ impl Pallet { } /// Adds a project to the ProjectsToUpdate storage, so it can be updated at some later point in time. - pub fn add_to_update_store(block_number: T::BlockNumber, store: (&T::ProjectIdentifier, UpdateType)) { + pub fn add_to_update_store(block_number: ::BlockNumber, store: (&T::ProjectIdentifier, UpdateType)) { // Try to get the project into the earliest possible block to update. // There is a limit for how many projects can update each block, so we need to make sure we don't exceed that limit let mut block_number = block_number; @@ -2166,9 +2177,9 @@ impl Pallet { _caller: &AccountIdOf, multiplier: MultiplierOf, bonded_amount: BalanceOf, - ) -> Result>, DispatchError> { + ) -> Result::BlockNumber, BalanceOf>, DispatchError> { // TODO: duration should depend on `_multiplier` and `_caller` credential - let duration: T::BlockNumber = multiplier.calculate_vesting_duration::(); + let duration: ::BlockNumber = multiplier.calculate_vesting_duration::(); let duration_as_balance = T::BlockNumberToBalance::convert(duration); let amount_per_block = if duration_as_balance == Zero::zero() { bonded_amount @@ -2182,7 +2193,7 @@ impl Pallet { /// Calculates the price (in USD) of contribution tokens for the Community and Remainder Rounds pub fn calculate_weighted_average_price( project_id: T::ProjectIdentifier, - end_block: T::BlockNumber, + end_block: ::BlockNumber, total_allocation_size: BalanceOf, ) -> DispatchResult { // Get all the bids that were made before the end of the candle @@ -2401,12 +2412,12 @@ impl Pallet { } pub fn select_random_block( - candle_starting_block: T::BlockNumber, - candle_ending_block: T::BlockNumber, - ) -> T::BlockNumber { + candle_starting_block: ::BlockNumber, + candle_ending_block: ::BlockNumber, + ) -> ::BlockNumber { let nonce = Self::get_and_increment_nonce(); let (random_value, _known_since) = T::Randomness::random(&nonce); - let random_block = ::decode(&mut random_value.as_ref()) + let random_block = <::BlockNumber>::decode(&mut random_value.as_ref()) .expect("secure hashes should always be bigger than the block number; qed"); let block_range = candle_ending_block - candle_starting_block; @@ -2581,7 +2592,7 @@ impl Pallet { project_id: T::ProjectIdentifier, mut project_details: ProjectDetailsOf, reason: SuccessReason, - settlement_delta: T::BlockNumber, + settlement_delta: ::BlockNumber, ) -> DispatchResult { let now = >::block_number(); project_details.status = ProjectStatus::FundingSuccessful; @@ -2598,7 +2609,7 @@ impl Pallet { project_id: T::ProjectIdentifier, mut project_details: ProjectDetailsOf, reason: FailureReason, - settlement_delta: T::BlockNumber, + settlement_delta: ::BlockNumber, ) -> DispatchResult { let now = >::block_number(); project_details.status = ProjectStatus::FundingFailed; diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 4646d0788..acfe41815 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -276,6 +276,8 @@ pub mod pallet { + Parameter + Member; + type BlockNumber: IsType<::BlockNumber> + Into; + type RuntimeOrigin: IsType<::RuntimeOrigin> + Into::RuntimeOrigin>>; @@ -296,7 +298,7 @@ pub mod pallet { + MaybeSerializeDeserialize; /// The inner balance type we will use for all of our outer currency types. (e.g native, funding, CTs) - type Balance: Balance + From + FixedPointOperand + MaybeSerializeDeserialize; + type Balance: Balance + From + FixedPointOperand + MaybeSerializeDeserialize + Into; /// Represents the value of something in USD type Price: FixedPointNumber + Parameter + Copy + MaxEncodedLen + MaybeSerializeDeserialize; @@ -326,7 +328,7 @@ pub mod pallet { type PriceProvider: ProvideStatemintPrice; /// Something that provides randomness in the runtime. - type Randomness: Randomness; + type Randomness: Randomness::BlockNumber>; /// The maximum length of data stored on-chain. #[pallet::constant] @@ -338,27 +340,27 @@ pub mod pallet { /// The length (expressed in number of blocks) of the evaluation period. #[pallet::constant] - type EvaluationDuration: Get; + type EvaluationDuration: Get<::BlockNumber>; /// The time window (expressed in number of blocks) that an issuer has to start the auction round. #[pallet::constant] - type AuctionInitializePeriodDuration: Get; + type AuctionInitializePeriodDuration: Get<::BlockNumber>; /// The length (expressed in number of blocks) of the Auction Round, English period. #[pallet::constant] - type EnglishAuctionDuration: Get; + type EnglishAuctionDuration: Get<::BlockNumber>; /// The length (expressed in number of blocks) of the Auction Round, Candle period. #[pallet::constant] - type CandleAuctionDuration: Get; + type CandleAuctionDuration: Get<::BlockNumber>; /// The length (expressed in number of blocks) of the Community Round. #[pallet::constant] - type CommunityFundingDuration: Get; + type CommunityFundingDuration: Get<::BlockNumber>; /// The length (expressed in number of blocks) of the Remainder Round. #[pallet::constant] - type RemainderFundingDuration: Get; + type RemainderFundingDuration: Get<::BlockNumber>; /// `PalletId` for the funding pallet. An appropriate value could be /// `PalletId(*b"py/cfund")` @@ -398,9 +400,9 @@ pub mod pallet { Moment = BlockNumberOf, >; /// For now we expect 3 days until the project is automatically accepted. Timeline decided by MiCA regulations. - type ManualAcceptanceDuration: Get; + type ManualAcceptanceDuration: Get<::BlockNumber>; /// For now we expect 4 days from acceptance to settlement due to MiCA regulations. - type SuccessToSettlementTime: Get; + type SuccessToSettlementTime: Get<::BlockNumber>; type EvaluatorSlash: Get; @@ -469,7 +471,7 @@ pub mod pallet { pub type ProjectsToUpdate = StorageMap< _, Blake2_128Concat, - T::BlockNumber, + ::BlockNumber, BoundedVec<(T::ProjectIdentifier, UpdateType), T::MaxProjectsToUpdatePerBlock>, ValueQuery, >; @@ -536,18 +538,18 @@ pub mod pallet { /// The period an issuer has to start the auction phase of the project. AuctionInitializePeriod { project_id: T::ProjectIdentifier, - start_block: T::BlockNumber, - end_block: T::BlockNumber, + start_block: ::BlockNumber, + end_block: ::BlockNumber, }, /// The auction round of a project started. EnglishAuctionStarted { project_id: T::ProjectIdentifier, - when: T::BlockNumber, + when: ::BlockNumber, }, /// The candle auction part of the auction started for a project CandleAuctionStarted { project_id: T::ProjectIdentifier, - when: T::BlockNumber, + when: ::BlockNumber, }, /// The auction round of a project ended. AuctionFailed { @@ -1160,7 +1162,7 @@ pub mod pallet { } #[pallet::call_index(24)] - #[pallet::weight(Weight::from_part(1000, 0))] + #[pallet::weight(Weight::from_parts(1000, 0))] pub fn start_migration( origin: OriginFor, project_id: T::ProjectIdentifier, @@ -1172,7 +1174,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(now: T::BlockNumber) -> Weight { + fn on_initialize(now: ::BlockNumber) -> Weight { // Get the projects that need to be updated on this block and update them for (project_id, update_type) in ProjectsToUpdate::::take(now) { match update_type { @@ -1223,7 +1225,7 @@ pub mod pallet { Weight::from_parts(0, 0) } - fn on_idle(_now: T::BlockNumber, max_weight: Weight) -> Weight { + fn on_idle(_now: ::BlockNumber, max_weight: Weight) -> Weight { let mut remaining_weight = max_weight; let projects_needing_cleanup = ProjectsDetails::::iter() diff --git a/pallets/funding/src/traits.rs b/pallets/funding/src/traits.rs index 6bffe24a6..8e5fa41c5 100644 --- a/pallets/funding/src/traits.rs +++ b/pallets/funding/src/traits.rs @@ -8,7 +8,7 @@ pub trait BondingRequirementCalculation { } pub trait VestingDurationCalculation { - fn calculate_vesting_duration(&self) -> T::BlockNumber; + fn calculate_vesting_duration(&self) -> ::BlockNumber; } pub trait ProvideStatemintPrice { diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index 75116ff7e..70d908d3f 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -69,7 +69,7 @@ pub mod config_types { } impl VestingDurationCalculation for Multiplier { - fn calculate_vesting_duration(&self) -> T::BlockNumber { + fn calculate_vesting_duration(&self) -> ::BlockNumber { // gradient "m" of the linear curve function y = m*x + b where x is the multiplier and y is the number of weeks const GRADIENT: FixedU128 = FixedU128::from_rational(2167u128, 1000u128); // negative constant (because we cannot have negative values, so we take the negative and do "-b" instead of "+b") "b" of the linear curve function y = m*x + b diff --git a/pallets/parachain-staking/src/benchmarks.rs b/pallets/parachain-staking/src/benchmarks.rs index 9380f521c..3af2bb50a 100644 --- a/pallets/parachain-staking/src/benchmarks.rs +++ b/pallets/parachain-staking/src/benchmarks.rs @@ -96,7 +96,7 @@ fn parachain_staking_on_finalize(author: T::AccountId) { /// Run to end block and author fn roll_to_and_author(round_delay: u32, author: T::AccountId) { let total_rounds = round_delay + 1u32; - let round_length: T::BlockNumber = Pallet::::round().length.into(); + let round_length: ::BlockNumber = Pallet::::round().length.into(); let mut now = >::block_number() + 1u32.into(); let end = Pallet::::round().first + (round_length * total_rounds.into()); while now < end { diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index b787a8577..472dac11c 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -235,7 +235,7 @@ pub mod pallet { pub enum Event { /// Started new round. NewRound { - starting_block: T::BlockNumber, + starting_block: ::BlockNumber, round: RoundIndex, selected_collators_number: u32, total_balance: BalanceOf, @@ -424,7 +424,7 @@ pub mod pallet { /// Set blocks per round BlocksPerRoundSet { current_round: RoundIndex, - first_block: T::BlockNumber, + first_block: ::BlockNumber, old: u32, new: u32, new_per_round_inflation_min: Perbill, @@ -447,7 +447,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(n: ::BlockNumber) -> Weight { let mut weight = T::WeightInfo::base_on_initialize(); let mut round = >::get(); From 3c22edadc5fe3aa0ac005e9ff66812a410ef3809 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 13 Nov 2023 11:47:47 +0100 Subject: [PATCH 019/212] revert staking changes --- pallets/parachain-staking/src/benchmarks.rs | 2 +- pallets/parachain-staking/src/lib.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pallets/parachain-staking/src/benchmarks.rs b/pallets/parachain-staking/src/benchmarks.rs index 3af2bb50a..9380f521c 100644 --- a/pallets/parachain-staking/src/benchmarks.rs +++ b/pallets/parachain-staking/src/benchmarks.rs @@ -96,7 +96,7 @@ fn parachain_staking_on_finalize(author: T::AccountId) { /// Run to end block and author fn roll_to_and_author(round_delay: u32, author: T::AccountId) { let total_rounds = round_delay + 1u32; - let round_length: ::BlockNumber = Pallet::::round().length.into(); + let round_length: T::BlockNumber = Pallet::::round().length.into(); let mut now = >::block_number() + 1u32.into(); let end = Pallet::::round().first + (round_length * total_rounds.into()); while now < end { diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index 472dac11c..b787a8577 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -235,7 +235,7 @@ pub mod pallet { pub enum Event { /// Started new round. NewRound { - starting_block: ::BlockNumber, + starting_block: T::BlockNumber, round: RoundIndex, selected_collators_number: u32, total_balance: BalanceOf, @@ -424,7 +424,7 @@ pub mod pallet { /// Set blocks per round BlocksPerRoundSet { current_round: RoundIndex, - first_block: ::BlockNumber, + first_block: T::BlockNumber, old: u32, new: u32, new_per_round_inflation_min: Perbill, @@ -447,7 +447,7 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_initialize(n: ::BlockNumber) -> Weight { + fn on_initialize(n: T::BlockNumber) -> Weight { let mut weight = T::WeightInfo::base_on_initialize(); let mut round = >::get(); From 308b95570ea05fbdece471d03464843753725130 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 13 Nov 2023 12:41:42 +0100 Subject: [PATCH 020/212] saving now evaluation reward and move to u64 for migration --- pallets/funding/src/benchmarking.rs | 6 +-- pallets/funding/src/functions.rs | 41 +++++++++++++------ pallets/funding/src/impls.rs | 4 +- pallets/funding/src/instantiator.rs | 4 +- pallets/funding/src/lib.rs | 5 ++- pallets/funding/src/mock.rs | 61 +++++++++++++++-------------- pallets/funding/src/types.rs | 9 ++++- runtimes/testnet/src/lib.rs | 59 ++++++++++++++-------------- 8 files changed, 109 insertions(+), 80 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index ad61ac779..bae3ec2d1 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -334,7 +334,7 @@ mod benchmarks { evaluator == test_evaluator.clone() && original_plmc_bond == plmc_for_evaluating[0].plmc_amount && current_plmc_bond == plmc_for_evaluating[0].plmc_amount && - !rewarded_or_slashed => {}, + rewarded_or_slashed.is_some() => {}, _ => assert!(false, "Evaluation is not stored correctly"), } @@ -721,7 +721,7 @@ mod benchmarks { // Storage let stored_evaluation = Evaluations::::get((project_id, evaluator.clone(), evaluation_to_unbond.id)).unwrap(); - assert!(stored_evaluation.rewarded_or_slashed); + assert!(stored_evaluation.rewarded_or_slashed.is_some()); let slashed_amount = T::EvaluatorSlash::get() * evaluation_to_unbond.original_plmc_bond; let current_plmc_bond = evaluation_to_unbond.current_plmc_bond.saturating_sub(slashed_amount); assert_eq!(stored_evaluation.current_plmc_bond, current_plmc_bond); @@ -790,7 +790,7 @@ mod benchmarks { // Storage let stored_evaluation = Evaluations::::get((project_id, evaluator.clone(), evaluation_to_unbond.id)).unwrap(); - assert!(stored_evaluation.rewarded_or_slashed); + assert!(stored_evaluation.rewarded_or_slashed.is_some()); // Balances let project_details = ProjectsDetails::::get(project_id).unwrap(); diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 83dedd3f2..c6d3b8607 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -38,6 +38,7 @@ use sp_std::marker::PhantomData; use crate::ProjectStatus::FundingSuccessful; use polimec_traits::ReleaseSchedule; +use crate::Call::start_bid_vesting_schedule_for; use crate::traits::{BondingRequirementCalculation, ProvideStatemintPrice, VestingDurationCalculation}; @@ -781,7 +782,7 @@ impl Pallet { early_usd_amount, late_usd_amount, when: now, - rewarded_or_slashed: false, + rewarded_or_slashed: None, }; // * Update Storage * @@ -1266,7 +1267,7 @@ impl Pallet { // * Validity checks * ensure!( (project_details.evaluation_round_info.evaluators_outcome == EvaluatorsOutcomeOf::::Unchanged || - released_evaluation.rewarded_or_slashed) && + released_evaluation.rewarded_or_slashed.is_some()) && matches!( project_details.status, ProjectStatus::EvaluationFailed | ProjectStatus::FundingFailed | ProjectStatus::FundingSuccessful @@ -1313,7 +1314,7 @@ impl Pallet { // * Validity checks * ensure!( - !evaluation.rewarded_or_slashed && matches!(project_details.status, ProjectStatus::FundingSuccessful), + evaluation.rewarded_or_slashed.is_none() && matches!(project_details.status, ProjectStatus::FundingSuccessful), Error::::NotAllowed ); @@ -1329,7 +1330,7 @@ impl Pallet { let total_reward_amount = early_evaluators_rewards.saturating_add(normal_evaluators_rewards); // * Update storage * T::ContributionTokenCurrency::mint_into(project_id, &evaluation.evaluator, total_reward_amount)?; - evaluation.rewarded_or_slashed = true; + evaluation.rewarded_or_slashed = Some(RewardOrSlash::Reward(total_reward_amount)); Evaluations::::insert((project_id, evaluator, evaluation_id), evaluation); // * Emit events * @@ -1360,7 +1361,7 @@ impl Pallet { // * Validity checks * ensure!( - !evaluation.rewarded_or_slashed && + evaluation.rewarded_or_slashed.is_none() && matches!(project_details.evaluation_round_info.evaluators_outcome, EvaluatorsOutcome::Slashed), Error::::NotAllowed ); @@ -1370,7 +1371,7 @@ impl Pallet { let slashed_amount = slash_percentage * evaluation.original_plmc_bond; // * Update storage * - evaluation.rewarded_or_slashed = true; + evaluation.rewarded_or_slashed = Some(RewardOrSlash::Slash(slashed_amount)); T::NativeCurrency::transfer_on_hold( &LockType::Evaluation(project_id), @@ -2087,7 +2088,7 @@ impl Pallet { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let migration_readiness_check = project_details.migration_readiness_check.ok_or(Error::::NotAllowed)?; - let evaluations = Bids::::iter_prefix_values((project_id, participant.clone())); + let evaluations = Evaluations::::iter_prefix_values((project_id, participant.clone())); let bids = Bids::::iter_prefix_values((project_id, participant.clone())); let contributions = Contributions::::iter_prefix_values((project_id, participant.clone())); let available_contribution_tokens = T::ContributionTokenCurrency::balance(project_id, &participant.clone()); @@ -2096,12 +2097,28 @@ impl Pallet { ensure!(migration_readiness_check.is_ready(), Error::::NotAllowed); // * Process Data * - let mut migrations: Vec<(u128, u32)> = Vec::new(); - for contribution in contributions { - let multiplier = contribution.multiplier.calculate_vesting_duration::(); - let multiplier_local = ::BlockNumber::from(multiplier); - migrations.push((contribution.ct_amount.into(), multiplier_local.into())) + // u128 is a balance, u64 is now a BlockNumber, but will be a Moment/Timestamp in the future + let mut migrations: Vec<(u128, u64)> = Vec::new(); + let mut evaluation_ct_amount = available_contribution_tokens; + for evaluation in evaluations { + if let Some(RewardOrSlash::Reward(ct_amount)) = evaluation.rewarded_or_slashed { + let multiplier = MultiplierOf::::try_from(1u8).map_err(|_| Error::::BadConversion)?; + let vesting_duration = multiplier.calculate_vesting_duration::(); + } + } + for contribution in contributions { + let vesting_duration = contribution.multiplier.calculate_vesting_duration::(); + let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); + migrations.push((contribution.ct_amount.into(), vesting_duration_local_type.into())); + evaluation_ct_amount -= contribution.ct_amount; + } + for bid in bids { + let vesting_duration = bid.multiplier.calculate_vesting_duration::(); + let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); + migrations.push((bid.final_ct_amount.into(), vesting_duration_local_type.into())); + evaluation_ct_amount -= bid.final_ct_amount; + } Ok(()) diff --git a/pallets/funding/src/impls.rs b/pallets/funding/src/impls.rs index 9f1b637df..cddb97c92 100644 --- a/pallets/funding/src/impls.rs +++ b/pallets/funding/src/impls.rs @@ -244,7 +244,7 @@ fn remaining_evaluators_to_reward_or_slash( if outcome == EvaluatorsOutcomeOf::::Unchanged { 0u64 } else { - Evaluations::::iter_prefix_values((project_id,)).filter(|evaluation| !evaluation.rewarded_or_slashed).count() + Evaluations::::iter_prefix_values((project_id,)).filter(|evaluation| evaluation.rewarded_or_slashed.is_none()).count() as u64 } } @@ -297,7 +297,7 @@ fn remaining_contributions_without_issuer_payout(project_id: T::Proje fn reward_or_slash_one_evaluation(project_id: T::ProjectIdentifier) -> Result<(Weight, u64), DispatchError> { let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectNotFound)?; let project_evaluations = Evaluations::::iter_prefix_values((project_id,)); - let mut remaining_evaluations = project_evaluations.filter(|evaluation| !evaluation.rewarded_or_slashed); + let mut remaining_evaluations = project_evaluations.filter(|evaluation| evaluation.rewarded_or_slashed.is_none()); let base_weight = Weight::from_parts(10_000_000, 0); if let Some(evaluation) = remaining_evaluations.next() { diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 781bea056..f2f253a48 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -791,7 +791,7 @@ impl< let early_evaluators_rewards = early_reward_weight * reward_info.early_evaluator_reward_pot; let normal_evaluators_rewards = normal_reward_weight * reward_info.normal_evaluator_reward_pot; let total_reward_amount = early_evaluators_rewards.saturating_add(normal_evaluators_rewards); - total_reward_amount.into() + total_reward_amount } } @@ -1359,7 +1359,7 @@ impl ExistentialDeposits for Vec Vec> { self.iter() .map(|x| { - UserToPLMCBalance::new(x.clone(), ::ExistentialDeposit::get().into()) + UserToPLMCBalance::new(x.clone(), ::ExistentialDeposit::get()) }) .collect::>() } diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index acfe41815..f9887b5fa 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -276,7 +276,8 @@ pub mod pallet { + Parameter + Member; - type BlockNumber: IsType<::BlockNumber> + Into; + // TODO: our local BlockNumber should be removed once we move onto using Moment for time tracking + type BlockNumber: IsType<::BlockNumber> + Into; type RuntimeOrigin: IsType<::RuntimeOrigin> + Into::RuntimeOrigin>>; @@ -876,6 +877,8 @@ pub mod pallet { /// Tried to start a migration check but the bidirectional channel is not yet open CommsNotEstablished, XcmFailed, + // Tried to convert one type into another and failed. i.e try_into failed + BadConversion } #[pallet::call] diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 585871fb7..c8a02174c 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -321,44 +321,45 @@ impl pallet_linear_release::Config for TestRuntime { impl Config for TestRuntime { type AllPalletsWithoutSystem = AllPalletsWithoutSystem; - type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; + type RuntimeEvent = RuntimeEvent; + type BlockNumber = BlockNumber; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + type ProjectIdentifier = Identifier; + type Multiplier = Multiplier; type Balance = Balance; - type BlockNumberToBalance = ConvertInto; - type CandleAuctionDuration = CandleAuctionDuration; - type CommunityFundingDuration = CommunityRoundDuration; + type Price = FixedU128; + type NativeCurrency = Balances; + type FundingCurrency = StatemintAssets; type ContributionTokenCurrency = LocalAssets; - type ContributionVesting = ConstU32<4>; - type DaysToBlocks = DaysToBlocks; - type EnglishAuctionDuration = EnglishAuctionDuration; + type PriceProvider = ConstPriceProvider; + type Randomness = RandomnessCollectiveFlip; + type StringLimit = ConstU32<64>; + type PreImageLimit = ConstU32<1024>; type EvaluationDuration = EvaluationDuration; - type EvaluationSuccessThreshold = EarlyEvaluationThreshold; - type EvaluatorSlash = EvaluatorSlash; - type FeeBrackets = FeeBrackets; - type FundingCurrency = StatemintAssets; - type ManualAcceptanceDuration = ManualAcceptanceDuration; + type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; + type EnglishAuctionDuration = EnglishAuctionDuration; + type CandleAuctionDuration = CandleAuctionDuration; + type CommunityFundingDuration = CommunityRoundDuration; + type RemainderFundingDuration = RemainderFundingDuration; + type PalletId = FundingPalletId; + type MaxProjectsToUpdatePerBlock = ConstU32<100>; + type MaxEvaluationsPerUser = ConstU32<4>; // Low value to simplify the tests type MaxBidsPerUser = ConstU32<4>; type MaxContributionsPerUser = ConstU32<4>; - type MaxEvaluationsPerUser = ConstU32<4>; - type MaxProjectsToUpdatePerBlock = ConstU32<100>; - type Multiplier = Multiplier; - type NativeCurrency = Balances; - type PalletId = FundingPalletId; - type PolimecReceiverInfo = PolimecReceiverInfo; - type PreImageLimit = ConstU32<1024>; - type Price = FixedU128; - type PriceProvider = ConstPriceProvider; - type ProjectIdentifier = Identifier; - type Randomness = RandomnessCollectiveFlip; - type RemainderFundingDuration = RemainderFundingDuration; - type RuntimeCall = RuntimeCall; - type RuntimeEvent = RuntimeEvent; - type RuntimeOrigin = RuntimeOrigin; - type StringLimit = ConstU32<64>; + type ContributionVesting = ConstU32<4>; + type WeightInfo = weights::SubstrateWeight; + type FeeBrackets = FeeBrackets; + type EvaluationSuccessThreshold = EarlyEvaluationThreshold; + type Vesting = Vesting; + type ManualAcceptanceDuration = ManualAcceptanceDuration; type SuccessToSettlementTime = SuccessToSettlementTime; + type EvaluatorSlash = EvaluatorSlash; type TreasuryAccount = TreasuryAccount; - type Vesting = Vesting; - type WeightInfo = weights::SubstrateWeight; + type DaysToBlocks = DaysToBlocks; + type BlockNumberToBalance = ConvertInto; + type PolimecReceiverInfo = PolimecReceiverInfo; } // Build genesis storage according to the mock runtime. diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index 70d908d3f..5a073c0a7 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -232,7 +232,8 @@ pub mod storage_types { pub early_usd_amount: Balance, pub late_usd_amount: Balance, pub when: BlockNumber, - pub rewarded_or_slashed: bool, + // Will be Some after a reward of slash was made on this evaluation. + pub rewarded_or_slashed: Option>, } #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] @@ -660,6 +661,12 @@ pub mod inner_types { Slashed, } + #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, PartialOrd, Ord, RuntimeDebug, TypeInfo, MaxEncodedLen)] + pub enum RewardOrSlash { + Reward(Balance), + Slash(Balance), + } + #[derive(Default, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct RewardInfo { // Total "Early Evaluators" rewards amount in Contribution Tokens diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index e0c69c939..185a73b2c 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -497,43 +497,44 @@ parameter_types! { } impl pallet_funding::Config for Runtime { type AllPalletsWithoutSystem = (Balances, LocalAssets, StatemintAssets, PolimecFunding, LinearVesting, Random); - type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; + type RuntimeEvent = RuntimeEvent; + type BlockNumber = BlockNumber; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + type ProjectIdentifier = u32; + type Multiplier = pallet_funding::types::Multiplier; type Balance = Balance; - type BlockNumberToBalance = ConvertInto; + type Price = FixedU128; + type NativeCurrency = Balances; + type FundingCurrency = StatemintAssets; + type ContributionTokenCurrency = LocalAssets; + type PriceProvider = pallet_funding::types::ConstPriceProvider; + type Randomness = Random; + type StringLimit = ConstU32<64>; + type PreImageLimit = ConstU32<1024>; + type EvaluationDuration = EvaluationDuration; + type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; + type EnglishAuctionDuration = EnglishAuctionDuration; type CandleAuctionDuration = CandleAuctionDuration; type CommunityFundingDuration = CommunityFundingDuration; - type ContributionTokenCurrency = LocalAssets; + type RemainderFundingDuration = RemainderFundingDuration; + type PalletId = FundingPalletId; + type MaxProjectsToUpdatePerBlock = ConstU32<100>; + type MaxEvaluationsPerUser = ConstU32<256>; + type MaxBidsPerUser = ConstU32<256>; + type MaxContributionsPerUser = ConstU32<256>; type ContributionVesting = ContributionVestingDuration; - type DaysToBlocks = DaysToBlocks; - type EnglishAuctionDuration = EnglishAuctionDuration; - type EvaluationDuration = EvaluationDuration; - type EvaluationSuccessThreshold = EarlyEvaluationThreshold; - type EvaluatorSlash = EvaluatorSlash; + type WeightInfo = pallet_funding::weights::SubstrateWeight; type FeeBrackets = FeeBrackets; - type FundingCurrency = StatemintAssets; + type EvaluationSuccessThreshold = EarlyEvaluationThreshold; + type Vesting = LinearVesting; type ManualAcceptanceDuration = ManualAcceptanceDuration; - type MaxBidsPerUser = ConstU32<256>; - type MaxContributionsPerUser = ConstU32<256>; - type MaxEvaluationsPerUser = ConstU32<256>; - type MaxProjectsToUpdatePerBlock = ConstU32<100>; - type Multiplier = pallet_funding::types::Multiplier; - type NativeCurrency = Balances; - type PalletId = FundingPalletId; - type PolimecReceiverInfo = PolimecReceiverInfo; - type PreImageLimit = ConstU32<1024>; - type Price = FixedU128; - type PriceProvider = pallet_funding::types::ConstPriceProvider; - type ProjectIdentifier = u32; - type Randomness = Random; - type RemainderFundingDuration = RemainderFundingDuration; - type RuntimeCall = RuntimeCall; - type RuntimeEvent = RuntimeEvent; - type RuntimeOrigin = RuntimeOrigin; - type StringLimit = ConstU32<64>; type SuccessToSettlementTime = SuccessToSettlementTime; + type EvaluatorSlash = EvaluatorSlash; type TreasuryAccount = TreasuryAccount; - type Vesting = LinearVesting; - type WeightInfo = pallet_funding::weights::SubstrateWeight; + type DaysToBlocks = DaysToBlocks; + type BlockNumberToBalance = ConvertInto; + type PolimecReceiverInfo = PolimecReceiverInfo; } parameter_types! { From f1bae11f13a2cc3518f2cb9814c764575507ea5a Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 13 Nov 2023 14:06:50 +0100 Subject: [PATCH 021/212] save --- Cargo.lock | 2 + integration-tests/src/tests/basic_comms.rs | 9 +++ integration-tests/src/tests/ct_migration.rs | 2 - pallets/funding/Cargo.toml | 1 + pallets/funding/src/functions.rs | 69 ++++++++++++++++----- pallets/funding/src/lib.rs | 10 +++ pallets/funding/src/mock.rs | 11 +++- pallets/polimec-receiver/Cargo.toml | 2 +- pallets/polimec-receiver/src/lib.rs | 53 ++-------------- runtimes/testnet/src/lib.rs | 8 +++ 10 files changed, 99 insertions(+), 68 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1c94625c7..8a44c1828 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6304,6 +6304,7 @@ dependencies = [ "pallet-xcm", "parachains-common", "parity-scale-codec", + "polimec-receiver", "polimec-traits", "polimec-xcm-executor", "polkadot-parachain", @@ -7762,6 +7763,7 @@ dependencies = [ "sp-core", "sp-io", "sp-runtime", + "sp-std", ] [[package]] diff --git a/integration-tests/src/tests/basic_comms.rs b/integration-tests/src/tests/basic_comms.rs index d7ca133c6..5c0fcdb7b 100644 --- a/integration-tests/src/tests/basic_comms.rs +++ b/integration-tests/src/tests/basic_comms.rs @@ -8,6 +8,15 @@ fn dmp() { let remark = PolimecCall::System(frame_system::Call::::remark_with_event { remark: "Hello from Polkadot!".as_bytes().to_vec(), }); + let inner_call = frame_system::Call::::remark_with_event { + remark: "Hello from Polkadot!".as_bytes().to_vec(), + }.encode(); + let encoded_remark = remark.clone().encode(); + let encoded_inner = "Hello from Polkadot!".as_bytes().to_vec(); + let fake_encode = (0u8, 7u8, encoded_inner.clone()).encode(); + let fake_encode_2 = (0u8, inner_call.clone()).encode(); + let mut fake_encode_3 = vec![0u8]; + fake_encode_3.extend_from_slice(inner_call[..].as_ref()); let sudo_origin = PolkadotOrigin::root(); let para_id = Polimec::para_id(); let xcm = VersionedXcm::from(Xcm(vec![ diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index ef6e930fd..aa5a27419 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -39,8 +39,6 @@ fn migration_check() { }); Polimec::execute_with(|| { - dbg!(Polimec::events()); - assert_ok!(PolimecFunding::do_migration(issuer(), 0u32)); println!("Polimec events:"); dbg!(Polimec::events()); }); diff --git a/pallets/funding/Cargo.toml b/pallets/funding/Cargo.toml index 8b32222d8..25515dc3d 100644 --- a/pallets/funding/Cargo.toml +++ b/pallets/funding/Cargo.toml @@ -42,6 +42,7 @@ pallet-xcm.workspace = true polkadot-runtime.workspace = true polkadot-runtime-parachains.workspace = true polkadot-parachain.workspace = true +polimec-receiver.workspace = true [dev-dependencies] pallet-insecure-randomness-collective-flip.workspace = true diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index c6d3b8607..2fe3bfc4c 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -1770,10 +1770,6 @@ impl Pallet { pub fn do_handle_channel_open_request(message: Instruction) -> XcmResult { // TODO: set these constants with a proper value - const MAX_MESSAGE_SIZE_THRESHOLDS: (u32, u32) = (50000, 102_400); - const MAX_CAPACITY_THRESHOLDS: (u32, u32) = (8, 1000); - const REQUIRED_MAX_CAPACITY: u32 = 8u32; - const REQUIRED_MAX_MESSAGE_SIZE: u32 = 102_400u32; const EXECUTION_DOT: MultiAsset = MultiAsset { id: Concrete(MultiLocation { parents: 0, interior: Here }), fun: Fungible(1_0_000_000_000u128), @@ -1781,14 +1777,17 @@ impl Pallet { const MAX_WEIGHT: Weight = Weight::from_parts(20_000_000_000, 1_000_000); const POLIMEC_PARA_ID: u32 = 3355u32; + let max_message_size_thresholds = T::MaxMessageSizeThresholds::get(); + let max_capacity_thresholds = T::MaxCapacityThresholds::get(); + log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest received: {:?}", message); match message { Instruction::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } - if max_message_size >= MAX_MESSAGE_SIZE_THRESHOLDS.0 && - max_message_size <= MAX_MESSAGE_SIZE_THRESHOLDS.1 && - max_capacity >= MAX_CAPACITY_THRESHOLDS.0 && - max_capacity <= MAX_CAPACITY_THRESHOLDS.1 => + if max_message_size >= max_message_size_thresholds.0 && + max_message_size <= max_message_size_thresholds.1 && + max_capacity >= max_capacity_thresholds.0 && + max_capacity <= max_capacity_thresholds.1 => { log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest accepted"); @@ -1811,8 +1810,8 @@ impl Pallet { polkadot_runtime::Runtime, >::hrmp_init_open_channel { recipient: ParaId::from(sender), - proposed_max_capacity: REQUIRED_MAX_CAPACITY, - proposed_max_message_size: REQUIRED_MAX_MESSAGE_SIZE, + proposed_max_capacity: T::RequiredMaxCapacity::get(), + proposed_max_message_size: T::RequiredMaxMessageSize::get(), }) .encode(); @@ -2091,35 +2090,37 @@ impl Pallet { let evaluations = Evaluations::::iter_prefix_values((project_id, participant.clone())); let bids = Bids::::iter_prefix_values((project_id, participant.clone())); let contributions = Contributions::::iter_prefix_values((project_id, participant.clone())); - let available_contribution_tokens = T::ContributionTokenCurrency::balance(project_id, &participant.clone()); - + let max_message_size = T::RequiredMaxMessageSize::get(); + let project_para_id = project_details.parachain_id.ok_or(Error::::ImpossibleState)?; // * Validity Checks * ensure!(migration_readiness_check.is_ready(), Error::::NotAllowed); // * Process Data * // u128 is a balance, u64 is now a BlockNumber, but will be a Moment/Timestamp in the future let mut migrations: Vec<(u128, u64)> = Vec::new(); - let mut evaluation_ct_amount = available_contribution_tokens; for evaluation in evaluations { if let Some(RewardOrSlash::Reward(ct_amount)) = evaluation.rewarded_or_slashed { let multiplier = MultiplierOf::::try_from(1u8).map_err(|_| Error::::BadConversion)?; let vesting_duration = multiplier.calculate_vesting_duration::(); - + let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); + migrations.push((ct_amount.into(), vesting_duration_local_type.into())); } } for contribution in contributions { let vesting_duration = contribution.multiplier.calculate_vesting_duration::(); let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); migrations.push((contribution.ct_amount.into(), vesting_duration_local_type.into())); - evaluation_ct_amount -= contribution.ct_amount; } for bid in bids { let vesting_duration = bid.multiplier.calculate_vesting_duration::(); let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); migrations.push((bid.final_ct_amount.into(), vesting_duration_local_type.into())); - evaluation_ct_amount -= bid.final_ct_amount; } + // let xcm_messages = construct_migration_xcm_messages(migrations, max_message_size, project_para_id); + + + Ok(()) // * Emit events * @@ -2636,4 +2637,40 @@ impl Pallet { Self::deposit_event(Event::FundingEnded { project_id, outcome: FundingOutcome::Failure(reason) }); Ok(()) } + + pub fn construct_migration_xcm_messages( + migrations: Vec<(u128, u64)>, + max_message_size: u32, + project_para_id: ParaId, + ) -> Vec> { + const MAX_WEIGHT: Weight = Weight::from_parts(20_000_000_000, 1_000_000); + let encoded_migrations_size = migrations.encode().len(); + let migration_call = polimec_receiver::Call::migrate_for_user { migrations }.encode(); + let polimec_receiver_info = T::PolimecReceiverInfo::get(); + let encoded_call = vec![polimec_receiver_info.index]; + let mut base_xcm_message = vec![ + UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, + Transact { + origin_kind: OriginKind::Native, + require_weight_at_most: MAX_WEIGHT, + call: polimec_receiver, + } + ]; + let mut xcm_messages: Vec> = Vec::new(); + let mut current_message: Vec<(u128, u64)> = Vec::new(); + let mut current_message_size: u128 = 0; + for (amount, duration) in migrations { + if current_message_size + amount > max_message_size { + xcm_messages.push(Self::construct_xcm_message(current_message, project_para_id)); + current_message = Vec::new(); + current_message_size = 0; + } + current_message.push((amount, duration)); + current_message_size += amount; + } + if !current_message.is_empty() { + xcm_messages.push(Self::construct_xcm_message(current_message, project_para_id)); + } + xcm_messages + } } diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index f9887b5fa..a5202efd8 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -415,6 +415,16 @@ pub mod pallet { type BlockNumberToBalance: Convert, BalanceOf>; type PolimecReceiverInfo: Get; + + /// Range of max_message_size values for the hrmp config where we accept the incoming channel request + type MaxMessageSizeThresholds: Get<(u32, u32)>; + /// Range of max_capacity_thresholds values for the hrmp config where we accept the incoming channel request + type MaxCapacityThresholds: Get<(u32, u32)>; + /// max_capacity config required for the channel from polimec to the project + type RequiredMaxCapacity: Get; + /// max_message_size config required for the channel from polimec to the project + type RequiredMaxMessageSize: Get; + } #[pallet::storage] diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index c8a02174c..8763b8972 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -318,7 +318,12 @@ impl pallet_linear_release::Config for TestRuntime { const MAX_VESTING_SCHEDULES: u32 = 32; } - +parameter_types! { + pub MaxMessageSizeThresholds: (u32, u32) = (50000, 102_400); + pub MaxCapacityThresholds: (u32, u32) = (8, 1000); + pub RequiredMaxCapacity: u32 = 8; + pub RequiredMaxMessageSize: u32 = 102_400; +} impl Config for TestRuntime { type AllPalletsWithoutSystem = AllPalletsWithoutSystem; type RuntimeEvent = RuntimeEvent; @@ -360,6 +365,10 @@ impl Config for TestRuntime { type DaysToBlocks = DaysToBlocks; type BlockNumberToBalance = ConvertInto; type PolimecReceiverInfo = PolimecReceiverInfo; + type MaxMessageSizeThresholds = MaxMessageSizeThresholds; + type MaxCapacityThresholds = MaxCapacityThresholds; + type RequiredMaxCapacity = RequiredMaxCapacity; + type RequiredMaxMessageSize = RequiredMaxMessageSize; } // Build genesis storage according to the mock runtime. diff --git a/pallets/polimec-receiver/Cargo.toml b/pallets/polimec-receiver/Cargo.toml index 0f87d84b0..0527fcd6d 100644 --- a/pallets/polimec-receiver/Cargo.toml +++ b/pallets/polimec-receiver/Cargo.toml @@ -19,7 +19,7 @@ scale-info = { version = "2.2.0", default-features = false, features = ["derive" frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.43" } frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } - +sp-std.workspace = true [dev-dependencies] serde = { version = "1.0.132" } diff --git a/pallets/polimec-receiver/src/lib.rs b/pallets/polimec-receiver/src/lib.rs index 4aa9b3f9a..62ba80cac 100644 --- a/pallets/polimec-receiver/src/lib.rs +++ b/pallets/polimec-receiver/src/lib.rs @@ -1,5 +1,4 @@ #![cfg_attr(not(feature = "std"), no_std)] - /// Edit this file to define custom logic or remove it if it is not needed. /// Learn more about FRAME and the core library of Substrate FRAME pallets: /// @@ -9,89 +8,47 @@ pub use pallet::*; pub mod pallet { use frame_support::{dispatch::DispatchResultWithPostInfo, pallet_prelude::*}; use frame_system::pallet_prelude::*; + use sp_std::prelude::*; - /// Configure the pallet by specifying the parameters and types on which it depends. #[pallet::config] pub trait Config: frame_system::Config { - /// Because this pallet emits events, it depends on the runtime's definition of an event. type RuntimeEvent: From> + IsType<::RuntimeEvent>; } #[pallet::pallet] pub struct Pallet(_); - // The pallet's runtime storage items. - // https://docs.substrate.io/v3/runtime/storage #[pallet::storage] #[pallet::getter(fn something)] - // Learn more about declaring storage items: - // https://docs.substrate.io/v3/runtime/storage#declaring-storage-items pub type Something = StorageValue<_, u32>; - // Pallets use events to inform users when important changes are made. - // https://docs.substrate.io/v3/runtime/events-and-errors #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { - /// Event documentation should end with an array that provides descriptive names for event - /// parameters. [something, who] SomethingStored(u32, T::AccountId), } - // Errors inform users that something went wrong. #[pallet::error] pub enum Error { - /// Error names should be descriptive. NoneValue, - /// Errors should have helpful documentation associated with them. StorageOverflow, } #[pallet::hooks] impl Hooks> for Pallet {} - // Dispatchable functions allows users to interact with the pallet and invoke state changes. - // These functions materialize as "extrinsics", which are often compared to transactions. - // Dispatchable functions must be annotated with a weight and must return a DispatchResult. + #[pallet::call] impl Pallet { - /// An example dispatchable that takes a singles value as a parameter, writes the value to - /// storage and emits an event. This function must be dispatched by a signed extrinsic. #[pallet::call_index(0)] #[pallet::weight(Weight::from_parts(10_000, 0) + T::DbWeight::get().writes(1))] - pub fn do_something(origin: OriginFor, something: u32) -> DispatchResultWithPostInfo { - // Check that the extrinsic was signed and get the signer. - // This function will return an error if the extrinsic is not signed. - // https://docs.substrate.io/v3/runtime/origins - let who = ensure_signed(origin)?; + pub fn migrate_for_user(origin: OriginFor, migrations: Vec<(u128, u64)>) -> DispatchResult { - // Update storage. - >::put(something); + let who = ensure_signed(origin)?; - // Emit an event. - Self::deposit_event(Event::SomethingStored(something, who)); - // Return a successful DispatchResultWithPostInfo - Ok(().into()) + Ok(()) } - /// An example dispatchable that may throw a custom error. - #[pallet::call_index(1)] - #[pallet::weight(Weight::from_parts(10_000, 0) + T::DbWeight::get().reads_writes(1,1))] - pub fn cause_error(origin: OriginFor) -> DispatchResultWithPostInfo { - let _who = ensure_signed(origin)?; - // Read a value from storage. - match >::get() { - // Return an error if the value has not been set. - None => Err(Error::::NoneValue)?, - Some(old) => { - // Increment the value read from storage; will error in the event of overflow. - let new = old.checked_add(1).ok_or(Error::::StorageOverflow)?; - // Update the value in storage with the incremented result. - >::put(new); - Ok(().into()) - }, - } - } } } diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 185a73b2c..8e38d2984 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -494,6 +494,10 @@ parameter_types! { pub PolimecReceiverInfo: xcm::v3::PalletInfo = xcm::v3::PalletInfo::new( 51, "PolimecReceiver".into(), "polimec_receiver".into(), 0, 1, 0 ).unwrap(); + pub MaxMessageSizeThresholds: (u32, u32) = (50000, 102_400); + pub MaxCapacityThresholds: (u32, u32) = (8, 1000); + pub RequiredMaxCapacity: u32 = 8; + pub RequiredMaxMessageSize: u32 = 102_400; } impl pallet_funding::Config for Runtime { type AllPalletsWithoutSystem = (Balances, LocalAssets, StatemintAssets, PolimecFunding, LinearVesting, Random); @@ -535,6 +539,10 @@ impl pallet_funding::Config for Runtime { type DaysToBlocks = DaysToBlocks; type BlockNumberToBalance = ConvertInto; type PolimecReceiverInfo = PolimecReceiverInfo; + type MaxMessageSizeThresholds = MaxMessageSizeThresholds; + type MaxCapacityThresholds = MaxCapacityThresholds; + type RequiredMaxCapacity = RequiredMaxCapacity; + type RequiredMaxMessageSize = RequiredMaxMessageSize; } parameter_types! { From 154ee8a398def8f700de06d8cf6a0ec42ee05c03 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 13 Nov 2023 16:29:17 +0100 Subject: [PATCH 022/212] save --- integration-tests/src/tests/basic_comms.rs | 6 +- integration-tests/src/tests/ct_migration.rs | 5 + pallets/funding/src/functions.rs | 123 ++++++++++++++------ pallets/funding/src/impls.rs | 5 +- pallets/funding/src/instantiator.rs | 4 +- pallets/funding/src/lib.rs | 13 ++- pallets/funding/src/mock.rs | 68 +++++------ pallets/funding/src/types.rs | 3 + pallets/polimec-receiver/src/lib.rs | 23 ++-- runtimes/testnet/src/lib.rs | 66 +++++------ 10 files changed, 190 insertions(+), 126 deletions(-) diff --git a/integration-tests/src/tests/basic_comms.rs b/integration-tests/src/tests/basic_comms.rs index 5c0fcdb7b..f5484f761 100644 --- a/integration-tests/src/tests/basic_comms.rs +++ b/integration-tests/src/tests/basic_comms.rs @@ -8,9 +8,9 @@ fn dmp() { let remark = PolimecCall::System(frame_system::Call::::remark_with_event { remark: "Hello from Polkadot!".as_bytes().to_vec(), }); - let inner_call = frame_system::Call::::remark_with_event { - remark: "Hello from Polkadot!".as_bytes().to_vec(), - }.encode(); + let inner_call = + frame_system::Call::::remark_with_event { remark: "Hello from Polkadot!".as_bytes().to_vec() } + .encode(); let encoded_remark = remark.clone().encode(); let encoded_inner = "Hello from Polkadot!".as_bytes().to_vec(); let fake_encode = (0u8, 7u8, encoded_inner.clone()).encode(); diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index aa5a27419..f4f97fc66 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -31,6 +31,8 @@ fn migration_check() { let channel_accepted_message = xcm::v3::opaque::Instruction::HrmpChannelAccepted { recipient: 6969u32 }; assert_ok!(PolimecFunding::do_handle_channel_accepted(channel_accepted_message)); + + inst.advance_time(10u32.into()).unwrap(); }); Penpal::execute_with(|| { @@ -41,5 +43,8 @@ fn migration_check() { Polimec::execute_with(|| { println!("Polimec events:"); dbg!(Polimec::events()); + + let project_details = pallet_funding::ProjectsDetails::::get(project_id).unwrap(); + assert!(project_details.migration_readiness_check.unwrap().is_ready()) }); } diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 2fe3bfc4c..249593994 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -29,6 +29,7 @@ use frame_support::{ Get, }, }; +use itertools::Itertools; use sp_arithmetic::{ traits::{CheckedDiv, CheckedSub, Zero}, Percent, Perquintill, @@ -36,9 +37,8 @@ use sp_arithmetic::{ use sp_runtime::traits::Convert; use sp_std::marker::PhantomData; -use crate::ProjectStatus::FundingSuccessful; +use crate::{Call::start_bid_vesting_schedule_for, ProjectStatus::FundingSuccessful}; use polimec_traits::ReleaseSchedule; -use crate::Call::start_bid_vesting_schedule_for; use crate::traits::{BondingRequirementCalculation, ProvideStatemintPrice, VestingDurationCalculation}; @@ -1314,7 +1314,8 @@ impl Pallet { // * Validity checks * ensure!( - evaluation.rewarded_or_slashed.is_none() && matches!(project_details.status, ProjectStatus::FundingSuccessful), + evaluation.rewarded_or_slashed.is_none() && + matches!(project_details.status, ProjectStatus::FundingSuccessful), Error::::NotAllowed ); @@ -2083,7 +2084,11 @@ impl Pallet { Ok(()) } - pub fn do_one_migration(caller: AccountIdOf, project_id: T::ProjectIdentifier, participant: AccountIdOf) -> DispatchResult { + pub fn do_one_migration( + caller: AccountIdOf, + project_id: T::ProjectIdentifier, + participant: AccountIdOf, + ) -> DispatchResult { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let migration_readiness_check = project_details.migration_readiness_check.ok_or(Error::::NotAllowed)?; @@ -2117,13 +2122,25 @@ impl Pallet { migrations.push((bid.final_ct_amount.into(), vesting_duration_local_type.into())); } - // let xcm_messages = construct_migration_xcm_messages(migrations, max_message_size, project_para_id); - - + let xcm_messages = Self::construct_migration_xcm_messages(T::AccountId32Conversion::convert(participant), migrations, max_message_size); + for xcm in xcm_messages { + let dest_loc = MultiLocation { parents: 1, interior: Here }; + let mut destination = Some(dest_loc); + let (ticket, _price) = T::XcmRouter::validate(&mut destination, &mut Some(xcm)); + match T::XcmRouter::deliver(ticket) { + Ok(_) => { + Pallet::::deposit_event(Event::::UserMigrationSent { + user: participant.clone(), + }); + Ok(()) + }, + Err(_e) => { + return Err(Error::::XcmFailed) + }, + } + } Ok(()) - - // * Emit events * } } @@ -2139,7 +2156,10 @@ impl Pallet { } /// Adds a project to the ProjectsToUpdate storage, so it can be updated at some later point in time. - pub fn add_to_update_store(block_number: ::BlockNumber, store: (&T::ProjectIdentifier, UpdateType)) { + pub fn add_to_update_store( + block_number: ::BlockNumber, + store: (&T::ProjectIdentifier, UpdateType), + ) { // Try to get the project into the earliest possible block to update. // There is a limit for how many projects can update each block, so we need to make sure we don't exceed that limit let mut block_number = block_number; @@ -2638,39 +2658,70 @@ impl Pallet { Ok(()) } + pub fn migrations_per_xcm_message_allowed(max_message_size: u32) -> u32 { + const MAX_WEIGHT: Weight = Weight::from_parts(20_000_000_000, 1_000_000); + + let one_migration_bytes = (0u128, 0u64).encode().len() as u32; + + // our encoded call starts with pallet index 51, and call index 0 + let mut encoded_call = vec![51u8, 0]; + let encoded_first_param = [0u8; 32].encode(); + let encoded_second_param = Vec::<(u128, u32)>::new().encode(); + // we append the encoded parameters, with our migrations vec being empty for now + encoded_call.extend_from_slice(encoded_first_param.as_slice()); + encoded_call.extend_from_slice(encoded_second_param.as_slice()); + + let mut base_xcm_message: Xcm<()> = Xcm(vec![ + UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, + Transact { origin_kind: OriginKind::Native, require_weight_at_most: MAX_WEIGHT, call: encoded_call.into() }, + ]); + let xcm_size = base_xcm_message.encode().len(); + + let available_bytes_for_migration_per_message = max_message_size.saturating_sub(xcm_size as u32); + + let mut output = 0u32; + let mut current_migration_size = 0u32; + while current_migration_size < available_bytes_for_migration_per_message { + if current_migration_size + one_migration_bytes > available_bytes_for_migration_per_message { + break + } else { + current_migration_size += one_migration_bytes; + output += 1; + } + } + + output + } + pub fn construct_migration_xcm_messages( + user: [u8; 32], migrations: Vec<(u128, u64)>, max_message_size: u32, - project_para_id: ParaId, ) -> Vec> { const MAX_WEIGHT: Weight = Weight::from_parts(20_000_000_000, 1_000_000); - let encoded_migrations_size = migrations.encode().len(); - let migration_call = polimec_receiver::Call::migrate_for_user { migrations }.encode(); - let polimec_receiver_info = T::PolimecReceiverInfo::get(); - let encoded_call = vec![polimec_receiver_info.index]; - let mut base_xcm_message = vec![ - UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, - Transact { - origin_kind: OriginKind::Native, - require_weight_at_most: MAX_WEIGHT, - call: polimec_receiver, - } - ]; + let _polimec_receiver_info = T::PolimecReceiverInfo::get(); + // TODO: use the actual pallet index when the fields are not private anymore (https://github.com/paritytech/polkadot-sdk/pull/2231) + let migrations_per_xcm = Self::migrations_per_xcm_message_allowed(max_message_size); let mut xcm_messages: Vec> = Vec::new(); - let mut current_message: Vec<(u128, u64)> = Vec::new(); - let mut current_message_size: u128 = 0; - for (amount, duration) in migrations { - if current_message_size + amount > max_message_size { - xcm_messages.push(Self::construct_xcm_message(current_message, project_para_id)); - current_message = Vec::new(); - current_message_size = 0; - } - current_message.push((amount, duration)); - current_message_size += amount; - } - if !current_message.is_empty() { - xcm_messages.push(Self::construct_xcm_message(current_message, project_para_id)); + + for migrations in migrations.chunks(migrations_per_xcm as usize) { + let migrations = migrations.to_vec(); + let mut encoded_call = vec![51u8, 0]; + encoded_call.extend_from_slice(user.encode().as_slice()); + encoded_call.extend_from_slice(migrations.encode().as_slice()); + let xcm: Xcm<()> = Xcm(vec![ + UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, + Transact { + origin_kind: OriginKind::Native, + require_weight_at_most: MAX_WEIGHT, + call: encoded_call.into(), + }, + ]); + xcm_messages.push(xcm); } + + // TODO: we probably want to ensure we dont build too many messages to overflow the queue. Which we know from the parameter `T::RequiredMaxCapacity`. + // the problem is that we don't know the existing messages in the destination queue. So for now we assume all messages will succeed xcm_messages } } diff --git a/pallets/funding/src/impls.rs b/pallets/funding/src/impls.rs index cddb97c92..0c15dc0d4 100644 --- a/pallets/funding/src/impls.rs +++ b/pallets/funding/src/impls.rs @@ -244,8 +244,9 @@ fn remaining_evaluators_to_reward_or_slash( if outcome == EvaluatorsOutcomeOf::::Unchanged { 0u64 } else { - Evaluations::::iter_prefix_values((project_id,)).filter(|evaluation| evaluation.rewarded_or_slashed.is_none()).count() - as u64 + Evaluations::::iter_prefix_values((project_id,)) + .filter(|evaluation| evaluation.rewarded_or_slashed.is_none()) + .count() as u64 } } diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index f2f253a48..1701fd4c4 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -1358,9 +1358,7 @@ pub trait ExistentialDeposits { impl ExistentialDeposits for Vec> { fn existential_deposits(&self) -> Vec> { self.iter() - .map(|x| { - UserToPLMCBalance::new(x.clone(), ::ExistentialDeposit::get()) - }) + .map(|x| UserToPLMCBalance::new(x.clone(), ::ExistentialDeposit::get())) .collect::>() } } diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index a5202efd8..75fccddeb 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -279,6 +279,8 @@ pub mod pallet { // TODO: our local BlockNumber should be removed once we move onto using Moment for time tracking type BlockNumber: IsType<::BlockNumber> + Into; + type AccountId32Conversion: Convert; + type RuntimeOrigin: IsType<::RuntimeOrigin> + Into::RuntimeOrigin>>; @@ -424,7 +426,6 @@ pub mod pallet { type RequiredMaxCapacity: Get; /// max_message_size config required for the channel from polimec to the project type RequiredMaxMessageSize: Get; - } #[pallet::storage] @@ -792,6 +793,9 @@ pub mod pallet { MigrationStarted { project_id: T::ProjectIdentifier, }, + UserMigrationSent { + user: T::AccountId, + } } #[pallet::error] @@ -888,7 +892,7 @@ pub mod pallet { CommsNotEstablished, XcmFailed, // Tried to convert one type into another and failed. i.e try_into failed - BadConversion + BadConversion, } #[pallet::call] @@ -1176,10 +1180,7 @@ pub mod pallet { #[pallet::call_index(24)] #[pallet::weight(Weight::from_parts(1000, 0))] - pub fn start_migration( - origin: OriginFor, - project_id: T::ProjectIdentifier, - ) -> DispatchResult { + pub fn start_migration(origin: OriginFor, project_id: T::ProjectIdentifier) -> DispatchResult { let caller = ensure_signed(origin)?; Self::do_start_migration(&caller, project_id) } diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 8763b8972..5ee53c625 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -326,49 +326,49 @@ parameter_types! { } impl Config for TestRuntime { type AllPalletsWithoutSystem = AllPalletsWithoutSystem; - type RuntimeEvent = RuntimeEvent; - type BlockNumber = BlockNumber; - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - type ProjectIdentifier = Identifier; - type Multiplier = Multiplier; - type Balance = Balance; - type Price = FixedU128; - type NativeCurrency = Balances; - type FundingCurrency = StatemintAssets; - type ContributionTokenCurrency = LocalAssets; - type PriceProvider = ConstPriceProvider; - type Randomness = RandomnessCollectiveFlip; - type StringLimit = ConstU32<64>; - type PreImageLimit = ConstU32<1024>; - type EvaluationDuration = EvaluationDuration; type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; - type EnglishAuctionDuration = EnglishAuctionDuration; + type Balance = Balance; + type BlockNumber = BlockNumber; + type BlockNumberToBalance = ConvertInto; type CandleAuctionDuration = CandleAuctionDuration; type CommunityFundingDuration = CommunityRoundDuration; - type RemainderFundingDuration = RemainderFundingDuration; - type PalletId = FundingPalletId; - type MaxProjectsToUpdatePerBlock = ConstU32<100>; - type MaxEvaluationsPerUser = ConstU32<4>; - // Low value to simplify the tests - type MaxBidsPerUser = ConstU32<4>; - type MaxContributionsPerUser = ConstU32<4>; + type ContributionTokenCurrency = LocalAssets; type ContributionVesting = ConstU32<4>; - type WeightInfo = weights::SubstrateWeight; - type FeeBrackets = FeeBrackets; + type DaysToBlocks = DaysToBlocks; + type EnglishAuctionDuration = EnglishAuctionDuration; + type EvaluationDuration = EvaluationDuration; type EvaluationSuccessThreshold = EarlyEvaluationThreshold; - type Vesting = Vesting; - type ManualAcceptanceDuration = ManualAcceptanceDuration; - type SuccessToSettlementTime = SuccessToSettlementTime; type EvaluatorSlash = EvaluatorSlash; - type TreasuryAccount = TreasuryAccount; - type DaysToBlocks = DaysToBlocks; - type BlockNumberToBalance = ConvertInto; - type PolimecReceiverInfo = PolimecReceiverInfo; - type MaxMessageSizeThresholds = MaxMessageSizeThresholds; + type FeeBrackets = FeeBrackets; + type FundingCurrency = StatemintAssets; + type ManualAcceptanceDuration = ManualAcceptanceDuration; + // Low value to simplify the tests + type MaxBidsPerUser = ConstU32<4>; type MaxCapacityThresholds = MaxCapacityThresholds; + type MaxContributionsPerUser = ConstU32<4>; + type MaxEvaluationsPerUser = ConstU32<4>; + type MaxMessageSizeThresholds = MaxMessageSizeThresholds; + type MaxProjectsToUpdatePerBlock = ConstU32<100>; + type Multiplier = Multiplier; + type NativeCurrency = Balances; + type PalletId = FundingPalletId; + type PolimecReceiverInfo = PolimecReceiverInfo; + type PreImageLimit = ConstU32<1024>; + type Price = FixedU128; + type PriceProvider = ConstPriceProvider; + type ProjectIdentifier = Identifier; + type Randomness = RandomnessCollectiveFlip; + type RemainderFundingDuration = RemainderFundingDuration; type RequiredMaxCapacity = RequiredMaxCapacity; type RequiredMaxMessageSize = RequiredMaxMessageSize; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type StringLimit = ConstU32<64>; + type SuccessToSettlementTime = SuccessToSettlementTime; + type TreasuryAccount = TreasuryAccount; + type Vesting = Vesting; + type WeightInfo = weights::SubstrateWeight; } // Build genesis storage according to the mock runtime. diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index 5a073c0a7..02b103aef 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -234,6 +234,7 @@ pub mod storage_types { pub when: BlockNumber, // Will be Some after a reward of slash was made on this evaluation. pub rewarded_or_slashed: Option>, + pub migration_sent: bool } #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] @@ -264,6 +265,7 @@ pub mod storage_types { pub when: BlockNumber, pub funds_released: bool, pub ct_minted: bool, + pub migration_sent: bool } impl< @@ -315,6 +317,7 @@ pub mod storage_types { pub plmc_vesting_info: Option, pub funds_released: bool, pub ct_minted: bool, + pub migration_sent: bool, } /// Represents a bucket that holds a specific amount of tokens at a given price. diff --git a/pallets/polimec-receiver/src/lib.rs b/pallets/polimec-receiver/src/lib.rs index 62ba80cac..247e0300e 100644 --- a/pallets/polimec-receiver/src/lib.rs +++ b/pallets/polimec-receiver/src/lib.rs @@ -11,7 +11,10 @@ pub mod pallet { use sp_std::prelude::*; #[pallet::config] - pub trait Config: frame_system::Config { + pub trait Config: frame_system::Config + where + Self::AccountId: From<[u8; 32]>, + { type RuntimeEvent: From> + IsType<::RuntimeEvent>; } @@ -24,7 +27,10 @@ pub mod pallet { #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] - pub enum Event { + pub enum Event + where + T::AccountId: From<[u8; 32]>, + { SomethingStored(u32, T::AccountId), } @@ -35,20 +41,19 @@ pub mod pallet { } #[pallet::hooks] - impl Hooks> for Pallet {} - + impl Hooks> for Pallet where T::AccountId: From<[u8; 32]> {} #[pallet::call] - impl Pallet { + impl Pallet + where + T::AccountId: From<[u8; 32]>, + { #[pallet::call_index(0)] #[pallet::weight(Weight::from_parts(10_000, 0) + T::DbWeight::get().writes(1))] - pub fn migrate_for_user(origin: OriginFor, migrations: Vec<(u128, u64)>) -> DispatchResult { - + pub fn migrate_for_user(origin: OriginFor, user: [u8; 32], migrations: Vec<(u128, u64)>) -> DispatchResult { let who = ensure_signed(origin)?; Ok(()) } - - } } diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 8e38d2984..81fde00ec 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -501,48 +501,48 @@ parameter_types! { } impl pallet_funding::Config for Runtime { type AllPalletsWithoutSystem = (Balances, LocalAssets, StatemintAssets, PolimecFunding, LinearVesting, Random); - type RuntimeEvent = RuntimeEvent; - type BlockNumber = BlockNumber; - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - type ProjectIdentifier = u32; - type Multiplier = pallet_funding::types::Multiplier; - type Balance = Balance; - type Price = FixedU128; - type NativeCurrency = Balances; - type FundingCurrency = StatemintAssets; - type ContributionTokenCurrency = LocalAssets; - type PriceProvider = pallet_funding::types::ConstPriceProvider; - type Randomness = Random; - type StringLimit = ConstU32<64>; - type PreImageLimit = ConstU32<1024>; - type EvaluationDuration = EvaluationDuration; type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; - type EnglishAuctionDuration = EnglishAuctionDuration; + type Balance = Balance; + type BlockNumber = BlockNumber; + type BlockNumberToBalance = ConvertInto; type CandleAuctionDuration = CandleAuctionDuration; type CommunityFundingDuration = CommunityFundingDuration; - type RemainderFundingDuration = RemainderFundingDuration; - type PalletId = FundingPalletId; - type MaxProjectsToUpdatePerBlock = ConstU32<100>; - type MaxEvaluationsPerUser = ConstU32<256>; - type MaxBidsPerUser = ConstU32<256>; - type MaxContributionsPerUser = ConstU32<256>; + type ContributionTokenCurrency = LocalAssets; type ContributionVesting = ContributionVestingDuration; - type WeightInfo = pallet_funding::weights::SubstrateWeight; - type FeeBrackets = FeeBrackets; + type DaysToBlocks = DaysToBlocks; + type EnglishAuctionDuration = EnglishAuctionDuration; + type EvaluationDuration = EvaluationDuration; type EvaluationSuccessThreshold = EarlyEvaluationThreshold; - type Vesting = LinearVesting; - type ManualAcceptanceDuration = ManualAcceptanceDuration; - type SuccessToSettlementTime = SuccessToSettlementTime; type EvaluatorSlash = EvaluatorSlash; - type TreasuryAccount = TreasuryAccount; - type DaysToBlocks = DaysToBlocks; - type BlockNumberToBalance = ConvertInto; - type PolimecReceiverInfo = PolimecReceiverInfo; - type MaxMessageSizeThresholds = MaxMessageSizeThresholds; + type FeeBrackets = FeeBrackets; + type FundingCurrency = StatemintAssets; + type ManualAcceptanceDuration = ManualAcceptanceDuration; + type MaxBidsPerUser = ConstU32<256>; type MaxCapacityThresholds = MaxCapacityThresholds; + type MaxContributionsPerUser = ConstU32<256>; + type MaxEvaluationsPerUser = ConstU32<256>; + type MaxMessageSizeThresholds = MaxMessageSizeThresholds; + type MaxProjectsToUpdatePerBlock = ConstU32<100>; + type Multiplier = pallet_funding::types::Multiplier; + type NativeCurrency = Balances; + type PalletId = FundingPalletId; + type PolimecReceiverInfo = PolimecReceiverInfo; + type PreImageLimit = ConstU32<1024>; + type Price = FixedU128; + type PriceProvider = pallet_funding::types::ConstPriceProvider; + type ProjectIdentifier = u32; + type Randomness = Random; + type RemainderFundingDuration = RemainderFundingDuration; type RequiredMaxCapacity = RequiredMaxCapacity; type RequiredMaxMessageSize = RequiredMaxMessageSize; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type StringLimit = ConstU32<64>; + type SuccessToSettlementTime = SuccessToSettlementTime; + type TreasuryAccount = TreasuryAccount; + type Vesting = LinearVesting; + type WeightInfo = pallet_funding::weights::SubstrateWeight; } parameter_types! { From 79adcc9b5be3e68bc100390dd207c50077d37170 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 14 Nov 2023 13:33:16 +0100 Subject: [PATCH 023/212] migration is successfully sent and reflected in the system --- integration-tests/src/tests/ct_migration.rs | 84 ++++++++++++++++++- pallets/funding/src/functions.rs | 91 ++++++++++++++------- pallets/funding/src/impls.rs | 10 ++- pallets/funding/src/lib.rs | 1 + pallets/funding/src/types.rs | 55 ++++++++++++- pallets/polimec-receiver/src/lib.rs | 13 ++- runtimes/testnet/src/lib.rs | 1 + 7 files changed, 215 insertions(+), 40 deletions(-) diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index f4f97fc66..f9e542d34 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -1,3 +1,5 @@ +use sp_runtime::{FixedPointNumber, Perquintill}; +use pallet_funding::{BidInfoOf, ContributionInfoOf, EvaluationInfoOf, RewardOrSlash}; use crate::*; use polimec_parachain_runtime::PolimecFunding; use tests::defaults::*; @@ -32,7 +34,7 @@ fn migration_check() { let channel_accepted_message = xcm::v3::opaque::Instruction::HrmpChannelAccepted { recipient: 6969u32 }; assert_ok!(PolimecFunding::do_handle_channel_accepted(channel_accepted_message)); - inst.advance_time(10u32.into()).unwrap(); + inst.advance_time(::SuccessToSettlementTime::get() + 1u32).unwrap(); }); Penpal::execute_with(|| { @@ -48,3 +50,83 @@ fn migration_check() { assert!(project_details.migration_readiness_check.unwrap().is_ready()) }); } + +#[test] +fn migration_is_sent() { + let mut inst = IntegrationInstantiator::new(None); + let project_id = Polimec::execute_with(|| { + inst.create_finished_project( + default_project(issuer(), 0), + issuer(), + vec![ + UserToUSDBalance::new(eval_1(), 50_000 * PLMC), + UserToUSDBalance::new(eval_2(), 25_000 * PLMC), + UserToUSDBalance::new(eval_3(), 32_000 * PLMC), + ], + IntegrationInstantiator::generate_bids_from_total_usd( + Perquintill::from_percent(40) * (sp_runtime::FixedU128::from_float(1.0).checked_mul_int(100_000 * ASSET_UNIT).unwrap()), + sp_runtime::FixedU128::from_float(1.0), + default_weights(), + vec![eval_1(), bidder_2(), bidder_3(), bidder_4(), bidder_5()], + ), + IntegrationInstantiator::generate_contributions_from_total_usd( + Perquintill::from_percent(50) * (sp_runtime::FixedU128::from_float(1.0).checked_mul_int(100_000 * ASSET_UNIT).unwrap()), + sp_runtime::FixedU128::from_float(1.0), + default_weights(), + vec![eval_1(), buyer_2(), buyer_3(), buyer_4(), buyer_5()], + ), + vec![], + ) + }); + let penpal_sov_acc = PolkadotRelay::sovereign_account_id_of(Parachain(Penpal::para_id().into()).into()); + PolkadotRelay::fund_accounts(vec![(penpal_sov_acc, 100_0_000_000_000u128)]); + + // Mock HRMP establishment + Polimec::execute_with(|| { + assert_ok!(PolimecFunding::do_set_para_id_for_project(&issuer(), project_id, ParaId::from(6969u32))); + + let open_channel_message = xcm::v3::opaque::Instruction::HrmpNewChannelOpenRequest { + sender: 6969, + max_message_size: 102_300, + max_capacity: 1000, + }; + assert_ok!(PolimecFunding::do_handle_channel_open_request(open_channel_message)); + + let channel_accepted_message = xcm::v3::opaque::Instruction::HrmpChannelAccepted { recipient: 6969u32 }; + assert_ok!(PolimecFunding::do_handle_channel_accepted(channel_accepted_message)); + + inst.advance_time(::SuccessToSettlementTime::get() + 1u32).unwrap(); + let project_details = pallet_funding::ProjectsDetails::::get(project_id).unwrap(); + dbg!(project_details.evaluation_round_info.evaluators_outcome); + let evaluations = pallet_funding::Evaluations::::iter_prefix_values((project_id,)).collect::>(); + dbg!(evaluations); + }); + + // Migration is ready + Polimec::execute_with(|| { + let project_details = pallet_funding::ProjectsDetails::::get(project_id).unwrap(); + assert!(project_details.migration_readiness_check.unwrap().is_ready()) + }); + + // Migrate one user's contribution tokens. He evaluated, bid, and contributed + Polimec::execute_with(|| { + assert_ok!(PolimecFunding::do_migrate_one_participant(eval_1(), project_id, eval_1())); + println!("Polimec events:"); + dbg!(Polimec::events()); + let mut user_evaluations = pallet_funding::Evaluations::::iter_prefix_values((project_id, eval_1())); + let mut user_bids = pallet_funding::Bids::::iter_prefix_values((project_id, eval_1())); + dbg!(user_bids.clone(); + let mut user_contributions = pallet_funding::Contributions::::iter_prefix_values((project_id, eval_1())); + + assert!(user_evaluations.all(|evaluation| evaluation.ct_migration_sent)); + assert!(user_bids.all(|bid| bid.ct_migration_sent)); + assert!(user_contributions.all(|contribution| contribution.ct_migration_sent)); + }); + + Penpal::execute_with(|| { + println!("Penpal events:"); + dbg!(Penpal::events()); + }); + + +} diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 249593994..6a3736755 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -783,6 +783,8 @@ impl Pallet { late_usd_amount, when: now, rewarded_or_slashed: None, + ct_migration_sent: false, + ct_migration_confirmed: false, }; // * Update Storage * @@ -946,6 +948,8 @@ impl Pallet { when: now, funds_released: false, ct_minted: false, + ct_migration_sent: false, + ct_migration_confirmed: false, }; // * Update storage * @@ -1057,6 +1061,8 @@ impl Pallet { plmc_vesting_info: None, funds_released: false, ct_minted: false, + ct_migration_sent: false, + ct_migration_confirmed: false, }; // * Update storage * @@ -1261,8 +1267,9 @@ impl Pallet { ) -> DispatchResult { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; - let released_evaluation = + let mut released_evaluation = Evaluations::::get((project_id, evaluator, evaluation_id)).ok_or(Error::::EvaluationNotFound)?; + let release_amount = released_evaluation.current_plmc_bond; // * Validity checks * ensure!( @@ -1282,12 +1289,17 @@ impl Pallet { released_evaluation.current_plmc_bond, Precision::Exact, )?; - Evaluations::::remove((project_id, evaluator, evaluation_id)); + + released_evaluation.current_plmc_bond = Zero::zero(); + Evaluations::::insert((project_id, evaluator, evaluation_id), released_evaluation); + + // FIXME: same question as removing bid + // Evaluations::::remove((project_id, evaluator, evaluation_id)); // * Emit events * Self::deposit_event(Event::BondReleased { project_id, - amount: released_evaluation.current_plmc_bond, + amount: release_amount, bonder: evaluator.clone(), releaser: releaser.clone(), }); @@ -1575,7 +1587,9 @@ impl Pallet { // * Update Storage * T::NativeCurrency::release(&LockType::Participation(project_id), bidder, bid.plmc_bond, Precision::Exact)?; - Bids::::remove((project_id, bidder, bid_id)); + + // FIXME: Since we store the migration info here, we might not want to delete it. Users will want to find out their previous history + // Bids::::remove((project_id, bidder, bid_id)); // * Emit events * Self::deposit_event(Event::BondReleased { @@ -1646,7 +1660,9 @@ impl Pallet { // * Update Storage * T::NativeCurrency::release(&LockType::Participation(project_id), contributor, bid.plmc_bond, Precision::Exact)?; - Contributions::::remove((project_id, contributor, contribution_id)); + + // FIXME: same question as bids removing + // Contributions::::remove((project_id, contributor, contribution_id)); // * Emit events * Self::deposit_event(Event::BondReleased { @@ -2084,7 +2100,7 @@ impl Pallet { Ok(()) } - pub fn do_one_migration( + pub fn do_migrate_one_participant( caller: AccountIdOf, project_id: T::ProjectIdentifier, participant: AccountIdOf, @@ -2092,55 +2108,68 @@ impl Pallet { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let migration_readiness_check = project_details.migration_readiness_check.ok_or(Error::::NotAllowed)?; - let evaluations = Evaluations::::iter_prefix_values((project_id, participant.clone())); - let bids = Bids::::iter_prefix_values((project_id, participant.clone())); - let contributions = Contributions::::iter_prefix_values((project_id, participant.clone())); + let evaluations = Evaluations::::iter_prefix_values((project_id, participant.clone())).filter(|evaluation| { + evaluation.ct_migration_sent == false + }); + let bids = Bids::::iter_prefix_values((project_id, participant.clone())).filter(|bid| { + bid.ct_migration_sent == false + }); + let contributions = Contributions::::iter_prefix_values((project_id, participant.clone())).filter(|contribution| { + contribution.ct_migration_sent == false + }); let max_message_size = T::RequiredMaxMessageSize::get(); let project_para_id = project_details.parachain_id.ok_or(Error::::ImpossibleState)?; + // * Validity Checks * ensure!(migration_readiness_check.is_ready(), Error::::NotAllowed); // * Process Data * // u128 is a balance, u64 is now a BlockNumber, but will be a Moment/Timestamp in the future - let mut migrations: Vec<(u128, u64)> = Vec::new(); + let mut migrations: Vec<(MigrationOrigin, MigrationInfo)> = Vec::new(); for evaluation in evaluations { if let Some(RewardOrSlash::Reward(ct_amount)) = evaluation.rewarded_or_slashed { let multiplier = MultiplierOf::::try_from(1u8).map_err(|_| Error::::BadConversion)?; let vesting_duration = multiplier.calculate_vesting_duration::(); let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); - migrations.push((ct_amount.into(), vesting_duration_local_type.into())); + let migration_origin = MigrationOrigin::Evaluation { project_id, user: evaluation.evaluator, id: evaluation.id }; + let migration_info: MigrationInfo = (ct_amount.into(), vesting_duration_local_type.into()).into(); + migrations.push((migration_origin, migration_info)); } } for contribution in contributions { let vesting_duration = contribution.multiplier.calculate_vesting_duration::(); let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); - migrations.push((contribution.ct_amount.into(), vesting_duration_local_type.into())); + let migration_origin = MigrationOrigin::Contribution { project_id, user: contribution.contributor, id: contribution.id }; + let migration_info: MigrationInfo = (contribution.ct_amount.into(), vesting_duration_local_type.into()).into(); + migrations.push((migration_origin, migration_info)); } for bid in bids { let vesting_duration = bid.multiplier.calculate_vesting_duration::(); let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); - migrations.push((bid.final_ct_amount.into(), vesting_duration_local_type.into())); + let migration_origin = MigrationOrigin::Bid { project_id, user: bid.bidder, id: bid.id }; + let migration_info: MigrationInfo = (bid.final_ct_amount.into(), vesting_duration_local_type.into()).into(); + migrations.push((migration_origin, migration_info)); } - let xcm_messages = Self::construct_migration_xcm_messages(T::AccountId32Conversion::convert(participant), migrations, max_message_size); - for xcm in xcm_messages { - let dest_loc = MultiLocation { parents: 1, interior: Here }; - let mut destination = Some(dest_loc); - let (ticket, _price) = T::XcmRouter::validate(&mut destination, &mut Some(xcm)); - match T::XcmRouter::deliver(ticket) { + let constructed_migrations = Self::construct_migration_xcm_messages(T::AccountId32Conversion::convert(participant.clone()), migrations, max_message_size); + for (migration_origins, xcm) in constructed_migrations { + let project_multilocation = MultiLocation { parents: 1, interior: X1(Parachain(project_para_id.into())) }; + match >::send_xcm(Here, project_multilocation, xcm) { Ok(_) => { - Pallet::::deposit_event(Event::::UserMigrationSent { + for origin in migration_origins { + origin.mark_as_sent() + } + Self::deposit_event(Event::::UserMigrationSent { user: participant.clone(), }); - Ok(()) }, Err(_e) => { - return Err(Error::::XcmFailed) + return Err(Error::::XcmFailed.into()) }, } } - Ok(()) + } } @@ -2666,7 +2695,7 @@ impl Pallet { // our encoded call starts with pallet index 51, and call index 0 let mut encoded_call = vec![51u8, 0]; let encoded_first_param = [0u8; 32].encode(); - let encoded_second_param = Vec::<(u128, u32)>::new().encode(); + let encoded_second_param = Vec::::new().encode(); // we append the encoded parameters, with our migrations vec being empty for now encoded_call.extend_from_slice(encoded_first_param.as_slice()); encoded_call.extend_from_slice(encoded_second_param.as_slice()); @@ -2695,20 +2724,20 @@ impl Pallet { pub fn construct_migration_xcm_messages( user: [u8; 32], - migrations: Vec<(u128, u64)>, + migrations: Vec<(MigrationOrigin, MigrationInfo)>, max_message_size: u32, - ) -> Vec> { + ) -> Vec<(Vec>, Xcm<()>)> { const MAX_WEIGHT: Weight = Weight::from_parts(20_000_000_000, 1_000_000); let _polimec_receiver_info = T::PolimecReceiverInfo::get(); // TODO: use the actual pallet index when the fields are not private anymore (https://github.com/paritytech/polkadot-sdk/pull/2231) let migrations_per_xcm = Self::migrations_per_xcm_message_allowed(max_message_size); - let mut xcm_messages: Vec> = Vec::new(); + let mut output: Vec<(Vec>, Xcm<()>)> = Vec::new(); for migrations in migrations.chunks(migrations_per_xcm as usize) { - let migrations = migrations.to_vec(); + let (migration_origins, migration_infos): (Vec>, Vec) = migrations.to_vec().into_iter().unzip(); let mut encoded_call = vec![51u8, 0]; encoded_call.extend_from_slice(user.encode().as_slice()); - encoded_call.extend_from_slice(migrations.encode().as_slice()); + encoded_call.extend_from_slice(migration_infos.encode().as_slice()); let xcm: Xcm<()> = Xcm(vec![ UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, Transact { @@ -2717,11 +2746,11 @@ impl Pallet { call: encoded_call.into(), }, ]); - xcm_messages.push(xcm); + output.push((migration_origins, xcm)); } // TODO: we probably want to ensure we dont build too many messages to overflow the queue. Which we know from the parameter `T::RequiredMaxCapacity`. // the problem is that we don't know the existing messages in the destination queue. So for now we assume all messages will succeed - xcm_messages + output } } diff --git a/pallets/funding/src/impls.rs b/pallets/funding/src/impls.rs index 0c15dc0d4..c833b97f7 100644 --- a/pallets/funding/src/impls.rs +++ b/pallets/funding/src/impls.rs @@ -1,4 +1,5 @@ use frame_support::{traits::Get, weights::Weight}; +use sp_arithmetic::traits::Zero; use sp_runtime::{traits::AccountIdConversion, DispatchError}; use sp_std::marker::PhantomData; @@ -355,11 +356,12 @@ fn reward_or_slash_one_evaluation(project_id: T::ProjectIdentifier) - } fn unbond_one_evaluation(project_id: T::ProjectIdentifier) -> (Weight, u64) { - let project_evaluations = Evaluations::::iter_prefix_values((project_id,)).collect::>(); - let evaluation_count = project_evaluations.len() as u64; + let project_evaluations = Evaluations::::iter_prefix_values((project_id,)); + let mut remaining_evaluations = project_evaluations.filter(|evaluation| evaluation.current_plmc_bond > Zero::zero()); let base_weight = Weight::from_parts(10_000_000, 0); + if let Some(evaluation) = remaining_evaluations.next() { + let remaining = remaining_evaluations.count() as u64; - if let Some(evaluation) = project_evaluations.first() { match Pallet::::do_evaluation_unbond_for( &T::PalletId::get().into_account_truncating(), evaluation.project_id, @@ -374,7 +376,7 @@ fn unbond_one_evaluation(project_id: T::ProjectIdentifier) -> (Weight error: e, }), }; - (base_weight.saturating_add(WeightInfoOf::::evaluation_unbond_for()), evaluation_count.saturating_sub(1u64)) + (base_weight.saturating_add(WeightInfoOf::::evaluation_unbond_for()), remaining.saturating_sub(1u64)) } else { (base_weight, 0u64) } diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 75fccddeb..975a58734 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -793,6 +793,7 @@ pub mod pallet { MigrationStarted { project_id: T::ProjectIdentifier, }, + UserMigrationSent { user: T::AccountId, } diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index 02b103aef..68cf8d159 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -234,7 +234,8 @@ pub mod storage_types { pub when: BlockNumber, // Will be Some after a reward of slash was made on this evaluation. pub rewarded_or_slashed: Option>, - pub migration_sent: bool + pub ct_migration_sent: bool, + pub ct_migration_confirmed: bool } #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] @@ -265,7 +266,8 @@ pub mod storage_types { pub when: BlockNumber, pub funds_released: bool, pub ct_minted: bool, - pub migration_sent: bool + pub ct_migration_sent: bool, + pub ct_migration_confirmed: bool, } impl< @@ -317,7 +319,8 @@ pub mod storage_types { pub plmc_vesting_info: Option, pub funds_released: bool, pub ct_minted: bool, - pub migration_sent: bool, + pub ct_migration_sent: bool, + pub ct_migration_confirmed: bool } /// Represents a bucket that holds a specific amount of tokens at a given price. @@ -367,6 +370,7 @@ pub mod storage_types { } pub mod inner_types { + use crate::{AccountIdOf, Bids, Contributions, Evaluations, ProjectIdOf}; use super::*; #[derive(Default, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] @@ -720,4 +724,49 @@ pub mod inner_types { /// request for a hrmp channel was sent to the relay. Waiting for response. AwaitingAcceptance, } + + #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] + pub enum MigrationOrigin { + Evaluation{ project_id: ProjectIdOf, user: AccountIdOf, id: u32 }, + Bid { project_id: ProjectIdOf, user: AccountIdOf, id: u32 }, + Contribution { project_id: ProjectIdOf, user: AccountIdOf, id: u32 }, + } + impl MigrationOrigin { + pub fn mark_as_sent(&self) { + match self { + MigrationOrigin::Evaluation { project_id, user, id } => { + Evaluations::::mutate((project_id, user, id), |maybe_evaluation|{ + if let Some(evaluation) = maybe_evaluation { + evaluation.ct_migration_sent = true; + } + }); + } + MigrationOrigin::Bid { project_id, user, id } => { + Bids::::mutate((project_id, user, id), |maybe_bid|{ + if let Some(bid) = maybe_bid { + bid.ct_migration_sent = true; + } + }); + } + MigrationOrigin::Contribution { project_id, user, id } => { + Contributions::::mutate((project_id, user, id), |maybe_contribution|{ + if let Some(contribution) = maybe_contribution { + contribution.ct_migration_sent = true; + } + }); + } + } + } + } + + #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] + pub struct MigrationInfo { + contribution_token_amount: u128, + vesting_time: u64 + } + impl From<(u128, u64)> for MigrationInfo { + fn from((contribution_token_amount, vesting_time): (u128, u64)) -> Self { + Self { contribution_token_amount, vesting_time } + } + } } diff --git a/pallets/polimec-receiver/src/lib.rs b/pallets/polimec-receiver/src/lib.rs index 247e0300e..113f4859a 100644 --- a/pallets/polimec-receiver/src/lib.rs +++ b/pallets/polimec-receiver/src/lib.rs @@ -1,4 +1,8 @@ #![cfg_attr(not(feature = "std"), no_std)] + +use codec::{Decode, Encode, MaxEncodedLen}; +use frame_support::dispatch::TypeInfo; +use frame_support::RuntimeDebug; /// Edit this file to define custom logic or remove it if it is not needed. /// Learn more about FRAME and the core library of Substrate FRAME pallets: /// @@ -50,10 +54,17 @@ pub mod pallet { { #[pallet::call_index(0)] #[pallet::weight(Weight::from_parts(10_000, 0) + T::DbWeight::get().writes(1))] - pub fn migrate_for_user(origin: OriginFor, user: [u8; 32], migrations: Vec<(u128, u64)>) -> DispatchResult { + pub fn migrate_for_user(origin: OriginFor, user: [u8; 32], migrations: Vec) -> DispatchResult { let who = ensure_signed(origin)?; + Ok(()) } } } + +#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] +pub struct MigrationInfo { + contribution_token_amount: u128, + vesting_time: u64 +} diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 81fde00ec..6835d8c76 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -543,6 +543,7 @@ impl pallet_funding::Config for Runtime { type TreasuryAccount = TreasuryAccount; type Vesting = LinearVesting; type WeightInfo = pallet_funding::weights::SubstrateWeight; + type AccountId32Conversion = ConvertInto; } parameter_types! { From 88eeb2a3dbefcee35357bcbed94abba28b86b187 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 14 Nov 2023 16:34:17 +0100 Subject: [PATCH 024/212] vesting scheduling working in polimec-receiver --- Cargo.lock | 5 ++ integration-tests/penpal/Cargo.toml | 2 + integration-tests/penpal/src/lib.rs | 52 +++++++++++ integration-tests/penpal/src/xcm_config.rs | 2 +- integration-tests/src/constants.rs | 1 + integration-tests/src/tests/ct_migration.rs | 99 +++++++++++++++++++-- pallets/funding/src/functions.rs | 46 +++++----- pallets/funding/src/impls.rs | 3 +- pallets/funding/src/lib.rs | 4 +- pallets/funding/src/types.rs | 22 ++--- pallets/polimec-receiver/Cargo.toml | 16 +++- pallets/polimec-receiver/src/lib.rs | 57 ++++++++++-- runtimes/testnet/src/lib.rs | 2 +- 13 files changed, 252 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8a44c1828..5d1b3cb62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7357,6 +7357,7 @@ dependencies = [ "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", + "pallet-vesting", "pallet-xcm", "parachain-info", "parachains-common", @@ -7365,6 +7366,7 @@ dependencies = [ "polkadot-parachain", "polkadot-primitives", "polkadot-runtime-common", + "polkadot-runtime-parachains", "scale-info", "smallvec", "sp-api", @@ -7758,6 +7760,9 @@ dependencies = [ "frame-support", "frame-system", "parity-scale-codec", + "polimec-traits", + "polkadot-parachain", + "polkadot-runtime-parachains", "scale-info", "serde", "sp-core", diff --git a/integration-tests/penpal/Cargo.toml b/integration-tests/penpal/Cargo.toml index 85bce7028..b56cd9c7d 100644 --- a/integration-tests/penpal/Cargo.toml +++ b/integration-tests/penpal/Cargo.toml @@ -53,6 +53,7 @@ sp-session.workspace = true sp-std.workspace = true sp-transaction-pool.workspace = true sp-version.workspace = true +polkadot-runtime-parachains.workspace = true # Polkadot polkadot-primitives.workspace = true @@ -76,6 +77,7 @@ cumulus-primitives-utility.workspace = true pallet-collator-selection.workspace = true parachain-info.workspace = true parachains-common.workspace = true +pallet-vesting.workspace = true [features] default = [ diff --git a/integration-tests/penpal/src/lib.rs b/integration-tests/penpal/src/lib.rs index c09431dc3..010fe1951 100644 --- a/integration-tests/penpal/src/lib.rs +++ b/integration-tests/penpal/src/lib.rs @@ -31,6 +31,7 @@ mod weights; pub mod xcm_config; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; +use cumulus_primitives_core::ParaId; use frame_support::{ construct_runtime, dispatch::DispatchClass, @@ -74,8 +75,11 @@ use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; // XCM Imports use parachains_common::{AccountId, Signature}; +use sp_runtime::traits::Convert; use xcm::latest::prelude::BodyId; use xcm_executor::XcmExecutor; +use polimec_receiver::MigrationInfo; +use frame_support::traits::WithdrawReasons; /// Balance of an account. pub type Balance = u128; @@ -390,6 +394,8 @@ impl pallet_balances::Config for Runtime { type WeightInfo = pallet_balances::weights::SubstrateWeight; } + + parameter_types! { /// Relay Chain `TransactionByteFee` / 10 pub const TransactionByteFee: Balance = 10 * MICROUNIT; @@ -547,10 +553,54 @@ impl pallet_sudo::Config for Runtime { type WeightInfo = pallet_sudo::weights::SubstrateWeight; } +parameter_types! { + pub const MinVestedTransfer: Balance = 0_1_000_000_000u128; + pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = + WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); +} + +impl pallet_vesting::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Currency = Balances; + type BlockNumberToBalance = ConvertInto; + type MinVestedTransfer = MinVestedTransfer; + type WeightInfo = (); + type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; + const MAX_VESTING_SCHEDULES: u32 = 100; +} + + + +pub struct DivideBalanceByBlocks; +impl Convert for DivideBalanceByBlocks { + fn convert(migration_info: MigrationInfo) -> Balance { + let total_amount: Balance = migration_info.contribution_token_amount.into(); + // normally BlockNumber is u64 so we can use the safe .into() + let vesting_time_in_blocks: BlockNumber = migration_info.vesting_time.try_into().unwrap(); + if vesting_time_in_blocks == 0u32 { + total_amount + } else { + total_amount.checked_div(vesting_time_in_blocks as u128).expect("already checked division by zero") + } + } +} +parameter_types! { + pub PolimecParaId: ParaId = 3355u32.into(); + pub GenesisMoment: BlockNumber = 0u32; +} impl polimec_receiver::Config for Runtime { type RuntimeEvent = RuntimeEvent; + type PolimecParaId = PolimecParaId; + type RuntimeOrigin = RuntimeOrigin; + type Vesting = Vesting; + type Balances = Balances; + type Balance = Balance; + type GenesisMoment = GenesisMoment; + type MigrationInfoToPerBlockBalance = DivideBalanceByBlocks; } +impl polkadot_runtime_parachains::origin::Config for Runtime {} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where @@ -565,6 +615,7 @@ construct_runtime!( } = 1, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 2, ParachainInfo: parachain_info::{Pallet, Storage, Config} = 3, + ParachainOrigin: polkadot_runtime_parachains::origin = 4, // Monetary stuff. Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 10, @@ -587,6 +638,7 @@ construct_runtime!( // The main stage. Assets: pallet_assets::{Pallet, Call, Storage, Event} = 50, PolimecReceiver: polimec_receiver = 51, + Vesting: pallet_vesting = 52, Sudo: pallet_sudo::{Pallet, Call, Storage, Event, Config} = 255, } diff --git a/integration-tests/penpal/src/xcm_config.rs b/integration-tests/penpal/src/xcm_config.rs index dd78157c9..657175be4 100644 --- a/integration-tests/penpal/src/xcm_config.rs +++ b/integration-tests/penpal/src/xcm_config.rs @@ -123,7 +123,7 @@ pub type XcmOriginToTransactDispatchOrigin = ( RelayChainAsNative, // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when // recognized. - SiblingParachainAsNative, + SiblingParachainAsNative, // Native signed account converter; this just converts an `AccountId32` origin into a normal // `RuntimeOrigin::Signed` origin of the same 32-byte value. SignedAccountId32AsNative, diff --git a/integration-tests/src/constants.rs b/integration-tests/src/constants.rs index 7c4eee8db..d6a52f334 100644 --- a/integration-tests/src/constants.rs +++ b/integration-tests/src/constants.rs @@ -338,6 +338,7 @@ pub mod penpal { parachain_system: Default::default(), polkadot_xcm: penpal_runtime::PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION) }, sudo: penpal_runtime::SudoConfig { key: Some(get_account_id_from_seed::("Alice")) }, + ..Default::default() }; genesis_config.build_storage().unwrap() diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index f9e542d34..4944729d9 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -1,7 +1,7 @@ -use sp_runtime::{FixedPointNumber, Perquintill}; -use pallet_funding::{BidInfoOf, ContributionInfoOf, EvaluationInfoOf, RewardOrSlash}; use crate::*; +use pallet_funding::{BidInfoOf, ContributionInfoOf, EvaluationInfoOf, RewardOrSlash}; use polimec_parachain_runtime::PolimecFunding; +use sp_runtime::{FixedPointNumber, Perquintill}; use tests::defaults::*; #[test] @@ -64,13 +64,15 @@ fn migration_is_sent() { UserToUSDBalance::new(eval_3(), 32_000 * PLMC), ], IntegrationInstantiator::generate_bids_from_total_usd( - Perquintill::from_percent(40) * (sp_runtime::FixedU128::from_float(1.0).checked_mul_int(100_000 * ASSET_UNIT).unwrap()), + Perquintill::from_percent(40) * + (sp_runtime::FixedU128::from_float(1.0).checked_mul_int(100_000 * ASSET_UNIT).unwrap()), sp_runtime::FixedU128::from_float(1.0), default_weights(), vec![eval_1(), bidder_2(), bidder_3(), bidder_4(), bidder_5()], ), IntegrationInstantiator::generate_contributions_from_total_usd( - Perquintill::from_percent(50) * (sp_runtime::FixedU128::from_float(1.0).checked_mul_int(100_000 * ASSET_UNIT).unwrap()), + Perquintill::from_percent(50) * + (sp_runtime::FixedU128::from_float(1.0).checked_mul_int(100_000 * ASSET_UNIT).unwrap()), sp_runtime::FixedU128::from_float(1.0), default_weights(), vec![eval_1(), buyer_2(), buyer_3(), buyer_4(), buyer_5()], @@ -98,7 +100,8 @@ fn migration_is_sent() { inst.advance_time(::SuccessToSettlementTime::get() + 1u32).unwrap(); let project_details = pallet_funding::ProjectsDetails::::get(project_id).unwrap(); dbg!(project_details.evaluation_round_info.evaluators_outcome); - let evaluations = pallet_funding::Evaluations::::iter_prefix_values((project_id,)).collect::>(); + let evaluations = + pallet_funding::Evaluations::::iter_prefix_values((project_id,)).collect::>(); dbg!(evaluations); }); @@ -113,10 +116,11 @@ fn migration_is_sent() { assert_ok!(PolimecFunding::do_migrate_one_participant(eval_1(), project_id, eval_1())); println!("Polimec events:"); dbg!(Polimec::events()); - let mut user_evaluations = pallet_funding::Evaluations::::iter_prefix_values((project_id, eval_1())); + let mut user_evaluations = + pallet_funding::Evaluations::::iter_prefix_values((project_id, eval_1())); let mut user_bids = pallet_funding::Bids::::iter_prefix_values((project_id, eval_1())); - dbg!(user_bids.clone(); - let mut user_contributions = pallet_funding::Contributions::::iter_prefix_values((project_id, eval_1())); + let mut user_contributions = + pallet_funding::Contributions::::iter_prefix_values((project_id, eval_1())); assert!(user_evaluations.all(|evaluation| evaluation.ct_migration_sent)); assert!(user_bids.all(|bid| bid.ct_migration_sent)); @@ -127,6 +131,85 @@ fn migration_is_sent() { println!("Penpal events:"); dbg!(Penpal::events()); }); +} + +#[test] +fn migration_is_executed_on_project() { + let mut inst = IntegrationInstantiator::new(None); + let project_id = Polimec::execute_with(|| { + inst.create_finished_project( + default_project(issuer(), 0), + issuer(), + vec![ + UserToUSDBalance::new(eval_1(), 50_000 * PLMC), + UserToUSDBalance::new(eval_2(), 25_000 * PLMC), + UserToUSDBalance::new(eval_3(), 32_000 * PLMC), + ], + IntegrationInstantiator::generate_bids_from_total_usd( + Perquintill::from_percent(40) * + (sp_runtime::FixedU128::from_float(1.0).checked_mul_int(100_000 * ASSET_UNIT).unwrap()), + sp_runtime::FixedU128::from_float(1.0), + default_weights(), + vec![eval_1(), bidder_2(), bidder_3(), bidder_4(), bidder_5()], + ), + IntegrationInstantiator::generate_contributions_from_total_usd( + Perquintill::from_percent(50) * + (sp_runtime::FixedU128::from_float(1.0).checked_mul_int(100_000 * ASSET_UNIT).unwrap()), + sp_runtime::FixedU128::from_float(1.0), + default_weights(), + vec![eval_1(), buyer_2(), buyer_3(), buyer_4(), buyer_5()], + ), + vec![], + ) + }); + let penpal_sov_acc = PolkadotRelay::sovereign_account_id_of(Parachain(Penpal::para_id().into()).into()); + PolkadotRelay::fund_accounts(vec![(penpal_sov_acc, 100_0_000_000_000u128)]); + // Mock HRMP establishment + Polimec::execute_with(|| { + assert_ok!(PolimecFunding::do_set_para_id_for_project(&issuer(), project_id, ParaId::from(6969u32))); + let open_channel_message = xcm::v3::opaque::Instruction::HrmpNewChannelOpenRequest { + sender: 6969, + max_message_size: 102_300, + max_capacity: 1000, + }; + assert_ok!(PolimecFunding::do_handle_channel_open_request(open_channel_message)); + + let channel_accepted_message = xcm::v3::opaque::Instruction::HrmpChannelAccepted { recipient: 6969u32 }; + assert_ok!(PolimecFunding::do_handle_channel_accepted(channel_accepted_message)); + + inst.advance_time(::SuccessToSettlementTime::get() + 1u32).unwrap(); + let project_details = pallet_funding::ProjectsDetails::::get(project_id).unwrap(); + dbg!(project_details.evaluation_round_info.evaluators_outcome); + let evaluations = + pallet_funding::Evaluations::::iter_prefix_values((project_id,)).collect::>(); + dbg!(evaluations); + }); + + // Migration is ready + Polimec::execute_with(|| { + let project_details = pallet_funding::ProjectsDetails::::get(project_id).unwrap(); + assert!(project_details.migration_readiness_check.unwrap().is_ready()) + }); + + // Migrate is sent + Polimec::execute_with(|| { + assert_ok!(PolimecFunding::do_migrate_one_participant(eval_1(), project_id, eval_1())); + println!("Polimec events:"); + dbg!(Polimec::events()); + let mut user_evaluations = + pallet_funding::Evaluations::::iter_prefix_values((project_id, eval_1())); + let mut user_bids = pallet_funding::Bids::::iter_prefix_values((project_id, eval_1())); + let mut user_contributions = + pallet_funding::Contributions::::iter_prefix_values((project_id, eval_1())); + + assert!(user_evaluations.all(|evaluation| evaluation.ct_migration_sent)); + assert!(user_bids.all(|bid| bid.ct_migration_sent)); + assert!(user_contributions.all(|contribution| contribution.ct_migration_sent)); + }); + + Penpal::execute_with(|| { + dbg!(Penpal::events()); + }); } diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 6a3736755..516c62eed 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -1293,7 +1293,7 @@ impl Pallet { released_evaluation.current_plmc_bond = Zero::zero(); Evaluations::::insert((project_id, evaluator, evaluation_id), released_evaluation); - // FIXME: same question as removing bid + // FIXME: same question as removing bid // Evaluations::::remove((project_id, evaluator, evaluation_id)); // * Emit events * @@ -2108,15 +2108,12 @@ impl Pallet { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let migration_readiness_check = project_details.migration_readiness_check.ok_or(Error::::NotAllowed)?; - let evaluations = Evaluations::::iter_prefix_values((project_id, participant.clone())).filter(|evaluation| { - evaluation.ct_migration_sent == false - }); - let bids = Bids::::iter_prefix_values((project_id, participant.clone())).filter(|bid| { - bid.ct_migration_sent == false - }); - let contributions = Contributions::::iter_prefix_values((project_id, participant.clone())).filter(|contribution| { - contribution.ct_migration_sent == false - }); + let evaluations = Evaluations::::iter_prefix_values((project_id, participant.clone())) + .filter(|evaluation| evaluation.ct_migration_sent == false); + let bids = Bids::::iter_prefix_values((project_id, participant.clone())) + .filter(|bid| bid.ct_migration_sent == false); + let contributions = Contributions::::iter_prefix_values((project_id, participant.clone())) + .filter(|contribution| contribution.ct_migration_sent == false); let max_message_size = T::RequiredMaxMessageSize::get(); let project_para_id = project_details.parachain_id.ok_or(Error::::ImpossibleState)?; @@ -2131,7 +2128,8 @@ impl Pallet { let multiplier = MultiplierOf::::try_from(1u8).map_err(|_| Error::::BadConversion)?; let vesting_duration = multiplier.calculate_vesting_duration::(); let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); - let migration_origin = MigrationOrigin::Evaluation { project_id, user: evaluation.evaluator, id: evaluation.id }; + let migration_origin = + MigrationOrigin::Evaluation { project_id, user: evaluation.evaluator, id: evaluation.id }; let migration_info: MigrationInfo = (ct_amount.into(), vesting_duration_local_type.into()).into(); migrations.push((migration_origin, migration_info)); } @@ -2139,8 +2137,10 @@ impl Pallet { for contribution in contributions { let vesting_duration = contribution.multiplier.calculate_vesting_duration::(); let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); - let migration_origin = MigrationOrigin::Contribution { project_id, user: contribution.contributor, id: contribution.id }; - let migration_info: MigrationInfo = (contribution.ct_amount.into(), vesting_duration_local_type.into()).into(); + let migration_origin = + MigrationOrigin::Contribution { project_id, user: contribution.contributor, id: contribution.id }; + let migration_info: MigrationInfo = + (contribution.ct_amount.into(), vesting_duration_local_type.into()).into(); migrations.push((migration_origin, migration_info)); } for bid in bids { @@ -2151,25 +2151,24 @@ impl Pallet { migrations.push((migration_origin, migration_info)); } - let constructed_migrations = Self::construct_migration_xcm_messages(T::AccountId32Conversion::convert(participant.clone()), migrations, max_message_size); + let constructed_migrations = Self::construct_migration_xcm_messages( + T::AccountId32Conversion::convert(participant.clone()), + migrations, + max_message_size, + ); for (migration_origins, xcm) in constructed_migrations { let project_multilocation = MultiLocation { parents: 1, interior: X1(Parachain(project_para_id.into())) }; - match >::send_xcm(Here, project_multilocation, xcm) { + match >::send_xcm(Here, project_multilocation, xcm) { Ok(_) => { for origin in migration_origins { origin.mark_as_sent() } - Self::deposit_event(Event::::UserMigrationSent { - user: participant.clone(), - }); - }, - Err(_e) => { - return Err(Error::::XcmFailed.into()) + Self::deposit_event(Event::::UserMigrationSent { user: participant.clone() }); }, + Err(_e) => return Err(Error::::XcmFailed.into()), } } Ok(()) - } } @@ -2734,7 +2733,8 @@ impl Pallet { let mut output: Vec<(Vec>, Xcm<()>)> = Vec::new(); for migrations in migrations.chunks(migrations_per_xcm as usize) { - let (migration_origins, migration_infos): (Vec>, Vec) = migrations.to_vec().into_iter().unzip(); + let (migration_origins, migration_infos): (Vec>, Vec) = + migrations.to_vec().into_iter().unzip(); let mut encoded_call = vec![51u8, 0]; encoded_call.extend_from_slice(user.encode().as_slice()); encoded_call.extend_from_slice(migration_infos.encode().as_slice()); diff --git a/pallets/funding/src/impls.rs b/pallets/funding/src/impls.rs index c833b97f7..9891f5be5 100644 --- a/pallets/funding/src/impls.rs +++ b/pallets/funding/src/impls.rs @@ -357,7 +357,8 @@ fn reward_or_slash_one_evaluation(project_id: T::ProjectIdentifier) - fn unbond_one_evaluation(project_id: T::ProjectIdentifier) -> (Weight, u64) { let project_evaluations = Evaluations::::iter_prefix_values((project_id,)); - let mut remaining_evaluations = project_evaluations.filter(|evaluation| evaluation.current_plmc_bond > Zero::zero()); + let mut remaining_evaluations = + project_evaluations.filter(|evaluation| evaluation.current_plmc_bond > Zero::zero()); let base_weight = Weight::from_parts(10_000_000, 0); if let Some(evaluation) = remaining_evaluations.next() { let remaining = remaining_evaluations.count() as u64; diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 975a58734..fcefa0754 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -119,7 +119,7 @@ //! let project_id: ::ProjectIdentifier = project_id.into(); //! // Check project is in the community round //! let project_details = pallet_funding::Pallet::::project_details(project_id).ok_or(Error::::ProjectNotFound)?; -//! ensure!(project_details.status == pallet_funding::ProjectStatus::CommunityRound, "Project is not in the community round"); +//! "ensure!(project_details.status == pallet_funding::ProjectStatus::CommunityRound, "Project is not in the community round"); //! //! // Calculate how much funding was done already //! let project_contributions: ::Balance = pallet_funding::Contributions::::iter_prefix_values((project_id,)) @@ -796,7 +796,7 @@ pub mod pallet { UserMigrationSent { user: T::AccountId, - } + }, } #[pallet::error] diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index 68cf8d159..ecf5adabd 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -235,7 +235,7 @@ pub mod storage_types { // Will be Some after a reward of slash was made on this evaluation. pub rewarded_or_slashed: Option>, pub ct_migration_sent: bool, - pub ct_migration_confirmed: bool + pub ct_migration_confirmed: bool, } #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] @@ -320,7 +320,7 @@ pub mod storage_types { pub funds_released: bool, pub ct_minted: bool, pub ct_migration_sent: bool, - pub ct_migration_confirmed: bool + pub ct_migration_confirmed: bool, } /// Represents a bucket that holds a specific amount of tokens at a given price. @@ -370,8 +370,8 @@ pub mod storage_types { } pub mod inner_types { - use crate::{AccountIdOf, Bids, Contributions, Evaluations, ProjectIdOf}; use super::*; + use crate::{AccountIdOf, Bids, Contributions, Evaluations, ProjectIdOf}; #[derive(Default, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] @@ -727,7 +727,7 @@ pub mod inner_types { #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub enum MigrationOrigin { - Evaluation{ project_id: ProjectIdOf, user: AccountIdOf, id: u32 }, + Evaluation { project_id: ProjectIdOf, user: AccountIdOf, id: u32 }, Bid { project_id: ProjectIdOf, user: AccountIdOf, id: u32 }, Contribution { project_id: ProjectIdOf, user: AccountIdOf, id: u32 }, } @@ -735,26 +735,26 @@ pub mod inner_types { pub fn mark_as_sent(&self) { match self { MigrationOrigin::Evaluation { project_id, user, id } => { - Evaluations::::mutate((project_id, user, id), |maybe_evaluation|{ + Evaluations::::mutate((project_id, user, id), |maybe_evaluation| { if let Some(evaluation) = maybe_evaluation { evaluation.ct_migration_sent = true; } }); - } + }, MigrationOrigin::Bid { project_id, user, id } => { - Bids::::mutate((project_id, user, id), |maybe_bid|{ + Bids::::mutate((project_id, user, id), |maybe_bid| { if let Some(bid) = maybe_bid { bid.ct_migration_sent = true; } }); - } + }, MigrationOrigin::Contribution { project_id, user, id } => { - Contributions::::mutate((project_id, user, id), |maybe_contribution|{ + Contributions::::mutate((project_id, user, id), |maybe_contribution| { if let Some(contribution) = maybe_contribution { contribution.ct_migration_sent = true; } }); - } + }, } } } @@ -762,7 +762,7 @@ pub mod inner_types { #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct MigrationInfo { contribution_token_amount: u128, - vesting_time: u64 + vesting_time: u64, } impl From<(u128, u64)> for MigrationInfo { fn from((contribution_token_amount, vesting_time): (u128, u64)) -> Self { diff --git a/pallets/polimec-receiver/Cargo.toml b/pallets/polimec-receiver/Cargo.toml index 0527fcd6d..ba68e07b4 100644 --- a/pallets/polimec-receiver/Cargo.toml +++ b/pallets/polimec-receiver/Cargo.toml @@ -16,10 +16,15 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = ["derive scale-info = { version = "2.2.0", default-features = false, features = ["derive"] } # Substrate -frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.43" } -frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } -frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } +frame-benchmarking = { workspace = true, optional = true} +frame-support.workspace = true +frame-system.workspace = true sp-std.workspace = true +polkadot-runtime-parachains.workspace = true +polkadot-parachain.workspace = true +polimec-traits.workspace = true +sp-runtime.workspace = true + [dev-dependencies] serde = { version = "1.0.132" } @@ -39,6 +44,9 @@ std = [ "frame-system/std", "sp-core/std", "sp-io/std", - "sp-runtime/std" + "sp-runtime/std", + "sp-std/std", + "polkadot-runtime-parachains/std", + "polkadot-parachain/std", ] try-runtime = [ "frame-support/try-runtime" ] diff --git a/pallets/polimec-receiver/src/lib.rs b/pallets/polimec-receiver/src/lib.rs index 113f4859a..656dfe3e9 100644 --- a/pallets/polimec-receiver/src/lib.rs +++ b/pallets/polimec-receiver/src/lib.rs @@ -1,8 +1,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use codec::{Decode, Encode, MaxEncodedLen}; -use frame_support::dispatch::TypeInfo; -use frame_support::RuntimeDebug; +use frame_support::{dispatch::TypeInfo, RuntimeDebug}; /// Edit this file to define custom logic or remove it if it is not needed. /// Learn more about FRAME and the core library of Substrate FRAME pallets: /// @@ -10,9 +9,20 @@ pub use pallet::*; #[frame_support::pallet] pub mod pallet { - use frame_support::{dispatch::DispatchResultWithPostInfo, pallet_prelude::*}; + use frame_support::{ + dispatch::DispatchResultWithPostInfo, + pallet_prelude::*, + traits::{Currency, ExistenceRequirement::KeepAlive}, + }; use frame_system::pallet_prelude::*; + use polkadot_parachain::primitives::{Id as ParaId, Sibling}; + use polkadot_runtime_parachains::origin::{ensure_parachain, Origin as ParachainOrigin}; + use sp_runtime::traits::{AccountIdConversion, Convert, Zero}; use sp_std::prelude::*; + use frame_support::traits::{VestingSchedule, tokens::Balance}; + use crate::MigrationInfo; + + type MomentOf = <::Vesting as VestingSchedule<::AccountId>>::Moment; #[pallet::config] pub trait Config: frame_system::Config @@ -20,6 +30,14 @@ pub mod pallet { Self::AccountId: From<[u8; 32]>, { type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type PolimecParaId: Get; + type RuntimeOrigin: IsType<::RuntimeOrigin> + + Into::RuntimeOrigin>>; + type Vesting: VestingSchedule; + type Balances: Currency; + type Balance: Balance + From + MaybeSerializeDeserialize; + type GenesisMoment: Get>; + type MigrationInfoToPerBlockBalance: Convert; } #[pallet::pallet] @@ -35,7 +53,10 @@ pub mod pallet { where T::AccountId: From<[u8; 32]>, { - SomethingStored(u32, T::AccountId), + MigrationsExecutedForUser { + user: T::AccountId, + migrations: Vec, + }, } #[pallet::error] @@ -54,9 +75,29 @@ pub mod pallet { { #[pallet::call_index(0)] #[pallet::weight(Weight::from_parts(10_000, 0) + T::DbWeight::get().writes(1))] - pub fn migrate_for_user(origin: OriginFor, user: [u8; 32], migrations: Vec) -> DispatchResult { - let who = ensure_signed(origin)?; + pub fn migrate_for_user( + origin: OriginFor, + user: [u8; 32], + migrations: Vec, + ) -> DispatchResult { + let para_id: ParaId = ensure_parachain(::RuntimeOrigin::from(origin))?; + let user: T::AccountId = user.into(); + let polimec_id = T::PolimecParaId::get(); + let polimec_soverign_account = Sibling(polimec_id).into_account_truncating(); + + ensure!(para_id == T::PolimecParaId::get(), "Only Polimec Parachain can call migrations"); + + for migration in migrations.clone() { + T::Balances::transfer( + &polimec_soverign_account, + &user, + migration.contribution_token_amount.into(), + KeepAlive, + )?; + T::Vesting::add_vesting_schedule(&user, migration.contribution_token_amount.into(), T::MigrationInfoToPerBlockBalance::convert(migration), T::GenesisMoment::get())?; + } + Self::deposit_event(Event::MigrationsExecutedForUser{user, migrations}); Ok(()) } @@ -65,6 +106,6 @@ pub mod pallet { #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct MigrationInfo { - contribution_token_amount: u128, - vesting_time: u64 + pub contribution_token_amount: u128, + pub vesting_time: u64, } diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 6835d8c76..c34a0b1f4 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -500,6 +500,7 @@ parameter_types! { pub RequiredMaxMessageSize: u32 = 102_400; } impl pallet_funding::Config for Runtime { + type AccountId32Conversion = ConvertInto; type AllPalletsWithoutSystem = (Balances, LocalAssets, StatemintAssets, PolimecFunding, LinearVesting, Random); type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; type Balance = Balance; @@ -543,7 +544,6 @@ impl pallet_funding::Config for Runtime { type TreasuryAccount = TreasuryAccount; type Vesting = LinearVesting; type WeightInfo = pallet_funding::weights::SubstrateWeight; - type AccountId32Conversion = ConvertInto; } parameter_types! { From 62adc46181ce4bede9f6e08259577f66e82c812c Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 14 Nov 2023 17:35:59 +0100 Subject: [PATCH 025/212] save: starting to implement transact response, but we need to store a new map of query id -> unconfirmed transactions --- integration-tests/penpal/src/lib.rs | 25 ++++----- pallets/funding/src/functions.rs | 84 ++++++++++++++++++++++++----- pallets/funding/src/lib.rs | 19 ++++++- pallets/funding/src/types.rs | 36 ++----------- pallets/polimec-receiver/src/lib.rs | 23 ++++---- 5 files changed, 115 insertions(+), 72 deletions(-) diff --git a/integration-tests/penpal/src/lib.rs b/integration-tests/penpal/src/lib.rs index 010fe1951..5243e878b 100644 --- a/integration-tests/penpal/src/lib.rs +++ b/integration-tests/penpal/src/lib.rs @@ -74,12 +74,12 @@ use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; // XCM Imports +use frame_support::traits::WithdrawReasons; use parachains_common::{AccountId, Signature}; +use polimec_receiver::MigrationInfo; use sp_runtime::traits::Convert; use xcm::latest::prelude::BodyId; use xcm_executor::XcmExecutor; -use polimec_receiver::MigrationInfo; -use frame_support::traits::WithdrawReasons; /// Balance of an account. pub type Balance = u128; @@ -394,8 +394,6 @@ impl pallet_balances::Config for Runtime { type WeightInfo = pallet_balances::weights::SubstrateWeight; } - - parameter_types! { /// Relay Chain `TransactionByteFee` / 10 pub const TransactionByteFee: Balance = 10 * MICROUNIT; @@ -560,17 +558,16 @@ parameter_types! { } impl pallet_vesting::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; type BlockNumberToBalance = ConvertInto; + type Currency = Balances; type MinVestedTransfer = MinVestedTransfer; - type WeightInfo = (); + type RuntimeEvent = RuntimeEvent; type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; + type WeightInfo = (); + const MAX_VESTING_SCHEDULES: u32 = 100; } - - pub struct DivideBalanceByBlocks; impl Convert for DivideBalanceByBlocks { fn convert(migration_info: MigrationInfo) -> Balance { @@ -589,14 +586,14 @@ parameter_types! { pub GenesisMoment: BlockNumber = 0u32; } impl polimec_receiver::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type PolimecParaId = PolimecParaId; - type RuntimeOrigin = RuntimeOrigin; - type Vesting = Vesting; - type Balances = Balances; type Balance = Balance; + type Balances = Balances; type GenesisMoment = GenesisMoment; type MigrationInfoToPerBlockBalance = DivideBalanceByBlocks; + type PolimecParaId = PolimecParaId; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type Vesting = Vesting; } impl polkadot_runtime_parachains::origin::Config for Runtime {} diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 516c62eed..44b27a950 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -43,6 +43,7 @@ use polimec_traits::ReleaseSchedule; use crate::traits::{BondingRequirementCalculation, ProvideStatemintPrice, VestingDurationCalculation}; use super::*; +const POLIMEC_PARA_ID: u32 = 3355u32; // Round transitions impl Pallet { @@ -1792,7 +1793,6 @@ impl Pallet { fun: Fungible(1_0_000_000_000u128), }; const MAX_WEIGHT: Weight = Weight::from_parts(20_000_000_000, 1_000_000); - const POLIMEC_PARA_ID: u32 = 3355u32; let max_message_size_thresholds = T::MaxMessageSizeThresholds::get(); let max_capacity_thresholds = T::MaxCapacityThresholds::get(); @@ -2116,13 +2116,14 @@ impl Pallet { .filter(|contribution| contribution.ct_migration_sent == false); let max_message_size = T::RequiredMaxMessageSize::get(); let project_para_id = project_details.parachain_id.ok_or(Error::::ImpossibleState)?; + let now = >::block_number(); // * Validity Checks * ensure!(migration_readiness_check.is_ready(), Error::::NotAllowed); // * Process Data * // u128 is a balance, u64 is now a BlockNumber, but will be a Moment/Timestamp in the future - let mut migrations: Vec<(MigrationOrigin, MigrationInfo)> = Vec::new(); + let mut migrations: Vec<(MigrationOriginOf, MigrationInfo)> = Vec::new(); for evaluation in evaluations { if let Some(RewardOrSlash::Reward(ct_amount)) = evaluation.rewarded_or_slashed { let multiplier = MultiplierOf::::try_from(1u8).map_err(|_| Error::::BadConversion)?; @@ -2158,18 +2159,45 @@ impl Pallet { ); for (migration_origins, xcm) in constructed_migrations { let project_multilocation = MultiLocation { parents: 1, interior: X1(Parachain(project_para_id.into())) }; - match >::send_xcm(Here, project_multilocation, xcm) { - Ok(_) => { - for origin in migration_origins { - origin.mark_as_sent() - } - Self::deposit_event(Event::::UserMigrationSent { user: participant.clone() }); - }, - Err(_e) => return Err(Error::::XcmFailed.into()), + + let call: ::RuntimeCall = + Call::user_migration_response { query_id: Default::default(), response: Default::default() }.into(); + let transact_response_query_id = pallet_xcm::Pallet::::new_notify_query( + project_multilocation.clone(), + call.into(), + now + 20u32.into(), + Here, + ); + // TODO: check these values + let max_weight = Weight::from_parts(700_000_000, 10_000); + + let mut instructions = xcm.into_inner(); + instructions.push(ReportTransactStatus(QueryResponseInfo { + destination: Parachain(POLIMEC_PARA_ID).into(), + query_id: transact_response_query_id, + max_weight, + })); + let xcm = Xcm(instructions); + + >::send_xcm(Here, project_multilocation, xcm).map_err(|_| Error::::XcmFailed)?; + for origin in migration_origins { + Self::mark_single_migration_as_sent(origin); } + UnconfirmedMigrations::::insert(transact_response_query_id, migration_origins); + + Self::deposit_event(Event::::UserMigrationSent { user: participant.clone() }); } Ok(()) } + + pub fn do_user_migration_response( + location: MultiLocation, + query_id: xcm::v3::QueryId, + response: xcm::v3::Response, + ) -> DispatchResult { + use xcm::v3::prelude::*; + Ok(()) + } } // Helper functions @@ -2723,17 +2751,17 @@ impl Pallet { pub fn construct_migration_xcm_messages( user: [u8; 32], - migrations: Vec<(MigrationOrigin, MigrationInfo)>, + migrations: Vec<(MigrationOriginOf, MigrationInfo)>, max_message_size: u32, - ) -> Vec<(Vec>, Xcm<()>)> { + ) -> Vec<(Vec>, Xcm<()>)> { const MAX_WEIGHT: Weight = Weight::from_parts(20_000_000_000, 1_000_000); let _polimec_receiver_info = T::PolimecReceiverInfo::get(); // TODO: use the actual pallet index when the fields are not private anymore (https://github.com/paritytech/polkadot-sdk/pull/2231) let migrations_per_xcm = Self::migrations_per_xcm_message_allowed(max_message_size); - let mut output: Vec<(Vec>, Xcm<()>)> = Vec::new(); + let mut output: Vec<(Vec>, Xcm<()>)> = Vec::new(); for migrations in migrations.chunks(migrations_per_xcm as usize) { - let (migration_origins, migration_infos): (Vec>, Vec) = + let (migration_origins, migration_infos): (Vec>, Vec) = migrations.to_vec().into_iter().unzip(); let mut encoded_call = vec![51u8, 0]; encoded_call.extend_from_slice(user.encode().as_slice()); @@ -2753,4 +2781,32 @@ impl Pallet { // the problem is that we don't know the existing messages in the destination queue. So for now we assume all messages will succeed output } + + pub fn mark_single_migration_as_sent( + migration_origin: MigrationOriginOf, + ) { + match migration_origin { + MigrationOrigin::Evaluation { project_id, user, id } => { + Evaluations::::mutate((project_id, user, id), |maybe_evaluation| { + if let Some(evaluation) = maybe_evaluation { + evaluation.ct_migration_sent = true; + } + }); + }, + MigrationOrigin::Bid { project_id, user, id } => { + Bids::::mutate((project_id, user, id), |maybe_bid| { + if let Some(bid) = maybe_bid { + bid.ct_migration_sent = true; + } + }); + }, + MigrationOrigin::Contribution { project_id, user, id } => { + Contributions::::mutate((project_id, user, id), |maybe_contribution| { + if let Some(contribution) = maybe_contribution { + contribution.ct_migration_sent = true; + } + }); + }, + } + } } diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index fcefa0754..7c7115dba 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -240,6 +240,8 @@ pub type BidInfoOf = BidInfo< pub type ContributionInfoOf = ContributionInfo, AccountIdOf, BalanceOf, MultiplierOf, VestingInfoOf>; +pub type MigrationOriginOf = MigrationOrigin, ProjectIdOf>; + pub type BucketOf = Bucket, PriceOf>; pub type BondTypeOf = LockType>; pub type WeightInfoOf = ::WeightInfo; @@ -527,6 +529,10 @@ pub mod pallet { ContributionInfoOf, >; + #[pallet::storage] + /// Migrations sent and awaiting for confirmation + pub type UnconfirmedMigrations = StorageMap<_, Blake2_128Concat, QueryId, BoundedVec, ConstU32<100>>>; + #[pallet::event] #[pallet::generate_deposit(pub (super) fn deposit_event)] pub enum Event { @@ -1185,6 +1191,18 @@ pub mod pallet { let caller = ensure_signed(origin)?; Self::do_start_migration(&caller, project_id) } + + #[pallet::call_index(25)] + #[pallet::weight(Weight::from_parts(1000, 0))] + pub fn user_migration_response( + origin: OriginFor, + query_id: xcm::v3::QueryId, + response: xcm::v3::Response, + ) -> DispatchResult { + let location = ensure_response(::RuntimeOrigin::from(origin))?; + + Self::do_user_migration_response(location, query_id, response) + } } #[pallet::hooks] @@ -1321,7 +1339,6 @@ pub mod pallet { T::AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, ::RuntimeEvent: From> + TryInto> + Parameter + Member, - // AccountIdOf: Into< as OriginTrait>::AccountId> + sp_std::fmt::Debug, { fn default() -> Self { Self { starting_projects: vec![], phantom: PhantomData } diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index ecf5adabd..86257f636 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -726,39 +726,11 @@ pub mod inner_types { } #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] - pub enum MigrationOrigin { - Evaluation { project_id: ProjectIdOf, user: AccountIdOf, id: u32 }, - Bid { project_id: ProjectIdOf, user: AccountIdOf, id: u32 }, - Contribution { project_id: ProjectIdOf, user: AccountIdOf, id: u32 }, + pub enum MigrationOrigin { + Evaluation { project_id: ProjectId, user: AccountId, id: u32 }, + Bid { project_id: ProjectId, user: AccountId, id: u32 }, + Contribution { project_id: ProjectId, user: AccountId, id: u32 }, } - impl MigrationOrigin { - pub fn mark_as_sent(&self) { - match self { - MigrationOrigin::Evaluation { project_id, user, id } => { - Evaluations::::mutate((project_id, user, id), |maybe_evaluation| { - if let Some(evaluation) = maybe_evaluation { - evaluation.ct_migration_sent = true; - } - }); - }, - MigrationOrigin::Bid { project_id, user, id } => { - Bids::::mutate((project_id, user, id), |maybe_bid| { - if let Some(bid) = maybe_bid { - bid.ct_migration_sent = true; - } - }); - }, - MigrationOrigin::Contribution { project_id, user, id } => { - Contributions::::mutate((project_id, user, id), |maybe_contribution| { - if let Some(contribution) = maybe_contribution { - contribution.ct_migration_sent = true; - } - }); - }, - } - } - } - #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct MigrationInfo { contribution_token_amount: u128, diff --git a/pallets/polimec-receiver/src/lib.rs b/pallets/polimec-receiver/src/lib.rs index 656dfe3e9..e903e7be9 100644 --- a/pallets/polimec-receiver/src/lib.rs +++ b/pallets/polimec-receiver/src/lib.rs @@ -9,18 +9,17 @@ pub use pallet::*; #[frame_support::pallet] pub mod pallet { + use crate::MigrationInfo; use frame_support::{ dispatch::DispatchResultWithPostInfo, pallet_prelude::*, - traits::{Currency, ExistenceRequirement::KeepAlive}, + traits::{tokens::Balance, Currency, ExistenceRequirement::KeepAlive, VestingSchedule}, }; use frame_system::pallet_prelude::*; use polkadot_parachain::primitives::{Id as ParaId, Sibling}; use polkadot_runtime_parachains::origin::{ensure_parachain, Origin as ParachainOrigin}; use sp_runtime::traits::{AccountIdConversion, Convert, Zero}; use sp_std::prelude::*; - use frame_support::traits::{VestingSchedule, tokens::Balance}; - use crate::MigrationInfo; type MomentOf = <::Vesting as VestingSchedule<::AccountId>>::Moment; @@ -33,8 +32,8 @@ pub mod pallet { type PolimecParaId: Get; type RuntimeOrigin: IsType<::RuntimeOrigin> + Into::RuntimeOrigin>>; - type Vesting: VestingSchedule; - type Balances: Currency; + type Vesting: VestingSchedule; + type Balances: Currency; type Balance: Balance + From + MaybeSerializeDeserialize; type GenesisMoment: Get>; type MigrationInfoToPerBlockBalance: Convert; @@ -53,10 +52,7 @@ pub mod pallet { where T::AccountId: From<[u8; 32]>, { - MigrationsExecutedForUser { - user: T::AccountId, - migrations: Vec, - }, + MigrationsExecutedForUser { user: T::AccountId, migrations: Vec }, } #[pallet::error] @@ -94,10 +90,15 @@ pub mod pallet { migration.contribution_token_amount.into(), KeepAlive, )?; - T::Vesting::add_vesting_schedule(&user, migration.contribution_token_amount.into(), T::MigrationInfoToPerBlockBalance::convert(migration), T::GenesisMoment::get())?; + T::Vesting::add_vesting_schedule( + &user, + migration.contribution_token_amount.into(), + T::MigrationInfoToPerBlockBalance::convert(migration), + T::GenesisMoment::get(), + )?; } - Self::deposit_event(Event::MigrationsExecutedForUser{user, migrations}); + Self::deposit_event(Event::MigrationsExecutedForUser { user, migrations }); Ok(()) } From 85bdfb949446de202a7411023fde19f2aa81cba3 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 15 Nov 2023 10:20:08 +0100 Subject: [PATCH 026/212] save --- pallets/funding/src/functions.rs | 40 ++--------- pallets/funding/src/lib.rs | 6 +- pallets/funding/src/mock.rs | 112 +++++++++++++++++++++---------- pallets/funding/src/types.rs | 8 +-- runtimes/testnet/src/lib.rs | 47 +++++++++++++ 5 files changed, 139 insertions(+), 74 deletions(-) diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 44b27a950..d560399cd 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -2714,47 +2714,14 @@ impl Pallet { Ok(()) } - pub fn migrations_per_xcm_message_allowed(max_message_size: u32) -> u32 { - const MAX_WEIGHT: Weight = Weight::from_parts(20_000_000_000, 1_000_000); - - let one_migration_bytes = (0u128, 0u64).encode().len() as u32; - - // our encoded call starts with pallet index 51, and call index 0 - let mut encoded_call = vec![51u8, 0]; - let encoded_first_param = [0u8; 32].encode(); - let encoded_second_param = Vec::::new().encode(); - // we append the encoded parameters, with our migrations vec being empty for now - encoded_call.extend_from_slice(encoded_first_param.as_slice()); - encoded_call.extend_from_slice(encoded_second_param.as_slice()); - - let mut base_xcm_message: Xcm<()> = Xcm(vec![ - UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, - Transact { origin_kind: OriginKind::Native, require_weight_at_most: MAX_WEIGHT, call: encoded_call.into() }, - ]); - let xcm_size = base_xcm_message.encode().len(); - - let available_bytes_for_migration_per_message = max_message_size.saturating_sub(xcm_size as u32); - - let mut output = 0u32; - let mut current_migration_size = 0u32; - while current_migration_size < available_bytes_for_migration_per_message { - if current_migration_size + one_migration_bytes > available_bytes_for_migration_per_message { - break - } else { - current_migration_size += one_migration_bytes; - output += 1; - } - } - output - } pub fn construct_migration_xcm_messages( user: [u8; 32], migrations: Vec<(MigrationOriginOf, MigrationInfo)>, - max_message_size: u32, ) -> Vec<(Vec>, Xcm<()>)> { const MAX_WEIGHT: Weight = Weight::from_parts(20_000_000_000, 1_000_000); + let max_message_size = T::RequiredMaxMessageSize::get(); let _polimec_receiver_info = T::PolimecReceiverInfo::get(); // TODO: use the actual pallet index when the fields are not private anymore (https://github.com/paritytech/polkadot-sdk/pull/2231) let migrations_per_xcm = Self::migrations_per_xcm_message_allowed(max_message_size); @@ -2773,6 +2740,11 @@ impl Pallet { require_weight_at_most: MAX_WEIGHT, call: encoded_call.into(), }, + ReportTransactStatus(QueryResponseInfo { + destination: Parachain(POLIMEC_PARA_ID).into(), + query_id: 0, + max_weight: MAX_WEIGHT, + }), ]); output.push((migration_origins, xcm)); } diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 7c7115dba..8e2f7cd70 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -240,7 +240,7 @@ pub type BidInfoOf = BidInfo< pub type ContributionInfoOf = ContributionInfo, AccountIdOf, BalanceOf, MultiplierOf, VestingInfoOf>; -pub type MigrationOriginOf = MigrationOrigin, ProjectIdOf>; +pub type MigrationOriginOf = MigrationOrigin, ProjectIdOf, u32>; pub type BucketOf = Bucket, PriceOf>; pub type BondTypeOf = LockType>; @@ -428,6 +428,7 @@ pub mod pallet { type RequiredMaxCapacity: Get; /// max_message_size config required for the channel from polimec to the project type RequiredMaxMessageSize: Get; + type MaxMigrationsPerXcm: Get; } #[pallet::storage] @@ -531,7 +532,7 @@ pub mod pallet { #[pallet::storage] /// Migrations sent and awaiting for confirmation - pub type UnconfirmedMigrations = StorageMap<_, Blake2_128Concat, QueryId, BoundedVec, ConstU32<100>>>; + pub type UnconfirmedMigrations = StorageMap<_, Blake2_128Concat, QueryId, BoundedVec, T::MaxMigrationsPerXcm>>; #[pallet::event] #[pallet::generate_deposit(pub (super) fn deposit_event)] @@ -1467,3 +1468,4 @@ pub mod local_macros { } pub(crate) use unwrap_result_or_skip; } + diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 5ee53c625..450062796 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -318,57 +318,101 @@ impl pallet_linear_release::Config for TestRuntime { const MAX_VESTING_SCHEDULES: u32 = 32; } +pub fn migrations_per_xcm_message_allowed() -> u32 { + const MAX_WEIGHT: Weight = Weight::from_parts(20_000_000_000, 1_000_000); + + let one_migration_bytes = (0u128, 0u64).encode().len() as u32; + + // our encoded call starts with pallet index 51, and call index 0 + let mut encoded_call = vec![51u8, 0]; + let encoded_first_param = [0u8; 32].encode(); + let encoded_second_param = Vec::::new().encode(); + // we append the encoded parameters, with our migrations vec being empty for now + encoded_call.extend_from_slice(encoded_first_param.as_slice()); + encoded_call.extend_from_slice(encoded_second_param.as_slice()); + + let mut base_xcm_message: Xcm<()> = Xcm(vec![ + UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, + Transact { origin_kind: OriginKind::Native, require_weight_at_most: MAX_WEIGHT, call: encoded_call.into() }, + ReportTransactStatus(QueryResponseInfo { + destination: Parachain(POLIMEC_PARA_ID).into(), + query_id: 0, + max_weight, + }), + ]); + let xcm_size = base_xcm_message.encode().len(); + + let available_bytes_for_migration_per_message = RequiredMaxMessageSize::get().saturating_sub(xcm_size as u32); + + let mut output = 0u32; + let mut current_migration_size = 0u32; + while current_migration_size < available_bytes_for_migration_per_message { + if current_migration_size + one_migration_bytes > available_bytes_for_migration_per_message { + break + } else { + current_migration_size += one_migration_bytes; + output += 1; + } + } + + output +} + parameter_types! { pub MaxMessageSizeThresholds: (u32, u32) = (50000, 102_400); pub MaxCapacityThresholds: (u32, u32) = (8, 1000); pub RequiredMaxCapacity: u32 = 8; pub RequiredMaxMessageSize: u32 = 102_400; + pub MaxMigrationsPerXcm: u32 = migrations_per_xcm_message_allowed(); + } impl Config for TestRuntime { type AllPalletsWithoutSystem = AllPalletsWithoutSystem; - type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; - type Balance = Balance; + type RuntimeEvent = RuntimeEvent; type BlockNumber = BlockNumber; - type BlockNumberToBalance = ConvertInto; - type CandleAuctionDuration = CandleAuctionDuration; - type CommunityFundingDuration = CommunityRoundDuration; + type AccountId32Conversion = ConvertInto; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + type ProjectIdentifier = Identifier; + type Multiplier = Multiplier; + type Balance = Balance; + type Price = FixedU128; + type NativeCurrency = Balances; + type FundingCurrency = StatemintAssets; type ContributionTokenCurrency = LocalAssets; - type ContributionVesting = ConstU32<4>; - type DaysToBlocks = DaysToBlocks; - type EnglishAuctionDuration = EnglishAuctionDuration; + type PriceProvider = ConstPriceProvider; + type Randomness = RandomnessCollectiveFlip; + type StringLimit = ConstU32<64>; + type PreImageLimit = ConstU32<1024>; type EvaluationDuration = EvaluationDuration; - type EvaluationSuccessThreshold = EarlyEvaluationThreshold; - type EvaluatorSlash = EvaluatorSlash; - type FeeBrackets = FeeBrackets; - type FundingCurrency = StatemintAssets; - type ManualAcceptanceDuration = ManualAcceptanceDuration; + type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; + type EnglishAuctionDuration = EnglishAuctionDuration; + type CandleAuctionDuration = CandleAuctionDuration; + type CommunityFundingDuration = CommunityRoundDuration; + type RemainderFundingDuration = RemainderFundingDuration; + type PalletId = FundingPalletId; + type MaxProjectsToUpdatePerBlock = ConstU32<100>; + type MaxEvaluationsPerUser = ConstU32<4>; // Low value to simplify the tests type MaxBidsPerUser = ConstU32<4>; - type MaxCapacityThresholds = MaxCapacityThresholds; type MaxContributionsPerUser = ConstU32<4>; - type MaxEvaluationsPerUser = ConstU32<4>; - type MaxMessageSizeThresholds = MaxMessageSizeThresholds; - type MaxProjectsToUpdatePerBlock = ConstU32<100>; - type Multiplier = Multiplier; - type NativeCurrency = Balances; - type PalletId = FundingPalletId; + type ContributionVesting = ConstU32<4>; + type WeightInfo = weights::SubstrateWeight; + type FeeBrackets = FeeBrackets; + type EvaluationSuccessThreshold = EarlyEvaluationThreshold; + type Vesting = Vesting; + type ManualAcceptanceDuration = ManualAcceptanceDuration; + type SuccessToSettlementTime = SuccessToSettlementTime; + type EvaluatorSlash = EvaluatorSlash; + type TreasuryAccount = TreasuryAccount; + type DaysToBlocks = DaysToBlocks; + type BlockNumberToBalance = ConvertInto; type PolimecReceiverInfo = PolimecReceiverInfo; - type PreImageLimit = ConstU32<1024>; - type Price = FixedU128; - type PriceProvider = ConstPriceProvider; - type ProjectIdentifier = Identifier; - type Randomness = RandomnessCollectiveFlip; - type RemainderFundingDuration = RemainderFundingDuration; + type MaxMessageSizeThresholds = MaxMessageSizeThresholds; + type MaxCapacityThresholds = MaxCapacityThresholds; type RequiredMaxCapacity = RequiredMaxCapacity; type RequiredMaxMessageSize = RequiredMaxMessageSize; - type RuntimeCall = RuntimeCall; - type RuntimeEvent = RuntimeEvent; - type RuntimeOrigin = RuntimeOrigin; - type StringLimit = ConstU32<64>; - type SuccessToSettlementTime = SuccessToSettlementTime; - type TreasuryAccount = TreasuryAccount; - type Vesting = Vesting; - type WeightInfo = weights::SubstrateWeight; + type MaxMigrationsPerXcm = MaxMigrationsPerXcm; } // Build genesis storage according to the mock runtime. diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index 86257f636..6f34c1030 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -726,10 +726,10 @@ pub mod inner_types { } #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] - pub enum MigrationOrigin { - Evaluation { project_id: ProjectId, user: AccountId, id: u32 }, - Bid { project_id: ProjectId, user: AccountId, id: u32 }, - Contribution { project_id: ProjectId, user: AccountId, id: u32 }, + pub enum MigrationOrigin { + Evaluation { project_id: ProjectId, user: AccountId, id: Id }, + Bid { project_id: ProjectId, user: AccountId, id: Id }, + Contribution { project_id: ProjectId, user: AccountId, id: Id }, } #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct MigrationInfo { diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index c34a0b1f4..6deedbb0f 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -36,6 +36,7 @@ pub use parachains_common::{ Header, Index, Signature, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, MINUTES, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; +use parity_scale_codec::Encode; // Polkadot imports use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; @@ -54,6 +55,8 @@ use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; +use xcm::opaque::v3::Xcm; +use xcm::v3::{OriginKind, QueryResponseInfo, WeightLimit, Instruction::{Transact, UnpaidExecution, ReportTransactStatus}, Junction::Parachain}; // XCM Imports use polimec_xcm_executor::XcmExecutor; @@ -489,6 +492,48 @@ impl pallet_assets::Config for Runtime { type WeightInfo = (); } +const POLIMEC_PARACHAIN_ID: u32 = 3355; + +pub fn migrations_per_xcm_message_allowed() -> u32 { + const MAX_WEIGHT: Weight = Weight::from_parts(20_000_000_000, 1_000_000); + + let one_migration_bytes = (0u128, 0u64).encode().len() as u32; + + // our encoded call starts with pallet index 51, and call index 0 + let mut encoded_call = vec![51u8, 0]; + let encoded_first_param = [0u8; 32].encode(); + let encoded_second_param = Vec::::new().encode(); + // we append the encoded parameters, with our migrations vec being empty for now + encoded_call.extend_from_slice(encoded_first_param.as_slice()); + encoded_call.extend_from_slice(encoded_second_param.as_slice()); + + let mut base_xcm_message: Xcm = Xcm(vec![ + UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, + Transact { origin_kind: OriginKind::Native, require_weight_at_most: MAX_WEIGHT, call: encoded_call.into() }, + ReportTransactStatus(QueryResponseInfo { + destination: Parachain(POLIMEC_PARACHAIN_ID).into(), + query_id: 0, + max_weight, + }), + ]); + let xcm_size = base_xcm_message.encode().len(); + + let available_bytes_for_migration_per_message = RequiredMaxMessageSize::get().saturating_sub(xcm_size as u32); + + let mut output = 0u32; + let mut current_migration_size = 0u32; + while current_migration_size < available_bytes_for_migration_per_message { + if current_migration_size + one_migration_bytes > available_bytes_for_migration_per_message { + break + } else { + current_migration_size += one_migration_bytes; + output += 1; + } + } + + output +} + parameter_types! { pub TreasuryAccount: AccountId = [69u8; 32].into(); pub PolimecReceiverInfo: xcm::v3::PalletInfo = xcm::v3::PalletInfo::new( @@ -498,6 +543,7 @@ parameter_types! { pub MaxCapacityThresholds: (u32, u32) = (8, 1000); pub RequiredMaxCapacity: u32 = 8; pub RequiredMaxMessageSize: u32 = 102_400; + pub MaxMigrationsPerXcm: u32 = migrations_per_xcm_message_allowed(); } impl pallet_funding::Config for Runtime { type AccountId32Conversion = ConvertInto; @@ -544,6 +590,7 @@ impl pallet_funding::Config for Runtime { type TreasuryAccount = TreasuryAccount; type Vesting = LinearVesting; type WeightInfo = pallet_funding::weights::SubstrateWeight; + type MaxMigrationsPerXcm = (); } parameter_types! { From 1b4d8bb90f5d00c79d824b116d6cd754718fde02 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 15 Nov 2023 16:02:06 +0100 Subject: [PATCH 027/212] Migration for a single user working fully and tested --- Cargo.lock | 2 + integration-tests/Cargo.toml | 3 + integration-tests/src/tests/ct_migration.rs | 262 +++++++++++++++++-- pallets/funding/src/functions.rs | 268 +++++++++++++++----- pallets/funding/src/lib.rs | 39 ++- pallets/funding/src/mock.rs | 112 +++----- pallets/funding/src/types.rs | 46 +++- runtimes/testnet/src/lib.rs | 54 +--- 8 files changed, 545 insertions(+), 241 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5d1b3cb62..74baeae5c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4132,12 +4132,14 @@ dependencies = [ "pallet-im-online", "pallet-message-queue", "pallet-staking", + "pallet-vesting", "pallet-xcm", "parachain-info", "parachains-common", "parity-scale-codec", "penpal-runtime", "polimec-parachain-runtime", + "polimec-receiver", "polkadot-core-primitives", "polkadot-parachain", "polkadot-primitives", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index f267d7323..36e92bc19 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -19,6 +19,8 @@ parity-scale-codec = { workspace = true, features = [ ] } scale-info = { workspace = true, features = ["derive"] } +# Local +polimec-receiver.workspace = true frame-system.workspace = true frame-support.workspace = true @@ -54,6 +56,7 @@ polkadot-runtime-constants.workspace = true pallet-staking.workspace = true pallet-message-queue.workspace = true +pallet-vesting.workspace = true # Runtimes polkadot-runtime.workspace = true diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index 4944729d9..76d9a05c1 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -1,7 +1,8 @@ use crate::*; -use pallet_funding::{BidInfoOf, ContributionInfoOf, EvaluationInfoOf, RewardOrSlash}; +use pallet_funding::{AcceptedFundingAsset, BidInfoOf, ContributionInfoOf, EvaluationInfoOf, MigrationStatus, MultiplierOf, RewardOrSlash}; use polimec_parachain_runtime::PolimecFunding; use sp_runtime::{FixedPointNumber, Perquintill}; +use pallet_funding::traits::VestingDurationCalculation; use tests::defaults::*; #[test] @@ -114,27 +115,21 @@ fn migration_is_sent() { // Migrate one user's contribution tokens. He evaluated, bid, and contributed Polimec::execute_with(|| { assert_ok!(PolimecFunding::do_migrate_one_participant(eval_1(), project_id, eval_1())); - println!("Polimec events:"); - dbg!(Polimec::events()); + let query_id = pallet_funding::UnconfirmedMigrations::::iter_keys().next().unwrap(); let mut user_evaluations = pallet_funding::Evaluations::::iter_prefix_values((project_id, eval_1())); let mut user_bids = pallet_funding::Bids::::iter_prefix_values((project_id, eval_1())); let mut user_contributions = pallet_funding::Contributions::::iter_prefix_values((project_id, eval_1())); - assert!(user_evaluations.all(|evaluation| evaluation.ct_migration_sent)); - assert!(user_bids.all(|bid| bid.ct_migration_sent)); - assert!(user_contributions.all(|contribution| contribution.ct_migration_sent)); - }); - - Penpal::execute_with(|| { - println!("Penpal events:"); - dbg!(Penpal::events()); + assert!(user_evaluations.all(|evaluation| evaluation.ct_migration_status == MigrationStatus::Sent(query_id))); + assert!(user_bids.all(|bid| bid.ct_migration_status == MigrationStatus::Sent(query_id))); + assert!(user_contributions.all(|contribution| contribution.ct_migration_status == MigrationStatus::Sent(query_id))); }); } #[test] -fn migration_is_executed_on_project() { +fn migration_is_executed_on_project_and_confirmed_on_polimec() { let mut inst = IntegrationInstantiator::new(None); let project_id = Polimec::execute_with(|| { inst.create_finished_project( @@ -180,11 +175,6 @@ fn migration_is_executed_on_project() { assert_ok!(PolimecFunding::do_handle_channel_accepted(channel_accepted_message)); inst.advance_time(::SuccessToSettlementTime::get() + 1u32).unwrap(); - let project_details = pallet_funding::ProjectsDetails::::get(project_id).unwrap(); - dbg!(project_details.evaluation_round_info.evaluators_outcome); - let evaluations = - pallet_funding::Evaluations::::iter_prefix_values((project_id,)).collect::>(); - dbg!(evaluations); }); // Migration is ready @@ -193,23 +183,249 @@ fn migration_is_executed_on_project() { assert!(project_details.migration_readiness_check.unwrap().is_ready()) }); + let pre_migration_balance = Penpal::account_data_of(eval_1()); + // Migrate is sent - Polimec::execute_with(|| { + let migrated_ct_amount = Polimec::execute_with(|| { assert_ok!(PolimecFunding::do_migrate_one_participant(eval_1(), project_id, eval_1())); - println!("Polimec events:"); - dbg!(Polimec::events()); + let (query_id, migrations) = pallet_funding::UnconfirmedMigrations::::iter().next().unwrap(); + let mut user_evaluations = pallet_funding::Evaluations::::iter_prefix_values((project_id, eval_1())); let mut user_bids = pallet_funding::Bids::::iter_prefix_values((project_id, eval_1())); let mut user_contributions = pallet_funding::Contributions::::iter_prefix_values((project_id, eval_1())); - assert!(user_evaluations.all(|evaluation| evaluation.ct_migration_sent)); - assert!(user_bids.all(|bid| bid.ct_migration_sent)); - assert!(user_contributions.all(|contribution| contribution.ct_migration_sent)); + let evaluation_ct_amount = user_evaluations.map(|evaluation| { + assert_eq!(evaluation.ct_migration_status, MigrationStatus::Sent(query_id)); + if let Some(RewardOrSlash::Reward(amount)) = evaluation.rewarded_or_slashed { + amount + } else { + panic!("should be rewarded") + } + }).sum::(); + let bid_ct_amount = user_bids.map(|bid| { + assert_eq!(bid.ct_migration_status, MigrationStatus::Sent(query_id)); + bid.final_ct_amount + }).sum::(); + let contribution_ct_amount = user_contributions.map(|contribution| { + assert_eq!(contribution.ct_migration_status, MigrationStatus::Sent(query_id)); + contribution.ct_amount + }).sum::(); + + evaluation_ct_amount + bid_ct_amount + contribution_ct_amount + + }); + + + Penpal::execute_with(|| { + assert_expected_events!( + Penpal, + vec![ + PenpalEvent::PolimecReceiver(polimec_receiver::Event::MigrationsExecutedForUser{user, ..}) => { + user: *user == eval_1(), + }, + ] + ); + + dbg!(Penpal::events()); + }); + + // Balance is there for the user after vesting (Multiplier 1, so no vesting) + let post_migration_balance = Penpal::account_data_of(eval_1()); + dbg!(migrated_ct_amount); + dbg!(pre_migration_balance.clone()); + dbg!(post_migration_balance.clone()); + assert_eq!(post_migration_balance.free - pre_migration_balance.free, migrated_ct_amount); + + Polimec::execute_with(|| { + let mut user_evaluations = + pallet_funding::Evaluations::::iter_prefix_values((project_id, eval_1())); + let mut user_bids = pallet_funding::Bids::::iter_prefix_values((project_id, eval_1())); + let mut user_contributions = + pallet_funding::Contributions::::iter_prefix_values((project_id, eval_1())); + + assert!(user_evaluations.all(|bid| bid.ct_migration_status == MigrationStatus::Confirmed)); + assert!(user_bids.all(|bid| bid.ct_migration_status == MigrationStatus::Confirmed)); + assert!(user_contributions.all(|contribution| contribution.ct_migration_status == MigrationStatus::Confirmed)); + + assert_expected_events!( + Polimec, + vec![ + PolimecEvent::PolimecFunding(pallet_funding::Event::MigrationsConfirmed{project_id, ..}) => { + project_id: project_id == project_id, + }, + ] + ); + }); +} + +#[test] +fn vesting_over_several_blocks_on_project() { + let mut inst = IntegrationInstantiator::new(None); + let mut bids = Vec::new(); + let mut contributions = Vec::new(); + let multiplier_for_vesting = MultiplierOf::::try_from(10u8).unwrap(); + + bids.push(BidParams { + bidder: buyer_1(), + amount: 2_000 * ASSET_UNIT, + price: 12u128.into(), + multiplier: MultiplierOf::::try_from(10u8).unwrap(), + asset: AcceptedFundingAsset::USDT, + }); + bids.push(BidParams { + bidder: bidder_1(), + amount: 20_000 * ASSET_UNIT, + price: 10u128.into(), + multiplier: multiplier_for_vesting, + asset: AcceptedFundingAsset::USDT, + }); + bids.push(BidParams { + bidder: bidder_2(), + amount: 12_000 * ASSET_UNIT, + price: 11u128.into(), + multiplier: MultiplierOf::::try_from(10u8).unwrap(), + asset: AcceptedFundingAsset::USDT, + }); + + contributions.push(ContributionParams { + contributor: buyer_1(), + amount: 10_250 * ASSET_UNIT, + multiplier: MultiplierOf::::try_from(1u8).unwrap(), + asset: AcceptedFundingAsset::USDT, + }); + contributions.push(ContributionParams { + contributor: buyer_2(), + amount: 5000 * ASSET_UNIT, + multiplier: MultiplierOf::::try_from(1u8).unwrap(), + asset: AcceptedFundingAsset::USDT, + }); + contributions.push(ContributionParams { + contributor: buyer_3(), + amount: 30000 * ASSET_UNIT, + multiplier: MultiplierOf::::try_from(1u8).unwrap(), + asset: AcceptedFundingAsset::USDT, + }); + + let project_id = Polimec::execute_with(|| { + inst.create_finished_project( + default_project(issuer(), 0), + issuer(), + default_evaluations(), + bids, + contributions, + vec![], + ) + }); + let penpal_sov_acc = PolkadotRelay::sovereign_account_id_of(Parachain(Penpal::para_id().into()).into()); + PolkadotRelay::fund_accounts(vec![(penpal_sov_acc, 100_0_000_000_000u128)]); + + // Mock HRMP establishment + Polimec::execute_with(|| { + assert_ok!(PolimecFunding::do_set_para_id_for_project(&issuer(), project_id, ParaId::from(6969u32))); + + let open_channel_message = xcm::v3::opaque::Instruction::HrmpNewChannelOpenRequest { + sender: 6969, + max_message_size: 102_300, + max_capacity: 1000, + }; + assert_ok!(PolimecFunding::do_handle_channel_open_request(open_channel_message)); + + let channel_accepted_message = xcm::v3::opaque::Instruction::HrmpChannelAccepted { recipient: 6969u32 }; + assert_ok!(PolimecFunding::do_handle_channel_accepted(channel_accepted_message)); + + inst.advance_time(::SuccessToSettlementTime::get() + 1u32).unwrap(); + }); + + // Migration is ready + Polimec::execute_with(|| { + let project_details = pallet_funding::ProjectsDetails::::get(project_id).unwrap(); + assert!(project_details.migration_readiness_check.unwrap().is_ready()) }); + let pre_migration_balance = Penpal::account_data_of(buyer_1()); + + // Migrate is sent + let migrated_ct_amount = Polimec::execute_with(|| { + assert_ok!(PolimecFunding::do_migrate_one_participant(buyer_1(), project_id, buyer_1())); + let (query_id, migrations) = pallet_funding::UnconfirmedMigrations::::iter().next().unwrap(); + + let mut user_evaluations = + pallet_funding::Evaluations::::iter_prefix_values((project_id, buyer_1())); + let mut user_bids = pallet_funding::Bids::::iter_prefix_values((project_id, buyer_1())); + let mut user_contributions = + pallet_funding::Contributions::::iter_prefix_values((project_id, buyer_1())); + + let evaluation_ct_amount = user_evaluations.map(|evaluation| { + assert_eq!(evaluation.ct_migration_status, MigrationStatus::Sent(query_id)); + if let Some(RewardOrSlash::Reward(amount)) = evaluation.rewarded_or_slashed { + amount + } else { + panic!("should be rewarded") + } + }).sum::(); + let bid_ct_amount = user_bids.map(|bid| { + assert_eq!(bid.ct_migration_status, MigrationStatus::Sent(query_id)); + bid.final_ct_amount + }).sum::(); + let contribution_ct_amount = user_contributions.map(|contribution| { + assert_eq!(contribution.ct_migration_status, MigrationStatus::Sent(query_id)); + contribution.ct_amount + }).sum::(); + + evaluation_ct_amount + bid_ct_amount + contribution_ct_amount + + }); + + Penpal::execute_with(|| { + assert_expected_events!( + Penpal, + vec![ + PenpalEvent::PolimecReceiver(polimec_receiver::Event::MigrationsExecutedForUser{user, ..}) => { + user: *user == buyer_1(), + }, + ] + ); + dbg!(Penpal::events()); }); + + // Balance is there for the user after vesting (Multiplier 1, so no vesting) + let post_migration_balance = Penpal::account_data_of(buyer_1()); + dbg!(migrated_ct_amount); + dbg!(pre_migration_balance.clone()); + dbg!(post_migration_balance.clone()); + + Polimec::execute_with(|| { + let mut user_evaluations = + pallet_funding::Evaluations::::iter_prefix_values((project_id, buyer_1())); + let mut user_bids = pallet_funding::Bids::::iter_prefix_values((project_id, buyer_1())); + let mut user_contributions = + pallet_funding::Contributions::::iter_prefix_values((project_id, buyer_1())); + + assert!(user_evaluations.all(|bid| bid.ct_migration_status == MigrationStatus::Confirmed)); + assert!(user_bids.all(|bid| bid.ct_migration_status == MigrationStatus::Confirmed)); + assert!(user_contributions.all(|contribution| contribution.ct_migration_status == MigrationStatus::Confirmed)); + + assert_expected_events!( + Polimec, + vec![ + PolimecEvent::PolimecFunding(pallet_funding::Event::MigrationsConfirmed{project_id, ..}) => { + project_id: project_id == project_id, + }, + ] + ); + }); + + Penpal::execute_with(|| { + let unblock_time: u32 = multiplier_for_vesting.calculate_vesting_duration::(); + PenpalSystem::set_block_number(unblock_time + 1u32); + assert_ok!(pallet_vesting::Pallet::::vest(PenpalOrigin::signed(buyer_1()))); + }); + + let post_vest_balance = Penpal::account_data_of(buyer_1()); + dbg!(post_vest_balance); } + diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index d560399cd..d3f931adc 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -22,6 +22,7 @@ use frame_support::{ dispatch::DispatchResult, ensure, pallet_prelude::*, + parameter_types, traits::{ fungible::MutateHold as FungibleMutateHold, fungibles::{metadata::Mutate as MetadataMutate, Create, Inspect, Mutate as FungiblesMutate}, @@ -36,6 +37,7 @@ use sp_arithmetic::{ }; use sp_runtime::traits::Convert; use sp_std::marker::PhantomData; +use xcm::v3::MaxDispatchErrorLen; use crate::{Call::start_bid_vesting_schedule_for, ProjectStatus::FundingSuccessful}; use polimec_traits::ReleaseSchedule; @@ -784,8 +786,7 @@ impl Pallet { late_usd_amount, when: now, rewarded_or_slashed: None, - ct_migration_sent: false, - ct_migration_confirmed: false, + ct_migration_status: MigrationStatus::NotStarted, }; // * Update Storage * @@ -949,8 +950,7 @@ impl Pallet { when: now, funds_released: false, ct_minted: false, - ct_migration_sent: false, - ct_migration_confirmed: false, + ct_migration_status: MigrationStatus::NotStarted, }; // * Update storage * @@ -1062,8 +1062,7 @@ impl Pallet { plmc_vesting_info: None, funds_released: false, ct_minted: false, - ct_migration_sent: false, - ct_migration_confirmed: false, + ct_migration_status: MigrationStatus::NotStarted, }; // * Update storage * @@ -2055,11 +2054,19 @@ impl Pallet { fun: Fungible(amount), } if amount >= ct_sold_as_u128 && pid == u32::from(para_id) => { migration_check.holding_check.1 = CheckOutcome::Passed; - Self::deposit_event(Event::::MigrationCheckResponseAccepted { query_id, response }); + Self::deposit_event(Event::::MigrationCheckResponseAccepted { + project_id, + query_id, + response, + }); }, _ => { migration_check.holding_check.1 = CheckOutcome::Failed; - Self::deposit_event(Event::::MigrationCheckResponseRejected { query_id, response }); + Self::deposit_event(Event::::MigrationCheckResponseRejected { + project_id, + query_id, + response, + }); }, } }, @@ -2070,10 +2077,10 @@ impl Pallet { ) => if pallets_info.len() == 1 && pallets_info[0] == T::PolimecReceiverInfo::get() { migration_check.pallet_check.1 = CheckOutcome::Passed; - Self::deposit_event(Event::::MigrationCheckResponseAccepted { query_id, response }); + Self::deposit_event(Event::::MigrationCheckResponseAccepted { project_id, query_id, response }); } else { migration_check.pallet_check.1 = CheckOutcome::Failed; - Self::deposit_event(Event::::MigrationCheckResponseRejected { query_id, response }); + Self::deposit_event(Event::::MigrationCheckResponseRejected { project_id, query_id, response }); }, _ => return Err(Error::::NotAllowed.into()), }; @@ -2108,12 +2115,16 @@ impl Pallet { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let migration_readiness_check = project_details.migration_readiness_check.ok_or(Error::::NotAllowed)?; - let evaluations = Evaluations::::iter_prefix_values((project_id, participant.clone())) - .filter(|evaluation| evaluation.ct_migration_sent == false); + let evaluations = + Evaluations::::iter_prefix_values((project_id, participant.clone())).filter(|evaluation| { + matches!(evaluation.ct_migration_status, MigrationStatus::NotStarted | MigrationStatus::Failed(_)) + }); let bids = Bids::::iter_prefix_values((project_id, participant.clone())) - .filter(|bid| bid.ct_migration_sent == false); - let contributions = Contributions::::iter_prefix_values((project_id, participant.clone())) - .filter(|contribution| contribution.ct_migration_sent == false); + .filter(|bid| matches!(bid.ct_migration_status, MigrationStatus::NotStarted | MigrationStatus::Failed(_))); + let contributions = + Contributions::::iter_prefix_values((project_id, participant.clone())).filter(|contribution| { + matches!(contribution.ct_migration_status, MigrationStatus::NotStarted | MigrationStatus::Failed(_)) + }); let max_message_size = T::RequiredMaxMessageSize::get(); let project_para_id = project_details.parachain_id.ok_or(Error::::ImpossibleState)?; let now = >::block_number(); @@ -2129,8 +2140,7 @@ impl Pallet { let multiplier = MultiplierOf::::try_from(1u8).map_err(|_| Error::::BadConversion)?; let vesting_duration = multiplier.calculate_vesting_duration::(); let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); - let migration_origin = - MigrationOrigin::Evaluation { project_id, user: evaluation.evaluator, id: evaluation.id }; + let migration_origin = MigrationOrigin::Evaluation { user: evaluation.evaluator, id: evaluation.id }; let migration_info: MigrationInfo = (ct_amount.into(), vesting_duration_local_type.into()).into(); migrations.push((migration_origin, migration_info)); } @@ -2139,7 +2149,7 @@ impl Pallet { let vesting_duration = contribution.multiplier.calculate_vesting_duration::(); let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); let migration_origin = - MigrationOrigin::Contribution { project_id, user: contribution.contributor, id: contribution.id }; + MigrationOrigin::Contribution { user: contribution.contributor, id: contribution.id }; let migration_info: MigrationInfo = (contribution.ct_amount.into(), vesting_duration_local_type.into()).into(); migrations.push((migration_origin, migration_info)); @@ -2147,21 +2157,19 @@ impl Pallet { for bid in bids { let vesting_duration = bid.multiplier.calculate_vesting_duration::(); let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); - let migration_origin = MigrationOrigin::Bid { project_id, user: bid.bidder, id: bid.id }; + let migration_origin = MigrationOrigin::Bid { user: bid.bidder, id: bid.id }; let migration_info: MigrationInfo = (bid.final_ct_amount.into(), vesting_duration_local_type.into()).into(); migrations.push((migration_origin, migration_info)); } - let constructed_migrations = Self::construct_migration_xcm_messages( - T::AccountId32Conversion::convert(participant.clone()), - migrations, - max_message_size, - ); + let constructed_migrations = + Self::construct_migration_xcm_messages(T::AccountId32Conversion::convert(participant.clone()), migrations); for (migration_origins, xcm) in constructed_migrations { let project_multilocation = MultiLocation { parents: 1, interior: X1(Parachain(project_para_id.into())) }; + let project_migration_origins = ProjectMigrationOriginsOf:: { project_id, migration_origins }; let call: ::RuntimeCall = - Call::user_migration_response { query_id: Default::default(), response: Default::default() }.into(); + Call::confirm_migrations { query_id: Default::default(), response: Default::default() }.into(); let transact_response_query_id = pallet_xcm::Pallet::::new_notify_query( project_multilocation.clone(), call.into(), @@ -2173,30 +2181,52 @@ impl Pallet { let mut instructions = xcm.into_inner(); instructions.push(ReportTransactStatus(QueryResponseInfo { - destination: Parachain(POLIMEC_PARA_ID).into(), + destination: ParentThen(X1(Parachain(POLIMEC_PARA_ID))).into(), query_id: transact_response_query_id, max_weight, })); let xcm = Xcm(instructions); >::send_xcm(Here, project_multilocation, xcm).map_err(|_| Error::::XcmFailed)?; - for origin in migration_origins { - Self::mark_single_migration_as_sent(origin); - } - UnconfirmedMigrations::::insert(transact_response_query_id, migration_origins); + Self::mark_migrations_as_sent(project_migration_origins.clone(), transact_response_query_id); + UnconfirmedMigrations::::insert(transact_response_query_id, project_migration_origins); - Self::deposit_event(Event::::UserMigrationSent { user: participant.clone() }); + Self::deposit_event(Event::::UserMigrationSent { project_id, caller: caller.clone(), participant: participant.clone() }); } Ok(()) } - pub fn do_user_migration_response( + pub fn do_confirm_migrations( location: MultiLocation, - query_id: xcm::v3::QueryId, - response: xcm::v3::Response, + query_id: QueryId, + response: Response, ) -> DispatchResult { use xcm::v3::prelude::*; - Ok(()) + let unconfirmed_migrations = UnconfirmedMigrations::::take(query_id).ok_or(Error::::NotAllowed)?; + let project_id = unconfirmed_migrations.project_id; + let para_id = if let MultiLocation { parents: 1, interior: X1(Parachain(para_id)) } = location { + ParaId::from(para_id) + } else { + return Err(Error::::NotAllowed.into()) + }; + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; + + ensure!(project_details.parachain_id == Some(para_id), Error::::NotAllowed); + + match response { + Response::DispatchResult(MaybeErrorCode::Success) => { + Self::mark_migrations_as_confirmed(unconfirmed_migrations); + Self::deposit_event(Event::MigrationsConfirmed { project_id, query_id }); + Ok(()) + }, + Response::DispatchResult(MaybeErrorCode::Error(e)) | + Response::DispatchResult(MaybeErrorCode::TruncatedError(e)) => { + Self::mark_migrations_as_failed(unconfirmed_migrations, e); + Self::deposit_event(Event::MigrationsFailed { project_id, query_id }); + Ok(()) + }, + _ => Err(Error::::NotAllowed.into()), + } } } @@ -2714,20 +2744,57 @@ impl Pallet { Ok(()) } + pub fn migrations_per_xcm_message_allowed() -> u32 { + const MAX_WEIGHT: Weight = Weight::from_parts(20_000_000_000, 1_000_000); + + let one_migration_bytes = (0u128, 0u64).encode().len() as u32; + + // our encoded call starts with pallet index 51, and call index 0 + let mut encoded_call = vec![51u8, 0]; + let encoded_first_param = [0u8; 32].encode(); + let encoded_second_param = Vec::::new().encode(); + // we append the encoded parameters, with our migrations vec being empty for now + encoded_call.extend_from_slice(encoded_first_param.as_slice()); + encoded_call.extend_from_slice(encoded_second_param.as_slice()); + + let mut base_xcm_message: Xcm<()> = Xcm(vec![ + UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, + Transact { origin_kind: OriginKind::Native, require_weight_at_most: MAX_WEIGHT, call: encoded_call.into() }, + ReportTransactStatus(QueryResponseInfo { + destination: Parachain(3355).into(), + query_id: 0, + max_weight: MAX_WEIGHT, + }), + ]); + let xcm_size = base_xcm_message.encode().len(); + + let available_bytes_for_migration_per_message = + T::RequiredMaxMessageSize::get().saturating_sub(xcm_size as u32); + + let mut output = 0u32; + let mut current_migration_size = 0u32; + while current_migration_size < available_bytes_for_migration_per_message { + if current_migration_size + one_migration_bytes > available_bytes_for_migration_per_message { + break + } else { + current_migration_size += one_migration_bytes; + output += 1; + } + } + output + } pub fn construct_migration_xcm_messages( user: [u8; 32], migrations: Vec<(MigrationOriginOf, MigrationInfo)>, - ) -> Vec<(Vec>, Xcm<()>)> { + ) -> Vec<(BoundedVec, MaxMigrationsPerXcm>, Xcm<()>)> { const MAX_WEIGHT: Weight = Weight::from_parts(20_000_000_000, 1_000_000); - let max_message_size = T::RequiredMaxMessageSize::get(); let _polimec_receiver_info = T::PolimecReceiverInfo::get(); // TODO: use the actual pallet index when the fields are not private anymore (https://github.com/paritytech/polkadot-sdk/pull/2231) - let migrations_per_xcm = Self::migrations_per_xcm_message_allowed(max_message_size); - let mut output: Vec<(Vec>, Xcm<()>)> = Vec::new(); + let mut output = Vec::new(); - for migrations in migrations.chunks(migrations_per_xcm as usize) { + for migrations in migrations.chunks(MaxMigrationsPerXcm::::get() as usize) { let (migration_origins, migration_infos): (Vec>, Vec) = migrations.to_vec().into_iter().unzip(); let mut encoded_call = vec![51u8, 0]; @@ -2740,13 +2807,9 @@ impl Pallet { require_weight_at_most: MAX_WEIGHT, call: encoded_call.into(), }, - ReportTransactStatus(QueryResponseInfo { - destination: Parachain(POLIMEC_PARA_ID).into(), - query_id: 0, - max_weight: MAX_WEIGHT, - }), + // ReportTransactStatus should be appended here after knowing the query_id ]); - output.push((migration_origins, xcm)); + output.push((migration_origins.try_into().expect("already split into max length chunks"), xcm)); } // TODO: we probably want to ensure we dont build too many messages to overflow the queue. Which we know from the parameter `T::RequiredMaxCapacity`. @@ -2754,31 +2817,96 @@ impl Pallet { output } - pub fn mark_single_migration_as_sent( - migration_origin: MigrationOriginOf, + pub fn mark_migrations_as_sent(project_migration_origins: ProjectMigrationOriginsOf, query_id: QueryId) { + let project_id = project_migration_origins.project_id; + let migration_origins = project_migration_origins.migration_origins; + for origin in migration_origins { + match origin { + MigrationOrigin::Evaluation { user, id } => { + Evaluations::::mutate((project_id, user, id), |maybe_evaluation| { + if let Some(evaluation) = maybe_evaluation { + evaluation.ct_migration_status = MigrationStatus::Sent(query_id); + } + }); + }, + MigrationOrigin::Bid { user, id } => { + Bids::::mutate((project_id, user, id), |maybe_bid| { + if let Some(bid) = maybe_bid { + bid.ct_migration_status = MigrationStatus::Sent(query_id); + } + }); + }, + MigrationOrigin::Contribution { user, id } => { + Contributions::::mutate((project_id, user, id), |maybe_contribution| { + if let Some(contribution) = maybe_contribution { + contribution.ct_migration_status = MigrationStatus::Sent(query_id); + } + }); + }, + } + } + } + + pub fn mark_migrations_as_confirmed(project_migration_origins: ProjectMigrationOriginsOf) { + let project_id = project_migration_origins.project_id; + let migration_origins = project_migration_origins.migration_origins; + for origin in migration_origins { + match origin { + MigrationOrigin::Evaluation { user, id } => { + Evaluations::::mutate((project_id, user, id), |maybe_evaluation| { + if let Some(evaluation) = maybe_evaluation { + evaluation.ct_migration_status = MigrationStatus::Confirmed; + } + }); + }, + MigrationOrigin::Bid { user, id } => { + Bids::::mutate((project_id, user, id), |maybe_bid| { + if let Some(bid) = maybe_bid { + bid.ct_migration_status = MigrationStatus::Confirmed; + } + }); + }, + MigrationOrigin::Contribution { user, id } => { + Contributions::::mutate((project_id, user, id), |maybe_contribution| { + if let Some(contribution) = maybe_contribution { + contribution.ct_migration_status = MigrationStatus::Confirmed; + } + }); + }, + } + } + } + + pub fn mark_migrations_as_failed( + project_migration_origins: ProjectMigrationOriginsOf, + error: BoundedVec, ) { - match migration_origin { - MigrationOrigin::Evaluation { project_id, user, id } => { - Evaluations::::mutate((project_id, user, id), |maybe_evaluation| { - if let Some(evaluation) = maybe_evaluation { - evaluation.ct_migration_sent = true; - } - }); - }, - MigrationOrigin::Bid { project_id, user, id } => { - Bids::::mutate((project_id, user, id), |maybe_bid| { - if let Some(bid) = maybe_bid { - bid.ct_migration_sent = true; - } - }); - }, - MigrationOrigin::Contribution { project_id, user, id } => { - Contributions::::mutate((project_id, user, id), |maybe_contribution| { - if let Some(contribution) = maybe_contribution { - contribution.ct_migration_sent = true; - } - }); - }, + let project_id = project_migration_origins.project_id; + let migration_origins = project_migration_origins.migration_origins; + for origin in migration_origins { + match origin { + MigrationOrigin::Evaluation { user, id } => { + Evaluations::::mutate((project_id, user, id), |maybe_evaluation| { + if let Some(evaluation) = maybe_evaluation { + evaluation.ct_migration_status = MigrationStatus::Failed(error.clone()); + } + }); + }, + MigrationOrigin::Bid { user, id } => { + Bids::::mutate((project_id, user, id), |maybe_bid| { + if let Some(bid) = maybe_bid { + bid.ct_migration_status = MigrationStatus::Failed(error.clone()); + } + }); + }, + MigrationOrigin::Contribution { user, id } => { + Contributions::::mutate((project_id, user, id), |maybe_contribution| { + if let Some(contribution) = maybe_contribution { + contribution.ct_migration_status = MigrationStatus::Failed(error.clone()); + } + }); + }, + } } } } diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 8e2f7cd70..d4c4477e3 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -240,7 +240,9 @@ pub type BidInfoOf = BidInfo< pub type ContributionInfoOf = ContributionInfo, AccountIdOf, BalanceOf, MultiplierOf, VestingInfoOf>; -pub type MigrationOriginOf = MigrationOrigin, ProjectIdOf, u32>; +pub type MigrationOriginOf = MigrationOrigin, u32>; +pub type ProjectMigrationOriginsOf = + ProjectMigrationOrigins, BoundedVec, MaxMigrationsPerXcm>>; pub type BucketOf = Bucket, PriceOf>; pub type BondTypeOf = LockType>; @@ -428,7 +430,6 @@ pub mod pallet { type RequiredMaxCapacity: Get; /// max_message_size config required for the channel from polimec to the project type RequiredMaxMessageSize: Get; - type MaxMigrationsPerXcm: Get; } #[pallet::storage] @@ -532,7 +533,7 @@ pub mod pallet { #[pallet::storage] /// Migrations sent and awaiting for confirmation - pub type UnconfirmedMigrations = StorageMap<_, Blake2_128Concat, QueryId, BoundedVec, T::MaxMigrationsPerXcm>>; + pub type UnconfirmedMigrations = StorageMap<_, Blake2_128Concat, QueryId, ProjectMigrationOriginsOf>; #[pallet::event] #[pallet::generate_deposit(pub (super) fn deposit_event)] @@ -790,19 +791,30 @@ pub mod pallet { caller: T::AccountId, }, MigrationCheckResponseAccepted { - query_id: xcm::v3::QueryId, - response: xcm::v3::Response, + project_id: ProjectIdOf, + query_id: QueryId, + response: Response, }, MigrationCheckResponseRejected { - query_id: xcm::v3::QueryId, - response: xcm::v3::Response, + project_id: ProjectIdOf, + query_id: QueryId, + response: Response, }, MigrationStarted { project_id: T::ProjectIdentifier, }, - UserMigrationSent { - user: T::AccountId, + project_id: ProjectIdOf, + caller: AccountIdOf, + participant: AccountIdOf, + }, + MigrationsConfirmed { + project_id: ProjectIdOf, + query_id: QueryId, + }, + MigrationsFailed { + project_id: ProjectIdOf, + query_id: QueryId, }, } @@ -1195,14 +1207,14 @@ pub mod pallet { #[pallet::call_index(25)] #[pallet::weight(Weight::from_parts(1000, 0))] - pub fn user_migration_response( + pub fn confirm_migrations( origin: OriginFor, - query_id: xcm::v3::QueryId, - response: xcm::v3::Response, + query_id: QueryId, + response: Response, ) -> DispatchResult { let location = ensure_response(::RuntimeOrigin::from(origin))?; - Self::do_user_migration_response(location, query_id, response) + Self::do_confirm_migrations(location, query_id, response) } } @@ -1468,4 +1480,3 @@ pub mod local_macros { } pub(crate) use unwrap_result_or_skip; } - diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 450062796..7977d5cc4 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -318,101 +318,61 @@ impl pallet_linear_release::Config for TestRuntime { const MAX_VESTING_SCHEDULES: u32 = 32; } -pub fn migrations_per_xcm_message_allowed() -> u32 { - const MAX_WEIGHT: Weight = Weight::from_parts(20_000_000_000, 1_000_000); - - let one_migration_bytes = (0u128, 0u64).encode().len() as u32; - - // our encoded call starts with pallet index 51, and call index 0 - let mut encoded_call = vec![51u8, 0]; - let encoded_first_param = [0u8; 32].encode(); - let encoded_second_param = Vec::::new().encode(); - // we append the encoded parameters, with our migrations vec being empty for now - encoded_call.extend_from_slice(encoded_first_param.as_slice()); - encoded_call.extend_from_slice(encoded_second_param.as_slice()); - - let mut base_xcm_message: Xcm<()> = Xcm(vec![ - UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, - Transact { origin_kind: OriginKind::Native, require_weight_at_most: MAX_WEIGHT, call: encoded_call.into() }, - ReportTransactStatus(QueryResponseInfo { - destination: Parachain(POLIMEC_PARA_ID).into(), - query_id: 0, - max_weight, - }), - ]); - let xcm_size = base_xcm_message.encode().len(); - - let available_bytes_for_migration_per_message = RequiredMaxMessageSize::get().saturating_sub(xcm_size as u32); - - let mut output = 0u32; - let mut current_migration_size = 0u32; - while current_migration_size < available_bytes_for_migration_per_message { - if current_migration_size + one_migration_bytes > available_bytes_for_migration_per_message { - break - } else { - current_migration_size += one_migration_bytes; - output += 1; - } - } - - output -} parameter_types! { pub MaxMessageSizeThresholds: (u32, u32) = (50000, 102_400); pub MaxCapacityThresholds: (u32, u32) = (8, 1000); pub RequiredMaxCapacity: u32 = 8; pub RequiredMaxMessageSize: u32 = 102_400; - pub MaxMigrationsPerXcm: u32 = migrations_per_xcm_message_allowed(); } + impl Config for TestRuntime { - type AllPalletsWithoutSystem = AllPalletsWithoutSystem; - type RuntimeEvent = RuntimeEvent; - type BlockNumber = BlockNumber; type AccountId32Conversion = ConvertInto; - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - type ProjectIdentifier = Identifier; - type Multiplier = Multiplier; - type Balance = Balance; - type Price = FixedU128; - type NativeCurrency = Balances; - type FundingCurrency = StatemintAssets; - type ContributionTokenCurrency = LocalAssets; - type PriceProvider = ConstPriceProvider; - type Randomness = RandomnessCollectiveFlip; - type StringLimit = ConstU32<64>; - type PreImageLimit = ConstU32<1024>; - type EvaluationDuration = EvaluationDuration; + type AllPalletsWithoutSystem = AllPalletsWithoutSystem; type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; - type EnglishAuctionDuration = EnglishAuctionDuration; + type Balance = Balance; + type BlockNumber = BlockNumber; + type BlockNumberToBalance = ConvertInto; type CandleAuctionDuration = CandleAuctionDuration; type CommunityFundingDuration = CommunityRoundDuration; - type RemainderFundingDuration = RemainderFundingDuration; - type PalletId = FundingPalletId; - type MaxProjectsToUpdatePerBlock = ConstU32<100>; - type MaxEvaluationsPerUser = ConstU32<4>; - // Low value to simplify the tests - type MaxBidsPerUser = ConstU32<4>; - type MaxContributionsPerUser = ConstU32<4>; + type ContributionTokenCurrency = LocalAssets; type ContributionVesting = ConstU32<4>; - type WeightInfo = weights::SubstrateWeight; - type FeeBrackets = FeeBrackets; + type DaysToBlocks = DaysToBlocks; + type EnglishAuctionDuration = EnglishAuctionDuration; + type EvaluationDuration = EvaluationDuration; type EvaluationSuccessThreshold = EarlyEvaluationThreshold; - type Vesting = Vesting; - type ManualAcceptanceDuration = ManualAcceptanceDuration; - type SuccessToSettlementTime = SuccessToSettlementTime; type EvaluatorSlash = EvaluatorSlash; - type TreasuryAccount = TreasuryAccount; - type DaysToBlocks = DaysToBlocks; - type BlockNumberToBalance = ConvertInto; - type PolimecReceiverInfo = PolimecReceiverInfo; - type MaxMessageSizeThresholds = MaxMessageSizeThresholds; + type FeeBrackets = FeeBrackets; + type FundingCurrency = StatemintAssets; + type ManualAcceptanceDuration = ManualAcceptanceDuration; + // Low value to simplify the tests + type MaxBidsPerUser = ConstU32<4>; type MaxCapacityThresholds = MaxCapacityThresholds; + type MaxContributionsPerUser = ConstU32<4>; + type MaxEvaluationsPerUser = ConstU32<4>; + type MaxMessageSizeThresholds = MaxMessageSizeThresholds; + type MaxProjectsToUpdatePerBlock = ConstU32<100>; + type Multiplier = Multiplier; + type NativeCurrency = Balances; + type PalletId = FundingPalletId; + type PolimecReceiverInfo = PolimecReceiverInfo; + type PreImageLimit = ConstU32<1024>; + type Price = FixedU128; + type PriceProvider = ConstPriceProvider; + type ProjectIdentifier = Identifier; + type Randomness = RandomnessCollectiveFlip; + type RemainderFundingDuration = RemainderFundingDuration; type RequiredMaxCapacity = RequiredMaxCapacity; type RequiredMaxMessageSize = RequiredMaxMessageSize; - type MaxMigrationsPerXcm = MaxMigrationsPerXcm; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type StringLimit = ConstU32<64>; + type SuccessToSettlementTime = SuccessToSettlementTime; + type TreasuryAccount = TreasuryAccount; + type Vesting = Vesting; + type WeightInfo = weights::SubstrateWeight; } // Build genesis storage according to the mock runtime. diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index 6f34c1030..cf26dd36e 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -234,11 +234,10 @@ pub mod storage_types { pub when: BlockNumber, // Will be Some after a reward of slash was made on this evaluation. pub rewarded_or_slashed: Option>, - pub ct_migration_sent: bool, - pub ct_migration_confirmed: bool, + pub ct_migration_status: MigrationStatus, } - #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] + #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] pub struct BidInfo< Id, ProjectId, @@ -266,8 +265,7 @@ pub mod storage_types { pub when: BlockNumber, pub funds_released: bool, pub ct_minted: bool, - pub ct_migration_sent: bool, - pub ct_migration_confirmed: bool, + pub ct_migration_status: MigrationStatus, } impl< @@ -305,7 +303,7 @@ pub mod storage_types { } } - #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] + #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] pub struct ContributionInfo { pub id: Id, pub project_id: ProjectId, @@ -319,8 +317,7 @@ pub mod storage_types { pub plmc_vesting_info: Option, pub funds_released: bool, pub ct_minted: bool, - pub ct_migration_sent: bool, - pub ct_migration_confirmed: bool, + pub ct_migration_status: MigrationStatus, } /// Represents a bucket that holds a specific amount of tokens at a given price. @@ -372,6 +369,8 @@ pub mod storage_types { pub mod inner_types { use super::*; use crate::{AccountIdOf, Bids, Contributions, Evaluations, ProjectIdOf}; + use frame_support::parameter_types; + use xcm::v3::MaxDispatchErrorLen; #[derive(Default, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] @@ -726,11 +725,18 @@ pub mod inner_types { } #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] - pub enum MigrationOrigin { - Evaluation { project_id: ProjectId, user: AccountId, id: Id }, - Bid { project_id: ProjectId, user: AccountId, id: Id }, - Contribution { project_id: ProjectId, user: AccountId, id: Id }, + pub enum MigrationOrigin { + Evaluation { user: AccountId, id: Id }, + Bid { user: AccountId, id: Id }, + Contribution { user: AccountId, id: Id }, + } + + #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] + pub struct ProjectMigrationOrigins { + pub project_id: ProjectId, + pub migration_origins: MigrationOrigins, } + #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct MigrationInfo { contribution_token_amount: u128, @@ -741,4 +747,20 @@ pub mod inner_types { Self { contribution_token_amount, vesting_time } } } + + #[derive(Clone, Encode, Decode, Eq, PartialEq, Ord, PartialOrd, RuntimeDebug, TypeInfo, MaxEncodedLen)] + pub enum MigrationStatus { + NotStarted, + Sent(xcm::v3::QueryId), + Confirmed, + Failed(BoundedVec), + } + + #[derive(Clone, Encode, Decode, Eq, PartialEq, Ord, PartialOrd, RuntimeDebug, TypeInfo, MaxEncodedLen)] + pub struct MaxMigrationsPerXcm(PhantomData); + impl Get for MaxMigrationsPerXcm { + fn get() -> u32 { + crate::Pallet::::migrations_per_xcm_message_allowed() + } + } } diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 6deedbb0f..1cf6dfe2b 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -55,8 +55,14 @@ use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; -use xcm::opaque::v3::Xcm; -use xcm::v3::{OriginKind, QueryResponseInfo, WeightLimit, Instruction::{Transact, UnpaidExecution, ReportTransactStatus}, Junction::Parachain}; +use xcm::{ + opaque::v3::Xcm, + v3::{ + Instruction::{ReportTransactStatus, Transact, UnpaidExecution}, + Junction::Parachain, + OriginKind, QueryResponseInfo, WeightLimit, + }, +}; // XCM Imports use polimec_xcm_executor::XcmExecutor; @@ -492,48 +498,6 @@ impl pallet_assets::Config for Runtime { type WeightInfo = (); } -const POLIMEC_PARACHAIN_ID: u32 = 3355; - -pub fn migrations_per_xcm_message_allowed() -> u32 { - const MAX_WEIGHT: Weight = Weight::from_parts(20_000_000_000, 1_000_000); - - let one_migration_bytes = (0u128, 0u64).encode().len() as u32; - - // our encoded call starts with pallet index 51, and call index 0 - let mut encoded_call = vec![51u8, 0]; - let encoded_first_param = [0u8; 32].encode(); - let encoded_second_param = Vec::::new().encode(); - // we append the encoded parameters, with our migrations vec being empty for now - encoded_call.extend_from_slice(encoded_first_param.as_slice()); - encoded_call.extend_from_slice(encoded_second_param.as_slice()); - - let mut base_xcm_message: Xcm = Xcm(vec![ - UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, - Transact { origin_kind: OriginKind::Native, require_weight_at_most: MAX_WEIGHT, call: encoded_call.into() }, - ReportTransactStatus(QueryResponseInfo { - destination: Parachain(POLIMEC_PARACHAIN_ID).into(), - query_id: 0, - max_weight, - }), - ]); - let xcm_size = base_xcm_message.encode().len(); - - let available_bytes_for_migration_per_message = RequiredMaxMessageSize::get().saturating_sub(xcm_size as u32); - - let mut output = 0u32; - let mut current_migration_size = 0u32; - while current_migration_size < available_bytes_for_migration_per_message { - if current_migration_size + one_migration_bytes > available_bytes_for_migration_per_message { - break - } else { - current_migration_size += one_migration_bytes; - output += 1; - } - } - - output -} - parameter_types! { pub TreasuryAccount: AccountId = [69u8; 32].into(); pub PolimecReceiverInfo: xcm::v3::PalletInfo = xcm::v3::PalletInfo::new( @@ -543,7 +507,6 @@ parameter_types! { pub MaxCapacityThresholds: (u32, u32) = (8, 1000); pub RequiredMaxCapacity: u32 = 8; pub RequiredMaxMessageSize: u32 = 102_400; - pub MaxMigrationsPerXcm: u32 = migrations_per_xcm_message_allowed(); } impl pallet_funding::Config for Runtime { type AccountId32Conversion = ConvertInto; @@ -590,7 +553,6 @@ impl pallet_funding::Config for Runtime { type TreasuryAccount = TreasuryAccount; type Vesting = LinearVesting; type WeightInfo = pallet_funding::weights::SubstrateWeight; - type MaxMigrationsPerXcm = (); } parameter_types! { From 7d27c36686b2ba03a97c740abccdccecc5396970 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 15 Nov 2023 16:09:24 +0100 Subject: [PATCH 028/212] Everything works! --- integration-tests/src/tests/basic_comms.rs | 9 --------- integration-tests/src/tests/ct_migration.rs | 18 +++++++++--------- pallets/funding/src/functions.rs | 7 ++----- pallets/funding/src/types.rs | 2 -- pallets/polimec-receiver/src/lib.rs | 3 +-- runtimes/testnet/src/lib.rs | 9 --------- 6 files changed, 12 insertions(+), 36 deletions(-) diff --git a/integration-tests/src/tests/basic_comms.rs b/integration-tests/src/tests/basic_comms.rs index f5484f761..d7ca133c6 100644 --- a/integration-tests/src/tests/basic_comms.rs +++ b/integration-tests/src/tests/basic_comms.rs @@ -8,15 +8,6 @@ fn dmp() { let remark = PolimecCall::System(frame_system::Call::::remark_with_event { remark: "Hello from Polkadot!".as_bytes().to_vec(), }); - let inner_call = - frame_system::Call::::remark_with_event { remark: "Hello from Polkadot!".as_bytes().to_vec() } - .encode(); - let encoded_remark = remark.clone().encode(); - let encoded_inner = "Hello from Polkadot!".as_bytes().to_vec(); - let fake_encode = (0u8, 7u8, encoded_inner.clone()).encode(); - let fake_encode_2 = (0u8, inner_call.clone()).encode(); - let mut fake_encode_3 = vec![0u8]; - fake_encode_3.extend_from_slice(inner_call[..].as_ref()); let sudo_origin = PolkadotOrigin::root(); let para_id = Polimec::para_id(); let xcm = VersionedXcm::from(Xcm(vec![ diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index 76d9a05c1..46e43b12a 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -1,5 +1,5 @@ use crate::*; -use pallet_funding::{AcceptedFundingAsset, BidInfoOf, ContributionInfoOf, EvaluationInfoOf, MigrationStatus, MultiplierOf, RewardOrSlash}; +use pallet_funding::{AcceptedFundingAsset, MigrationStatus, MultiplierOf, RewardOrSlash}; use polimec_parachain_runtime::PolimecFunding; use sp_runtime::{FixedPointNumber, Perquintill}; use pallet_funding::traits::VestingDurationCalculation; @@ -188,12 +188,12 @@ fn migration_is_executed_on_project_and_confirmed_on_polimec() { // Migrate is sent let migrated_ct_amount = Polimec::execute_with(|| { assert_ok!(PolimecFunding::do_migrate_one_participant(eval_1(), project_id, eval_1())); - let (query_id, migrations) = pallet_funding::UnconfirmedMigrations::::iter().next().unwrap(); + let (query_id, _migrations) = pallet_funding::UnconfirmedMigrations::::iter().next().unwrap(); - let mut user_evaluations = + let user_evaluations = pallet_funding::Evaluations::::iter_prefix_values((project_id, eval_1())); - let mut user_bids = pallet_funding::Bids::::iter_prefix_values((project_id, eval_1())); - let mut user_contributions = + let user_bids = pallet_funding::Bids::::iter_prefix_values((project_id, eval_1())); + let user_contributions = pallet_funding::Contributions::::iter_prefix_values((project_id, eval_1())); let evaluation_ct_amount = user_evaluations.map(|evaluation| { @@ -349,12 +349,12 @@ fn vesting_over_several_blocks_on_project() { // Migrate is sent let migrated_ct_amount = Polimec::execute_with(|| { assert_ok!(PolimecFunding::do_migrate_one_participant(buyer_1(), project_id, buyer_1())); - let (query_id, migrations) = pallet_funding::UnconfirmedMigrations::::iter().next().unwrap(); + let (query_id, _migrations) = pallet_funding::UnconfirmedMigrations::::iter().next().unwrap(); - let mut user_evaluations = + let user_evaluations = pallet_funding::Evaluations::::iter_prefix_values((project_id, buyer_1())); - let mut user_bids = pallet_funding::Bids::::iter_prefix_values((project_id, buyer_1())); - let mut user_contributions = + let user_bids = pallet_funding::Bids::::iter_prefix_values((project_id, buyer_1())); + let user_contributions = pallet_funding::Contributions::::iter_prefix_values((project_id, buyer_1())); let evaluation_ct_amount = user_evaluations.map(|evaluation| { diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index d3f931adc..b9fa253c1 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -22,7 +22,6 @@ use frame_support::{ dispatch::DispatchResult, ensure, pallet_prelude::*, - parameter_types, traits::{ fungible::MutateHold as FungibleMutateHold, fungibles::{metadata::Mutate as MetadataMutate, Create, Inspect, Mutate as FungiblesMutate}, @@ -30,7 +29,6 @@ use frame_support::{ Get, }, }; -use itertools::Itertools; use sp_arithmetic::{ traits::{CheckedDiv, CheckedSub, Zero}, Percent, Perquintill, @@ -39,7 +37,7 @@ use sp_runtime::traits::Convert; use sp_std::marker::PhantomData; use xcm::v3::MaxDispatchErrorLen; -use crate::{Call::start_bid_vesting_schedule_for, ProjectStatus::FundingSuccessful}; +use crate::{ProjectStatus::FundingSuccessful}; use polimec_traits::ReleaseSchedule; use crate::traits::{BondingRequirementCalculation, ProvideStatemintPrice, VestingDurationCalculation}; @@ -2125,7 +2123,6 @@ impl Pallet { Contributions::::iter_prefix_values((project_id, participant.clone())).filter(|contribution| { matches!(contribution.ct_migration_status, MigrationStatus::NotStarted | MigrationStatus::Failed(_)) }); - let max_message_size = T::RequiredMaxMessageSize::get(); let project_para_id = project_details.parachain_id.ok_or(Error::::ImpossibleState)?; let now = >::block_number(); @@ -2757,7 +2754,7 @@ impl Pallet { encoded_call.extend_from_slice(encoded_first_param.as_slice()); encoded_call.extend_from_slice(encoded_second_param.as_slice()); - let mut base_xcm_message: Xcm<()> = Xcm(vec![ + let base_xcm_message: Xcm<()> = Xcm(vec![ UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, Transact { origin_kind: OriginKind::Native, require_weight_at_most: MAX_WEIGHT, call: encoded_call.into() }, ReportTransactStatus(QueryResponseInfo { diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index cf26dd36e..ed4c276b2 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -368,8 +368,6 @@ pub mod storage_types { pub mod inner_types { use super::*; - use crate::{AccountIdOf, Bids, Contributions, Evaluations, ProjectIdOf}; - use frame_support::parameter_types; use xcm::v3::MaxDispatchErrorLen; #[derive(Default, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] diff --git a/pallets/polimec-receiver/src/lib.rs b/pallets/polimec-receiver/src/lib.rs index e903e7be9..cbcb4f7d2 100644 --- a/pallets/polimec-receiver/src/lib.rs +++ b/pallets/polimec-receiver/src/lib.rs @@ -11,14 +11,13 @@ pub use pallet::*; pub mod pallet { use crate::MigrationInfo; use frame_support::{ - dispatch::DispatchResultWithPostInfo, pallet_prelude::*, traits::{tokens::Balance, Currency, ExistenceRequirement::KeepAlive, VestingSchedule}, }; use frame_system::pallet_prelude::*; use polkadot_parachain::primitives::{Id as ParaId, Sibling}; use polkadot_runtime_parachains::origin::{ensure_parachain, Origin as ParachainOrigin}; - use sp_runtime::traits::{AccountIdConversion, Convert, Zero}; + use sp_runtime::traits::{AccountIdConversion, Convert}; use sp_std::prelude::*; type MomentOf = <::Vesting as VestingSchedule<::AccountId>>::Moment; diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 1cf6dfe2b..c34a0b1f4 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -36,7 +36,6 @@ pub use parachains_common::{ Header, Index, Signature, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, MINUTES, NORMAL_DISPATCH_RATIO, SLOT_DURATION, }; -use parity_scale_codec::Encode; // Polkadot imports use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate}; @@ -55,14 +54,6 @@ use sp_std::prelude::*; #[cfg(feature = "std")] use sp_version::NativeVersion; use sp_version::RuntimeVersion; -use xcm::{ - opaque::v3::Xcm, - v3::{ - Instruction::{ReportTransactStatus, Transact, UnpaidExecution}, - Junction::Parachain, - OriginKind, QueryResponseInfo, WeightLimit, - }, -}; // XCM Imports use polimec_xcm_executor::XcmExecutor; From 26ae34e3b6730166d152ae15c12300064087e1b0 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 15 Nov 2023 17:39:03 +0100 Subject: [PATCH 029/212] pallet_funding test broken currently --- integration-tests/src/tests/ct_migration.rs | 6 +- pallets/funding/src/lib.rs | 13 ++++ pallets/funding/src/mock.rs | 80 ++++++++++++--------- 3 files changed, 61 insertions(+), 38 deletions(-) diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index 46e43b12a..8e4c8393a 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -114,7 +114,7 @@ fn migration_is_sent() { // Migrate one user's contribution tokens. He evaluated, bid, and contributed Polimec::execute_with(|| { - assert_ok!(PolimecFunding::do_migrate_one_participant(eval_1(), project_id, eval_1())); + assert_ok!(PolimecFunding::migrate_one_participant(PolimecOrigin::signed(eval_1()), project_id, eval_1())); let query_id = pallet_funding::UnconfirmedMigrations::::iter_keys().next().unwrap(); let mut user_evaluations = pallet_funding::Evaluations::::iter_prefix_values((project_id, eval_1())); @@ -187,7 +187,7 @@ fn migration_is_executed_on_project_and_confirmed_on_polimec() { // Migrate is sent let migrated_ct_amount = Polimec::execute_with(|| { - assert_ok!(PolimecFunding::do_migrate_one_participant(eval_1(), project_id, eval_1())); + assert_ok!(PolimecFunding::migrate_one_participant(PolimecOrigin::signed(eval_1()), project_id, eval_1())); let (query_id, _migrations) = pallet_funding::UnconfirmedMigrations::::iter().next().unwrap(); let user_evaluations = @@ -348,7 +348,7 @@ fn vesting_over_several_blocks_on_project() { // Migrate is sent let migrated_ct_amount = Polimec::execute_with(|| { - assert_ok!(PolimecFunding::do_migrate_one_participant(buyer_1(), project_id, buyer_1())); + assert_ok!(PolimecFunding::migrate_one_participant(PolimecOrigin::signed(buyer_1()), project_id, buyer_1())); let (query_id, _migrations) = pallet_funding::UnconfirmedMigrations::::iter().next().unwrap(); let user_evaluations = diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index d4c4477e3..8b7a967d1 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1207,6 +1207,19 @@ pub mod pallet { #[pallet::call_index(25)] #[pallet::weight(Weight::from_parts(1000, 0))] + pub fn migrate_one_participant( + origin: OriginFor, + project_id: T::ProjectIdentifier, + participant: AccountIdOf, + ) -> DispatchResult { + let caller = ensure_signed(origin)?; + Self::do_migrate_one_participant(caller, project_id, participant) + } + + + + #[pallet::call_index(26)] + #[pallet::weight(Weight::from_parts(1000, 0))] pub fn confirm_migrations( origin: OriginFor, query_id: QueryId, diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 7977d5cc4..aa2a7d077 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -86,6 +86,7 @@ pub const fn free_deposit() -> Balance { use frame_support::traits::{Everything, OriginTrait}; use frame_system::RawOrigin as SystemRawOrigin; use polkadot_parachain::primitives::Sibling; +use sp_core::crypto::Dummy; use sp_runtime::traits::Get; use xcm_builder::{EnsureXcmOrigin, FixedWeightBounds, ParentIsPreset, SiblingParachainConvertsVia}; use xcm_executor::traits::Convert; @@ -327,52 +328,61 @@ parameter_types! { } +pub struct DummyConverter; +impl sp_runtime::traits::Convert for DummyConverter { + fn convert(a: AccountId) -> [u8; 32] { + let mut account: [u8; 32] = [0u8; 32]; + account[0..7].copy_from_slice(a.to_le_bytes().as_slice()); + account + } +} + impl Config for TestRuntime { - type AccountId32Conversion = ConvertInto; type AllPalletsWithoutSystem = AllPalletsWithoutSystem; - type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; - type Balance = Balance; + type RuntimeEvent = RuntimeEvent; type BlockNumber = BlockNumber; - type BlockNumberToBalance = ConvertInto; - type CandleAuctionDuration = CandleAuctionDuration; - type CommunityFundingDuration = CommunityRoundDuration; + type AccountId32Conversion = DummyConverter; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + type ProjectIdentifier = Identifier; + type Multiplier = Multiplier; + type Balance = Balance; + type Price = FixedU128; + type NativeCurrency = Balances; + type FundingCurrency = StatemintAssets; type ContributionTokenCurrency = LocalAssets; - type ContributionVesting = ConstU32<4>; - type DaysToBlocks = DaysToBlocks; - type EnglishAuctionDuration = EnglishAuctionDuration; + type PriceProvider = ConstPriceProvider; + type Randomness = RandomnessCollectiveFlip; + type StringLimit = ConstU32<64>; + type PreImageLimit = ConstU32<1024>; type EvaluationDuration = EvaluationDuration; - type EvaluationSuccessThreshold = EarlyEvaluationThreshold; - type EvaluatorSlash = EvaluatorSlash; - type FeeBrackets = FeeBrackets; - type FundingCurrency = StatemintAssets; - type ManualAcceptanceDuration = ManualAcceptanceDuration; + type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; + type EnglishAuctionDuration = EnglishAuctionDuration; + type CandleAuctionDuration = CandleAuctionDuration; + type CommunityFundingDuration = CommunityRoundDuration; + type RemainderFundingDuration = RemainderFundingDuration; + type PalletId = FundingPalletId; + type MaxProjectsToUpdatePerBlock = ConstU32<100>; + type MaxEvaluationsPerUser = ConstU32<4>; // Low value to simplify the tests type MaxBidsPerUser = ConstU32<4>; - type MaxCapacityThresholds = MaxCapacityThresholds; type MaxContributionsPerUser = ConstU32<4>; - type MaxEvaluationsPerUser = ConstU32<4>; - type MaxMessageSizeThresholds = MaxMessageSizeThresholds; - type MaxProjectsToUpdatePerBlock = ConstU32<100>; - type Multiplier = Multiplier; - type NativeCurrency = Balances; - type PalletId = FundingPalletId; + type ContributionVesting = ConstU32<4>; + type WeightInfo = weights::SubstrateWeight; + type FeeBrackets = FeeBrackets; + type EvaluationSuccessThreshold = EarlyEvaluationThreshold; + type Vesting = Vesting; + type ManualAcceptanceDuration = ManualAcceptanceDuration; + type SuccessToSettlementTime = SuccessToSettlementTime; + type EvaluatorSlash = EvaluatorSlash; + type TreasuryAccount = TreasuryAccount; + type DaysToBlocks = DaysToBlocks; + type BlockNumberToBalance = ConvertInto; type PolimecReceiverInfo = PolimecReceiverInfo; - type PreImageLimit = ConstU32<1024>; - type Price = FixedU128; - type PriceProvider = ConstPriceProvider; - type ProjectIdentifier = Identifier; - type Randomness = RandomnessCollectiveFlip; - type RemainderFundingDuration = RemainderFundingDuration; + type MaxMessageSizeThresholds = MaxMessageSizeThresholds; + type MaxCapacityThresholds = MaxCapacityThresholds; type RequiredMaxCapacity = RequiredMaxCapacity; type RequiredMaxMessageSize = RequiredMaxMessageSize; - type RuntimeCall = RuntimeCall; - type RuntimeEvent = RuntimeEvent; - type RuntimeOrigin = RuntimeOrigin; - type StringLimit = ConstU32<64>; - type SuccessToSettlementTime = SuccessToSettlementTime; - type TreasuryAccount = TreasuryAccount; - type Vesting = Vesting; - type WeightInfo = weights::SubstrateWeight; } // Build genesis storage according to the mock runtime. From 5275f2fc6c79d925823f530a33ae88ef6991b543 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 16 Nov 2023 12:07:01 +0100 Subject: [PATCH 030/212] bug found in evaluation unbonding by cleaner. Still an infinite loop bug remaining --- pallets/funding/src/impls.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pallets/funding/src/impls.rs b/pallets/funding/src/impls.rs index 9891f5be5..82ad13655 100644 --- a/pallets/funding/src/impls.rs +++ b/pallets/funding/src/impls.rs @@ -361,8 +361,6 @@ fn unbond_one_evaluation(project_id: T::ProjectIdentifier) -> (Weight project_evaluations.filter(|evaluation| evaluation.current_plmc_bond > Zero::zero()); let base_weight = Weight::from_parts(10_000_000, 0); if let Some(evaluation) = remaining_evaluations.next() { - let remaining = remaining_evaluations.count() as u64; - match Pallet::::do_evaluation_unbond_for( &T::PalletId::get().into_account_truncating(), evaluation.project_id, @@ -377,7 +375,7 @@ fn unbond_one_evaluation(project_id: T::ProjectIdentifier) -> (Weight error: e, }), }; - (base_weight.saturating_add(WeightInfoOf::::evaluation_unbond_for()), remaining.saturating_sub(1u64)) + (base_weight.saturating_add(WeightInfoOf::::evaluation_unbond_for()), remaining_evaluations.count() as u64) } else { (base_weight, 0u64) } From 41a3465aee33df2e3c7b36d94c0243412e550132 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 16 Nov 2023 13:13:51 +0100 Subject: [PATCH 031/212] all bugs squashed B) --- pallets/funding/src/functions.rs | 10 ++++++---- pallets/funding/src/lib.rs | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index b9fa253c1..ccdb003ca 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -1565,6 +1565,8 @@ impl Pallet { Ok(()) } + // Unbond the PLMC of a bid instantly, following a failed funding outcome. + // Unbonding of PLMC in a successful funding outcome is handled by the vesting schedule. pub fn do_bid_unbond_for( caller: &AccountIdOf, project_id: T::ProjectIdentifier, @@ -1586,8 +1588,7 @@ impl Pallet { // * Update Storage * T::NativeCurrency::release(&LockType::Participation(project_id), bidder, bid.plmc_bond, Precision::Exact)?; - // FIXME: Since we store the migration info here, we might not want to delete it. Users will want to find out their previous history - // Bids::::remove((project_id, bidder, bid_id)); + Bids::::remove((project_id, bidder, bid_id)); // * Emit events * Self::deposit_event(Event::BondReleased { @@ -1642,6 +1643,8 @@ impl Pallet { Ok(()) } + // Unbond the PLMC of a contribution instantly, following a failed funding outcome. + // Unbonding of PLMC in a successful funding outcome is handled by the vesting schedule. pub fn do_contribution_unbond_for( caller: &AccountIdOf, project_id: T::ProjectIdentifier, @@ -1659,8 +1662,7 @@ impl Pallet { // * Update Storage * T::NativeCurrency::release(&LockType::Participation(project_id), contributor, bid.plmc_bond, Precision::Exact)?; - // FIXME: same question as bids removing - // Contributions::::remove((project_id, contributor, contribution_id)); + Contributions::::remove((project_id, contributor, contribution_id)); // * Emit events * Self::deposit_event(Event::BondReleased { diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 8b7a967d1..be9a7269d 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -119,7 +119,7 @@ //! let project_id: ::ProjectIdentifier = project_id.into(); //! // Check project is in the community round //! let project_details = pallet_funding::Pallet::::project_details(project_id).ok_or(Error::::ProjectNotFound)?; -//! "ensure!(project_details.status == pallet_funding::ProjectStatus::CommunityRound, "Project is not in the community round"); +//! ensure!(project_details.status == pallet_funding::ProjectStatus::CommunityRound, "Project is not in the community round"); //! //! // Calculate how much funding was done already //! let project_contributions: ::Balance = pallet_funding::Contributions::::iter_prefix_values((project_id,)) From 0095a22fe953fdf00ea24fb45f40a0dec2bca69b Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 16 Nov 2023 16:16:17 +0100 Subject: [PATCH 032/212] need to find a way to generate function from a new macro --- Cargo.lock | 1 + integration-tests/Cargo.toml | 1 + integration-tests/src/tests/ct_migration.rs | 90 ++-- integration-tests/src/tests/e2e.rs | 497 ++++++++++++++++++++ integration-tests/src/tests/mod.rs | 1 + integration-tests/src/tests/oracle.rs | 26 + nodes/parachain/src/chain_spec/testnet.rs | 1 - pallets/funding/src/functions.rs | 14 +- pallets/funding/src/lib.rs | 8 +- pallets/funding/src/mock.rs | 70 +-- pallets/funding/src/tests.rs | 480 ------------------- runtimes/testnet/src/lib.rs | 2 +- 12 files changed, 620 insertions(+), 571 deletions(-) create mode 100644 integration-tests/src/tests/e2e.rs diff --git a/Cargo.lock b/Cargo.lock index af324b885..bed7dee6b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4151,6 +4151,7 @@ dependencies = [ "polkadot-service", "sc-consensus-grandpa", "scale-info", + "sp-arithmetic", "sp-authority-discovery", "sp-consensus-babe", "sp-core", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 98fef470c..3dd81a48b 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -22,6 +22,7 @@ scale-info = { workspace = true, features = ["derive"] } # Local polimec-receiver.workspace = true +sp-arithmetic.workspace = true frame-system.workspace = true frame-support.workspace = true pallet-balances.workspace = true diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index 8e4c8393a..d5186024c 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -1,8 +1,9 @@ use crate::*; -use pallet_funding::{AcceptedFundingAsset, MigrationStatus, MultiplierOf, RewardOrSlash}; +use pallet_funding::{ + traits::VestingDurationCalculation, AcceptedFundingAsset, MigrationStatus, MultiplierOf, RewardOrSlash, +}; use polimec_parachain_runtime::PolimecFunding; use sp_runtime::{FixedPointNumber, Perquintill}; -use pallet_funding::traits::VestingDurationCalculation; use tests::defaults::*; #[test] @@ -124,7 +125,9 @@ fn migration_is_sent() { assert!(user_evaluations.all(|evaluation| evaluation.ct_migration_status == MigrationStatus::Sent(query_id))); assert!(user_bids.all(|bid| bid.ct_migration_status == MigrationStatus::Sent(query_id))); - assert!(user_contributions.all(|contribution| contribution.ct_migration_status == MigrationStatus::Sent(query_id))); + assert!( + user_contributions.all(|contribution| contribution.ct_migration_status == MigrationStatus::Sent(query_id)) + ); }); } @@ -196,28 +199,32 @@ fn migration_is_executed_on_project_and_confirmed_on_polimec() { let user_contributions = pallet_funding::Contributions::::iter_prefix_values((project_id, eval_1())); - let evaluation_ct_amount = user_evaluations.map(|evaluation| { - assert_eq!(evaluation.ct_migration_status, MigrationStatus::Sent(query_id)); - if let Some(RewardOrSlash::Reward(amount)) = evaluation.rewarded_or_slashed { - amount - } else { - panic!("should be rewarded") - } - }).sum::(); - let bid_ct_amount = user_bids.map(|bid| { - assert_eq!(bid.ct_migration_status, MigrationStatus::Sent(query_id)); - bid.final_ct_amount - }).sum::(); - let contribution_ct_amount = user_contributions.map(|contribution| { - assert_eq!(contribution.ct_migration_status, MigrationStatus::Sent(query_id)); - contribution.ct_amount - }).sum::(); + let evaluation_ct_amount = user_evaluations + .map(|evaluation| { + assert_eq!(evaluation.ct_migration_status, MigrationStatus::Sent(query_id)); + if let Some(RewardOrSlash::Reward(amount)) = evaluation.rewarded_or_slashed { + amount + } else { + panic!("should be rewarded") + } + }) + .sum::(); + let bid_ct_amount = user_bids + .map(|bid| { + assert_eq!(bid.ct_migration_status, MigrationStatus::Sent(query_id)); + bid.final_ct_amount + }) + .sum::(); + let contribution_ct_amount = user_contributions + .map(|contribution| { + assert_eq!(contribution.ct_migration_status, MigrationStatus::Sent(query_id)); + contribution.ct_amount + }) + .sum::(); evaluation_ct_amount + bid_ct_amount + contribution_ct_amount - }); - Penpal::execute_with(|| { assert_expected_events!( Penpal, @@ -357,28 +364,32 @@ fn vesting_over_several_blocks_on_project() { let user_contributions = pallet_funding::Contributions::::iter_prefix_values((project_id, buyer_1())); - let evaluation_ct_amount = user_evaluations.map(|evaluation| { - assert_eq!(evaluation.ct_migration_status, MigrationStatus::Sent(query_id)); - if let Some(RewardOrSlash::Reward(amount)) = evaluation.rewarded_or_slashed { - amount - } else { - panic!("should be rewarded") - } - }).sum::(); - let bid_ct_amount = user_bids.map(|bid| { - assert_eq!(bid.ct_migration_status, MigrationStatus::Sent(query_id)); - bid.final_ct_amount - }).sum::(); - let contribution_ct_amount = user_contributions.map(|contribution| { - assert_eq!(contribution.ct_migration_status, MigrationStatus::Sent(query_id)); - contribution.ct_amount - }).sum::(); + let evaluation_ct_amount = user_evaluations + .map(|evaluation| { + assert_eq!(evaluation.ct_migration_status, MigrationStatus::Sent(query_id)); + if let Some(RewardOrSlash::Reward(amount)) = evaluation.rewarded_or_slashed { + amount + } else { + panic!("should be rewarded") + } + }) + .sum::(); + let bid_ct_amount = user_bids + .map(|bid| { + assert_eq!(bid.ct_migration_status, MigrationStatus::Sent(query_id)); + bid.final_ct_amount + }) + .sum::(); + let contribution_ct_amount = user_contributions + .map(|contribution| { + assert_eq!(contribution.ct_migration_status, MigrationStatus::Sent(query_id)); + contribution.ct_amount + }) + .sum::(); evaluation_ct_amount + bid_ct_amount + contribution_ct_amount - }); - Penpal::execute_with(|| { assert_expected_events!( Penpal, @@ -428,4 +439,3 @@ fn vesting_over_several_blocks_on_project() { let post_vest_balance = Penpal::account_data_of(buyer_1()); dbg!(post_vest_balance); } - diff --git a/integration-tests/src/tests/e2e.rs b/integration-tests/src/tests/e2e.rs new file mode 100644 index 000000000..197293d89 --- /dev/null +++ b/integration-tests/src/tests/e2e.rs @@ -0,0 +1,497 @@ +use super::*; +use crate::{tests::defaults::*, *}; +use frame_support::BoundedVec; +use pallet_funding::{instantiator::*, *}; +use polimec_parachain_runtime::US_DOLLAR; +use sp_runtime::FixedU128; +use sp_runtime::traits::{AccountIdConversion, CheckedSub}; +use sp_arithmetic::Perquintill; +use sp_core::U256; + +type UserToCTBalance = Vec<(AccountId, BalanceOf, ProjectIdOf)>; + + +fn increase_by_one(account_id: AccountId) -> impl FnMut() -> AccountId { + let mut num = U256::from(account_id.clone()); + + move || { + let output = num; + num.saturating_add(U256::from(1)); + account_id = num.try_into().unwrap(); + } +} + + +define_names_v2! { + [0; 32], + increase_by_one, + LINA, "Lina"; + MIA, "Mia"; + ALEXEY, "Alexey"; + PAUL, "Paul"; + MARIA, "Maria"; + GEORGE, "George"; + CLARA, "Clara"; + RAMONA, "Ramona"; + PASCAL, "Pascal"; + EMMA, "Emma"; + BIBI, "Bibi"; + AHMED, "Ahmed"; + HERBERT, "Herbert"; + LENI, "Leni"; + XI, "Xi"; + TOM, "Tom"; + ADAMS, "Adams"; + POLK, "Polk"; + MARKUS, "Markus"; + ELLA, "Ella"; + SKR, "Skr"; + ARTHUR, "Arthur"; + MILA, "Mila"; + LINCOLN, "Lincoln"; + MONROE, "Monroe"; + ARBRESHA, "Arbresha"; + ELDIN, "Eldin"; + HARDING, "Harding"; + SOFIA, "Sofia"; + DOMINIK, "Dominik"; + NOLAND, "Noland"; + HANNAH, "Hannah"; + HOOVER, "Hoover"; + GIGI, "Gigi"; + JEFFERSON, "Jefferson"; + LINDI, "Lindi"; + KEVIN, "Kevin"; + ANIS, "Anis"; + RETO, "Reto"; + HAALAND, "Haaland"; + XENIA, "Xenia"; + EVA, "Eva"; + SKARA, "Skara"; + ROOSEVELT, "Roosevelt"; + DRACULA, "Dracula"; + DURIM, "Durim"; + HARRISON, "Harrison"; + DRIN, "Drin"; + PARI, "Pari"; + TUTI, "Tuti"; + BENITO, "Benito"; + VANESSA, "Vanessa"; + ENES, "Enes"; + RUDOLF, "Rudolf"; + CERTO, "Certo"; + TIESTO, "Tiesto"; + DAVID, "David"; + ATAKAN, "Atakan"; + YANN, "Yann"; + ENIS, "Enis"; + ALFREDO, "Alfredo"; + QENDRIM, "Qendrim"; + LEONARDO, "Leonardo"; + KEN, "Ken"; + LUCA, "Luca"; + FLAVIO, "Flavio"; + FREDI, "Fredi"; + ALI, "Ali"; + DILARA, "Dilara"; + DAMIAN, "Damian"; + KAYA, "Kaya"; + IAZI, "Iazi"; + CHRIGI, "Chrigi"; + VALENTINA, "Valentina"; + ALMA, "Alma"; + ALENA, "Alena"; + PATRICK, "Patrick"; + ONTARIO, "Ontario"; + RAKIA, "Rakia"; + HUBERT, "Hubert"; + UTUS, "Utus"; + TOME, "Tome"; + ZUBER, "Zuber"; + ADAM, "Adam"; + STANI, "Stani"; + BETI, "Beti"; + HALIT, "Halit"; + DRAGAN, "Dragan"; + LEA, "Lea"; + LUIS, "Luis"; + TATI, "Tati"; + WEST, "West"; + MIRIJAM, "Mirijam"; + LIONEL, "Lionel"; + GIOVANNI, "Giovanni"; + JOEL, "Joel"; + POLKA, "Polk"; + MALIK, "Malik"; + ALEXANDER, "Alexander"; + SOLOMUN, "Solomun"; + JOHNNY, "Johnny"; + GRINGO, "Gringo"; + JONAS, "Jonas"; + BUNDI, "Bundi"; + FELIX, "Felix"; +} + +pub fn excel_project(nonce: u64) -> ProjectMetadataOf { + let bounded_name = BoundedVec::try_from("Polimec".as_bytes().to_vec()).unwrap(); + let bounded_symbol = BoundedVec::try_from("PLMC".as_bytes().to_vec()).unwrap(); + let metadata_hash = hashed(format!("{}-{}", METADATA, nonce)); + ProjectMetadata { + token_information: CurrencyMetadata { name: bounded_name, symbol: bounded_symbol, decimals: 10 }, + mainnet_token_max_supply: 1_000_000_0_000_000_000, // Made up, not in the Sheet. + // Total Allocation of Contribution Tokens Available for the Funding Round + total_allocation_size: (50_000_0_000_000_000, 50_000_0_000_000_000), + // Minimum Price per Contribution Token (in USDT) + minimum_price: PriceOf::::from(10), + ticket_size: TicketSize { minimum: Some(1), maximum: None }, + participants_size: ParticipantsSize { minimum: Some(2), maximum: None }, + funding_thresholds: Default::default(), + conversion_rate: 1, + participation_currencies: AcceptedFundingAsset::USDT, + funding_destination_account: issuer(), + offchain_information_hash: Some(metadata_hash), + } +} + +fn excel_evaluators() -> Vec> { + vec![ + UserToUSDBalance::new(LINA, 93754 * US_DOLLAR), + UserToUSDBalance::new(MIA, 162 * US_DOLLAR), + UserToUSDBalance::new(ALEXEY, 7454 * US_DOLLAR), + UserToUSDBalance::new(PAUL, 8192 * US_DOLLAR), + UserToUSDBalance::new(MARIA, 11131 * US_DOLLAR), + UserToUSDBalance::new(GEORGE, 4765 * US_DOLLAR), + UserToUSDBalance::new(CLARA, 4363 * US_DOLLAR), + UserToUSDBalance::new(RAMONA, 4120 * US_DOLLAR), + UserToUSDBalance::new(PASCAL, 1626 * US_DOLLAR), + UserToUSDBalance::new(EMMA, 3996 * US_DOLLAR), + UserToUSDBalance::new(BIBI, 3441 * US_DOLLAR), + UserToUSDBalance::new(AHMED, 8048 * US_DOLLAR), + UserToUSDBalance::new(HERBERT, 2538 * US_DOLLAR), + UserToUSDBalance::new(LENI, 5803 * US_DOLLAR), + UserToUSDBalance::new(XI, 1669 * US_DOLLAR), + UserToUSDBalance::new(TOM, 6526 * US_DOLLAR), + ] +} + +fn excel_bidders() -> Vec> { + vec![ + BidParams::from(ADAMS, 700 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(POLK, 4000 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(MARKUS, 3000 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(ELLA, 700 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(SKR, 3400 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(ARTHUR, 1000 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(MILA, 8400 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(LINCOLN, 800 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(MONROE, 1300 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(ARBRESHA, 5000 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(ELDIN, 600 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(HARDING, 800 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(SOFIA, 3000 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(DOMINIK, 8000 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(NOLAND, 900 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(LINA, 8400 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(LINA, 1000 * ASSET_UNIT, FixedU128::from_float(11.0)), + BidParams::from(HANNAH, 400 * ASSET_UNIT, FixedU128::from_float(11.0)), + BidParams::from(HOOVER, 2000 * ASSET_UNIT, FixedU128::from_float(11.0)), + BidParams::from(GIGI, 600 * ASSET_UNIT, FixedU128::from_float(11.0)), + BidParams::from(JEFFERSON, 1000 * ASSET_UNIT, FixedU128::from_float(11.0)), + BidParams::from(JEFFERSON, 2000 * ASSET_UNIT, FixedU128::from_float(12.0)), + ] +} + +fn excel_contributors() -> Vec> { + vec![ + ContributionParams::from(DRIN, 692 * US_DOLLAR), + ContributionParams::from(PARI, 236 * US_DOLLAR), + ContributionParams::from(TUTI, 24 * US_DOLLAR), + ContributionParams::from(BENITO, 688 * US_DOLLAR), + ContributionParams::from(VANESSA, 33 * US_DOLLAR), + ContributionParams::from(ENES, 1148 * US_DOLLAR), + ContributionParams::from(RUDOLF, 35 * US_DOLLAR), + ContributionParams::from(CERTO, 840 * US_DOLLAR), + ContributionParams::from(TIESTO, 132 * US_DOLLAR), + ContributionParams::from(DAVID, 21 * US_DOLLAR), + ContributionParams::from(ATAKAN, 59 * US_DOLLAR), + ContributionParams::from(YANN, 89 * US_DOLLAR), + ContributionParams::from(ENIS, 332 * US_DOLLAR), + ContributionParams::from(ALFREDO, 8110 * US_DOLLAR), + ContributionParams::from(QENDRIM, 394 * US_DOLLAR), + ContributionParams::from(LEONARDO, 840 * US_DOLLAR), + ContributionParams::from(KEN, 352 * US_DOLLAR), + ContributionParams::from(LUCA, 640 * US_DOLLAR), + // TODO: XI is a partipant in the Community Round AND an Evaluator. At the moment, this returns `InsufficientBalance` because it seems we don't mint to him enough USDT. + // To be addressed and tested in a separate PR. + //ContributionParams::from(XI, 588 * US_DOLLAR), + ContributionParams::from(FLAVIO, 792 * US_DOLLAR), + ContributionParams::from(FREDI, 993 * US_DOLLAR), + ContributionParams::from(ALI, 794 * US_DOLLAR), + ContributionParams::from(DILARA, 256 * US_DOLLAR), + ContributionParams::from(DAMIAN, 431 * US_DOLLAR), + ContributionParams::from(KAYA, 935 * US_DOLLAR), + ContributionParams::from(IAZI, 174 * US_DOLLAR), + ContributionParams::from(CHRIGI, 877 * US_DOLLAR), + ContributionParams::from(VALENTINA, 961 * US_DOLLAR), + ContributionParams::from(ALMA, 394 * US_DOLLAR), + ContributionParams::from(ALENA, 442 * US_DOLLAR), + ContributionParams::from(PATRICK, 486 * US_DOLLAR), + ContributionParams::from(ONTARIO, 17 * US_DOLLAR), + ContributionParams::from(RAKIA, 9424 * US_DOLLAR), + ContributionParams::from(HUBERT, 14 * US_DOLLAR), + ContributionParams::from(UTUS, 4906 * US_DOLLAR), + ContributionParams::from(TOME, 68 * US_DOLLAR), + ContributionParams::from(ZUBER, 9037 * US_DOLLAR), + ContributionParams::from(ADAM, 442 * US_DOLLAR), + ContributionParams::from(STANI, 40 * US_DOLLAR), + ContributionParams::from(BETI, 68 * US_DOLLAR), + ContributionParams::from(HALIT, 68 * US_DOLLAR), + ContributionParams::from(DRAGAN, 98 * US_DOLLAR), + ContributionParams::from(LEA, 17 * US_DOLLAR), + ContributionParams::from(LUIS, 422 * US_DOLLAR), + ] +} + +fn excel_remainders() -> Vec> { + vec![ + ContributionParams::from(JOEL, 692 * US_DOLLAR), + ContributionParams::from(POLK, 236 * US_DOLLAR), + ContributionParams::from(MALIK, 24 * US_DOLLAR), + ContributionParams::from(LEA, 688 * US_DOLLAR), + ContributionParams::from(RAMONA, 35 * US_DOLLAR), + ContributionParams::from(SOLOMUN, 840 * US_DOLLAR), + ContributionParams::from(JONAS, 59 * US_DOLLAR), + ] +} + +fn excel_ct_amounts() -> UserToCTBalance { + vec![ + (LINA, 42916134112336, 0), + (MIA, 32685685157, 0), + (ALEXEY, 1422329504123, 0), + (PAUL, 1164821313204, 0), + (MARIA, 1582718022129, 0), + (GEORGE, 677535834646, 0), + (CLARA, 620375413759, 0), + (RAMONA, 935823219043, 0), + (PASCAL, 231201105380, 0), + (EMMA, 568191646431, 0), + (BIBI, 489276139982, 0), + (AHMED, 1144345938558, 0), + (HERBERT, 360878478139, 0), + (LENI, 825129160220, 0), + (XI, 237315279753, 0), + (TOM, 927932603756, 0), + (ADAMS, 700 * ASSET_UNIT, 0), + (POLK, 4236 * ASSET_UNIT, 0), + (MARKUS, 3000 * ASSET_UNIT, 0), + (ELLA, 700 * ASSET_UNIT, 0), + (SKR, 3400 * ASSET_UNIT, 0), + (ARTHUR, 1000 * ASSET_UNIT, 0), + (MILA, 8400 * ASSET_UNIT, 0), + (LINCOLN, 800 * ASSET_UNIT, 0), + (MONROE, 1300 * ASSET_UNIT, 0), + (ARBRESHA, 5000 * ASSET_UNIT, 0), + (ELDIN, 600 * ASSET_UNIT, 0), + (HARDING, 800 * ASSET_UNIT, 0), + (SOFIA, 3000 * ASSET_UNIT, 0), + (DOMINIK, 8000 * ASSET_UNIT, 0), + (NOLAND, 900 * ASSET_UNIT, 0), + (HANNAH, 400 * ASSET_UNIT, 0), + (HOOVER, 2000 * ASSET_UNIT, 0), + (GIGI, 600 * ASSET_UNIT, 0), + (JEFFERSON, 3000 * ASSET_UNIT, 0), + (DRIN, 692 * ASSET_UNIT, 0), + (PARI, 236 * ASSET_UNIT, 0), + (TUTI, 24 * ASSET_UNIT, 0), + (BENITO, 688 * ASSET_UNIT, 0), + (VANESSA, 33 * ASSET_UNIT, 0), + (ENES, 1148 * ASSET_UNIT, 0), + (RUDOLF, 35 * ASSET_UNIT, 0), + (CERTO, 840 * ASSET_UNIT, 0), + (TIESTO, 132 * ASSET_UNIT, 0), + (DAVID, 21 * ASSET_UNIT, 0), + (ATAKAN, 59 * ASSET_UNIT, 0), + (YANN, 89 * ASSET_UNIT, 0), + (ENIS, 332 * ASSET_UNIT, 0), + (ALFREDO, 8110 * ASSET_UNIT, 0), + (QENDRIM, 394 * ASSET_UNIT, 0), + (LEONARDO, 840 * ASSET_UNIT, 0), + (KEN, 352 * ASSET_UNIT, 0), + (LUCA, 640 * ASSET_UNIT, 0), + (FLAVIO, 792 * ASSET_UNIT, 0), + (FREDI, 993 * ASSET_UNIT, 0), + (ALI, 794 * ASSET_UNIT, 0), + (DILARA, 256 * ASSET_UNIT, 0), + (DAMIAN, 431 * ASSET_UNIT, 0), + (KAYA, 935 * ASSET_UNIT, 0), + (IAZI, 174 * ASSET_UNIT, 0), + (CHRIGI, 877 * ASSET_UNIT, 0), + (VALENTINA, 961 * ASSET_UNIT, 0), + (ALMA, 394 * ASSET_UNIT, 0), + (ALENA, 442 * ASSET_UNIT, 0), + (PATRICK, 486 * ASSET_UNIT, 0), + (ONTARIO, 17 * ASSET_UNIT, 0), + (RAKIA, 9424 * ASSET_UNIT, 0), + (HUBERT, 14 * ASSET_UNIT, 0), + (UTUS, 4906 * ASSET_UNIT, 0), + (TOME, 68 * ASSET_UNIT, 0), + (ZUBER, 9037 * ASSET_UNIT, 0), + (ADAM, 442 * ASSET_UNIT, 0), + (STANI, 40 * ASSET_UNIT, 0), + (BETI, 68 * ASSET_UNIT, 0), + (HALIT, 68 * ASSET_UNIT, 0), + (DRAGAN, 98 * ASSET_UNIT, 0), + (LEA, 705 * ASSET_UNIT, 0), + (LUIS, 422 * ASSET_UNIT, 0), + (JOEL, 692 * ASSET_UNIT, 0), + (MALIK, 24 * ASSET_UNIT, 0), + (SOLOMUN, 840 * ASSET_UNIT, 0), + (JONAS, 59 * ASSET_UNIT, 0), + ] +} + +#[test] +fn evaluation_round_completed() { + let mut inst = IntegrationInstantiator::new(None); + let issuer = issuer(); + let project = excel_project(inst.get_new_nonce()); + let evaluations = excel_evaluators(); + + inst.create_auctioning_project(project, issuer(), evaluations); +} + +#[test] +fn auction_round_completed() { + let mut inst = IntegrationInstantiator::new(None); + let issuer = issuer(); + let project = excel_project(inst.get_new_nonce()); + let evaluations = excel_evaluators(); + let bids = excel_bidders(); + //let filtered_bids = MockInstantiator::filter_bids_after_auction(bids.clone(), project.total_allocation_size.0); + let (project_id, _) = inst.create_community_contributing_project(project, issuer(), evaluations, bids); + let wavgp_from_excel = 10.202357561; + // Convert the float to a FixedU128 + let wavgp_to_substrate = FixedU128::from_float(wavgp_from_excel); + dbg!(wavgp_to_substrate); + let wavgp_from_chain = inst.get_project_details(project_id).weighted_average_price.unwrap(); + dbg!(wavgp_from_chain); + let res = wavgp_from_chain.checked_sub(&wavgp_to_substrate).unwrap(); + // We are more precise than Excel. From the 11th decimal onwards, the difference should be less than 0.00001. + assert!(res < FixedU128::from_float(0.00001)); + let names = names(); + inst.execute(|| { + let bids = Bids::::iter_prefix_values((0,)).sorted_by_key(|bid| bid.bidder).collect_vec(); + + for bid in bids.clone() { + println!("{}: {}", names[&bid.bidder], bid.funding_asset_amount_locked); + } + let total_participation = bids.into_iter().fold(0, |acc, bid| acc + bid.funding_asset_amount_locked); + dbg!(total_participation); + }) +} + +#[test] +fn community_round_completed() { + let mut inst = IntegrationInstantiator::new(None); + let _ = inst.create_remainder_contributing_project( + excel_project(0), + issuer(), + excel_evaluators(), + excel_bidders(), + excel_contributors(), + ); + + inst.execute(|| { + let contributions = Contributions::::iter_prefix_values((0,)) + .sorted_by_key(|bid| bid.contributor) + .collect_vec(); + let total_contribution = contributions.clone().into_iter().fold(0, |acc, bid| acc + bid.funding_asset_amount); + let total_contribution_as_fixed = FixedU128::from_rational(total_contribution, PLMC); + dbg!(total_contribution_as_fixed); + // In USD + // let total_ct_amount = contributions.clone().into_iter().fold(0, |acc, bid| acc + bid.ct_amount); + // let total_contribution_from_excel = 46821.0; + // dbg!(total_contribution_from_excel); + // let res = total_contribution_as_fixed - FixedU128::from_float(total_contribution_from_excel); + // // We are more precise than Excel. From the 11th decimal onwards, the difference should be less than 0.001. + // assert!(res < FixedU128::from_float(0.001)); + // let total_ct_sold_from_excel = 46821; + // assert_eq!(total_ct_amount / PLMC, total_ct_sold_from_excel); + }) +} + +#[test] +fn remainder_round_completed() { + let mut inst = IntegrationInstantiator::new(None); + let _ = inst.create_finished_project( + excel_project(0), + issuer(), + excel_evaluators(), + excel_bidders(), + excel_contributors(), + excel_remainders(), + ); + + inst.execute(|| { + let contributions = Contributions::::iter_prefix_values((0,)) + .sorted_by_key(|bid| bid.contributor) + .collect_vec(); + let total_contributions = contributions.into_iter().fold(0, |acc, bid| acc + bid.funding_asset_amount); + dbg!(total_contributions); + let total_contributions_as_fixed = FixedU128::from_rational(total_contributions, PLMC); + let total_from_excel = 503945.4517; + let total_to_substrate = FixedU128::from_float(total_from_excel); + dbg!(total_to_substrate); + let res = total_contributions_as_fixed.checked_sub(&total_to_substrate).unwrap(); + // We are more precise than Excel. From the 11th decimal onwards, the difference should be less than 0.0001. + assert!(res < FixedU128::from_float(0.001)); + }) +} + +#[test] +fn funds_raised() { + let mut inst = IntegrationInstantiator::new(None); + let _ = inst.create_finished_project( + excel_project(0), + issuer(), + excel_evaluators(), + excel_bidders(), + excel_contributors(), + excel_remainders(), + ); + + inst.execute(|| { + let pallet_id = ::PalletId::get(); + let project_specific_account: u64 = pallet_id.into_sub_account_truncating(0); + let funding = StatemintAssets::balance(1984, project_specific_account); + let fund_raised_from_excel = 1005361.955; + let fund_raised_to_substrate = FixedU128::from_float(fund_raised_from_excel); + let fund_raised_as_fixed = FixedU128::from_rational(funding, ASSET_UNIT); + let res = fund_raised_to_substrate.checked_sub(&fund_raised_as_fixed).unwrap(); + // We are more precise than Excel. From the 11th decimal onwards, the difference should be less than 0.0003. + assert!(res < FixedU128::from_float(0.001)); + }) +} + +#[test] +fn ct_minted() { + let mut inst = IntegrationInstantiator::new(None); + let _ = inst.create_finished_project( + excel_project(0), + issuer(), + excel_evaluators(), + excel_bidders(), + excel_contributors(), + excel_remainders(), + ); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + + inst.advance_time(10).unwrap(); + + for (contributor, expected_amount, project_id) in excel_ct_amounts() { + let minted = + inst.execute(|| ::ContributionTokenCurrency::balance(project_id, &contributor)); + assert_close_enough!(minted, expected_amount, Perquintill::from_parts(10_000_000_000u64)); + } +} diff --git a/integration-tests/src/tests/mod.rs b/integration-tests/src/tests/mod.rs index 367e58910..21790eb6c 100644 --- a/integration-tests/src/tests/mod.rs +++ b/integration-tests/src/tests/mod.rs @@ -1,5 +1,6 @@ mod basic_comms; mod ct_migration; mod defaults; +mod e2e; mod oracle; mod reserve_backed_transfers; diff --git a/integration-tests/src/tests/oracle.rs b/integration-tests/src/tests/oracle.rs index 4626c2138..04abdc819 100644 --- a/integration-tests/src/tests/oracle.rs +++ b/integration-tests/src/tests/oracle.rs @@ -5,6 +5,7 @@ use crate::*; use parity_scale_codec::alloc::collections::HashMap; use polimec_parachain_runtime::{Oracle, RuntimeOrigin}; use sp_runtime::{bounded_vec, BoundedVec, FixedU128}; +use tests::defaults::*; fn values( values: [f64; 4], @@ -84,3 +85,28 @@ fn data_is_correctly_combined() { } }) } + +#[test] +fn pallet_funding_works() { + let mut inst = IntegrationInstantiator::new(None); + + Polimec::execute_with(|| { + let alice = Polimec::account_id_of(ALICE); + assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(alice.clone()), values([4.84, 1.0, 1.0, 0.4]))); + + let bob = Polimec::account_id_of(BOB); + assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(bob.clone()), values([4.84, 1.0, 1.0, 0.4]))); + + let charlie = Polimec::account_id_of(CHARLIE); + assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(charlie.clone()), values([4.84, 1.0, 1.0, 0.4]))); + + let project_id = inst.create_finished_project( + default_project(issuer(), 0), + issuer(), + default_evaluations(), + default_bids(), + default_community_contributions(), + vec![], + ); + }); +} diff --git a/nodes/parachain/src/chain_spec/testnet.rs b/nodes/parachain/src/chain_spec/testnet.rs index 71e5c72ae..9a117a04e 100644 --- a/nodes/parachain/src/chain_spec/testnet.rs +++ b/nodes/parachain/src/chain_spec/testnet.rs @@ -262,7 +262,6 @@ fn testnet_genesis( democracy: Default::default(), linear_vesting: LinearVestingConfig { vesting: vec![] }, oracle_providers_membership: Default::default(), - } } diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index ccdb003ca..c2e31d387 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -37,7 +37,7 @@ use sp_runtime::traits::Convert; use sp_std::marker::PhantomData; use xcm::v3::MaxDispatchErrorLen; -use crate::{ProjectStatus::FundingSuccessful}; +use crate::ProjectStatus::FundingSuccessful; use polimec_traits::ReleaseSchedule; use crate::traits::{BondingRequirementCalculation, ProvideStatemintPrice, VestingDurationCalculation}; @@ -2190,16 +2190,16 @@ impl Pallet { Self::mark_migrations_as_sent(project_migration_origins.clone(), transact_response_query_id); UnconfirmedMigrations::::insert(transact_response_query_id, project_migration_origins); - Self::deposit_event(Event::::UserMigrationSent { project_id, caller: caller.clone(), participant: participant.clone() }); + Self::deposit_event(Event::::UserMigrationSent { + project_id, + caller: caller.clone(), + participant: participant.clone(), + }); } Ok(()) } - pub fn do_confirm_migrations( - location: MultiLocation, - query_id: QueryId, - response: Response, - ) -> DispatchResult { + pub fn do_confirm_migrations(location: MultiLocation, query_id: QueryId, response: Response) -> DispatchResult { use xcm::v3::prelude::*; let unconfirmed_migrations = UnconfirmedMigrations::::take(query_id).ok_or(Error::::NotAllowed)?; let project_id = unconfirmed_migrations.project_id; diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index be9a7269d..8bf976ea0 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1216,15 +1216,9 @@ pub mod pallet { Self::do_migrate_one_participant(caller, project_id, participant) } - - #[pallet::call_index(26)] #[pallet::weight(Weight::from_parts(1000, 0))] - pub fn confirm_migrations( - origin: OriginFor, - query_id: QueryId, - response: Response, - ) -> DispatchResult { + pub fn confirm_migrations(origin: OriginFor, query_id: QueryId, response: Response) -> DispatchResult { let location = ensure_response(::RuntimeOrigin::from(origin))?; Self::do_confirm_migrations(location, query_id, response) diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index aa2a7d077..0bd997759 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -338,51 +338,51 @@ impl sp_runtime::traits::Convert for DummyConverter { } impl Config for TestRuntime { - type AllPalletsWithoutSystem = AllPalletsWithoutSystem; - type RuntimeEvent = RuntimeEvent; - type BlockNumber = BlockNumber; type AccountId32Conversion = DummyConverter; - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - type ProjectIdentifier = Identifier; - type Multiplier = Multiplier; - type Balance = Balance; - type Price = FixedU128; - type NativeCurrency = Balances; - type FundingCurrency = StatemintAssets; - type ContributionTokenCurrency = LocalAssets; - type PriceProvider = ConstPriceProvider; - type Randomness = RandomnessCollectiveFlip; - type StringLimit = ConstU32<64>; - type PreImageLimit = ConstU32<1024>; - type EvaluationDuration = EvaluationDuration; + type AllPalletsWithoutSystem = AllPalletsWithoutSystem; type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; - type EnglishAuctionDuration = EnglishAuctionDuration; + type Balance = Balance; + type BlockNumber = BlockNumber; + type BlockNumberToBalance = ConvertInto; type CandleAuctionDuration = CandleAuctionDuration; type CommunityFundingDuration = CommunityRoundDuration; - type RemainderFundingDuration = RemainderFundingDuration; - type PalletId = FundingPalletId; - type MaxProjectsToUpdatePerBlock = ConstU32<100>; - type MaxEvaluationsPerUser = ConstU32<4>; - // Low value to simplify the tests - type MaxBidsPerUser = ConstU32<4>; - type MaxContributionsPerUser = ConstU32<4>; + type ContributionTokenCurrency = LocalAssets; type ContributionVesting = ConstU32<4>; - type WeightInfo = weights::SubstrateWeight; - type FeeBrackets = FeeBrackets; + type DaysToBlocks = DaysToBlocks; + type EnglishAuctionDuration = EnglishAuctionDuration; + type EvaluationDuration = EvaluationDuration; type EvaluationSuccessThreshold = EarlyEvaluationThreshold; - type Vesting = Vesting; - type ManualAcceptanceDuration = ManualAcceptanceDuration; - type SuccessToSettlementTime = SuccessToSettlementTime; type EvaluatorSlash = EvaluatorSlash; - type TreasuryAccount = TreasuryAccount; - type DaysToBlocks = DaysToBlocks; - type BlockNumberToBalance = ConvertInto; - type PolimecReceiverInfo = PolimecReceiverInfo; - type MaxMessageSizeThresholds = MaxMessageSizeThresholds; + type FeeBrackets = FeeBrackets; + type FundingCurrency = StatemintAssets; + type ManualAcceptanceDuration = ManualAcceptanceDuration; + // Low value to simplify the tests + type MaxBidsPerUser = ConstU32<4>; type MaxCapacityThresholds = MaxCapacityThresholds; + type MaxContributionsPerUser = ConstU32<4>; + type MaxEvaluationsPerUser = ConstU32<4>; + type MaxMessageSizeThresholds = MaxMessageSizeThresholds; + type MaxProjectsToUpdatePerBlock = ConstU32<100>; + type Multiplier = Multiplier; + type NativeCurrency = Balances; + type PalletId = FundingPalletId; + type PolimecReceiverInfo = PolimecReceiverInfo; + type PreImageLimit = ConstU32<1024>; + type Price = FixedU128; + type PriceProvider = ConstPriceProvider; + type ProjectIdentifier = Identifier; + type Randomness = RandomnessCollectiveFlip; + type RemainderFundingDuration = RemainderFundingDuration; type RequiredMaxCapacity = RequiredMaxCapacity; type RequiredMaxMessageSize = RequiredMaxMessageSize; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type StringLimit = ConstU32<64>; + type SuccessToSettlementTime = SuccessToSettlementTime; + type TreasuryAccount = TreasuryAccount; + type Vesting = Vesting; + type WeightInfo = weights::SubstrateWeight; } // Build genesis storage according to the mock runtime. diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index f5df84eef..b279498b9 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -52,7 +52,6 @@ use mock::TestRuntime; use super::*; type MockInstantiator = Instantiator; -type UserToCTBalance = Vec<(AccountId, BalanceOf, ProjectIdOf)>; const METADATA: &str = r#"METADATA { @@ -113,27 +112,6 @@ pub mod defaults { } } - pub fn excel_project(nonce: u64) -> ProjectMetadataOf { - let bounded_name = BoundedVec::try_from("Polimec".as_bytes().to_vec()).unwrap(); - let bounded_symbol = BoundedVec::try_from("PLMC".as_bytes().to_vec()).unwrap(); - let metadata_hash = hashed(format!("{}-{}", METADATA, nonce)); - ProjectMetadata { - token_information: CurrencyMetadata { name: bounded_name, symbol: bounded_symbol, decimals: 10 }, - mainnet_token_max_supply: 1_000_000_0_000_000_000, // Made up, not in the Sheet. - // Total Allocation of Contribution Tokens Available for the Funding Round - total_allocation_size: (50_000_0_000_000_000, 50_000_0_000_000_000), - // Minimum Price per Contribution Token (in USDT) - minimum_price: PriceOf::::from(10), - ticket_size: TicketSize { minimum: Some(1), maximum: None }, - participants_size: ParticipantsSize { minimum: Some(2), maximum: None }, - funding_thresholds: Default::default(), - conversion_rate: 1, - participation_currencies: AcceptedFundingAsset::USDT, - funding_destination_account: ISSUER, - offchain_information_hash: Some(metadata_hash), - } - } - pub fn default_plmc_balances() -> Vec> { vec![ UserToPLMCBalance::new(ISSUER, 20_000 * PLMC), @@ -6393,461 +6371,3 @@ mod misc_features { assert!(true); } } - -mod e2e_testing { - use super::*; - - define_names! { - // In order to auto-incriment the ids, we have to use unsafe Rust. - LINA: 101, "Lina"; - MIA: 102, "Mia"; - ALEXEY: 103, "Alexey"; - PAUL: 104, "Paul"; - MARIA: 105, "Maria"; - GEORGE: 106, "George"; - CLARA: 107, "Clara"; - RAMONA: 108, "Ramona"; - PASCAL: 109, "Pascal"; - EMMA: 110, "Emma"; - BIBI: 111, "Bibi"; - AHMED: 112, "Ahmed"; - HERBERT: 113, "Herbert"; - LENI: 114, "Leni"; - XI: 115, "Xi"; - TOM: 116, "Tom"; - ADAMS: 117, "Adams"; - POLK: 118, "Polk"; - MARKUS: 119, "Markus"; - ELLA: 120, "Ella"; - SKR: 121, "Skr"; - ARTHUR: 122, "Arthur"; - MILA: 123, "Mila"; - LINCOLN: 124, "Lincoln"; - MONROE: 125, "Monroe"; - ARBRESHA: 126, "Arbresha"; - ELDIN: 127, "Eldin"; - HARDING: 128, "Harding"; - SOFIA: 129, "Sofia"; - DOMINIK: 130, "Dominik"; - NOLAND: 131, "Noland"; - HANNAH: 132, "Hannah"; - HOOVER: 133, "Hoover"; - GIGI: 134, "Gigi"; - JEFFERSON: 135, "Jefferson"; - LINDI: 136, "Lindi"; - KEVIN: 137, "Kevin"; - ANIS: 138, "Anis"; - RETO: 139, "Reto"; - HAALAND: 140, "Haaland"; - XENIA: 141, "Xenia"; - EVA: 142, "Eva"; - SKARA: 143, "Skara"; - ROOSEVELT: 144, "Roosevelt"; - DRACULA: 145, "Dracula"; - DURIM: 146, "Durim"; - HARRISON: 147, "Harrison"; - DRIN: 148, "Drin"; - PARI: 149, "Pari"; - TUTI: 150, "Tuti"; - BENITO: 151, "Benito"; - VANESSA: 152, "Vanessa"; - ENES: 153, "Enes"; - RUDOLF: 154, "Rudolf"; - CERTO: 155, "Certo"; - TIESTO: 156, "Tiesto"; - DAVID: 157, "David"; - ATAKAN: 158, "Atakan"; - YANN: 159, "Yann"; - ENIS: 160, "Enis"; - ALFREDO: 161, "Alfredo"; - QENDRIM: 162, "Qendrim"; - LEONARDO: 163, "Leonardo"; - KEN: 164, "Ken"; - LUCA: 165, "Luca"; - FLAVIO: 167, "Flavio"; - FREDI: 168, "Fredi"; - ALI: 169, "Ali"; - DILARA: 170, "Dilara"; - DAMIAN: 171, "Damian"; - KAYA: 172, "Kaya"; - IAZI: 173, "Iazi"; - CHRIGI: 174, "Chrigi"; - VALENTINA: 175, "Valentina"; - ALMA: 176, "Alma"; - ALENA: 177, "Alena"; - PATRICK: 178, "Patrick"; - ONTARIO: 179, "Ontario"; - RAKIA: 180, "Rakia"; - HUBERT: 181, "Hubert"; - UTUS: 182, "Utus"; - TOME: 183, "Tome"; - ZUBER: 184, "Zuber"; - ADAM: 185, "Adam"; - STANI: 186, "Stani"; - BETI: 187, "Beti"; - HALIT: 188, "Halit"; - DRAGAN: 189, "Dragan"; - LEA: 190, "Lea"; - LUIS: 191, "Luis"; - TATI: 192, "Tati"; - WEST: 193, "West"; - MIRIJAM: 194, "Mirijam"; - LIONEL: 195, "Lionel"; - GIOVANNI: 196, "Giovanni"; - JOEL: 197, "Joel"; - POLKA: 198, "Polk"; - MALIK: 199, "Malik"; - ALEXANDER: 201, "Alexander"; - SOLOMUN: 203, "Solomun"; - JOHNNY: 204, "Johnny"; - GRINGO: 205, "Gringo"; - JONAS: 206, "Jonas"; - BUNDI: 207, "Bundi"; - FELIX: 208, "Felix"; - } - - fn excel_evaluators() -> Vec> { - vec![ - UserToUSDBalance::new(LINA, 93754 * US_DOLLAR), - UserToUSDBalance::new(MIA, 162 * US_DOLLAR), - UserToUSDBalance::new(ALEXEY, 7454 * US_DOLLAR), - UserToUSDBalance::new(PAUL, 8192 * US_DOLLAR), - UserToUSDBalance::new(MARIA, 11131 * US_DOLLAR), - UserToUSDBalance::new(GEORGE, 4765 * US_DOLLAR), - UserToUSDBalance::new(CLARA, 4363 * US_DOLLAR), - UserToUSDBalance::new(RAMONA, 4120 * US_DOLLAR), - UserToUSDBalance::new(PASCAL, 1626 * US_DOLLAR), - UserToUSDBalance::new(EMMA, 3996 * US_DOLLAR), - UserToUSDBalance::new(BIBI, 3441 * US_DOLLAR), - UserToUSDBalance::new(AHMED, 8048 * US_DOLLAR), - UserToUSDBalance::new(HERBERT, 2538 * US_DOLLAR), - UserToUSDBalance::new(LENI, 5803 * US_DOLLAR), - UserToUSDBalance::new(XI, 1669 * US_DOLLAR), - UserToUSDBalance::new(TOM, 6526 * US_DOLLAR), - ] - } - - fn excel_bidders() -> Vec> { - vec![ - BidParams::from(ADAMS, 700 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(POLK, 4000 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(MARKUS, 3000 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(ELLA, 700 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(SKR, 3400 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(ARTHUR, 1000 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(MILA, 8400 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(LINCOLN, 800 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(MONROE, 1300 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(ARBRESHA, 5000 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(ELDIN, 600 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(HARDING, 800 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(SOFIA, 3000 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(DOMINIK, 8000 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(NOLAND, 900 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(LINA, 8400 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(LINA, 1000 * ASSET_UNIT, FixedU128::from_float(11.0)), - BidParams::from(HANNAH, 400 * ASSET_UNIT, FixedU128::from_float(11.0)), - BidParams::from(HOOVER, 2000 * ASSET_UNIT, FixedU128::from_float(11.0)), - BidParams::from(GIGI, 600 * ASSET_UNIT, FixedU128::from_float(11.0)), - BidParams::from(JEFFERSON, 1000 * ASSET_UNIT, FixedU128::from_float(11.0)), - BidParams::from(JEFFERSON, 2000 * ASSET_UNIT, FixedU128::from_float(12.0)), - ] - } - - fn excel_contributors() -> Vec> { - vec![ - ContributionParams::from(DRIN, 692 * US_DOLLAR), - ContributionParams::from(PARI, 236 * US_DOLLAR), - ContributionParams::from(TUTI, 24 * US_DOLLAR), - ContributionParams::from(BENITO, 688 * US_DOLLAR), - ContributionParams::from(VANESSA, 33 * US_DOLLAR), - ContributionParams::from(ENES, 1148 * US_DOLLAR), - ContributionParams::from(RUDOLF, 35 * US_DOLLAR), - ContributionParams::from(CERTO, 840 * US_DOLLAR), - ContributionParams::from(TIESTO, 132 * US_DOLLAR), - ContributionParams::from(DAVID, 21 * US_DOLLAR), - ContributionParams::from(ATAKAN, 59 * US_DOLLAR), - ContributionParams::from(YANN, 89 * US_DOLLAR), - ContributionParams::from(ENIS, 332 * US_DOLLAR), - ContributionParams::from(ALFREDO, 8110 * US_DOLLAR), - ContributionParams::from(QENDRIM, 394 * US_DOLLAR), - ContributionParams::from(LEONARDO, 840 * US_DOLLAR), - ContributionParams::from(KEN, 352 * US_DOLLAR), - ContributionParams::from(LUCA, 640 * US_DOLLAR), - // TODO: XI is a partipant in the Community Round AND an Evaluator. At the moment, this returns `InsufficientBalance` because it seems we don't mint to him enough USDT. - // To be addressed and tested in a separate PR. - //ContributionParams::from(XI, 588 * US_DOLLAR), - ContributionParams::from(FLAVIO, 792 * US_DOLLAR), - ContributionParams::from(FREDI, 993 * US_DOLLAR), - ContributionParams::from(ALI, 794 * US_DOLLAR), - ContributionParams::from(DILARA, 256 * US_DOLLAR), - ContributionParams::from(DAMIAN, 431 * US_DOLLAR), - ContributionParams::from(KAYA, 935 * US_DOLLAR), - ContributionParams::from(IAZI, 174 * US_DOLLAR), - ContributionParams::from(CHRIGI, 877 * US_DOLLAR), - ContributionParams::from(VALENTINA, 961 * US_DOLLAR), - ContributionParams::from(ALMA, 394 * US_DOLLAR), - ContributionParams::from(ALENA, 442 * US_DOLLAR), - ContributionParams::from(PATRICK, 486 * US_DOLLAR), - ContributionParams::from(ONTARIO, 17 * US_DOLLAR), - ContributionParams::from(RAKIA, 9424 * US_DOLLAR), - ContributionParams::from(HUBERT, 14 * US_DOLLAR), - ContributionParams::from(UTUS, 4906 * US_DOLLAR), - ContributionParams::from(TOME, 68 * US_DOLLAR), - ContributionParams::from(ZUBER, 9037 * US_DOLLAR), - ContributionParams::from(ADAM, 442 * US_DOLLAR), - ContributionParams::from(STANI, 40 * US_DOLLAR), - ContributionParams::from(BETI, 68 * US_DOLLAR), - ContributionParams::from(HALIT, 68 * US_DOLLAR), - ContributionParams::from(DRAGAN, 98 * US_DOLLAR), - ContributionParams::from(LEA, 17 * US_DOLLAR), - ContributionParams::from(LUIS, 422 * US_DOLLAR), - ] - } - - fn excel_remainders() -> Vec> { - vec![ - ContributionParams::from(JOEL, 692 * US_DOLLAR), - ContributionParams::from(POLK, 236 * US_DOLLAR), - ContributionParams::from(MALIK, 24 * US_DOLLAR), - ContributionParams::from(LEA, 688 * US_DOLLAR), - ContributionParams::from(RAMONA, 35 * US_DOLLAR), - ContributionParams::from(SOLOMUN, 840 * US_DOLLAR), - ContributionParams::from(JONAS, 59 * US_DOLLAR), - ] - } - - fn excel_ct_amounts() -> UserToCTBalance { - vec![ - (LINA, 42916134112336, 0), - (MIA, 32685685157, 0), - (ALEXEY, 1422329504123, 0), - (PAUL, 1164821313204, 0), - (MARIA, 1582718022129, 0), - (GEORGE, 677535834646, 0), - (CLARA, 620375413759, 0), - (RAMONA, 935823219043, 0), - (PASCAL, 231201105380, 0), - (EMMA, 568191646431, 0), - (BIBI, 489276139982, 0), - (AHMED, 1144345938558, 0), - (HERBERT, 360878478139, 0), - (LENI, 825129160220, 0), - (XI, 237315279753, 0), - (TOM, 927932603756, 0), - (ADAMS, 700 * ASSET_UNIT, 0), - (POLK, 4236 * ASSET_UNIT, 0), - (MARKUS, 3000 * ASSET_UNIT, 0), - (ELLA, 700 * ASSET_UNIT, 0), - (SKR, 3400 * ASSET_UNIT, 0), - (ARTHUR, 1000 * ASSET_UNIT, 0), - (MILA, 8400 * ASSET_UNIT, 0), - (LINCOLN, 800 * ASSET_UNIT, 0), - (MONROE, 1300 * ASSET_UNIT, 0), - (ARBRESHA, 5000 * ASSET_UNIT, 0), - (ELDIN, 600 * ASSET_UNIT, 0), - (HARDING, 800 * ASSET_UNIT, 0), - (SOFIA, 3000 * ASSET_UNIT, 0), - (DOMINIK, 8000 * ASSET_UNIT, 0), - (NOLAND, 900 * ASSET_UNIT, 0), - (HANNAH, 400 * ASSET_UNIT, 0), - (HOOVER, 2000 * ASSET_UNIT, 0), - (GIGI, 600 * ASSET_UNIT, 0), - (JEFFERSON, 3000 * ASSET_UNIT, 0), - (DRIN, 692 * ASSET_UNIT, 0), - (PARI, 236 * ASSET_UNIT, 0), - (TUTI, 24 * ASSET_UNIT, 0), - (BENITO, 688 * ASSET_UNIT, 0), - (VANESSA, 33 * ASSET_UNIT, 0), - (ENES, 1148 * ASSET_UNIT, 0), - (RUDOLF, 35 * ASSET_UNIT, 0), - (CERTO, 840 * ASSET_UNIT, 0), - (TIESTO, 132 * ASSET_UNIT, 0), - (DAVID, 21 * ASSET_UNIT, 0), - (ATAKAN, 59 * ASSET_UNIT, 0), - (YANN, 89 * ASSET_UNIT, 0), - (ENIS, 332 * ASSET_UNIT, 0), - (ALFREDO, 8110 * ASSET_UNIT, 0), - (QENDRIM, 394 * ASSET_UNIT, 0), - (LEONARDO, 840 * ASSET_UNIT, 0), - (KEN, 352 * ASSET_UNIT, 0), - (LUCA, 640 * ASSET_UNIT, 0), - (FLAVIO, 792 * ASSET_UNIT, 0), - (FREDI, 993 * ASSET_UNIT, 0), - (ALI, 794 * ASSET_UNIT, 0), - (DILARA, 256 * ASSET_UNIT, 0), - (DAMIAN, 431 * ASSET_UNIT, 0), - (KAYA, 935 * ASSET_UNIT, 0), - (IAZI, 174 * ASSET_UNIT, 0), - (CHRIGI, 877 * ASSET_UNIT, 0), - (VALENTINA, 961 * ASSET_UNIT, 0), - (ALMA, 394 * ASSET_UNIT, 0), - (ALENA, 442 * ASSET_UNIT, 0), - (PATRICK, 486 * ASSET_UNIT, 0), - (ONTARIO, 17 * ASSET_UNIT, 0), - (RAKIA, 9424 * ASSET_UNIT, 0), - (HUBERT, 14 * ASSET_UNIT, 0), - (UTUS, 4906 * ASSET_UNIT, 0), - (TOME, 68 * ASSET_UNIT, 0), - (ZUBER, 9037 * ASSET_UNIT, 0), - (ADAM, 442 * ASSET_UNIT, 0), - (STANI, 40 * ASSET_UNIT, 0), - (BETI, 68 * ASSET_UNIT, 0), - (HALIT, 68 * ASSET_UNIT, 0), - (DRAGAN, 98 * ASSET_UNIT, 0), - (LEA, 705 * ASSET_UNIT, 0), - (LUIS, 422 * ASSET_UNIT, 0), - (JOEL, 692 * ASSET_UNIT, 0), - (MALIK, 24 * ASSET_UNIT, 0), - (SOLOMUN, 840 * ASSET_UNIT, 0), - (JONAS, 59 * ASSET_UNIT, 0), - ] - } - - #[test] - fn evaluation_round_completed() { - let ext = Some(RefCell::new(new_test_ext())); - let mut inst = MockInstantiator::new(ext); - let issuer = ISSUER; - let project = excel_project(inst.get_new_nonce()); - let evaluations = excel_evaluators(); - - inst.create_auctioning_project(project, issuer, evaluations); - } - - #[test] - fn auction_round_completed() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = excel_project(inst.get_new_nonce()); - let evaluations = excel_evaluators(); - let bids = excel_bidders(); - //let filtered_bids = MockInstantiator::filter_bids_after_auction(bids.clone(), project.total_allocation_size.0); - let (project_id, _) = inst.create_community_contributing_project(project, issuer, evaluations, bids); - let wavgp_from_excel = 10.202357561; - // Convert the float to a FixedU128 - let wavgp_to_substrate = FixedU128::from_float(wavgp_from_excel); - dbg!(wavgp_to_substrate); - let wavgp_from_chain = inst.get_project_details(project_id).weighted_average_price.unwrap(); - dbg!(wavgp_from_chain); - let res = wavgp_from_chain.checked_sub(&wavgp_to_substrate).unwrap(); - // We are more precise than Excel. From the 11th decimal onwards, the difference should be less than 0.00001. - assert!(res < FixedU128::from_float(0.00001)); - let names = names(); - inst.execute(|| { - let bids = Bids::::iter_prefix_values((0,)).sorted_by_key(|bid| bid.bidder).collect_vec(); - - for bid in bids.clone() { - println!("{}: {}", names[&bid.bidder], bid.funding_asset_amount_locked); - } - let total_participation = bids.into_iter().fold(0, |acc, bid| acc + bid.funding_asset_amount_locked); - dbg!(total_participation); - }) - } - - #[test] - fn community_round_completed() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let _ = inst.create_remainder_contributing_project( - excel_project(0), - ISSUER, - excel_evaluators(), - excel_bidders(), - excel_contributors(), - ); - - inst.execute(|| { - let contributions = Contributions::::iter_prefix_values((0,)) - .sorted_by_key(|bid| bid.contributor) - .collect_vec(); - let total_contribution = - contributions.clone().into_iter().fold(0, |acc, bid| acc + bid.funding_asset_amount); - let total_contribution_as_fixed = FixedU128::from_rational(total_contribution, PLMC); - dbg!(total_contribution_as_fixed); - // In USD - // let total_ct_amount = contributions.clone().into_iter().fold(0, |acc, bid| acc + bid.ct_amount); - // let total_contribution_from_excel = 46821.0; - // dbg!(total_contribution_from_excel); - // let res = total_contribution_as_fixed - FixedU128::from_float(total_contribution_from_excel); - // // We are more precise than Excel. From the 11th decimal onwards, the difference should be less than 0.001. - // assert!(res < FixedU128::from_float(0.001)); - // let total_ct_sold_from_excel = 46821; - // assert_eq!(total_ct_amount / PLMC, total_ct_sold_from_excel); - }) - } - - #[test] - fn remainder_round_completed() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let _ = inst.create_finished_project( - excel_project(0), - ISSUER, - excel_evaluators(), - excel_bidders(), - excel_contributors(), - excel_remainders(), - ); - - inst.execute(|| { - let contributions = Contributions::::iter_prefix_values((0,)) - .sorted_by_key(|bid| bid.contributor) - .collect_vec(); - let total_contributions = contributions.into_iter().fold(0, |acc, bid| acc + bid.funding_asset_amount); - dbg!(total_contributions); - let total_contributions_as_fixed = FixedU128::from_rational(total_contributions, PLMC); - let total_from_excel = 503945.4517; - let total_to_substrate = FixedU128::from_float(total_from_excel); - dbg!(total_to_substrate); - let res = total_contributions_as_fixed.checked_sub(&total_to_substrate).unwrap(); - // We are more precise than Excel. From the 11th decimal onwards, the difference should be less than 0.0001. - assert!(res < FixedU128::from_float(0.001)); - }) - } - - #[test] - fn funds_raised() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let _ = inst.create_finished_project( - excel_project(0), - ISSUER, - excel_evaluators(), - excel_bidders(), - excel_contributors(), - excel_remainders(), - ); - - inst.execute(|| { - let pallet_id = ::PalletId::get(); - let project_specific_account: u64 = pallet_id.into_sub_account_truncating(0); - let funding = StatemintAssets::balance(1984, project_specific_account); - let fund_raised_from_excel = 1005361.955; - let fund_raised_to_substrate = FixedU128::from_float(fund_raised_from_excel); - let fund_raised_as_fixed = FixedU128::from_rational(funding, ASSET_UNIT); - let res = fund_raised_to_substrate.checked_sub(&fund_raised_as_fixed).unwrap(); - // We are more precise than Excel. From the 11th decimal onwards, the difference should be less than 0.0003. - assert!(res < FixedU128::from_float(0.001)); - }) - } - - #[test] - fn ct_minted() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let _ = inst.create_finished_project( - excel_project(0), - ISSUER, - excel_evaluators(), - excel_bidders(), - excel_contributors(), - excel_remainders(), - ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - - inst.advance_time(10).unwrap(); - - for (contributor, expected_amount, project_id) in excel_ct_amounts() { - let minted = - inst.execute(|| ::ContributionTokenCurrency::balance(project_id, &contributor)); - assert_close_enough!(minted, expected_amount, Perquintill::from_parts(10_000_000_000u64)); - } - } -} diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 65ad1a016..9f7be2a9a 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -66,7 +66,7 @@ pub use crate::xcm_config::*; include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); // Polimec Shared Imports -use pallet_funding::{BondTypeOf, DaysToBlocks, ConstPriceProvider}; +use pallet_funding::{BondTypeOf, ConstPriceProvider, DaysToBlocks}; pub use pallet_parachain_staking; pub use shared_configuration::*; From f1c8bfac6053344903e15a24a5d76cea45fa1cb8 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 17 Nov 2023 17:40:19 +0100 Subject: [PATCH 033/212] need to find a way to generate function from a new macro --- Cargo.lock | 17 +++++++++ Cargo.toml | 7 ++++ .../macros/src/generate_accounts.rs | 35 +++++++++++++++++++ integration-tests/src/tests/e2e.rs | 8 ++--- 4 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 integration-tests/macros/src/generate_accounts.rs diff --git a/Cargo.lock b/Cargo.lock index bed7dee6b..7296deba5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5261,6 +5261,23 @@ dependencies = [ "libc", ] +[[package]] +name = "macros" +version = "0.1.0" +dependencies = [ + "proc-macro2", + "quote", + "sp-core", + "syn 2.0.39", +] + +[[package]] +name = "macros-tests" +version = "0.1.0" +dependencies = [ + "macros", +] + [[package]] name = "maplit" version = "1.0.2" diff --git a/Cargo.toml b/Cargo.toml index 766840c25..2e89a62d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,8 @@ members = [ "pallets/*", "integration-tests", "integration-tests/penpal", + "integration-tests/macros", + "integration-tests/macros/tests", "traits", ] @@ -58,6 +60,11 @@ pallet-linear-release = { path = "pallets/linear-release", default-features = fa polimec-xcm-executor = { path = "pallets/xcm-executor", default-features = false} polimec-receiver = { path = "pallets/polimec-receiver", default-features = false } +# Internal macros +macros = { path = "integration-tests/macros" } +macros-tests = { path = "integration-tests/macros/tests" } + + # External pallets (with default disabled) orml-oracle = {git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.43", default-features = false} orml-traits = {git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.43", default-features = false} diff --git a/integration-tests/macros/src/generate_accounts.rs b/integration-tests/macros/src/generate_accounts.rs new file mode 100644 index 000000000..58b984eec --- /dev/null +++ b/integration-tests/macros/src/generate_accounts.rs @@ -0,0 +1,35 @@ +#![allow(dead_code)] +#![allow(unused_imports)] +#![allow(unused_variables)] +#![allow(unused_macros)] + +use core::panic; +use proc_macro::TokenStream; +use quote::{quote, ToTokens}; +use sp_core::U256; +use syn::{parse::{Parse, ParseBuffer, ParseStream}, parse2, parse_macro_input, punctuated::Punctuated, token::Comma, Expr, GenericArgument, GenericParam, Generics, Ident, Result, Token, Type, Visibility, WhereClause, ItemMod}; + +pub fn generate_accounts_impl(_args: TokenStream, input: TokenStream) -> TokenStream { + let item = parse_macro_input!(input as ItemMod); + let name = &item.ident; + let content = item.content.expect("Expected accounts defined").1; + let names = parse_macro_input!(content as Punctuated); + + let mut starting_value = U256::from(0u32); + + let generated_consts = names.iter().enumerate().map(|(i, name)| { + let val = starting_value.checked_add(U256::from(i)).unwrap(); + let const_value: [u8; 32] = val.try_into().unwrap(); + quote! { + pub const #name: [u8; 32] = #const_value; + } + }); + + let output = quote! { + pub mod #name { + #(#generated_consts)* + } + }; + + output.into() +} diff --git a/integration-tests/src/tests/e2e.rs b/integration-tests/src/tests/e2e.rs index 197293d89..7897213fd 100644 --- a/integration-tests/src/tests/e2e.rs +++ b/integration-tests/src/tests/e2e.rs @@ -3,14 +3,15 @@ use crate::{tests::defaults::*, *}; use frame_support::BoundedVec; use pallet_funding::{instantiator::*, *}; use polimec_parachain_runtime::US_DOLLAR; -use sp_runtime::FixedU128; -use sp_runtime::traits::{AccountIdConversion, CheckedSub}; use sp_arithmetic::Perquintill; use sp_core::U256; +use sp_runtime::{ + traits::{AccountIdConversion, CheckedSub}, + FixedU128, +}; type UserToCTBalance = Vec<(AccountId, BalanceOf, ProjectIdOf)>; - fn increase_by_one(account_id: AccountId) -> impl FnMut() -> AccountId { let mut num = U256::from(account_id.clone()); @@ -21,7 +22,6 @@ fn increase_by_one(account_id: AccountId) -> impl FnMut() -> AccountId { } } - define_names_v2! { [0; 32], increase_by_one, From a87cff272b34d2fc89f9fe024a25b604c76707d3 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 21 Nov 2023 15:32:50 +0100 Subject: [PATCH 034/212] e2e tests successfully adapted to the xcm emulator --- Cargo.lock | 2 + integration-tests/Cargo.toml | 2 + integration-tests/macros/Cargo.toml | 25 + .../macros/src/generate_accounts.rs | 58 +- integration-tests/macros/src/lib.rs | 10 + integration-tests/macros/tests/Cargo.toml | 9 + integration-tests/macros/tests/src/lib.rs | 13 + integration-tests/src/tests/e2e.rs | 788 +++++++++--------- runtimes/shared-configuration/src/funding.rs | 4 +- 9 files changed, 505 insertions(+), 406 deletions(-) create mode 100644 integration-tests/macros/Cargo.toml create mode 100644 integration-tests/macros/src/lib.rs create mode 100644 integration-tests/macros/tests/Cargo.toml create mode 100644 integration-tests/macros/tests/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 7296deba5..df6bb4273 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4126,6 +4126,8 @@ dependencies = [ "cumulus-primitives-core", "frame-support", "frame-system", + "itertools 0.10.5", + "macros", "orml-oracle", "pallet-assets", "pallet-balances", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 3dd81a48b..f354ec46d 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -21,6 +21,7 @@ scale-info = { workspace = true, features = ["derive"] } # Local polimec-receiver.workspace = true +macros.workspace = true sp-arithmetic.workspace = true frame-system.workspace = true @@ -66,6 +67,7 @@ polkadot-runtime.workspace = true statemint-runtime.workspace = true polimec-parachain-runtime.workspace = true penpal-runtime = { path = "./penpal", default-features = false } +itertools = "0.10.5" [features] default = [ "std" ] diff --git a/integration-tests/macros/Cargo.toml b/integration-tests/macros/Cargo.toml new file mode 100644 index 000000000..36d42018c --- /dev/null +++ b/integration-tests/macros/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "macros" +version = "0.1.0" +edition = "2021" + +[lib] +name = "macros" +path = "src/lib.rs" +proc-macro = true +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +quote = "1.0.33" +syn = { version = "2.0.39", features = ["extra-traits"]} +proc-macro2 = "1.0.69" +sp-core.workspace = true + + + +[features] +default = ["std"] + +std = [ + "sp-core/std", +] diff --git a/integration-tests/macros/src/generate_accounts.rs b/integration-tests/macros/src/generate_accounts.rs index 58b984eec..1260ae1b2 100644 --- a/integration-tests/macros/src/generate_accounts.rs +++ b/integration-tests/macros/src/generate_accounts.rs @@ -5,31 +5,51 @@ use core::panic; use proc_macro::TokenStream; -use quote::{quote, ToTokens}; +use quote::{format_ident, quote, ToTokens}; use sp_core::U256; use syn::{parse::{Parse, ParseBuffer, ParseStream}, parse2, parse_macro_input, punctuated::Punctuated, token::Comma, Expr, GenericArgument, GenericParam, Generics, Ident, Result, Token, Type, Visibility, WhereClause, ItemMod}; -pub fn generate_accounts_impl(_args: TokenStream, input: TokenStream) -> TokenStream { - let item = parse_macro_input!(input as ItemMod); - let name = &item.ident; - let content = item.content.expect("Expected accounts defined").1; - let names = parse_macro_input!(content as Punctuated); +pub fn generate_accounts_impl(input: TokenStream) -> TokenStream { + let inputs = parse_macro_input!(input with Punctuated::::parse_terminated); + let mut output = quote! {}; + let mut insertions = Vec::new(); - let mut starting_value = U256::from(0u32); + for input in inputs { + let name = input.to_string(); - let generated_consts = names.iter().enumerate().map(|(i, name)| { - let val = starting_value.checked_add(U256::from(i)).unwrap(); - let const_value: [u8; 32] = val.try_into().unwrap(); - quote! { - pub const #name: [u8; 32] = #const_value; - } - }); + // Ensure the name is all uppercase + if name != name.to_uppercase() { + panic!("Name must be in all uppercase"); + } + + // Generate a unique [u8; 32] value for the constant + let mut value = [0u8; 32]; + for (i, byte) in name.bytes().enumerate() { + value[i % 32] ^= byte; + } + + let ident = format_ident!("{}", name); - let output = quote! { - pub mod #name { - #(#generated_consts)* + // Convert the array into a tuple for the quote macro + let value_iter = value.clone().into_iter(); + + output.extend(quote! { + pub const #input: [u8; 32] = [#(#value_iter), *]; + }); + + insertions.push(quote!{ + names.insert(#input, stringify!(#ident)); + }); + } + + output.extend(quote!{ + pub fn names() -> std::collections::HashMap<[u8; 32], &'static str> { + let mut names = std::collections::HashMap::new(); + #(#insertions)* + names } - }; + }); + - output.into() + TokenStream::from(output) } diff --git a/integration-tests/macros/src/lib.rs b/integration-tests/macros/src/lib.rs new file mode 100644 index 000000000..62e05b143 --- /dev/null +++ b/integration-tests/macros/src/lib.rs @@ -0,0 +1,10 @@ +extern crate proc_macro; +use proc_macro::TokenStream; + +mod generate_accounts; + +#[proc_macro] +pub fn generate_accounts(input: TokenStream) -> TokenStream { + generate_accounts::generate_accounts_impl(input) +} + diff --git a/integration-tests/macros/tests/Cargo.toml b/integration-tests/macros/tests/Cargo.toml new file mode 100644 index 000000000..bbbdba90c --- /dev/null +++ b/integration-tests/macros/tests/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "macros-tests" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +macros.workspace = true diff --git a/integration-tests/macros/tests/src/lib.rs b/integration-tests/macros/tests/src/lib.rs new file mode 100644 index 000000000..5752a76ad --- /dev/null +++ b/integration-tests/macros/tests/src/lib.rs @@ -0,0 +1,13 @@ +use macros::generate_accounts; + +#[test] +fn test_generate_accounts_macro() { + generate_accounts!( + ALICE, + BOB, + ); + + dbg!(ALICE); + dbg!(BOB); + dbg!(names()); +} diff --git a/integration-tests/src/tests/e2e.rs b/integration-tests/src/tests/e2e.rs index 7897213fd..579c816ec 100644 --- a/integration-tests/src/tests/e2e.rs +++ b/integration-tests/src/tests/e2e.rs @@ -2,135 +2,125 @@ use super::*; use crate::{tests::defaults::*, *}; use frame_support::BoundedVec; use pallet_funding::{instantiator::*, *}; -use polimec_parachain_runtime::US_DOLLAR; -use sp_arithmetic::Perquintill; +use polimec_parachain_runtime::{PolimecFunding, US_DOLLAR}; +use sp_arithmetic::{FixedPointNumber, Perquintill}; use sp_core::U256; use sp_runtime::{ traits::{AccountIdConversion, CheckedSub}, FixedU128, }; +use macros::generate_accounts; +use itertools::Itertools; type UserToCTBalance = Vec<(AccountId, BalanceOf, ProjectIdOf)>; -fn increase_by_one(account_id: AccountId) -> impl FnMut() -> AccountId { - let mut num = U256::from(account_id.clone()); - - move || { - let output = num; - num.saturating_add(U256::from(1)); - account_id = num.try_into().unwrap(); - } -} - -define_names_v2! { - [0; 32], - increase_by_one, - LINA, "Lina"; - MIA, "Mia"; - ALEXEY, "Alexey"; - PAUL, "Paul"; - MARIA, "Maria"; - GEORGE, "George"; - CLARA, "Clara"; - RAMONA, "Ramona"; - PASCAL, "Pascal"; - EMMA, "Emma"; - BIBI, "Bibi"; - AHMED, "Ahmed"; - HERBERT, "Herbert"; - LENI, "Leni"; - XI, "Xi"; - TOM, "Tom"; - ADAMS, "Adams"; - POLK, "Polk"; - MARKUS, "Markus"; - ELLA, "Ella"; - SKR, "Skr"; - ARTHUR, "Arthur"; - MILA, "Mila"; - LINCOLN, "Lincoln"; - MONROE, "Monroe"; - ARBRESHA, "Arbresha"; - ELDIN, "Eldin"; - HARDING, "Harding"; - SOFIA, "Sofia"; - DOMINIK, "Dominik"; - NOLAND, "Noland"; - HANNAH, "Hannah"; - HOOVER, "Hoover"; - GIGI, "Gigi"; - JEFFERSON, "Jefferson"; - LINDI, "Lindi"; - KEVIN, "Kevin"; - ANIS, "Anis"; - RETO, "Reto"; - HAALAND, "Haaland"; - XENIA, "Xenia"; - EVA, "Eva"; - SKARA, "Skara"; - ROOSEVELT, "Roosevelt"; - DRACULA, "Dracula"; - DURIM, "Durim"; - HARRISON, "Harrison"; - DRIN, "Drin"; - PARI, "Pari"; - TUTI, "Tuti"; - BENITO, "Benito"; - VANESSA, "Vanessa"; - ENES, "Enes"; - RUDOLF, "Rudolf"; - CERTO, "Certo"; - TIESTO, "Tiesto"; - DAVID, "David"; - ATAKAN, "Atakan"; - YANN, "Yann"; - ENIS, "Enis"; - ALFREDO, "Alfredo"; - QENDRIM, "Qendrim"; - LEONARDO, "Leonardo"; - KEN, "Ken"; - LUCA, "Luca"; - FLAVIO, "Flavio"; - FREDI, "Fredi"; - ALI, "Ali"; - DILARA, "Dilara"; - DAMIAN, "Damian"; - KAYA, "Kaya"; - IAZI, "Iazi"; - CHRIGI, "Chrigi"; - VALENTINA, "Valentina"; - ALMA, "Alma"; - ALENA, "Alena"; - PATRICK, "Patrick"; - ONTARIO, "Ontario"; - RAKIA, "Rakia"; - HUBERT, "Hubert"; - UTUS, "Utus"; - TOME, "Tome"; - ZUBER, "Zuber"; - ADAM, "Adam"; - STANI, "Stani"; - BETI, "Beti"; - HALIT, "Halit"; - DRAGAN, "Dragan"; - LEA, "Lea"; - LUIS, "Luis"; - TATI, "Tati"; - WEST, "West"; - MIRIJAM, "Mirijam"; - LIONEL, "Lionel"; - GIOVANNI, "Giovanni"; - JOEL, "Joel"; - POLKA, "Polk"; - MALIK, "Malik"; - ALEXANDER, "Alexander"; - SOLOMUN, "Solomun"; - JOHNNY, "Johnny"; - GRINGO, "Gringo"; - JONAS, "Jonas"; - BUNDI, "Bundi"; - FELIX, "Felix"; -} +generate_accounts!( + LINA, + MIA, + ALEXEY, + PAUL, + MARIA, + GEORGE, + CLARA, + RAMONA, + PASCAL, + EMMA, + BIBI, + AHMED, + HERBERT, + LENI, + XI, + TOM, + ADAMS, + POLK, + MARKUS, + ELLA, + SKR, + ARTHUR, + MILA, + LINCOLN, + MONROE, + ARBRESHA, + ELDIN, + HARDING, + SOFIA, + DOMINIK, + NOLAND, + HANNAH, + HOOVER, + GIGI, + JEFFERSON, + LINDI, + KEVIN, + ANIS, + RETO, + HAALAND, + XENIA, + EVA, + SKARA, + ROOSEVELT, + DRACULA, + DURIM, + HARRISON, + DRIN, + PARI, + TUTI, + BENITO, + VANESSA, + ENES, + RUDOLF, + CERTO, + TIESTO, + DAVID, + ATAKAN, + YANN, + ENIS, + ALFREDO, + QENDRIM, + LEONARDO, + KEN, + LUCA, + FLAVIO, + FREDI, + ALI, + DILARA, + DAMIAN, + KAYA, + IAZI, + CHRIGI, + VALENTINA, + ALMA, + ALENA, + PATRICK, + ONTARIO, + RAKIA, + HUBERT, + UTUS, + TOME, + ZUBER, + ADAM, + STANI, + BETI, + HALIT, + DRAGAN, + LEA, + LUIS, + TATI, + WEST, + MIRIJAM, + LIONEL, + GIOVANNI, + JOEL, + POLKA, + MALIK, + ALEXANDER, + SOLOMUN, + JOHNNY, + GRINGO, + JONAS, + BUNDI, + FELIX, +); pub fn excel_project(nonce: u64) -> ProjectMetadataOf { let bounded_name = BoundedVec::try_from("Polimec".as_bytes().to_vec()).unwrap(); @@ -155,210 +145,213 @@ pub fn excel_project(nonce: u64) -> ProjectMetadataOf { fn excel_evaluators() -> Vec> { vec![ - UserToUSDBalance::new(LINA, 93754 * US_DOLLAR), - UserToUSDBalance::new(MIA, 162 * US_DOLLAR), - UserToUSDBalance::new(ALEXEY, 7454 * US_DOLLAR), - UserToUSDBalance::new(PAUL, 8192 * US_DOLLAR), - UserToUSDBalance::new(MARIA, 11131 * US_DOLLAR), - UserToUSDBalance::new(GEORGE, 4765 * US_DOLLAR), - UserToUSDBalance::new(CLARA, 4363 * US_DOLLAR), - UserToUSDBalance::new(RAMONA, 4120 * US_DOLLAR), - UserToUSDBalance::new(PASCAL, 1626 * US_DOLLAR), - UserToUSDBalance::new(EMMA, 3996 * US_DOLLAR), - UserToUSDBalance::new(BIBI, 3441 * US_DOLLAR), - UserToUSDBalance::new(AHMED, 8048 * US_DOLLAR), - UserToUSDBalance::new(HERBERT, 2538 * US_DOLLAR), - UserToUSDBalance::new(LENI, 5803 * US_DOLLAR), - UserToUSDBalance::new(XI, 1669 * US_DOLLAR), - UserToUSDBalance::new(TOM, 6526 * US_DOLLAR), + UserToUSDBalance::new(LINA.into(), 93754 * US_DOLLAR), + UserToUSDBalance::new(MIA.into(), 162 * US_DOLLAR), + UserToUSDBalance::new(ALEXEY.into(), 7454 * US_DOLLAR), + UserToUSDBalance::new(PAUL.into(), 8192 * US_DOLLAR), + UserToUSDBalance::new(MARIA.into(), 11131 * US_DOLLAR), + UserToUSDBalance::new(GEORGE.into(), 4765 * US_DOLLAR), + UserToUSDBalance::new(CLARA.into(), 4363 * US_DOLLAR), + UserToUSDBalance::new(RAMONA.into(), 4120 * US_DOLLAR), + UserToUSDBalance::new(PASCAL.into(), 1626 * US_DOLLAR), + UserToUSDBalance::new(EMMA.into(), 3996 * US_DOLLAR), + UserToUSDBalance::new(BIBI.into(), 3441 * US_DOLLAR), + UserToUSDBalance::new(AHMED.into(), 8048 * US_DOLLAR), + UserToUSDBalance::new(HERBERT.into(), 2538 * US_DOLLAR), + UserToUSDBalance::new(LENI.into(), 5803 * US_DOLLAR), + UserToUSDBalance::new(XI.into(), 1669 * US_DOLLAR), + UserToUSDBalance::new(TOM.into(), 6526 * US_DOLLAR), ] } fn excel_bidders() -> Vec> { vec![ - BidParams::from(ADAMS, 700 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(POLK, 4000 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(MARKUS, 3000 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(ELLA, 700 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(SKR, 3400 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(ARTHUR, 1000 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(MILA, 8400 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(LINCOLN, 800 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(MONROE, 1300 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(ARBRESHA, 5000 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(ELDIN, 600 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(HARDING, 800 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(SOFIA, 3000 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(DOMINIK, 8000 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(NOLAND, 900 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(LINA, 8400 * ASSET_UNIT, FixedU128::from_float(10.0)), - BidParams::from(LINA, 1000 * ASSET_UNIT, FixedU128::from_float(11.0)), - BidParams::from(HANNAH, 400 * ASSET_UNIT, FixedU128::from_float(11.0)), - BidParams::from(HOOVER, 2000 * ASSET_UNIT, FixedU128::from_float(11.0)), - BidParams::from(GIGI, 600 * ASSET_UNIT, FixedU128::from_float(11.0)), - BidParams::from(JEFFERSON, 1000 * ASSET_UNIT, FixedU128::from_float(11.0)), - BidParams::from(JEFFERSON, 2000 * ASSET_UNIT, FixedU128::from_float(12.0)), + BidParams::from(ADAMS.into(), 700 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(POLK.into(), 4000 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(MARKUS.into(), 3000 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(ELLA.into(), 700 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(SKR.into(), 3400 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(ARTHUR.into(), 1000 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(MILA.into(), 8400 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(LINCOLN.into(), 800 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(MONROE.into(), 1300 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(ARBRESHA.into(), 5000 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(ELDIN.into(), 600 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(HARDING.into(), 800 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(SOFIA.into(), 3000 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(DOMINIK.into(), 8000 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(NOLAND.into(), 900 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(LINA.into(), 8400 * ASSET_UNIT, FixedU128::from_float(10.0)), + BidParams::from(LINA.into(), 1000 * ASSET_UNIT, FixedU128::from_float(11.0)), + BidParams::from(HANNAH.into(), 400 * ASSET_UNIT, FixedU128::from_float(11.0)), + BidParams::from(HOOVER.into(), 2000 * ASSET_UNIT, FixedU128::from_float(11.0)), + BidParams::from(GIGI.into(), 600 * ASSET_UNIT, FixedU128::from_float(11.0)), + BidParams::from(JEFFERSON.into(), 1000 * ASSET_UNIT, FixedU128::from_float(11.0)), + BidParams::from(JEFFERSON.into(), 2000 * ASSET_UNIT, FixedU128::from_float(12.0)), ] } -fn excel_contributors() -> Vec> { +fn excel_contributions() -> Vec> { vec![ - ContributionParams::from(DRIN, 692 * US_DOLLAR), - ContributionParams::from(PARI, 236 * US_DOLLAR), - ContributionParams::from(TUTI, 24 * US_DOLLAR), - ContributionParams::from(BENITO, 688 * US_DOLLAR), - ContributionParams::from(VANESSA, 33 * US_DOLLAR), - ContributionParams::from(ENES, 1148 * US_DOLLAR), - ContributionParams::from(RUDOLF, 35 * US_DOLLAR), - ContributionParams::from(CERTO, 840 * US_DOLLAR), - ContributionParams::from(TIESTO, 132 * US_DOLLAR), - ContributionParams::from(DAVID, 21 * US_DOLLAR), - ContributionParams::from(ATAKAN, 59 * US_DOLLAR), - ContributionParams::from(YANN, 89 * US_DOLLAR), - ContributionParams::from(ENIS, 332 * US_DOLLAR), - ContributionParams::from(ALFREDO, 8110 * US_DOLLAR), - ContributionParams::from(QENDRIM, 394 * US_DOLLAR), - ContributionParams::from(LEONARDO, 840 * US_DOLLAR), - ContributionParams::from(KEN, 352 * US_DOLLAR), - ContributionParams::from(LUCA, 640 * US_DOLLAR), + ContributionParams::from(DRIN.into(), 692 * US_DOLLAR), + ContributionParams::from(PARI.into(), 236 * US_DOLLAR), + ContributionParams::from(TUTI.into(), 24 * US_DOLLAR), + ContributionParams::from(BENITO.into(), 688 * US_DOLLAR), + ContributionParams::from(VANESSA.into(), 33 * US_DOLLAR), + ContributionParams::from(ENES.into(), 1148 * US_DOLLAR), + ContributionParams::from(RUDOLF.into(), 35 * US_DOLLAR), + ContributionParams::from(CERTO.into(), 840 * US_DOLLAR), + ContributionParams::from(TIESTO.into(), 132 * US_DOLLAR), + ContributionParams::from(DAVID.into(), 21 * US_DOLLAR), + ContributionParams::from(ATAKAN.into(), 59 * US_DOLLAR), + ContributionParams::from(YANN.into(), 89 * US_DOLLAR), + ContributionParams::from(ENIS.into(), 332 * US_DOLLAR), + ContributionParams::from(ALFREDO.into(), 8110 * US_DOLLAR), + ContributionParams::from(QENDRIM.into(), 394 * US_DOLLAR), + ContributionParams::from(LEONARDO.into(), 840 * US_DOLLAR), + ContributionParams::from(KEN.into(), 352 * US_DOLLAR), + ContributionParams::from(LUCA.into(), 640 * US_DOLLAR), // TODO: XI is a partipant in the Community Round AND an Evaluator. At the moment, this returns `InsufficientBalance` because it seems we don't mint to him enough USDT. // To be addressed and tested in a separate PR. //ContributionParams::from(XI, 588 * US_DOLLAR), - ContributionParams::from(FLAVIO, 792 * US_DOLLAR), - ContributionParams::from(FREDI, 993 * US_DOLLAR), - ContributionParams::from(ALI, 794 * US_DOLLAR), - ContributionParams::from(DILARA, 256 * US_DOLLAR), - ContributionParams::from(DAMIAN, 431 * US_DOLLAR), - ContributionParams::from(KAYA, 935 * US_DOLLAR), - ContributionParams::from(IAZI, 174 * US_DOLLAR), - ContributionParams::from(CHRIGI, 877 * US_DOLLAR), - ContributionParams::from(VALENTINA, 961 * US_DOLLAR), - ContributionParams::from(ALMA, 394 * US_DOLLAR), - ContributionParams::from(ALENA, 442 * US_DOLLAR), - ContributionParams::from(PATRICK, 486 * US_DOLLAR), - ContributionParams::from(ONTARIO, 17 * US_DOLLAR), - ContributionParams::from(RAKIA, 9424 * US_DOLLAR), - ContributionParams::from(HUBERT, 14 * US_DOLLAR), - ContributionParams::from(UTUS, 4906 * US_DOLLAR), - ContributionParams::from(TOME, 68 * US_DOLLAR), - ContributionParams::from(ZUBER, 9037 * US_DOLLAR), - ContributionParams::from(ADAM, 442 * US_DOLLAR), - ContributionParams::from(STANI, 40 * US_DOLLAR), - ContributionParams::from(BETI, 68 * US_DOLLAR), - ContributionParams::from(HALIT, 68 * US_DOLLAR), - ContributionParams::from(DRAGAN, 98 * US_DOLLAR), - ContributionParams::from(LEA, 17 * US_DOLLAR), - ContributionParams::from(LUIS, 422 * US_DOLLAR), + ContributionParams::from(FLAVIO.into(), 792 * US_DOLLAR), + ContributionParams::from(FREDI.into(), 993 * US_DOLLAR), + ContributionParams::from(ALI.into(), 794 * US_DOLLAR), + ContributionParams::from(DILARA.into(), 256 * US_DOLLAR), + ContributionParams::from(DAMIAN.into(), 431 * US_DOLLAR), + ContributionParams::from(KAYA.into(), 935 * US_DOLLAR), + ContributionParams::from(IAZI.into(), 174 * US_DOLLAR), + ContributionParams::from(CHRIGI.into(), 877 * US_DOLLAR), + ContributionParams::from(VALENTINA.into(), 961 * US_DOLLAR), + ContributionParams::from(ALMA.into(), 394 * US_DOLLAR), + ContributionParams::from(ALENA.into(), 442 * US_DOLLAR), + ContributionParams::from(PATRICK.into(), 486 * US_DOLLAR), + ContributionParams::from(ONTARIO.into(), 17 * US_DOLLAR), + ContributionParams::from(RAKIA.into(), 9424 * US_DOLLAR), + ContributionParams::from(HUBERT.into(), 14 * US_DOLLAR), + ContributionParams::from(UTUS.into(), 4906 * US_DOLLAR), + ContributionParams::from(TOME.into(), 68 * US_DOLLAR), + ContributionParams::from(ZUBER.into(), 9037 * US_DOLLAR), + ContributionParams::from(ADAM.into(), 442 * US_DOLLAR), + ContributionParams::from(STANI.into(), 40 * US_DOLLAR), + ContributionParams::from(BETI.into(), 68 * US_DOLLAR), + ContributionParams::from(HALIT.into(), 68 * US_DOLLAR), + ContributionParams::from(DRAGAN.into(), 98 * US_DOLLAR), + ContributionParams::from(LEA.into(), 17 * US_DOLLAR), + ContributionParams::from(LUIS.into(), 422 * US_DOLLAR), ] } fn excel_remainders() -> Vec> { vec![ - ContributionParams::from(JOEL, 692 * US_DOLLAR), - ContributionParams::from(POLK, 236 * US_DOLLAR), - ContributionParams::from(MALIK, 24 * US_DOLLAR), - ContributionParams::from(LEA, 688 * US_DOLLAR), - ContributionParams::from(RAMONA, 35 * US_DOLLAR), - ContributionParams::from(SOLOMUN, 840 * US_DOLLAR), - ContributionParams::from(JONAS, 59 * US_DOLLAR), + ContributionParams::from(JOEL.into(), 692 * US_DOLLAR), + ContributionParams::from(POLK.into(), 236 * US_DOLLAR), + ContributionParams::from(MALIK.into(), 24 * US_DOLLAR), + ContributionParams::from(LEA.into(), 688 * US_DOLLAR), + ContributionParams::from(RAMONA.into(), 35 * US_DOLLAR), + ContributionParams::from(SOLOMUN.into(), 840 * US_DOLLAR), + ContributionParams::from(JONAS.into(), 59 * US_DOLLAR), ] } fn excel_ct_amounts() -> UserToCTBalance { vec![ - (LINA, 42916134112336, 0), - (MIA, 32685685157, 0), - (ALEXEY, 1422329504123, 0), - (PAUL, 1164821313204, 0), - (MARIA, 1582718022129, 0), - (GEORGE, 677535834646, 0), - (CLARA, 620375413759, 0), - (RAMONA, 935823219043, 0), - (PASCAL, 231201105380, 0), - (EMMA, 568191646431, 0), - (BIBI, 489276139982, 0), - (AHMED, 1144345938558, 0), - (HERBERT, 360878478139, 0), - (LENI, 825129160220, 0), - (XI, 237315279753, 0), - (TOM, 927932603756, 0), - (ADAMS, 700 * ASSET_UNIT, 0), - (POLK, 4236 * ASSET_UNIT, 0), - (MARKUS, 3000 * ASSET_UNIT, 0), - (ELLA, 700 * ASSET_UNIT, 0), - (SKR, 3400 * ASSET_UNIT, 0), - (ARTHUR, 1000 * ASSET_UNIT, 0), - (MILA, 8400 * ASSET_UNIT, 0), - (LINCOLN, 800 * ASSET_UNIT, 0), - (MONROE, 1300 * ASSET_UNIT, 0), - (ARBRESHA, 5000 * ASSET_UNIT, 0), - (ELDIN, 600 * ASSET_UNIT, 0), - (HARDING, 800 * ASSET_UNIT, 0), - (SOFIA, 3000 * ASSET_UNIT, 0), - (DOMINIK, 8000 * ASSET_UNIT, 0), - (NOLAND, 900 * ASSET_UNIT, 0), - (HANNAH, 400 * ASSET_UNIT, 0), - (HOOVER, 2000 * ASSET_UNIT, 0), - (GIGI, 600 * ASSET_UNIT, 0), - (JEFFERSON, 3000 * ASSET_UNIT, 0), - (DRIN, 692 * ASSET_UNIT, 0), - (PARI, 236 * ASSET_UNIT, 0), - (TUTI, 24 * ASSET_UNIT, 0), - (BENITO, 688 * ASSET_UNIT, 0), - (VANESSA, 33 * ASSET_UNIT, 0), - (ENES, 1148 * ASSET_UNIT, 0), - (RUDOLF, 35 * ASSET_UNIT, 0), - (CERTO, 840 * ASSET_UNIT, 0), - (TIESTO, 132 * ASSET_UNIT, 0), - (DAVID, 21 * ASSET_UNIT, 0), - (ATAKAN, 59 * ASSET_UNIT, 0), - (YANN, 89 * ASSET_UNIT, 0), - (ENIS, 332 * ASSET_UNIT, 0), - (ALFREDO, 8110 * ASSET_UNIT, 0), - (QENDRIM, 394 * ASSET_UNIT, 0), - (LEONARDO, 840 * ASSET_UNIT, 0), - (KEN, 352 * ASSET_UNIT, 0), - (LUCA, 640 * ASSET_UNIT, 0), - (FLAVIO, 792 * ASSET_UNIT, 0), - (FREDI, 993 * ASSET_UNIT, 0), - (ALI, 794 * ASSET_UNIT, 0), - (DILARA, 256 * ASSET_UNIT, 0), - (DAMIAN, 431 * ASSET_UNIT, 0), - (KAYA, 935 * ASSET_UNIT, 0), - (IAZI, 174 * ASSET_UNIT, 0), - (CHRIGI, 877 * ASSET_UNIT, 0), - (VALENTINA, 961 * ASSET_UNIT, 0), - (ALMA, 394 * ASSET_UNIT, 0), - (ALENA, 442 * ASSET_UNIT, 0), - (PATRICK, 486 * ASSET_UNIT, 0), - (ONTARIO, 17 * ASSET_UNIT, 0), - (RAKIA, 9424 * ASSET_UNIT, 0), - (HUBERT, 14 * ASSET_UNIT, 0), - (UTUS, 4906 * ASSET_UNIT, 0), - (TOME, 68 * ASSET_UNIT, 0), - (ZUBER, 9037 * ASSET_UNIT, 0), - (ADAM, 442 * ASSET_UNIT, 0), - (STANI, 40 * ASSET_UNIT, 0), - (BETI, 68 * ASSET_UNIT, 0), - (HALIT, 68 * ASSET_UNIT, 0), - (DRAGAN, 98 * ASSET_UNIT, 0), - (LEA, 705 * ASSET_UNIT, 0), - (LUIS, 422 * ASSET_UNIT, 0), - (JOEL, 692 * ASSET_UNIT, 0), - (MALIK, 24 * ASSET_UNIT, 0), - (SOLOMUN, 840 * ASSET_UNIT, 0), - (JONAS, 59 * ASSET_UNIT, 0), + (LINA.into(), 42916134112336, 0), + (MIA.into(), 32685685157, 0), + (ALEXEY.into(), 1422329504123, 0), + (PAUL.into(), 1164821313204, 0), + (MARIA.into(), 1582718022129, 0), + (GEORGE.into(), 677535834646, 0), + (CLARA.into(), 620375413759, 0), + (RAMONA.into(), 935823219043, 0), + (PASCAL.into(), 231201105380, 0), + (EMMA.into(), 568191646431, 0), + (BIBI.into(), 489276139982, 0), + (AHMED.into(), 1144345938558, 0), + (HERBERT.into(), 360878478139, 0), + (LENI.into(), 825129160220, 0), + (XI.into(), 237315279753, 0), + (TOM.into(), 927932603756, 0), + (ADAMS.into(), 700 * ASSET_UNIT, 0), + (POLK.into(), 4236 * ASSET_UNIT, 0), + (MARKUS.into(), 3000 * ASSET_UNIT, 0), + (ELLA.into(), 700 * ASSET_UNIT, 0), + (SKR.into(), 3400 * ASSET_UNIT, 0), + (ARTHUR.into(), 1000 * ASSET_UNIT, 0), + (MILA.into(), 8400 * ASSET_UNIT, 0), + (LINCOLN.into(), 800 * ASSET_UNIT, 0), + (MONROE.into(), 1300 * ASSET_UNIT, 0), + (ARBRESHA.into(), 5000 * ASSET_UNIT, 0), + (ELDIN.into(), 600 * ASSET_UNIT, 0), + (HARDING.into(), 800 * ASSET_UNIT, 0), + (SOFIA.into(), 3000 * ASSET_UNIT, 0), + (DOMINIK.into(), 8000 * ASSET_UNIT, 0), + (NOLAND.into(), 900 * ASSET_UNIT, 0), + (HANNAH.into(), 400 * ASSET_UNIT, 0), + (HOOVER.into(), 2000 * ASSET_UNIT, 0), + (GIGI.into(), 600 * ASSET_UNIT, 0), + (JEFFERSON.into(), 3000 * ASSET_UNIT, 0), + (DRIN.into(), 692 * ASSET_UNIT, 0), + (PARI.into(), 236 * ASSET_UNIT, 0), + (TUTI.into(), 24 * ASSET_UNIT, 0), + (BENITO.into(), 688 * ASSET_UNIT, 0), + (VANESSA.into(), 33 * ASSET_UNIT, 0), + (ENES.into(), 1148 * ASSET_UNIT, 0), + (RUDOLF.into(), 35 * ASSET_UNIT, 0), + (CERTO.into(), 840 * ASSET_UNIT, 0), + (TIESTO.into(), 132 * ASSET_UNIT, 0), + (DAVID.into(), 21 * ASSET_UNIT, 0), + (ATAKAN.into(), 59 * ASSET_UNIT, 0), + (YANN.into(), 89 * ASSET_UNIT, 0), + (ENIS.into(), 332 * ASSET_UNIT, 0), + (ALFREDO.into(), 8110 * ASSET_UNIT, 0), + (QENDRIM.into(), 394 * ASSET_UNIT, 0), + (LEONARDO.into(), 840 * ASSET_UNIT, 0), + (KEN.into(), 352 * ASSET_UNIT, 0), + (LUCA.into(), 640 * ASSET_UNIT, 0), + (FLAVIO.into(), 792 * ASSET_UNIT, 0), + (FREDI.into(), 993 * ASSET_UNIT, 0), + (ALI.into(), 794 * ASSET_UNIT, 0), + (DILARA.into(), 256 * ASSET_UNIT, 0), + (DAMIAN.into(), 431 * ASSET_UNIT, 0), + (KAYA.into(), 935 * ASSET_UNIT, 0), + (IAZI.into(), 174 * ASSET_UNIT, 0), + (CHRIGI.into(), 877 * ASSET_UNIT, 0), + (VALENTINA.into(), 961 * ASSET_UNIT, 0), + (ALMA.into(), 394 * ASSET_UNIT, 0), + (ALENA.into(), 442 * ASSET_UNIT, 0), + (PATRICK.into(), 486 * ASSET_UNIT, 0), + (ONTARIO.into(), 17 * ASSET_UNIT, 0), + (RAKIA.into(), 9424 * ASSET_UNIT, 0), + (HUBERT.into(), 14 * ASSET_UNIT, 0), + (UTUS.into(), 4906 * ASSET_UNIT, 0), + (TOME.into(), 68 * ASSET_UNIT, 0), + (ZUBER.into(), 9037 * ASSET_UNIT, 0), + (ADAM.into(), 442 * ASSET_UNIT, 0), + (STANI.into(), 40 * ASSET_UNIT, 0), + (BETI.into(), 68 * ASSET_UNIT, 0), + (HALIT.into(), 68 * ASSET_UNIT, 0), + (DRAGAN.into(), 98 * ASSET_UNIT, 0), + (LEA.into(), 705 * ASSET_UNIT, 0), + (LUIS.into(), 422 * ASSET_UNIT, 0), + (JOEL.into(), 692 * ASSET_UNIT, 0), + (MALIK.into(), 24 * ASSET_UNIT, 0), + (SOLOMUN.into(), 840 * ASSET_UNIT, 0), + (JONAS.into(), 59 * ASSET_UNIT, 0), ] } #[test] fn evaluation_round_completed() { let mut inst = IntegrationInstantiator::new(None); + let issuer = issuer(); let project = excel_project(inst.get_new_nonce()); let evaluations = excel_evaluators(); - inst.create_auctioning_project(project, issuer(), evaluations); + Polimec::execute_with(|| { + inst.create_auctioning_project(project, issuer, evaluations); + }); } #[test] @@ -368,130 +361,155 @@ fn auction_round_completed() { let project = excel_project(inst.get_new_nonce()); let evaluations = excel_evaluators(); let bids = excel_bidders(); - //let filtered_bids = MockInstantiator::filter_bids_after_auction(bids.clone(), project.total_allocation_size.0); - let (project_id, _) = inst.create_community_contributing_project(project, issuer(), evaluations, bids); - let wavgp_from_excel = 10.202357561; - // Convert the float to a FixedU128 - let wavgp_to_substrate = FixedU128::from_float(wavgp_from_excel); - dbg!(wavgp_to_substrate); - let wavgp_from_chain = inst.get_project_details(project_id).weighted_average_price.unwrap(); - dbg!(wavgp_from_chain); - let res = wavgp_from_chain.checked_sub(&wavgp_to_substrate).unwrap(); - // We are more precise than Excel. From the 11th decimal onwards, the difference should be less than 0.00001. - assert!(res < FixedU128::from_float(0.00001)); - let names = names(); - inst.execute(|| { - let bids = Bids::::iter_prefix_values((0,)).sorted_by_key(|bid| bid.bidder).collect_vec(); - for bid in bids.clone() { - println!("{}: {}", names[&bid.bidder], bid.funding_asset_amount_locked); - } - let total_participation = bids.into_iter().fold(0, |acc, bid| acc + bid.funding_asset_amount_locked); - dbg!(total_participation); - }) + Polimec::execute_with(|| { + //let filtered_bids = MockInstantiator::filter_bids_after_auction(bids.clone(), project.total_allocation_size.0); + let (project_id, _) = inst.create_community_contributing_project(project, issuer, evaluations, bids); + let wavgp_from_excel = 10.202357561; + // Convert the float to a FixedU128 + let wavgp_to_substrate = FixedU128::from_float(wavgp_from_excel); + dbg!(wavgp_to_substrate); + let wavgp_from_chain = inst.get_project_details(project_id).weighted_average_price.unwrap(); + dbg!(wavgp_from_chain); + let res = wavgp_from_chain.checked_sub(&wavgp_to_substrate).unwrap(); + // We are more precise than Excel. From the 11th decimal onwards, the difference should be less than 0.00001. + assert!(res < FixedU128::from_float(0.00001)); + let names = names(); + inst.execute(|| { + let bids = Bids::::iter_prefix_values((0, )).sorted_by_key(|bid| bid.bidder.clone()).collect_vec(); + + for bid in bids.clone() { + let key: [u8; 32] = bid.bidder.clone().into(); + println!("{}: {}", names[&key], bid.funding_asset_amount_locked); + } + let total_participation = bids.into_iter().fold(0, |acc, bid| acc + bid.funding_asset_amount_locked); + dbg!(total_participation); + }) + }); } #[test] fn community_round_completed() { let mut inst = IntegrationInstantiator::new(None); - let _ = inst.create_remainder_contributing_project( - excel_project(0), - issuer(), - excel_evaluators(), - excel_bidders(), - excel_contributors(), - ); - inst.execute(|| { - let contributions = Contributions::::iter_prefix_values((0,)) - .sorted_by_key(|bid| bid.contributor) - .collect_vec(); - let total_contribution = contributions.clone().into_iter().fold(0, |acc, bid| acc + bid.funding_asset_amount); - let total_contribution_as_fixed = FixedU128::from_rational(total_contribution, PLMC); - dbg!(total_contribution_as_fixed); - // In USD - // let total_ct_amount = contributions.clone().into_iter().fold(0, |acc, bid| acc + bid.ct_amount); - // let total_contribution_from_excel = 46821.0; - // dbg!(total_contribution_from_excel); - // let res = total_contribution_as_fixed - FixedU128::from_float(total_contribution_from_excel); - // // We are more precise than Excel. From the 11th decimal onwards, the difference should be less than 0.001. - // assert!(res < FixedU128::from_float(0.001)); - // let total_ct_sold_from_excel = 46821; - // assert_eq!(total_ct_amount / PLMC, total_ct_sold_from_excel); - }) + Polimec::execute_with(|| { + let _ = inst.create_remainder_contributing_project( + excel_project(0), + issuer(), + excel_evaluators(), + excel_bidders(), + excel_contributions(), + ); + + inst.execute(|| { + let contributions = Contributions::::iter_prefix_values((0, )) + .sorted_by_key(|bid| bid.contributor.clone()) + .collect_vec(); + let total_contribution = contributions.clone().into_iter().fold(0, |acc, bid| acc + bid.funding_asset_amount); + let total_contribution_as_fixed = FixedU128::from_rational(total_contribution, PLMC); + dbg!(total_contribution_as_fixed); + // In USD + // let total_ct_amount = contributions.clone().into_iter().fold(0, |acc, bid| acc + bid.ct_amount); + // let total_contribution_from_excel = 46821.0; + // dbg!(total_contribution_from_excel); + // let res = total_contribution_as_fixed - FixedU128::from_float(total_contribution_from_excel); + // // We are more precise than Excel. From the 11th decimal onwards, the difference should be less than 0.001. + // assert!(res < FixedU128::from_float(0.001)); + // let total_ct_sold_from_excel = 46821; + // assert_eq!(total_ct_amount / PLMC, total_ct_sold_from_excel); + }) + }); } #[test] fn remainder_round_completed() { let mut inst = IntegrationInstantiator::new(None); - let _ = inst.create_finished_project( - excel_project(0), - issuer(), - excel_evaluators(), - excel_bidders(), - excel_contributors(), - excel_remainders(), - ); - inst.execute(|| { - let contributions = Contributions::::iter_prefix_values((0,)) - .sorted_by_key(|bid| bid.contributor) + Polimec::execute_with(|| { + let project_id = inst.create_finished_project( + excel_project(0), + issuer(), + excel_evaluators(), + excel_bidders(), + excel_contributions(), + excel_remainders(), + ); + + let price = inst.get_project_details(project_id).weighted_average_price.unwrap(); + let price_as_u128 = price.checked_mul_int(1_0_000_000_000u128).unwrap(); + dbg!(price_as_u128); + let funding_necessary_1 = IntegrationInstantiator::calculate_contributed_funding_asset_spent(excel_contributions(), price); + let funding_necessary_2 = IntegrationInstantiator::calculate_contributed_funding_asset_spent(excel_remainders(), price); + let mut total = 0u128; + for item in funding_necessary_1 { + total += item.asset_amount; + } + for item in funding_necessary_2 { + total += item.asset_amount; + } + dbg!(total); + let contributions = Contributions::::iter_prefix_values((0, )) + .sorted_by_key(|contribution| contribution.contributor.clone()) .collect_vec(); - let total_contributions = contributions.into_iter().fold(0, |acc, bid| acc + bid.funding_asset_amount); - dbg!(total_contributions); + let total_contributions = contributions.into_iter().fold(0, |acc, contribution| acc + contribution.funding_asset_amount); let total_contributions_as_fixed = FixedU128::from_rational(total_contributions, PLMC); + dbg!(total_contributions_as_fixed); let total_from_excel = 503945.4517; let total_to_substrate = FixedU128::from_float(total_from_excel); dbg!(total_to_substrate); let res = total_contributions_as_fixed.checked_sub(&total_to_substrate).unwrap(); // We are more precise than Excel. From the 11th decimal onwards, the difference should be less than 0.0001. assert!(res < FixedU128::from_float(0.001)); - }) + }); } #[test] fn funds_raised() { let mut inst = IntegrationInstantiator::new(None); - let _ = inst.create_finished_project( - excel_project(0), - issuer(), - excel_evaluators(), - excel_bidders(), - excel_contributors(), - excel_remainders(), - ); - inst.execute(|| { - let pallet_id = ::PalletId::get(); - let project_specific_account: u64 = pallet_id.into_sub_account_truncating(0); - let funding = StatemintAssets::balance(1984, project_specific_account); - let fund_raised_from_excel = 1005361.955; - let fund_raised_to_substrate = FixedU128::from_float(fund_raised_from_excel); - let fund_raised_as_fixed = FixedU128::from_rational(funding, ASSET_UNIT); - let res = fund_raised_to_substrate.checked_sub(&fund_raised_as_fixed).unwrap(); - // We are more precise than Excel. From the 11th decimal onwards, the difference should be less than 0.0003. - assert!(res < FixedU128::from_float(0.001)); - }) + Polimec::execute_with(|| { + let project_id = inst.create_finished_project( + excel_project(0), + issuer(), + excel_evaluators(), + excel_bidders(), + excel_contributions(), + excel_remainders(), + ); + + inst.execute(|| { + let project_specific_account: AccountId = PolimecFunding::fund_account_id(project_id); + let funding = PolimecStatemintAssets::balance(AcceptedFundingAsset::USDT.to_statemint_id(), project_specific_account); + let fund_raised_from_excel = 1005361.955; + let fund_raised_to_substrate = FixedU128::from_float(fund_raised_from_excel); + let fund_raised_as_fixed = FixedU128::from_rational(funding, ASSET_UNIT); + let res = fund_raised_to_substrate.checked_sub(&fund_raised_as_fixed).unwrap(); + // We are more precise than Excel. From the 11th decimal onwards, the difference should be less than 0.0003. + assert!(res < FixedU128::from_float(0.001)); + }) + }); } #[test] fn ct_minted() { let mut inst = IntegrationInstantiator::new(None); - let _ = inst.create_finished_project( - excel_project(0), - issuer(), - excel_evaluators(), - excel_bidders(), - excel_contributors(), - excel_remainders(), - ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + Polimec::execute_with(|| { + let _ = inst.create_finished_project( + excel_project(0), + issuer(), + excel_evaluators(), + excel_bidders(), + excel_contributions(), + excel_remainders(), + ); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - inst.advance_time(10).unwrap(); + inst.advance_time(10).unwrap(); - for (contributor, expected_amount, project_id) in excel_ct_amounts() { - let minted = - inst.execute(|| ::ContributionTokenCurrency::balance(project_id, &contributor)); - assert_close_enough!(minted, expected_amount, Perquintill::from_parts(10_000_000_000u64)); - } + for (contributor, expected_amount, project_id) in excel_ct_amounts() { + let minted = + inst.execute(|| ::ContributionTokenCurrency::balance(project_id, &contributor)); + assert_close_enough!(minted, expected_amount, Perquintill::from_parts(10_000_000_000u64)); + } + }); } diff --git a/runtimes/shared-configuration/src/funding.rs b/runtimes/shared-configuration/src/funding.rs index 5c3eeb7c0..8153bdef6 100644 --- a/runtimes/shared-configuration/src/funding.rs +++ b/runtimes/shared-configuration/src/funding.rs @@ -79,8 +79,8 @@ parameter_types! { pub const FundingPalletId: PalletId = PalletId(*b"py/cfund"); pub PriceMap: BTreeMap = BTreeMap::from_iter(vec![ (AcceptedFundingAsset::DOT.to_statemint_id(), FixedU128::from_rational(69, 1)), // DOT - (AcceptedFundingAsset::USDC.to_statemint_id(), FixedU128::from_rational(97, 100)), // USDC - (AcceptedFundingAsset::USDT.to_statemint_id(), FixedU128::from_rational(95, 100)), // USDT + (AcceptedFundingAsset::USDC.to_statemint_id(), FixedU128::from_rational(100, 100)), // USDC + (AcceptedFundingAsset::USDT.to_statemint_id(), FixedU128::from_rational(100, 100)), // USDT (pallet_funding::PLMC_STATEMINT_ID, FixedU128::from_rational(840, 100)), // PLMC ]); pub FeeBrackets: Vec<(Percent, Balance)> = vec![ From a65814aa829e77d3af9068d72dca2427af26f766 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 21 Nov 2023 15:45:38 +0100 Subject: [PATCH 035/212] Testnet now using Oracle, and e2e successfully passing. --- .../macros/src/generate_accounts.rs | 91 ++++---- integration-tests/macros/src/lib.rs | 3 +- integration-tests/macros/tests/src/lib.rs | 11 +- integration-tests/src/tests/e2e.rs | 200 +++++++----------- runtimes/testnet/src/lib.rs | 2 +- 5 files changed, 136 insertions(+), 171 deletions(-) diff --git a/integration-tests/macros/src/generate_accounts.rs b/integration-tests/macros/src/generate_accounts.rs index 1260ae1b2..32bd86dc9 100644 --- a/integration-tests/macros/src/generate_accounts.rs +++ b/integration-tests/macros/src/generate_accounts.rs @@ -7,49 +7,54 @@ use core::panic; use proc_macro::TokenStream; use quote::{format_ident, quote, ToTokens}; use sp_core::U256; -use syn::{parse::{Parse, ParseBuffer, ParseStream}, parse2, parse_macro_input, punctuated::Punctuated, token::Comma, Expr, GenericArgument, GenericParam, Generics, Ident, Result, Token, Type, Visibility, WhereClause, ItemMod}; +use syn::{ + parse::{Parse, ParseBuffer, ParseStream}, + parse2, parse_macro_input, + punctuated::Punctuated, + token::Comma, + Expr, GenericArgument, GenericParam, Generics, Ident, ItemMod, Result, Token, Type, Visibility, WhereClause, +}; pub fn generate_accounts_impl(input: TokenStream) -> TokenStream { - let inputs = parse_macro_input!(input with Punctuated::::parse_terminated); - let mut output = quote! {}; - let mut insertions = Vec::new(); - - for input in inputs { - let name = input.to_string(); - - // Ensure the name is all uppercase - if name != name.to_uppercase() { - panic!("Name must be in all uppercase"); - } - - // Generate a unique [u8; 32] value for the constant - let mut value = [0u8; 32]; - for (i, byte) in name.bytes().enumerate() { - value[i % 32] ^= byte; - } - - let ident = format_ident!("{}", name); - - // Convert the array into a tuple for the quote macro - let value_iter = value.clone().into_iter(); - - output.extend(quote! { - pub const #input: [u8; 32] = [#(#value_iter), *]; - }); - - insertions.push(quote!{ - names.insert(#input, stringify!(#ident)); - }); - } - - output.extend(quote!{ - pub fn names() -> std::collections::HashMap<[u8; 32], &'static str> { - let mut names = std::collections::HashMap::new(); - #(#insertions)* - names - } - }); - - - TokenStream::from(output) + let inputs = parse_macro_input!(input with Punctuated::::parse_terminated); + let mut output = quote! {}; + let mut insertions = Vec::new(); + + for input in inputs { + let name = input.to_string(); + + // Ensure the name is all uppercase + if name != name.to_uppercase() { + panic!("Name must be in all uppercase"); + } + + // Generate a unique [u8; 32] value for the constant + let mut value = [0u8; 32]; + for (i, byte) in name.bytes().enumerate() { + value[i % 32] ^= byte; + } + + let ident = format_ident!("{}", name); + + // Convert the array into a tuple for the quote macro + let value_iter = value.clone().into_iter(); + + output.extend(quote! { + pub const #input: [u8; 32] = [#(#value_iter), *]; + }); + + insertions.push(quote! { + names.insert(#input, stringify!(#ident)); + }); + } + + output.extend(quote! { + pub fn names() -> std::collections::HashMap<[u8; 32], &'static str> { + let mut names = std::collections::HashMap::new(); + #(#insertions)* + names + } + }); + + TokenStream::from(output) } diff --git a/integration-tests/macros/src/lib.rs b/integration-tests/macros/src/lib.rs index 62e05b143..144dd1d59 100644 --- a/integration-tests/macros/src/lib.rs +++ b/integration-tests/macros/src/lib.rs @@ -5,6 +5,5 @@ mod generate_accounts; #[proc_macro] pub fn generate_accounts(input: TokenStream) -> TokenStream { - generate_accounts::generate_accounts_impl(input) + generate_accounts::generate_accounts_impl(input) } - diff --git a/integration-tests/macros/tests/src/lib.rs b/integration-tests/macros/tests/src/lib.rs index 5752a76ad..868eb7f28 100644 --- a/integration-tests/macros/tests/src/lib.rs +++ b/integration-tests/macros/tests/src/lib.rs @@ -2,12 +2,9 @@ use macros::generate_accounts; #[test] fn test_generate_accounts_macro() { - generate_accounts!( - ALICE, - BOB, - ); + generate_accounts!(ALICE, BOB,); - dbg!(ALICE); - dbg!(BOB); - dbg!(names()); + dbg!(ALICE); + dbg!(BOB); + dbg!(names()); } diff --git a/integration-tests/src/tests/e2e.rs b/integration-tests/src/tests/e2e.rs index 579c816ec..a660cb8d0 100644 --- a/integration-tests/src/tests/e2e.rs +++ b/integration-tests/src/tests/e2e.rs @@ -1,6 +1,8 @@ use super::*; use crate::{tests::defaults::*, *}; -use frame_support::BoundedVec; +use frame_support::{bounded_vec, BoundedVec}; +use itertools::Itertools; +use macros::generate_accounts; use pallet_funding::{instantiator::*, *}; use polimec_parachain_runtime::{PolimecFunding, US_DOLLAR}; use sp_arithmetic::{FixedPointNumber, Perquintill}; @@ -9,119 +11,67 @@ use sp_runtime::{ traits::{AccountIdConversion, CheckedSub}, FixedU128, }; -use macros::generate_accounts; -use itertools::Itertools; +use std::collections::HashMap; type UserToCTBalance = Vec<(AccountId, BalanceOf, ProjectIdOf)>; generate_accounts!( - LINA, - MIA, - ALEXEY, - PAUL, - MARIA, - GEORGE, - CLARA, - RAMONA, - PASCAL, - EMMA, - BIBI, - AHMED, - HERBERT, - LENI, - XI, - TOM, - ADAMS, - POLK, - MARKUS, - ELLA, - SKR, - ARTHUR, - MILA, - LINCOLN, - MONROE, - ARBRESHA, - ELDIN, - HARDING, - SOFIA, - DOMINIK, - NOLAND, - HANNAH, - HOOVER, - GIGI, - JEFFERSON, - LINDI, - KEVIN, - ANIS, - RETO, - HAALAND, - XENIA, - EVA, - SKARA, - ROOSEVELT, - DRACULA, - DURIM, - HARRISON, - DRIN, - PARI, - TUTI, - BENITO, - VANESSA, - ENES, - RUDOLF, - CERTO, - TIESTO, - DAVID, - ATAKAN, - YANN, - ENIS, - ALFREDO, - QENDRIM, - LEONARDO, - KEN, - LUCA, - FLAVIO, - FREDI, - ALI, - DILARA, - DAMIAN, - KAYA, - IAZI, - CHRIGI, - VALENTINA, - ALMA, - ALENA, - PATRICK, - ONTARIO, - RAKIA, - HUBERT, - UTUS, - TOME, - ZUBER, - ADAM, - STANI, - BETI, - HALIT, - DRAGAN, - LEA, - LUIS, - TATI, - WEST, - MIRIJAM, - LIONEL, - GIOVANNI, - JOEL, - POLKA, - MALIK, - ALEXANDER, - SOLOMUN, - JOHNNY, - GRINGO, - JONAS, - BUNDI, - FELIX, + LINA, MIA, ALEXEY, PAUL, MARIA, GEORGE, CLARA, RAMONA, PASCAL, EMMA, BIBI, AHMED, HERBERT, LENI, XI, TOM, ADAMS, + POLK, MARKUS, ELLA, SKR, ARTHUR, MILA, LINCOLN, MONROE, ARBRESHA, ELDIN, HARDING, SOFIA, DOMINIK, NOLAND, HANNAH, + HOOVER, GIGI, JEFFERSON, LINDI, KEVIN, ANIS, RETO, HAALAND, XENIA, EVA, SKARA, ROOSEVELT, DRACULA, DURIM, HARRISON, + DRIN, PARI, TUTI, BENITO, VANESSA, ENES, RUDOLF, CERTO, TIESTO, DAVID, ATAKAN, YANN, ENIS, ALFREDO, QENDRIM, + LEONARDO, KEN, LUCA, FLAVIO, FREDI, ALI, DILARA, DAMIAN, KAYA, IAZI, CHRIGI, VALENTINA, ALMA, ALENA, PATRICK, + ONTARIO, RAKIA, HUBERT, UTUS, TOME, ZUBER, ADAM, STANI, BETI, HALIT, DRAGAN, LEA, LUIS, TATI, WEST, MIRIJAM, + LIONEL, GIOVANNI, JOEL, POLKA, MALIK, ALEXANDER, SOLOMUN, JOHNNY, GRINGO, JONAS, BUNDI, FELIX, ); +pub fn set_oracle_prices() { + fn values( + values: [f64; 4], + ) -> BoundedVec< + (u32, FixedU128), + >::MaxFeedValues, + > { + let [dot, usdc, usdt, plmc] = values; + bounded_vec![ + (0u32, FixedU128::from_float(dot)), + (420u32, FixedU128::from_float(usdc)), + (1984u32, FixedU128::from_float(usdt)), + (2069u32, FixedU128::from_float(plmc)) + ] + } + + let alice = Polimec::account_id_of(ALICE); + assert_ok!(polimec_parachain_runtime::Oracle::feed_values( + PolimecOrigin::signed(alice.clone()), + values([4.84, 1.0, 1.0, 0.4]) + )); + + let bob = Polimec::account_id_of(BOB); + assert_ok!(polimec_parachain_runtime::Oracle::feed_values( + PolimecOrigin::signed(bob.clone()), + values([4.84, 1.0, 1.0, 0.4]) + )); + + let charlie = Polimec::account_id_of(CHARLIE); + assert_ok!(polimec_parachain_runtime::Oracle::feed_values( + PolimecOrigin::signed(charlie.clone()), + values([4.84, 1.0, 1.0, 0.4]) + )); + + let expected_values = HashMap::from([ + (0u32, FixedU128::from_float(4.84)), + (420u32, FixedU128::from_float(1.0)), + (1984u32, FixedU128::from_float(1.0)), + (2069u32, FixedU128::from_float(0.4)), + ]); + + for (key, value) in polimec_parachain_runtime::Oracle::get_all_values() { + assert!(value.is_some()); + assert_eq!(expected_values.get(&key).unwrap(), &value.unwrap().value); + } +} + pub fn excel_project(nonce: u64) -> ProjectMetadataOf { let bounded_name = BoundedVec::try_from("Polimec".as_bytes().to_vec()).unwrap(); let bounded_symbol = BoundedVec::try_from("PLMC".as_bytes().to_vec()).unwrap(); @@ -350,6 +300,7 @@ fn evaluation_round_completed() { let evaluations = excel_evaluators(); Polimec::execute_with(|| { + set_oracle_prices(); inst.create_auctioning_project(project, issuer, evaluations); }); } @@ -357,12 +308,14 @@ fn evaluation_round_completed() { #[test] fn auction_round_completed() { let mut inst = IntegrationInstantiator::new(None); + let issuer = issuer(); let project = excel_project(inst.get_new_nonce()); let evaluations = excel_evaluators(); let bids = excel_bidders(); Polimec::execute_with(|| { + set_oracle_prices(); //let filtered_bids = MockInstantiator::filter_bids_after_auction(bids.clone(), project.total_allocation_size.0); let (project_id, _) = inst.create_community_contributing_project(project, issuer, evaluations, bids); let wavgp_from_excel = 10.202357561; @@ -376,7 +329,8 @@ fn auction_round_completed() { assert!(res < FixedU128::from_float(0.00001)); let names = names(); inst.execute(|| { - let bids = Bids::::iter_prefix_values((0, )).sorted_by_key(|bid| bid.bidder.clone()).collect_vec(); + let bids = + Bids::::iter_prefix_values((0,)).sorted_by_key(|bid| bid.bidder.clone()).collect_vec(); for bid in bids.clone() { let key: [u8; 32] = bid.bidder.clone().into(); @@ -393,6 +347,7 @@ fn community_round_completed() { let mut inst = IntegrationInstantiator::new(None); Polimec::execute_with(|| { + set_oracle_prices(); let _ = inst.create_remainder_contributing_project( excel_project(0), issuer(), @@ -402,10 +357,11 @@ fn community_round_completed() { ); inst.execute(|| { - let contributions = Contributions::::iter_prefix_values((0, )) + let contributions = Contributions::::iter_prefix_values((0,)) .sorted_by_key(|bid| bid.contributor.clone()) .collect_vec(); - let total_contribution = contributions.clone().into_iter().fold(0, |acc, bid| acc + bid.funding_asset_amount); + let total_contribution = + contributions.clone().into_iter().fold(0, |acc, bid| acc + bid.funding_asset_amount); let total_contribution_as_fixed = FixedU128::from_rational(total_contribution, PLMC); dbg!(total_contribution_as_fixed); // In USD @@ -426,6 +382,7 @@ fn remainder_round_completed() { let mut inst = IntegrationInstantiator::new(None); Polimec::execute_with(|| { + set_oracle_prices(); let project_id = inst.create_finished_project( excel_project(0), issuer(), @@ -438,8 +395,10 @@ fn remainder_round_completed() { let price = inst.get_project_details(project_id).weighted_average_price.unwrap(); let price_as_u128 = price.checked_mul_int(1_0_000_000_000u128).unwrap(); dbg!(price_as_u128); - let funding_necessary_1 = IntegrationInstantiator::calculate_contributed_funding_asset_spent(excel_contributions(), price); - let funding_necessary_2 = IntegrationInstantiator::calculate_contributed_funding_asset_spent(excel_remainders(), price); + let funding_necessary_1 = + IntegrationInstantiator::calculate_contributed_funding_asset_spent(excel_contributions(), price); + let funding_necessary_2 = + IntegrationInstantiator::calculate_contributed_funding_asset_spent(excel_remainders(), price); let mut total = 0u128; for item in funding_necessary_1 { total += item.asset_amount; @@ -448,10 +407,11 @@ fn remainder_round_completed() { total += item.asset_amount; } dbg!(total); - let contributions = Contributions::::iter_prefix_values((0, )) + let contributions = Contributions::::iter_prefix_values((0,)) .sorted_by_key(|contribution| contribution.contributor.clone()) .collect_vec(); - let total_contributions = contributions.into_iter().fold(0, |acc, contribution| acc + contribution.funding_asset_amount); + let total_contributions = + contributions.into_iter().fold(0, |acc, contribution| acc + contribution.funding_asset_amount); let total_contributions_as_fixed = FixedU128::from_rational(total_contributions, PLMC); dbg!(total_contributions_as_fixed); let total_from_excel = 503945.4517; @@ -468,6 +428,7 @@ fn funds_raised() { let mut inst = IntegrationInstantiator::new(None); Polimec::execute_with(|| { + set_oracle_prices(); let project_id = inst.create_finished_project( excel_project(0), issuer(), @@ -479,7 +440,8 @@ fn funds_raised() { inst.execute(|| { let project_specific_account: AccountId = PolimecFunding::fund_account_id(project_id); - let funding = PolimecStatemintAssets::balance(AcceptedFundingAsset::USDT.to_statemint_id(), project_specific_account); + let funding = + PolimecStatemintAssets::balance(AcceptedFundingAsset::USDT.to_statemint_id(), project_specific_account); let fund_raised_from_excel = 1005361.955; let fund_raised_to_substrate = FixedU128::from_float(fund_raised_from_excel); let fund_raised_as_fixed = FixedU128::from_rational(funding, ASSET_UNIT); @@ -493,7 +455,9 @@ fn funds_raised() { #[test] fn ct_minted() { let mut inst = IntegrationInstantiator::new(None); + Polimec::execute_with(|| { + set_oracle_prices(); let _ = inst.create_finished_project( excel_project(0), issuer(), @@ -507,8 +471,8 @@ fn ct_minted() { inst.advance_time(10).unwrap(); for (contributor, expected_amount, project_id) in excel_ct_amounts() { - let minted = - inst.execute(|| ::ContributionTokenCurrency::balance(project_id, &contributor)); + let minted = inst + .execute(|| ::ContributionTokenCurrency::balance(project_id, &contributor)); assert_close_enough!(minted, expected_amount, Perquintill::from_parts(10_000_000_000u64)); } }); diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 9f7be2a9a..9a74c773d 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -534,7 +534,7 @@ impl pallet_funding::Config for Runtime { type PolimecReceiverInfo = PolimecReceiverInfo; type PreImageLimit = ConstU32<1024>; type Price = Price; - type PriceProvider = ConstPriceProvider; + type PriceProvider = OraclePriceProvider; type ProjectIdentifier = u32; type Randomness = Random; type RemainderFundingDuration = RemainderFundingDuration; From 9c0b29b86ac2d93ab8160f216d69265edc22ae29 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 21 Nov 2023 17:25:09 +0100 Subject: [PATCH 036/212] not all xcmp messages being received --- integration-tests/src/tests/e2e.rs | 102 ++++++++++++++++++++++++++++ pallets/funding/src/instantiator.rs | 8 +++ 2 files changed, 110 insertions(+) diff --git a/integration-tests/src/tests/e2e.rs b/integration-tests/src/tests/e2e.rs index a660cb8d0..fef9572a0 100644 --- a/integration-tests/src/tests/e2e.rs +++ b/integration-tests/src/tests/e2e.rs @@ -477,3 +477,105 @@ fn ct_minted() { } }); } + +#[test] +fn ct_migrated() { + let mut inst = IntegrationInstantiator::new(None); + + let project_id = Polimec::execute_with(|| { + set_oracle_prices(); + let project_id = inst.create_finished_project( + excel_project(0), + issuer(), + excel_evaluators(), + excel_bidders(), + excel_contributions(), + excel_remainders(), + ); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + + inst.advance_time(10).unwrap(); + + for (contributor, expected_amount, project_id) in excel_ct_amounts() { + let minted = inst + .execute(|| ::ContributionTokenCurrency::balance(project_id, &contributor)); + assert_close_enough!(minted, expected_amount, Perquintill::from_parts(10_000_000_000u64)); + } + + project_id + }); + + let project_details = Polimec::execute_with(|| { + inst.get_project_details(project_id) + }); + assert!(matches!(project_details.evaluation_round_info.evaluators_outcome, EvaluatorsOutcome::Rewarded(_))); + + // Mock HRMP establishment + Polimec::execute_with(|| { + assert_ok!(PolimecFunding::do_set_para_id_for_project(&issuer(), project_id, ParaId::from(6969u32))); + + let open_channel_message = xcm::v3::opaque::Instruction::HrmpNewChannelOpenRequest { + sender: 6969, + max_message_size: 102_300, + max_capacity: 1000, + }; + assert_ok!(PolimecFunding::do_handle_channel_open_request(open_channel_message)); + + let channel_accepted_message = xcm::v3::opaque::Instruction::HrmpChannelAccepted { recipient: 6969u32 }; + assert_ok!(PolimecFunding::do_handle_channel_accepted(channel_accepted_message)); + + }); + + // Migration is ready + Polimec::execute_with(|| { + let project_details = pallet_funding::ProjectsDetails::::get(project_id).unwrap(); + assert!(project_details.migration_readiness_check.unwrap().is_ready()) + }); + + + excel_ct_amounts().iter().unique().map(|item| { + let data = Penpal::account_data_of(item.0.clone()); + assert_eq!(data.free, 0u128, "Participant balances should be 0 before ct migration"); + data + }).collect::>(); + + // Migrate CTs + let accounts = excel_ct_amounts().iter().map(|item| item.0.clone()).unique().collect::>(); + let total_ct_sold = excel_ct_amounts().iter().fold(0, |acc, item| acc + item.1); + dbg!(total_ct_sold); + let polimec_sov_acc = Penpal::sovereign_account_id_of((Parent, Parachain(polimec::PARA_ID)).into()); + let polimec_fund_balance = Penpal::account_data_of(polimec_sov_acc); + dbg!(polimec_fund_balance); + + + let names = names(); + + Polimec::execute_with(|| { + for account in accounts { + assert_ok!(PolimecFunding::migrate_one_participant(PolimecOrigin::signed(account.clone()), project_id, account.clone())); + let key: [u8; 32] = account.clone().into(); + println!("Migrated CTs for {}", names[&key]); + inst.advance_time(1u32).unwrap(); + } + + // dbg!(Polimec::events()); + }); + + Penpal::execute_with(||{ + dbg!(Penpal::events()); + // ::XcmpMessageHandler + }); + + + + // Check balances after migration, before vesting + excel_ct_amounts().iter().unique().map(|item| { + let data = Penpal::account_data_of(item.0.clone()); + let key: [u8; 32] = item.0.clone().into(); + println!("Participant {} has {} CTs. Expected {}", names[&key], data.free.clone(), item.1); + dbg!(data.clone()); + assert_close_enough!(data.free, item.1, Perquintill::from_parts(10_000_000_000u64), "Participant balances should be transfered to each account after ct migration, but be frozen"); + data.clone() + }).collect::>(); + +} diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 1701fd4c4..fd6a80c81 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -1702,6 +1702,14 @@ pub mod testing_macros { #[macro_export] macro_rules! assert_close_enough { + // Match when a message is provided + ($real:expr, $desired:expr, $max_approximation:expr, $msg:expr) => { + let real_parts = Perquintill::from_rational($real, $desired); + let one = Perquintill::from_percent(100u64); + let real_approximation = one - real_parts; + assert!(real_approximation <= $max_approximation, $msg); + }; + // Match when no message is provided ($real:expr, $desired:expr, $max_approximation:expr) => { let real_parts = Perquintill::from_rational($real, $desired); let one = Perquintill::from_percent(100u64); From bd07a4821b97be35ed8c1ff8b9086f04c28fbcaf Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 22 Nov 2023 17:07:25 +0100 Subject: [PATCH 037/212] save --- pallets/funding/src/functions.rs | 5 ++- runtimes/testnet/src/lib.rs | 70 ++++++++++++++++---------------- 2 files changed, 39 insertions(+), 36 deletions(-) diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index c2e31d387..d93921c60 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -2788,7 +2788,10 @@ impl Pallet { user: [u8; 32], migrations: Vec<(MigrationOriginOf, MigrationInfo)>, ) -> Vec<(BoundedVec, MaxMigrationsPerXcm>, Xcm<()>)> { - const MAX_WEIGHT: Weight = Weight::from_parts(20_000_000_000, 1_000_000); + + // TODO: adjust this as benchmarks for polimec-receiver are written + const MAX_WEIGHT: Weight = Weight::from_parts(10_000, 0); + // const MAX_WEIGHT: Weight = Weight::from_parts(100_003_000_000_000, 10_000_196_608); let _polimec_receiver_info = T::PolimecReceiverInfo::get(); // TODO: use the actual pallet index when the fields are not private anymore (https://github.com/paritytech/polkadot-sdk/pull/2231) let mut output = Vec::new(); diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 9a74c773d..13cfbf698 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -500,54 +500,54 @@ parameter_types! { ).unwrap(); pub MaxMessageSizeThresholds: (u32, u32) = (50000, 102_400); pub MaxCapacityThresholds: (u32, u32) = (8, 1000); - pub RequiredMaxCapacity: u32 = 8; + pub RequiredMaxCapacity: u32 = 20; pub RequiredMaxMessageSize: u32 = 102_400; } impl pallet_funding::Config for Runtime { - type AccountId32Conversion = ConvertInto; type AllPalletsWithoutSystem = (Balances, LocalAssets, StatemintAssets, PolimecFunding, LinearVesting, Random); - type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; - type Balance = Balance; + type RuntimeEvent = RuntimeEvent; type BlockNumber = BlockNumber; - type BlockNumberToBalance = ConvertInto; + type AccountId32Conversion = ConvertInto; + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + type ProjectIdentifier = u32; + type Multiplier = pallet_funding::types::Multiplier; + type Balance = Balance; + type Price = Price; + type NativeCurrency = Balances; + type FundingCurrency = StatemintAssets; + type ContributionTokenCurrency = LocalAssets; + type PriceProvider = OraclePriceProvider; + type Randomness = Random; + type StringLimit = ConstU32<64>; + type PreImageLimit = ConstU32<1024>; + type EvaluationDuration = EvaluationDuration; + type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; + type EnglishAuctionDuration = EnglishAuctionDuration; type CandleAuctionDuration = CandleAuctionDuration; type CommunityFundingDuration = CommunityFundingDuration; - type ContributionTokenCurrency = LocalAssets; + type RemainderFundingDuration = RemainderFundingDuration; + type PalletId = FundingPalletId; + type MaxProjectsToUpdatePerBlock = ConstU32<100>; + type MaxEvaluationsPerUser = ConstU32<256>; + type MaxBidsPerUser = ConstU32<256>; + type MaxContributionsPerUser = ConstU32<256>; type ContributionVesting = ContributionVestingDuration; - type DaysToBlocks = DaysToBlocks; - type EnglishAuctionDuration = EnglishAuctionDuration; - type EvaluationDuration = EvaluationDuration; - type EvaluationSuccessThreshold = EarlyEvaluationThreshold; - type EvaluatorSlash = EvaluatorSlash; + type WeightInfo = pallet_funding::weights::SubstrateWeight; type FeeBrackets = FeeBrackets; - type FundingCurrency = StatemintAssets; + type EvaluationSuccessThreshold = EarlyEvaluationThreshold; + type Vesting = LinearVesting; type ManualAcceptanceDuration = ManualAcceptanceDuration; - type MaxBidsPerUser = ConstU32<256>; - type MaxCapacityThresholds = MaxCapacityThresholds; - type MaxContributionsPerUser = ConstU32<256>; - type MaxEvaluationsPerUser = ConstU32<256>; - type MaxMessageSizeThresholds = MaxMessageSizeThresholds; - type MaxProjectsToUpdatePerBlock = ConstU32<100>; - type Multiplier = pallet_funding::types::Multiplier; - type NativeCurrency = Balances; - type PalletId = FundingPalletId; + type SuccessToSettlementTime = SuccessToSettlementTime; + type EvaluatorSlash = EvaluatorSlash; + type TreasuryAccount = TreasuryAccount; + type DaysToBlocks = DaysToBlocks; + type BlockNumberToBalance = ConvertInto; type PolimecReceiverInfo = PolimecReceiverInfo; - type PreImageLimit = ConstU32<1024>; - type Price = Price; - type PriceProvider = OraclePriceProvider; - type ProjectIdentifier = u32; - type Randomness = Random; - type RemainderFundingDuration = RemainderFundingDuration; + type MaxMessageSizeThresholds = MaxMessageSizeThresholds; + type MaxCapacityThresholds = MaxCapacityThresholds; type RequiredMaxCapacity = RequiredMaxCapacity; type RequiredMaxMessageSize = RequiredMaxMessageSize; - type RuntimeCall = RuntimeCall; - type RuntimeEvent = RuntimeEvent; - type RuntimeOrigin = RuntimeOrigin; - type StringLimit = ConstU32<64>; - type SuccessToSettlementTime = SuccessToSettlementTime; - type TreasuryAccount = TreasuryAccount; - type Vesting = LinearVesting; - type WeightInfo = pallet_funding::weights::SubstrateWeight; } parameter_types! { From 901d741dbb128696ae2c8ce207587e6263cc59f6 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 23 Nov 2023 09:53:29 +0100 Subject: [PATCH 038/212] cleanup --- integration-tests/macros/tests/src/lib.rs | 4 +- integration-tests/src/constants.rs | 5 +- integration-tests/src/tests/ct_migration.rs | 8 +++ integration-tests/src/tests/defaults.rs | 59 ++++++++++++++- integration-tests/src/tests/e2e.rs | 79 ++++----------------- integration-tests/src/tests/oracle.rs | 2 +- pallets/funding/src/mock.rs | 1 - pallets/funding/src/tests.rs | 4 +- pallets/polimec-receiver/src/lib.rs | 2 +- runtimes/testnet/src/lib.rs | 2 +- 10 files changed, 86 insertions(+), 80 deletions(-) diff --git a/integration-tests/macros/tests/src/lib.rs b/integration-tests/macros/tests/src/lib.rs index 868eb7f28..0d68990eb 100644 --- a/integration-tests/macros/tests/src/lib.rs +++ b/integration-tests/macros/tests/src/lib.rs @@ -1,8 +1,6 @@ -use macros::generate_accounts; - #[test] fn test_generate_accounts_macro() { - generate_accounts!(ALICE, BOB,); + macros::generate_accounts!(ALICE, BOB,); dbg!(ALICE); dbg!(BOB); diff --git a/integration-tests/src/constants.rs b/integration-tests/src/constants.rs index e0b119ee1..9ac29e6bf 100644 --- a/integration-tests/src/constants.rs +++ b/integration-tests/src/constants.rs @@ -9,8 +9,7 @@ use sp_consensus_babe::AuthorityId as BabeId; use sp_core::{sr25519, storage::Storage, Pair, Public}; use sp_runtime::{ bounded_vec, - traits::{IdentifyAccount, Verify}, - BuildStorage, MultiSignature, Perbill, + BuildStorage, Perbill, }; pub use xcm; use xcm_emulator::get_account_id_from_seed; @@ -21,8 +20,6 @@ pub const REF_TIME_THRESHOLD: u64 = 33; pub const PROOF_SIZE_THRESHOLD: u64 = 33; pub const INITIAL_DEPOSIT: u128 = 420_0_000_000_000; -type AccountPublic = ::Signer; - /// Helper function to generate a crypto pair from seed fn get_from_seed(seed: &str) -> ::Public { TPublic::Pair::from_string(&format!("//{}", seed), None).expect("static values are valid; qed").public() diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index d5186024c..42971532d 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -9,6 +9,7 @@ use tests::defaults::*; #[test] fn migration_check() { let mut inst = IntegrationInstantiator::new(None); + set_oracle_prices(); let project_id = Polimec::execute_with(|| { inst.create_finished_project( default_project(issuer(), 0), @@ -56,6 +57,8 @@ fn migration_check() { #[test] fn migration_is_sent() { let mut inst = IntegrationInstantiator::new(None); + set_oracle_prices(); + let project_id = Polimec::execute_with(|| { inst.create_finished_project( default_project(issuer(), 0), @@ -134,6 +137,8 @@ fn migration_is_sent() { #[test] fn migration_is_executed_on_project_and_confirmed_on_polimec() { let mut inst = IntegrationInstantiator::new(None); + set_oracle_prices(); + let project_id = Polimec::execute_with(|| { inst.create_finished_project( default_project(issuer(), 0), @@ -226,6 +231,7 @@ fn migration_is_executed_on_project_and_confirmed_on_polimec() { }); Penpal::execute_with(|| { + dbg!(Penpal::events()); assert_expected_events!( Penpal, vec![ @@ -270,6 +276,8 @@ fn migration_is_executed_on_project_and_confirmed_on_polimec() { #[test] fn vesting_over_several_blocks_on_project() { let mut inst = IntegrationInstantiator::new(None); + set_oracle_prices(); + let mut bids = Vec::new(); let mut contributions = Vec::new(); let multiplier_for_vesting = MultiplierOf::::try_from(10u8).unwrap(); diff --git a/integration-tests/src/tests/defaults.rs b/integration-tests/src/tests/defaults.rs index 072d4e57a..6ff4ef5ea 100644 --- a/integration-tests/src/tests/defaults.rs +++ b/integration-tests/src/tests/defaults.rs @@ -1,12 +1,17 @@ -use frame_support::BoundedVec; +use std::collections::HashMap; +use frame_support::{assert_ok, bounded_vec, BoundedVec}; +use sp_arithmetic::FixedU128; pub use pallet_funding::instantiator::{BidParams, ContributionParams, UserToPLMCBalance, UserToUSDBalance}; use pallet_funding::{ AcceptedFundingAsset, CurrencyMetadata, ParticipantsSize, ProjectMetadata, ProjectMetadataOf, TicketSize, }; use sp_core::H256; +use crate::PolimecOrigin; use polimec_parachain_runtime::AccountId; use sp_runtime::{traits::ConstU32, FixedPointNumber, Perquintill}; +use xcm_emulator::TestExt; + pub const METADATA: &str = r#"METADATA { "whitepaper":"ipfs_url", @@ -138,7 +143,57 @@ pub fn default_contributors() -> Vec { vec![buyer_1(), buyer_2(), buyer_3(), buyer_4(), buyer_5()] } -use crate::{Polimec, PolimecRuntime}; +use crate::{ALICE, BOB, CHARLIE, Polimec, PolimecRuntime}; + +pub fn set_oracle_prices() { + + Polimec::execute_with(|| { + fn values( + values: [f64; 4], + ) -> BoundedVec< + (u32, FixedU128), + >::MaxFeedValues, + > { + let [dot, usdc, usdt, plmc] = values; + bounded_vec![ + (0u32, FixedU128::from_float(dot)), + (420u32, FixedU128::from_float(usdc)), + (1984u32, FixedU128::from_float(usdt)), + (2069u32, FixedU128::from_float(plmc)) + ] + } + + let alice = Polimec::account_id_of(ALICE); + assert_ok!(polimec_parachain_runtime::Oracle::feed_values( + PolimecOrigin::signed(alice.clone()), + values([4.84, 1.0, 1.0, 0.4]) + )); + + let bob = Polimec::account_id_of(BOB); + assert_ok!(polimec_parachain_runtime::Oracle::feed_values( + PolimecOrigin::signed(bob.clone()), + values([4.84, 1.0, 1.0, 0.4]) + )); + + let charlie = Polimec::account_id_of(CHARLIE); + assert_ok!(polimec_parachain_runtime::Oracle::feed_values( + PolimecOrigin::signed(charlie.clone()), + values([4.84, 1.0, 1.0, 0.4]) + )); + + let expected_values = HashMap::from([ + (0u32, FixedU128::from_float(4.84)), + (420u32, FixedU128::from_float(1.0)), + (1984u32, FixedU128::from_float(1.0)), + (2069u32, FixedU128::from_float(0.4)), + ]); + + for (key, value) in polimec_parachain_runtime::Oracle::get_all_values() { + assert!(value.is_some()); + assert_eq!(expected_values.get(&key).unwrap(), &value.unwrap().value); + } + }); +} #[test] fn something() { diff --git a/integration-tests/src/tests/e2e.rs b/integration-tests/src/tests/e2e.rs index fef9572a0..ef90aea1f 100644 --- a/integration-tests/src/tests/e2e.rs +++ b/integration-tests/src/tests/e2e.rs @@ -1,17 +1,14 @@ -use super::*; use crate::{tests::defaults::*, *}; -use frame_support::{bounded_vec, BoundedVec}; +use frame_support::{BoundedVec}; use itertools::Itertools; use macros::generate_accounts; -use pallet_funding::{instantiator::*, *}; +use pallet_funding::*; use polimec_parachain_runtime::{PolimecFunding, US_DOLLAR}; use sp_arithmetic::{FixedPointNumber, Perquintill}; -use sp_core::U256; use sp_runtime::{ - traits::{AccountIdConversion, CheckedSub}, + traits::{CheckedSub}, FixedU128, }; -use std::collections::HashMap; type UserToCTBalance = Vec<(AccountId, BalanceOf, ProjectIdOf)>; @@ -25,52 +22,7 @@ generate_accounts!( LIONEL, GIOVANNI, JOEL, POLKA, MALIK, ALEXANDER, SOLOMUN, JOHNNY, GRINGO, JONAS, BUNDI, FELIX, ); -pub fn set_oracle_prices() { - fn values( - values: [f64; 4], - ) -> BoundedVec< - (u32, FixedU128), - >::MaxFeedValues, - > { - let [dot, usdc, usdt, plmc] = values; - bounded_vec![ - (0u32, FixedU128::from_float(dot)), - (420u32, FixedU128::from_float(usdc)), - (1984u32, FixedU128::from_float(usdt)), - (2069u32, FixedU128::from_float(plmc)) - ] - } - let alice = Polimec::account_id_of(ALICE); - assert_ok!(polimec_parachain_runtime::Oracle::feed_values( - PolimecOrigin::signed(alice.clone()), - values([4.84, 1.0, 1.0, 0.4]) - )); - - let bob = Polimec::account_id_of(BOB); - assert_ok!(polimec_parachain_runtime::Oracle::feed_values( - PolimecOrigin::signed(bob.clone()), - values([4.84, 1.0, 1.0, 0.4]) - )); - - let charlie = Polimec::account_id_of(CHARLIE); - assert_ok!(polimec_parachain_runtime::Oracle::feed_values( - PolimecOrigin::signed(charlie.clone()), - values([4.84, 1.0, 1.0, 0.4]) - )); - - let expected_values = HashMap::from([ - (0u32, FixedU128::from_float(4.84)), - (420u32, FixedU128::from_float(1.0)), - (1984u32, FixedU128::from_float(1.0)), - (2069u32, FixedU128::from_float(0.4)), - ]); - - for (key, value) in polimec_parachain_runtime::Oracle::get_all_values() { - assert!(value.is_some()); - assert_eq!(expected_values.get(&key).unwrap(), &value.unwrap().value); - } -} pub fn excel_project(nonce: u64) -> ProjectMetadataOf { let bounded_name = BoundedVec::try_from("Polimec".as_bytes().to_vec()).unwrap(); @@ -298,9 +250,9 @@ fn evaluation_round_completed() { let issuer = issuer(); let project = excel_project(inst.get_new_nonce()); let evaluations = excel_evaluators(); + set_oracle_prices(); Polimec::execute_with(|| { - set_oracle_prices(); inst.create_auctioning_project(project, issuer, evaluations); }); } @@ -313,9 +265,9 @@ fn auction_round_completed() { let project = excel_project(inst.get_new_nonce()); let evaluations = excel_evaluators(); let bids = excel_bidders(); + set_oracle_prices(); Polimec::execute_with(|| { - set_oracle_prices(); //let filtered_bids = MockInstantiator::filter_bids_after_auction(bids.clone(), project.total_allocation_size.0); let (project_id, _) = inst.create_community_contributing_project(project, issuer, evaluations, bids); let wavgp_from_excel = 10.202357561; @@ -345,9 +297,9 @@ fn auction_round_completed() { #[test] fn community_round_completed() { let mut inst = IntegrationInstantiator::new(None); + set_oracle_prices(); Polimec::execute_with(|| { - set_oracle_prices(); let _ = inst.create_remainder_contributing_project( excel_project(0), issuer(), @@ -380,9 +332,9 @@ fn community_round_completed() { #[test] fn remainder_round_completed() { let mut inst = IntegrationInstantiator::new(None); + set_oracle_prices(); Polimec::execute_with(|| { - set_oracle_prices(); let project_id = inst.create_finished_project( excel_project(0), issuer(), @@ -426,9 +378,9 @@ fn remainder_round_completed() { #[test] fn funds_raised() { let mut inst = IntegrationInstantiator::new(None); + set_oracle_prices(); Polimec::execute_with(|| { - set_oracle_prices(); let project_id = inst.create_finished_project( excel_project(0), issuer(), @@ -455,9 +407,9 @@ fn funds_raised() { #[test] fn ct_minted() { let mut inst = IntegrationInstantiator::new(None); + set_oracle_prices(); Polimec::execute_with(|| { - set_oracle_prices(); let _ = inst.create_finished_project( excel_project(0), issuer(), @@ -478,12 +430,13 @@ fn ct_minted() { }); } +#[ignore] #[test] fn ct_migrated() { let mut inst = IntegrationInstantiator::new(None); + set_oracle_prices(); let project_id = Polimec::execute_with(|| { - set_oracle_prices(); let project_id = inst.create_finished_project( excel_project(0), issuer(), @@ -533,11 +486,10 @@ fn ct_migrated() { }); - excel_ct_amounts().iter().unique().map(|item| { + excel_ct_amounts().iter().unique().for_each(|item| { let data = Penpal::account_data_of(item.0.clone()); assert_eq!(data.free, 0u128, "Participant balances should be 0 before ct migration"); - data - }).collect::>(); + }); // Migrate CTs let accounts = excel_ct_amounts().iter().map(|item| item.0.clone()).unique().collect::>(); @@ -569,13 +521,12 @@ fn ct_migrated() { // Check balances after migration, before vesting - excel_ct_amounts().iter().unique().map(|item| { + excel_ct_amounts().iter().unique().for_each(|item| { let data = Penpal::account_data_of(item.0.clone()); let key: [u8; 32] = item.0.clone().into(); println!("Participant {} has {} CTs. Expected {}", names[&key], data.free.clone(), item.1); dbg!(data.clone()); assert_close_enough!(data.free, item.1, Perquintill::from_parts(10_000_000_000u64), "Participant balances should be transfered to each account after ct migration, but be frozen"); - data.clone() - }).collect::>(); + }); } diff --git a/integration-tests/src/tests/oracle.rs b/integration-tests/src/tests/oracle.rs index 04abdc819..1c9ee7603 100644 --- a/integration-tests/src/tests/oracle.rs +++ b/integration-tests/src/tests/oracle.rs @@ -100,7 +100,7 @@ fn pallet_funding_works() { let charlie = Polimec::account_id_of(CHARLIE); assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(charlie.clone()), values([4.84, 1.0, 1.0, 0.4]))); - let project_id = inst.create_finished_project( + let _project_id = inst.create_finished_project( default_project(issuer(), 0), issuer(), default_evaluations(), diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 0bd997759..cdae8ba32 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -86,7 +86,6 @@ pub const fn free_deposit() -> Balance { use frame_support::traits::{Everything, OriginTrait}; use frame_system::RawOrigin as SystemRawOrigin; use polkadot_parachain::primitives::Sibling; -use sp_core::crypto::Dummy; use sp_runtime::traits::Get; use xcm_builder::{EnsureXcmOrigin, FixedWeightBounds, ParentIsPreset, SiblingParachainConvertsVia}; use xcm_executor::traits::Convert; diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index b279498b9..3c7942bf9 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -28,7 +28,7 @@ use frame_support::{ use itertools::Itertools; use parachains_common::DAYS; use sp_arithmetic::{ - traits::{CheckedSub, Zero}, + traits::{Zero}, Percent, Perquintill, }; use sp_std::{cell::RefCell, marker::PhantomData}; @@ -37,8 +37,6 @@ use std::{cmp::min, iter::zip}; use defaults::*; use polimec_traits::ReleaseSchedule; -use sp_runtime::traits::AccountIdConversion; - use crate::{ instantiator::*, mock::*, diff --git a/pallets/polimec-receiver/src/lib.rs b/pallets/polimec-receiver/src/lib.rs index cbcb4f7d2..a779b1d20 100644 --- a/pallets/polimec-receiver/src/lib.rs +++ b/pallets/polimec-receiver/src/lib.rs @@ -69,7 +69,7 @@ pub mod pallet { T::AccountId: From<[u8; 32]>, { #[pallet::call_index(0)] - #[pallet::weight(Weight::from_parts(10_000, 0) + T::DbWeight::get().writes(1))] + #[pallet::weight(Weight::from_parts(10_000, 0))] pub fn migrate_for_user( origin: OriginFor, user: [u8; 32], diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 13cfbf698..78f634752 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -66,7 +66,7 @@ pub use crate::xcm_config::*; include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); // Polimec Shared Imports -use pallet_funding::{BondTypeOf, ConstPriceProvider, DaysToBlocks}; +use pallet_funding::{BondTypeOf, DaysToBlocks}; pub use pallet_parachain_staking; pub use shared_configuration::*; From 9c627a8047efb1720b93e78737dba2f74842828a Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 23 Nov 2023 09:55:10 +0100 Subject: [PATCH 039/212] fmt --- integration-tests/src/constants.rs | 5 +- integration-tests/src/tests/defaults.rs | 7 ++- integration-tests/src/tests/e2e.rs | 34 ++++++------- pallets/funding/src/functions.rs | 1 - pallets/funding/src/tests.rs | 5 +- runtimes/testnet/src/lib.rs | 68 ++++++++++++------------- 6 files changed, 54 insertions(+), 66 deletions(-) diff --git a/integration-tests/src/constants.rs b/integration-tests/src/constants.rs index 9ac29e6bf..f57400055 100644 --- a/integration-tests/src/constants.rs +++ b/integration-tests/src/constants.rs @@ -7,10 +7,7 @@ use sc_consensus_grandpa::AuthorityId as GrandpaId; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_consensus_babe::AuthorityId as BabeId; use sp_core::{sr25519, storage::Storage, Pair, Public}; -use sp_runtime::{ - bounded_vec, - BuildStorage, Perbill, -}; +use sp_runtime::{bounded_vec, BuildStorage, Perbill}; pub use xcm; use xcm_emulator::get_account_id_from_seed; diff --git a/integration-tests/src/tests/defaults.rs b/integration-tests/src/tests/defaults.rs index 6ff4ef5ea..fc5b31621 100644 --- a/integration-tests/src/tests/defaults.rs +++ b/integration-tests/src/tests/defaults.rs @@ -1,11 +1,11 @@ -use std::collections::HashMap; use frame_support::{assert_ok, bounded_vec, BoundedVec}; -use sp_arithmetic::FixedU128; pub use pallet_funding::instantiator::{BidParams, ContributionParams, UserToPLMCBalance, UserToUSDBalance}; use pallet_funding::{ AcceptedFundingAsset, CurrencyMetadata, ParticipantsSize, ProjectMetadata, ProjectMetadataOf, TicketSize, }; +use sp_arithmetic::FixedU128; use sp_core::H256; +use std::collections::HashMap; use crate::PolimecOrigin; use polimec_parachain_runtime::AccountId; @@ -143,10 +143,9 @@ pub fn default_contributors() -> Vec { vec![buyer_1(), buyer_2(), buyer_3(), buyer_4(), buyer_5()] } -use crate::{ALICE, BOB, CHARLIE, Polimec, PolimecRuntime}; +use crate::{Polimec, PolimecRuntime, ALICE, BOB, CHARLIE}; pub fn set_oracle_prices() { - Polimec::execute_with(|| { fn values( values: [f64; 4], diff --git a/integration-tests/src/tests/e2e.rs b/integration-tests/src/tests/e2e.rs index ef90aea1f..77a190d3c 100644 --- a/integration-tests/src/tests/e2e.rs +++ b/integration-tests/src/tests/e2e.rs @@ -1,14 +1,11 @@ use crate::{tests::defaults::*, *}; -use frame_support::{BoundedVec}; +use frame_support::BoundedVec; use itertools::Itertools; use macros::generate_accounts; use pallet_funding::*; use polimec_parachain_runtime::{PolimecFunding, US_DOLLAR}; use sp_arithmetic::{FixedPointNumber, Perquintill}; -use sp_runtime::{ - traits::{CheckedSub}, - FixedU128, -}; +use sp_runtime::{traits::CheckedSub, FixedU128}; type UserToCTBalance = Vec<(AccountId, BalanceOf, ProjectIdOf)>; @@ -22,8 +19,6 @@ generate_accounts!( LIONEL, GIOVANNI, JOEL, POLKA, MALIK, ALEXANDER, SOLOMUN, JOHNNY, GRINGO, JONAS, BUNDI, FELIX, ); - - pub fn excel_project(nonce: u64) -> ProjectMetadataOf { let bounded_name = BoundedVec::try_from("Polimec".as_bytes().to_vec()).unwrap(); let bounded_symbol = BoundedVec::try_from("PLMC".as_bytes().to_vec()).unwrap(); @@ -458,9 +453,7 @@ fn ct_migrated() { project_id }); - let project_details = Polimec::execute_with(|| { - inst.get_project_details(project_id) - }); + let project_details = Polimec::execute_with(|| inst.get_project_details(project_id)); assert!(matches!(project_details.evaluation_round_info.evaluators_outcome, EvaluatorsOutcome::Rewarded(_))); // Mock HRMP establishment @@ -476,7 +469,6 @@ fn ct_migrated() { let channel_accepted_message = xcm::v3::opaque::Instruction::HrmpChannelAccepted { recipient: 6969u32 }; assert_ok!(PolimecFunding::do_handle_channel_accepted(channel_accepted_message)); - }); // Migration is ready @@ -485,7 +477,6 @@ fn ct_migrated() { assert!(project_details.migration_readiness_check.unwrap().is_ready()) }); - excel_ct_amounts().iter().unique().for_each(|item| { let data = Penpal::account_data_of(item.0.clone()); assert_eq!(data.free, 0u128, "Participant balances should be 0 before ct migration"); @@ -499,12 +490,15 @@ fn ct_migrated() { let polimec_fund_balance = Penpal::account_data_of(polimec_sov_acc); dbg!(polimec_fund_balance); - let names = names(); Polimec::execute_with(|| { for account in accounts { - assert_ok!(PolimecFunding::migrate_one_participant(PolimecOrigin::signed(account.clone()), project_id, account.clone())); + assert_ok!(PolimecFunding::migrate_one_participant( + PolimecOrigin::signed(account.clone()), + project_id, + account.clone() + )); let key: [u8; 32] = account.clone().into(); println!("Migrated CTs for {}", names[&key]); inst.advance_time(1u32).unwrap(); @@ -513,20 +507,22 @@ fn ct_migrated() { // dbg!(Polimec::events()); }); - Penpal::execute_with(||{ + Penpal::execute_with(|| { dbg!(Penpal::events()); // ::XcmpMessageHandler }); - - // Check balances after migration, before vesting excel_ct_amounts().iter().unique().for_each(|item| { let data = Penpal::account_data_of(item.0.clone()); let key: [u8; 32] = item.0.clone().into(); println!("Participant {} has {} CTs. Expected {}", names[&key], data.free.clone(), item.1); dbg!(data.clone()); - assert_close_enough!(data.free, item.1, Perquintill::from_parts(10_000_000_000u64), "Participant balances should be transfered to each account after ct migration, but be frozen"); + assert_close_enough!( + data.free, + item.1, + Perquintill::from_parts(10_000_000_000u64), + "Participant balances should be transfered to each account after ct migration, but be frozen" + ); }); - } diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index d93921c60..644106693 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -2788,7 +2788,6 @@ impl Pallet { user: [u8; 32], migrations: Vec<(MigrationOriginOf, MigrationInfo)>, ) -> Vec<(BoundedVec, MaxMigrationsPerXcm>, Xcm<()>)> { - // TODO: adjust this as benchmarks for polimec-receiver are written const MAX_WEIGHT: Weight = Weight::from_parts(10_000, 0); // const MAX_WEIGHT: Weight = Weight::from_parts(100_003_000_000_000, 10_000_196_608); diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 3c7942bf9..3092315e6 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -27,10 +27,7 @@ use frame_support::{ }; use itertools::Itertools; use parachains_common::DAYS; -use sp_arithmetic::{ - traits::{Zero}, - Percent, Perquintill, -}; +use sp_arithmetic::{traits::Zero, Percent, Perquintill}; use sp_std::{cell::RefCell, marker::PhantomData}; use std::{cmp::min, iter::zip}; diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 78f634752..bb872765f 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -504,50 +504,50 @@ parameter_types! { pub RequiredMaxMessageSize: u32 = 102_400; } impl pallet_funding::Config for Runtime { - type AllPalletsWithoutSystem = (Balances, LocalAssets, StatemintAssets, PolimecFunding, LinearVesting, Random); - type RuntimeEvent = RuntimeEvent; - type BlockNumber = BlockNumber; type AccountId32Conversion = ConvertInto; - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - type ProjectIdentifier = u32; - type Multiplier = pallet_funding::types::Multiplier; - type Balance = Balance; - type Price = Price; - type NativeCurrency = Balances; - type FundingCurrency = StatemintAssets; - type ContributionTokenCurrency = LocalAssets; - type PriceProvider = OraclePriceProvider; - type Randomness = Random; - type StringLimit = ConstU32<64>; - type PreImageLimit = ConstU32<1024>; - type EvaluationDuration = EvaluationDuration; + type AllPalletsWithoutSystem = (Balances, LocalAssets, StatemintAssets, PolimecFunding, LinearVesting, Random); type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; - type EnglishAuctionDuration = EnglishAuctionDuration; + type Balance = Balance; + type BlockNumber = BlockNumber; + type BlockNumberToBalance = ConvertInto; type CandleAuctionDuration = CandleAuctionDuration; type CommunityFundingDuration = CommunityFundingDuration; - type RemainderFundingDuration = RemainderFundingDuration; - type PalletId = FundingPalletId; - type MaxProjectsToUpdatePerBlock = ConstU32<100>; - type MaxEvaluationsPerUser = ConstU32<256>; - type MaxBidsPerUser = ConstU32<256>; - type MaxContributionsPerUser = ConstU32<256>; + type ContributionTokenCurrency = LocalAssets; type ContributionVesting = ContributionVestingDuration; - type WeightInfo = pallet_funding::weights::SubstrateWeight; - type FeeBrackets = FeeBrackets; + type DaysToBlocks = DaysToBlocks; + type EnglishAuctionDuration = EnglishAuctionDuration; + type EvaluationDuration = EvaluationDuration; type EvaluationSuccessThreshold = EarlyEvaluationThreshold; - type Vesting = LinearVesting; - type ManualAcceptanceDuration = ManualAcceptanceDuration; - type SuccessToSettlementTime = SuccessToSettlementTime; type EvaluatorSlash = EvaluatorSlash; - type TreasuryAccount = TreasuryAccount; - type DaysToBlocks = DaysToBlocks; - type BlockNumberToBalance = ConvertInto; - type PolimecReceiverInfo = PolimecReceiverInfo; - type MaxMessageSizeThresholds = MaxMessageSizeThresholds; + type FeeBrackets = FeeBrackets; + type FundingCurrency = StatemintAssets; + type ManualAcceptanceDuration = ManualAcceptanceDuration; + type MaxBidsPerUser = ConstU32<256>; type MaxCapacityThresholds = MaxCapacityThresholds; + type MaxContributionsPerUser = ConstU32<256>; + type MaxEvaluationsPerUser = ConstU32<256>; + type MaxMessageSizeThresholds = MaxMessageSizeThresholds; + type MaxProjectsToUpdatePerBlock = ConstU32<100>; + type Multiplier = pallet_funding::types::Multiplier; + type NativeCurrency = Balances; + type PalletId = FundingPalletId; + type PolimecReceiverInfo = PolimecReceiverInfo; + type PreImageLimit = ConstU32<1024>; + type Price = Price; + type PriceProvider = OraclePriceProvider; + type ProjectIdentifier = u32; + type Randomness = Random; + type RemainderFundingDuration = RemainderFundingDuration; type RequiredMaxCapacity = RequiredMaxCapacity; type RequiredMaxMessageSize = RequiredMaxMessageSize; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type StringLimit = ConstU32<64>; + type SuccessToSettlementTime = SuccessToSettlementTime; + type TreasuryAccount = TreasuryAccount; + type Vesting = LinearVesting; + type WeightInfo = pallet_funding::weights::SubstrateWeight; } parameter_types! { From d0b182761e5e3a491ef442dbc488bdd1230d3a32 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 23 Nov 2023 12:56:50 +0100 Subject: [PATCH 040/212] fixes --- integration-tests/penpal/src/lib.rs | 2 +- integration-tests/src/constants.rs | 10 +-- integration-tests/src/tests/ct_migration.rs | 99 ++++++++++++--------- integration-tests/src/tests/defaults.rs | 2 +- pallets/funding/src/functions.rs | 16 ++-- pallets/funding/src/lib.rs | 8 +- pallets/funding/src/mock.rs | 73 ++++++++------- 7 files changed, 104 insertions(+), 106 deletions(-) diff --git a/integration-tests/penpal/src/lib.rs b/integration-tests/penpal/src/lib.rs index 5243e878b..153840e45 100644 --- a/integration-tests/penpal/src/lib.rs +++ b/integration-tests/penpal/src/lib.rs @@ -582,7 +582,7 @@ impl Convert for DivideBalanceByBlocks { } } parameter_types! { - pub PolimecParaId: ParaId = 3355u32.into(); + pub PolimecParaId: ParaId = 3344u32.into(); pub GenesisMoment: BlockNumber = 0u32; } impl polimec_receiver::Config for Runtime { diff --git a/integration-tests/src/constants.rs b/integration-tests/src/constants.rs index e0b119ee1..913a22eab 100644 --- a/integration-tests/src/constants.rs +++ b/integration-tests/src/constants.rs @@ -7,11 +7,7 @@ use sc_consensus_grandpa::AuthorityId as GrandpaId; use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_consensus_babe::AuthorityId as BabeId; use sp_core::{sr25519, storage::Storage, Pair, Public}; -use sp_runtime::{ - bounded_vec, - traits::{IdentifyAccount, Verify}, - BuildStorage, MultiSignature, Perbill, -}; +use sp_runtime::{bounded_vec, BuildStorage, Perbill}; pub use xcm; use xcm_emulator::get_account_id_from_seed; @@ -21,8 +17,6 @@ pub const REF_TIME_THRESHOLD: u64 = 33; pub const PROOF_SIZE_THRESHOLD: u64 = 33; pub const INITIAL_DEPOSIT: u128 = 420_0_000_000_000; -type AccountPublic = ::Signer; - /// Helper function to generate a crypto pair from seed fn get_from_seed(seed: &str) -> ::Public { TPublic::Pair::from_string(&format!("//{}", seed), None).expect("static values are valid; qed").public() @@ -226,7 +220,7 @@ pub mod polimec { use pallet_funding::AcceptedFundingAsset; use xcm::{prelude::Parachain, v3::Parent}; - pub const PARA_ID: u32 = 3355; + pub const PARA_ID: u32 = 3344; pub const ED: Balance = polimec_parachain_runtime::EXISTENTIAL_DEPOSIT; pub fn genesis() -> Storage { diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index 592d7c7be..36a5c91cf 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -1,22 +1,26 @@ use crate::*; -use pallet_funding::{AcceptedFundingAsset, MigrationStatus, MultiplierOf, RewardOrSlash}; +use pallet_funding::{ + traits::VestingDurationCalculation, AcceptedFundingAsset, MigrationStatus, MultiplierOf, RewardOrSlash, +}; use polimec_parachain_runtime::PolimecFunding; use sp_runtime::{FixedPointNumber, Perquintill}; -use pallet_funding::traits::VestingDurationCalculation; use tests::defaults::*; #[test] fn migration_check() { let mut inst = IntegrationInstantiator::new(None); let project_id = Polimec::execute_with(|| { - inst.create_finished_project( + let project_id = inst.create_finished_project( default_project(issuer(), 0), issuer(), default_evaluations(), default_bids(), default_community_contributions(), vec![], - ) + ); + + inst.advance_time(::SuccessToSettlementTime::get() + 1u32).unwrap(); + project_id }); // Mock HRMP establishment @@ -32,8 +36,6 @@ fn migration_check() { let channel_accepted_message = xcm::v3::opaque::Instruction::HrmpChannelAccepted { recipient: 6969u32 }; assert_ok!(PolimecFunding::do_handle_channel_accepted(channel_accepted_message)); - - inst.advance_time(::SuccessToSettlementTime::get() + 1u32).unwrap(); }); Penpal::execute_with(|| { @@ -122,7 +124,9 @@ fn migration_is_sent() { assert!(user_evaluations.all(|evaluation| evaluation.ct_migration_status == MigrationStatus::Sent(query_id))); assert!(user_bids.all(|bid| bid.ct_migration_status == MigrationStatus::Sent(query_id))); - assert!(user_contributions.all(|contribution| contribution.ct_migration_status == MigrationStatus::Sent(query_id))); + assert!( + user_contributions.all(|contribution| contribution.ct_migration_status == MigrationStatus::Sent(query_id)) + ); }); } @@ -194,28 +198,32 @@ fn migration_is_executed_on_project_and_confirmed_on_polimec() { let user_contributions = pallet_funding::Contributions::::iter_prefix_values((project_id, eval_1())); - let evaluation_ct_amount = user_evaluations.map(|evaluation| { - assert_eq!(evaluation.ct_migration_status, MigrationStatus::Sent(query_id)); - if let Some(RewardOrSlash::Reward(amount)) = evaluation.rewarded_or_slashed { - amount - } else { - panic!("should be rewarded") - } - }).sum::(); - let bid_ct_amount = user_bids.map(|bid| { - assert_eq!(bid.ct_migration_status, MigrationStatus::Sent(query_id)); - bid.final_ct_amount - }).sum::(); - let contribution_ct_amount = user_contributions.map(|contribution| { - assert_eq!(contribution.ct_migration_status, MigrationStatus::Sent(query_id)); - contribution.ct_amount - }).sum::(); + let evaluation_ct_amount = user_evaluations + .map(|evaluation| { + assert_eq!(evaluation.ct_migration_status, MigrationStatus::Sent(query_id)); + if let Some(RewardOrSlash::Reward(amount)) = evaluation.rewarded_or_slashed { + amount + } else { + panic!("should be rewarded") + } + }) + .sum::(); + let bid_ct_amount = user_bids + .map(|bid| { + assert_eq!(bid.ct_migration_status, MigrationStatus::Sent(query_id)); + bid.final_ct_amount + }) + .sum::(); + let contribution_ct_amount = user_contributions + .map(|contribution| { + assert_eq!(contribution.ct_migration_status, MigrationStatus::Sent(query_id)); + contribution.ct_amount + }) + .sum::(); evaluation_ct_amount + bid_ct_amount + contribution_ct_amount - }); - Penpal::execute_with(|| { assert_expected_events!( Penpal, @@ -355,28 +363,32 @@ fn vesting_over_several_blocks_on_project() { let user_contributions = pallet_funding::Contributions::::iter_prefix_values((project_id, buyer_1())); - let evaluation_ct_amount = user_evaluations.map(|evaluation| { - assert_eq!(evaluation.ct_migration_status, MigrationStatus::Sent(query_id)); - if let Some(RewardOrSlash::Reward(amount)) = evaluation.rewarded_or_slashed { - amount - } else { - panic!("should be rewarded") - } - }).sum::(); - let bid_ct_amount = user_bids.map(|bid| { - assert_eq!(bid.ct_migration_status, MigrationStatus::Sent(query_id)); - bid.final_ct_amount - }).sum::(); - let contribution_ct_amount = user_contributions.map(|contribution| { - assert_eq!(contribution.ct_migration_status, MigrationStatus::Sent(query_id)); - contribution.ct_amount - }).sum::(); + let evaluation_ct_amount = user_evaluations + .map(|evaluation| { + assert_eq!(evaluation.ct_migration_status, MigrationStatus::Sent(query_id)); + if let Some(RewardOrSlash::Reward(amount)) = evaluation.rewarded_or_slashed { + amount + } else { + panic!("should be rewarded") + } + }) + .sum::(); + let bid_ct_amount = user_bids + .map(|bid| { + assert_eq!(bid.ct_migration_status, MigrationStatus::Sent(query_id)); + bid.final_ct_amount + }) + .sum::(); + let contribution_ct_amount = user_contributions + .map(|contribution| { + assert_eq!(contribution.ct_migration_status, MigrationStatus::Sent(query_id)); + contribution.ct_amount + }) + .sum::(); evaluation_ct_amount + bid_ct_amount + contribution_ct_amount - }); - Penpal::execute_with(|| { assert_expected_events!( Penpal, @@ -426,4 +438,3 @@ fn vesting_over_several_blocks_on_project() { let post_vest_balance = Penpal::account_data_of(buyer_1()); dbg!(post_vest_balance); } - diff --git a/integration-tests/src/tests/defaults.rs b/integration-tests/src/tests/defaults.rs index 52a88c694..2e7af7784 100644 --- a/integration-tests/src/tests/defaults.rs +++ b/integration-tests/src/tests/defaults.rs @@ -6,7 +6,7 @@ use pallet_funding::{ use sp_core::H256; use polimec_parachain_runtime::AccountId; -use sp_runtime::{traits::ConstU32, FixedPointNumber, Perquintill}; +use sp_runtime::{traits::ConstU32, Perquintill}; pub const METADATA: &str = r#"METADATA { "whitepaper":"ipfs_url", diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 687c82cec..4882b533b 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -37,7 +37,7 @@ use sp_runtime::traits::Convert; use sp_std::marker::PhantomData; use xcm::v3::MaxDispatchErrorLen; -use crate::{ProjectStatus::FundingSuccessful}; +use crate::ProjectStatus::FundingSuccessful; use polimec_traits::ReleaseSchedule; use crate::traits::{BondingRequirementCalculation, ProvideStatemintPrice, VestingDurationCalculation}; @@ -2193,16 +2193,16 @@ impl Pallet { Self::mark_migrations_as_sent(project_migration_origins.clone(), transact_response_query_id); UnconfirmedMigrations::::insert(transact_response_query_id, project_migration_origins); - Self::deposit_event(Event::::UserMigrationSent { project_id, caller: caller.clone(), participant: participant.clone() }); + Self::deposit_event(Event::::UserMigrationSent { + project_id, + caller: caller.clone(), + participant: participant.clone(), + }); } Ok(()) } - pub fn do_confirm_migrations( - location: MultiLocation, - query_id: QueryId, - response: Response, - ) -> DispatchResult { + pub fn do_confirm_migrations(location: MultiLocation, query_id: QueryId, response: Response) -> DispatchResult { use xcm::v3::prelude::*; let unconfirmed_migrations = UnconfirmedMigrations::::take(query_id).ok_or(Error::::NotAllowed)?; let project_id = unconfirmed_migrations.project_id; @@ -2763,7 +2763,7 @@ impl Pallet { UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, Transact { origin_kind: OriginKind::Native, require_weight_at_most: MAX_WEIGHT, call: encoded_call.into() }, ReportTransactStatus(QueryResponseInfo { - destination: Parachain(3355).into(), + destination: Parachain(3344).into(), query_id: 0, max_weight: MAX_WEIGHT, }), diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index be9a7269d..8bf976ea0 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1216,15 +1216,9 @@ pub mod pallet { Self::do_migrate_one_participant(caller, project_id, participant) } - - #[pallet::call_index(26)] #[pallet::weight(Weight::from_parts(1000, 0))] - pub fn confirm_migrations( - origin: OriginFor, - query_id: QueryId, - response: Response, - ) -> DispatchResult { + pub fn confirm_migrations(origin: OriginFor, query_id: QueryId, response: Response) -> DispatchResult { let location = ensure_response(::RuntimeOrigin::from(origin))?; Self::do_confirm_migrations(location, query_id, response) diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index aa2a7d077..0e9ed090e 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -86,7 +86,6 @@ pub const fn free_deposit() -> Balance { use frame_support::traits::{Everything, OriginTrait}; use frame_system::RawOrigin as SystemRawOrigin; use polkadot_parachain::primitives::Sibling; -use sp_core::crypto::Dummy; use sp_runtime::traits::Get; use xcm_builder::{EnsureXcmOrigin, FixedWeightBounds, ParentIsPreset, SiblingParachainConvertsVia}; use xcm_executor::traits::Convert; @@ -121,7 +120,7 @@ parameter_types! { parameter_types! { pub UniversalLocation: InteriorMultiLocation = ( GlobalConsensus(Polkadot), - Parachain(3355u32.into()), + Parachain(3344u32.into()), ).into(); pub const RelayNetwork: Option = None; pub UnitWeightCost: Weight = Weight::from_parts(1_000_000_000, 64 * 1024); @@ -338,51 +337,51 @@ impl sp_runtime::traits::Convert for DummyConverter { } impl Config for TestRuntime { - type AllPalletsWithoutSystem = AllPalletsWithoutSystem; - type RuntimeEvent = RuntimeEvent; - type BlockNumber = BlockNumber; type AccountId32Conversion = DummyConverter; - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - type ProjectIdentifier = Identifier; - type Multiplier = Multiplier; - type Balance = Balance; - type Price = FixedU128; - type NativeCurrency = Balances; - type FundingCurrency = StatemintAssets; - type ContributionTokenCurrency = LocalAssets; - type PriceProvider = ConstPriceProvider; - type Randomness = RandomnessCollectiveFlip; - type StringLimit = ConstU32<64>; - type PreImageLimit = ConstU32<1024>; - type EvaluationDuration = EvaluationDuration; + type AllPalletsWithoutSystem = AllPalletsWithoutSystem; type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; - type EnglishAuctionDuration = EnglishAuctionDuration; + type Balance = Balance; + type BlockNumber = BlockNumber; + type BlockNumberToBalance = ConvertInto; type CandleAuctionDuration = CandleAuctionDuration; type CommunityFundingDuration = CommunityRoundDuration; - type RemainderFundingDuration = RemainderFundingDuration; - type PalletId = FundingPalletId; - type MaxProjectsToUpdatePerBlock = ConstU32<100>; - type MaxEvaluationsPerUser = ConstU32<4>; - // Low value to simplify the tests - type MaxBidsPerUser = ConstU32<4>; - type MaxContributionsPerUser = ConstU32<4>; + type ContributionTokenCurrency = LocalAssets; type ContributionVesting = ConstU32<4>; - type WeightInfo = weights::SubstrateWeight; - type FeeBrackets = FeeBrackets; + type DaysToBlocks = DaysToBlocks; + type EnglishAuctionDuration = EnglishAuctionDuration; + type EvaluationDuration = EvaluationDuration; type EvaluationSuccessThreshold = EarlyEvaluationThreshold; - type Vesting = Vesting; - type ManualAcceptanceDuration = ManualAcceptanceDuration; - type SuccessToSettlementTime = SuccessToSettlementTime; type EvaluatorSlash = EvaluatorSlash; - type TreasuryAccount = TreasuryAccount; - type DaysToBlocks = DaysToBlocks; - type BlockNumberToBalance = ConvertInto; - type PolimecReceiverInfo = PolimecReceiverInfo; - type MaxMessageSizeThresholds = MaxMessageSizeThresholds; + type FeeBrackets = FeeBrackets; + type FundingCurrency = StatemintAssets; + type ManualAcceptanceDuration = ManualAcceptanceDuration; + // Low value to simplify the tests + type MaxBidsPerUser = ConstU32<4>; type MaxCapacityThresholds = MaxCapacityThresholds; + type MaxContributionsPerUser = ConstU32<4>; + type MaxEvaluationsPerUser = ConstU32<4>; + type MaxMessageSizeThresholds = MaxMessageSizeThresholds; + type MaxProjectsToUpdatePerBlock = ConstU32<100>; + type Multiplier = Multiplier; + type NativeCurrency = Balances; + type PalletId = FundingPalletId; + type PolimecReceiverInfo = PolimecReceiverInfo; + type PreImageLimit = ConstU32<1024>; + type Price = FixedU128; + type PriceProvider = ConstPriceProvider; + type ProjectIdentifier = Identifier; + type Randomness = RandomnessCollectiveFlip; + type RemainderFundingDuration = RemainderFundingDuration; type RequiredMaxCapacity = RequiredMaxCapacity; type RequiredMaxMessageSize = RequiredMaxMessageSize; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type StringLimit = ConstU32<64>; + type SuccessToSettlementTime = SuccessToSettlementTime; + type TreasuryAccount = TreasuryAccount; + type Vesting = Vesting; + type WeightInfo = weights::SubstrateWeight; } // Build genesis storage according to the mock runtime. From c10f4d64d4f79d29915f73a476812d9adeceec29 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 24 Nov 2023 11:18:43 +0100 Subject: [PATCH 041/212] save --- integration-tests/src/tests/e2e.rs | 7 +++++++ pallets/funding/src/functions.rs | 13 ++----------- pallets/funding/src/tests.rs | 8 ++++++++ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/integration-tests/src/tests/e2e.rs b/integration-tests/src/tests/e2e.rs index 77a190d3c..c285bace4 100644 --- a/integration-tests/src/tests/e2e.rs +++ b/integration-tests/src/tests/e2e.rs @@ -492,6 +492,13 @@ fn ct_migrated() { let names = names(); + Penpal::execute_with(||{ + assert_ok!(::XcmpMessageHandler::update_xcmp_max_individual_weight( + PenpalOrigin::root(), + Weight::from_parts(10_000_000_000, 500_000) + )); + }); + Polimec::execute_with(|| { for account in accounts { assert_ok!(PolimecFunding::migrate_one_participant( diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index cf05e8ec0..d4c614b60 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -2772,17 +2772,7 @@ impl Pallet { let available_bytes_for_migration_per_message = T::RequiredMaxMessageSize::get().saturating_sub(xcm_size as u32); - - let mut output = 0u32; - let mut current_migration_size = 0u32; - while current_migration_size < available_bytes_for_migration_per_message { - if current_migration_size + one_migration_bytes > available_bytes_for_migration_per_message { - break - } else { - current_migration_size += one_migration_bytes; - output += 1; - } - } + let mut output = available_bytes_for_migration_per_message.saturating_div(one_migration_bytes); output } @@ -2793,6 +2783,7 @@ impl Pallet { ) -> Vec<(BoundedVec, MaxMigrationsPerXcm>, Xcm<()>)> { // TODO: adjust this as benchmarks for polimec-receiver are written const MAX_WEIGHT: Weight = Weight::from_parts(10_000, 0); + // const MAX_WEIGHT: Weight = Weight::from_parts(100_003_000_000_000, 10_000_196_608); let _polimec_receiver_info = T::PolimecReceiverInfo::get(); // TODO: use the actual pallet index when the fields are not private anymore (https://github.com/paritytech/polkadot-sdk/pull/2231) diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 3092315e6..33c17e1c1 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -6075,6 +6075,14 @@ mod ct_migration { let project_details = inst.get_project_details(project_id); assert_eq!(project_details.parachain_id, None); } + + #[test] + fn check_migrations_per_xcm() { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + inst.execute(||{ + dbg!(Pallet::::migrations_per_xcm_message_allowed()) + }); + } } mod test_helper_functions { From c0d24515fb7e61bb8d9112120736622478ab1137 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 28 Nov 2023 16:59:33 +0100 Subject: [PATCH 042/212] limiting 5 migrations per block works --- integration-tests/Cargo.toml | 3 +++ integration-tests/src/tests/e2e.rs | 38 ++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index f354ec46d..15317f211 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -138,3 +138,6 @@ testing-node = [ "pallet-funding/testing-node", "polimec-parachain-runtime/testing-node" ] +fast-gov = [ + "polimec-parachain-runtime/fast-gov" +] \ No newline at end of file diff --git a/integration-tests/src/tests/e2e.rs b/integration-tests/src/tests/e2e.rs index c285bace4..5871254a8 100644 --- a/integration-tests/src/tests/e2e.rs +++ b/integration-tests/src/tests/e2e.rs @@ -425,7 +425,6 @@ fn ct_minted() { }); } -#[ignore] #[test] fn ct_migrated() { let mut inst = IntegrationInstantiator::new(None); @@ -499,20 +498,33 @@ fn ct_migrated() { )); }); - Polimec::execute_with(|| { - for account in accounts { - assert_ok!(PolimecFunding::migrate_one_participant( - PolimecOrigin::signed(account.clone()), - project_id, - account.clone() - )); - let key: [u8; 32] = account.clone().into(); - println!("Migrated CTs for {}", names[&key]); - inst.advance_time(1u32).unwrap(); + for group in accounts.chunks(5) { + PolkadotRelay::execute_with(||{ + let now = PolkadotSystem::block_number(); + PolkadotSystem::set_block_number(now + 1u32); + + }); + Polimec::execute_with(||{ + let now = PolimecSystem::block_number(); + PolimecSystem::set_block_number(now + 1u32); + }); + Penpal::execute_with(||{ + let now = PenpalSystem::block_number(); + PenpalSystem::set_block_number(now + 1u32); + }); + for account in group { + Polimec::execute_with(|| { + assert_ok!(PolimecFunding::migrate_one_participant( + PolimecOrigin::signed(account.clone()), + project_id, + account.clone() + )); + let key: [u8; 32] = account.clone().into(); + println!("Migrated CTs for {}", names[&key]); + }); } + } - // dbg!(Polimec::events()); - }); Penpal::execute_with(|| { dbg!(Penpal::events()); From c698ce8c1439c312d6ef2434aa3259caea32fa16 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 28 Nov 2023 17:05:20 +0100 Subject: [PATCH 043/212] fmt --- integration-tests/src/tests/e2e.rs | 18 ++++----- nodes/parachain/src/chain_spec/testnet.rs | 14 +++++-- pallets/funding/src/tests.rs | 4 +- runtimes/testnet/src/lib.rs | 45 ++++++++++++----------- 4 files changed, 42 insertions(+), 39 deletions(-) diff --git a/integration-tests/src/tests/e2e.rs b/integration-tests/src/tests/e2e.rs index 5871254a8..bbcfbfc31 100644 --- a/integration-tests/src/tests/e2e.rs +++ b/integration-tests/src/tests/e2e.rs @@ -491,7 +491,7 @@ fn ct_migrated() { let names = names(); - Penpal::execute_with(||{ + Penpal::execute_with(|| { assert_ok!(::XcmpMessageHandler::update_xcmp_max_individual_weight( PenpalOrigin::root(), Weight::from_parts(10_000_000_000, 500_000) @@ -499,33 +499,31 @@ fn ct_migrated() { }); for group in accounts.chunks(5) { - PolkadotRelay::execute_with(||{ + PolkadotRelay::execute_with(|| { let now = PolkadotSystem::block_number(); PolkadotSystem::set_block_number(now + 1u32); - }); - Polimec::execute_with(||{ + Polimec::execute_with(|| { let now = PolimecSystem::block_number(); PolimecSystem::set_block_number(now + 1u32); }); - Penpal::execute_with(||{ + Penpal::execute_with(|| { let now = PenpalSystem::block_number(); PenpalSystem::set_block_number(now + 1u32); }); for account in group { Polimec::execute_with(|| { assert_ok!(PolimecFunding::migrate_one_participant( - PolimecOrigin::signed(account.clone()), - project_id, - account.clone() - )); + PolimecOrigin::signed(account.clone()), + project_id, + account.clone() + )); let key: [u8; 32] = account.clone().into(); println!("Migrated CTs for {}", names[&key]); }); } } - Penpal::execute_with(|| { dbg!(Penpal::events()); // ::XcmpMessageHandler diff --git a/nodes/parachain/src/chain_spec/testnet.rs b/nodes/parachain/src/chain_spec/testnet.rs index f4ba55636..c4b7e83af 100644 --- a/nodes/parachain/src/chain_spec/testnet.rs +++ b/nodes/parachain/src/chain_spec/testnet.rs @@ -20,10 +20,16 @@ use cumulus_primitives_core::ParaId; use frame_benchmarking::frame_support::bounded_vec; -use polimec_parachain_runtime::{pallet_parachain_staking::{ - inflation::{perbill_annual_to_perbill_round, BLOCKS_PER_YEAR}, - InflationInfo, Range, -}, AccountId, AuraId as AuthorityId, Balance, BalancesConfig, CouncilConfig, GenesisConfig, LinearVestingConfig, MinCandidateStk, ParachainInfoConfig, ParachainStakingConfig, PolkadotXcmConfig, Runtime, SessionConfig, StatemintAssetsConfig, SudoConfig, SystemConfig, TechnicalCommitteeConfig, EXISTENTIAL_DEPOSIT, PLMC, OracleProvidersMembershipConfig}; +use polimec_parachain_runtime::{ + pallet_parachain_staking::{ + inflation::{perbill_annual_to_perbill_round, BLOCKS_PER_YEAR}, + InflationInfo, Range, + }, + AccountId, AuraId as AuthorityId, Balance, BalancesConfig, CouncilConfig, GenesisConfig, LinearVestingConfig, + MinCandidateStk, OracleProvidersMembershipConfig, ParachainInfoConfig, ParachainStakingConfig, PolkadotXcmConfig, + Runtime, SessionConfig, StatemintAssetsConfig, SudoConfig, SystemConfig, TechnicalCommitteeConfig, + EXISTENTIAL_DEPOSIT, PLMC, +}; use sc_service::ChainType; use sp_core::{crypto::UncheckedInto, sr25519}; use sp_runtime::{traits::AccountIdConversion, Perbill, Percent}; diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 33c17e1c1..1c3fc28f4 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -6079,9 +6079,7 @@ mod ct_migration { #[test] fn check_migrations_per_xcm() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - inst.execute(||{ - dbg!(Pallet::::migrations_per_xcm_message_allowed()) - }); + inst.execute(|| dbg!(Pallet::::migrations_per_xcm_message_allowed())); } } diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 13b606543..acaa1f271 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -68,9 +68,9 @@ pub use crate::xcm_config::*; include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); // Polimec Shared Imports -use pallet_funding::{AcceptedFundingAsset, BondTypeOf, DaysToBlocks}; #[cfg(feature = "runtime-benchmarks")] use pallet_funding::traits::SetPrices; +use pallet_funding::{AcceptedFundingAsset, BondTypeOf, DaysToBlocks}; pub use pallet_parachain_staking; pub use shared_configuration::*; @@ -153,32 +153,33 @@ pub struct SetOraclePrices; #[cfg(feature = "runtime-benchmarks")] impl SetPrices for SetOraclePrices { fn set_prices() { - let dot = (AcceptedFundingAsset::DOT.to_statemint_id(), FixedU128::from_rational(69, 1)); let usdc = (AcceptedFundingAsset::USDT.to_statemint_id(), FixedU128::from_rational(1, 1)); let usdt = (AcceptedFundingAsset::USDT.to_statemint_id(), FixedU128::from_rational(1, 1)); let plmc = (pallet_funding::PLMC_STATEMINT_ID, FixedU128::from_rational(840, 100)); - let values: BoundedVec<(u32, FixedU128), >::MaxFeedValues> = vec![ - dot, usdc, usdt, plmc].try_into().expect("benchmarks can panic"); - let alice: [u8; 32] = [212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, 86, 132, 231, 165, 109, 162, 125]; - let bob: [u8; 32] = [142, 175, 4, 21, 22, 135, 115, 99, 38, 201, 254, 161, 126, 37, 252, 82, 135, 97, 54, 147, 201, 18, 144, 156, 178, 38, 170, 71, 148, 242, 106, 72]; - let charlie: [u8; 32] = [144, 181, 171, 32, 92, 105, 116, 201, 234, 132, 27, 230, 136, 134, 70, 51, 220, 156, 168, 163, 87, 132, 62, 234, 207, 35, 20, 100, 153, 101, 254, 34]; - - frame_support::assert_ok!(Oracle::feed_values( - RuntimeOrigin::signed(alice.clone().into()), - values.clone() - )); - - frame_support::assert_ok!(Oracle::feed_values( - RuntimeOrigin::signed(bob.clone().into()), - values.clone() - )); - - frame_support::assert_ok!(Oracle::feed_values( - RuntimeOrigin::signed(charlie.clone().into()), - values.clone() - )); + let values: BoundedVec< + (u32, FixedU128), + >::MaxFeedValues, + > = vec![dot, usdc, usdt, plmc].try_into().expect("benchmarks can panic"); + let alice: [u8; 32] = [ + 212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, + 227, 154, 86, 132, 231, 165, 109, 162, 125, + ]; + let bob: [u8; 32] = [ + 142, 175, 4, 21, 22, 135, 115, 99, 38, 201, 254, 161, 126, 37, 252, 82, 135, 97, 54, 147, 201, 18, 144, + 156, 178, 38, 170, 71, 148, 242, 106, 72, + ]; + let charlie: [u8; 32] = [ + 144, 181, 171, 32, 92, 105, 116, 201, 234, 132, 27, 230, 136, 134, 70, 51, 220, 156, 168, 163, 87, 132, 62, + 234, 207, 35, 20, 100, 153, 101, 254, 34, + ]; + + frame_support::assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(alice.clone().into()), values.clone())); + + frame_support::assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(bob.clone().into()), values.clone())); + + frame_support::assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(charlie.clone().into()), values.clone())); } } From 5cb739f1e8c0a8de1e93296f89f4866551d1939f Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 28 Nov 2023 17:40:20 +0100 Subject: [PATCH 044/212] save --- integration-tests/src/tests/e2e.rs | 44 +++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/integration-tests/src/tests/e2e.rs b/integration-tests/src/tests/e2e.rs index bbcfbfc31..14b23bc4d 100644 --- a/integration-tests/src/tests/e2e.rs +++ b/integration-tests/src/tests/e2e.rs @@ -491,27 +491,27 @@ fn ct_migrated() { let names = names(); - Penpal::execute_with(|| { - assert_ok!(::XcmpMessageHandler::update_xcmp_max_individual_weight( - PenpalOrigin::root(), - Weight::from_parts(10_000_000_000, 500_000) - )); - }); - - for group in accounts.chunks(5) { - PolkadotRelay::execute_with(|| { - let now = PolkadotSystem::block_number(); - PolkadotSystem::set_block_number(now + 1u32); - }); - Polimec::execute_with(|| { - let now = PolimecSystem::block_number(); - PolimecSystem::set_block_number(now + 1u32); - }); - Penpal::execute_with(|| { - let now = PenpalSystem::block_number(); - PenpalSystem::set_block_number(now + 1u32); - }); - for account in group { + // Penpal::execute_with(|| { + // assert_ok!(::XcmpMessageHandler::update_xcmp_max_individual_weight( + // PenpalOrigin::root(), + // Weight::from_parts(10_000_000_000, 500_000) + // )); + // }); + + // for group in accounts.chunks(5) { + // PolkadotRelay::execute_with(|| { + // let now = PolkadotSystem::block_number(); + // PolkadotSystem::set_block_number(now + 1u32); + // }); + // Polimec::execute_with(|| { + // let now = PolimecSystem::block_number(); + // PolimecSystem::set_block_number(now + 1u32); + // }); + // Penpal::execute_with(|| { + // let now = PenpalSystem::block_number(); + // PenpalSystem::set_block_number(now + 1u32); + // }); + for account in accounts { Polimec::execute_with(|| { assert_ok!(PolimecFunding::migrate_one_participant( PolimecOrigin::signed(account.clone()), @@ -522,7 +522,7 @@ fn ct_migrated() { println!("Migrated CTs for {}", names[&key]); }); } - } + // } Penpal::execute_with(|| { dbg!(Penpal::events()); From 4e0a6c3dad15847ffba1b71af552d16fb0d61884 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 28 Nov 2023 17:47:48 +0100 Subject: [PATCH 045/212] back to normal migration without bundling per block, now works for some reason --- integration-tests/src/tests/e2e.rs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/integration-tests/src/tests/e2e.rs b/integration-tests/src/tests/e2e.rs index 14b23bc4d..87fa02470 100644 --- a/integration-tests/src/tests/e2e.rs +++ b/integration-tests/src/tests/e2e.rs @@ -511,22 +511,23 @@ fn ct_migrated() { // let now = PenpalSystem::block_number(); // PenpalSystem::set_block_number(now + 1u32); // }); - for account in accounts { - Polimec::execute_with(|| { - assert_ok!(PolimecFunding::migrate_one_participant( - PolimecOrigin::signed(account.clone()), - project_id, - account.clone() - )); - let key: [u8; 32] = account.clone().into(); - println!("Migrated CTs for {}", names[&key]); - }); - } + for account in accounts { + Polimec::execute_with(|| { + assert_ok!(PolimecFunding::migrate_one_participant( + PolimecOrigin::signed(account.clone()), + project_id, + account.clone() + )); + let key: [u8; 32] = account.clone().into(); + println!("Migrated CTs for {}", names[&key]); + inst.advance_time(1u32).unwrap(); + + }); + } // } Penpal::execute_with(|| { dbg!(Penpal::events()); - // ::XcmpMessageHandler }); // Check balances after migration, before vesting From ad0bdc0fc6f6a2a756ce20ebc0fbf308f69ff3e9 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 29 Nov 2023 09:49:14 +0100 Subject: [PATCH 046/212] final commit --- integration-tests/src/tests/e2e.rs | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/integration-tests/src/tests/e2e.rs b/integration-tests/src/tests/e2e.rs index 87fa02470..75092f62b 100644 --- a/integration-tests/src/tests/e2e.rs +++ b/integration-tests/src/tests/e2e.rs @@ -491,26 +491,6 @@ fn ct_migrated() { let names = names(); - // Penpal::execute_with(|| { - // assert_ok!(::XcmpMessageHandler::update_xcmp_max_individual_weight( - // PenpalOrigin::root(), - // Weight::from_parts(10_000_000_000, 500_000) - // )); - // }); - - // for group in accounts.chunks(5) { - // PolkadotRelay::execute_with(|| { - // let now = PolkadotSystem::block_number(); - // PolkadotSystem::set_block_number(now + 1u32); - // }); - // Polimec::execute_with(|| { - // let now = PolimecSystem::block_number(); - // PolimecSystem::set_block_number(now + 1u32); - // }); - // Penpal::execute_with(|| { - // let now = PenpalSystem::block_number(); - // PenpalSystem::set_block_number(now + 1u32); - // }); for account in accounts { Polimec::execute_with(|| { assert_ok!(PolimecFunding::migrate_one_participant( @@ -521,10 +501,8 @@ fn ct_migrated() { let key: [u8; 32] = account.clone().into(); println!("Migrated CTs for {}", names[&key]); inst.advance_time(1u32).unwrap(); - }); } - // } Penpal::execute_with(|| { dbg!(Penpal::events()); From 07806566ecf2687f134eface4ed6b87885eed54c Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 29 Nov 2023 11:38:56 +0100 Subject: [PATCH 047/212] first commit --- integration-tests/src/tests/e2e.rs | 22 ++++++++++++++++++++++ pallets/funding/README.md | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/integration-tests/src/tests/e2e.rs b/integration-tests/src/tests/e2e.rs index 75092f62b..87fa02470 100644 --- a/integration-tests/src/tests/e2e.rs +++ b/integration-tests/src/tests/e2e.rs @@ -491,6 +491,26 @@ fn ct_migrated() { let names = names(); + // Penpal::execute_with(|| { + // assert_ok!(::XcmpMessageHandler::update_xcmp_max_individual_weight( + // PenpalOrigin::root(), + // Weight::from_parts(10_000_000_000, 500_000) + // )); + // }); + + // for group in accounts.chunks(5) { + // PolkadotRelay::execute_with(|| { + // let now = PolkadotSystem::block_number(); + // PolkadotSystem::set_block_number(now + 1u32); + // }); + // Polimec::execute_with(|| { + // let now = PolimecSystem::block_number(); + // PolimecSystem::set_block_number(now + 1u32); + // }); + // Penpal::execute_with(|| { + // let now = PenpalSystem::block_number(); + // PenpalSystem::set_block_number(now + 1u32); + // }); for account in accounts { Polimec::execute_with(|| { assert_ok!(PolimecFunding::migrate_one_participant( @@ -501,8 +521,10 @@ fn ct_migrated() { let key: [u8; 32] = account.clone().into(); println!("Migrated CTs for {}", names[&key]); inst.advance_time(1u32).unwrap(); + }); } + // } Penpal::execute_with(|| { dbg!(Penpal::events()); diff --git a/pallets/funding/README.md b/pallets/funding/README.md index 97b072c21..453df7ee9 100644 --- a/pallets/funding/README.md +++ b/pallets/funding/README.md @@ -1,6 +1,6 @@ # Funding Pallet -Polimec's main business logic. It allows credentialised users to create, +Polimec's main business logic. It allows credentialed users to create, evaluate, and fund projects. It rewards project evaluators and contributors with `Contribution Tokens`. These From 8a098bde041f3d047af6e04fb32fedf8d2d9c455 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 29 Nov 2023 15:02:47 +0100 Subject: [PATCH 048/212] ct migration tests refactor --- integration-tests/src/tests/ct_migration.rs | 408 ++++++++------------ integration-tests/src/tests/e2e.rs | 1 - pallets/funding/src/functions.rs | 4 +- pallets/polimec-receiver/src/lib.rs | 3 +- 4 files changed, 162 insertions(+), 254 deletions(-) diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index a49bf165d..cbf3aa2f6 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -1,30 +1,21 @@ use crate::*; -use pallet_funding::{ - traits::VestingDurationCalculation, AcceptedFundingAsset, MigrationStatus, MultiplierOf, RewardOrSlash, -}; +use pallet_funding::{traits::VestingDurationCalculation, AcceptedFundingAsset, MigrationStatus, MultiplierOf, ProjectIdOf, RewardOrSlash, BidStatus, Multiplier, assert_close_enough}; use polimec_parachain_runtime::PolimecFunding; use sp_runtime::{FixedPointNumber, Perquintill}; +use std::collections::HashMap; +use polimec_receiver::MigrationInfo; use tests::defaults::*; -#[test] -fn migration_check() { - let mut inst = IntegrationInstantiator::new(None); - set_oracle_prices(); - let project_id = Polimec::execute_with(|| { - let project_id = inst.create_finished_project( - default_project(issuer(), 0), - issuer(), - default_evaluations(), - default_bids(), - default_community_contributions(), - vec![], - ); +fn calculate_total_ct_amount<'a>(migrations: impl Iterator) -> u128 { + migrations.into_iter().map(|m| m.contribution_token_amount).sum() +} +fn execute_cleaner(inst: &mut IntegrationInstantiator) { + Polimec::execute_with(||{ inst.advance_time(::SuccessToSettlementTime::get() + 1u32).unwrap(); - project_id }); - - // Mock HRMP establishment +} +fn mock_hrmp_establishment(project_id: u32) { Polimec::execute_with(|| { assert_ok!(PolimecFunding::do_set_para_id_for_project(&issuer(), project_id, ParaId::from(6969u32))); @@ -43,16 +34,136 @@ fn migration_check() { println!("penpal events:"); dbg!(Penpal::events()); }); +} +fn assert_migration_is_ready(project_id: u32) { Polimec::execute_with(|| { - println!("Polimec events:"); - dbg!(Polimec::events()); - let project_details = pallet_funding::ProjectsDetails::::get(project_id).unwrap(); assert!(project_details.migration_readiness_check.unwrap().is_ready()) }); } +fn send_migrations( + project_id: ProjectIdOf, + accounts: Vec, +) -> HashMap> { + let mut output = HashMap::new(); + for account in accounts { + let migrations = Polimec::execute_with(|| { + assert_ok!(PolimecFunding::migrate_one_participant(PolimecOrigin::signed(account.clone()), project_id, account.clone())); + let (query_id, _migrations) = + pallet_funding::UnconfirmedMigrations::::iter().next().unwrap(); + + let user_evaluations = + pallet_funding::Evaluations::::iter_prefix_values((project_id, account.clone())); + let user_bids = pallet_funding::Bids::::iter_prefix_values((project_id, account.clone())) + .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))); + let user_contributions = + pallet_funding::Contributions::::iter_prefix_values((project_id, account.clone())); + + let evaluation_migrations = user_evaluations + .map(|evaluation| { + assert_eq!(evaluation.ct_migration_status, MigrationStatus::Sent(query_id)); + if let Some(RewardOrSlash::Reward(amount)) = evaluation.rewarded_or_slashed { + MigrationInfo { + contribution_token_amount: amount, + vesting_time: Multiplier::new(1u8).unwrap().calculate_vesting_duration::().into() + } + } else { + panic!("should be rewarded") + } + }); + let bid_migrations = user_bids + .map(|bid| { + assert_eq!(bid.ct_migration_status, MigrationStatus::Sent(query_id)); + MigrationInfo { + contribution_token_amount: bid.final_ct_amount, + vesting_time: bid.multiplier.calculate_vesting_duration::().into() + } + }); + let contribution_ct_amount = user_contributions + .map(|contribution| { + assert_eq!(contribution.ct_migration_status, MigrationStatus::Sent(query_id)); + MigrationInfo { + contribution_token_amount: contribution.ct_amount, + vesting_time: contribution.multiplier.calculate_vesting_duration::().into() + } + }); + + evaluation_migrations.chain(bid_migrations).chain(contribution_ct_amount).collect::>() + }); + output.insert(account.clone(), migrations); + } + output +} + +fn migrations_are_executed(migrations: impl Iterator)>) { + Penpal::execute_with(|| { + + for (account, migrations) in migrations { + let amount = calculate_total_ct_amount(migrations.iter()); + + assert_expected_events!( + Penpal, + vec![ + PenpalEvent::PolimecReceiver(polimec_receiver::Event::MigrationsExecutedForUser{user, migrations}) => { + user: *user == account, + migrations: migrations.into_iter().map(|m|m.contribution_token_amount).sum::() == amount, + }, + ] + ); + } + }); +} + +fn migrations_are_confirmed_for(project_id: u32, accounts: Vec) { + Polimec::execute_with(|| { + for account in accounts { + let mut user_evaluations = + pallet_funding::Evaluations::::iter_prefix_values((project_id, account.clone())); + let mut user_bids = pallet_funding::Bids::::iter_prefix_values((project_id, account.clone())); + let mut user_contributions = + pallet_funding::Contributions::::iter_prefix_values((project_id, account.clone())); + + assert!(user_evaluations.all(|bid| bid.ct_migration_status == MigrationStatus::Confirmed)); + assert!(user_bids.all(|bid| bid.ct_migration_status == MigrationStatus::Confirmed)); + assert!(user_contributions.all(|contribution| contribution.ct_migration_status == MigrationStatus::Confirmed)); + + assert_expected_events!( + Polimec, + vec![ + PolimecEvent::PolimecFunding(pallet_funding::Event::MigrationsConfirmed{project_id, ..}) => { + project_id: project_id == project_id, + }, + ] + ); + } + }); +} + +#[test] +fn migration_check() { + let mut inst = IntegrationInstantiator::new(None); + set_oracle_prices(); + let project_id = Polimec::execute_with(|| { + let project_id = inst.create_finished_project( + default_project(issuer(), 0), + issuer(), + default_evaluations(), + default_bids(), + default_community_contributions(), + vec![], + ); + + inst.advance_time(::SuccessToSettlementTime::get() + 1u32).unwrap(); + project_id + }); + + mock_hrmp_establishment(project_id); + + assert_migration_is_ready(project_id); +} + #[test] fn migration_is_sent() { let mut inst = IntegrationInstantiator::new(None); @@ -84,53 +195,17 @@ fn migration_is_sent() { vec![], ) }); + execute_cleaner(&mut inst); + let penpal_sov_acc = PolkadotRelay::sovereign_account_id_of(Parachain(Penpal::para_id().into()).into()); PolkadotRelay::fund_accounts(vec![(penpal_sov_acc, 100_0_000_000_000u128)]); - // Mock HRMP establishment - Polimec::execute_with(|| { - assert_ok!(PolimecFunding::do_set_para_id_for_project(&issuer(), project_id, ParaId::from(6969u32))); - let open_channel_message = xcm::v3::opaque::Instruction::HrmpNewChannelOpenRequest { - sender: 6969, - max_message_size: 102_300, - max_capacity: 1000, - }; - assert_ok!(PolimecFunding::do_handle_channel_open_request(open_channel_message)); + mock_hrmp_establishment(project_id); - let channel_accepted_message = xcm::v3::opaque::Instruction::HrmpChannelAccepted { recipient: 6969u32 }; - assert_ok!(PolimecFunding::do_handle_channel_accepted(channel_accepted_message)); - - inst.advance_time(::SuccessToSettlementTime::get() + 1u32).unwrap(); - let project_details = pallet_funding::ProjectsDetails::::get(project_id).unwrap(); - dbg!(project_details.evaluation_round_info.evaluators_outcome); - let evaluations = - pallet_funding::Evaluations::::iter_prefix_values((project_id,)).collect::>(); - dbg!(evaluations); - }); - - // Migration is ready - Polimec::execute_with(|| { - let project_details = pallet_funding::ProjectsDetails::::get(project_id).unwrap(); - assert!(project_details.migration_readiness_check.unwrap().is_ready()) - }); + assert_migration_is_ready(project_id); - // Migrate one user's contribution tokens. He evaluated, bid, and contributed - Polimec::execute_with(|| { - assert_ok!(PolimecFunding::migrate_one_participant(PolimecOrigin::signed(eval_1()), project_id, eval_1())); - let query_id = pallet_funding::UnconfirmedMigrations::::iter_keys().next().unwrap(); - let mut user_evaluations = - pallet_funding::Evaluations::::iter_prefix_values((project_id, eval_1())); - let mut user_bids = pallet_funding::Bids::::iter_prefix_values((project_id, eval_1())); - let mut user_contributions = - pallet_funding::Contributions::::iter_prefix_values((project_id, eval_1())); - - assert!(user_evaluations.all(|evaluation| evaluation.ct_migration_status == MigrationStatus::Sent(query_id))); - assert!(user_bids.all(|bid| bid.ct_migration_status == MigrationStatus::Sent(query_id))); - assert!( - user_contributions.all(|contribution| contribution.ct_migration_status == MigrationStatus::Sent(query_id)) - ); - }); + send_migrations(project_id, vec![eval_1()]); } #[test] @@ -164,112 +239,27 @@ fn migration_is_executed_on_project_and_confirmed_on_polimec() { vec![], ) }); + execute_cleaner(&mut inst); let penpal_sov_acc = PolkadotRelay::sovereign_account_id_of(Parachain(Penpal::para_id().into()).into()); PolkadotRelay::fund_accounts(vec![(penpal_sov_acc, 100_0_000_000_000u128)]); - // Mock HRMP establishment - Polimec::execute_with(|| { - assert_ok!(PolimecFunding::do_set_para_id_for_project(&issuer(), project_id, ParaId::from(6969u32))); - - let open_channel_message = xcm::v3::opaque::Instruction::HrmpNewChannelOpenRequest { - sender: 6969, - max_message_size: 102_300, - max_capacity: 1000, - }; - assert_ok!(PolimecFunding::do_handle_channel_open_request(open_channel_message)); - - let channel_accepted_message = xcm::v3::opaque::Instruction::HrmpChannelAccepted { recipient: 6969u32 }; - assert_ok!(PolimecFunding::do_handle_channel_accepted(channel_accepted_message)); + mock_hrmp_establishment(project_id); - inst.advance_time(::SuccessToSettlementTime::get() + 1u32).unwrap(); - }); - - // Migration is ready - Polimec::execute_with(|| { - let project_details = pallet_funding::ProjectsDetails::::get(project_id).unwrap(); - assert!(project_details.migration_readiness_check.unwrap().is_ready()) - }); + assert_migration_is_ready(project_id); let pre_migration_balance = Penpal::account_data_of(eval_1()); - // Migrate is sent - let migrated_ct_amount = Polimec::execute_with(|| { - assert_ok!(PolimecFunding::migrate_one_participant(PolimecOrigin::signed(eval_1()), project_id, eval_1())); - let (query_id, _migrations) = pallet_funding::UnconfirmedMigrations::::iter().next().unwrap(); - - let user_evaluations = - pallet_funding::Evaluations::::iter_prefix_values((project_id, eval_1())); - let user_bids = pallet_funding::Bids::::iter_prefix_values((project_id, eval_1())); - let user_contributions = - pallet_funding::Contributions::::iter_prefix_values((project_id, eval_1())); - - let evaluation_ct_amount = user_evaluations - .map(|evaluation| { - assert_eq!(evaluation.ct_migration_status, MigrationStatus::Sent(query_id)); - if let Some(RewardOrSlash::Reward(amount)) = evaluation.rewarded_or_slashed { - amount - } else { - panic!("should be rewarded") - } - }) - .sum::(); - let bid_ct_amount = user_bids - .map(|bid| { - assert_eq!(bid.ct_migration_status, MigrationStatus::Sent(query_id)); - bid.final_ct_amount - }) - .sum::(); - let contribution_ct_amount = user_contributions - .map(|contribution| { - assert_eq!(contribution.ct_migration_status, MigrationStatus::Sent(query_id)); - contribution.ct_amount - }) - .sum::(); - - evaluation_ct_amount + bid_ct_amount + contribution_ct_amount - }); + let migrations = send_migrations(project_id, vec![eval_1()]); + let eval_1_migrations = migrations[&eval_1()].clone(); - Penpal::execute_with(|| { - dbg!(Penpal::events()); - assert_expected_events!( - Penpal, - vec![ - PenpalEvent::PolimecReceiver(polimec_receiver::Event::MigrationsExecutedForUser{user, ..}) => { - user: *user == eval_1(), - }, - ] - ); - dbg!(Penpal::events()); - }); + migrations_are_confirmed_for(project_id, vec![eval_1()]); + let eval_1_total_migrated_amount = calculate_total_ct_amount(eval_1_migrations.iter()); // Balance is there for the user after vesting (Multiplier 1, so no vesting) let post_migration_balance = Penpal::account_data_of(eval_1()); - dbg!(migrated_ct_amount); - dbg!(pre_migration_balance.clone()); - dbg!(post_migration_balance.clone()); - assert_eq!(post_migration_balance.free - pre_migration_balance.free, migrated_ct_amount); + assert_eq!(post_migration_balance.free - pre_migration_balance.free, eval_1_total_migrated_amount); - Polimec::execute_with(|| { - let mut user_evaluations = - pallet_funding::Evaluations::::iter_prefix_values((project_id, eval_1())); - let mut user_bids = pallet_funding::Bids::::iter_prefix_values((project_id, eval_1())); - let mut user_contributions = - pallet_funding::Contributions::::iter_prefix_values((project_id, eval_1())); - - assert!(user_evaluations.all(|bid| bid.ct_migration_status == MigrationStatus::Confirmed)); - assert!(user_bids.all(|bid| bid.ct_migration_status == MigrationStatus::Confirmed)); - assert!(user_contributions.all(|contribution| contribution.ct_migration_status == MigrationStatus::Confirmed)); - - assert_expected_events!( - Polimec, - vec![ - PolimecEvent::PolimecFunding(pallet_funding::Event::MigrationsConfirmed{project_id, ..}) => { - project_id: project_id == project_id, - }, - ] - ); - }); } #[test] @@ -332,110 +322,27 @@ fn vesting_over_several_blocks_on_project() { vec![], ) }); + execute_cleaner(&mut inst); let penpal_sov_acc = PolkadotRelay::sovereign_account_id_of(Parachain(Penpal::para_id().into()).into()); PolkadotRelay::fund_accounts(vec![(penpal_sov_acc, 100_0_000_000_000u128)]); - // Mock HRMP establishment - Polimec::execute_with(|| { - assert_ok!(PolimecFunding::do_set_para_id_for_project(&issuer(), project_id, ParaId::from(6969u32))); - - let open_channel_message = xcm::v3::opaque::Instruction::HrmpNewChannelOpenRequest { - sender: 6969, - max_message_size: 102_300, - max_capacity: 1000, - }; - assert_ok!(PolimecFunding::do_handle_channel_open_request(open_channel_message)); + mock_hrmp_establishment(project_id); - let channel_accepted_message = xcm::v3::opaque::Instruction::HrmpChannelAccepted { recipient: 6969u32 }; - assert_ok!(PolimecFunding::do_handle_channel_accepted(channel_accepted_message)); - - inst.advance_time(::SuccessToSettlementTime::get() + 1u32).unwrap(); - }); - - // Migration is ready - Polimec::execute_with(|| { - let project_details = pallet_funding::ProjectsDetails::::get(project_id).unwrap(); - assert!(project_details.migration_readiness_check.unwrap().is_ready()) - }); + assert_migration_is_ready(project_id); let pre_migration_balance = Penpal::account_data_of(buyer_1()); // Migrate is sent - let migrated_ct_amount = Polimec::execute_with(|| { - assert_ok!(PolimecFunding::migrate_one_participant(PolimecOrigin::signed(buyer_1()), project_id, buyer_1())); - let (query_id, _migrations) = pallet_funding::UnconfirmedMigrations::::iter().next().unwrap(); - - let user_evaluations = - pallet_funding::Evaluations::::iter_prefix_values((project_id, buyer_1())); - let user_bids = pallet_funding::Bids::::iter_prefix_values((project_id, buyer_1())); - let user_contributions = - pallet_funding::Contributions::::iter_prefix_values((project_id, buyer_1())); - - let evaluation_ct_amount = user_evaluations - .map(|evaluation| { - assert_eq!(evaluation.ct_migration_status, MigrationStatus::Sent(query_id)); - if let Some(RewardOrSlash::Reward(amount)) = evaluation.rewarded_or_slashed { - amount - } else { - panic!("should be rewarded") - } - }) - .sum::(); - let bid_ct_amount = user_bids - .map(|bid| { - assert_eq!(bid.ct_migration_status, MigrationStatus::Sent(query_id)); - bid.final_ct_amount - }) - .sum::(); - let contribution_ct_amount = user_contributions - .map(|contribution| { - assert_eq!(contribution.ct_migration_status, MigrationStatus::Sent(query_id)); - contribution.ct_amount - }) - .sum::(); - - evaluation_ct_amount + bid_ct_amount + contribution_ct_amount - }); + let migrations_sent = send_migrations(project_id, vec![buyer_1()]); - Penpal::execute_with(|| { - assert_expected_events!( - Penpal, - vec![ - PenpalEvent::PolimecReceiver(polimec_receiver::Event::MigrationsExecutedForUser{user, ..}) => { - user: *user == buyer_1(), - }, - ] - ); + migrations_are_executed(migrations_sent.into_iter()); - dbg!(Penpal::events()); - }); - - // Balance is there for the user after vesting (Multiplier 1, so no vesting) let post_migration_balance = Penpal::account_data_of(buyer_1()); - dbg!(migrated_ct_amount); - dbg!(pre_migration_balance.clone()); - dbg!(post_migration_balance.clone()); - Polimec::execute_with(|| { - let mut user_evaluations = - pallet_funding::Evaluations::::iter_prefix_values((project_id, buyer_1())); - let mut user_bids = pallet_funding::Bids::::iter_prefix_values((project_id, buyer_1())); - let mut user_contributions = - pallet_funding::Contributions::::iter_prefix_values((project_id, buyer_1())); - - assert!(user_evaluations.all(|bid| bid.ct_migration_status == MigrationStatus::Confirmed)); - assert!(user_bids.all(|bid| bid.ct_migration_status == MigrationStatus::Confirmed)); - assert!(user_contributions.all(|contribution| contribution.ct_migration_status == MigrationStatus::Confirmed)); - - assert_expected_events!( - Polimec, - vec![ - PolimecEvent::PolimecFunding(pallet_funding::Event::MigrationsConfirmed{project_id, ..}) => { - project_id: project_id == project_id, - }, - ] - ); - }); + assert_close_enough!(post_migration_balance.free - pre_migration_balance.free - post_migration_balance.frozen - pre_migration_balance.frozen, 10_250 * ASSET_UNIT, Perquintill::from_parts(10_000_000_000u64)); + + migrations_are_confirmed_for(project_id, vec![buyer_1()]); + Penpal::execute_with(|| { let unblock_time: u32 = multiplier_for_vesting.calculate_vesting_duration::(); @@ -444,5 +351,8 @@ fn vesting_over_several_blocks_on_project() { }); let post_vest_balance = Penpal::account_data_of(buyer_1()); - dbg!(post_vest_balance); + assert_close_enough!(post_vest_balance.free - post_vest_balance.frozen, 10_250 * ASSET_UNIT + 2000 * ASSET_UNIT, Perquintill::from_parts(10_000_000_000u64)); } + +#[test] +fn disallow_duplicated_migrations_on_receiver_pallet() {} diff --git a/integration-tests/src/tests/e2e.rs b/integration-tests/src/tests/e2e.rs index 87fa02470..57eeab692 100644 --- a/integration-tests/src/tests/e2e.rs +++ b/integration-tests/src/tests/e2e.rs @@ -521,7 +521,6 @@ fn ct_migrated() { let key: [u8; 32] = account.clone().into(); println!("Migrated CTs for {}", names[&key]); inst.advance_time(1u32).unwrap(); - }); } // } diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 58dc5b4eb..7a2ccefab 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -694,8 +694,6 @@ impl Pallet { } } -// Extrinsics and HRMP interactions - // Extrinsics and HRMP interactions impl Pallet { /// Change the metadata hash of a project @@ -2772,7 +2770,7 @@ impl Pallet { let available_bytes_for_migration_per_message = T::RequiredMaxMessageSize::get().saturating_sub(xcm_size as u32); - let mut output = available_bytes_for_migration_per_message.saturating_div(one_migration_bytes); + let output = available_bytes_for_migration_per_message.saturating_div(one_migration_bytes); output } diff --git a/pallets/polimec-receiver/src/lib.rs b/pallets/polimec-receiver/src/lib.rs index daeaf0c2d..7b88718fb 100644 --- a/pallets/polimec-receiver/src/lib.rs +++ b/pallets/polimec-receiver/src/lib.rs @@ -105,8 +105,9 @@ pub mod pallet { } } -#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] +#[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct MigrationInfo { pub contribution_token_amount: u128, pub vesting_time: u64, } + From 90558f01a54ecee057d0acabf34a7518f1a7653e Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 29 Nov 2023 16:58:53 +0100 Subject: [PATCH 049/212] stable --- integration-tests/src/tests/ct_migration.rs | 98 ++++++++++-------- pallets/funding/src/functions.rs | 109 ++++++++++++-------- pallets/funding/src/lib.rs | 9 +- pallets/funding/src/types.rs | 28 +---- pallets/polimec-receiver/src/lib.rs | 1 - runtimes/testnet/src/lib.rs | 14 ++- traits/src/lib.rs | 32 +++++- 7 files changed, 175 insertions(+), 116 deletions(-) diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index cbf3aa2f6..4d073fd93 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -1,17 +1,20 @@ use crate::*; -use pallet_funding::{traits::VestingDurationCalculation, AcceptedFundingAsset, MigrationStatus, MultiplierOf, ProjectIdOf, RewardOrSlash, BidStatus, Multiplier, assert_close_enough}; +use pallet_funding::{ + assert_close_enough, traits::VestingDurationCalculation, AcceptedFundingAsset, BidStatus, MigrationStatus, + Multiplier, MultiplierOf, ProjectIdOf, RewardOrSlash, +}; use polimec_parachain_runtime::PolimecFunding; +use polimec_receiver::MigrationInfo; use sp_runtime::{FixedPointNumber, Perquintill}; use std::collections::HashMap; -use polimec_receiver::MigrationInfo; use tests::defaults::*; -fn calculate_total_ct_amount<'a>(migrations: impl Iterator) -> u128 { +fn calculate_total_ct_amount<'a>(migrations: impl Iterator) -> u128 { migrations.into_iter().map(|m| m.contribution_token_amount).sum() } fn execute_cleaner(inst: &mut IntegrationInstantiator) { - Polimec::execute_with(||{ + Polimec::execute_with(|| { inst.advance_time(::SuccessToSettlementTime::get() + 1u32).unwrap(); }); } @@ -50,7 +53,11 @@ fn send_migrations( let mut output = HashMap::new(); for account in accounts { let migrations = Polimec::execute_with(|| { - assert_ok!(PolimecFunding::migrate_one_participant(PolimecOrigin::signed(account.clone()), project_id, account.clone())); + assert_ok!(PolimecFunding::migrate_one_participant( + PolimecOrigin::signed(account.clone()), + project_id, + account.clone() + )); let (query_id, _migrations) = pallet_funding::UnconfirmedMigrations::::iter().next().unwrap(); @@ -61,34 +68,34 @@ fn send_migrations( let user_contributions = pallet_funding::Contributions::::iter_prefix_values((project_id, account.clone())); - let evaluation_migrations = user_evaluations - .map(|evaluation| { - assert_eq!(evaluation.ct_migration_status, MigrationStatus::Sent(query_id)); - if let Some(RewardOrSlash::Reward(amount)) = evaluation.rewarded_or_slashed { - MigrationInfo { - contribution_token_amount: amount, - vesting_time: Multiplier::new(1u8).unwrap().calculate_vesting_duration::().into() - } - } else { - panic!("should be rewarded") - } - }); - let bid_migrations = user_bids - .map(|bid| { - assert_eq!(bid.ct_migration_status, MigrationStatus::Sent(query_id)); - MigrationInfo { - contribution_token_amount: bid.final_ct_amount, - vesting_time: bid.multiplier.calculate_vesting_duration::().into() - } - }); - let contribution_ct_amount = user_contributions - .map(|contribution| { - assert_eq!(contribution.ct_migration_status, MigrationStatus::Sent(query_id)); + let evaluation_migrations = user_evaluations.map(|evaluation| { + assert_eq!(evaluation.ct_migration_status, MigrationStatus::Sent(query_id)); + if let Some(RewardOrSlash::Reward(amount)) = evaluation.rewarded_or_slashed { MigrationInfo { - contribution_token_amount: contribution.ct_amount, - vesting_time: contribution.multiplier.calculate_vesting_duration::().into() + contribution_token_amount: amount, + vesting_time: Multiplier::new(1u8) + .unwrap() + .calculate_vesting_duration::() + .into(), } - }); + } else { + panic!("should be rewarded") + } + }); + let bid_migrations = user_bids.map(|bid| { + assert_eq!(bid.ct_migration_status, MigrationStatus::Sent(query_id)); + MigrationInfo { + contribution_token_amount: bid.final_ct_amount, + vesting_time: bid.multiplier.calculate_vesting_duration::().into(), + } + }); + let contribution_ct_amount = user_contributions.map(|contribution| { + assert_eq!(contribution.ct_migration_status, MigrationStatus::Sent(query_id)); + MigrationInfo { + contribution_token_amount: contribution.ct_amount, + vesting_time: contribution.multiplier.calculate_vesting_duration::().into(), + } + }); evaluation_migrations.chain(bid_migrations).chain(contribution_ct_amount).collect::>() }); @@ -97,9 +104,8 @@ fn send_migrations( output } -fn migrations_are_executed(migrations: impl Iterator)>) { +fn migrations_are_executed(migrations: impl Iterator)>) { Penpal::execute_with(|| { - for (account, migrations) in migrations { let amount = calculate_total_ct_amount(migrations.iter()); @@ -121,13 +127,16 @@ fn migrations_are_confirmed_for(project_id: u32, accounts: Vec) { for account in accounts { let mut user_evaluations = pallet_funding::Evaluations::::iter_prefix_values((project_id, account.clone())); - let mut user_bids = pallet_funding::Bids::::iter_prefix_values((project_id, account.clone())); + let mut user_bids = + pallet_funding::Bids::::iter_prefix_values((project_id, account.clone())); let mut user_contributions = pallet_funding::Contributions::::iter_prefix_values((project_id, account.clone())); assert!(user_evaluations.all(|bid| bid.ct_migration_status == MigrationStatus::Confirmed)); assert!(user_bids.all(|bid| bid.ct_migration_status == MigrationStatus::Confirmed)); - assert!(user_contributions.all(|contribution| contribution.ct_migration_status == MigrationStatus::Confirmed)); + assert!( + user_contributions.all(|contribution| contribution.ct_migration_status == MigrationStatus::Confirmed) + ); assert_expected_events!( Polimec, @@ -200,7 +209,6 @@ fn migration_is_sent() { let penpal_sov_acc = PolkadotRelay::sovereign_account_id_of(Parachain(Penpal::para_id().into()).into()); PolkadotRelay::fund_accounts(vec![(penpal_sov_acc, 100_0_000_000_000u128)]); - mock_hrmp_establishment(project_id); assert_migration_is_ready(project_id); @@ -252,14 +260,12 @@ fn migration_is_executed_on_project_and_confirmed_on_polimec() { let migrations = send_migrations(project_id, vec![eval_1()]); let eval_1_migrations = migrations[&eval_1()].clone(); - migrations_are_confirmed_for(project_id, vec![eval_1()]); let eval_1_total_migrated_amount = calculate_total_ct_amount(eval_1_migrations.iter()); // Balance is there for the user after vesting (Multiplier 1, so no vesting) let post_migration_balance = Penpal::account_data_of(eval_1()); assert_eq!(post_migration_balance.free - pre_migration_balance.free, eval_1_total_migrated_amount); - } #[test] @@ -339,11 +345,17 @@ fn vesting_over_several_blocks_on_project() { let post_migration_balance = Penpal::account_data_of(buyer_1()); - assert_close_enough!(post_migration_balance.free - pre_migration_balance.free - post_migration_balance.frozen - pre_migration_balance.frozen, 10_250 * ASSET_UNIT, Perquintill::from_parts(10_000_000_000u64)); + assert_close_enough!( + post_migration_balance.free - + pre_migration_balance.free - + post_migration_balance.frozen - + pre_migration_balance.frozen, + 10_250 * ASSET_UNIT, + Perquintill::from_parts(10_000_000_000u64) + ); migrations_are_confirmed_for(project_id, vec![buyer_1()]); - Penpal::execute_with(|| { let unblock_time: u32 = multiplier_for_vesting.calculate_vesting_duration::(); PenpalSystem::set_block_number(unblock_time + 1u32); @@ -351,7 +363,11 @@ fn vesting_over_several_blocks_on_project() { }); let post_vest_balance = Penpal::account_data_of(buyer_1()); - assert_close_enough!(post_vest_balance.free - post_vest_balance.frozen, 10_250 * ASSET_UNIT + 2000 * ASSET_UNIT, Perquintill::from_parts(10_000_000_000u64)); + assert_close_enough!( + post_vest_balance.free - post_vest_balance.frozen, + 10_250 * ASSET_UNIT + 2000 * ASSET_UNIT, + Perquintill::from_parts(10_000_000_000u64) + ); } #[test] diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 7a2ccefab..42cbfc6a6 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -33,7 +33,7 @@ use sp_arithmetic::{ traits::{CheckedDiv, CheckedSub, Zero}, Percent, Perquintill, }; -use sp_runtime::traits::Convert; +use sp_runtime::traits::{Convert, ConvertBack}; use sp_std::marker::PhantomData; use xcm::v3::MaxDispatchErrorLen; @@ -41,6 +41,7 @@ use crate::ProjectStatus::FundingSuccessful; use polimec_traits::ReleaseSchedule; use crate::traits::{BondingRequirementCalculation, ProvideStatemintPrice, VestingDurationCalculation}; +use polimec_traits::migration_types::{MigrationInfo, MigrationOrigin}; use super::*; const POLIMEC_PARA_ID: u32 = 3344u32; @@ -2134,13 +2135,16 @@ impl Pallet { // * Process Data * // u128 is a balance, u64 is now a BlockNumber, but will be a Moment/Timestamp in the future - let mut migrations: Vec<(MigrationOriginOf, MigrationInfo)> = Vec::new(); + let mut migrations: Vec<(MigrationOrigin, MigrationInfo)> = Vec::new(); for evaluation in evaluations { if let Some(RewardOrSlash::Reward(ct_amount)) = evaluation.rewarded_or_slashed { let multiplier = MultiplierOf::::try_from(1u8).map_err(|_| Error::::BadConversion)?; let vesting_duration = multiplier.calculate_vesting_duration::(); let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); - let migration_origin = MigrationOrigin::Evaluation { user: evaluation.evaluator, id: evaluation.id }; + let migration_origin = MigrationOrigin::Evaluation { + user: ::AccountId32Conversion::convert(evaluation.evaluator), + id: evaluation.id, + }; let migration_info: MigrationInfo = (ct_amount.into(), vesting_duration_local_type.into()).into(); migrations.push((migration_origin, migration_info)); } @@ -2148,8 +2152,10 @@ impl Pallet { for contribution in contributions { let vesting_duration = contribution.multiplier.calculate_vesting_duration::(); let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); - let migration_origin = - MigrationOrigin::Contribution { user: contribution.contributor, id: contribution.id }; + let migration_origin = MigrationOrigin::Contribution { + user: ::AccountId32Conversion::convert(contribution.contributor), + id: contribution.id, + }; let migration_info: MigrationInfo = (contribution.ct_amount.into(), vesting_duration_local_type.into()).into(); migrations.push((migration_origin, migration_info)); @@ -2157,7 +2163,8 @@ impl Pallet { for bid in bids { let vesting_duration = bid.multiplier.calculate_vesting_duration::(); let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); - let migration_origin = MigrationOrigin::Bid { user: bid.bidder, id: bid.id }; + let migration_origin = + MigrationOrigin::Bid { user: ::AccountId32Conversion::convert(bid.bidder), id: bid.id }; let migration_info: MigrationInfo = (bid.final_ct_amount.into(), vesting_duration_local_type.into()).into(); migrations.push((migration_origin, migration_info)); } @@ -2777,8 +2784,8 @@ impl Pallet { pub fn construct_migration_xcm_messages( user: [u8; 32], - migrations: Vec<(MigrationOriginOf, MigrationInfo)>, - ) -> Vec<(BoundedVec, MaxMigrationsPerXcm>, Xcm<()>)> { + migrations: Vec<(MigrationOrigin, MigrationInfo)>, + ) -> Vec<(BoundedVec>, Xcm<()>)> { // TODO: adjust this as benchmarks for polimec-receiver are written const MAX_WEIGHT: Weight = Weight::from_parts(10_000, 0); @@ -2788,7 +2795,7 @@ impl Pallet { let mut output = Vec::new(); for migrations in migrations.chunks(MaxMigrationsPerXcm::::get() as usize) { - let (migration_origins, migration_infos): (Vec>, Vec) = + let (migration_origins, migration_infos): (Vec, Vec) = migrations.to_vec().into_iter().unzip(); let mut encoded_call = vec![51u8, 0]; encoded_call.extend_from_slice(user.encode().as_slice()); @@ -2816,25 +2823,31 @@ impl Pallet { for origin in migration_origins { match origin { MigrationOrigin::Evaluation { user, id } => { - Evaluations::::mutate((project_id, user, id), |maybe_evaluation| { - if let Some(evaluation) = maybe_evaluation { - evaluation.ct_migration_status = MigrationStatus::Sent(query_id); - } - }); + Evaluations::::mutate( + (project_id, T::AccountId32Conversion::convert_back(user), id), + |maybe_evaluation| { + if let Some(evaluation) = maybe_evaluation { + evaluation.ct_migration_status = MigrationStatus::Sent(query_id); + } + }, + ); }, MigrationOrigin::Bid { user, id } => { - Bids::::mutate((project_id, user, id), |maybe_bid| { + Bids::::mutate((project_id, T::AccountId32Conversion::convert_back(user), id), |maybe_bid| { if let Some(bid) = maybe_bid { bid.ct_migration_status = MigrationStatus::Sent(query_id); } }); }, MigrationOrigin::Contribution { user, id } => { - Contributions::::mutate((project_id, user, id), |maybe_contribution| { - if let Some(contribution) = maybe_contribution { - contribution.ct_migration_status = MigrationStatus::Sent(query_id); - } - }); + Contributions::::mutate( + (project_id, T::AccountId32Conversion::convert_back(user), id), + |maybe_contribution| { + if let Some(contribution) = maybe_contribution { + contribution.ct_migration_status = MigrationStatus::Sent(query_id); + } + }, + ); }, } } @@ -2846,25 +2859,31 @@ impl Pallet { for origin in migration_origins { match origin { MigrationOrigin::Evaluation { user, id } => { - Evaluations::::mutate((project_id, user, id), |maybe_evaluation| { - if let Some(evaluation) = maybe_evaluation { - evaluation.ct_migration_status = MigrationStatus::Confirmed; - } - }); + Evaluations::::mutate( + (project_id, T::AccountId32Conversion::convert_back(user), id), + |maybe_evaluation| { + if let Some(evaluation) = maybe_evaluation { + evaluation.ct_migration_status = MigrationStatus::Confirmed; + } + }, + ); }, MigrationOrigin::Bid { user, id } => { - Bids::::mutate((project_id, user, id), |maybe_bid| { + Bids::::mutate((project_id, T::AccountId32Conversion::convert_back(user), id), |maybe_bid| { if let Some(bid) = maybe_bid { bid.ct_migration_status = MigrationStatus::Confirmed; } }); }, MigrationOrigin::Contribution { user, id } => { - Contributions::::mutate((project_id, user, id), |maybe_contribution| { - if let Some(contribution) = maybe_contribution { - contribution.ct_migration_status = MigrationStatus::Confirmed; - } - }); + Contributions::::mutate( + (project_id, T::AccountId32Conversion::convert_back(user), id), + |maybe_contribution| { + if let Some(contribution) = maybe_contribution { + contribution.ct_migration_status = MigrationStatus::Confirmed; + } + }, + ); }, } } @@ -2879,25 +2898,31 @@ impl Pallet { for origin in migration_origins { match origin { MigrationOrigin::Evaluation { user, id } => { - Evaluations::::mutate((project_id, user, id), |maybe_evaluation| { - if let Some(evaluation) = maybe_evaluation { - evaluation.ct_migration_status = MigrationStatus::Failed(error.clone()); - } - }); + Evaluations::::mutate( + (project_id, T::AccountId32Conversion::convert_back(user), id), + |maybe_evaluation| { + if let Some(evaluation) = maybe_evaluation { + evaluation.ct_migration_status = MigrationStatus::Failed(error.clone()); + } + }, + ); }, MigrationOrigin::Bid { user, id } => { - Bids::::mutate((project_id, user, id), |maybe_bid| { + Bids::::mutate((project_id, T::AccountId32Conversion::convert_back(user), id), |maybe_bid| { if let Some(bid) = maybe_bid { bid.ct_migration_status = MigrationStatus::Failed(error.clone()); } }); }, MigrationOrigin::Contribution { user, id } => { - Contributions::::mutate((project_id, user, id), |maybe_contribution| { - if let Some(contribution) = maybe_contribution { - contribution.ct_migration_status = MigrationStatus::Failed(error.clone()); - } - }); + Contributions::::mutate( + (project_id, T::AccountId32Conversion::convert_back(user), id), + |maybe_contribution| { + if let Some(contribution) = maybe_contribution { + contribution.ct_migration_status = MigrationStatus::Failed(error.clone()); + } + }, + ); }, } } diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 1befdacda..06420c268 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -180,6 +180,7 @@ use frame_support::{ BoundedVec, PalletId, }; pub use pallet::*; +use polimec_traits::migration_types::{MigrationInfo, MigrationOrigin}; use polkadot_parachain::primitives::Id as ParaId; use sp_arithmetic::traits::{One, Saturating}; use sp_runtime::{traits::AccountIdConversion, FixedPointNumber, FixedPointOperand, FixedU128}; @@ -228,7 +229,6 @@ pub type EvaluationRoundInfoOf = EvaluationRoundInfo>; pub type VestingInfoOf = VestingInfo, BalanceOf>; pub type EvaluationInfoOf = EvaluationInfo, AccountIdOf, BalanceOf, BlockNumberOf>; pub type BidInfoOf = BidInfo< - u32, ProjectIdOf, BalanceOf, PriceOf, @@ -240,9 +240,8 @@ pub type BidInfoOf = BidInfo< pub type ContributionInfoOf = ContributionInfo, AccountIdOf, BalanceOf, MultiplierOf, VestingInfoOf>; -pub type MigrationOriginOf = MigrationOrigin, u32>; pub type ProjectMigrationOriginsOf = - ProjectMigrationOrigins, BoundedVec, MaxMigrationsPerXcm>>; + ProjectMigrationOrigins, BoundedVec>>; pub type BucketOf = Bucket, PriceOf>; pub type BondTypeOf = LockType>; @@ -255,7 +254,7 @@ pub mod pallet { use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; use sp_arithmetic::Percent; - use sp_runtime::traits::Convert; + use sp_runtime::traits::{Convert, ConvertBack}; use local_macros::*; @@ -286,7 +285,7 @@ pub mod pallet { // TODO: our local BlockNumber should be removed once we move onto using Moment for time tracking type BlockNumber: IsType<::BlockNumber> + Into; - type AccountId32Conversion: Convert; + type AccountId32Conversion: ConvertBack; type RuntimeOrigin: IsType<::RuntimeOrigin> + Into::RuntimeOrigin>>; diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index ed4c276b2..d1e00b0c0 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -239,7 +239,6 @@ pub mod storage_types { #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] pub struct BidInfo< - Id, ProjectId, Balance: BalanceT, Price: FixedPointNumber, @@ -248,7 +247,7 @@ pub mod storage_types { Multiplier, VestingInfo, > { - pub id: Id, + pub id: u32, pub project_id: ProjectId, pub bidder: AccountId, pub status: BidStatus, @@ -269,7 +268,6 @@ pub mod storage_types { } impl< - BidId: Eq + Ord, ProjectId: Eq, Balance: BalanceT + FixedPointOperand + Ord, Price: FixedPointNumber, @@ -277,7 +275,7 @@ pub mod storage_types { BlockNumber: Eq + Ord, Multiplier: Eq, VestingInfo: Eq, - > Ord for BidInfo + > Ord for BidInfo { fn cmp(&self, other: &Self) -> sp_std::cmp::Ordering { match self.original_ct_usd_price.cmp(&other.original_ct_usd_price) { @@ -288,7 +286,6 @@ pub mod storage_types { } impl< - BidId: Eq + Ord, ProjectId: Eq, Balance: BalanceT + FixedPointOperand, Price: FixedPointNumber, @@ -296,7 +293,7 @@ pub mod storage_types { BlockNumber: Eq + Ord, Multiplier: Eq, VestingInfo: Eq, - > PartialOrd for BidInfo + > PartialOrd for BidInfo { fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) @@ -722,30 +719,11 @@ pub mod inner_types { AwaitingAcceptance, } - #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] - pub enum MigrationOrigin { - Evaluation { user: AccountId, id: Id }, - Bid { user: AccountId, id: Id }, - Contribution { user: AccountId, id: Id }, - } - #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct ProjectMigrationOrigins { pub project_id: ProjectId, pub migration_origins: MigrationOrigins, } - - #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] - pub struct MigrationInfo { - contribution_token_amount: u128, - vesting_time: u64, - } - impl From<(u128, u64)> for MigrationInfo { - fn from((contribution_token_amount, vesting_time): (u128, u64)) -> Self { - Self { contribution_token_amount, vesting_time } - } - } - #[derive(Clone, Encode, Decode, Eq, PartialEq, Ord, PartialOrd, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub enum MigrationStatus { NotStarted, diff --git a/pallets/polimec-receiver/src/lib.rs b/pallets/polimec-receiver/src/lib.rs index 7b88718fb..f5f58e26b 100644 --- a/pallets/polimec-receiver/src/lib.rs +++ b/pallets/polimec-receiver/src/lib.rs @@ -110,4 +110,3 @@ pub struct MigrationInfo { pub contribution_token_amount: u128, pub vesting_time: u64, } - diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index acaa1f271..637cbe8f2 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -51,6 +51,7 @@ use sp_runtime::{ ApplyExtrinsicResult, }; pub use sp_runtime::{FixedU128, MultiAddress, Perbill, Permill}; +use sp_runtime::traits::{Convert, ConvertBack, Identity}; use sp_std::prelude::*; #[cfg(feature = "std")] @@ -542,8 +543,19 @@ parameter_types! { pub RequiredMaxCapacity: u32 = 20; pub RequiredMaxMessageSize: u32 = 102_400; } +pub struct ConvertSelf; +impl Convert for ConvertSelf { + fn convert(account_id: AccountId) -> [u8;32] { + account_id.into() + } +} +impl ConvertBack for ConvertSelf { + fn convert_back(bytes: [u8; 32]) -> AccountId { + bytes.into() + } +} impl pallet_funding::Config for Runtime { - type AccountId32Conversion = ConvertInto; + type AccountId32Conversion = ConvertSelf; type AllPalletsWithoutSystem = (Balances, LocalAssets, StatemintAssets, PolimecFunding, LinearVesting, Random); type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; type Balance = Balance; diff --git a/traits/src/lib.rs b/traits/src/lib.rs index 67c437d59..0bf93b225 100644 --- a/traits/src/lib.rs +++ b/traits/src/lib.rs @@ -16,7 +16,8 @@ #![cfg_attr(not(feature = "std"), no_std)] -use frame_support::{pallet_prelude::*, traits::tokens::fungible}; +use frame_support::{pallet_prelude::*, traits::tokens::fungible, RuntimeDebug}; +use sp_std::prelude::*; /// A release schedule over a fungible. This allows a particular fungible to have release limits /// applied to it. @@ -95,3 +96,32 @@ pub trait ReleaseSchedule { fn remove_all_vesting_schedules(who: &AccountId, reason: Reason) -> DispatchResult; } + +pub mod migration_types { + use super::*; + + #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] + pub enum MigrationOrigin { + Evaluation { user: [u8; 32], id: u32 }, + Bid { user: [u8; 32], id: u32 }, + Contribution { user: [u8; 32], id: u32 }, + } + + #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] + pub struct MigrationInfo { + contribution_token_amount: u128, + vesting_time: u64, + } + impl From<(u128, u64)> for MigrationInfo { + fn from((contribution_token_amount, vesting_time): (u128, u64)) -> Self { + Self { contribution_token_amount, vesting_time } + } + } + + pub struct Migration { + origin: MigrationOrigin, + info: MigrationInfo + } + + pub struct Migrations(Vec); +} From 6b03214d6b48b2bc91e42402848f712b5dee60aa Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 30 Nov 2023 10:36:30 +0100 Subject: [PATCH 050/212] using generate_accounts! macro in all integration tests --- Cargo.lock | 2 + integration-tests/Cargo.toml | 1 + integration-tests/penpal/Cargo.toml | 1 + integration-tests/penpal/src/lib.rs | 4 +- integration-tests/src/tests/ct_migration.rs | 106 ++++++++++++-------- integration-tests/src/tests/defaults.rs | 91 ++++++++--------- integration-tests/src/tests/e2e.rs | 18 ++-- integration-tests/src/tests/oracle.rs | 12 +-- pallets/funding/src/functions.rs | 69 +++++++------ pallets/polimec-receiver/src/lib.rs | 54 +++++----- runtimes/testnet/src/lib.rs | 7 +- traits/src/lib.rs | 55 ++++++++-- 12 files changed, 247 insertions(+), 173 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ea5b10fd6..ef57967ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4166,6 +4166,7 @@ dependencies = [ "penpal-runtime", "polimec-parachain-runtime", "polimec-receiver", + "polimec-traits", "polkadot-core-primitives", "polkadot-parachain", "polkadot-primitives", @@ -7454,6 +7455,7 @@ dependencies = [ "parachains-common", "parity-scale-codec", "polimec-receiver", + "polimec-traits", "polkadot-parachain", "polkadot-primitives", "polkadot-runtime-common", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 84242610d..cd93f155b 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -20,6 +20,7 @@ scale-info = { workspace = true, features = ["derive"] } # Local polimec-receiver.workspace = true macros.workspace = true +polimec-traits.workspace = true sp-arithmetic.workspace = true frame-system.workspace = true diff --git a/integration-tests/penpal/Cargo.toml b/integration-tests/penpal/Cargo.toml index 4ee7b3408..1b71a092a 100644 --- a/integration-tests/penpal/Cargo.toml +++ b/integration-tests/penpal/Cargo.toml @@ -23,6 +23,7 @@ smallvec = "1.10.0" # Local polimec-receiver.workspace = true +polimec-traits.workspace = true # Substrate frame-benchmarking = { workspace = true, optional = true } diff --git a/integration-tests/penpal/src/lib.rs b/integration-tests/penpal/src/lib.rs index 153840e45..6eb5349cc 100644 --- a/integration-tests/penpal/src/lib.rs +++ b/integration-tests/penpal/src/lib.rs @@ -48,6 +48,7 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, EnsureSigned, }; +use polimec_traits::migration_types::MigrationInfo; use smallvec::smallvec; use sp_api::impl_runtime_apis; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; @@ -76,7 +77,6 @@ use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}; // XCM Imports use frame_support::traits::WithdrawReasons; use parachains_common::{AccountId, Signature}; -use polimec_receiver::MigrationInfo; use sp_runtime::traits::Convert; use xcm::latest::prelude::BodyId; use xcm_executor::XcmExecutor; @@ -584,11 +584,13 @@ impl Convert for DivideBalanceByBlocks { parameter_types! { pub PolimecParaId: ParaId = 3344u32.into(); pub GenesisMoment: BlockNumber = 0u32; + pub const MaxMigrations: u128 = 100000; } impl polimec_receiver::Config for Runtime { type Balance = Balance; type Balances = Balances; type GenesisMoment = GenesisMoment; + type MaxMigrations = MaxMigrations; type MigrationInfoToPerBlockBalance = DivideBalanceByBlocks; type PolimecParaId = PolimecParaId; type RuntimeEvent = RuntimeEvent; diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index 4d073fd93..5750f58a5 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -4,7 +4,7 @@ use pallet_funding::{ Multiplier, MultiplierOf, ProjectIdOf, RewardOrSlash, }; use polimec_parachain_runtime::PolimecFunding; -use polimec_receiver::MigrationInfo; +use polimec_traits::migration_types::MigrationInfo; use sp_runtime::{FixedPointNumber, Perquintill}; use std::collections::HashMap; use tests::defaults::*; @@ -20,7 +20,7 @@ fn execute_cleaner(inst: &mut IntegrationInstantiator) { } fn mock_hrmp_establishment(project_id: u32) { Polimec::execute_with(|| { - assert_ok!(PolimecFunding::do_set_para_id_for_project(&issuer(), project_id, ParaId::from(6969u32))); + assert_ok!(PolimecFunding::do_set_para_id_for_project(&ISSUER.into(), project_id, ParaId::from(6969u32))); let open_channel_message = xcm::v3::opaque::Instruction::HrmpNewChannelOpenRequest { sender: 6969, @@ -112,9 +112,17 @@ fn migrations_are_executed(migrations: impl Iterator { - user: *user == account, - migrations: migrations.into_iter().map(|m|m.contribution_token_amount).sum::() == amount, + PenpalEvent::PolimecReceiver(polimec_receiver::Event::MigrationsExecuted{migrations}) => { + migrations: { + let origins = migrations.origins(); + let infos = migrations.infos(); + let mut migrations_come_from_same_user = origins.into_iter().map(|origin| { + let account: [u8; 32] = account.clone().into(); + origin.user == account + }); + migrations_come_from_same_user.all(|x|x) && + infos.into_iter().map(|info| info.contribution_token_amount).sum::() == amount + }, }, ] ); @@ -156,8 +164,8 @@ fn migration_check() { set_oracle_prices(); let project_id = Polimec::execute_with(|| { let project_id = inst.create_finished_project( - default_project(issuer(), 0), - issuer(), + default_project(ISSUER.into(), 0), + ISSUER.into(), default_evaluations(), default_bids(), default_community_contributions(), @@ -180,26 +188,26 @@ fn migration_is_sent() { let project_id = Polimec::execute_with(|| { inst.create_finished_project( - default_project(issuer(), 0), - issuer(), + default_project(ISSUER.into(), 0), + ISSUER.into(), vec![ - UserToUSDBalance::new(eval_1(), 50_000 * PLMC), - UserToUSDBalance::new(eval_2(), 25_000 * PLMC), - UserToUSDBalance::new(eval_3(), 32_000 * PLMC), + UserToUSDBalance::new(EVAL_1.into(), 50_000 * PLMC), + UserToUSDBalance::new(EVAL_2.into(), 25_000 * PLMC), + UserToUSDBalance::new(EVAL_3.into(), 32_000 * PLMC), ], IntegrationInstantiator::generate_bids_from_total_usd( Perquintill::from_percent(40) * (sp_runtime::FixedU128::from_float(1.0).checked_mul_int(100_000 * ASSET_UNIT).unwrap()), sp_runtime::FixedU128::from_float(1.0), default_weights(), - vec![eval_1(), bidder_2(), bidder_3(), bidder_4(), bidder_5()], + vec![EVAL_1.into(), BIDDER_1.into(), BIDDER_2.into(), BIDDER_3.into(), BIDDER_4.into()], ), IntegrationInstantiator::generate_contributions_from_total_usd( Perquintill::from_percent(50) * (sp_runtime::FixedU128::from_float(1.0).checked_mul_int(100_000 * ASSET_UNIT).unwrap()), sp_runtime::FixedU128::from_float(1.0), default_weights(), - vec![eval_1(), buyer_2(), buyer_3(), buyer_4(), buyer_5()], + vec![EVAL_1.into(), BUYER_1.into(), BUYER_2.into(), BUYER_3.into(), BUYER_4.into()], ), vec![], ) @@ -213,7 +221,7 @@ fn migration_is_sent() { assert_migration_is_ready(project_id); - send_migrations(project_id, vec![eval_1()]); + send_migrations(project_id, vec![EVAL_1.into()]); } #[test] @@ -223,26 +231,26 @@ fn migration_is_executed_on_project_and_confirmed_on_polimec() { let project_id = Polimec::execute_with(|| { inst.create_finished_project( - default_project(issuer(), 0), - issuer(), + default_project(ISSUER.into(), 0), + ISSUER.into(), vec![ - UserToUSDBalance::new(eval_1(), 50_000 * PLMC), - UserToUSDBalance::new(eval_2(), 25_000 * PLMC), - UserToUSDBalance::new(eval_3(), 32_000 * PLMC), + UserToUSDBalance::new(EVAL_1.into(), 50_000 * PLMC), + UserToUSDBalance::new(EVAL_2.into(), 25_000 * PLMC), + UserToUSDBalance::new(EVAL_3.into(), 32_000 * PLMC), ], IntegrationInstantiator::generate_bids_from_total_usd( Perquintill::from_percent(40) * (sp_runtime::FixedU128::from_float(1.0).checked_mul_int(100_000 * ASSET_UNIT).unwrap()), sp_runtime::FixedU128::from_float(1.0), default_weights(), - vec![eval_1(), bidder_2(), bidder_3(), bidder_4(), bidder_5()], + vec![EVAL_1.into(), BIDDER_2.into(), BIDDER_3.into(), BIDDER_4.into(), BIDDER_5.into()], ), IntegrationInstantiator::generate_contributions_from_total_usd( Perquintill::from_percent(50) * (sp_runtime::FixedU128::from_float(1.0).checked_mul_int(100_000 * ASSET_UNIT).unwrap()), sp_runtime::FixedU128::from_float(1.0), default_weights(), - vec![eval_1(), buyer_2(), buyer_3(), buyer_4(), buyer_5()], + vec![EVAL_1.into(), BUYER_2.into(), BUYER_3.into(), BUYER_4.into(), BUYER_5.into()], ), vec![], ) @@ -255,16 +263,16 @@ fn migration_is_executed_on_project_and_confirmed_on_polimec() { assert_migration_is_ready(project_id); - let pre_migration_balance = Penpal::account_data_of(eval_1()); + let pre_migration_balance = Penpal::account_data_of(EVAL_1.into()); - let migrations = send_migrations(project_id, vec![eval_1()]); - let eval_1_migrations = migrations[&eval_1()].clone(); + let migrations = send_migrations(project_id, vec![EVAL_1.into()]); + let eval_1_migrations = migrations[&EVAL_1.into()].clone(); - migrations_are_confirmed_for(project_id, vec![eval_1()]); + migrations_are_confirmed_for(project_id, vec![EVAL_1.into()]); let eval_1_total_migrated_amount = calculate_total_ct_amount(eval_1_migrations.iter()); // Balance is there for the user after vesting (Multiplier 1, so no vesting) - let post_migration_balance = Penpal::account_data_of(eval_1()); + let post_migration_balance = Penpal::account_data_of(EVAL_1.into()); assert_eq!(post_migration_balance.free - pre_migration_balance.free, eval_1_total_migrated_amount); } @@ -278,21 +286,21 @@ fn vesting_over_several_blocks_on_project() { let multiplier_for_vesting = MultiplierOf::::try_from(10u8).unwrap(); bids.push(BidParams { - bidder: buyer_1(), + bidder: BUYER_1.into(), amount: 2_000 * ASSET_UNIT, price: 12u128.into(), multiplier: MultiplierOf::::try_from(10u8).unwrap(), asset: AcceptedFundingAsset::USDT, }); bids.push(BidParams { - bidder: bidder_1(), + bidder: BIDDER_1.into(), amount: 20_000 * ASSET_UNIT, price: 10u128.into(), multiplier: multiplier_for_vesting, asset: AcceptedFundingAsset::USDT, }); bids.push(BidParams { - bidder: bidder_2(), + bidder: BIDDER_2.into(), amount: 12_000 * ASSET_UNIT, price: 11u128.into(), multiplier: MultiplierOf::::try_from(10u8).unwrap(), @@ -300,19 +308,19 @@ fn vesting_over_several_blocks_on_project() { }); contributions.push(ContributionParams { - contributor: buyer_1(), + contributor: BUYER_1.into(), amount: 10_250 * ASSET_UNIT, multiplier: MultiplierOf::::try_from(1u8).unwrap(), asset: AcceptedFundingAsset::USDT, }); contributions.push(ContributionParams { - contributor: buyer_2(), + contributor: BUYER_2.into(), amount: 5000 * ASSET_UNIT, multiplier: MultiplierOf::::try_from(1u8).unwrap(), asset: AcceptedFundingAsset::USDT, }); contributions.push(ContributionParams { - contributor: buyer_3(), + contributor: BUYER_3.into(), amount: 30000 * ASSET_UNIT, multiplier: MultiplierOf::::try_from(1u8).unwrap(), asset: AcceptedFundingAsset::USDT, @@ -320,8 +328,8 @@ fn vesting_over_several_blocks_on_project() { let project_id = Polimec::execute_with(|| { inst.create_finished_project( - default_project(issuer(), 0), - issuer(), + default_project(ISSUER.into(), 0), + ISSUER.into(), default_evaluations(), bids, contributions, @@ -336,14 +344,14 @@ fn vesting_over_several_blocks_on_project() { assert_migration_is_ready(project_id); - let pre_migration_balance = Penpal::account_data_of(buyer_1()); + let pre_migration_balance = Penpal::account_data_of(BUYER_1.into()); // Migrate is sent - let migrations_sent = send_migrations(project_id, vec![buyer_1()]); + let migrations_sent = send_migrations(project_id, vec![BUYER_1.into()]); migrations_are_executed(migrations_sent.into_iter()); - let post_migration_balance = Penpal::account_data_of(buyer_1()); + let post_migration_balance = Penpal::account_data_of(BUYER_1.into()); assert_close_enough!( post_migration_balance.free - @@ -354,15 +362,15 @@ fn vesting_over_several_blocks_on_project() { Perquintill::from_parts(10_000_000_000u64) ); - migrations_are_confirmed_for(project_id, vec![buyer_1()]); + migrations_are_confirmed_for(project_id, vec![BUYER_1.into()]); Penpal::execute_with(|| { let unblock_time: u32 = multiplier_for_vesting.calculate_vesting_duration::(); PenpalSystem::set_block_number(unblock_time + 1u32); - assert_ok!(pallet_vesting::Pallet::::vest(PenpalOrigin::signed(buyer_1()))); + assert_ok!(pallet_vesting::Pallet::::vest(PenpalOrigin::signed(BUYER_1.into()))); }); - let post_vest_balance = Penpal::account_data_of(buyer_1()); + let post_vest_balance = Penpal::account_data_of(BUYER_1.into()); assert_close_enough!( post_vest_balance.free - post_vest_balance.frozen, 10_250 * ASSET_UNIT + 2000 * ASSET_UNIT, @@ -371,4 +379,18 @@ fn vesting_over_several_blocks_on_project() { } #[test] -fn disallow_duplicated_migrations_on_receiver_pallet() {} +fn disallow_duplicated_migrations_on_receiver_pallet() { + let mut inst = IntegrationInstantiator::new(None); + set_oracle_prices(); + + let project_id = Polimec::execute_with(|| { + inst.create_finished_project( + default_project(ISSUER.into(), 0), + ISSUER.into(), + default_evaluations(), + default_bids(), + default_community_contributions(), + default_remainder_contributions(), + ) + }); +} diff --git a/integration-tests/src/tests/defaults.rs b/integration-tests/src/tests/defaults.rs index ee52c70b7..7befe8f4e 100644 --- a/integration-tests/src/tests/defaults.rs +++ b/integration-tests/src/tests/defaults.rs @@ -11,6 +11,7 @@ use crate::PolimecOrigin; use polimec_parachain_runtime::AccountId; use sp_runtime::{traits::ConstU32, FixedPointNumber, Perquintill}; use xcm_emulator::TestExt; +use macros::generate_accounts; pub const METADATA: &str = r#"METADATA { @@ -31,48 +32,25 @@ pub type IntegrationInstantiator = pallet_funding::instantiator::Instantiator< pub fn hashed(data: impl AsRef<[u8]>) -> sp_core::H256 { ::hash(data.as_ref()) } -pub fn issuer() -> AccountId { - Polimec::account_id_of("issuer") -} -pub fn eval_1() -> AccountId { - Polimec::account_id_of("eval_1") -} -pub fn eval_2() -> AccountId { - Polimec::account_id_of("eval_2") -} -pub fn eval_3() -> AccountId { - Polimec::account_id_of("eval_3") -} -pub fn bidder_1() -> AccountId { - Polimec::account_id_of("bidder_1") -} -pub fn bidder_2() -> AccountId { - Polimec::account_id_of("bidder_2") -} -pub fn bidder_3() -> AccountId { - Polimec::account_id_of("bidder_3") -} -pub fn bidder_4() -> AccountId { - Polimec::account_id_of("bidder_4") -} -pub fn bidder_5() -> AccountId { - Polimec::account_id_of("bidder_5") -} -pub fn buyer_1() -> AccountId { - Polimec::account_id_of("buyer_1") -} -pub fn buyer_2() -> AccountId { - Polimec::account_id_of("buyer_2") -} -pub fn buyer_3() -> AccountId { - Polimec::account_id_of("buyer_3") -} -pub fn buyer_4() -> AccountId { - Polimec::account_id_of("buyer_4") -} -pub fn buyer_5() -> AccountId { - Polimec::account_id_of("buyer_5") -} + +generate_accounts!( + ISSUER, + EVAL_1, + EVAL_2, + EVAL_3, + BIDDER_1, + BIDDER_2, + BIDDER_3, + BIDDER_4, + BIDDER_5, + BUYER_1, + BUYER_2, + BUYER_3, + BUYER_4, + BUYER_5, +); + + pub fn bounded_name() -> BoundedVec> { BoundedVec::try_from("Contribution Token TEST".as_bytes().to_vec()).unwrap() } @@ -107,13 +85,13 @@ pub fn default_project(issuer: AccountId, nonce: u32) -> ProjectMetadataOf Vec> { vec![ - UserToUSDBalance::new(eval_1(), 50_000 * PLMC), - UserToUSDBalance::new(eval_2(), 25_000 * PLMC), - UserToUSDBalance::new(eval_3(), 32_000 * PLMC), + UserToUSDBalance::new(EVAL_1.into(), 50_000 * PLMC), + UserToUSDBalance::new(EVAL_2.into(), 25_000 * PLMC), + UserToUSDBalance::new(EVAL_3.into(), 32_000 * PLMC), ] } pub fn default_bidders() -> Vec { - vec![bidder_1(), bidder_2(), bidder_3(), bidder_4(), bidder_5()] + vec![BIDDER_1.into(), BIDDER_2.into(), BIDDER_3.into(), BIDDER_4.into(), BIDDER_5.into()] } pub fn default_bids() -> Vec> { @@ -134,11 +112,26 @@ pub fn default_community_contributions() -> Vec Vec { - vec![buyer_1(), buyer_2(), buyer_3(), buyer_4(), buyer_5()] + +pub fn default_remainder_contributions() -> Vec> { + let fifty_percent_funding_usd = Perquintill::from_percent(5) * 100_000 * ASSET_UNIT; + + IntegrationInstantiator::generate_contributions_from_total_usd( + fifty_percent_funding_usd, + sp_runtime::FixedU128::from_float(1.0), + default_weights(), + default_remainder_contributors(), + ) +} +pub fn default_community_contributors() -> Vec { + vec![BUYER_1.into(), BUYER_2.into(), BUYER_3.into(), BUYER_4.into(), BUYER_5.into()] +} + +pub fn default_remainder_contributors() -> Vec { + vec![BUYER_1.into(), BUYER_2.into(), BUYER_3.into(), BUYER_4.into(), BUYER_5.into()] } use crate::{Polimec, PolimecRuntime, ALICE, BOB, CHARLIE}; diff --git a/integration-tests/src/tests/e2e.rs b/integration-tests/src/tests/e2e.rs index 57eeab692..c9a4e1f74 100644 --- a/integration-tests/src/tests/e2e.rs +++ b/integration-tests/src/tests/e2e.rs @@ -35,7 +35,7 @@ pub fn excel_project(nonce: u64) -> ProjectMetadataOf { funding_thresholds: Default::default(), conversion_rate: 1, participation_currencies: AcceptedFundingAsset::USDT, - funding_destination_account: issuer(), + funding_destination_account: ISSUER.into(), offchain_information_hash: Some(metadata_hash), } } @@ -242,7 +242,7 @@ fn excel_ct_amounts() -> UserToCTBalance { fn evaluation_round_completed() { let mut inst = IntegrationInstantiator::new(None); - let issuer = issuer(); + let issuer = ISSUER.into(); let project = excel_project(inst.get_new_nonce()); let evaluations = excel_evaluators(); set_oracle_prices(); @@ -256,7 +256,7 @@ fn evaluation_round_completed() { fn auction_round_completed() { let mut inst = IntegrationInstantiator::new(None); - let issuer = issuer(); + let issuer = ISSUER.into(); let project = excel_project(inst.get_new_nonce()); let evaluations = excel_evaluators(); let bids = excel_bidders(); @@ -297,7 +297,7 @@ fn community_round_completed() { Polimec::execute_with(|| { let _ = inst.create_remainder_contributing_project( excel_project(0), - issuer(), + ISSUER.into(), excel_evaluators(), excel_bidders(), excel_contributions(), @@ -332,7 +332,7 @@ fn remainder_round_completed() { Polimec::execute_with(|| { let project_id = inst.create_finished_project( excel_project(0), - issuer(), + ISSUER.into(), excel_evaluators(), excel_bidders(), excel_contributions(), @@ -378,7 +378,7 @@ fn funds_raised() { Polimec::execute_with(|| { let project_id = inst.create_finished_project( excel_project(0), - issuer(), + ISSUER.into(), excel_evaluators(), excel_bidders(), excel_contributions(), @@ -407,7 +407,7 @@ fn ct_minted() { Polimec::execute_with(|| { let _ = inst.create_finished_project( excel_project(0), - issuer(), + ISSUER.into(), excel_evaluators(), excel_bidders(), excel_contributions(), @@ -433,7 +433,7 @@ fn ct_migrated() { let project_id = Polimec::execute_with(|| { let project_id = inst.create_finished_project( excel_project(0), - issuer(), + ISSUER.into(), excel_evaluators(), excel_bidders(), excel_contributions(), @@ -457,7 +457,7 @@ fn ct_migrated() { // Mock HRMP establishment Polimec::execute_with(|| { - assert_ok!(PolimecFunding::do_set_para_id_for_project(&issuer(), project_id, ParaId::from(6969u32))); + assert_ok!(PolimecFunding::do_set_para_id_for_project(&ISSUER.into(), project_id, ParaId::from(6969u32))); let open_channel_message = xcm::v3::opaque::Instruction::HrmpNewChannelOpenRequest { sender: 6969, diff --git a/integration-tests/src/tests/oracle.rs b/integration-tests/src/tests/oracle.rs index 1c9ee7603..b4a4fe1e6 100644 --- a/integration-tests/src/tests/oracle.rs +++ b/integration-tests/src/tests/oracle.rs @@ -101,12 +101,12 @@ fn pallet_funding_works() { assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(charlie.clone()), values([4.84, 1.0, 1.0, 0.4]))); let _project_id = inst.create_finished_project( - default_project(issuer(), 0), - issuer(), - default_evaluations(), - default_bids(), - default_community_contributions(), - vec![], + default_project(ISSUER.into(), 0), + ISSUER.into(), + default_evaluations(), + default_bids(), + default_community_contributions(), + vec![], ); }); } diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 42cbfc6a6..c6c814e94 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -29,6 +29,7 @@ use frame_support::{ Get, }, }; +use itertools::Itertools; use sp_arithmetic::{ traits::{CheckedDiv, CheckedSub, Zero}, Percent, Perquintill, @@ -41,7 +42,7 @@ use crate::ProjectStatus::FundingSuccessful; use polimec_traits::ReleaseSchedule; use crate::traits::{BondingRequirementCalculation, ProvideStatemintPrice, VestingDurationCalculation}; -use polimec_traits::migration_types::{MigrationInfo, MigrationOrigin}; +use polimec_traits::migration_types::{Migration, MigrationInfo, MigrationOrigin, Migrations, ParticipationType}; use super::*; const POLIMEC_PARA_ID: u32 = 3344u32; @@ -2135,38 +2136,43 @@ impl Pallet { // * Process Data * // u128 is a balance, u64 is now a BlockNumber, but will be a Moment/Timestamp in the future - let mut migrations: Vec<(MigrationOrigin, MigrationInfo)> = Vec::new(); + let mut migrations: Migrations = Migrations::new(); for evaluation in evaluations { if let Some(RewardOrSlash::Reward(ct_amount)) = evaluation.rewarded_or_slashed { let multiplier = MultiplierOf::::try_from(1u8).map_err(|_| Error::::BadConversion)?; let vesting_duration = multiplier.calculate_vesting_duration::(); let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); - let migration_origin = MigrationOrigin::Evaluation { + let migration_origin = MigrationOrigin { user: ::AccountId32Conversion::convert(evaluation.evaluator), id: evaluation.id, + participation_type: ParticipationType::Evaluation, }; let migration_info: MigrationInfo = (ct_amount.into(), vesting_duration_local_type.into()).into(); - migrations.push((migration_origin, migration_info)); + migrations.push(Migration::new(migration_origin, migration_info)); } } for contribution in contributions { let vesting_duration = contribution.multiplier.calculate_vesting_duration::(); let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); - let migration_origin = MigrationOrigin::Contribution { + let migration_origin = MigrationOrigin { user: ::AccountId32Conversion::convert(contribution.contributor), id: contribution.id, + participation_type: ParticipationType::Contribution, }; let migration_info: MigrationInfo = (contribution.ct_amount.into(), vesting_duration_local_type.into()).into(); - migrations.push((migration_origin, migration_info)); + migrations.push(Migration::new(migration_origin, migration_info)); } for bid in bids { let vesting_duration = bid.multiplier.calculate_vesting_duration::(); let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); - let migration_origin = - MigrationOrigin::Bid { user: ::AccountId32Conversion::convert(bid.bidder), id: bid.id }; + let migration_origin = MigrationOrigin { + user: ::AccountId32Conversion::convert(bid.bidder), + id: bid.id, + participation_type: ParticipationType::Bid, + }; let migration_info: MigrationInfo = (bid.final_ct_amount.into(), vesting_duration_local_type.into()).into(); - migrations.push((migration_origin, migration_info)); + migrations.push(Migration::new(migration_origin, migration_info)); } let constructed_migrations = @@ -2784,7 +2790,7 @@ impl Pallet { pub fn construct_migration_xcm_messages( user: [u8; 32], - migrations: Vec<(MigrationOrigin, MigrationInfo)>, + migrations: Migrations, ) -> Vec<(BoundedVec>, Xcm<()>)> { // TODO: adjust this as benchmarks for polimec-receiver are written const MAX_WEIGHT: Weight = Weight::from_parts(10_000, 0); @@ -2794,12 +2800,12 @@ impl Pallet { // TODO: use the actual pallet index when the fields are not private anymore (https://github.com/paritytech/polkadot-sdk/pull/2231) let mut output = Vec::new(); - for migrations in migrations.chunks(MaxMigrationsPerXcm::::get() as usize) { - let (migration_origins, migration_infos): (Vec, Vec) = - migrations.to_vec().into_iter().unzip(); + for migrations_slice in migrations.inner().chunks(MaxMigrationsPerXcm::::get() as usize) { + let migrations_vec = migrations_slice.to_vec(); + let migrations_item = Migrations::from(migrations_vec); + let mut encoded_call = vec![51u8, 0]; - encoded_call.extend_from_slice(user.encode().as_slice()); - encoded_call.extend_from_slice(migration_infos.encode().as_slice()); + encoded_call.extend_from_slice(migrations_item.encode().as_slice()); let xcm: Xcm<()> = Xcm(vec![ UnpaidExecution { weight_limit: WeightLimit::Unlimited, check_origin: None }, Transact { @@ -2809,7 +2815,8 @@ impl Pallet { }, // ReportTransactStatus should be appended here after knowing the query_id ]); - output.push((migration_origins.try_into().expect("already split into max length chunks"), xcm)); + + output.push((migrations_item.origins().try_into().expect("already separated into allowed chunks"), xcm)); } // TODO: we probably want to ensure we dont build too many messages to overflow the queue. Which we know from the parameter `T::RequiredMaxCapacity`. @@ -2820,9 +2827,9 @@ impl Pallet { pub fn mark_migrations_as_sent(project_migration_origins: ProjectMigrationOriginsOf, query_id: QueryId) { let project_id = project_migration_origins.project_id; let migration_origins = project_migration_origins.migration_origins; - for origin in migration_origins { - match origin { - MigrationOrigin::Evaluation { user, id } => { + for MigrationOrigin { user, id, participation_type } in migration_origins { + match participation_type { + ParticipationType::Evaluation => { Evaluations::::mutate( (project_id, T::AccountId32Conversion::convert_back(user), id), |maybe_evaluation| { @@ -2832,14 +2839,14 @@ impl Pallet { }, ); }, - MigrationOrigin::Bid { user, id } => { + ParticipationType::Bid => { Bids::::mutate((project_id, T::AccountId32Conversion::convert_back(user), id), |maybe_bid| { if let Some(bid) = maybe_bid { bid.ct_migration_status = MigrationStatus::Sent(query_id); } }); }, - MigrationOrigin::Contribution { user, id } => { + ParticipationType::Contribution => { Contributions::::mutate( (project_id, T::AccountId32Conversion::convert_back(user), id), |maybe_contribution| { @@ -2856,9 +2863,9 @@ impl Pallet { pub fn mark_migrations_as_confirmed(project_migration_origins: ProjectMigrationOriginsOf) { let project_id = project_migration_origins.project_id; let migration_origins = project_migration_origins.migration_origins; - for origin in migration_origins { - match origin { - MigrationOrigin::Evaluation { user, id } => { + for MigrationOrigin { user, id, participation_type } in migration_origins { + match participation_type { + ParticipationType::Evaluation => { Evaluations::::mutate( (project_id, T::AccountId32Conversion::convert_back(user), id), |maybe_evaluation| { @@ -2868,14 +2875,14 @@ impl Pallet { }, ); }, - MigrationOrigin::Bid { user, id } => { + ParticipationType::Bid => { Bids::::mutate((project_id, T::AccountId32Conversion::convert_back(user), id), |maybe_bid| { if let Some(bid) = maybe_bid { bid.ct_migration_status = MigrationStatus::Confirmed; } }); }, - MigrationOrigin::Contribution { user, id } => { + ParticipationType::Contribution => { Contributions::::mutate( (project_id, T::AccountId32Conversion::convert_back(user), id), |maybe_contribution| { @@ -2895,9 +2902,9 @@ impl Pallet { ) { let project_id = project_migration_origins.project_id; let migration_origins = project_migration_origins.migration_origins; - for origin in migration_origins { - match origin { - MigrationOrigin::Evaluation { user, id } => { + for MigrationOrigin { user, id, participation_type } in migration_origins { + match participation_type { + ParticipationType::Evaluation => { Evaluations::::mutate( (project_id, T::AccountId32Conversion::convert_back(user), id), |maybe_evaluation| { @@ -2907,14 +2914,14 @@ impl Pallet { }, ); }, - MigrationOrigin::Bid { user, id } => { + ParticipationType::Bid => { Bids::::mutate((project_id, T::AccountId32Conversion::convert_back(user), id), |maybe_bid| { if let Some(bid) = maybe_bid { bid.ct_migration_status = MigrationStatus::Failed(error.clone()); } }); }, - MigrationOrigin::Contribution { user, id } => { + ParticipationType::Contribution => { Contributions::::mutate( (project_id, T::AccountId32Conversion::convert_back(user), id), |maybe_contribution| { diff --git a/pallets/polimec-receiver/src/lib.rs b/pallets/polimec-receiver/src/lib.rs index f5f58e26b..bdf8c03e5 100644 --- a/pallets/polimec-receiver/src/lib.rs +++ b/pallets/polimec-receiver/src/lib.rs @@ -9,12 +9,12 @@ pub use pallet::*; #[frame_support::pallet] pub mod pallet { - use crate::MigrationInfo; use frame_support::{ pallet_prelude::*, traits::{tokens::Balance, Currency, ExistenceRequirement::KeepAlive, VestingSchedule}, }; use frame_system::pallet_prelude::*; + use polimec_traits::migration_types::{Migration, MigrationInfo, MigrationOrigin, Migrations, ParticipationType}; use polkadot_parachain::primitives::{Id as ParaId, Sibling}; use polkadot_runtime_parachains::origin::{ensure_parachain, Origin as ParachainOrigin}; use sp_runtime::traits::{AccountIdConversion, Convert}; @@ -37,6 +37,7 @@ pub mod pallet { type Balance: Balance + From + MaybeSerializeDeserialize; type GenesisMoment: Get>; type MigrationInfoToPerBlockBalance: Convert; + type MaxMigrations: Get; } #[pallet::pallet] @@ -44,7 +45,17 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn something)] - pub type Something = StorageValue<_, u32>; + // pub type ExecutedMigrations = StorageNMap<_, BoundedVec>; + pub type ExecutedMigrations = StorageNMap< + _, + ( + NMapKey, + NMapKey, + NMapKey, + ), + bool, + ValueQuery, + >; #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] @@ -52,7 +63,7 @@ pub mod pallet { where T::AccountId: From<[u8; 32]>, { - MigrationsExecutedForUser { user: T::AccountId, migrations: Vec }, + MigrationsExecuted { migrations: Migrations }, } #[pallet::error] @@ -71,42 +82,39 @@ pub mod pallet { { #[pallet::call_index(0)] #[pallet::weight(Weight::from_parts(10_000, 0))] - pub fn migrate_for_user( - origin: OriginFor, - user: [u8; 32], - migrations: Vec, - ) -> DispatchResult { + pub fn execute_migrations(origin: OriginFor, migrations: Migrations) -> DispatchResult { let para_id: ParaId = ensure_parachain(::RuntimeOrigin::from(origin))?; - let user: T::AccountId = user.into(); let polimec_id = T::PolimecParaId::get(); let polimec_soverign_account = Sibling(polimec_id).into_account_truncating(); ensure!(para_id == T::PolimecParaId::get(), "Only Polimec Parachain can call migrations"); - - for migration in migrations.clone() { + for Migration { + origin: MigrationOrigin { user, id, participation_type }, + info: info @ MigrationInfo { contribution_token_amount, .. }, + } in migrations.clone().inner() + { + let already_executed = ExecutedMigrations::::get((user.clone(), participation_type, id)); + if already_executed { + continue + } T::Balances::transfer( &polimec_soverign_account, - &user, - migration.contribution_token_amount.into(), + &user.into(), + contribution_token_amount.into(), KeepAlive, )?; T::Vesting::add_vesting_schedule( - &user, - migration.contribution_token_amount.into(), - T::MigrationInfoToPerBlockBalance::convert(migration), + &user.into(), + contribution_token_amount.into(), + T::MigrationInfoToPerBlockBalance::convert(info), T::GenesisMoment::get(), )?; + ExecutedMigrations::::insert((user.clone(), participation_type, id), true); } - Self::deposit_event(Event::MigrationsExecutedForUser { user, migrations }); + Self::deposit_event(Event::MigrationsExecuted { migrations }); Ok(()) } } } - -#[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] -pub struct MigrationInfo { - pub contribution_token_amount: u128, - pub vesting_time: u64, -} diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 637cbe8f2..c60a132fd 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -46,12 +46,11 @@ use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; pub use sp_runtime::BuildStorage; use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, - traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, OpaqueKeys}, + traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, Convert, ConvertBack, ConvertInto, Identity, OpaqueKeys}, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, }; pub use sp_runtime::{FixedU128, MultiAddress, Perbill, Permill}; -use sp_runtime::traits::{Convert, ConvertBack, Identity}; use sp_std::prelude::*; #[cfg(feature = "std")] @@ -544,8 +543,8 @@ parameter_types! { pub RequiredMaxMessageSize: u32 = 102_400; } pub struct ConvertSelf; -impl Convert for ConvertSelf { - fn convert(account_id: AccountId) -> [u8;32] { +impl Convert for ConvertSelf { + fn convert(account_id: AccountId) -> [u8; 32] { account_id.into() } } diff --git a/traits/src/lib.rs b/traits/src/lib.rs index 0bf93b225..3069b0fc8 100644 --- a/traits/src/lib.rs +++ b/traits/src/lib.rs @@ -101,16 +101,23 @@ pub mod migration_types { use super::*; #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] - pub enum MigrationOrigin { - Evaluation { user: [u8; 32], id: u32 }, - Bid { user: [u8; 32], id: u32 }, - Contribution { user: [u8; 32], id: u32 }, + pub struct MigrationOrigin { + pub user: [u8; 32], + pub id: u32, + pub participation_type: ParticipationType, + } + + #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] + pub enum ParticipationType { + Evaluation, + Bid, + Contribution, } #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct MigrationInfo { - contribution_token_amount: u128, - vesting_time: u64, + pub contribution_token_amount: u128, + pub vesting_time: u64, } impl From<(u128, u64)> for MigrationInfo { fn from((contribution_token_amount, vesting_time): (u128, u64)) -> Self { @@ -118,10 +125,42 @@ pub mod migration_types { } } + #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct Migration { - origin: MigrationOrigin, - info: MigrationInfo + pub origin: MigrationOrigin, + pub info: MigrationInfo, + } + impl Migration { + pub fn new(origin: MigrationOrigin, info: MigrationInfo) -> Self { + Self { origin, info } + } } + #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)] pub struct Migrations(Vec); + impl Migrations { + pub fn new() -> Self { + Self(Vec::new()) + } + + pub fn inner(self) -> Vec { + self.0 + } + + pub fn push(&mut self, migration: Migration) { + self.0.push(migration) + } + + pub fn from(migrations: Vec) -> Self { + Self(migrations) + } + + pub fn origins(&self) -> Vec { + self.0.iter().map(|migration| migration.origin.clone()).collect() + } + + pub fn infos(&self) -> Vec { + self.0.iter().map(|migration| migration.info.clone()).collect() + } + } } From 6401c3ccb6fda820ae093bab6f1d6e52c89a86ae Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 30 Nov 2023 15:27:00 +0100 Subject: [PATCH 051/212] wip --- Cargo.lock | 3 +- Cargo.toml | 1 + integration-tests/Cargo.toml | 6 +- integration-tests/src/tests/ct_migration.rs | 211 +++++++++++++------- integration-tests/src/tests/defaults.rs | 23 +-- integration-tests/src/tests/oracle.rs | 12 +- pallets/funding/Cargo.toml | 2 +- pallets/funding/src/functions.rs | 18 +- pallets/funding/src/lib.rs | 6 +- pallets/funding/src/types.rs | 3 +- traits/Cargo.toml | 4 + traits/src/lib.rs | 49 ++++- 12 files changed, 227 insertions(+), 111 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ef57967ca..b0f2f3234 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4148,7 +4148,7 @@ dependencies = [ "cumulus-primitives-core", "frame-support", "frame-system", - "itertools 0.10.5", + "itertools 0.11.0", "macros", "orml-oracle", "pallet-assets", @@ -7873,6 +7873,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "itertools 0.11.0", "parity-scale-codec", "scale-info", "serde", diff --git a/Cargo.toml b/Cargo.toml index 2e89a62d6..3e35b2bb6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -87,6 +87,7 @@ hex-literal = "0.3.4" serde = { version = "1.0.188", default-features = false } smallvec = "1.11.0" log = { version = "0.4.17", default-features = false } +itertools = { version = "0.11.0", default-features = false, features = ["use_alloc"] } # Emulations xcm-emulator = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "release-v0.9.430" } diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index cd93f155b..abff9188c 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -66,7 +66,7 @@ polkadot-runtime.workspace = true statemint-runtime.workspace = true polimec-parachain-runtime.workspace = true penpal-runtime = { path = "./penpal", default-features = false } -itertools = "0.10.5" +itertools.workspace = true [features] default = [ "std" ] @@ -111,6 +111,7 @@ std = [ "xcm-builder/std", "xcm-executor/std", "xcm/std", + "itertools/use_std" ] runtime-benchmarks = [ @@ -138,7 +139,8 @@ runtime-benchmarks = [ "statemint-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "pallet-xcm/runtime-benchmarks" + "pallet-xcm/runtime-benchmarks", + "itertools/use_alloc", ] testing-node = [ "pallet-funding/testing-node", diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index 5750f58a5..87074d456 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -4,15 +4,11 @@ use pallet_funding::{ Multiplier, MultiplierOf, ProjectIdOf, RewardOrSlash, }; use polimec_parachain_runtime::PolimecFunding; -use polimec_traits::migration_types::MigrationInfo; +use polimec_traits::migration_types::{Migration, MigrationInfo, MigrationOrigin, Migrations, ParticipationType}; use sp_runtime::{FixedPointNumber, Perquintill}; use std::collections::HashMap; use tests::defaults::*; -fn calculate_total_ct_amount<'a>(migrations: impl Iterator) -> u128 { - migrations.into_iter().map(|m| m.contribution_token_amount).sum() -} - fn execute_cleaner(inst: &mut IntegrationInstantiator) { Polimec::execute_with(|| { inst.advance_time(::SuccessToSettlementTime::get() + 1u32).unwrap(); @@ -49,7 +45,7 @@ fn assert_migration_is_ready(project_id: u32) { fn send_migrations( project_id: ProjectIdOf, accounts: Vec, -) -> HashMap> { +) -> HashMap { let mut output = HashMap::new(); for account in accounts { let migrations = Polimec::execute_with(|| { @@ -71,12 +67,19 @@ fn send_migrations( let evaluation_migrations = user_evaluations.map(|evaluation| { assert_eq!(evaluation.ct_migration_status, MigrationStatus::Sent(query_id)); if let Some(RewardOrSlash::Reward(amount)) = evaluation.rewarded_or_slashed { - MigrationInfo { - contribution_token_amount: amount, - vesting_time: Multiplier::new(1u8) - .unwrap() - .calculate_vesting_duration::() - .into(), + Migration { + info: MigrationInfo { + contribution_token_amount: amount, + vesting_time: Multiplier::new(1u8) + .unwrap() + .calculate_vesting_duration::() + .into(), + }, + origin: MigrationOrigin { + user: account.clone().into(), + id: evaluation.id, + participation_type: ParticipationType::Evaluation, + }, } } else { panic!("should be rewarded") @@ -84,80 +87,144 @@ fn send_migrations( }); let bid_migrations = user_bids.map(|bid| { assert_eq!(bid.ct_migration_status, MigrationStatus::Sent(query_id)); - MigrationInfo { - contribution_token_amount: bid.final_ct_amount, - vesting_time: bid.multiplier.calculate_vesting_duration::().into(), + Migration { + info: MigrationInfo { + contribution_token_amount: bid.final_ct_amount, + vesting_time: bid.multiplier.calculate_vesting_duration::().into(), + }, + origin: MigrationOrigin { + user: account.clone().into(), + id: bid.id, + participation_type: ParticipationType::Bid, + }, } }); let contribution_ct_amount = user_contributions.map(|contribution| { assert_eq!(contribution.ct_migration_status, MigrationStatus::Sent(query_id)); - MigrationInfo { - contribution_token_amount: contribution.ct_amount, - vesting_time: contribution.multiplier.calculate_vesting_duration::().into(), + Migration { + info: MigrationInfo { + contribution_token_amount: contribution.ct_amount, + vesting_time: contribution.multiplier.calculate_vesting_duration::().into(), + }, + origin: MigrationOrigin { + user: account.clone().into(), + id: contribution.id, + participation_type: ParticipationType::Contribution, + }, } }); - evaluation_migrations.chain(bid_migrations).chain(contribution_ct_amount).collect::>() + evaluation_migrations.chain(bid_migrations).chain(contribution_ct_amount).collect::() }); output.insert(account.clone(), migrations); } output } -fn migrations_are_executed(migrations: impl Iterator)>) { - Penpal::execute_with(|| { - for (account, migrations) in migrations { - let amount = calculate_total_ct_amount(migrations.iter()); - +fn migrations_are_executed(grouped_migrations: Vec) { + for migration_group in grouped_migrations { + let user = migration_group.clone().inner()[0].origin.user; + assert!(migration_group.origins().iter().all(|origin|origin.user == user )); + Penpal::execute_with(|| { assert_expected_events!( Penpal, vec![ PenpalEvent::PolimecReceiver(polimec_receiver::Event::MigrationsExecuted{migrations}) => { migrations: { - let origins = migrations.origins(); - let infos = migrations.infos(); - let mut migrations_come_from_same_user = origins.into_iter().map(|origin| { - let account: [u8; 32] = account.clone().into(); - origin.user == account - }); - migrations_come_from_same_user.all(|x|x) && - infos.into_iter().map(|info| info.contribution_token_amount).sum::() == amount + migrations.clone().sort_by_ct_amount() == migration_group.clone().sort_by_ct_amount() }, }, ] ); - } - }); + }); + + let user_info = Penpal::account_data_of(user.into()); + assert_close_enough!(user_info.free, migration_group.total_ct_amount(), Perquintill::from_parts(10_000_000_000u64)); + + let vest_scheduled_cts = migration_group.inner().iter().filter_map(|migration| { + if migration.info.vesting_time > 1 { + Some(migration.info.contribution_token_amount) + } else { + None + } + }).sum::(); + assert_close_enough!(user_info.frozen, vest_scheduled_cts, Perquintill::from_parts(1_000_000_000u64)); + } } -fn migrations_are_confirmed_for(project_id: u32, accounts: Vec) { +fn migrations_are_confirmed(project_id: u32, grouped_migrations: Vec) { Polimec::execute_with(|| { - for account in accounts { - let mut user_evaluations = - pallet_funding::Evaluations::::iter_prefix_values((project_id, account.clone())); - let mut user_bids = - pallet_funding::Bids::::iter_prefix_values((project_id, account.clone())); - let mut user_contributions = - pallet_funding::Contributions::::iter_prefix_values((project_id, account.clone())); - - assert!(user_evaluations.all(|bid| bid.ct_migration_status == MigrationStatus::Confirmed)); - assert!(user_bids.all(|bid| bid.ct_migration_status == MigrationStatus::Confirmed)); - assert!( - user_contributions.all(|contribution| contribution.ct_migration_status == MigrationStatus::Confirmed) - ); - + for migration_group in grouped_migrations { assert_expected_events!( Polimec, vec![ - PolimecEvent::PolimecFunding(pallet_funding::Event::MigrationsConfirmed{project_id, ..}) => { + PolimecEvent::PolimecFunding(pallet_funding::Event::MigrationsConfirmed{project_id, migration_origins}) => { project_id: project_id == project_id, + migration_origins: { + let mut a = migration_group.origins().clone(); + let mut b = migration_origins.to_vec().clone(); + a.sort(); + b.sort(); + a == b + }, }, ] ); + for migration_origin in migration_group.origins() { + match migration_origin.participation_type { + ParticipationType::Evaluation => { + let evaluation = pallet_funding::Evaluations::::get(( + project_id, + AccountId::from(migration_origin.user), + migration_origin.id, + ) + ) + .unwrap(); + assert_eq!(evaluation.ct_migration_status, MigrationStatus::Confirmed); + }, + ParticipationType::Bid => { + let bid = pallet_funding::Bids::::get(( + project_id, + AccountId::from(migration_origin.user), + migration_origin.id, + )) + .unwrap(); + assert_eq!(bid.ct_migration_status, MigrationStatus::Confirmed); + }, + ParticipationType::Contribution => { + let contribution = pallet_funding::Contributions::::get(( + project_id, + AccountId::from(migration_origin.user), + migration_origin.id, + )) + .unwrap(); + assert_eq!(contribution.ct_migration_status, MigrationStatus::Confirmed); + }, + } + } } }); } +fn vest_migrations(grouped_migrations: Vec) { + for migration_group in grouped_migrations { + let user = migration_group.clone().inner()[0].origin.user; + assert!(migration_group.origins().iter().all(|origin|origin.user == user )); + + Penpal::execute_with(|| { + assert_ok!(pallet_vesting::Pallet::::vest(PenpalOrigin::signed(user.into()))); + }); + } +} +fn migrations_are_vested(grouped_migrations: Vec) { + for migration_group in grouped_migrations { + let user = migration_group.clone().inner()[0].origin.user; + assert!(migration_group.origins().iter().all(|origin|origin.user == user )); + let total_ct = migration_group.total_ct_amount(); + let user_info = Penpal::account_data_of(user.into()); + } +} + #[test] fn migration_check() { let mut inst = IntegrationInstantiator::new(None); @@ -214,9 +281,6 @@ fn migration_is_sent() { }); execute_cleaner(&mut inst); - let penpal_sov_acc = PolkadotRelay::sovereign_account_id_of(Parachain(Penpal::para_id().into()).into()); - PolkadotRelay::fund_accounts(vec![(penpal_sov_acc, 100_0_000_000_000u128)]); - mock_hrmp_establishment(project_id); assert_migration_is_ready(project_id); @@ -256,24 +320,16 @@ fn migration_is_executed_on_project_and_confirmed_on_polimec() { ) }); execute_cleaner(&mut inst); - let penpal_sov_acc = PolkadotRelay::sovereign_account_id_of(Parachain(Penpal::para_id().into()).into()); - PolkadotRelay::fund_accounts(vec![(penpal_sov_acc, 100_0_000_000_000u128)]); mock_hrmp_establishment(project_id); assert_migration_is_ready(project_id); - let pre_migration_balance = Penpal::account_data_of(EVAL_1.into()); + let migrations_map = send_migrations(project_id, vec![EVAL_1.into()]); + let grouped_migrations = migrations_map.values().cloned().collect::>(); - let migrations = send_migrations(project_id, vec![EVAL_1.into()]); - let eval_1_migrations = migrations[&EVAL_1.into()].clone(); - - migrations_are_confirmed_for(project_id, vec![EVAL_1.into()]); - let eval_1_total_migrated_amount = calculate_total_ct_amount(eval_1_migrations.iter()); - - // Balance is there for the user after vesting (Multiplier 1, so no vesting) - let post_migration_balance = Penpal::account_data_of(EVAL_1.into()); - assert_eq!(post_migration_balance.free - pre_migration_balance.free, eval_1_total_migrated_amount); + migrations_are_executed(grouped_migrations.clone()); + migrations_are_confirmed(project_id, grouped_migrations.clone()); } #[test] @@ -337,8 +393,6 @@ fn vesting_over_several_blocks_on_project() { ) }); execute_cleaner(&mut inst); - let penpal_sov_acc = PolkadotRelay::sovereign_account_id_of(Parachain(Penpal::para_id().into()).into()); - PolkadotRelay::fund_accounts(vec![(penpal_sov_acc, 100_0_000_000_000u128)]); mock_hrmp_establishment(project_id); @@ -347,9 +401,10 @@ fn vesting_over_several_blocks_on_project() { let pre_migration_balance = Penpal::account_data_of(BUYER_1.into()); // Migrate is sent - let migrations_sent = send_migrations(project_id, vec![BUYER_1.into()]); + let user_migrations = send_migrations(project_id, vec![BUYER_1.into()]); + let grouped_migrations = user_migrations.values().cloned().collect::>(); - migrations_are_executed(migrations_sent.into_iter()); + migrations_are_executed(grouped_migrations.clone()); let post_migration_balance = Penpal::account_data_of(BUYER_1.into()); @@ -362,7 +417,7 @@ fn vesting_over_several_blocks_on_project() { Perquintill::from_parts(10_000_000_000u64) ); - migrations_are_confirmed_for(project_id, vec![BUYER_1.into()]); + migrations_are_confirmed(project_id, grouped_migrations.clone()); Penpal::execute_with(|| { let unblock_time: u32 = multiplier_for_vesting.calculate_vesting_duration::(); @@ -393,4 +448,20 @@ fn disallow_duplicated_migrations_on_receiver_pallet() { default_remainder_contributions(), ) }); + + let mut participants = vec![ + EVAL_1, EVAL_2, EVAL_3, EVAL_4, BIDDER_1, BIDDER_2, BIDDER_3, BIDDER_4, BIDDER_5, BIDDER_6, BUYER_1, BUYER_2, + BUYER_3, BUYER_4, BUYER_5, BUYER_6, + ] + .into_iter() + .map(|x| AccountId::from(x)) + .collect::>(); + + execute_cleaner(&mut inst); + + mock_hrmp_establishment(project_id); + + assert_migration_is_ready(project_id); + + let migrations_sent = send_migrations(project_id, participants); } diff --git a/integration-tests/src/tests/defaults.rs b/integration-tests/src/tests/defaults.rs index 7befe8f4e..297a7ba69 100644 --- a/integration-tests/src/tests/defaults.rs +++ b/integration-tests/src/tests/defaults.rs @@ -8,10 +8,10 @@ use sp_core::H256; use std::collections::HashMap; use crate::PolimecOrigin; +use macros::generate_accounts; use polimec_parachain_runtime::AccountId; use sp_runtime::{traits::ConstU32, FixedPointNumber, Perquintill}; use xcm_emulator::TestExt; -use macros::generate_accounts; pub const METADATA: &str = r#"METADATA { @@ -34,23 +34,10 @@ pub fn hashed(data: impl AsRef<[u8]>) -> sp_core::H256 { } generate_accounts!( - ISSUER, - EVAL_1, - EVAL_2, - EVAL_3, - BIDDER_1, - BIDDER_2, - BIDDER_3, - BIDDER_4, - BIDDER_5, - BUYER_1, - BUYER_2, - BUYER_3, - BUYER_4, - BUYER_5, + ISSUER, EVAL_1, EVAL_2, EVAL_3, EVAL_4, BIDDER_1, BIDDER_2, BIDDER_3, BIDDER_4, BIDDER_5, BIDDER_6, BUYER_1, + BUYER_2, BUYER_3, BUYER_4, BUYER_5, BUYER_6, ); - pub fn bounded_name() -> BoundedVec> { BoundedVec::try_from("Contribution Token TEST".as_bytes().to_vec()).unwrap() } @@ -122,7 +109,7 @@ pub fn default_remainder_contributions() -> Vec Vec { } pub fn default_remainder_contributors() -> Vec { - vec![BUYER_1.into(), BUYER_2.into(), BUYER_3.into(), BUYER_4.into(), BUYER_5.into()] + vec![EVAL_4.into(), BUYER_6.into(), BIDDER_6.into(), EVAL_1.into(), BUYER_1.into(), BIDDER_1.into()] } use crate::{Polimec, PolimecRuntime, ALICE, BOB, CHARLIE}; diff --git a/integration-tests/src/tests/oracle.rs b/integration-tests/src/tests/oracle.rs index b4a4fe1e6..9e155f916 100644 --- a/integration-tests/src/tests/oracle.rs +++ b/integration-tests/src/tests/oracle.rs @@ -101,12 +101,12 @@ fn pallet_funding_works() { assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(charlie.clone()), values([4.84, 1.0, 1.0, 0.4]))); let _project_id = inst.create_finished_project( - default_project(ISSUER.into(), 0), - ISSUER.into(), - default_evaluations(), - default_bids(), - default_community_contributions(), - vec![], + default_project(ISSUER.into(), 0), + ISSUER.into(), + default_evaluations(), + default_bids(), + default_community_contributions(), + vec![], ); }); } diff --git a/pallets/funding/Cargo.toml b/pallets/funding/Cargo.toml index a3f6a4e77..c8eb9729d 100644 --- a/pallets/funding/Cargo.toml +++ b/pallets/funding/Cargo.toml @@ -20,7 +20,7 @@ scale-info = { version = "2.9.0", default-features = false, features = [ ] } log.workspace = true -itertools = { version = "0.11.0", default-features = false } +itertools.workspace = true # Substrate dependencies frame-benchmarking = {workspace = true, optional = true} diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index c6c814e94..1eaca7f8f 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -2177,9 +2177,9 @@ impl Pallet { let constructed_migrations = Self::construct_migration_xcm_messages(T::AccountId32Conversion::convert(participant.clone()), migrations); - for (migration_origins, xcm) in constructed_migrations { + for (migrations, xcm) in constructed_migrations { let project_multilocation = MultiLocation { parents: 1, interior: X1(Parachain(project_para_id.into())) }; - let project_migration_origins = ProjectMigrationOriginsOf:: { project_id, migration_origins }; + let project_migration_origins = ProjectMigrationOriginsOf:: { project_id, migration_origins: migrations.origins().try_into().expect("construct function uses same constraint T::MaxMigrationsPerXcm") }; let call: ::RuntimeCall = Call::confirm_migrations { query_id: Default::default(), response: Default::default() }.into(); @@ -2228,14 +2228,16 @@ impl Pallet { match response { Response::DispatchResult(MaybeErrorCode::Success) => { - Self::mark_migrations_as_confirmed(unconfirmed_migrations); - Self::deposit_event(Event::MigrationsConfirmed { project_id, query_id }); + Self::mark_migrations_as_confirmed(unconfirmed_migrations.clone()); + Self::deposit_event(Event::MigrationsConfirmed { project_id, migration_origins: unconfirmed_migrations.migration_origins }); + // Self::deposit_event(Event::MigrationsConfirmed { project_id }); Ok(()) }, Response::DispatchResult(MaybeErrorCode::Error(e)) | Response::DispatchResult(MaybeErrorCode::TruncatedError(e)) => { - Self::mark_migrations_as_failed(unconfirmed_migrations, e); - Self::deposit_event(Event::MigrationsFailed { project_id, query_id }); + Self::mark_migrations_as_failed(unconfirmed_migrations.clone(), e); + Self::deposit_event(Event::MigrationsFailed { project_id, migration_origins: unconfirmed_migrations.migration_origins }); + // Self::deposit_event(Event::MigrationsFailed { project_id}); Ok(()) }, _ => Err(Error::::NotAllowed.into()), @@ -2791,7 +2793,7 @@ impl Pallet { pub fn construct_migration_xcm_messages( user: [u8; 32], migrations: Migrations, - ) -> Vec<(BoundedVec>, Xcm<()>)> { + ) -> Vec<(Migrations, Xcm<()>)> { // TODO: adjust this as benchmarks for polimec-receiver are written const MAX_WEIGHT: Weight = Weight::from_parts(10_000, 0); @@ -2816,7 +2818,7 @@ impl Pallet { // ReportTransactStatus should be appended here after knowing the query_id ]); - output.push((migrations_item.origins().try_into().expect("already separated into allowed chunks"), xcm)); + output.push((migrations_item, xcm)); } // TODO: we probably want to ensure we dont build too many messages to overflow the queue. Which we know from the parameter `T::RequiredMaxCapacity`. diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 06420c268..ade53f54e 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -180,7 +180,7 @@ use frame_support::{ BoundedVec, PalletId, }; pub use pallet::*; -use polimec_traits::migration_types::{MigrationInfo, MigrationOrigin}; +use polimec_traits::migration_types::*; use polkadot_parachain::primitives::Id as ParaId; use sp_arithmetic::traits::{One, Saturating}; use sp_runtime::{traits::AccountIdConversion, FixedPointNumber, FixedPointOperand, FixedU128}; @@ -812,11 +812,11 @@ pub mod pallet { }, MigrationsConfirmed { project_id: ProjectIdOf, - query_id: QueryId, + migration_origins: BoundedVec>, }, MigrationsFailed { project_id: ProjectIdOf, - query_id: QueryId, + migration_origins: BoundedVec>, }, } diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index d1e00b0c0..534c2bc0f 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -366,6 +366,7 @@ pub mod storage_types { pub mod inner_types { use super::*; use xcm::v3::MaxDispatchErrorLen; + use polimec_traits::migration_types::{MigrationOrigin, Migrations}; #[derive(Default, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] @@ -722,7 +723,7 @@ pub mod inner_types { #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct ProjectMigrationOrigins { pub project_id: ProjectId, - pub migration_origins: MigrationOrigins, + pub migration_origins: MigrationOrigins } #[derive(Clone, Encode, Decode, Eq, PartialEq, Ord, PartialOrd, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub enum MigrationStatus { diff --git a/traits/Cargo.toml b/traits/Cargo.toml index 6919d1502..3081f30ea 100644 --- a/traits/Cargo.toml +++ b/traits/Cargo.toml @@ -25,6 +25,7 @@ frame-support = { git = "https://github.com/paritytech/substrate", default-featu frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } +itertools.workspace = true [dev-dependencies] sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.43" } @@ -43,12 +44,15 @@ std = [ "sp-io/std", "sp-runtime/std", "sp-std/std", + "itertools/use_std", + "itertools/use_alloc", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", + "itertools/use_alloc", ] try-runtime = [ "frame-support/try-runtime", diff --git a/traits/src/lib.rs b/traits/src/lib.rs index 3069b0fc8..07eefdabf 100644 --- a/traits/src/lib.rs +++ b/traits/src/lib.rs @@ -17,6 +17,7 @@ #![cfg_attr(not(feature = "std"), no_std)] use frame_support::{pallet_prelude::*, traits::tokens::fungible, RuntimeDebug}; +use itertools::Itertools; use sp_std::prelude::*; /// A release schedule over a fungible. This allows a particular fungible to have release limits @@ -106,14 +107,29 @@ pub mod migration_types { pub id: u32, pub participation_type: ParticipationType, } + impl PartialOrd for MigrationOrigin { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } + } + impl Ord for MigrationOrigin { + fn cmp(&self, other: &Self) -> core::cmp::Ordering { + if self.participation_type == other.participation_type { + self.id.cmp(&other.id) + } else { + self.participation_type.cmp(&other.participation_type) + } + } + } - #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] + #[derive(Clone, Copy, Encode, Decode, Eq, PartialEq, Ord, PartialOrd, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub enum ParticipationType { Evaluation, Bid, Contribution, } + #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct MigrationInfo { pub contribution_token_amount: u128, @@ -138,6 +154,12 @@ pub mod migration_types { #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)] pub struct Migrations(Vec); + impl FromIterator for Migrations { + fn from_iter>(iter: T) -> Self { + Migrations::from(iter.into_iter().collect::>()) + } + } + impl Migrations { pub fn new() -> Self { Self(Vec::new()) @@ -162,5 +184,30 @@ pub mod migration_types { pub fn infos(&self) -> Vec { self.0.iter().map(|migration| migration.info.clone()).collect() } + + pub fn group_by_user(self) -> Vec<([u8; 32], Vec)> { + let mut migrations = self.0; + migrations.sort_by(|a, b| a.origin.user.cmp(&b.origin.user)); + migrations + .into_iter() + .group_by(|migration| migration.origin.user) + .into_iter() + .map(|(user, migrations)| (user, migrations.collect::>())) + .collect::>() + } + + pub fn sort_by_ct_amount(self) -> Migrations { + let mut migrations = self.0; + migrations.sort_by(|a, b| a.info.contribution_token_amount.cmp(&b.info.contribution_token_amount)); + Migrations(migrations) + } + + pub fn total_ct_amount(&self) -> u128 { + self.0.iter().map(|migration| migration.info.contribution_token_amount).sum() + } + + pub fn biggest_vesting_time(&self) -> u64 { + self.0.iter().map(|migration| migration.info.vesting_time).max().unwrap_or(0) + } } } From e5a27e255cc553dfdd4d8ca28c10f71e01800979 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 30 Nov 2023 17:02:01 +0100 Subject: [PATCH 052/212] big refactor --- integration-tests/penpal/src/lib.rs | 7 +--- integration-tests/src/tests/ct_migration.rs | 36 ++++++++------------- pallets/funding/src/instantiator.rs | 2 +- 3 files changed, 15 insertions(+), 30 deletions(-) diff --git a/integration-tests/penpal/src/lib.rs b/integration-tests/penpal/src/lib.rs index 6eb5349cc..df32a35d0 100644 --- a/integration-tests/penpal/src/lib.rs +++ b/integration-tests/penpal/src/lib.rs @@ -53,12 +53,7 @@ use smallvec::smallvec; use sp_api::impl_runtime_apis; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; -use sp_runtime::{ - create_runtime_str, generic, impl_opaque_keys, - traits::{AccountIdLookup, BlakeTwo256, Block as BlockT}, - transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, -}; +use sp_runtime::{create_runtime_str, generic, impl_opaque_keys, traits::{AccountIdLookup, BlakeTwo256, Block as BlockT}, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, FixedU128}; pub use sp_runtime::{traits::ConvertInto, MultiAddress, Perbill, Permill}; use sp_std::prelude::*; #[cfg(feature = "std")] diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index 87074d456..2f22c556c 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -148,7 +148,7 @@ fn migrations_are_executed(grouped_migrations: Vec) { None } }).sum::(); - assert_close_enough!(user_info.frozen, vest_scheduled_cts, Perquintill::from_parts(1_000_000_000u64)); + assert_close_enough!(user_info.frozen, vest_scheduled_cts, Perquintill::from_parts(10_000_000_000_000u64)); } } @@ -207,6 +207,14 @@ fn migrations_are_confirmed(project_id: u32, grouped_migrations: Vec } fn vest_migrations(grouped_migrations: Vec) { + let biggest_time = grouped_migrations + .iter() + .map(|migrations| migrations.biggest_vesting_time()) + .max() + .unwrap(); + Penpal::execute_with(||{ + PenpalSystem::set_block_number(biggest_time as u32); + }); for migration_group in grouped_migrations { let user = migration_group.clone().inner()[0].origin.user; assert!(migration_group.origins().iter().all(|origin|origin.user == user )); @@ -216,6 +224,7 @@ fn vest_migrations(grouped_migrations: Vec) { }); } } + fn migrations_are_vested(grouped_migrations: Vec) { for migration_group in grouped_migrations { let user = migration_group.clone().inner()[0].origin.user; @@ -329,6 +338,7 @@ fn migration_is_executed_on_project_and_confirmed_on_polimec() { let grouped_migrations = migrations_map.values().cloned().collect::>(); migrations_are_executed(grouped_migrations.clone()); + migrations_are_confirmed(project_id, grouped_migrations.clone()); } @@ -406,31 +416,11 @@ fn vesting_over_several_blocks_on_project() { migrations_are_executed(grouped_migrations.clone()); - let post_migration_balance = Penpal::account_data_of(BUYER_1.into()); - - assert_close_enough!( - post_migration_balance.free - - pre_migration_balance.free - - post_migration_balance.frozen - - pre_migration_balance.frozen, - 10_250 * ASSET_UNIT, - Perquintill::from_parts(10_000_000_000u64) - ); - migrations_are_confirmed(project_id, grouped_migrations.clone()); - Penpal::execute_with(|| { - let unblock_time: u32 = multiplier_for_vesting.calculate_vesting_duration::(); - PenpalSystem::set_block_number(unblock_time + 1u32); - assert_ok!(pallet_vesting::Pallet::::vest(PenpalOrigin::signed(BUYER_1.into()))); - }); + vest_migrations(grouped_migrations.clone()); - let post_vest_balance = Penpal::account_data_of(BUYER_1.into()); - assert_close_enough!( - post_vest_balance.free - post_vest_balance.frozen, - 10_250 * ASSET_UNIT + 2000 * ASSET_UNIT, - Perquintill::from_parts(10_000_000_000u64) - ); + migrations_are_vested(grouped_migrations.clone()); } #[test] diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index cd5fc753a..268574aff 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -1712,7 +1712,7 @@ pub mod testing_macros { let real_parts = Perquintill::from_rational($real, $desired); let one = Perquintill::from_percent(100u64); let real_approximation = one - real_parts; - assert!(real_approximation <= $max_approximation); + assert!(real_approximation <= $max_approximation, "Approximation is too big: {:?} > {:?} for {:?} and {:?}", real_approximation, $max_approximation, $real, $desired); }; } From 18ec0935f3558b0a9fd06923342c0c579589a1d8 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 30 Nov 2023 18:09:16 +0100 Subject: [PATCH 053/212] almost there --- integration-tests/penpal/src/lib.rs | 7 +- integration-tests/src/tests/ct_migration.rs | 98 ++++++++++++++------- pallets/funding/src/functions.rs | 26 ++++-- pallets/funding/src/instantiator.rs | 9 +- pallets/funding/src/types.rs | 4 +- pallets/polimec-receiver/src/lib.rs | 15 ++-- traits/src/lib.rs | 1 - 7 files changed, 107 insertions(+), 53 deletions(-) diff --git a/integration-tests/penpal/src/lib.rs b/integration-tests/penpal/src/lib.rs index df32a35d0..e8560f577 100644 --- a/integration-tests/penpal/src/lib.rs +++ b/integration-tests/penpal/src/lib.rs @@ -53,7 +53,12 @@ use smallvec::smallvec; use sp_api::impl_runtime_apis; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; -use sp_runtime::{create_runtime_str, generic, impl_opaque_keys, traits::{AccountIdLookup, BlakeTwo256, Block as BlockT}, transaction_validity::{TransactionSource, TransactionValidity}, ApplyExtrinsicResult, FixedU128}; +use sp_runtime::{ + create_runtime_str, generic, impl_opaque_keys, + traits::{AccountIdLookup, BlakeTwo256, Block as BlockT}, + transaction_validity::{TransactionSource, TransactionValidity}, + ApplyExtrinsicResult, FixedU128, +}; pub use sp_runtime::{traits::ConvertInto, MultiAddress, Perbill, Permill}; use sp_std::prelude::*; #[cfg(feature = "std")] diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index 2f22c556c..5fdb090ec 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -124,30 +124,39 @@ fn send_migrations( fn migrations_are_executed(grouped_migrations: Vec) { for migration_group in grouped_migrations { let user = migration_group.clone().inner()[0].origin.user; - assert!(migration_group.origins().iter().all(|origin|origin.user == user )); - Penpal::execute_with(|| { - assert_expected_events!( - Penpal, - vec![ - PenpalEvent::PolimecReceiver(polimec_receiver::Event::MigrationsExecuted{migrations}) => { - migrations: { - migrations.clone().sort_by_ct_amount() == migration_group.clone().sort_by_ct_amount() + assert!(migration_group.origins().iter().all(|origin| origin.user == user)); + + for single_migration in migration_group.clone().inner() { + Penpal::execute_with(|| { + assert_expected_events!( + Penpal, + vec![ + PenpalEvent::PolimecReceiver(polimec_receiver::Event::MigrationExecuted{migration}) => { + migration: *migration == single_migration, }, - }, - ] - ); - }); + ] + ); + }); + } let user_info = Penpal::account_data_of(user.into()); - assert_close_enough!(user_info.free, migration_group.total_ct_amount(), Perquintill::from_parts(10_000_000_000u64)); + assert_close_enough!( + user_info.free, + migration_group.total_ct_amount(), + Perquintill::from_parts(10_000_000_000u64) + ); - let vest_scheduled_cts = migration_group.inner().iter().filter_map(|migration| { - if migration.info.vesting_time > 1 { - Some(migration.info.contribution_token_amount) - } else { - None - } - }).sum::(); + let vest_scheduled_cts = migration_group + .inner() + .iter() + .filter_map(|migration| { + if migration.info.vesting_time > 1 { + Some(migration.info.contribution_token_amount) + } else { + None + } + }) + .sum::(); assert_close_enough!(user_info.frozen, vest_scheduled_cts, Perquintill::from_parts(10_000_000_000_000u64)); } } @@ -177,8 +186,7 @@ fn migrations_are_confirmed(project_id: u32, grouped_migrations: Vec project_id, AccountId::from(migration_origin.user), migration_origin.id, - ) - ) + )) .unwrap(); assert_eq!(evaluation.ct_migration_status, MigrationStatus::Confirmed); }, @@ -207,17 +215,13 @@ fn migrations_are_confirmed(project_id: u32, grouped_migrations: Vec } fn vest_migrations(grouped_migrations: Vec) { - let biggest_time = grouped_migrations - .iter() - .map(|migrations| migrations.biggest_vesting_time()) - .max() - .unwrap(); - Penpal::execute_with(||{ + let biggest_time = grouped_migrations.iter().map(|migrations| migrations.biggest_vesting_time()).max().unwrap(); + Penpal::execute_with(|| { PenpalSystem::set_block_number(biggest_time as u32); }); for migration_group in grouped_migrations { let user = migration_group.clone().inner()[0].origin.user; - assert!(migration_group.origins().iter().all(|origin|origin.user == user )); + assert!(migration_group.origins().iter().all(|origin| origin.user == user)); Penpal::execute_with(|| { assert_ok!(pallet_vesting::Pallet::::vest(PenpalOrigin::signed(user.into()))); @@ -228,7 +232,7 @@ fn vest_migrations(grouped_migrations: Vec) { fn migrations_are_vested(grouped_migrations: Vec) { for migration_group in grouped_migrations { let user = migration_group.clone().inner()[0].origin.user; - assert!(migration_group.origins().iter().all(|origin|origin.user == user )); + assert!(migration_group.origins().iter().all(|origin| origin.user == user)); let total_ct = migration_group.total_ct_amount(); let user_info = Penpal::account_data_of(user.into()); } @@ -408,8 +412,6 @@ fn vesting_over_several_blocks_on_project() { assert_migration_is_ready(project_id); - let pre_migration_balance = Penpal::account_data_of(BUYER_1.into()); - // Migrate is sent let user_migrations = send_migrations(project_id, vec![BUYER_1.into()]); let grouped_migrations = user_migrations.values().cloned().collect::>(); @@ -453,5 +455,35 @@ fn disallow_duplicated_migrations_on_receiver_pallet() { assert_migration_is_ready(project_id); - let migrations_sent = send_migrations(project_id, participants); + // Migrate is sent + let user_migrations = send_migrations(project_id, vec![BUYER_1.into()]); + let grouped_migrations = user_migrations.values().cloned().collect::>(); + + migrations_are_executed(grouped_migrations.clone()); + + migrations_are_confirmed(project_id, grouped_migrations.clone()); + + vest_migrations(grouped_migrations.clone()); + + migrations_are_vested(grouped_migrations.clone()); + + // just any number that lets us execute our xcm's + for migrations in grouped_migrations { + for (_, xcm) in PolimecFundingPallet::construct_migration_xcm_messages(migrations) { + let call: ::RuntimeCall = + pallet_funding::Call::confirm_migrations { query_id: Default::default(), response: Default::default() }.into(); + + let max_weight = Weight::from_parts(700_000_000, 10_000); + let mut instructions = xcm.into_inner(); + instructions.push(ReportTransactStatus(QueryResponseInfo { + destination: ParentThen(X1(Parachain(Polimec::para_id().into()))).into(), + query_id: 69, + max_weight, + })); + let xcm = Xcm(instructions); + let project_multilocation = MultiLocation { parents: 1, interior: X1(Parachain(Penpal::para_id().into())) }; + + PolimecXcmPallet::send_xcm(Here, project_multilocation, xcm).unwrap(); + } + } } diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 1eaca7f8f..95dda29af 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -2175,11 +2175,16 @@ impl Pallet { migrations.push(Migration::new(migration_origin, migration_info)); } - let constructed_migrations = - Self::construct_migration_xcm_messages(T::AccountId32Conversion::convert(participant.clone()), migrations); + let constructed_migrations = Self::construct_migration_xcm_messages(migrations); for (migrations, xcm) in constructed_migrations { let project_multilocation = MultiLocation { parents: 1, interior: X1(Parachain(project_para_id.into())) }; - let project_migration_origins = ProjectMigrationOriginsOf:: { project_id, migration_origins: migrations.origins().try_into().expect("construct function uses same constraint T::MaxMigrationsPerXcm") }; + let project_migration_origins = ProjectMigrationOriginsOf:: { + project_id, + migration_origins: migrations + .origins() + .try_into() + .expect("construct function uses same constraint T::MaxMigrationsPerXcm"), + }; let call: ::RuntimeCall = Call::confirm_migrations { query_id: Default::default(), response: Default::default() }.into(); @@ -2229,14 +2234,20 @@ impl Pallet { match response { Response::DispatchResult(MaybeErrorCode::Success) => { Self::mark_migrations_as_confirmed(unconfirmed_migrations.clone()); - Self::deposit_event(Event::MigrationsConfirmed { project_id, migration_origins: unconfirmed_migrations.migration_origins }); + Self::deposit_event(Event::MigrationsConfirmed { + project_id, + migration_origins: unconfirmed_migrations.migration_origins, + }); // Self::deposit_event(Event::MigrationsConfirmed { project_id }); Ok(()) }, Response::DispatchResult(MaybeErrorCode::Error(e)) | Response::DispatchResult(MaybeErrorCode::TruncatedError(e)) => { Self::mark_migrations_as_failed(unconfirmed_migrations.clone(), e); - Self::deposit_event(Event::MigrationsFailed { project_id, migration_origins: unconfirmed_migrations.migration_origins }); + Self::deposit_event(Event::MigrationsFailed { + project_id, + migration_origins: unconfirmed_migrations.migration_origins, + }); // Self::deposit_event(Event::MigrationsFailed { project_id}); Ok(()) }, @@ -2790,10 +2801,7 @@ impl Pallet { output } - pub fn construct_migration_xcm_messages( - user: [u8; 32], - migrations: Migrations, - ) -> Vec<(Migrations, Xcm<()>)> { + pub fn construct_migration_xcm_messages(migrations: Migrations) -> Vec<(Migrations, Xcm<()>)> { // TODO: adjust this as benchmarks for polimec-receiver are written const MAX_WEIGHT: Weight = Weight::from_parts(10_000, 0); diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 268574aff..63e020236 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -1712,7 +1712,14 @@ pub mod testing_macros { let real_parts = Perquintill::from_rational($real, $desired); let one = Perquintill::from_percent(100u64); let real_approximation = one - real_parts; - assert!(real_approximation <= $max_approximation, "Approximation is too big: {:?} > {:?} for {:?} and {:?}", real_approximation, $max_approximation, $real, $desired); + assert!( + real_approximation <= $max_approximation, + "Approximation is too big: {:?} > {:?} for {:?} and {:?}", + real_approximation, + $max_approximation, + $real, + $desired + ); }; } diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index 534c2bc0f..1c4d64e3c 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -365,8 +365,8 @@ pub mod storage_types { pub mod inner_types { use super::*; - use xcm::v3::MaxDispatchErrorLen; use polimec_traits::migration_types::{MigrationOrigin, Migrations}; + use xcm::v3::MaxDispatchErrorLen; #[derive(Default, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] @@ -723,7 +723,7 @@ pub mod inner_types { #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct ProjectMigrationOrigins { pub project_id: ProjectId, - pub migration_origins: MigrationOrigins + pub migration_origins: MigrationOrigins, } #[derive(Clone, Encode, Decode, Eq, PartialEq, Ord, PartialOrd, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub enum MigrationStatus { diff --git a/pallets/polimec-receiver/src/lib.rs b/pallets/polimec-receiver/src/lib.rs index bdf8c03e5..63533a48f 100644 --- a/pallets/polimec-receiver/src/lib.rs +++ b/pallets/polimec-receiver/src/lib.rs @@ -63,7 +63,10 @@ pub mod pallet { where T::AccountId: From<[u8; 32]>, { - MigrationsExecuted { migrations: Migrations }, + /// A Migration executed sucessfully + MigrationExecuted { migration: Migration }, + /// A Migration was found which wa already executed, and was skipped. + DuplicatedMigrationSkipped { migration: Migration }, } #[pallet::error] @@ -88,13 +91,14 @@ pub mod pallet { let polimec_soverign_account = Sibling(polimec_id).into_account_truncating(); ensure!(para_id == T::PolimecParaId::get(), "Only Polimec Parachain can call migrations"); - for Migration { + for migration @ Migration { origin: MigrationOrigin { user, id, participation_type }, - info: info @ MigrationInfo { contribution_token_amount, .. }, + info: MigrationInfo { contribution_token_amount, .. }, } in migrations.clone().inner() { let already_executed = ExecutedMigrations::::get((user.clone(), participation_type, id)); if already_executed { + Self::deposit_event(Event::DuplicatedMigrationSkipped { migration }); continue } T::Balances::transfer( @@ -106,14 +110,13 @@ pub mod pallet { T::Vesting::add_vesting_schedule( &user.into(), contribution_token_amount.into(), - T::MigrationInfoToPerBlockBalance::convert(info), + T::MigrationInfoToPerBlockBalance::convert(migration.info.clone()), T::GenesisMoment::get(), )?; ExecutedMigrations::::insert((user.clone(), participation_type, id), true); + Self::deposit_event(Event::MigrationExecuted { migration }); } - Self::deposit_event(Event::MigrationsExecuted { migrations }); - Ok(()) } } diff --git a/traits/src/lib.rs b/traits/src/lib.rs index 07eefdabf..3bc165b9f 100644 --- a/traits/src/lib.rs +++ b/traits/src/lib.rs @@ -129,7 +129,6 @@ pub mod migration_types { Contribution, } - #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] pub struct MigrationInfo { pub contribution_token_amount: u128, From 968c6e185bbd31ea7a3bb83a305ec9ecfb24f39d Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 1 Dec 2023 15:18:26 +0100 Subject: [PATCH 054/212] working --- integration-tests/src/tests/ct_migration.rs | 221 ++++++++++++-------- integration-tests/src/tests/defaults.rs | 9 + pallets/funding/src/instantiator.rs | 12 +- pallets/funding/src/mock.rs | 9 +- pallets/funding/src/tests.rs | 32 +++ runtimes/testnet/src/lib.rs | 2 +- 6 files changed, 193 insertions(+), 92 deletions(-) diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index 5fdb090ec..2995762d2 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -1,7 +1,7 @@ use crate::*; use pallet_funding::{ - assert_close_enough, traits::VestingDurationCalculation, AcceptedFundingAsset, BidStatus, MigrationStatus, - Multiplier, MultiplierOf, ProjectIdOf, RewardOrSlash, + assert_close_enough, traits::VestingDurationCalculation, AcceptedFundingAsset, BidStatus, EvaluatorsOutcome, + MigrationStatus, Multiplier, MultiplierOf, ProjectIdOf, RewardOrSlash, }; use polimec_parachain_runtime::PolimecFunding; use polimec_traits::migration_types::{Migration, MigrationInfo, MigrationOrigin, Migrations, ParticipationType}; @@ -54,8 +54,6 @@ fn send_migrations( project_id, account.clone() )); - let (query_id, _migrations) = - pallet_funding::UnconfirmedMigrations::::iter().next().unwrap(); let user_evaluations = pallet_funding::Evaluations::::iter_prefix_values((project_id, account.clone())); @@ -65,7 +63,7 @@ fn send_migrations( pallet_funding::Contributions::::iter_prefix_values((project_id, account.clone())); let evaluation_migrations = user_evaluations.map(|evaluation| { - assert_eq!(evaluation.ct_migration_status, MigrationStatus::Sent(query_id)); + assert!(matches!(evaluation.ct_migration_status, MigrationStatus::Sent(_))); if let Some(RewardOrSlash::Reward(amount)) = evaluation.rewarded_or_slashed { Migration { info: MigrationInfo { @@ -86,7 +84,7 @@ fn send_migrations( } }); let bid_migrations = user_bids.map(|bid| { - assert_eq!(bid.ct_migration_status, MigrationStatus::Sent(query_id)); + assert!(matches!(bid.ct_migration_status, MigrationStatus::Sent(_))); Migration { info: MigrationInfo { contribution_token_amount: bid.final_ct_amount, @@ -100,7 +98,7 @@ fn send_migrations( } }); let contribution_ct_amount = user_contributions.map(|contribution| { - assert_eq!(contribution.ct_migration_status, MigrationStatus::Sent(query_id)); + assert!(matches!(contribution.ct_migration_status, MigrationStatus::Sent(_))); Migration { info: MigrationInfo { contribution_token_amount: contribution.ct_amount, @@ -116,29 +114,33 @@ fn send_migrations( evaluation_migrations.chain(bid_migrations).chain(contribution_ct_amount).collect::() }); + if migrations.clone().inner().is_empty() { + panic!("no migrations for account: {:?}", account) + } output.insert(account.clone(), migrations); } output } fn migrations_are_executed(grouped_migrations: Vec) { + let all_migrations = + grouped_migrations.iter().flat_map(|migrations| migrations.clone().inner()).collect::>(); + Penpal::execute_with(|| { + assert_expected_events!( + Penpal, + vec![ + PenpalEvent::PolimecReceiver(polimec_receiver::Event::MigrationExecuted{migration}) => { + migration: all_migrations.contains(&migration), + }, + ] + ); + }); + + // since current way to migrate is by bundling each user's migrations into one, we can assume that all migrations in a group are from the same user for migration_group in grouped_migrations { let user = migration_group.clone().inner()[0].origin.user; assert!(migration_group.origins().iter().all(|origin| origin.user == user)); - for single_migration in migration_group.clone().inner() { - Penpal::execute_with(|| { - assert_expected_events!( - Penpal, - vec![ - PenpalEvent::PolimecReceiver(polimec_receiver::Event::MigrationExecuted{migration}) => { - migration: *migration == single_migration, - }, - ] - ); - }); - } - let user_info = Penpal::account_data_of(user.into()); assert_close_enough!( user_info.free, @@ -162,53 +164,60 @@ fn migrations_are_executed(grouped_migrations: Vec) { } fn migrations_are_confirmed(project_id: u32, grouped_migrations: Vec) { + let ordered_grouped_origins = grouped_migrations + .clone() + .into_iter() + .map(|group| { + let mut origins = group.origins(); + origins.sort(); + origins + }) + .collect::>(); Polimec::execute_with(|| { - for migration_group in grouped_migrations { - assert_expected_events!( - Polimec, - vec![ - PolimecEvent::PolimecFunding(pallet_funding::Event::MigrationsConfirmed{project_id, migration_origins}) => { - project_id: project_id == project_id, - migration_origins: { - let mut a = migration_group.origins().clone(); - let mut b = migration_origins.to_vec().clone(); - a.sort(); - b.sort(); - a == b - }, - }, - ] - ); - for migration_origin in migration_group.origins() { - match migration_origin.participation_type { - ParticipationType::Evaluation => { - let evaluation = pallet_funding::Evaluations::::get(( - project_id, - AccountId::from(migration_origin.user), - migration_origin.id, - )) - .unwrap(); - assert_eq!(evaluation.ct_migration_status, MigrationStatus::Confirmed); - }, - ParticipationType::Bid => { - let bid = pallet_funding::Bids::::get(( - project_id, - AccountId::from(migration_origin.user), - migration_origin.id, - )) - .unwrap(); - assert_eq!(bid.ct_migration_status, MigrationStatus::Confirmed); - }, - ParticipationType::Contribution => { - let contribution = pallet_funding::Contributions::::get(( - project_id, - AccountId::from(migration_origin.user), - migration_origin.id, - )) - .unwrap(); - assert_eq!(contribution.ct_migration_status, MigrationStatus::Confirmed); + assert_expected_events!( + Polimec, + vec![ + PolimecEvent::PolimecFunding(pallet_funding::Event::MigrationsConfirmed{project_id, migration_origins}) => { + project_id: project_id == project_id, + migration_origins: { + let mut migration_origins = migration_origins.to_vec(); + migration_origins.sort(); + ordered_grouped_origins.contains(&migration_origins) }, - } + }, + ] + ); + let all_migration_origins = + grouped_migrations.iter().flat_map(|migrations| migrations.clone().origins()).collect::>(); + for migration_origin in all_migration_origins { + match migration_origin.participation_type { + ParticipationType::Evaluation => { + let evaluation = pallet_funding::Evaluations::::get(( + project_id, + AccountId::from(migration_origin.user), + migration_origin.id, + )) + .unwrap(); + assert_eq!(evaluation.ct_migration_status, MigrationStatus::Confirmed); + }, + ParticipationType::Bid => { + let bid = pallet_funding::Bids::::get(( + project_id, + AccountId::from(migration_origin.user), + migration_origin.id, + )) + .unwrap(); + assert_eq!(bid.ct_migration_status, MigrationStatus::Confirmed); + }, + ParticipationType::Contribution => { + let contribution = pallet_funding::Contributions::::get(( + project_id, + AccountId::from(migration_origin.user), + migration_origin.id, + )) + .unwrap(); + assert_eq!(contribution.ct_migration_status, MigrationStatus::Confirmed); + }, } } }); @@ -217,15 +226,18 @@ fn migrations_are_confirmed(project_id: u32, grouped_migrations: Vec fn vest_migrations(grouped_migrations: Vec) { let biggest_time = grouped_migrations.iter().map(|migrations| migrations.biggest_vesting_time()).max().unwrap(); Penpal::execute_with(|| { - PenpalSystem::set_block_number(biggest_time as u32); + PenpalSystem::set_block_number(biggest_time as u32 + 1u32); }); for migration_group in grouped_migrations { let user = migration_group.clone().inner()[0].origin.user; assert!(migration_group.origins().iter().all(|origin| origin.user == user)); - - Penpal::execute_with(|| { - assert_ok!(pallet_vesting::Pallet::::vest(PenpalOrigin::signed(user.into()))); - }); + // check if any vesting_time is bigger than 1, which means the balance was actually frozen + let has_frozen_balance = migration_group.inner().iter().any(|migration| migration.info.vesting_time > 1); + if has_frozen_balance { + Penpal::execute_with(|| { + assert_ok!(pallet_vesting::Pallet::::vest(PenpalOrigin::signed(user.into()))); + }); + } } } @@ -233,8 +245,8 @@ fn migrations_are_vested(grouped_migrations: Vec) { for migration_group in grouped_migrations { let user = migration_group.clone().inner()[0].origin.user; assert!(migration_group.origins().iter().all(|origin| origin.user == user)); - let total_ct = migration_group.total_ct_amount(); let user_info = Penpal::account_data_of(user.into()); + assert_eq!(user_info.frozen, 0) } } @@ -265,7 +277,11 @@ fn migration_check() { fn migration_is_sent() { let mut inst = IntegrationInstantiator::new(None); set_oracle_prices(); - + let mut participants = + vec![EVAL_1, EVAL_2, EVAL_3, BIDDER_1, BIDDER_2, BIDDER_3, BIDDER_4, BUYER_1, BUYER_2, BUYER_3, BUYER_4] + .into_iter() + .map(|x| AccountId::from(x)) + .collect::>(); let project_id = Polimec::execute_with(|| { inst.create_finished_project( default_project(ISSUER.into(), 0), @@ -281,6 +297,7 @@ fn migration_is_sent() { sp_runtime::FixedU128::from_float(1.0), default_weights(), vec![EVAL_1.into(), BIDDER_1.into(), BIDDER_2.into(), BIDDER_3.into(), BIDDER_4.into()], + default_bidder_multipliers(), ), IntegrationInstantiator::generate_contributions_from_total_usd( Perquintill::from_percent(50) * @@ -288,6 +305,7 @@ fn migration_is_sent() { sp_runtime::FixedU128::from_float(1.0), default_weights(), vec![EVAL_1.into(), BUYER_1.into(), BUYER_2.into(), BUYER_3.into(), BUYER_4.into()], + default_contributor_multipliers(), ), vec![], ) @@ -298,14 +316,18 @@ fn migration_is_sent() { assert_migration_is_ready(project_id); - send_migrations(project_id, vec![EVAL_1.into()]); + send_migrations(project_id, participants); } #[test] fn migration_is_executed_on_project_and_confirmed_on_polimec() { let mut inst = IntegrationInstantiator::new(None); set_oracle_prices(); - + let mut participants = + vec![EVAL_1, EVAL_2, EVAL_3, BIDDER_2, BIDDER_3, BIDDER_4, BIDDER_5, BUYER_2, BUYER_3, BUYER_4, BUYER_5] + .into_iter() + .map(|x| AccountId::from(x)) + .collect::>(); let project_id = Polimec::execute_with(|| { inst.create_finished_project( default_project(ISSUER.into(), 0), @@ -321,6 +343,7 @@ fn migration_is_executed_on_project_and_confirmed_on_polimec() { sp_runtime::FixedU128::from_float(1.0), default_weights(), vec![EVAL_1.into(), BIDDER_2.into(), BIDDER_3.into(), BIDDER_4.into(), BIDDER_5.into()], + default_bidder_multipliers(), ), IntegrationInstantiator::generate_contributions_from_total_usd( Perquintill::from_percent(50) * @@ -328,6 +351,7 @@ fn migration_is_executed_on_project_and_confirmed_on_polimec() { sp_runtime::FixedU128::from_float(1.0), default_weights(), vec![EVAL_1.into(), BUYER_2.into(), BUYER_3.into(), BUYER_4.into(), BUYER_5.into()], + default_contributor_multipliers(), ), vec![], ) @@ -338,7 +362,7 @@ fn migration_is_executed_on_project_and_confirmed_on_polimec() { assert_migration_is_ready(project_id); - let migrations_map = send_migrations(project_id, vec![EVAL_1.into()]); + let migrations_map = send_migrations(project_id, participants); let grouped_migrations = migrations_map.values().cloned().collect::>(); migrations_are_executed(grouped_migrations.clone()); @@ -350,7 +374,10 @@ fn migration_is_executed_on_project_and_confirmed_on_polimec() { fn vesting_over_several_blocks_on_project() { let mut inst = IntegrationInstantiator::new(None); set_oracle_prices(); - + let mut participants = vec![EVAL_1, EVAL_2, EVAL_3, BIDDER_1, BIDDER_2, BUYER_1, BUYER_2, BUYER_3] + .into_iter() + .map(|x| AccountId::from(x)) + .collect::>(); let mut bids = Vec::new(); let mut contributions = Vec::new(); let multiplier_for_vesting = MultiplierOf::::try_from(10u8).unwrap(); @@ -359,7 +386,7 @@ fn vesting_over_several_blocks_on_project() { bidder: BUYER_1.into(), amount: 2_000 * ASSET_UNIT, price: 12u128.into(), - multiplier: MultiplierOf::::try_from(10u8).unwrap(), + multiplier: MultiplierOf::::try_from(20u8).unwrap(), asset: AcceptedFundingAsset::USDT, }); bids.push(BidParams { @@ -373,7 +400,7 @@ fn vesting_over_several_blocks_on_project() { bidder: BIDDER_2.into(), amount: 12_000 * ASSET_UNIT, price: 11u128.into(), - multiplier: MultiplierOf::::try_from(10u8).unwrap(), + multiplier: MultiplierOf::::try_from(7u8).unwrap(), asset: AcceptedFundingAsset::USDT, }); @@ -386,13 +413,13 @@ fn vesting_over_several_blocks_on_project() { contributions.push(ContributionParams { contributor: BUYER_2.into(), amount: 5000 * ASSET_UNIT, - multiplier: MultiplierOf::::try_from(1u8).unwrap(), + multiplier: MultiplierOf::::try_from(2u8).unwrap(), asset: AcceptedFundingAsset::USDT, }); contributions.push(ContributionParams { contributor: BUYER_3.into(), amount: 30000 * ASSET_UNIT, - multiplier: MultiplierOf::::try_from(1u8).unwrap(), + multiplier: MultiplierOf::::try_from(3u8).unwrap(), asset: AcceptedFundingAsset::USDT, }); @@ -413,7 +440,7 @@ fn vesting_over_several_blocks_on_project() { assert_migration_is_ready(project_id); // Migrate is sent - let user_migrations = send_migrations(project_id, vec![BUYER_1.into()]); + let user_migrations = send_migrations(project_id, participants); let grouped_migrations = user_migrations.values().cloned().collect::>(); migrations_are_executed(grouped_migrations.clone()); @@ -441,6 +468,13 @@ fn disallow_duplicated_migrations_on_receiver_pallet() { ) }); + let project_details = Polimec::execute_with(|| inst.get_project_details(project_id)); + if let EvaluatorsOutcome::Rewarded(info) = project_details.evaluation_round_info.evaluators_outcome { + println!("rewarded: {:?}", info); + } else { + panic!("should be rewarded") + } + let mut participants = vec![ EVAL_1, EVAL_2, EVAL_3, EVAL_4, BIDDER_1, BIDDER_2, BIDDER_3, BIDDER_4, BIDDER_5, BIDDER_6, BUYER_1, BUYER_2, BUYER_3, BUYER_4, BUYER_5, BUYER_6, @@ -456,7 +490,7 @@ fn disallow_duplicated_migrations_on_receiver_pallet() { assert_migration_is_ready(project_id); // Migrate is sent - let user_migrations = send_migrations(project_id, vec![BUYER_1.into()]); + let user_migrations = send_migrations(project_id, participants); let grouped_migrations = user_migrations.values().cloned().collect::>(); migrations_are_executed(grouped_migrations.clone()); @@ -468,10 +502,11 @@ fn disallow_duplicated_migrations_on_receiver_pallet() { migrations_are_vested(grouped_migrations.clone()); // just any number that lets us execute our xcm's - for migrations in grouped_migrations { + for migrations in grouped_migrations.clone() { for (_, xcm) in PolimecFundingPallet::construct_migration_xcm_messages(migrations) { let call: ::RuntimeCall = - pallet_funding::Call::confirm_migrations { query_id: Default::default(), response: Default::default() }.into(); + pallet_funding::Call::confirm_migrations { query_id: Default::default(), response: Default::default() } + .into(); let max_weight = Weight::from_parts(700_000_000, 10_000); let mut instructions = xcm.into_inner(); @@ -483,7 +518,23 @@ fn disallow_duplicated_migrations_on_receiver_pallet() { let xcm = Xcm(instructions); let project_multilocation = MultiLocation { parents: 1, interior: X1(Parachain(Penpal::para_id().into())) }; - PolimecXcmPallet::send_xcm(Here, project_multilocation, xcm).unwrap(); + Polimec::execute_with(|| { + PolimecXcmPallet::send_xcm(Here, project_multilocation, xcm).unwrap(); + }); } } + + // each duplicated migration was skipped (in this case we duplicated all of them) + let all_migrations = + grouped_migrations.iter().flat_map(|migrations| migrations.clone().inner()).collect::>(); + Penpal::execute_with(|| { + assert_expected_events!( + Penpal, + vec![ + PenpalEvent::PolimecReceiver(polimec_receiver::Event::DuplicatedMigrationSkipped{migration}) => { + migration: all_migrations.contains(&migration), + }, + ] + ); + }); } diff --git a/integration-tests/src/tests/defaults.rs b/integration-tests/src/tests/defaults.rs index 297a7ba69..40d7846ab 100644 --- a/integration-tests/src/tests/defaults.rs +++ b/integration-tests/src/tests/defaults.rs @@ -50,6 +50,12 @@ pub fn metadata_hash(nonce: u32) -> H256 { pub fn default_weights() -> Vec { vec![20u8, 15u8, 10u8, 25u8, 30u8] } +pub fn default_bidder_multipliers() -> Vec { + vec![1u8, 6u8, 20u8, 12u8, 3u8] +} +pub fn default_contributor_multipliers() -> Vec { + vec![1u8, 2u8, 1u8, 4u8, 1u8] +} pub fn default_project(issuer: AccountId, nonce: u32) -> ProjectMetadataOf { ProjectMetadata { @@ -89,6 +95,7 @@ pub fn default_bids() -> Vec> { sp_runtime::FixedU128::from_float(1.0), default_weights(), default_bidders(), + default_bidder_multipliers(), ) } @@ -100,6 +107,7 @@ pub fn default_community_contributions() -> Vec Vec Vec { diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 63e020236..3fdfcba49 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -739,15 +739,16 @@ impl< min_price: PriceOf, weights: Vec, bidders: Vec>, + multipliers: Vec, ) -> Vec> { assert_eq!(weights.len(), bidders.len(), "Should have enough weights for all the bidders"); - zip(weights, bidders) - .map(|(weight, bidder)| { + zip(zip(weights, bidders), multipliers) + .map(|((weight, bidder), multiplier)| { let ticket_size = Percent::from_percent(weight) * usd_amount; let token_amount = min_price.reciprocal().unwrap().saturating_mul_int(ticket_size); - BidParams::new(bidder, token_amount, min_price, 1u8, AcceptedFundingAsset::USDT) + BidParams::new(bidder, token_amount, min_price, multiplier, AcceptedFundingAsset::USDT) }) .collect() } @@ -757,9 +758,10 @@ impl< final_price: PriceOf, weights: Vec, contributors: Vec>, + multipliers: Vec, ) -> Vec> { - zip(weights, contributors) - .map(|(weight, bidder)| { + zip(zip(weights, contributors), multipliers) + .map(|((weight, bidder), multiplier)| { let ticket_size = Percent::from_percent(weight) * usd_amount; let token_amount = final_price.reciprocal().unwrap().saturating_mul_int(ticket_size); diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index a3c290cb7..f543cfe2f 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -86,7 +86,7 @@ pub const fn free_deposit() -> Balance { use frame_support::traits::{Everything, OriginTrait}; use frame_system::RawOrigin as SystemRawOrigin; use polkadot_parachain::primitives::Sibling; -use sp_runtime::traits::Get; +use sp_runtime::traits::{ConvertBack, Get}; use xcm_builder::{EnsureXcmOrigin, FixedWeightBounds, ParentIsPreset, SiblingParachainConvertsVia}; use xcm_executor::traits::Convert; @@ -335,6 +335,13 @@ impl sp_runtime::traits::Convert for DummyConverter { account } } +impl ConvertBack for DummyConverter { + fn convert_back(bytes: [u8; 32]) -> AccountId { + let mut account: [u8; 8] = bytes[0..7].try_into().unwrap(); + u64::from_le_bytes(account) + + } +} impl Config for TestRuntime { type AccountId32Conversion = DummyConverter; diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 1c3fc28f4..1a87d231d 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -163,6 +163,9 @@ pub mod defaults { pub fn default_bidders() -> Vec { vec![BIDDER_1, BIDDER_2, BIDDER_3, BIDDER_4, BIDDER_5] } + pub fn default_multipliers() -> Vec { + vec![1u8, 1u8, 1u8, 1u8, 1u8] + } pub fn default_contributors() -> Vec { vec![BUYER_1, BUYER_2, BUYER_3, BUYER_4, BUYER_5] @@ -179,12 +182,14 @@ pub mod defaults { min_price, default_weights(), default_bidders(), + default_multipliers(), ); let contributions = MockInstantiator::generate_contributions_from_total_usd( Percent::from_percent(50u8) * usd_to_reach, min_price, default_weights(), default_contributors(), + default_multipliers(), ); instantiator.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]) } @@ -1441,6 +1446,7 @@ mod auction_round_success { project.minimum_price, default_weights(), default_bidders(), + default_multipliers(), ); let community_contributions = vec![]; let remainder_contributions = vec![]; @@ -1518,6 +1524,7 @@ mod auction_round_success { project.minimum_price, default_weights(), default_bidders(), + default_multipliers(), ); let community_contributions = vec![]; let remainder_contributions = vec![]; @@ -1614,6 +1621,7 @@ mod auction_round_success { project.minimum_price, default_weights(), default_bidders(), + default_multipliers(), ); bids.remove(0); let community_contributions = vec![]; @@ -1696,6 +1704,7 @@ mod auction_round_success { project.minimum_price, default_weights(), default_bidders(), + default_multipliers(), ); bids.remove(0); let community_contributions = vec![]; @@ -1794,6 +1803,7 @@ mod auction_round_success { project.minimum_price, default_weights(), default_bidders(), + default_multipliers(), ); bids.remove(0); @@ -1854,6 +1864,7 @@ mod auction_round_success { project.minimum_price, default_weights(), default_bidders(), + default_multipliers(), ); bids.remove(0); @@ -3501,6 +3512,7 @@ mod community_round_failure { project.minimum_price, default_weights(), default_bidders(), + default_multipliers(), ); let community_contributions = vec![ @@ -3610,6 +3622,7 @@ mod community_round_failure { project.minimum_price, default_weights(), default_bidders(), + default_multipliers(), ); let community_contributions = vec![ @@ -3750,8 +3763,10 @@ mod community_round_failure { project.minimum_price, default_weights(), default_bidders(), + default_multipliers(), ); + let community_contributions = vec![ ContributionParams::new(BUYER_1, 1_000 * ASSET_UNIT, 2u8.try_into().unwrap(), AcceptedFundingAsset::USDT), ContributionParams::new(BUYER_2, 500 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), @@ -3832,6 +3847,7 @@ mod community_round_failure { project.minimum_price, default_weights(), default_bidders(), + default_multipliers(), ); bids.remove(0); @@ -5123,6 +5139,7 @@ mod remainder_round_failure { project.minimum_price, default_weights(), default_bidders(), + default_multipliers(), ); let community_contributions = vec![ @@ -5223,6 +5240,7 @@ mod remainder_round_failure { project.minimum_price, default_weights(), default_bidders(), + default_multipliers(), ); let community_contributions = vec![ @@ -5353,6 +5371,7 @@ mod remainder_round_failure { project.minimum_price, default_weights(), default_bidders(), + default_multipliers(), ); let community_contributions = vec![ @@ -5465,6 +5484,7 @@ mod remainder_round_failure { project.minimum_price, default_weights(), default_bidders(), + default_multipliers(), ); let community_contributions = vec![ @@ -5638,12 +5658,14 @@ mod funding_end { min_price, default_weights(), default_bidders(), + default_multipliers(), ); let contributions = MockInstantiator::generate_contributions_from_total_usd( Percent::from_percent(50u8) * twenty_percent_funding_usd, min_price, default_weights(), default_contributors(), + default_multipliers(), ); let project_id = inst.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]); @@ -5665,12 +5687,14 @@ mod funding_end { min_price, default_weights(), default_bidders(), + default_multipliers(), ); let contributions = MockInstantiator::generate_contributions_from_total_usd( Percent::from_percent(50u8) * twenty_percent_funding_usd, min_price, default_weights(), default_contributors(), + default_multipliers(), ); let project_id = inst.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]); @@ -5692,12 +5716,14 @@ mod funding_end { min_price, default_weights(), default_bidders(), + default_multipliers(), ); let contributions = MockInstantiator::generate_contributions_from_total_usd( Percent::from_percent(50u8) * twenty_percent_funding_usd, min_price, default_weights(), default_contributors(), + default_multipliers(), ); let project_id = inst.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]); @@ -5718,12 +5744,14 @@ mod funding_end { min_price, default_weights(), default_bidders(), + default_multipliers(), ); let contributions = MockInstantiator::generate_contributions_from_total_usd( Percent::from_percent(50u8) * twenty_percent_funding_usd, min_price, default_weights(), default_contributors(), + default_multipliers(), ); let project_id = inst.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]); @@ -5762,12 +5790,14 @@ mod funding_end { min_price, default_weights(), default_bidders(), + default_multipliers(), ); let contributions = MockInstantiator::generate_contributions_from_total_usd( Percent::from_percent(50u8) * twenty_percent_funding_usd, min_price, default_weights(), default_contributors(), + default_multipliers(), ); let project_id = inst.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]); @@ -5810,12 +5840,14 @@ mod funding_end { min_price, default_weights(), default_bidders(), + default_multipliers(), ); let contributions = MockInstantiator::generate_contributions_from_total_usd( Percent::from_percent(50u8) * twenty_percent_funding_usd, min_price, default_weights(), default_contributors(), + default_multipliers(), ); let project_id = inst.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]); diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index c60a132fd..2750359a1 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -539,7 +539,7 @@ parameter_types! { ).unwrap(); pub MaxMessageSizeThresholds: (u32, u32) = (50000, 102_400); pub MaxCapacityThresholds: (u32, u32) = (8, 1000); - pub RequiredMaxCapacity: u32 = 20; + pub RequiredMaxCapacity: u32 = 1000; pub RequiredMaxMessageSize: u32 = 102_400; } pub struct ConvertSelf; From 7c371608cac72aaed5cfb92d2bf93312d91175b4 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 4 Dec 2023 10:15:47 +0100 Subject: [PATCH 055/212] final changes --- integration-tests/src/tests/ct_migration.rs | 5 ++++- pallets/funding/src/mock.rs | 1 - pallets/funding/src/tests.rs | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index 2995762d2..04b12d91d 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -246,7 +246,8 @@ fn migrations_are_vested(grouped_migrations: Vec) { let user = migration_group.clone().inner()[0].origin.user; assert!(migration_group.origins().iter().all(|origin| origin.user == user)); let user_info = Penpal::account_data_of(user.into()); - assert_eq!(user_info.frozen, 0) + assert_eq!(user_info.frozen, 0); + assert_eq!(user_info.free, migration_group.total_ct_amount()); } } @@ -537,4 +538,6 @@ fn disallow_duplicated_migrations_on_receiver_pallet() { ] ); }); + + migrations_are_vested(grouped_migrations.clone()); } diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index f543cfe2f..01cdfb9ab 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -339,7 +339,6 @@ impl ConvertBack for DummyConverter { fn convert_back(bytes: [u8; 32]) -> AccountId { let mut account: [u8; 8] = bytes[0..7].try_into().unwrap(); u64::from_le_bytes(account) - } } diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 1a87d231d..04b7a87d4 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -3766,7 +3766,6 @@ mod community_round_failure { default_multipliers(), ); - let community_contributions = vec![ ContributionParams::new(BUYER_1, 1_000 * ASSET_UNIT, 2u8.try_into().unwrap(), AcceptedFundingAsset::USDT), ContributionParams::new(BUYER_2, 500 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), From 80a14cf2a2dfdc19229eabe70d7d13dd5ec58127 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 5 Dec 2023 13:06:53 +0100 Subject: [PATCH 056/212] tests passing --- Cargo.lock | 44 ++++---- Cargo.toml | 4 +- integration-tests/Cargo.toml | 2 +- integration-tests/penpal/Cargo.toml | 2 +- integration-tests/penpal/src/lib.rs | 2 +- integration-tests/src/tests/ct_migration.rs | 34 ++++-- pallets/funding/Cargo.toml | 8 +- pallets/funding/src/benchmarking.rs | 2 +- pallets/funding/src/functions.rs | 63 ++++++++++- pallets/funding/src/instantiator.rs | 84 ++++++++++++-- pallets/funding/src/lib.rs | 10 +- pallets/funding/src/tests.rs | 116 +++++++++++++++----- pallets/funding/src/types.rs | 5 +- pallets/linear-release/Cargo.toml | 8 +- pallets/linear-release/src/lib.rs | 2 +- pallets/polimec-receiver/Cargo.toml | 8 +- pallets/polimec-receiver/src/lib.rs | 5 +- {traits => polimec-common}/Cargo.toml | 4 +- {traits => polimec-common}/src/lib.rs | 0 19 files changed, 295 insertions(+), 108 deletions(-) rename {traits => polimec-common}/Cargo.toml (95%) rename {traits => polimec-common}/src/lib.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index b0f2f3234..46f297482 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4164,9 +4164,9 @@ dependencies = [ "parachains-common", "parity-scale-codec", "penpal-runtime", + "polimec-common", "polimec-parachain-runtime", "polimec-receiver", - "polimec-traits", "polkadot-core-primitives", "polkadot-parachain", "polkadot-primitives", @@ -6396,8 +6396,8 @@ dependencies = [ "pallet-xcm", "parachains-common", "parity-scale-codec", + "polimec-common", "polimec-receiver", - "polimec-traits", "polimec-xcm-executor", "polkadot-parachain", "polkadot-runtime", @@ -6515,7 +6515,7 @@ dependencies = [ "pallet-balances", "pallet-funding", "parity-scale-codec", - "polimec-traits", + "polimec-common", "scale-info", "sp-core", "sp-io", @@ -7454,8 +7454,8 @@ dependencies = [ "parachain-info", "parachains-common", "parity-scale-codec", + "polimec-common", "polimec-receiver", - "polimec-traits", "polkadot-parachain", "polkadot-primitives", "polkadot-runtime-common", @@ -7704,6 +7704,23 @@ dependencies = [ "xcm-executor", ] +[[package]] +name = "polimec-common" +version = "0.1.0" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "itertools 0.11.0", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "polimec-parachain-node" version = "0.1.0" @@ -7855,7 +7872,7 @@ dependencies = [ "frame-support", "frame-system", "parity-scale-codec", - "polimec-traits", + "polimec-common", "polkadot-parachain", "polkadot-runtime-parachains", "scale-info", @@ -7866,23 +7883,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "polimec-traits" -version = "0.1.0" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "itertools 0.11.0", - "parity-scale-codec", - "scale-info", - "serde", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - [[package]] name = "polimec-xcm-executor" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 3e35b2bb6..d333db216 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ members = [ "integration-tests/penpal", "integration-tests/macros", "integration-tests/macros/tests", - "traits", + "polimec-common", ] resolver = "2" @@ -70,7 +70,7 @@ orml-oracle = {git = "https://github.com/open-web3-stack/open-runtime-module-lib orml-traits = {git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v0.9.43", default-features = false} # Internal support (with default disabled) shared-configuration = { path = "runtimes/shared-configuration", default-features = false } -polimec-traits = { path = "traits", default-features = false } +polimec-common = { path = "polimec-common", default-features = false } # External support (with default disabled) substrate-fixed = { git = "https://github.com/encointer/substrate-fixed", default-features = false } diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index abff9188c..621db44eb 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -20,7 +20,7 @@ scale-info = { workspace = true, features = ["derive"] } # Local polimec-receiver.workspace = true macros.workspace = true -polimec-traits.workspace = true +polimec-common.workspace = true sp-arithmetic.workspace = true frame-system.workspace = true diff --git a/integration-tests/penpal/Cargo.toml b/integration-tests/penpal/Cargo.toml index 1b71a092a..cf31cdf4b 100644 --- a/integration-tests/penpal/Cargo.toml +++ b/integration-tests/penpal/Cargo.toml @@ -23,7 +23,7 @@ smallvec = "1.10.0" # Local polimec-receiver.workspace = true -polimec-traits.workspace = true +polimec-common.workspace = true # Substrate frame-benchmarking = { workspace = true, optional = true } diff --git a/integration-tests/penpal/src/lib.rs b/integration-tests/penpal/src/lib.rs index e8560f577..5351c6c02 100644 --- a/integration-tests/penpal/src/lib.rs +++ b/integration-tests/penpal/src/lib.rs @@ -48,7 +48,7 @@ use frame_system::{ limits::{BlockLength, BlockWeights}, EnsureRoot, EnsureSigned, }; -use polimec_traits::migration_types::MigrationInfo; +use polimec_common::migration_types::MigrationInfo; use smallvec::smallvec; use sp_api::impl_runtime_apis; pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index 04b12d91d..04c41f25c 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -3,8 +3,8 @@ use pallet_funding::{ assert_close_enough, traits::VestingDurationCalculation, AcceptedFundingAsset, BidStatus, EvaluatorsOutcome, MigrationStatus, Multiplier, MultiplierOf, ProjectIdOf, RewardOrSlash, }; +use polimec_common::migration_types::{Migration, MigrationInfo, MigrationOrigin, Migrations, ParticipationType}; use polimec_parachain_runtime::PolimecFunding; -use polimec_traits::migration_types::{Migration, MigrationInfo, MigrationOrigin, Migrations, ParticipationType}; use sp_runtime::{FixedPointNumber, Perquintill}; use std::collections::HashMap; use tests::defaults::*; @@ -375,23 +375,24 @@ fn migration_is_executed_on_project_and_confirmed_on_polimec() { fn vesting_over_several_blocks_on_project() { let mut inst = IntegrationInstantiator::new(None); set_oracle_prices(); - let mut participants = vec![EVAL_1, EVAL_2, EVAL_3, BIDDER_1, BIDDER_2, BUYER_1, BUYER_2, BUYER_3] + let participants = vec![EVAL_1, EVAL_2, EVAL_3, BIDDER_1, BIDDER_2, BUYER_1, BUYER_2, BUYER_3] .into_iter() .map(|x| AccountId::from(x)) .collect::>(); let mut bids = Vec::new(); - let mut contributions = Vec::new(); + let mut community_contributions = Vec::new(); + let mut remainder_contributions = Vec::new(); let multiplier_for_vesting = MultiplierOf::::try_from(10u8).unwrap(); bids.push(BidParams { - bidder: BUYER_1.into(), + bidder: BIDDER_1.into(), amount: 2_000 * ASSET_UNIT, price: 12u128.into(), multiplier: MultiplierOf::::try_from(20u8).unwrap(), asset: AcceptedFundingAsset::USDT, }); bids.push(BidParams { - bidder: BIDDER_1.into(), + bidder: BIDDER_2.into(), amount: 20_000 * ASSET_UNIT, price: 10u128.into(), multiplier: multiplier_for_vesting, @@ -405,33 +406,46 @@ fn vesting_over_several_blocks_on_project() { asset: AcceptedFundingAsset::USDT, }); - contributions.push(ContributionParams { + community_contributions.push(ContributionParams { contributor: BUYER_1.into(), amount: 10_250 * ASSET_UNIT, multiplier: MultiplierOf::::try_from(1u8).unwrap(), asset: AcceptedFundingAsset::USDT, }); - contributions.push(ContributionParams { + community_contributions.push(ContributionParams { contributor: BUYER_2.into(), amount: 5000 * ASSET_UNIT, multiplier: MultiplierOf::::try_from(2u8).unwrap(), asset: AcceptedFundingAsset::USDT, }); - contributions.push(ContributionParams { + community_contributions.push(ContributionParams { contributor: BUYER_3.into(), amount: 30000 * ASSET_UNIT, multiplier: MultiplierOf::::try_from(3u8).unwrap(), asset: AcceptedFundingAsset::USDT, }); + remainder_contributions.push(ContributionParams { + contributor: BIDDER_1.into(), + amount: 5000 * ASSET_UNIT, + multiplier: MultiplierOf::::try_from(2u8).unwrap(), + asset: AcceptedFundingAsset::USDT, + }); + remainder_contributions.push(ContributionParams { + contributor: EVAL_2.into(), + amount: 250 * ASSET_UNIT, + multiplier: MultiplierOf::::try_from(3u8).unwrap(), + asset: AcceptedFundingAsset::USDT, + }); + let project_id = Polimec::execute_with(|| { inst.create_finished_project( default_project(ISSUER.into(), 0), ISSUER.into(), default_evaluations(), bids, - contributions, - vec![], + community_contributions, + remainder_contributions, ) }); execute_cleaner(&mut inst); diff --git a/pallets/funding/Cargo.toml b/pallets/funding/Cargo.toml index c8eb9729d..af1adf09e 100644 --- a/pallets/funding/Cargo.toml +++ b/pallets/funding/Cargo.toml @@ -29,7 +29,7 @@ frame-system.workspace = true sp-std.workspace = true sp-runtime.workspace = true sp-arithmetic.workspace = true -polimec-traits.workspace = true +polimec-common.workspace = true parachains-common.workspace = true sp-core.workspace = true pallet-balances.workspace = true @@ -68,7 +68,7 @@ std = [ "parachains-common/std", "parity-scale-codec/std", "polimec-receiver/std", - "polimec-traits/std", + "polimec-common/std", "polimec-xcm-executor/std", "polkadot-parachain/std", "polkadot-runtime-parachains/std", @@ -95,7 +95,7 @@ runtime-benchmarks = [ "pallet-timestamp/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", "polimec-receiver/runtime-benchmarks", - "polimec-traits/runtime-benchmarks", + "polimec-common/runtime-benchmarks", "polimec-xcm-executor/runtime-benchmarks", "polkadot-parachain/runtime-benchmarks", "polkadot-runtime-parachains/runtime-benchmarks", @@ -115,7 +115,7 @@ try-runtime = [ "pallet-timestamp/try-runtime", "pallet-xcm/try-runtime", "polimec-receiver/try-runtime", - "polimec-traits/try-runtime", + "polimec-common/try-runtime", "polkadot-runtime-parachains/try-runtime", "polkadot-runtime/try-runtime", "sp-runtime/try-runtime", diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index a8dd06f5d..b8120ff4e 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -26,7 +26,7 @@ use frame_benchmarking::v2::*; use frame_support::{dispatch::RawOrigin, traits::OriginTrait, Parameter}; #[allow(unused_imports)] use pallet::Pallet as PalletFunding; -use polimec_traits::ReleaseSchedule; +use polimec_common::ReleaseSchedule; use scale_info::prelude::format; use sp_arithmetic::Percent; use sp_core::H256; diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 95dda29af..752357204 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -23,7 +23,7 @@ use frame_support::{ ensure, pallet_prelude::*, traits::{ - fungible::MutateHold as FungibleMutateHold, + fungible::{InspectHold, MutateHold as FungibleMutateHold}, fungibles::{metadata::Mutate as MetadataMutate, Create, Inspect, Mutate as FungiblesMutate}, tokens::{Fortitude, Precision, Preservation, Restriction}, Get, @@ -39,10 +39,10 @@ use sp_std::marker::PhantomData; use xcm::v3::MaxDispatchErrorLen; use crate::ProjectStatus::FundingSuccessful; -use polimec_traits::ReleaseSchedule; +use polimec_common::ReleaseSchedule; use crate::traits::{BondingRequirementCalculation, ProvideStatemintPrice, VestingDurationCalculation}; -use polimec_traits::migration_types::{Migration, MigrationInfo, MigrationOrigin, Migrations, ParticipationType}; +use polimec_common::migration_types::{Migration, MigrationInfo, MigrationOrigin, Migrations, ParticipationType}; use super::*; const POLIMEC_PARA_ID: u32 = 3344u32; @@ -752,6 +752,7 @@ impl Pallet { let early_evaluation_reward_threshold_usd = T::EvaluationSuccessThreshold::get() * project_details.fundraising_target; let evaluation_round_info = &mut project_details.evaluation_round_info; + let ct_deposit = T::ContributionTokenCurrency::deposit_required(project_id); // * Validity Checks * ensure!(evaluator.clone() != project_details.issuer, Error::::ContributionToThemselves); @@ -791,6 +792,11 @@ impl Pallet { }; // * Update Storage * + // Reserve plmc deposit to create a contribution token account for this project + if T::NativeCurrency::balance_on_hold(&LockType::FutureDeposit(project_id), &evaluator) < ct_deposit { + T::NativeCurrency::hold(&LockType::FutureDeposit(project_id), &evaluator, ct_deposit)?; + } + if caller_existing_evaluations.len() < T::MaxEvaluationsPerUser::get() as usize { T::NativeCurrency::hold(&LockType::Evaluation(project_id), evaluator, plmc_bond)?; } else { @@ -812,7 +818,7 @@ impl Pallet { Precision::Exact, )?; - T::NativeCurrency::hold(&LockType::Evaluation(project_id), evaluator, plmc_bond)?; + T::NativeCurrency::hold(&LockType::Evaluation(project_id), &evaluator, plmc_bond)?; Evaluations::::remove((project_id, evaluator, low_id)); } @@ -850,18 +856,24 @@ impl Pallet { funding_asset: AcceptedFundingAsset, ) -> DispatchResult { // * Get variables * - ensure!(ct_amount > Zero::zero(), Error::::BidTooLow); let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; let plmc_usd_price = T::PriceProvider::get_price(PLMC_STATEMINT_ID).ok_or(Error::::PriceNotFound)?; + let ct_deposit = T::ContributionTokenCurrency::deposit_required(project_id); // * Validity checks * + ensure!(ct_amount > Zero::zero(), Error::::BidTooLow); ensure!(bidder.clone() != project_details.issuer, Error::::ContributionToThemselves); ensure!(matches!(project_details.status, ProjectStatus::AuctionRound(_)), Error::::AuctionNotStarted); ensure!(funding_asset == project_metadata.participation_currencies, Error::::FundingAssetNotAccepted); // Note: We limit the CT Amount to the total allocation size, to avoid long running loops. ensure!(ct_amount <= project_metadata.total_allocation_size.0, Error::::NotAllowed); + // Reserve plmc deposit to create a contribution token account for this project + if T::NativeCurrency::balance_on_hold(&LockType::FutureDeposit(project_id), &bidder) < ct_deposit { + T::NativeCurrency::hold(&LockType::FutureDeposit(project_id), &bidder, ct_deposit)?; + } + // Fetch current bucket details and other required info let mut current_bucket = Buckets::::get(project_id).ok_or(Error::::ProjectNotFound)?; let now = >::block_number(); @@ -1011,6 +1023,7 @@ impl Pallet { ) -> DispatchResultWithPostInfo { let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; + let ct_deposit = T::ContributionTokenCurrency::deposit_required(project_id); // * Validity checks * ensure!(project_metadata.participation_currencies == asset, Error::::FundingAssetNotAccepted); @@ -1067,6 +1080,11 @@ impl Pallet { }; // * Update storage * + // Reserve plmc deposit to create a contribution token account for this project + if T::NativeCurrency::balance_on_hold(&LockType::FutureDeposit(project_id), &contributor) < ct_deposit { + T::NativeCurrency::hold(&LockType::FutureDeposit(project_id), &contributor, ct_deposit)?; + } + // Try adding the new contribution to the system let existing_contributions = Contributions::::iter_prefix_values((project_id, contributor)).collect::>(); @@ -1211,6 +1229,15 @@ impl Pallet { bid.ct_minted = true; // * Update storage * + if !T::ContributionTokenCurrency::contains(&project_id, &bid.bidder) { + T::NativeCurrency::release( + &LockType::FutureDeposit(project_id), + &bid.bidder, + T::ContributionTokenCurrency::deposit_required(project_id), + Precision::Exact, + )?; + T::ContributionTokenCurrency::touch(project_id, bid.bidder.clone(), bid.bidder.clone())?; + } T::ContributionTokenCurrency::mint_into(project_id, &bid.bidder, ct_amount)?; Bids::::insert((project_id, bidder, bid_id), &bid); @@ -1246,6 +1273,19 @@ impl Pallet { contribution.ct_minted = true; // * Update storage * + if !T::ContributionTokenCurrency::contains(&project_id, &contribution.contributor) { + T::NativeCurrency::release( + &LockType::FutureDeposit(project_id), + &contribution.contributor, + T::ContributionTokenCurrency::deposit_required(project_id), + Precision::Exact, + )?; + T::ContributionTokenCurrency::touch( + project_id, + contribution.contributor.clone(), + contribution.contributor.clone(), + )?; + } T::ContributionTokenCurrency::mint_into(project_id, &contribution.contributor, ct_amount)?; Contributions::::insert((project_id, contributor, contribution_id), contribution); @@ -1343,6 +1383,19 @@ impl Pallet { let normal_evaluators_rewards = normal_reward_weight * reward_info.normal_evaluator_reward_pot; let total_reward_amount = early_evaluators_rewards.saturating_add(normal_evaluators_rewards); // * Update storage * + if !T::ContributionTokenCurrency::contains(&project_id, &evaluation.evaluator) { + T::NativeCurrency::release( + &LockType::FutureDeposit(project_id), + &evaluation.evaluator, + T::ContributionTokenCurrency::deposit_required(project_id), + Precision::Exact, + )?; + T::ContributionTokenCurrency::touch( + project_id, + evaluation.evaluator.clone(), + evaluation.evaluator.clone(), + )?; + } T::ContributionTokenCurrency::mint_into(project_id, &evaluation.evaluator, total_reward_amount)?; evaluation.rewarded_or_slashed = Some(RewardOrSlash::Reward(total_reward_amount)); Evaluations::::insert((project_id, evaluator, evaluation_id), evaluation); diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 3fdfcba49..0df0d2611 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -6,11 +6,12 @@ use frame_support::{ metadata::Inspect as MetadataInspect, roles::Inspect as RolesInspect, Inspect as FungiblesInspect, Mutate as FungiblesMutate, }, - Get, OnFinalize, OnIdle, OnInitialize, + AccountTouch, Get, OnFinalize, OnIdle, OnInitialize, }, weights::Weight, Parameter, }; +use std::ops::Not; use sp_arithmetic::Perquintill; @@ -43,6 +44,7 @@ use crate::{ }; pub use testing_macros::*; + pub type RuntimeOriginOf = ::RuntimeOrigin; pub struct BoxToFunction(pub Box); @@ -381,10 +383,20 @@ impl< total_plmc_supply: BalanceOf, ) { let project_details = self.get_project_details(project_id); + let accounts = expected_reserved_plmc_balances.accounts(); + let expected_ct_account_deposits = accounts + .into_iter() + .map(|account| UserToPLMCBalance { + account, + plmc_amount: ::ContributionTokenCurrency::deposit_required(One::one()), + }) + .collect::>>(); + assert_eq!(project_details.status, ProjectStatus::EvaluationRound); + assert_eq!(self.get_plmc_total_supply(), total_plmc_supply); self.do_free_plmc_assertions(expected_free_plmc_balances); self.do_reserved_plmc_assertions(expected_reserved_plmc_balances, LockType::Evaluation(project_id)); - assert_eq!(self.get_plmc_total_supply(), total_plmc_supply) + self.do_reserved_plmc_assertions(expected_ct_account_deposits, LockType::FutureDeposit(project_id)); } #[allow(unused)] @@ -912,6 +924,7 @@ impl< let plmc_eval_deposits: Vec> = Self::calculate_evaluation_plmc_spent(evaluations.clone()); let plmc_existential_deposits: Vec> = evaluators.existential_deposits(); + let plmc_ct_account_deposits: Vec> = evaluators.ct_account_deposits(); let expected_remaining_plmc: Vec> = Self::generic_map_operation( vec![prev_plmc_balances.clone(), plmc_existential_deposits.clone()], @@ -920,11 +933,15 @@ impl< self.mint_plmc_to(plmc_eval_deposits.clone()); self.mint_plmc_to(plmc_existential_deposits.clone()); + self.mint_plmc_to(plmc_ct_account_deposits.clone()); self.bond_for_users(project_id, evaluations).unwrap(); - let expected_evaluator_balances = - Self::sum_balance_mappings(vec![plmc_eval_deposits.clone(), plmc_existential_deposits.clone()]); + let expected_evaluator_balances = Self::sum_balance_mappings(vec![ + plmc_eval_deposits.clone(), + plmc_existential_deposits.clone(), + plmc_ct_account_deposits, + ]); let expected_total_supply = prev_supply + expected_evaluator_balances; @@ -985,6 +1002,8 @@ impl< let project_id = self.create_auctioning_project(project_metadata.clone(), issuer, evaluations.clone()); let bids = self.simulate_bids_with_bucket(bids, project_id); let bidders = bids.accounts(); + let bidders_non_evaluators = + bidders.clone().into_iter().filter(|account| evaluations.accounts().contains(account).not()).collect_vec(); let asset_id = bids[0].asset.to_statemint_id(); let prev_plmc_balances = self.get_free_plmc_balances_for(bidders.clone()); let prev_funding_asset_balances = self.get_free_statemint_asset_balances_for(asset_id, bidders.clone()); @@ -1005,10 +1024,14 @@ impl< ); let total_plmc_participation_locked = plmc_bid_deposits; let plmc_existential_deposits: Vec> = bidders.existential_deposits(); + let plmc_ct_account_deposits: Vec> = bidders_non_evaluators.ct_account_deposits(); let funding_asset_deposits = Self::calculate_auction_funding_asset_spent(&bids, None); - let bidder_balances = - Self::sum_balance_mappings(vec![necessary_plmc_mint.clone(), plmc_existential_deposits.clone()]); + let bidder_balances = Self::sum_balance_mappings(vec![ + necessary_plmc_mint.clone(), + plmc_existential_deposits.clone(), + plmc_ct_account_deposits.clone(), + ]); let expected_free_plmc_balances = Self::generic_map_operation( vec![prev_plmc_balances.clone(), plmc_existential_deposits.clone()], @@ -1020,6 +1043,7 @@ impl< self.mint_plmc_to(necessary_plmc_mint.clone()); self.mint_plmc_to(plmc_existential_deposits.clone()); + self.mint_plmc_to(plmc_ct_account_deposits.clone()); self.mint_statemint_asset_to(funding_asset_deposits.clone()); self.bid_for_users(project_id, bids.clone()).expect("Bidding should work"); @@ -1133,6 +1157,11 @@ impl< let ct_price = self.get_project_details(project_id).weighted_average_price.unwrap(); let contributors = contributions.accounts(); + let contributors_non_evaluators = contributors + .clone() + .into_iter() + .filter(|account| evaluations.accounts().contains(account).not()) + .collect_vec(); let asset_id = contributions[0].asset.to_statemint_id(); let prev_plmc_balances = self.get_free_plmc_balances_for(contributors.clone()); let prev_funding_asset_balances = self.get_free_statemint_asset_balances_for(asset_id, contributors.clone()); @@ -1151,10 +1180,14 @@ impl< MergeOperation::Add, ); let plmc_existential_deposits = contributors.existential_deposits(); + let plmc_ct_account_deposits = contributors_non_evaluators.ct_account_deposits(); let funding_asset_deposits = Self::calculate_contributed_funding_asset_spent(contributions.clone(), ct_price); - let contributor_balances = - Self::sum_balance_mappings(vec![necessary_plmc_mint.clone(), plmc_existential_deposits.clone()]); + let contributor_balances = Self::sum_balance_mappings(vec![ + necessary_plmc_mint.clone(), + plmc_existential_deposits.clone(), + plmc_ct_account_deposits.clone(), + ]); let expected_free_plmc_balances = Self::generic_map_operation( vec![prev_plmc_balances.clone(), plmc_existential_deposits.clone()], @@ -1166,6 +1199,7 @@ impl< self.mint_plmc_to(necessary_plmc_mint.clone()); self.mint_plmc_to(plmc_existential_deposits.clone()); + self.mint_plmc_to(plmc_ct_account_deposits.clone()); self.mint_statemint_asset_to(funding_asset_deposits.clone()); self.contribute_for_users(project_id, contributions.clone()).expect("Contributing should work"); @@ -1214,6 +1248,15 @@ impl< let ct_price = self.get_project_details(project_id).weighted_average_price.unwrap(); let contributors = remainder_contributions.accounts(); + let new_contributors = contributors + .clone() + .into_iter() + .filter(|account| { + evaluations.accounts().contains(account).not() && + bids.accounts().contains(account).not() && + community_contributions.accounts().contains(account).not() + }) + .collect_vec(); let asset_id = remainder_contributions[0].asset.to_statemint_id(); let prev_plmc_balances = self.get_free_plmc_balances_for(contributors.clone()); let prev_funding_asset_balances = self.get_free_statemint_asset_balances_for(asset_id, contributors.clone()); @@ -1234,11 +1277,15 @@ impl< MergeOperation::Add, ); let plmc_existential_deposits = contributors.existential_deposits(); + let plmc_ct_account_deposits = new_contributors.ct_account_deposits(); let funding_asset_deposits = Self::calculate_contributed_funding_asset_spent(remainder_contributions.clone(), ct_price); - let contributor_balances = - Self::sum_balance_mappings(vec![necessary_plmc_mint.clone(), plmc_existential_deposits.clone()]); + let contributor_balances = Self::sum_balance_mappings(vec![ + necessary_plmc_mint.clone(), + plmc_existential_deposits.clone(), + plmc_ct_account_deposits.clone(), + ]); let expected_free_plmc_balances = Self::generic_map_operation( vec![prev_plmc_balances.clone(), plmc_existential_deposits.clone()], @@ -1250,6 +1297,7 @@ impl< self.mint_plmc_to(necessary_plmc_mint.clone()); self.mint_plmc_to(plmc_existential_deposits.clone()); + self.mint_plmc_to(plmc_ct_account_deposits.clone()); self.mint_statemint_asset_to(funding_asset_deposits.clone()); self.contribute_for_users(project_id, remainder_contributions.clone()) @@ -1351,16 +1399,28 @@ pub trait AccountMerge { fn subtract_accounts(&self, other_list: Self) -> Self; } -pub trait ExistentialDeposits { +pub trait Deposits { fn existential_deposits(&self) -> Vec>; + fn ct_account_deposits(&self) -> Vec>; } -impl ExistentialDeposits for Vec> { +impl Deposits for Vec> { fn existential_deposits(&self) -> Vec> { self.iter() .map(|x| UserToPLMCBalance::new(x.clone(), ::ExistentialDeposit::get())) .collect::>() } + + fn ct_account_deposits(&self) -> Vec> { + self.iter() + .map(|x| { + UserToPLMCBalance::new( + x.clone(), + ::ContributionTokenCurrency::deposit_required(One::one()), + ) + }) + .collect::>() + } } #[derive(Clone, PartialEq, Debug)] pub struct UserToPLMCBalance { diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index ade53f54e..1558d7dda 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -175,12 +175,12 @@ use frame_support::{ traits::{ tokens::{fungible, fungibles, Balance}, - Randomness, + AccountTouch, ContainsPair, Randomness, }, BoundedVec, PalletId, }; pub use pallet::*; -use polimec_traits::migration_types::*; +use polimec_common::migration_types::*; use polkadot_parachain::primitives::Id as ParaId; use sp_arithmetic::traits::{One, Saturating}; use sp_runtime::{traits::AccountIdConversion, FixedPointNumber, FixedPointOperand, FixedU128}; @@ -332,7 +332,9 @@ pub mod pallet { + fungibles::metadata::Inspect> + fungibles::metadata::Mutate> + fungibles::Mutate, Balance = BalanceOf> - + fungibles::roles::Inspect>; + + fungibles::roles::Inspect> + + AccountTouch, Balance = BalanceOf> + + ContainsPair>; type PriceProvider: ProvideStatemintPrice; @@ -402,7 +404,7 @@ pub mod pallet { type EvaluationSuccessThreshold: Get; - type Vesting: polimec_traits::ReleaseSchedule< + type Vesting: polimec_common::ReleaseSchedule< AccountIdOf, BondTypeOf, Currency = Self::NativeCurrency, diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 04b7a87d4..af5ea4fb6 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -32,7 +32,7 @@ use sp_std::{cell::RefCell, marker::PhantomData}; use std::{cmp::min, iter::zip}; use defaults::*; -use polimec_traits::ReleaseSchedule; +use polimec_common::ReleaseSchedule; use crate::{ instantiator::*, @@ -382,11 +382,13 @@ mod evaluation_round_success { let ct_price = details.weighted_average_price.unwrap(); let plmc_deposits = MockInstantiator::calculate_contributed_plmc_spent(contributions.clone(), ct_price); let existential_deposits = plmc_deposits.accounts().existential_deposits(); + let ct_account_deposits = plmc_deposits.accounts().ct_account_deposits(); let funding_deposits = MockInstantiator::calculate_contributed_funding_asset_spent(contributions.clone(), ct_price); inst.mint_plmc_to(plmc_deposits); inst.mint_plmc_to(existential_deposits); + inst.mint_plmc_to(ct_account_deposits); inst.mint_statemint_asset_to(funding_deposits); inst.contribute_for_users(project_id, contributions).unwrap(); @@ -460,7 +462,7 @@ mod evaluation_round_success { default_project(inst.get_new_nonce(), ISSUER), ISSUER, evaluations.clone(), - vec![BidParams::new(BUYER_1, 1000 * ASSET_UNIT, 10u128.into(), 1u8, AcceptedFundingAsset::USDT)], + vec![BidParams::new(BIDDER_1, 1000 * ASSET_UNIT, 10u128.into(), 1u8, AcceptedFundingAsset::USDT)], vec![ContributionParams::new(BUYER_1, 1000 * US_DOLLAR, 1u8, AcceptedFundingAsset::USDT)], ); @@ -506,6 +508,8 @@ mod evaluation_round_failure { let plmc_eval_deposits: Vec> = MockInstantiator::calculate_evaluation_plmc_spent(evaluations.clone()); let plmc_existential_deposits = plmc_eval_deposits.accounts().existential_deposits(); + let ct_account_deposits = plmc_eval_deposits.accounts().ct_account_deposits(); + let expected_evaluator_balances = MockInstantiator::generic_map_operation( vec![plmc_eval_deposits.clone(), plmc_existential_deposits.clone()], MergeOperation::Add, @@ -513,6 +517,7 @@ mod evaluation_round_failure { inst.mint_plmc_to(plmc_eval_deposits.clone()); inst.mint_plmc_to(plmc_existential_deposits.clone()); + inst.mint_plmc_to(ct_account_deposits.clone()); let project_id = inst.create_evaluating_project(project, issuer); @@ -729,9 +734,11 @@ mod auction_round_success { let statemint_funding = MockInstantiator::calculate_auction_funding_asset_spent(&bids, None); let plmc_funding = MockInstantiator::calculate_auction_plmc_spent(&bids, None); let ed_funding = plmc_funding.accounts().existential_deposits(); + let ct_account_deposits = plmc_funding.accounts().ct_account_deposits(); inst.mint_plmc_to(ed_funding); inst.mint_plmc_to(plmc_funding); + inst.mint_plmc_to(ct_account_deposits); inst.mint_statemint_asset_to(statemint_funding); inst.bid_for_users(project_id, bids).unwrap(); @@ -768,9 +775,13 @@ mod auction_round_success { .end() .expect("Candle auction end point should exist"); - let mut bidding_account = 1000; - let bid_info = - BidParams::new(0, 50u128, PriceOf::::from_float(1.0), 1u8, AcceptedFundingAsset::USDT); + let bid_info = BidParams::new( + 0, + 50u128 * ASSET_UNIT, + PriceOf::::from_float(1.0), + 1u8, + AcceptedFundingAsset::USDT, + ); let plmc_necessary_funding = MockInstantiator::calculate_auction_plmc_spent(&vec![bid_info.clone()], None)[0].plmc_amount; let statemint_asset_necessary_funding = @@ -780,11 +791,15 @@ mod auction_round_success { let starting_bid_block = inst.current_block(); let blocks_to_bid = inst.current_block()..candle_end_block; + let mut bidding_account = 1000; + // Do one candle bid for each block until the end of candle auction with a new user for _block in blocks_to_bid { assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AuctionRound(AuctionPhase::Candle)); - inst.mint_plmc_to(vec![UserToPLMCBalance::new(bidding_account, MockInstantiator::get_ed())]); inst.mint_plmc_to(vec![UserToPLMCBalance::new(bidding_account, plmc_necessary_funding)]); + inst.mint_plmc_to(vec![bidding_account].existential_deposits()); + inst.mint_plmc_to(vec![bidding_account].ct_account_deposits()); + inst.mint_statemint_asset_to(vec![UserToStatemintAsset::new( bidding_account, statemint_asset_necessary_funding, @@ -862,8 +877,10 @@ mod auction_round_success { let evaluations = default_evaluations(); let required_plmc = MockInstantiator::calculate_evaluation_plmc_spent(evaluations.clone()); let ed_plmc = required_plmc.accounts().existential_deposits(); + let ct_acount_deposits = required_plmc.accounts().ct_account_deposits(); inst.mint_plmc_to(required_plmc); inst.mint_plmc_to(ed_plmc); + inst.mint_plmc_to(ct_acount_deposits); inst.bond_for_users(project_id, evaluations).unwrap(); inst.advance_time(::EvaluationDuration::get() + 1).unwrap(); assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AuctionInitializePeriod); @@ -878,8 +895,10 @@ mod auction_round_success { let evaluations = default_evaluations(); let required_plmc = MockInstantiator::calculate_evaluation_plmc_spent(evaluations.clone()); let ed_plmc = required_plmc.accounts().existential_deposits(); + let ct_acount_deposits = required_plmc.accounts().ct_account_deposits(); inst.mint_plmc_to(required_plmc); inst.mint_plmc_to(ed_plmc); + inst.mint_plmc_to(ct_acount_deposits); inst.bond_for_users(project_id, evaluations).unwrap(); inst.advance_time(::EvaluationDuration::get() + 1).unwrap(); assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AuctionInitializePeriod); @@ -896,8 +915,10 @@ mod auction_round_success { let evaluations = default_evaluations(); let required_plmc = MockInstantiator::calculate_evaluation_plmc_spent(evaluations.clone()); let ed_plmc = required_plmc.accounts().existential_deposits(); + let ct_acount_deposits = required_plmc.accounts().ct_account_deposits(); inst.mint_plmc_to(required_plmc); inst.mint_plmc_to(ed_plmc); + inst.mint_plmc_to(ct_acount_deposits); inst.bond_for_users(project_id, evaluations).unwrap(); inst.advance_time(::EvaluationDuration::get() + 1).unwrap(); assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AuctionInitializePeriod); @@ -1378,10 +1399,11 @@ mod auction_round_success { let project_id = inst.create_auctioning_project(project, issuer, evaluations); let mut bidders_plmc = MockInstantiator::calculate_auction_plmc_spent(&bids, None); - bidders_plmc - .iter_mut() - .for_each(|UserToPLMCBalance { account: _, plmc_amount }| *plmc_amount += MockInstantiator::get_ed()); + let bidders_existential_deposits = bidders_plmc.accounts().existential_deposits(); + let bidders_ct_account_deposits = bidders_plmc.accounts().ct_account_deposits(); inst.mint_plmc_to(bidders_plmc.clone()); + inst.mint_plmc_to(bidders_existential_deposits); + inst.mint_plmc_to(bidders_ct_account_deposits); let bidders_funding_assets = MockInstantiator::calculate_auction_funding_asset_spent(&bids, None); inst.mint_statemint_asset_to(bidders_funding_assets.clone()); @@ -1392,10 +1414,11 @@ mod auction_round_success { let final_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); let mut contributors_plmc = MockInstantiator::calculate_contributed_plmc_spent(community_contributions.clone(), final_price); - contributors_plmc - .iter_mut() - .for_each(|UserToPLMCBalance { account: _, plmc_amount }| *plmc_amount += MockInstantiator::get_ed()); + let contributors_existential_deposits = contributors_plmc.accounts().existential_deposits(); + let contributors_ct_account_deposits = contributors_plmc.accounts().ct_account_deposits(); inst.mint_plmc_to(contributors_plmc.clone()); + inst.mint_plmc_to(contributors_existential_deposits); + inst.mint_plmc_to(contributors_ct_account_deposits); let contributors_funding_assets = MockInstantiator::calculate_contributed_funding_asset_spent(community_contributions.clone(), final_price); @@ -2078,11 +2101,13 @@ mod auction_round_failure { project_id, ); let mut plmc_fundings = MockInstantiator::calculate_auction_plmc_spent(&bids, None); - plmc_fundings.push(UserToPLMCBalance::new(BIDDER_1, MockInstantiator::get_ed())); - plmc_fundings.push(UserToPLMCBalance::new(BIDDER_2, MockInstantiator::get_ed())); let usdt_fundings = MockInstantiator::calculate_auction_funding_asset_spent(&bids, None); + let plmc_existential_amounnts = plmc_fundings.accounts().existential_deposits(); + let plmc_ct_account_deposits = plmc_fundings.accounts().ct_account_deposits(); inst.mint_plmc_to(plmc_fundings.clone()); + inst.mint_plmc_to(plmc_existential_amounnts.clone()); + inst.mint_plmc_to(plmc_ct_account_deposits.clone()); inst.mint_statemint_asset_to(usdt_fundings.clone()); inst.bid_for_users(project_id, vec![glutton_bid_1, rejected_bid, glutton_bid_2]).expect("Bids should pass"); @@ -2162,13 +2187,15 @@ mod auction_round_failure { let mut plmc_fundings = MockInstantiator::calculate_auction_plmc_spent(&vec![bid_in.clone(), bid_out.clone()], None); - plmc_fundings.push(UserToPLMCBalance::new(BIDDER_1, MockInstantiator::get_ed())); - plmc_fundings.push(UserToPLMCBalance::new(BIDDER_2, MockInstantiator::get_ed())); + let plmc_existential_amounts = plmc_fundings.accounts().existential_deposits(); + let plmc_ct_account_deposits = plmc_fundings.accounts().ct_account_deposits(); let usdt_fundings = MockInstantiator::calculate_auction_funding_asset_spent(&vec![bid_in.clone(), bid_out.clone()], None); inst.mint_plmc_to(plmc_fundings.clone()); + inst.mint_plmc_to(plmc_existential_amounts.clone()); + inst.mint_plmc_to(plmc_ct_account_deposits.clone()); inst.mint_statemint_asset_to(usdt_fundings.clone()); inst.bid_for_users(project_id, vec![bid_in]).expect("Bids should pass"); @@ -2302,11 +2329,14 @@ mod community_round_success { ]; let mut plmc_funding = MockInstantiator::calculate_contributed_plmc_spent(contributions.clone(), token_price); - plmc_funding.push(UserToPLMCBalance::new(BOB, MockInstantiator::get_ed())); + let plmc_existential_deposit = plmc_funding.accounts().existential_deposits(); + let plmc_ct_account_deposits = plmc_funding.accounts().ct_account_deposits(); let statemint_funding = MockInstantiator::calculate_contributed_funding_asset_spent(contributions.clone(), token_price); inst.mint_plmc_to(plmc_funding); + inst.mint_plmc_to(plmc_existential_deposit); + inst.mint_plmc_to(plmc_ct_account_deposits); inst.mint_statemint_asset_to(statemint_funding.clone()); inst.contribute_for_users(project_id, vec![contributions[0].clone()]) @@ -2345,11 +2375,14 @@ mod community_round_success { let contributions = vec![ContributionParams::new(BOB, remaining_ct.1, 1u8, AcceptedFundingAsset::USDT)]; let mut plmc_fundings = MockInstantiator::calculate_contributed_plmc_spent(contributions.clone(), ct_price); - plmc_fundings.push(UserToPLMCBalance::new(BOB, MockInstantiator::get_ed())); + let plmc_existential_deposits = plmc_fundings.accounts().existential_deposits(); + let plmc_ct_account_deposits = plmc_fundings.accounts().ct_account_deposits(); let statemint_asset_fundings = MockInstantiator::calculate_contributed_funding_asset_spent(contributions.clone(), ct_price); inst.mint_plmc_to(plmc_fundings.clone()); + inst.mint_plmc_to(plmc_existential_deposits.clone()); + inst.mint_plmc_to(plmc_ct_account_deposits.clone()); inst.mint_statemint_asset_to(statemint_asset_fundings.clone()); // Buy remaining CTs @@ -2366,7 +2399,7 @@ mod community_round_success { // Check project is in FundingEnded state assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingSuccessful); - inst.do_free_plmc_assertions(vec![plmc_fundings[1].clone()]); + inst.do_free_plmc_assertions(plmc_existential_deposits); inst.do_free_statemint_asset_assertions(vec![UserToStatemintAsset::::new( BOB, 0_u128, @@ -2393,11 +2426,14 @@ mod community_round_success { let contributions = vec![ContributionParams::new(BOB, remaining_ct.1, 1u8, AcceptedFundingAsset::USDT)]; let mut plmc_fundings = MockInstantiator::calculate_contributed_plmc_spent(contributions.clone(), ct_price); - plmc_fundings.push(UserToPLMCBalance::new(BOB, MockInstantiator::get_ed())); + let plmc_existential_deposits = plmc_fundings.accounts().existential_deposits(); + let plmc_ct_account_deposits = plmc_fundings.accounts().ct_account_deposits(); let mut statemint_asset_fundings = MockInstantiator::calculate_contributed_funding_asset_spent(contributions.clone(), ct_price); inst.mint_plmc_to(plmc_fundings.clone()); + inst.mint_plmc_to(plmc_existential_deposits.clone()); + inst.mint_plmc_to(plmc_ct_account_deposits.clone()); inst.mint_statemint_asset_to(statemint_asset_fundings.clone()); // Buy remaining CTs @@ -2423,7 +2459,7 @@ mod community_round_success { let remaining_statemint_assets: BalanceOf = statemint_asset_fundings.iter().fold(0_u128, |acc, item| acc + item.asset_amount); - inst.do_free_plmc_assertions(vec![UserToPLMCBalance::new(BOB, remaining_plmc)]); + inst.do_free_plmc_assertions(plmc_existential_deposits); inst.do_free_statemint_asset_assertions(vec![UserToStatemintAsset::::new( BOB, remaining_statemint_assets, @@ -2465,12 +2501,16 @@ mod community_round_success { .collect(); let plmc_funding = MockInstantiator::calculate_contributed_plmc_spent(contributions.clone(), token_price); - let ed_funding = vec![UserToPLMCBalance::new(CONTRIBUTOR, MockInstantiator::get_ed())]; + let plmc_existential_deposits = plmc_funding.accounts().existential_deposits(); + let plmc_ct_account_deposits = plmc_funding.accounts().ct_account_deposits(); + let statemint_funding = MockInstantiator::calculate_contributed_funding_asset_spent(contributions.clone(), token_price); inst.mint_plmc_to(plmc_funding.clone()); - inst.mint_plmc_to(ed_funding); + inst.mint_plmc_to(plmc_existential_deposits.clone()); + inst.mint_plmc_to(plmc_ct_account_deposits.clone()); + inst.mint_statemint_asset_to(statemint_funding.clone()); // Reach the limit of contributions for a user-project @@ -2573,12 +2613,14 @@ mod community_round_success { .collect(); let plmc_funding = MockInstantiator::calculate_contributed_plmc_spent(contributions.clone(), token_price); - let ed_funding = vec![UserToPLMCBalance::new(CONTRIBUTOR, MockInstantiator::get_ed())]; + let plmc_existential_deposits = plmc_funding.accounts().existential_deposits(); + let plmc_ct_account_deposits = plmc_funding.accounts().ct_account_deposits(); let statemint_funding = MockInstantiator::calculate_contributed_funding_asset_spent(contributions.clone(), token_price); inst.mint_plmc_to(plmc_funding.clone()); - inst.mint_plmc_to(ed_funding); + inst.mint_plmc_to(plmc_existential_deposits.clone()); + inst.mint_plmc_to(plmc_ct_account_deposits.clone()); inst.mint_statemint_asset_to(statemint_funding.clone()); // Reach the limit of contributions for a user-project @@ -4089,11 +4131,14 @@ mod remainder_round_success { let contributions = vec![ContributionParams::new(BOB, remaining_ct.0 + remaining_ct.1, 1u8, AcceptedFundingAsset::USDT)]; let mut plmc_fundings = MockInstantiator::calculate_contributed_plmc_spent(contributions.clone(), ct_price); - plmc_fundings.push(UserToPLMCBalance::new(BOB, MockInstantiator::get_ed())); + let plmc_existential_deposits = contributions.accounts().existential_deposits(); + let plmc_ct_account_deposits = contributions.accounts().ct_account_deposits(); let statemint_asset_fundings = MockInstantiator::calculate_contributed_funding_asset_spent(contributions.clone(), ct_price); inst.mint_plmc_to(plmc_fundings.clone()); + inst.mint_plmc_to(plmc_existential_deposits.clone()); + inst.mint_plmc_to(plmc_ct_account_deposits.clone()); inst.mint_statemint_asset_to(statemint_asset_fundings.clone()); // Buy remaining CTs @@ -4112,7 +4157,7 @@ mod remainder_round_success { // Check project is in FundingEnded state assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingSuccessful); - inst.do_free_plmc_assertions(vec![plmc_fundings[1].clone()]); + inst.do_free_plmc_assertions(plmc_existential_deposits); inst.do_free_statemint_asset_assertions(vec![UserToStatemintAsset::::new( BOB, 0_u128, @@ -4141,11 +4186,14 @@ mod remainder_round_success { let contributions = vec![ContributionParams::new(BOB, remaining_ct, 1u8, AcceptedFundingAsset::USDT)]; let mut plmc_fundings = MockInstantiator::calculate_contributed_plmc_spent(contributions.clone(), ct_price); - plmc_fundings.push(UserToPLMCBalance::new(BOB, MockInstantiator::get_ed())); + let plmc_existential_deposits = contributions.accounts().existential_deposits(); + let plmc_ct_account_deposits = contributions.accounts().ct_account_deposits(); let mut statemint_asset_fundings = MockInstantiator::calculate_contributed_funding_asset_spent(contributions.clone(), ct_price); inst.mint_plmc_to(plmc_fundings.clone()); + inst.mint_plmc_to(plmc_existential_deposits.clone()); + inst.mint_plmc_to(plmc_ct_account_deposits.clone()); inst.mint_statemint_asset_to(statemint_asset_fundings.clone()); // Buy remaining CTs @@ -4172,7 +4220,7 @@ mod remainder_round_success { let remaining_statemint_assets: BalanceOf = statemint_asset_fundings.iter().fold(Zero::zero(), |acc, item| item.asset_amount + acc); - inst.do_free_plmc_assertions(vec![UserToPLMCBalance::new(BOB, remaining_plmc)]); + inst.do_free_plmc_assertions(plmc_existential_deposits); inst.do_free_statemint_asset_assertions(vec![UserToStatemintAsset::::new( BOB, remaining_statemint_assets, @@ -6030,6 +6078,16 @@ mod funding_end { FixedU128::from_rational(4334, 1000).saturating_mul_int(one_week_in_blocks as u64) ); } + + // i.e consumer increase bug fixed with touch on pallet-assets + #[test] + fn no_limit_on_project_contributions_per_user() { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let project_metadata = default_project(inst.get_new_nonce(), ISSUER); + let (bidding_allocation, contributing_allocation) = project_metadata.total_allocation_size; + let evaluations = default_evaluations(); + // let bids = MockInstantiator::generate_bids_from_total_usd((), (), vec![], vec![], vec![]); + } } mod ct_migration { diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index 1c4d64e3c..2292fd97a 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -103,6 +103,9 @@ pub mod config_types { pub enum LockType { Evaluation(ProjectId), Participation(ProjectId), + // We require a PLMC deposit to create an account for minting the CTs to this user. + // Here we make sure the user has this amount before letting him participate. + FutureDeposit(ProjectId), } pub struct ConstPriceProvider(PhantomData<(AssetId, Price, Mapping)>); @@ -365,7 +368,7 @@ pub mod storage_types { pub mod inner_types { use super::*; - use polimec_traits::migration_types::{MigrationOrigin, Migrations}; + use polimec_common::migration_types::{MigrationOrigin, Migrations}; use xcm::v3::MaxDispatchErrorLen; #[derive(Default, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] diff --git a/pallets/linear-release/Cargo.toml b/pallets/linear-release/Cargo.toml index 8b7346e5e..9ad0a8aea 100644 --- a/pallets/linear-release/Cargo.toml +++ b/pallets/linear-release/Cargo.toml @@ -20,7 +20,7 @@ frame-support.workspace = true frame-system.workspace = true sp-std.workspace = true sp-runtime.workspace = true -polimec-traits.workspace = true +polimec-common.workspace = true frame-benchmarking = { workspace = true, optional = true } pallet-funding = { workspace = true, optional = true } xcm-builder = { workspace = true, optional = true } @@ -41,7 +41,7 @@ std = [ "pallet-balances/std", "pallet-funding/std", "parity-scale-codec/std", - "polimec-traits/std", + "polimec-common/std", "scale-info/std", "sp-core/std", "sp-io/std", @@ -56,7 +56,7 @@ runtime-benchmarks = [ "pallet-balances/runtime-benchmarks", "pallet-funding", "pallet-funding?/runtime-benchmarks", - "polimec-traits/runtime-benchmarks", + "polimec-common/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", ] @@ -65,6 +65,6 @@ try-runtime = [ "frame-system/try-runtime", "pallet-balances/try-runtime", "pallet-funding/try-runtime", - "polimec-traits/try-runtime", + "polimec-common/try-runtime", "sp-runtime/try-runtime", ] diff --git a/pallets/linear-release/src/lib.rs b/pallets/linear-release/src/lib.rs index 04e591af3..6a0c807aa 100644 --- a/pallets/linear-release/src/lib.rs +++ b/pallets/linear-release/src/lib.rs @@ -32,7 +32,7 @@ use frame_support::{ }; use frame_system::pallet_prelude::*; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use polimec_traits::ReleaseSchedule; +use polimec_common::ReleaseSchedule; use scale_info::TypeInfo; use sp_runtime::{ traits::{AtLeast32BitUnsigned, Bounded, Convert, One, Saturating, Zero}, diff --git a/pallets/polimec-receiver/Cargo.toml b/pallets/polimec-receiver/Cargo.toml index b0b134687..62eea9fb4 100644 --- a/pallets/polimec-receiver/Cargo.toml +++ b/pallets/polimec-receiver/Cargo.toml @@ -22,7 +22,7 @@ frame-system.workspace = true sp-std.workspace = true polkadot-runtime-parachains.workspace = true polkadot-parachain.workspace = true -polimec-traits.workspace = true +polimec-common.workspace = true sp-runtime.workspace = true [dev-dependencies] @@ -39,7 +39,7 @@ runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", - "polimec-traits/runtime-benchmarks", + "polimec-common/runtime-benchmarks", "polkadot-parachain/runtime-benchmarks", "polkadot-runtime-parachains/runtime-benchmarks", "sp-runtime/runtime-benchmarks", @@ -49,7 +49,7 @@ std = [ "frame-benchmarking/std", "frame-support/std", "frame-system/std", - "polimec-traits/std", + "polimec-common/std", "polkadot-parachain/std", "polkadot-runtime-parachains/std", "scale-info/std", @@ -61,7 +61,7 @@ std = [ try-runtime = [ "frame-support/try-runtime", "frame-system/try-runtime", - "polimec-traits/try-runtime", + "polimec-common/try-runtime", "polkadot-runtime-parachains/try-runtime", "sp-runtime/try-runtime", ] diff --git a/pallets/polimec-receiver/src/lib.rs b/pallets/polimec-receiver/src/lib.rs index 63533a48f..2cac72c39 100644 --- a/pallets/polimec-receiver/src/lib.rs +++ b/pallets/polimec-receiver/src/lib.rs @@ -1,7 +1,4 @@ #![cfg_attr(not(feature = "std"), no_std)] - -use codec::{Decode, Encode, MaxEncodedLen}; -use frame_support::{dispatch::TypeInfo, RuntimeDebug}; /// Edit this file to define custom logic or remove it if it is not needed. /// Learn more about FRAME and the core library of Substrate FRAME pallets: /// @@ -14,7 +11,7 @@ pub mod pallet { traits::{tokens::Balance, Currency, ExistenceRequirement::KeepAlive, VestingSchedule}, }; use frame_system::pallet_prelude::*; - use polimec_traits::migration_types::{Migration, MigrationInfo, MigrationOrigin, Migrations, ParticipationType}; + use polimec_common::migration_types::{Migration, MigrationInfo, MigrationOrigin, Migrations, ParticipationType}; use polkadot_parachain::primitives::{Id as ParaId, Sibling}; use polkadot_runtime_parachains::origin::{ensure_parachain, Origin as ParachainOrigin}; use sp_runtime::traits::{AccountIdConversion, Convert}; diff --git a/traits/Cargo.toml b/polimec-common/Cargo.toml similarity index 95% rename from traits/Cargo.toml rename to polimec-common/Cargo.toml index 3081f30ea..f509439df 100644 --- a/traits/Cargo.toml +++ b/polimec-common/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = 'polimec-traits' -description = 'Common traits for Polimec pallets' +name = 'polimec-common' +description = 'Common types, traits, and impls for Polimec and Projects' authors = ['Polimec Foundation '] documentation = "https://wiki.polimec.org/" edition = "2021" diff --git a/traits/src/lib.rs b/polimec-common/src/lib.rs similarity index 100% rename from traits/src/lib.rs rename to polimec-common/src/lib.rs From 9a0a32d57196c0fefaddd5ea359e1702f3a591b2 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 5 Dec 2023 14:34:14 +0100 Subject: [PATCH 057/212] multiple projects test passing. Big bug found with ever-increasing running times Failing test for release of ct deposit on failed project --- pallets/funding/src/tests.rs | 127 ++++++++++++++++++++++++++++++++++- 1 file changed, 126 insertions(+), 1 deletion(-) diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index af5ea4fb6..030819115 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -61,11 +61,13 @@ const ISSUER: AccountId = 10; const EVALUATOR_1: AccountId = 20; const EVALUATOR_2: AccountId = 21; const EVALUATOR_3: AccountId = 22; +const EVALUATOR_4: AccountId = 23; const BIDDER_1: AccountId = 30; const BIDDER_2: AccountId = 31; const BIDDER_3: AccountId = 32; const BIDDER_4: AccountId = 33; const BIDDER_5: AccountId = 34; +const BIDDER_6: AccountId = 35; const BUYER_1: AccountId = 40; const BUYER_2: AccountId = 41; const BUYER_3: AccountId = 42; @@ -166,6 +168,12 @@ pub mod defaults { pub fn default_multipliers() -> Vec { vec![1u8, 1u8, 1u8, 1u8, 1u8] } + pub fn default_bidder_multipliers() -> Vec { + vec![20u8, 3u8, 15u8, 13u8, 9u8] + } + pub fn default_contributor_multipliers() -> Vec { + vec![1u8, 5u8, 3u8, 1u8, 2u8] + } pub fn default_contributors() -> Vec { vec![BUYER_1, BUYER_2, BUYER_3, BUYER_4, BUYER_5] @@ -563,6 +571,86 @@ mod evaluation_round_failure { let dispatch_error = inst.bond_for_users(project_id, evaluations); assert_err!(dispatch_error, TokenError::FundsUnavailable) } + + #[test] + fn evaluation_ct_account_deposits_are_returned() { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let project_metadata = default_project(0, ISSUER); + let project_id = inst.create_evaluating_project(project_metadata.clone(), ISSUER); + let evaluation_success_threshold = ::EvaluationSuccessThreshold::get(); + let evaluation_min_success_amount = evaluation_success_threshold * + project_metadata.minimum_price.saturating_mul_int( + project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1, + ); + let evaluation_fail_amount = evaluation_min_success_amount - 100 * ASSET_UNIT; + let evaluator_bond = evaluation_fail_amount / 3; + let evaluations = vec![ + UserToUSDBalance::new(EVALUATOR_1, evaluator_bond), + UserToUSDBalance::new(EVALUATOR_2, evaluator_bond), + UserToUSDBalance::new(EVALUATOR_3, evaluator_bond), + ]; + let deposit_required = <::ContributionTokenCurrency as AccountTouch< + ProjectIdOf, + AccountIdOf, + >>::deposit_required(project_id); + inst.do_free_plmc_assertions(vec![ + UserToPLMCBalance::new(EVALUATOR_1, 0u128), + UserToPLMCBalance::new(EVALUATOR_2, 0u128), + UserToPLMCBalance::new(EVALUATOR_3, 0u128), + ]); + inst.do_reserved_plmc_assertions( + vec![ + UserToPLMCBalance::new(EVALUATOR_1, 0u128), + UserToPLMCBalance::new(EVALUATOR_2, 0u128), + UserToPLMCBalance::new(EVALUATOR_3, 0u128), + ], + LockType::FutureDeposit(project_id), + ); + + let required_plmc_bonds = MockInstantiator::calculate_evaluation_plmc_spent(evaluations.clone()); + let plmc_existential_deposits = required_plmc_bonds.accounts().existential_deposits(); + let plmc_ct_account_deposits = required_plmc_bonds.accounts().ct_account_deposits(); + + inst.mint_plmc_to(required_plmc_bonds.clone()); + inst.mint_plmc_to(plmc_existential_deposits.clone()); + inst.mint_plmc_to(plmc_ct_account_deposits.clone()); + + inst.bond_for_users(project_id, evaluations); + + inst.do_free_plmc_assertions(vec![ + UserToPLMCBalance::new(EVALUATOR_1, MockInstantiator::get_ed()), + UserToPLMCBalance::new(EVALUATOR_2, MockInstantiator::get_ed()), + UserToPLMCBalance::new(EVALUATOR_3, MockInstantiator::get_ed()), + ]); + inst.do_reserved_plmc_assertions( + vec![ + UserToPLMCBalance::new(EVALUATOR_1, deposit_required), + UserToPLMCBalance::new(EVALUATOR_2, deposit_required), + UserToPLMCBalance::new(EVALUATOR_3, deposit_required), + ], + LockType::FutureDeposit(project_id), + ); + + inst.advance_time(::EvaluationDuration::get() + 1).unwrap(); + inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::EvaluationFailed); + + let final_plmc_amounts = required_plmc_bonds + .into_iter() + .map(|UserToPLMCBalance { account, plmc_amount }| { + UserToPLMCBalance::new(account, plmc_amount + MockInstantiator::get_ed() + deposit_required) + }) + .collect_vec(); + inst.do_free_plmc_assertions(final_plmc_amounts); + inst.do_reserved_plmc_assertions( + vec![ + UserToPLMCBalance::new(EVALUATOR_1, 0u128), + UserToPLMCBalance::new(EVALUATOR_2, 0u128), + UserToPLMCBalance::new(EVALUATOR_3, 0u128), + ], + LockType::FutureDeposit(project_id), + ); + } } mod auction_round_success { @@ -6080,13 +6168,50 @@ mod funding_end { } // i.e consumer increase bug fixed with touch on pallet-assets + #[ignore] #[test] fn no_limit_on_project_contributions_per_user() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let project_metadata = default_project(inst.get_new_nonce(), ISSUER); let (bidding_allocation, contributing_allocation) = project_metadata.total_allocation_size; let evaluations = default_evaluations(); - // let bids = MockInstantiator::generate_bids_from_total_usd((), (), vec![], vec![], vec![]); + let bids = MockInstantiator::generate_bids_from_total_usd( + bidding_allocation, + project_metadata.minimum_price, + default_weights(), + default_bidders(), + default_bidder_multipliers(), + ); + let community_contributions = MockInstantiator::generate_contributions_from_total_usd( + contributing_allocation / 2, + project_metadata.minimum_price, + default_weights(), + default_contributors(), + default_contributor_multipliers(), + ); + let remainder_contributions = MockInstantiator::generate_contributions_from_total_usd( + contributing_allocation / 2, + project_metadata.minimum_price, + default_weights(), + vec![EVALUATOR_1, EVALUATOR_4, BIDDER_6, BUYER_4, BUYER_7], + vec![2u8, 1u8, 11u8, 1u8, 3u8], + ); + // try doing 1000 projects + use std::time::Instant; + for i in 0..10 { + let now = Instant::now(); + let project_id = inst.create_finished_project( + default_project(inst.get_new_nonce(), ISSUER), + ISSUER, + evaluations.clone(), + bids.clone(), + community_contributions.clone(), + remainder_contributions.clone(), + ); + inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); + let elapsed = now.elapsed(); + println!("Project number {} took {:?}", i, elapsed); + } } } From ed61665315871e09ac04720c97b694f7377aaff7 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 5 Dec 2023 16:59:07 +0100 Subject: [PATCH 058/212] state machine intergration for releasing deposit --- pallets/funding/src/functions.rs | 33 +++++++++++ pallets/funding/src/impls.rs | 95 ++++++++++++++++++++++++++++---- pallets/funding/src/lib.rs | 42 +++++++++----- pallets/funding/src/tests.rs | 13 ++--- pallets/funding/src/traits.rs | 5 +- pallets/funding/src/types.rs | 23 +++++--- 6 files changed, 169 insertions(+), 42 deletions(-) diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 752357204..0cea54bd5 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -1820,6 +1820,39 @@ impl Pallet { Ok(()) } + pub fn do_release_future_ct_deposit_for( + caller: &AccountIdOf, + project_id: T::ProjectIdentifier, + participant: &AccountIdOf, + ) -> DispatchResult { + // * Get variables * + let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; + let held_plmc = T::NativeCurrency::balance_on_hold(&LockType::FutureDeposit(project_id), participant); + // * Validity checks * + ensure!( + matches!(project_details.status, ProjectStatus::EvaluationFailed | ProjectStatus::FundingFailed), + Error::::NotAllowed + ); + ensure!(held_plmc > Zero::zero(), Error::::NoFutureDepositHeld); + + // * Update storage * + T::NativeCurrency::release( + &LockType::FutureDeposit(project_id), + participant, + T::ContributionTokenCurrency::deposit_required(project_id), + Precision::Exact, + )?; + + // * Emit events * + Self::deposit_event(Event::FutureCTDepositReleased { + project_id, + participant: participant.clone(), + caller: caller.clone(), + }); + + Ok(()) + } + pub fn do_set_para_id_for_project( caller: &AccountIdOf, project_id: T::ProjectIdentifier, diff --git a/pallets/funding/src/impls.rs b/pallets/funding/src/impls.rs index 16c03acc1..87f8acdbf 100644 --- a/pallets/funding/src/impls.rs +++ b/pallets/funding/src/impls.rs @@ -1,34 +1,44 @@ +use sp_std::collections::btree_set::BTreeSet; use frame_support::{traits::Get, weights::Weight}; +use itertools::Itertools; use sp_arithmetic::traits::Zero; use sp_runtime::{traits::AccountIdConversion, DispatchError}; use sp_std::marker::PhantomData; use crate::{traits::DoRemainingOperation, *}; -impl Cleaner { - pub fn has_remaining_operations(&self) -> bool { +impl DoRemainingOperation for Cleaner> { + fn has_remaining_operations(&self) -> bool { match self { Cleaner::NotReady => false, - Cleaner::Success(state) => state.has_remaining_operations(), - Cleaner::Failure(state) => state.has_remaining_operations(), + Cleaner::Success(state) => + > as DoRemainingOperation>::has_remaining_operations(state), + Cleaner::Failure(state) => + > as DoRemainingOperation>::has_remaining_operations(state), } } - pub fn do_one_operation(&mut self, project_id: T::ProjectIdentifier) -> Result { + fn do_one_operation(&mut self, project_id: T::ProjectIdentifier) -> Result { match self { Cleaner::NotReady => Err(DispatchError::Other("Cleaner not ready")), - Cleaner::Success(state) => state.do_one_operation::(project_id), - Cleaner::Failure(state) => state.do_one_operation::(project_id), + Cleaner::Success(state) => + > as DoRemainingOperation>::do_one_operation( + state, project_id, + ), + Cleaner::Failure(state) => + > as DoRemainingOperation>::do_one_operation( + state, project_id, + ), } } } -impl DoRemainingOperation for CleanerState { +impl DoRemainingOperation for CleanerState> { fn has_remaining_operations(&self) -> bool { !matches!(self, CleanerState::Finished(_)) } - fn do_one_operation(&mut self, project_id: T::ProjectIdentifier) -> Result { + fn do_one_operation(&mut self, project_id: T::ProjectIdentifier) -> Result { let evaluators_outcome = ProjectsDetails::::get(project_id) .ok_or(Error::::ImpossibleState)? .evaluation_round_info @@ -138,12 +148,12 @@ impl DoRemainingOperation for CleanerState { } } } -impl DoRemainingOperation for CleanerState { +impl DoRemainingOperation for CleanerState> { fn has_remaining_operations(&self) -> bool { !matches!(self, CleanerState::Finished(PhantomData::)) } - fn do_one_operation(&mut self, project_id: T::ProjectIdentifier) -> Result { + fn do_one_operation(&mut self, project_id: T::ProjectIdentifier) -> Result { let evaluators_outcome = ProjectsDetails::::get(project_id) .ok_or(Error::::ImpossibleState)? .evaluation_round_info @@ -223,7 +233,10 @@ impl DoRemainingOperation for CleanerState { CleanerState::ContributionUnbonding(remaining, PhantomData::) => if *remaining == 0 { - *self = CleanerState::Finished(PhantomData::); + *self = CleanerState::FutureDepositRelease( + remaining_participants::(project_id), + PhantomData::, + ); Ok(base_weight) } else { let (consumed_weight, remaining_contributions) = unbond_one_contribution::(project_id); @@ -231,6 +244,17 @@ impl DoRemainingOperation for CleanerState { Ok(consumed_weight) }, + CleanerState::FutureDepositRelease(remaining_participants, PhantomData::) => + if remaining_participants.is_empty() { + *self = CleanerState::Finished(PhantomData::); + Ok(base_weight) + } else { + let (consumed_weight, remaining_participants) = + release_future_ct_deposit_one_participant::(project_id, remaining_participants.clone()); + *self = CleanerState::FutureDepositRelease(remaining_participants, PhantomData::); + Ok(consumed_weight) + }, + CleanerState::Finished(PhantomData::) => Err(Error::::FinalizerFinished.into()), _ => Err(Error::::ImpossibleState.into()), @@ -238,6 +262,43 @@ impl DoRemainingOperation for CleanerState { } } +fn release_future_ct_deposit_one_participant( + project_id: ::ProjectIdentifier, + mut remaining_participants: AccountListOf, +) -> (Weight, AccountListOf) { + let base_weight = Weight::from_parts(10_000_000, 0); + let mut iter_participants = remaining_participants.into_iter(); + + while let Some(account) = iter_participants.next() { + match Pallet::::do_release_future_ct_deposit_for( + &T::PalletId::get().into_account_truncating(), + project_id, + &account, + ) { + // Ok(_) => return (base_weight.saturating_add(WeightInfoOf::::release_future_ct_deposit_for()), iter_participants.collect_vec()), + Ok(_) => + return ( + base_weight, + iter_participants.collect_vec().try_into().expect("Vec is equal or smaller, so has to fit"), + ), + Err(e) if e == Error::::NoFutureDepositHeld.into() => continue, + Err(e) => { + Pallet::::deposit_event(Event::ReleaseFutureCTDepositFailed { + project_id, + participant: account.clone(), + error: e, + }); + // return (base_weight.saturating_add(WeightInfoOf::::release_future_ct_deposit_for()), iter_participants.collect_vec()); + return ( + base_weight.saturating_add(base_weight), + iter_participants.collect_vec().try_into().expect("Vec is equal or smaller, so has to fit"), + ) + }, + }; + } + return (base_weight, iter_participants.collect_vec().try_into().expect("Vec is equal or smaller, so has to fit")) +} + fn remaining_evaluators_to_reward_or_slash( project_id: T::ProjectIdentifier, outcome: EvaluatorsOutcomeOf, @@ -278,6 +339,16 @@ fn remaining_contributions(project_id: T::ProjectIdentifier) -> u64 { Contributions::::iter_prefix_values((project_id,)).count() as u64 } +fn remaining_participants(project_id: T::ProjectIdentifier) -> AccountListOf { + let evaluators = Evaluations::::iter_key_prefix((project_id,)).map(|(evaluator, evaluation_id)| evaluator); + let bidders = Bids::::iter_key_prefix((project_id,)).map(|(bidder, bid_id)| bidder); + let contributors = + Contributions::::iter_key_prefix((project_id,)).map(|(contributor, contribution_id)| contributor); + let all_participants = + evaluators.chain(bidders).chain(contributors).collect::>>(); + AccountListOf::::force_from(all_participants.into_iter().collect_vec(), Some("getting remaining participants in Cleaner")) +} + fn remaining_bids_without_ct_minted(project_id: T::ProjectIdentifier) -> u64 { let project_bids = Bids::::iter_prefix_values((project_id,)); project_bids.filter(|bid| !bid.ct_minted).count() as u64 diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 1558d7dda..cae7585a1 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -172,6 +172,8 @@ // we add more without this limit. #![cfg_attr(feature = "runtime-benchmarks", recursion_limit = "512")] +use crate::traits::DoRemainingOperation; +pub use crate::weights::WeightInfo; use frame_support::{ traits::{ tokens::{fungible, fungibles, Balance}, @@ -183,13 +185,12 @@ pub use pallet::*; use polimec_common::migration_types::*; use polkadot_parachain::primitives::Id as ParaId; use sp_arithmetic::traits::{One, Saturating}; -use sp_runtime::{traits::AccountIdConversion, FixedPointNumber, FixedPointOperand, FixedU128}; +use sp_core::ConstU32; +use sp_runtime::{traits::AccountIdConversion, FixedPointNumber, FixedPointOperand, FixedU128, WeakBoundedVec}; use sp_std::{marker::PhantomData, prelude::*}; pub use types::*; use xcm::v3::{opaque::Instruction, prelude::*, SendXcm}; -pub use crate::weights::WeightInfo; - pub mod functions; pub mod types; pub mod weights; @@ -219,12 +220,20 @@ pub type HashOf = ::Hash; pub type AssetIdOf = <::FundingCurrency as fungibles::Inspect<::AccountId>>::AssetId; pub type RewardInfoOf = RewardInfo>; + +pub type AccountListOf = WeakBoundedVec, ConstU32<1000u32>>; pub type EvaluatorsOutcomeOf = EvaluatorsOutcome>; pub type ProjectMetadataOf = ProjectMetadata>, BalanceOf, PriceOf, AccountIdOf, HashOf>; -pub type ProjectDetailsOf = - ProjectDetails, BlockNumberOf, PriceOf, BalanceOf, EvaluationRoundInfoOf>; +pub type ProjectDetailsOf = ProjectDetails< + AccountIdOf, + BlockNumberOf, + PriceOf, + BalanceOf, + EvaluationRoundInfoOf, + AccountListOf, +>; pub type EvaluationRoundInfoOf = EvaluationRoundInfo>; pub type VestingInfoOf = VestingInfo, BalanceOf>; pub type EvaluationInfoOf = EvaluationInfo, AccountIdOf, BalanceOf, BlockNumberOf>; @@ -478,12 +487,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn project_details)] /// StorageMap containing additional information for the projects, relevant for correctness of the protocol - pub type ProjectsDetails = StorageMap< - _, - Blake2_128Concat, - T::ProjectIdentifier, - ProjectDetails, BlockNumberOf, PriceOf, BalanceOf, EvaluationRoundInfoOf>, - >; + pub type ProjectsDetails = StorageMap<_, Blake2_128Concat, T::ProjectIdentifier, ProjectDetailsOf>; #[pallet::storage] #[pallet::getter(fn projects_to_update)] @@ -820,6 +824,16 @@ pub mod pallet { project_id: ProjectIdOf, migration_origins: BoundedVec>, }, + ReleaseFutureCTDepositFailed { + project_id: ProjectIdOf, + participant: AccountIdOf, + error: DispatchError, + }, + FutureCTDepositReleased { + project_id: ProjectIdOf, + participant: AccountIdOf, + caller: AccountIdOf, + }, } #[pallet::error] @@ -917,6 +931,8 @@ pub mod pallet { XcmFailed, // Tried to convert one type into another and failed. i.e try_into failed BadConversion, + /// Tried to release the PLMC deposit held for a future CT mint, but there was nothing to release + NoFutureDepositHeld, } #[pallet::call] @@ -1287,7 +1303,7 @@ pub mod pallet { let projects_needing_cleanup = ProjectsDetails::::iter() .filter_map(|(project_id, info)| match info.cleanup { - cleaner if cleaner.has_remaining_operations() => Some((project_id, cleaner)), + cleaner if > as DoRemainingOperation>::has_remaining_operations(&cleaner) => Some((project_id, cleaner)), _ => None, }) .collect::>(); @@ -1306,7 +1322,7 @@ pub mod pallet { // let mut consumed_weight = WeightInfoOf::::insert_cleaned_project(); let mut consumed_weight = Weight::from_parts(6_034_000, 0); while !consumed_weight.any_gt(max_weight_per_project) { - if let Ok(weight) = cleaner.do_one_operation::(project_id) { + if let Ok(weight) = > as DoRemainingOperation>::do_one_operation(&mut cleaner, project_id) { consumed_weight.saturating_accrue(weight); } else { break diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 030819115..f97f9b207 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -583,8 +583,9 @@ mod evaluation_round_failure { project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1, ); let evaluation_fail_amount = evaluation_min_success_amount - 100 * ASSET_UNIT; - let evaluator_bond = evaluation_fail_amount / 3; + let evaluator_bond = evaluation_fail_amount / 4; let evaluations = vec![ + UserToUSDBalance::new(EVALUATOR_1, evaluator_bond), UserToUSDBalance::new(EVALUATOR_1, evaluator_bond), UserToUSDBalance::new(EVALUATOR_2, evaluator_bond), UserToUSDBalance::new(EVALUATOR_3, evaluator_bond), @@ -635,12 +636,10 @@ mod evaluation_round_failure { inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::EvaluationFailed); - let final_plmc_amounts = required_plmc_bonds - .into_iter() - .map(|UserToPLMCBalance { account, plmc_amount }| { - UserToPLMCBalance::new(account, plmc_amount + MockInstantiator::get_ed() + deposit_required) - }) - .collect_vec(); + let final_plmc_amounts = MockInstantiator::generic_map_operation( + vec![required_plmc_bonds, plmc_existential_deposits, plmc_ct_account_deposits], + MergeOperation::Add, + ); inst.do_free_plmc_assertions(final_plmc_amounts); inst.do_reserved_plmc_assertions( vec![ diff --git a/pallets/funding/src/traits.rs b/pallets/funding/src/traits.rs index 8fc3d07a4..d1b1b30ab 100644 --- a/pallets/funding/src/traits.rs +++ b/pallets/funding/src/traits.rs @@ -17,11 +17,10 @@ pub trait ProvideStatemintPrice { fn get_price(asset_id: Self::AssetId) -> Option; } -pub trait DoRemainingOperation { +pub trait DoRemainingOperation { fn has_remaining_operations(&self) -> bool; - fn do_one_operation(&mut self, project_id: T::ProjectIdentifier) - -> Result; + fn do_one_operation(&mut self, project_id: T::ProjectIdentifier) -> Result; } #[cfg(feature = "runtime-benchmarks")] diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index 2292fd97a..d8c5e64b2 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -182,7 +182,14 @@ pub mod storage_types { } #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] - pub struct ProjectDetails { + pub struct ProjectDetails< + AccountId, + BlockNumber, + Price: FixedPointNumber, + Balance: BalanceT, + EvaluationRoundInfo, + AccountList, + > { pub issuer: AccountId, /// Whether the project is frozen, so no `metadata` changes are allowed. pub is_frozen: bool, @@ -199,7 +206,7 @@ pub mod storage_types { /// Funding reached amount in USD equivalent pub funding_amount_reached: Balance, /// Cleanup operations remaining - pub cleanup: Cleaner, + pub cleanup: Cleaner, /// Information about the total amount bonded, and the outcome in regards to reward/slash/nothing pub evaluation_round_info: EvaluationRoundInfo, /// When the Funding Round ends @@ -369,6 +376,7 @@ pub mod storage_types { pub mod inner_types { use super::*; use polimec_common::migration_types::{MigrationOrigin, Migrations}; + use sp_runtime::WeakBoundedVec; use xcm::v3::MaxDispatchErrorLen; #[derive(Default, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] @@ -610,7 +618,7 @@ pub mod inner_types { pub struct Failure; #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] - pub enum CleanerState { + pub enum CleanerState { Initialized(PhantomData), // Success or Failure EvaluationRewardOrSlash(u64, PhantomData), @@ -628,18 +636,19 @@ pub mod inner_types { BidUnbonding(u64, PhantomData), ContributionFundingRelease(u64, PhantomData), ContributionUnbonding(u64, PhantomData), + FutureDepositRelease(AccountList, PhantomData), // Merge // Success or Failure Finished(PhantomData), } #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] - pub enum Cleaner { + pub enum Cleaner { NotReady, - Success(CleanerState), - Failure(CleanerState), + Success(CleanerState), + Failure(CleanerState), } - impl TryFrom for Cleaner { + impl TryFrom for Cleaner { type Error = (); fn try_from(value: ProjectStatus) -> Result { From d978e062f1274e2566908776ac94434a048cab97 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 5 Dec 2023 17:32:01 +0100 Subject: [PATCH 059/212] starting to fix last tests --- pallets/funding/src/tests.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index f97f9b207..556ef8972 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -495,9 +495,18 @@ mod evaluation_round_success { let increased_amounts = MockInstantiator::generic_map_operation(vec![post_free_plmc, prev_free_plmc], MergeOperation::Subtract); + let slashed_amounts = MockInstantiator::slash_evaluator_balances(MockInstantiator::calculate_evaluation_plmc_spent(evaluations)); + let deposit_required = <::ContributionTokenCurrency as AccountTouch< + ProjectIdOf, + AccountIdOf, + >>::deposit_required(project_id); + + let expected_final_amounts = slashed_amounts.into_iter().map(|UserToPLMCBalance { account, plmc_amount }| UserToPLMCBalance::new(account, plmc_amount + deposit_required)).collect::>(); + + assert_eq!( increased_amounts, - MockInstantiator::slash_evaluator_balances(MockInstantiator::calculate_evaluation_plmc_spent(evaluations)) + expected_final_amounts ) } } @@ -519,7 +528,7 @@ mod evaluation_round_failure { let ct_account_deposits = plmc_eval_deposits.accounts().ct_account_deposits(); let expected_evaluator_balances = MockInstantiator::generic_map_operation( - vec![plmc_eval_deposits.clone(), plmc_existential_deposits.clone()], + vec![plmc_eval_deposits.clone(), plmc_existential_deposits.clone(), ct_account_deposits.clone()], MergeOperation::Add, ); @@ -5571,6 +5580,14 @@ mod remainder_round_failure { ], MergeOperation::Add, ); + let deposit_required = <::ContributionTokenCurrency as AccountTouch< + ProjectIdOf, + AccountIdOf, + >>::deposit_required(project_id); + let all_expected_payouts = all_expected_payouts + .into_iter() + .map(|UserToPLMCBalance{account, plmc_amount }| UserToPLMCBalance::new(account, plmc_amount + deposit_required)) + .collect::>(); let prev_issuer_funding_balance = inst.get_free_plmc_balances_for(vec![issuer.clone()])[0].plmc_amount; @@ -5600,7 +5617,7 @@ mod remainder_round_failure { let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; assert_eq!(issuer_funding_delta, 0); - assert_eq!(all_expected_payouts, all_participants_plmc_deltas); + assert_eq!(all_participants_plmc_deltas, all_expected_payouts); } #[test] From ab61caf8c9ecbd8e3f26fc0acfd5c248368f8679 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 6 Dec 2023 11:27:17 +0100 Subject: [PATCH 060/212] only evaluation automatic release working. `bids_and_community_and_remainder_contribution_plmc_bonded_is_returned_automatically_on_funding_fail` failing because of this --- pallets/funding/src/tests.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 556ef8972..904f1f71a 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -5584,6 +5584,7 @@ mod remainder_round_failure { ProjectIdOf, AccountIdOf, >>::deposit_required(project_id); + let ed = MockInstantiator::get_ed(); let all_expected_payouts = all_expected_payouts .into_iter() .map(|UserToPLMCBalance{account, plmc_amount }| UserToPLMCBalance::new(account, plmc_amount + deposit_required)) @@ -5616,6 +5617,11 @@ mod remainder_round_failure { let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; + let participants = all_participants_plmc_deltas.accounts(); + for participant in participants { + let future_deposit_reserved = inst.execute(||{<::NativeCurrency as fungible::InspectHold>>::balance_on_hold(&LockType::FutureDeposit(project_id), &participant)}); + dbg!("participant {:?} has future deposit reserved {:?}", participant, future_deposit_reserved); + } assert_eq!(issuer_funding_delta, 0); assert_eq!(all_participants_plmc_deltas, all_expected_payouts); } From b80d50df61d8b5adcd28950de0dffd2219dd3d13 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 6 Dec 2023 11:49:54 +0100 Subject: [PATCH 061/212] state machine fixed where it only worked on evaluations --- pallets/funding/src/impls.rs | 34 ++++++++++++++++++---------------- pallets/funding/src/tests.rs | 29 +++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/pallets/funding/src/impls.rs b/pallets/funding/src/impls.rs index 87f8acdbf..b11cefd07 100644 --- a/pallets/funding/src/impls.rs +++ b/pallets/funding/src/impls.rs @@ -171,8 +171,8 @@ impl DoRemainingOperation for CleanerState) => if *remaining == 0 { - *self = CleanerState::EvaluationUnbonding( - remaining_evaluations::(project_id), + *self = CleanerState::FutureDepositRelease( + remaining_participants::(project_id), PhantomData::, ); Ok(base_weight) @@ -182,6 +182,20 @@ impl DoRemainingOperation for CleanerState) => + if remaining_participants.is_empty() { + *self = CleanerState::EvaluationUnbonding( + remaining_evaluations::(project_id), + PhantomData::, + ); + Ok(base_weight) + } else { + let (consumed_weight, remaining_participants) = + release_future_ct_deposit_one_participant::(project_id, remaining_participants.clone()); + *self = CleanerState::FutureDepositRelease(remaining_participants, PhantomData::); + Ok(consumed_weight) + }, + CleanerState::EvaluationUnbonding(remaining, PhantomData::) => if *remaining == 0 { *self = CleanerState::BidFundingRelease( @@ -233,10 +247,7 @@ impl DoRemainingOperation for CleanerState) => if *remaining == 0 { - *self = CleanerState::FutureDepositRelease( - remaining_participants::(project_id), - PhantomData::, - ); + *self = CleanerState::Finished(PhantomData::); Ok(base_weight) } else { let (consumed_weight, remaining_contributions) = unbond_one_contribution::(project_id); @@ -244,16 +255,7 @@ impl DoRemainingOperation for CleanerState) => - if remaining_participants.is_empty() { - *self = CleanerState::Finished(PhantomData::); - Ok(base_weight) - } else { - let (consumed_weight, remaining_participants) = - release_future_ct_deposit_one_participant::(project_id, remaining_participants.clone()); - *self = CleanerState::FutureDepositRelease(remaining_participants, PhantomData::); - Ok(consumed_weight) - }, + CleanerState::Finished(PhantomData::) => Err(Error::::FinalizerFinished.into()), diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 904f1f71a..72018f498 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -1967,6 +1967,12 @@ mod auction_round_success { let final_price = details.weighted_average_price.unwrap(); let mut plmc_locked_for_bids = MockInstantiator::calculate_auction_plmc_spent(&bids, Some(final_price)); plmc_locked_for_bids.sort_by_key(|item| item.account.clone()); + let ct_deposit_required = <::ContributionTokenCurrency as AccountTouch< + ProjectIdOf, + AccountIdOf, + >>::deposit_required(project_id); + plmc_locked_for_bids.iter_mut().for_each(|item| item.plmc_amount += ct_deposit_required ); + assert_eq!(delta_bidders_plmc_balances, plmc_locked_for_bids); } @@ -3962,11 +3968,19 @@ mod community_round_failure { delta_contributors_plmc_balances.sort_by_key(|item| item.account); let final_price = details.weighted_average_price.unwrap(); + let ct_deposit_required = <::ContributionTokenCurrency as AccountTouch< + ProjectIdOf, + AccountIdOf, + >>::deposit_required(project_id); + let mut plmc_locked_for_bids = MockInstantiator::calculate_auction_plmc_spent(&bids, Some(final_price)); plmc_locked_for_bids.sort_by_key(|item| item.account); + plmc_locked_for_bids.iter_mut().for_each(|item| item.plmc_amount += ct_deposit_required); + let mut plmc_locked_for_contributions = MockInstantiator::calculate_contributed_plmc_spent(community_contributions, final_price); plmc_locked_for_contributions.sort_by_key(|item| item.account); + plmc_locked_for_contributions.iter_mut().for_each(|item| item.plmc_amount += ct_deposit_required); assert_eq!(delta_bidders_plmc_balances, plmc_locked_for_bids); assert_eq!(delta_contributors_plmc_balances, plmc_locked_for_contributions); @@ -6100,10 +6114,16 @@ mod funding_end { ); let slashed_evaluation_locked_plmc = MockInstantiator::slash_evaluator_balances(old_evaluation_locked_plmc); - let expected_evaluator_free_balances = MockInstantiator::generic_map_operation( + let mut expected_evaluator_free_balances = MockInstantiator::generic_map_operation( vec![slashed_evaluation_locked_plmc, old_participation_locked_plmc, old_free_plmc], MergeOperation::Add, ); + let ct_deposit_required = <::ContributionTokenCurrency as AccountTouch< + ProjectIdOf, + AccountIdOf, + >>::deposit_required(project_id); + expected_evaluator_free_balances.iter_mut().for_each(|UserToPLMCBalance{plmc_amount, ..}| *plmc_amount += ct_deposit_required); + let actual_evaluator_free_balances = inst.get_free_plmc_balances_for(evaluators.clone()); @@ -6135,10 +6155,15 @@ mod funding_end { ); let slashed_evaluation_locked_plmc = MockInstantiator::slash_evaluator_balances(old_evaluation_locked_plmc); - let expected_evaluator_free_balances = MockInstantiator::generic_map_operation( + let mut expected_evaluator_free_balances = MockInstantiator::generic_map_operation( vec![slashed_evaluation_locked_plmc, old_participation_locked_plmc, old_free_plmc], MergeOperation::Add, ); + let ct_deposit_required = <::ContributionTokenCurrency as AccountTouch< + ProjectIdOf, + AccountIdOf, + >>::deposit_required(project_id); + expected_evaluator_free_balances.iter_mut().for_each(|UserToPLMCBalance{plmc_amount, ..}| *plmc_amount += ct_deposit_required); let actual_evaluator_free_balances = inst.get_free_plmc_balances_for(evaluators.clone()); From 98280ae967167d6906e55768d653d36f4b4b60d8 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 6 Dec 2023 17:42:57 +0100 Subject: [PATCH 062/212] broken tests --- pallets/funding/src/functions.rs | 4 +- pallets/funding/src/impls.rs | 13 +- pallets/funding/src/lib.rs | 11 +- pallets/funding/src/tests.rs | 328 ++++++++++++++++++++++++++++--- 4 files changed, 317 insertions(+), 39 deletions(-) diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 0cea54bd5..0be152800 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -592,7 +592,9 @@ impl Pallet { // * Calculate new variables * let funding_target = project_metadata .minimum_price - .checked_mul_int(project_metadata.total_allocation_size.0) + .checked_mul_int( + project_metadata.total_allocation_size.0.saturating_add(project_metadata.total_allocation_size.1), + ) .ok_or(Error::::BadMath)?; let funding_reached = project_details.funding_amount_reached; let funding_ratio = Perquintill::from_rational(funding_reached, funding_target); diff --git a/pallets/funding/src/impls.rs b/pallets/funding/src/impls.rs index b11cefd07..45c022126 100644 --- a/pallets/funding/src/impls.rs +++ b/pallets/funding/src/impls.rs @@ -1,9 +1,8 @@ -use sp_std::collections::btree_set::BTreeSet; use frame_support::{traits::Get, weights::Weight}; use itertools::Itertools; use sp_arithmetic::traits::Zero; use sp_runtime::{traits::AccountIdConversion, DispatchError}; -use sp_std::marker::PhantomData; +use sp_std::{collections::btree_set::BTreeSet, marker::PhantomData}; use crate::{traits::DoRemainingOperation, *}; @@ -255,8 +254,6 @@ impl DoRemainingOperation for CleanerState) => Err(Error::::FinalizerFinished.into()), _ => Err(Error::::ImpossibleState.into()), @@ -346,9 +343,11 @@ fn remaining_participants(project_id: T::ProjectIdentifier) -> Accoun let bidders = Bids::::iter_key_prefix((project_id,)).map(|(bidder, bid_id)| bidder); let contributors = Contributions::::iter_key_prefix((project_id,)).map(|(contributor, contribution_id)| contributor); - let all_participants = - evaluators.chain(bidders).chain(contributors).collect::>>(); - AccountListOf::::force_from(all_participants.into_iter().collect_vec(), Some("getting remaining participants in Cleaner")) + let all_participants = evaluators.chain(bidders).chain(contributors).collect::>>(); + AccountListOf::::force_from( + all_participants.into_iter().collect_vec(), + Some("getting remaining participants in Cleaner"), + ) } fn remaining_bids_without_ct_minted(project_id: T::ProjectIdentifier) -> u64 { diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index cae7585a1..98e54f9b2 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1303,7 +1303,11 @@ pub mod pallet { let projects_needing_cleanup = ProjectsDetails::::iter() .filter_map(|(project_id, info)| match info.cleanup { - cleaner if > as DoRemainingOperation>::has_remaining_operations(&cleaner) => Some((project_id, cleaner)), + cleaner + if > as DoRemainingOperation>::has_remaining_operations( + &cleaner, + ) => + Some((project_id, cleaner)), _ => None, }) .collect::>(); @@ -1322,7 +1326,10 @@ pub mod pallet { // let mut consumed_weight = WeightInfoOf::::insert_cleaned_project(); let mut consumed_weight = Weight::from_parts(6_034_000, 0); while !consumed_weight.any_gt(max_weight_per_project) { - if let Ok(weight) = > as DoRemainingOperation>::do_one_operation(&mut cleaner, project_id) { + if let Ok(weight) = > as DoRemainingOperation>::do_one_operation( + &mut cleaner, + project_id, + ) { consumed_weight.saturating_accrue(weight); } else { break diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 72018f498..6638f7cb7 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -144,9 +144,9 @@ pub mod defaults { pub fn default_community_buys() -> Vec> { vec![ - ContributionParams::new(BUYER_1, 100 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_2, 200 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_3, 2000 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), + ContributionParams::new(BUYER_1, 8_100 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), + ContributionParams::new(BUYER_2, 17_000 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), + ContributionParams::new(BUYER_3, 20_000 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), ] } @@ -171,14 +171,21 @@ pub mod defaults { pub fn default_bidder_multipliers() -> Vec { vec![20u8, 3u8, 15u8, 13u8, 9u8] } - pub fn default_contributor_multipliers() -> Vec { + pub fn default_community_contributor_multipliers() -> Vec { vec![1u8, 5u8, 3u8, 1u8, 2u8] } + pub fn default_remainder_contributor_multipliers() -> Vec { + vec![1u8, 10u8, 3u8, 2u8, 4u8] + } - pub fn default_contributors() -> Vec { + pub fn default_community_contributors() -> Vec { vec![BUYER_1, BUYER_2, BUYER_3, BUYER_4, BUYER_5] } + pub fn default_remainder_contributors() -> Vec { + vec![EVALUATOR_1, BIDDER_3, BUYER_4, BUYER_6, BIDDER_6] + } + pub fn project_from_funding_reached(instantiator: &mut MockInstantiator, percent: u64) -> ProjectIdOf { let project_metadata = default_project(instantiator.get_new_nonce(), ISSUER); let min_price = project_metadata.minimum_price; @@ -196,7 +203,7 @@ pub mod defaults { Percent::from_percent(50u8) * usd_to_reach, min_price, default_weights(), - default_contributors(), + default_community_contributors(), default_multipliers(), ); instantiator.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]) @@ -441,8 +448,10 @@ mod evaluation_round_success { let prev_free_plmc = inst.get_free_plmc_balances_for(evaluators.clone()); inst.finish_funding(project_id).unwrap(); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - + inst.advance_time(::ManualAcceptanceDuration::get() + 1).unwrap(); + inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingSuccessful); + assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); inst.advance_time(10).unwrap(); let post_unbond_amounts: Vec> = prev_reserved_plmc .iter() @@ -495,19 +504,21 @@ mod evaluation_round_success { let increased_amounts = MockInstantiator::generic_map_operation(vec![post_free_plmc, prev_free_plmc], MergeOperation::Subtract); - let slashed_amounts = MockInstantiator::slash_evaluator_balances(MockInstantiator::calculate_evaluation_plmc_spent(evaluations)); + let slashed_amounts = + MockInstantiator::slash_evaluator_balances(MockInstantiator::calculate_evaluation_plmc_spent(evaluations)); let deposit_required = <::ContributionTokenCurrency as AccountTouch< ProjectIdOf, AccountIdOf, >>::deposit_required(project_id); - let expected_final_amounts = slashed_amounts.into_iter().map(|UserToPLMCBalance { account, plmc_amount }| UserToPLMCBalance::new(account, plmc_amount + deposit_required)).collect::>(); - + let expected_final_amounts = slashed_amounts + .into_iter() + .map(|UserToPLMCBalance { account, plmc_amount }| { + UserToPLMCBalance::new(account, plmc_amount + deposit_required) + }) + .collect::>(); - assert_eq!( - increased_amounts, - expected_final_amounts - ) + assert_eq!(increased_amounts, expected_final_amounts) } } @@ -1971,8 +1982,7 @@ mod auction_round_success { ProjectIdOf, AccountIdOf, >>::deposit_required(project_id); - plmc_locked_for_bids.iter_mut().for_each(|item| item.plmc_amount += ct_deposit_required ); - + plmc_locked_for_bids.iter_mut().for_each(|item| item.plmc_amount += ct_deposit_required); assert_eq!(delta_bidders_plmc_balances, plmc_locked_for_bids); } @@ -2359,6 +2369,69 @@ mod auction_round_failure { project_id, ); } + + #[test] + fn bid_ct_account_deposits_are_returned() { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let project_metadata = default_project(0, ISSUER); + let automatic_fail_funding_percent = Percent::from_percent(30); + let (bid_allocation, contribution_allocation) = project_metadata.total_allocation_size; + let deposit_required = <::ContributionTokenCurrency as AccountTouch< + ProjectIdOf, + AccountIdOf, + >>::deposit_required(0); + + let desired_total_usd_amount_bid = + automatic_fail_funding_percent * project_metadata.minimum_price.saturating_mul_int(bid_allocation); + + let bids = MockInstantiator::generate_bids_from_total_usd( + desired_total_usd_amount_bid, + project_metadata.minimum_price, + default_weights(), + default_bidders(), + default_multipliers(), + ); + + let zero_balances = + bids.clone().accounts().into_iter().map(|acc| UserToPLMCBalance::new(acc, 0u128)).collect_vec(); + inst.do_free_plmc_assertions(zero_balances.clone()); + inst.do_reserved_plmc_assertions(zero_balances.clone(), LockType::FutureDeposit(0)); + + let required_plmc_bonds = MockInstantiator::calculate_auction_plmc_spent(&bids, None); + let plmc_existential_deposits = required_plmc_bonds.accounts().existential_deposits(); + let plmc_ct_account_deposits = required_plmc_bonds.accounts().ct_account_deposits(); + + let (project_id, _) = + inst.create_community_contributing_project(project_metadata, ISSUER, default_evaluations(), bids.clone()); + + let ed_balances = required_plmc_bonds + .accounts() + .into_iter() + .map(|acc| UserToPLMCBalance::new(acc, MockInstantiator::get_ed())) + .collect_vec(); + inst.do_free_plmc_assertions(ed_balances); + let ct_deposit_balances = required_plmc_bonds + .accounts() + .into_iter() + .map(|acc| UserToPLMCBalance::new(acc, deposit_required)) + .collect_vec(); + inst.do_reserved_plmc_assertions(ct_deposit_balances, LockType::FutureDeposit(project_id)); + + inst.advance_time(::CommunityFundingDuration::get() + 1).unwrap(); + inst.advance_time(::RemainderFundingDuration::get() + 1).unwrap(); + + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingFailed); + + inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); + assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Failure(CleanerState::Finished(PhantomData))); + + let final_plmc_amounts = MockInstantiator::generic_map_operation( + vec![required_plmc_bonds, plmc_existential_deposits, plmc_ct_account_deposits], + MergeOperation::Add, + ); + inst.do_free_plmc_assertions(final_plmc_amounts); + inst.do_reserved_plmc_assertions(zero_balances, LockType::FutureDeposit(project_id)); + } } mod community_round_success { @@ -4100,6 +4173,90 @@ mod community_round_failure { assert_eq!(delta_bidders_plmc_balances, plmc_locked_for_bids); assert_eq!(delta_contributors_plmc_balances, plmc_locked_for_contributions); } + + #[test] + fn community_contribution_ct_account_deposits_are_returned() { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let project_metadata = default_project(0, ISSUER); + let automatic_fail_funding_percent = Percent::from_percent(30); + let (bid_allocation, contribution_allocation) = project_metadata.total_allocation_size; + let deposit_required = <::ContributionTokenCurrency as AccountTouch< + ProjectIdOf, + AccountIdOf, + >>::deposit_required(0); + + let desired_total_usd_amount_bid = + automatic_fail_funding_percent * project_metadata.minimum_price.saturating_mul_int(bid_allocation); + let desired_total_usd_amount_contributed = + automatic_fail_funding_percent * project_metadata.minimum_price.saturating_mul_int(contribution_allocation); + + let bids = MockInstantiator::generate_bids_from_total_usd( + desired_total_usd_amount_bid, + project_metadata.minimum_price, + default_weights(), + default_bidders(), + default_bidder_multipliers(), + ); + + let community_contributions = MockInstantiator::generate_contributions_from_total_usd( + desired_total_usd_amount_contributed, + project_metadata.minimum_price, + default_weights(), + default_community_contributors(), + default_community_contributor_multipliers(), + ); + + let zero_balances = community_contributions + .clone() + .accounts() + .into_iter() + .map(|acc| UserToPLMCBalance::new(acc, 0u128)) + .collect_vec(); + inst.do_free_plmc_assertions(zero_balances.clone()); + inst.do_reserved_plmc_assertions(zero_balances.clone(), LockType::FutureDeposit(0)); + + let (project_id, _) = inst.create_remainder_contributing_project( + project_metadata, + ISSUER, + default_evaluations(), + bids.clone(), + community_contributions.clone(), + ); + + let required_plmc_bonds = MockInstantiator::calculate_contributed_plmc_spent( + community_contributions, + inst.get_project_details(project_id).weighted_average_price.unwrap(), + ); + let plmc_existential_deposits = required_plmc_bonds.accounts().existential_deposits(); + let plmc_ct_account_deposits = required_plmc_bonds.accounts().ct_account_deposits(); + + let ed_balances = required_plmc_bonds + .accounts() + .into_iter() + .map(|acc| UserToPLMCBalance::new(acc, MockInstantiator::get_ed())) + .collect_vec(); + inst.do_free_plmc_assertions(ed_balances); + let ct_deposit_balances = required_plmc_bonds + .accounts() + .into_iter() + .map(|acc| UserToPLMCBalance::new(acc, deposit_required)) + .collect_vec(); + inst.do_reserved_plmc_assertions(ct_deposit_balances, LockType::FutureDeposit(project_id)); + + inst.advance_time(::RemainderFundingDuration::get() + 1).unwrap(); + + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingFailed); + + inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); + assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Failure(CleanerState::Finished(PhantomData))); + + let final_plmc_amounts = MockInstantiator::generic_map_operation( + vec![required_plmc_bonds, plmc_existential_deposits, plmc_ct_account_deposits], + MergeOperation::Add, + ); + inst.do_free_plmc_assertions(final_plmc_amounts); + inst.do_reserved_plmc_assertions(zero_balances, LockType::FutureDeposit(project_id)); + } } mod remainder_round_success { @@ -5601,7 +5758,9 @@ mod remainder_round_failure { let ed = MockInstantiator::get_ed(); let all_expected_payouts = all_expected_payouts .into_iter() - .map(|UserToPLMCBalance{account, plmc_amount }| UserToPLMCBalance::new(account, plmc_amount + deposit_required)) + .map(|UserToPLMCBalance { account, plmc_amount }| { + UserToPLMCBalance::new(account, plmc_amount + deposit_required) + }) .collect::>(); let prev_issuer_funding_balance = inst.get_free_plmc_balances_for(vec![issuer.clone()])[0].plmc_amount; @@ -5810,6 +5969,114 @@ mod remainder_round_failure { assert_eq!(issuer_funding_delta, 0); assert_eq!(all_expected_payouts, all_participants_plmc_deltas); } + + #[test] + fn remainder_contribution_ct_account_deposits_are_returned() { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let project_metadata = default_project(0, ISSUER); + let automatic_fail_funding_percent = Percent::from_percent(30); + let (bid_allocation, contribution_allocation) = project_metadata.total_allocation_size; + let deposit_required = <::ContributionTokenCurrency as AccountTouch< + ProjectIdOf, + AccountIdOf, + >>::deposit_required(0); + + let remainder_contributors = vec![EVALUATOR_1, BIDDER_3, BUYER_4, BUYER_6, BIDDER_6]; + + let desired_total_usd_amount_bid = + automatic_fail_funding_percent * project_metadata.minimum_price.saturating_mul_int(bid_allocation); + let desired_total_usd_amount_contributed = + automatic_fail_funding_percent * project_metadata.minimum_price.saturating_mul_int(contribution_allocation); + + let bids = MockInstantiator::generate_bids_from_total_usd( + desired_total_usd_amount_bid, + project_metadata.minimum_price, + default_weights(), + default_bidders(), + default_bidder_multipliers(), + ); + + let community_contributions = MockInstantiator::generate_contributions_from_total_usd( + desired_total_usd_amount_contributed / 2, + project_metadata.minimum_price, + default_weights(), + default_community_contributors(), + default_community_contributor_multipliers(), + ); + + let remainder_contributions = MockInstantiator::generate_contributions_from_total_usd( + desired_total_usd_amount_contributed / 2, + project_metadata.minimum_price, + default_weights(), + default_remainder_contributors(), + default_remainder_contributor_multipliers(), + ); + + let zero_balances = remainder_contributions + .clone() + .accounts() + .into_iter() + .map(|acc| UserToPLMCBalance::new(acc, 0u128)) + .collect_vec(); + inst.do_free_plmc_assertions(zero_balances.clone()); + inst.do_reserved_plmc_assertions(zero_balances.clone(), LockType::FutureDeposit(0)); + + let project_id = inst.create_finished_project( + project_metadata, + ISSUER, + default_evaluations(), + bids.clone(), + community_contributions.clone(), + remainder_contributions.clone(), + ); + let wap = inst.get_project_details(project_id).weighted_average_price.unwrap(); + + let bidder_plmc_bonds = MockInstantiator::calculate_auction_plmc_spent(&bids, Some(wap)); + let community_contributor_plmc_bonds = MockInstantiator::calculate_contributed_plmc_spent( + community_contributions.clone(), + wap, + ); + let evaluators_and_contributors_plmc_bonds = MockInstantiator::calculate_total_plmc_locked_from_evaluations_and_remainder_contributions( + default_evaluations(), + remainder_contributions, + wap, + true, + ); + + let mut expected_final_plmc_balances = MockInstantiator::generic_map_operation( + vec![ + bidder_plmc_bonds, + community_contributor_plmc_bonds, + evaluators_and_contributors_plmc_bonds, + ], + MergeOperation::Add, + ); + expected_final_plmc_balances.iter_mut().for_each(|UserToPLMCBalance { account, plmc_amount }| { + *plmc_amount += deposit_required; + }); + + let prev_balances = inst.get_free_plmc_balances_for(expected_final_plmc_balances.accounts()); + let ct_deposit_balances = expected_final_plmc_balances + .accounts() + .into_iter() + .map(|acc| UserToPLMCBalance::new(acc, deposit_required)) + .collect_vec(); + inst.do_reserved_plmc_assertions(ct_deposit_balances, LockType::FutureDeposit(project_id)); + + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingFailed); + inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); + assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Failure(CleanerState::Finished(PhantomData))); + + let post_balances = inst.get_free_plmc_balances_for(expected_final_plmc_balances.accounts()); + + let plmc_deltas = MockInstantiator::generic_map_operation( + vec![post_balances, prev_balances], + MergeOperation::Subtract, + ); + + assert_eq!(plmc_deltas, expected_final_plmc_balances); + inst.do_reserved_plmc_assertions(zero_balances, LockType::FutureDeposit(project_id)); + } } mod funding_end { @@ -5835,7 +6102,7 @@ mod funding_end { Percent::from_percent(50u8) * twenty_percent_funding_usd, min_price, default_weights(), - default_contributors(), + default_community_contributors(), default_multipliers(), ); let project_id = @@ -5864,7 +6131,7 @@ mod funding_end { Percent::from_percent(50u8) * twenty_percent_funding_usd, min_price, default_weights(), - default_contributors(), + default_community_contributors(), default_multipliers(), ); let project_id = @@ -5893,7 +6160,7 @@ mod funding_end { Percent::from_percent(50u8) * twenty_percent_funding_usd, min_price, default_weights(), - default_contributors(), + default_community_contributors(), default_multipliers(), ); let project_id = @@ -5921,7 +6188,7 @@ mod funding_end { Percent::from_percent(50u8) * twenty_percent_funding_usd, min_price, default_weights(), - default_contributors(), + default_community_contributors(), default_multipliers(), ); let project_id = @@ -5967,7 +6234,7 @@ mod funding_end { Percent::from_percent(50u8) * twenty_percent_funding_usd, min_price, default_weights(), - default_contributors(), + default_community_contributors(), default_multipliers(), ); let project_id = @@ -6017,7 +6284,7 @@ mod funding_end { Percent::from_percent(50u8) * twenty_percent_funding_usd, min_price, default_weights(), - default_contributors(), + default_community_contributors(), default_multipliers(), ); let project_id = @@ -6122,8 +6389,9 @@ mod funding_end { ProjectIdOf, AccountIdOf, >>::deposit_required(project_id); - expected_evaluator_free_balances.iter_mut().for_each(|UserToPLMCBalance{plmc_amount, ..}| *plmc_amount += ct_deposit_required); - + expected_evaluator_free_balances + .iter_mut() + .for_each(|UserToPLMCBalance { plmc_amount, .. }| *plmc_amount += ct_deposit_required); let actual_evaluator_free_balances = inst.get_free_plmc_balances_for(evaluators.clone()); @@ -6163,7 +6431,9 @@ mod funding_end { ProjectIdOf, AccountIdOf, >>::deposit_required(project_id); - expected_evaluator_free_balances.iter_mut().for_each(|UserToPLMCBalance{plmc_amount, ..}| *plmc_amount += ct_deposit_required); + expected_evaluator_free_balances + .iter_mut() + .for_each(|UserToPLMCBalance { plmc_amount, .. }| *plmc_amount += ct_deposit_required); let actual_evaluator_free_balances = inst.get_free_plmc_balances_for(evaluators.clone()); @@ -6233,8 +6503,8 @@ mod funding_end { contributing_allocation / 2, project_metadata.minimum_price, default_weights(), - default_contributors(), - default_contributor_multipliers(), + default_community_contributors(), + default_community_contributor_multipliers(), ); let remainder_contributions = MockInstantiator::generate_contributions_from_total_usd( contributing_allocation / 2, From 9370b2c44ec508c0f991e5bfc8e30344c1b84927 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 7 Dec 2023 12:21:22 +0100 Subject: [PATCH 063/212] save --- pallets/funding/src/tests.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 6638f7cb7..faa85d29c 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -1571,15 +1571,9 @@ mod auction_round_success { let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); let evaluations = default_evaluations(); - let bids = MockInstantiator::generate_bids_from_total_usd( - project.total_allocation_size.0, - project.minimum_price, - default_weights(), - default_bidders(), - default_multipliers(), - ); - let community_contributions = vec![]; - let remainder_contributions = vec![]; + let bids = default_bids(); + let community_contributions = default_community_buys(); + let remainder_contributions = default_remainder_buys(); let project_id = inst.create_finished_project( project, @@ -1589,6 +1583,7 @@ mod auction_round_success { community_contributions, remainder_contributions, ); + let final_bid_payouts = inst.execute(|| { Bids::::iter_prefix_values((project_id,)) .map(|bid| { @@ -1600,6 +1595,17 @@ mod auction_round_success { }) .collect::>>() }); + let final_contribution_payouts = inst.execute(|| { + Contributions::::iter_prefix_values((project_id,)) + .map(|contribution| { + UserToStatemintAsset::::new( + contribution.contributor, + contribution.funding_asset_amount, + contribution.funding_asset.to_statemint_id(), + ) + }) + .collect::>>() + }); let total_expected_bid_payout = final_bid_payouts.iter().map(|bid| bid.asset_amount).sum::>(); From fe2ba747c080ff502640f85630ba122aa18cee92 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 7 Dec 2023 17:55:06 +0100 Subject: [PATCH 064/212] manual and automatic ct mint tests now passing. Removed the specific ones for just bids/evals/contr. and merged them all into 1 for manual and one for automatic --- integration-tests/src/tests/ct_migration.rs | 5 + pallets/funding/src/tests.rs | 1218 +++++++------------ 2 files changed, 476 insertions(+), 747 deletions(-) diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index 04c41f25c..d0b6a9f8d 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -555,3 +555,8 @@ fn disallow_duplicated_migrations_on_receiver_pallet() { migrations_are_vested(grouped_migrations.clone()); } + +#[test] +fn failing_bid_doesnt_get_migrated() { + todo!(); +} diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index faa85d29c..77a8beecf 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -1072,116 +1072,6 @@ mod auction_round_success { assert_eq!(bidder_5_bid.final_ct_usd_price, wabgp); } - #[test] - fn ct_minted_for_bids_automatically() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = default_evaluations(); - let bids = default_bids(); - let community_contributions = default_community_buys(); - let remainder_contributions = vec![]; - - let project_id = inst.create_finished_project( - project, - issuer, - evaluations, - bids.clone(), - community_contributions, - remainder_contributions, - ); - let details = inst.get_project_details(project_id); - assert_eq!(details.status, ProjectStatus::FundingSuccessful); - assert_eq!(details.cleanup, Cleaner::NotReady); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - inst.advance_time(10u64).unwrap(); - let details = inst.get_project_details(project_id); - assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); - - let stored_bids = inst.execute(|| Bids::::iter_prefix_values((project_id,)).collect::>()); - assert_eq!(stored_bids.len(), bids.len()); - let user_ct_amounts = MockInstantiator::generic_map_merge_reduce( - vec![stored_bids], - |bid| bid.bidder, - BalanceOf::::zero(), - |bid, acc| acc + bid.final_ct_amount, - ); - assert_eq!(user_ct_amounts.len(), bids.len()); - - for (bidder, amount) in user_ct_amounts { - let minted = - inst.execute(|| ::ContributionTokenCurrency::balance(project_id, bidder)); - assert_eq!(minted, amount); - } - } - - #[test] - fn ct_minted_for_bids_manually() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = default_evaluations(); - let bids = default_bids(); - let community_contributions = default_community_buys(); - let remainder_contributions = vec![]; - - let project_id = inst.create_finished_project( - project, - issuer, - evaluations, - bids.clone(), - community_contributions, - remainder_contributions, - ); - let details = inst.get_project_details(project_id); - assert_eq!(details.status, ProjectStatus::FundingSuccessful); - assert_eq!(details.cleanup, Cleaner::NotReady); - let stored_bids = inst.execute(|| Bids::::iter_prefix_values((project_id,)).collect::>()); - - for bid in stored_bids.clone() { - inst.execute(|| { - assert_noop!( - Pallet::::bid_ct_mint_for( - RuntimeOrigin::signed(bid.bidder), - project_id, - bid.bidder, - bid.id, - ), - Error::::CannotClaimYet - ); - }) - } - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - let details = inst.get_project_details(project_id); - assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData))); - - for bid in stored_bids.clone() { - inst.execute(|| { - Pallet::::bid_ct_mint_for( - RuntimeOrigin::signed(bid.bidder), - project_id, - bid.bidder, - bid.id, - ) - .unwrap() - }); - } - - assert_eq!(stored_bids.len(), bids.len()); - let user_ct_amounts = MockInstantiator::generic_map_merge_reduce( - vec![stored_bids], - |bid| bid.bidder, - BalanceOf::::zero(), - |bid, acc| acc + bid.final_ct_amount, - ); - assert_eq!(user_ct_amounts.len(), bids.len()); - - for (bidder, amount) in user_ct_amounts { - let minted = - inst.execute(|| ::ContributionTokenCurrency::balance(project_id, bidder)); - assert_eq!(minted, amount); - } - } #[test] pub fn cannot_mint_ct_twice_manually() { @@ -1585,63 +1475,55 @@ mod auction_round_success { ); let final_bid_payouts = inst.execute(|| { - Bids::::iter_prefix_values((project_id,)) - .map(|bid| { - UserToStatemintAsset::::new( - bid.bidder, - bid.funding_asset_amount_locked, - bid.funding_asset.to_statemint_id(), - ) - }) - .collect::>>() + Bids::::iter_prefix_values((project_id,)).map(|bid| { + UserToStatemintAsset::::new( + bid.bidder, + bid.funding_asset_amount_locked, + bid.funding_asset.to_statemint_id(), + ) + }) }); let final_contribution_payouts = inst.execute(|| { - Contributions::::iter_prefix_values((project_id,)) - .map(|contribution| { - UserToStatemintAsset::::new( - contribution.contributor, - contribution.funding_asset_amount, - contribution.funding_asset.to_statemint_id(), - ) - }) - .collect::>>() + Contributions::::iter_prefix_values((project_id,)).map(|contribution| { + UserToStatemintAsset::::new( + contribution.contributor, + contribution.funding_asset_amount, + contribution.funding_asset.to_statemint_id(), + ) + }) }); - let total_expected_bid_payout = - final_bid_payouts.iter().map(|bid| bid.asset_amount).sum::>(); + let expected_payouts = inst.execute(|| final_bid_payouts.chain(final_contribution_payouts).collect_vec()); + let total_expected_payouts = + expected_payouts.iter().map(|item| item.asset_amount).sum::>(); + let asset_id = AcceptedFundingAsset::USDT.to_statemint_id(); - let prev_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; + let prev_issuer_funding_balance = + inst.get_free_statemint_asset_balances_for(asset_id, vec![issuer.clone()])[0].asset_amount; let prev_bidders_funding_balances = - inst.get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, final_bid_payouts.accounts()); + inst.get_free_statemint_asset_balances_for(asset_id, expected_payouts.accounts()); let prev_total_bidder_balance = prev_bidders_funding_balances.iter().map(|item| item.asset_amount).sum::>(); - let prev_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; + let prev_project_pot_funding_balance = inst + .get_free_statemint_asset_balances_for(asset_id, vec![Pallet::::fund_account_id(project_id)])[0] + .asset_amount; inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); - let post_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; + let post_issuer_funding_balance = + inst.get_free_statemint_asset_balances_for(asset_id, vec![issuer.clone()])[0].asset_amount; let post_bidders_funding_balances = - inst.get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, final_bid_payouts.accounts()); + inst.get_free_statemint_asset_balances_for(asset_id, expected_payouts.accounts()); let post_total_bidder_balance = post_bidders_funding_balances.iter().map(|item| item.asset_amount).sum::>(); - let post_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; + let post_project_pot_funding_balance = inst + .get_free_statemint_asset_balances_for(asset_id, vec![Pallet::::fund_account_id(project_id)])[0] + .asset_amount; let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; let project_pot_funding_delta = prev_project_pot_funding_balance - post_project_pot_funding_balance; - assert_eq!(issuer_funding_delta, total_expected_bid_payout); + assert_eq!(issuer_funding_delta, total_expected_payouts); assert_eq!(issuer_funding_delta, project_pot_funding_delta); assert_eq!(prev_total_bidder_balance, 0u128); @@ -1662,8 +1544,8 @@ mod auction_round_success { default_bidders(), default_multipliers(), ); - let community_contributions = vec![]; - let remainder_contributions = vec![]; + let community_contributions = default_community_buys(); + let remainder_contributions = default_remainder_buys(); let project_id = inst.create_finished_project( project, @@ -3074,7 +2956,7 @@ mod community_round_success { } #[test] - fn ct_minted_for_community_buys_automatically() { + pub fn cannot_mint_ct_twice_manually() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); @@ -3094,31 +2976,38 @@ mod community_round_success { let details = inst.get_project_details(project_id); assert_eq!(details.status, ProjectStatus::FundingSuccessful); assert_eq!(details.cleanup, Cleaner::NotReady); + let stored_contributions = + inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - inst.advance_time(10u64).unwrap(); + let details = inst.get_project_details(project_id); - assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); + assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData))); - let stored_community_buys = - inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); - assert_eq!(stored_community_buys.len(), community_contributions.len()); - let user_ct_amounts = MockInstantiator::generic_map_merge_reduce( - vec![stored_community_buys], - |contribution| contribution.contributor, - BalanceOf::::zero(), - |contribution, acc| acc + contribution.ct_amount, - ); - assert_eq!(user_ct_amounts.len(), community_contributions.len()); + for contribution in stored_contributions.clone() { + inst.execute(|| { + Pallet::::contribution_ct_mint_for( + RuntimeOrigin::signed(contribution.contributor), + project_id, + contribution.contributor, + contribution.id, + ) + .unwrap(); - for (contributor, amount) in user_ct_amounts { - let minted = - inst.execute(|| ::ContributionTokenCurrency::balance(project_id, contributor)); - assert_eq!(minted, amount); + assert_noop!( + Pallet::::contribution_ct_mint_for( + RuntimeOrigin::signed(contribution.contributor), + project_id, + contribution.contributor, + contribution.id, + ), + Error::::NotAllowed + ); + }); } } #[test] - fn ct_minted_for_community_buys_manually() { + pub fn cannot_mint_ct_manually_after_automatic_mint() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); @@ -3138,42 +3027,17 @@ mod community_round_success { let details = inst.get_project_details(project_id); assert_eq!(details.status, ProjectStatus::FundingSuccessful); assert_eq!(details.cleanup, Cleaner::NotReady); - let stored_contributions = - inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); - - for contribution in stored_contributions.clone() { - inst.execute(|| { - assert_noop!( - Pallet::::contribution_ct_mint_for( - RuntimeOrigin::signed(contribution.contributor), - project_id, - contribution.contributor, - contribution.id, - ), - Error::::CannotClaimYet - ); - }) - } inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + inst.advance_time(10u64).unwrap(); let details = inst.get_project_details(project_id); - assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData))); - - for contribution in stored_contributions.clone() { - inst.execute(|| { - Pallet::::contribution_ct_mint_for( - RuntimeOrigin::signed(contribution.contributor), - project_id, - contribution.contributor, - contribution.id, - ) - .unwrap() - }); - } + assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); + let stored_contributions = + inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); assert_eq!(stored_contributions.len(), community_contributions.len()); let user_ct_amounts = MockInstantiator::generic_map_merge_reduce( - vec![stored_contributions], + vec![stored_contributions.clone()], |contribution| contribution.contributor, BalanceOf::::zero(), |contribution, acc| acc + contribution.ct_amount, @@ -3185,10 +3049,24 @@ mod community_round_success { inst.execute(|| ::ContributionTokenCurrency::balance(project_id, contributor)); assert_eq!(minted, amount); } + + for contribution in stored_contributions.clone() { + inst.execute(|| { + assert_noop!( + Pallet::::contribution_ct_mint_for( + RuntimeOrigin::signed(contribution.contributor), + project_id, + contribution.contributor, + contribution.id, + ), + Error::::NotAllowed + ); + }) + } } #[test] - pub fn cannot_mint_ct_twice_manually() { + pub fn plmc_vesting_schedule_starts_automatically() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); @@ -3205,122 +3083,12 @@ mod community_round_success { community_contributions.clone(), remainder_contributions, ); - let details = inst.get_project_details(project_id); - assert_eq!(details.status, ProjectStatus::FundingSuccessful); - assert_eq!(details.cleanup, Cleaner::NotReady); - let stored_contributions = - inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - let details = inst.get_project_details(project_id); - assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData))); - - for contribution in stored_contributions.clone() { - inst.execute(|| { - Pallet::::contribution_ct_mint_for( - RuntimeOrigin::signed(contribution.contributor), - project_id, - contribution.contributor, - contribution.id, - ) - .unwrap(); - - assert_noop!( - Pallet::::contribution_ct_mint_for( - RuntimeOrigin::signed(contribution.contributor), - project_id, - contribution.contributor, - contribution.id, - ), - Error::::NotAllowed - ); - }); - } - } - - #[test] - pub fn cannot_mint_ct_manually_after_automatic_mint() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = default_evaluations(); - let bids = default_bids(); - let community_contributions = default_community_buys(); - let remainder_contributions = vec![]; - - let project_id = inst.create_finished_project( - project, - issuer, - evaluations, - bids, - community_contributions.clone(), - remainder_contributions, - ); - let details = inst.get_project_details(project_id); - assert_eq!(details.status, ProjectStatus::FundingSuccessful); - assert_eq!(details.cleanup, Cleaner::NotReady); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - - inst.advance_time(10u64).unwrap(); - let details = inst.get_project_details(project_id); - assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); - - let stored_contributions = - inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); - assert_eq!(stored_contributions.len(), community_contributions.len()); - let user_ct_amounts = MockInstantiator::generic_map_merge_reduce( - vec![stored_contributions.clone()], - |contribution| contribution.contributor, - BalanceOf::::zero(), - |contribution, acc| acc + contribution.ct_amount, - ); - assert_eq!(user_ct_amounts.len(), community_contributions.len()); - - for (contributor, amount) in user_ct_amounts { - let minted = - inst.execute(|| ::ContributionTokenCurrency::balance(project_id, contributor)); - assert_eq!(minted, amount); - } - - for contribution in stored_contributions.clone() { - inst.execute(|| { - assert_noop!( - Pallet::::contribution_ct_mint_for( - RuntimeOrigin::signed(contribution.contributor), - project_id, - contribution.contributor, - contribution.id, - ), - Error::::NotAllowed - ); - }) - } - } - - #[test] - pub fn plmc_vesting_schedule_starts_automatically() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = default_evaluations(); - let bids = default_bids(); - let community_contributions = default_community_buys(); - let remainder_contributions = vec![]; - - let project_id = inst.create_finished_project( - project, - issuer, - evaluations, - bids, - community_contributions.clone(), - remainder_contributions, - ); - - let price = inst.get_project_details(project_id).weighted_average_price.unwrap(); - let contribution_locked_plmc = - MockInstantiator::calculate_contributed_plmc_spent(community_contributions, price); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - inst.advance_time(10u64).unwrap(); + let price = inst.get_project_details(project_id).weighted_average_price.unwrap(); + let contribution_locked_plmc = + MockInstantiator::calculate_contributed_plmc_spent(community_contributions, price); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + inst.advance_time(10u64).unwrap(); let details = inst.get_project_details(project_id); assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); @@ -3730,19 +3498,23 @@ mod community_round_failure { let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); let evaluations = default_evaluations(); + + let fail_percentage = Percent::from_percent(30u8); let bids = MockInstantiator::generate_bids_from_total_usd( - project.total_allocation_size.0 / 2, + fail_percentage * project.total_allocation_size.0, project.minimum_price, default_weights(), default_bidders(), default_multipliers(), ); - let community_contributions = vec![ - ContributionParams::new(BUYER_1, 1_000 * ASSET_UNIT, 2u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_2, 500 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_3, 73 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ]; + let community_contributions = MockInstantiator::generate_contributions_from_total_usd( + fail_percentage * project.total_allocation_size.1, + project.minimum_price, + default_weights(), + default_community_contributors(), + default_multipliers(), + ); let remainder_contributions = vec![]; let project_id = inst.create_finished_project( @@ -3787,14 +3559,6 @@ mod community_round_failure { let prev_total_bidder_balance = prev_bidders_funding_balances.iter().map(|item| item.asset_amount).sum::>(); - call_and_is_ok!( - inst, - Pallet::::decide_project_outcome( - RuntimeOrigin::signed(issuer), - project_id, - FundingOutcomeDecision::RejectFunding - ) - ); inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); inst.advance_time(10).unwrap(); assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Failure(CleanerState::Finished(PhantomData))); @@ -4514,7 +4278,7 @@ mod remainder_round_success { } #[test] - fn ct_minted_for_remainder_buys_automatically() { + pub fn cannot_mint_ct_twice_manually() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); @@ -4523,64 +4287,6 @@ mod remainder_round_success { let community_contributions = default_community_buys(); let remainder_contributions = default_remainder_buys(); - let project_id = inst.create_finished_project( - project, - issuer, - evaluations, - bids, - community_contributions, - remainder_contributions.clone(), - ); - let details = inst.get_project_details(project_id); - assert_eq!(details.status, ProjectStatus::FundingSuccessful); - assert_eq!(details.cleanup, Cleaner::NotReady); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - - inst.advance_time(10u64).unwrap(); - let details = inst.get_project_details(project_id); - assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); - - let evaluator_2_reward = extract_from_event!( - &mut inst, - Event::::EvaluationRewarded { evaluator: EVALUATOR_2, amount, .. }, - amount - ) - .unwrap(); - - let total_remainder_participant_ct_amounts = vec![ - (EVALUATOR_2, 300 * ASSET_UNIT + evaluator_2_reward), - (BUYER_2, 600 * ASSET_UNIT + 200 * ASSET_UNIT), - (BIDDER_1, 40_000 * ASSET_UNIT + 4000 * ASSET_UNIT), - ]; - for (contributor, amount) in total_remainder_participant_ct_amounts { - let minted = - inst.execute(|| ::ContributionTokenCurrency::balance(project_id, contributor)); - assert_eq!(minted, amount); - } - } - - #[test] - fn ct_minted_for_community_buys_manually() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = vec![ - UserToUSDBalance::new(EVALUATOR_1, 50_000 * PLMC), - UserToUSDBalance::new(EVALUATOR_2, 25_000 * PLMC), - UserToUSDBalance::new(EVALUATOR_3, 32_000 * PLMC), - ]; - let bids = vec![BidParams::new(BIDDER_1, 50000 * ASSET_UNIT, 1_u128.into(), 1u8, AcceptedFundingAsset::USDT)]; - let community_contributions = vec![ - ContributionParams::new(BUYER_1, 100 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_2, 200 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_3, 2000 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), - ]; - let remainder_contributions = vec![ - ContributionParams::new(EVALUATOR_2, 300 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_2, 600 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), - ContributionParams::new(BIDDER_1, 4000 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), - ]; - let project_id = inst.create_finished_project( project, issuer, @@ -4628,7 +4334,17 @@ mod remainder_round_success { contribution.contributor, contribution.id, ) - .unwrap() + .unwrap(); + + assert_noop!( + Pallet::::contribution_ct_mint_for( + RuntimeOrigin::signed(contribution.contributor), + project_id, + contribution.contributor, + contribution.id, + ), + Error::::NotAllowed + ); }); } @@ -4646,7 +4362,7 @@ mod remainder_round_success { let total_remainder_participant_ct_amounts = vec![ (EVALUATOR_2, 300 * ASSET_UNIT + evaluator_2_reward), (BUYER_2, 600 * ASSET_UNIT + 200 * ASSET_UNIT), - (BIDDER_1, 50000 * ASSET_UNIT + 4000 * ASSET_UNIT), + (BIDDER_1, 40000 * ASSET_UNIT + 4000 * ASSET_UNIT), ]; for (contributor, amount) in total_remainder_participant_ct_amounts { let minted = @@ -4656,7 +4372,7 @@ mod remainder_round_success { } #[test] - pub fn cannot_mint_ct_twice_manually() { + pub fn cannot_mint_ct_manually_after_automatic_mint() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); @@ -4686,46 +4402,8 @@ mod remainder_round_success { Contributions::::iter_prefix_values((project_id, BIDDER_1)).next().unwrap(); vec![evaluator_contribution.clone(), buyer_contribution.clone(), bidder_contribution.clone()] }); - for contribution in stored_contributions.clone() { - inst.execute(|| { - assert_noop!( - Pallet::::contribution_ct_mint_for( - RuntimeOrigin::signed(contribution.contributor), - project_id, - contribution.contributor, - contribution.id, - ), - Error::::CannotClaimYet - ); - }) - } inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - let details = inst.get_project_details(project_id); - assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData))); - - for contribution in stored_contributions.clone() { - inst.execute(|| { - Pallet::::contribution_ct_mint_for( - RuntimeOrigin::signed(contribution.contributor), - project_id, - contribution.contributor, - contribution.id, - ) - .unwrap(); - - assert_noop!( - Pallet::::contribution_ct_mint_for( - RuntimeOrigin::signed(contribution.contributor), - project_id, - contribution.contributor, - contribution.id, - ), - Error::::NotAllowed - ); - }); - } - inst.advance_time(10u64).unwrap(); let details = inst.get_project_details(project_id); assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); @@ -4747,15 +4425,29 @@ mod remainder_round_success { inst.execute(|| ::ContributionTokenCurrency::balance(project_id, contributor)); assert_eq!(minted, amount); } + + for contribution in stored_contributions.clone() { + inst.execute(|| { + assert_noop!( + Pallet::::contribution_ct_mint_for( + RuntimeOrigin::signed(contribution.contributor), + project_id, + contribution.contributor, + contribution.id, + ), + Error::::NotAllowed + ); + }); + } } #[test] - pub fn cannot_mint_ct_manually_after_automatic_mint() { + pub fn plmc_vesting_schedule_starts_automatically() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); let evaluations = default_evaluations(); - let bids = default_bids(); + let mut bids = default_bids(); let community_contributions = default_community_buys(); let remainder_contributions = default_remainder_buys(); @@ -4763,78 +4455,8 @@ mod remainder_round_success { project, issuer, evaluations, - bids, - community_contributions, - remainder_contributions.clone(), - ); - let details = inst.get_project_details(project_id); - assert_eq!(details.status, ProjectStatus::FundingSuccessful); - assert_eq!(details.cleanup, Cleaner::NotReady); - - let stored_contributions = inst.execute(|| { - let evaluator_contribution = - Contributions::::iter_prefix_values((project_id, EVALUATOR_2)).next().unwrap(); - let buyer_contribution = - Contributions::::iter_prefix_values((project_id, BUYER_2)).next().unwrap(); - let bidder_contribution = - Contributions::::iter_prefix_values((project_id, BIDDER_1)).next().unwrap(); - vec![evaluator_contribution.clone(), buyer_contribution.clone(), bidder_contribution.clone()] - }); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - - inst.advance_time(10u64).unwrap(); - let details = inst.get_project_details(project_id); - assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); - - let evaluator_2_reward = extract_from_event!( - &mut inst, - Event::::EvaluationRewarded { evaluator: EVALUATOR_2, amount, .. }, - amount - ) - .unwrap(); - - let total_remainder_participant_ct_amounts = vec![ - (EVALUATOR_2, 300 * ASSET_UNIT + evaluator_2_reward), - (BUYER_2, 600 * ASSET_UNIT + 200 * ASSET_UNIT), - (BIDDER_1, 40000 * ASSET_UNIT + 4000 * ASSET_UNIT), - ]; - for (contributor, amount) in total_remainder_participant_ct_amounts { - let minted = - inst.execute(|| ::ContributionTokenCurrency::balance(project_id, contributor)); - assert_eq!(minted, amount); - } - - for contribution in stored_contributions.clone() { - inst.execute(|| { - assert_noop!( - Pallet::::contribution_ct_mint_for( - RuntimeOrigin::signed(contribution.contributor), - project_id, - contribution.contributor, - contribution.id, - ), - Error::::NotAllowed - ); - }); - } - } - - #[test] - pub fn plmc_vesting_schedule_starts_automatically() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = default_evaluations(); - let mut bids = default_bids(); - let community_contributions = default_community_buys(); - let remainder_contributions = default_remainder_buys(); - - let project_id = inst.create_finished_project( - project, - issuer, - evaluations, - bids.clone(), - community_contributions.clone(), + bids.clone(), + community_contributions.clone(), remainder_contributions.clone(), ); @@ -5218,231 +4840,6 @@ mod remainder_round_success { assert_eq!(post_project_pot_funding_balance, 0u128); } - - #[test] - pub fn remainder_contribution_and_bid_funding_assets_are_paid_manually_to_issuer() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = default_evaluations(); - let bids = default_bids(); - let community_contributions = vec![]; - let remainder_contributions = default_remainder_buys(); - - let project_id = inst.create_finished_project( - project, - issuer, - evaluations, - bids, - community_contributions, - remainder_contributions, - ); - - let final_winning_bids = inst.execute(|| { - Bids::::iter_prefix_values((project_id,)) - .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) - .collect::>() - }); - let final_bid_payouts = inst.execute(|| { - Bids::::iter_prefix_values((project_id,)) - .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) - .map(|bid| { - UserToStatemintAsset::new( - bid.bidder, - bid.funding_asset_amount_locked, - bid.funding_asset.to_statemint_id(), - ) - }) - .collect::>>() - }); - let final_contributions = - inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); - let final_contribution_payouts = inst.execute(|| { - Contributions::::iter_prefix_values((project_id,)) - .map(|contribution| { - UserToStatemintAsset::new( - contribution.contributor, - contribution.funding_asset_amount, - contribution.funding_asset.to_statemint_id(), - ) - }) - .collect::>>() - }); - - let total_expected_bid_payout = - final_bid_payouts.iter().map(|bid| bid.asset_amount.clone()).sum::>(); - let total_expected_contribution_payout = final_contribution_payouts - .iter() - .map(|contribution| contribution.asset_amount.clone()) - .sum::>(); - - let prev_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; - - let prev_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; - - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - assert_eq!( - inst.get_project_details(project_id).cleanup, - Cleaner::Success(CleanerState::Initialized(PhantomData)) - ); - for bid in final_winning_bids { - inst.execute(|| { - Pallet::::payout_bid_funds_for( - RuntimeOrigin::signed(issuer), - project_id, - bid.bidder, - bid.id, - ) - }) - .unwrap(); - } - for contribution in final_contributions { - inst.execute(|| { - Pallet::::payout_contribution_funds_for( - RuntimeOrigin::signed(issuer), - project_id, - contribution.contributor, - contribution.id, - ) - }) - .unwrap(); - } - let post_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; - - let post_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; - - let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; - let project_pot_funding_delta = prev_project_pot_funding_balance - post_project_pot_funding_balance; - - assert_eq!(issuer_funding_delta - total_expected_bid_payout, total_expected_contribution_payout); - assert_eq!(issuer_funding_delta, project_pot_funding_delta); - - assert_eq!(post_project_pot_funding_balance, 0u128); - } - - #[test] - pub fn remainder_contribution_community_contribution_and_bid_funding_assets_are_paid_manually_to_issuer() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = default_evaluations(); - let bids = default_bids(); - let community_contributions = default_community_buys(); - let remainder_contributions = default_remainder_buys(); - - let project_id = inst.create_finished_project( - project, - issuer, - evaluations, - bids, - community_contributions, - remainder_contributions, - ); - - let final_winning_bids = inst.execute(|| { - Bids::::iter_prefix_values((project_id,)) - .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) - .collect::>() - }); - let final_bid_payouts = inst.execute(|| { - Bids::::iter_prefix_values((project_id,)) - .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) - .map(|bid| { - UserToStatemintAsset::new( - bid.bidder, - bid.funding_asset_amount_locked, - bid.funding_asset.to_statemint_id(), - ) - }) - .collect::>>() - }); - let final_contributions = - inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); - let final_contribution_payouts = inst.execute(|| { - Contributions::::iter_prefix_values((project_id,)) - .map(|contribution| { - UserToStatemintAsset::new( - contribution.contributor, - contribution.funding_asset_amount, - contribution.funding_asset.to_statemint_id(), - ) - }) - .collect::>>() - }); - - let total_expected_bid_payout = - final_bid_payouts.iter().map(|bid| bid.asset_amount.clone()).sum::>(); - let total_expected_contribution_payout = final_contribution_payouts - .iter() - .map(|contribution| contribution.asset_amount.clone()) - .sum::>(); - - let prev_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; - - let prev_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; - - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - assert_eq!( - inst.get_project_details(project_id).cleanup, - Cleaner::Success(CleanerState::Initialized(PhantomData)) - ); - for bid in final_winning_bids { - inst.execute(|| { - Pallet::::payout_bid_funds_for( - RuntimeOrigin::signed(issuer), - project_id, - bid.bidder, - bid.id, - ) - }) - .unwrap(); - } - for contribution in final_contributions { - inst.execute(|| { - Pallet::::payout_contribution_funds_for( - RuntimeOrigin::signed(issuer), - project_id, - contribution.contributor, - contribution.id, - ) - }) - .unwrap(); - } - let post_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; - - let post_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; - let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; - let project_pot_funding_delta = prev_project_pot_funding_balance - post_project_pot_funding_balance; - - assert_eq!(issuer_funding_delta - total_expected_bid_payout, total_expected_contribution_payout); - assert_eq!(issuer_funding_delta, project_pot_funding_delta); - - assert_eq!(post_project_pot_funding_balance, 0u128); - } } mod remainder_round_failure { @@ -6038,23 +5435,18 @@ mod remainder_round_failure { let wap = inst.get_project_details(project_id).weighted_average_price.unwrap(); let bidder_plmc_bonds = MockInstantiator::calculate_auction_plmc_spent(&bids, Some(wap)); - let community_contributor_plmc_bonds = MockInstantiator::calculate_contributed_plmc_spent( - community_contributions.clone(), - wap, - ); - let evaluators_and_contributors_plmc_bonds = MockInstantiator::calculate_total_plmc_locked_from_evaluations_and_remainder_contributions( - default_evaluations(), - remainder_contributions, - wap, - true, - ); + let community_contributor_plmc_bonds = + MockInstantiator::calculate_contributed_plmc_spent(community_contributions.clone(), wap); + let evaluators_and_contributors_plmc_bonds = + MockInstantiator::calculate_total_plmc_locked_from_evaluations_and_remainder_contributions( + default_evaluations(), + remainder_contributions, + wap, + true, + ); let mut expected_final_plmc_balances = MockInstantiator::generic_map_operation( - vec![ - bidder_plmc_bonds, - community_contributor_plmc_bonds, - evaluators_and_contributors_plmc_bonds, - ], + vec![bidder_plmc_bonds, community_contributor_plmc_bonds, evaluators_and_contributors_plmc_bonds], MergeOperation::Add, ); expected_final_plmc_balances.iter_mut().for_each(|UserToPLMCBalance { account, plmc_amount }| { @@ -6075,10 +5467,8 @@ mod remainder_round_failure { let post_balances = inst.get_free_plmc_balances_for(expected_final_plmc_balances.accounts()); - let plmc_deltas = MockInstantiator::generic_map_operation( - vec![post_balances, prev_balances], - MergeOperation::Subtract, - ); + let plmc_deltas = + MockInstantiator::generic_map_operation(vec![post_balances, prev_balances], MergeOperation::Subtract); assert_eq!(plmc_deltas, expected_final_plmc_balances); inst.do_reserved_plmc_assertions(zero_balances, LockType::FutureDeposit(project_id)); @@ -6446,6 +5836,228 @@ mod funding_end { assert_eq!(actual_evaluator_free_balances, expected_evaluator_free_balances); } + #[test] + fn ct_minted_automatically() { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let issuer = ISSUER; + let project = default_project(inst.get_new_nonce(), issuer); + let evaluations = default_evaluations(); + let bids = default_bids(); + let community_contributions = default_community_buys(); + let remainder_contributions = default_remainder_buys(); + + let project_id = inst.create_finished_project( + project, + issuer, + evaluations.clone(), + bids.clone(), + community_contributions.clone(), + remainder_contributions.clone(), + ); + let details = inst.get_project_details(project_id); + assert_eq!(details.status, ProjectStatus::FundingSuccessful); + assert_eq!(details.cleanup, Cleaner::NotReady); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + + inst.advance_time(10u64).unwrap(); + let details = inst.get_project_details(project_id); + assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); + + let evaluators = evaluations.accounts(); + let evaluator_ct_amounts = evaluators + .iter() + .map(|account| { + let evaluations = inst.execute(|| { + Evaluations::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + let total_evaluator_ct_rewarded = evaluations + .iter() + .map(|evaluation| evaluation.rewarded_or_slashed) + .map(|reward_or_slash| { + if let Some(RewardOrSlash::Reward(balance)) = reward_or_slash { + balance + } else { + Zero::zero() + } + }) + .sum::(); + + (account, total_evaluator_ct_rewarded) + }) + .collect_vec(); + + let bidders = bids.accounts(); + let bidder_ct_amounts = bidders + .iter() + .map(|account| { + let bids = inst.execute(|| { + Bids::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + let total_bidder_ct_rewarded = bids.iter().map(|bid| bid.final_ct_amount).sum::(); + + (account, total_bidder_ct_rewarded) + }) + .collect_vec(); + + let community_accounts = community_contributions.accounts(); + let remainder_accounts = remainder_contributions.accounts(); + let all_contributors = community_accounts.iter().chain(remainder_accounts.iter()).unique(); + let contributor_ct_amounts = all_contributors + .map(|account| { + let contributions = inst.execute(|| { + Contributions::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + let total_contributor_ct_rewarded = + contributions.iter().map(|contribution| contribution.ct_amount).sum::(); + + (account, total_contributor_ct_rewarded) + }) + .collect_vec(); + + let all_ct_expectations = MockInstantiator::generic_map_merge_reduce( + vec![evaluator_ct_amounts, bidder_ct_amounts, contributor_ct_amounts], + |item| item.0, + Zero::zero(), + |item, accumulator| accumulator + item.1, + ); + + for (account, amount) in all_ct_expectations { + let minted = + inst.execute(|| ::ContributionTokenCurrency::balance(project_id, account)); + assert_eq!(minted, amount); + } + } + + #[test] + fn ct_minted_manually() { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let issuer = ISSUER; + let project = default_project(inst.get_new_nonce(), issuer); + let evaluations = default_evaluations(); + let bids = default_bids(); + let community_contributions = default_community_buys(); + let remainder_contributions = default_remainder_buys(); + + let project_id = inst.create_finished_project( + project, + issuer, + evaluations.clone(), + bids.clone(), + community_contributions.clone(), + remainder_contributions.clone(), + ); + let details = inst.get_project_details(project_id); + assert_eq!(details.status, ProjectStatus::FundingSuccessful); + assert_eq!(details.cleanup, Cleaner::NotReady); + // do_end_funding + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData))); + + + let evaluators = evaluations.accounts(); + let evaluator_ct_amounts = evaluators + .iter() + .map(|account| { + let evaluations = inst.execute(|| { + Evaluations::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + for evaluation in evaluations.iter() { + inst.execute(|| { + assert_ok!(Pallet::::evaluation_reward_payout_for( + RuntimeOrigin::signed(evaluation.evaluator), + project_id, + evaluation.evaluator, + evaluation.id, + )); + }); + } + let evaluations = inst.execute(|| { + Evaluations::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + let total_evaluator_ct_rewarded = evaluations + .iter() + .map(|evaluation| evaluation.rewarded_or_slashed) + .map(|reward_or_slash| { + if let Some(RewardOrSlash::Reward(balance)) = reward_or_slash { + balance + } else { + Zero::zero() + } + }) + .sum::(); + + (account, total_evaluator_ct_rewarded) + }) + .collect_vec(); + + let bidders = bids.accounts(); + let bidder_ct_amounts = bidders + .iter() + .map(|account| { + let bids = inst.execute(|| { + Bids::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + for bid in bids.iter() { + inst.execute(|| { + assert_ok!(Pallet::::bid_ct_mint_for( + RuntimeOrigin::signed(bid.bidder), + project_id, + bid.bidder, + bid.id, + )); + }); + } + + let total_bidder_ct_rewarded = bids.iter().map(|bid| bid.final_ct_amount).sum::(); + + (account, total_bidder_ct_rewarded) + }) + .collect_vec(); + + let community_accounts = community_contributions.accounts(); + let remainder_accounts = remainder_contributions.accounts(); + let all_contributors = community_accounts.iter().chain(remainder_accounts.iter()).unique(); + let contributor_ct_amounts = all_contributors + .map(|account| { + let contributions = inst.execute(|| { + Contributions::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + for contribution in contributions.iter() { + inst.execute(|| { + assert_ok!(Pallet::::contribution_ct_mint_for( + RuntimeOrigin::signed(contribution.contributor), + project_id, + contribution.contributor, + contribution.id, + )); + }); + } + + let total_contributor_ct_rewarded = + contributions.iter().map(|contribution| contribution.ct_amount).sum::(); + + (account, total_contributor_ct_rewarded) + }) + .collect_vec(); + + let all_ct_expectations = MockInstantiator::generic_map_merge_reduce( + vec![evaluator_ct_amounts, bidder_ct_amounts, contributor_ct_amounts], + |item| item.0, + Zero::zero(), + |item, accumulator| accumulator + item.1, + ); + + for (account, amount) in all_ct_expectations { + let minted = + inst.execute(|| ::ContributionTokenCurrency::balance(project_id, account)); + assert_eq!(minted, amount, "Account: {}", account); + } + + let details = inst.get_project_details(project_id); + assert_eq!(details.status, ProjectStatus::FundingSuccessful); + assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData))); + } + #[test] fn multiplier_gets_correct_vesting_duration() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); @@ -6490,6 +6102,118 @@ mod funding_end { ); } + #[test] + pub fn funding_assets_are_paid_manually_to_issuer() { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let issuer = ISSUER; + let project = default_project(inst.get_new_nonce(), issuer); + let evaluations = default_evaluations(); + let bids = default_bids(); + let community_contributions = default_community_buys(); + let remainder_contributions = default_remainder_buys(); + + let project_id = inst.create_finished_project( + project, + issuer, + evaluations, + bids, + community_contributions, + remainder_contributions, + ); + + let final_winning_bids = inst.execute(|| { + Bids::::iter_prefix_values((project_id,)) + .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) + .collect::>() + }); + let final_bid_payouts = inst.execute(|| { + Bids::::iter_prefix_values((project_id,)) + .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) + .map(|bid| { + UserToStatemintAsset::new( + bid.bidder, + bid.funding_asset_amount_locked, + bid.funding_asset.to_statemint_id(), + ) + }) + .collect::>>() + }); + let final_contributions = + inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); + let final_contribution_payouts = inst.execute(|| { + Contributions::::iter_prefix_values((project_id,)) + .map(|contribution| { + UserToStatemintAsset::new( + contribution.contributor, + contribution.funding_asset_amount, + contribution.funding_asset.to_statemint_id(), + ) + }) + .collect::>>() + }); + + let total_expected_bid_payout = + final_bid_payouts.iter().map(|bid| bid.asset_amount.clone()).sum::>(); + let total_expected_contribution_payout = final_contribution_payouts + .iter() + .map(|contribution| contribution.asset_amount.clone()) + .sum::>(); + + let prev_issuer_funding_balance = inst + .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] + .asset_amount; + + let prev_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( + final_bid_payouts[0].asset_id, + vec![Pallet::::fund_account_id(project_id)], + )[0] + .asset_amount; + + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + assert_eq!( + inst.get_project_details(project_id).cleanup, + Cleaner::Success(CleanerState::Initialized(PhantomData)) + ); + for bid in final_winning_bids { + inst.execute(|| { + Pallet::::payout_bid_funds_for( + RuntimeOrigin::signed(issuer), + project_id, + bid.bidder, + bid.id, + ) + }) + .unwrap(); + } + for contribution in final_contributions { + inst.execute(|| { + Pallet::::payout_contribution_funds_for( + RuntimeOrigin::signed(issuer), + project_id, + contribution.contributor, + contribution.id, + ) + }) + .unwrap(); + } + let post_issuer_funding_balance = inst + .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] + .asset_amount; + + let post_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( + final_bid_payouts[0].asset_id, + vec![Pallet::::fund_account_id(project_id)], + )[0] + .asset_amount; + let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; + let project_pot_funding_delta = prev_project_pot_funding_balance - post_project_pot_funding_balance; + + assert_eq!(issuer_funding_delta - total_expected_bid_payout, total_expected_contribution_payout); + assert_eq!(issuer_funding_delta, project_pot_funding_delta); + + assert_eq!(post_project_pot_funding_balance, 0u128); + } + // i.e consumer increase bug fixed with touch on pallet-assets #[ignore] #[test] From e9dd2b049567e50b58913728079bdcf524fb3f93 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 11 Dec 2023 15:33:14 +0100 Subject: [PATCH 065/212] fixed most tests. Bid calculation function not working as intended now --- pallets/funding/src/tests.rs | 4560 ++++++++++++++-------------------- 1 file changed, 1902 insertions(+), 2658 deletions(-) diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 77a8beecf..54f754c16 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -190,7 +190,10 @@ pub mod defaults { let project_metadata = default_project(instantiator.get_new_nonce(), ISSUER); let min_price = project_metadata.minimum_price; let usd_to_reach = Perquintill::from_percent(percent) * - (project_metadata.minimum_price.checked_mul_int(project_metadata.total_allocation_size.0).unwrap()); + (project_metadata + .minimum_price + .checked_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1) + .unwrap()); let evaluations = default_evaluations(); let bids = MockInstantiator::generate_bids_from_total_usd( Percent::from_percent(50u8) * usd_to_reach, @@ -1072,7 +1075,6 @@ mod auction_round_success { assert_eq!(bidder_5_bid.final_ct_usd_price, wabgp); } - #[test] pub fn cannot_mint_ct_twice_manually() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); @@ -1455,179 +1457,6 @@ mod auction_round_success { assert!(!schedule_exists); } - #[test] - pub fn bid_funding_assets_are_paid_automatically_to_issuer() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = default_evaluations(); - let bids = default_bids(); - let community_contributions = default_community_buys(); - let remainder_contributions = default_remainder_buys(); - - let project_id = inst.create_finished_project( - project, - issuer, - evaluations, - bids, - community_contributions, - remainder_contributions, - ); - - let final_bid_payouts = inst.execute(|| { - Bids::::iter_prefix_values((project_id,)).map(|bid| { - UserToStatemintAsset::::new( - bid.bidder, - bid.funding_asset_amount_locked, - bid.funding_asset.to_statemint_id(), - ) - }) - }); - let final_contribution_payouts = inst.execute(|| { - Contributions::::iter_prefix_values((project_id,)).map(|contribution| { - UserToStatemintAsset::::new( - contribution.contributor, - contribution.funding_asset_amount, - contribution.funding_asset.to_statemint_id(), - ) - }) - }); - let expected_payouts = inst.execute(|| final_bid_payouts.chain(final_contribution_payouts).collect_vec()); - let total_expected_payouts = - expected_payouts.iter().map(|item| item.asset_amount).sum::>(); - let asset_id = AcceptedFundingAsset::USDT.to_statemint_id(); - - let prev_issuer_funding_balance = - inst.get_free_statemint_asset_balances_for(asset_id, vec![issuer.clone()])[0].asset_amount; - let prev_bidders_funding_balances = - inst.get_free_statemint_asset_balances_for(asset_id, expected_payouts.accounts()); - let prev_total_bidder_balance = - prev_bidders_funding_balances.iter().map(|item| item.asset_amount).sum::>(); - let prev_project_pot_funding_balance = inst - .get_free_statemint_asset_balances_for(asset_id, vec![Pallet::::fund_account_id(project_id)])[0] - .asset_amount; - - inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); - assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); - - let post_issuer_funding_balance = - inst.get_free_statemint_asset_balances_for(asset_id, vec![issuer.clone()])[0].asset_amount; - let post_bidders_funding_balances = - inst.get_free_statemint_asset_balances_for(asset_id, expected_payouts.accounts()); - let post_total_bidder_balance = - post_bidders_funding_balances.iter().map(|item| item.asset_amount).sum::>(); - let post_project_pot_funding_balance = inst - .get_free_statemint_asset_balances_for(asset_id, vec![Pallet::::fund_account_id(project_id)])[0] - .asset_amount; - - let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; - let project_pot_funding_delta = prev_project_pot_funding_balance - post_project_pot_funding_balance; - - assert_eq!(issuer_funding_delta, total_expected_payouts); - assert_eq!(issuer_funding_delta, project_pot_funding_delta); - - assert_eq!(prev_total_bidder_balance, 0u128); - assert_eq!(post_total_bidder_balance, 0u128); - assert_eq!(post_project_pot_funding_balance, 0u128); - } - - #[test] - pub fn bid_funding_assets_are_paid_manually_to_issuer() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = default_evaluations(); - let bids = MockInstantiator::generate_bids_from_total_usd( - project.total_allocation_size.0, - project.minimum_price, - default_weights(), - default_bidders(), - default_multipliers(), - ); - let community_contributions = default_community_buys(); - let remainder_contributions = default_remainder_buys(); - - let project_id = inst.create_finished_project( - project, - issuer, - evaluations, - bids, - community_contributions, - remainder_contributions, - ); - let final_winning_bids = - inst.execute(|| Bids::::iter_prefix_values((project_id,)).collect::>()); - let final_bid_payouts = inst.execute(|| { - Bids::::iter_prefix_values((project_id,)) - .map(|bid| { - UserToStatemintAsset::::new( - bid.bidder, - bid.funding_asset_amount_locked, - bid.funding_asset.to_statemint_id(), - ) - }) - .collect::>>() - }); - let total_expected_bid_payout = - final_bid_payouts.iter().map(|bid| bid.asset_amount.clone()).sum::>(); - - let prev_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; - let prev_bidders_funding_balances = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - final_bid_payouts.iter().map(|item| item.account.clone()).collect::>(), - ); - let prev_total_bidder_balance = - prev_bidders_funding_balances.iter().map(|item| item.asset_amount).sum::>(); - let prev_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; - - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - assert_eq!( - inst.get_project_details(project_id).cleanup, - Cleaner::Success(CleanerState::Initialized(PhantomData)) - ); - - for bid in final_winning_bids { - inst.execute(|| { - Pallet::::payout_bid_funds_for( - RuntimeOrigin::signed(issuer), - project_id, - bid.bidder, - bid.id, - ) - }) - .unwrap(); - } - - let post_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; - let post_bidders_funding_balances = - inst.get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, final_bid_payouts.accounts()); - let post_total_bidder_balance = - post_bidders_funding_balances.iter().map(|item| item.asset_amount).sum::>(); - let post_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; - - let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; - let project_pot_funding_delta = prev_project_pot_funding_balance - post_project_pot_funding_balance; - - assert_eq!(issuer_funding_delta, total_expected_bid_payout); - assert_eq!(issuer_funding_delta, project_pot_funding_delta); - - assert_eq!(prev_total_bidder_balance, 0u128); - assert_eq!(post_total_bidder_balance, 0u128); - assert_eq!(post_project_pot_funding_balance, 0u128); - } - #[test] pub fn bid_funding_assets_are_released_automatically_on_funding_fail() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); @@ -3260,506 +3089,353 @@ mod community_round_success { assert_eq!(vested_amount, post_free_balance - prev_free_balance); } } +} + +mod community_round_failure { + use super::*; #[test] - pub fn contribution_and_bid_funding_assets_are_paid_automatically_to_issuer() { + fn community_contribution_ct_account_deposits_are_returned() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = default_evaluations(); - let bids = default_bids(); - let community_contributions = default_community_buys(); - let remainder_contributions = vec![]; - - let project_id = inst.create_finished_project( - project, - issuer, - evaluations, - bids, - community_contributions, - remainder_contributions, - ); - - let final_bid_payouts = inst.execute(|| { - Bids::::iter_prefix_values((project_id,)) - .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) - .map(|bid| { - UserToStatemintAsset::::new( - bid.bidder, - bid.funding_asset_amount_locked, - bid.funding_asset.to_statemint_id(), - ) - }) - .collect::>>() - }); - let final_contribution_payouts = inst.execute(|| { - Contributions::::iter_prefix_values((project_id,)) - .map(|contribution| { - UserToStatemintAsset::::new( - contribution.contributor, - contribution.funding_asset_amount, - contribution.funding_asset.to_statemint_id(), - ) - }) - .collect::>>() - }); - - let total_expected_bid_payout = - final_bid_payouts.iter().map(|bid| bid.asset_amount.clone()).sum::>(); - let total_expected_contribution_payout = final_contribution_payouts - .iter() - .map(|contribution| contribution.asset_amount.clone()) - .sum::>(); + let project_metadata = default_project(0, ISSUER); + let automatic_fail_funding_percent = Percent::from_percent(30); + let (bid_allocation, contribution_allocation) = project_metadata.total_allocation_size; + let deposit_required = <::ContributionTokenCurrency as AccountTouch< + ProjectIdOf, + AccountIdOf, + >>::deposit_required(0); - let prev_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; + let desired_total_usd_amount_bid = + automatic_fail_funding_percent * project_metadata.minimum_price.saturating_mul_int(bid_allocation); + let desired_total_usd_amount_contributed = + automatic_fail_funding_percent * project_metadata.minimum_price.saturating_mul_int(contribution_allocation); - let prev_contributors_funding_balances = inst.get_free_statemint_asset_balances_for( - final_contribution_payouts[0].asset_id, - final_contribution_payouts.iter().map(|item| item.account.clone()).collect::>(), + let bids = MockInstantiator::generate_bids_from_total_usd( + desired_total_usd_amount_bid, + project_metadata.minimum_price, + default_weights(), + default_bidders(), + default_bidder_multipliers(), ); - let prev_total_contributor_balance = - prev_contributors_funding_balances.iter().map(|item| item.asset_amount).sum::>(); - let prev_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; + let community_contributions = MockInstantiator::generate_contributions_from_total_usd( + desired_total_usd_amount_contributed, + project_metadata.minimum_price, + default_weights(), + default_community_contributors(), + default_community_contributor_multipliers(), + ); - inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); - assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); + let zero_balances = community_contributions + .clone() + .accounts() + .into_iter() + .map(|acc| UserToPLMCBalance::new(acc, 0u128)) + .collect_vec(); + inst.do_free_plmc_assertions(zero_balances.clone()); + inst.do_reserved_plmc_assertions(zero_balances.clone(), LockType::FutureDeposit(0)); - let post_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; + let (project_id, _) = inst.create_remainder_contributing_project( + project_metadata, + ISSUER, + default_evaluations(), + bids.clone(), + community_contributions.clone(), + ); - let post_contributors_funding_balances = inst.get_free_statemint_asset_balances_for( - final_contribution_payouts[0].asset_id, - final_contribution_payouts.iter().map(|item| item.account.clone()).collect::>(), + let required_plmc_bonds = MockInstantiator::calculate_contributed_plmc_spent( + community_contributions, + inst.get_project_details(project_id).weighted_average_price.unwrap(), ); + let plmc_existential_deposits = required_plmc_bonds.accounts().existential_deposits(); + let plmc_ct_account_deposits = required_plmc_bonds.accounts().ct_account_deposits(); - let post_total_contributor_balance = - post_contributors_funding_balances.iter().map(|item| item.asset_amount).sum::>(); - let post_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; + let ed_balances = required_plmc_bonds + .accounts() + .into_iter() + .map(|acc| UserToPLMCBalance::new(acc, MockInstantiator::get_ed())) + .collect_vec(); + inst.do_free_plmc_assertions(ed_balances); + let ct_deposit_balances = required_plmc_bonds + .accounts() + .into_iter() + .map(|acc| UserToPLMCBalance::new(acc, deposit_required)) + .collect_vec(); + inst.do_reserved_plmc_assertions(ct_deposit_balances, LockType::FutureDeposit(project_id)); - let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; - let project_pot_funding_delta = prev_project_pot_funding_balance - post_project_pot_funding_balance; + inst.advance_time(::RemainderFundingDuration::get() + 1).unwrap(); - assert_eq!(issuer_funding_delta - total_expected_bid_payout, total_expected_contribution_payout); - assert_eq!(issuer_funding_delta, project_pot_funding_delta); + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingFailed); - assert_eq!(prev_total_contributor_balance, 0u128); - assert_eq!(post_total_contributor_balance, 0u128); - assert_eq!(post_project_pot_funding_balance, 0u128); + inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); + assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Failure(CleanerState::Finished(PhantomData))); + + let final_plmc_amounts = MockInstantiator::generic_map_operation( + vec![required_plmc_bonds, plmc_existential_deposits, plmc_ct_account_deposits], + MergeOperation::Add, + ); + inst.do_free_plmc_assertions(final_plmc_amounts); + inst.do_reserved_plmc_assertions(zero_balances, LockType::FutureDeposit(project_id)); + } +} + +mod remainder_round_success { + use super::*; + + #[test] + fn remainder_round_works() { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let _ = inst.create_finished_project( + default_project(inst.get_new_nonce(), ISSUER), + ISSUER, + default_evaluations(), + default_bids(), + default_community_buys(), + default_remainder_buys(), + ); } #[test] - pub fn contribution_and_bid_funding_assets_are_paid_manually_to_issuer() { + fn remainder_contributor_was_evaluator() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = default_evaluations(); - let bids = default_bids(); + let mut evaluations = default_evaluations(); let community_contributions = default_community_buys(); - let remainder_contributions = vec![]; + let evaluator_contributor = 69; + let evaluation_amount = 420 * US_DOLLAR; + let remainder_contribution = + ContributionParams::new(evaluator_contributor, 600 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT); + evaluations.push(UserToUSDBalance::new(evaluator_contributor, evaluation_amount)); + let bids = default_bids(); - let project_id = inst.create_finished_project( - project, - issuer, - evaluations, - bids, - community_contributions, - remainder_contributions, - ); + let (project_id, _) = + inst.create_remainder_contributing_project(project, issuer, evaluations, bids, community_contributions); + let ct_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); + let already_bonded_plmc = MockInstantiator::calculate_evaluation_plmc_spent(vec![UserToUSDBalance::new( + evaluator_contributor, + evaluation_amount, + )])[0] + .plmc_amount; + let plmc_available_for_contribution = + already_bonded_plmc - ::EvaluatorSlash::get() * already_bonded_plmc; + let necessary_plmc_for_buy = + MockInstantiator::calculate_contributed_plmc_spent(vec![remainder_contribution.clone()], ct_price)[0] + .plmc_amount; + let necessary_usdt_for_buy = + MockInstantiator::calculate_contributed_funding_asset_spent(vec![remainder_contribution.clone()], ct_price); - let final_winning_bids = inst.execute(|| { - Bids::::iter_prefix_values((project_id,)) - .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) - .collect::>() - }); - let final_bid_payouts = inst.execute(|| { - Bids::::iter_prefix_values((project_id,)) - .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) - .map(|bid| { - UserToStatemintAsset::::new( - bid.bidder, - bid.funding_asset_amount_locked, - bid.funding_asset.to_statemint_id(), - ) - }) - .collect::>>() - }); - let final_contributions = - inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); - let final_contribution_payouts = inst.execute(|| { - Contributions::::iter_prefix_values((project_id,)) - .map(|contribution| { - UserToStatemintAsset::::new( - contribution.contributor, - contribution.funding_asset_amount, - contribution.funding_asset.to_statemint_id(), - ) - }) - .collect::>>() - }); + inst.mint_plmc_to(vec![UserToPLMCBalance::new( + evaluator_contributor, + necessary_plmc_for_buy - plmc_available_for_contribution, + )]); + inst.mint_statemint_asset_to(necessary_usdt_for_buy); - let total_expected_bid_payout = - final_bid_payouts.iter().map(|bid| bid.asset_amount.clone()).sum::>(); - let total_expected_contribution_payout = final_contribution_payouts - .iter() - .map(|contribution| contribution.asset_amount.clone()) - .sum::>(); + inst.contribute_for_users(project_id, vec![remainder_contribution]).unwrap(); + } - let prev_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; + #[test] + fn remainder_contributor_was_evaluator_vec_full() { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let issuer = ISSUER; + let project = default_project(inst.get_new_nonce(), issuer); + let mut evaluations = default_evaluations(); + let bids = default_bids(); + let evaluator_contributor = 69; + let overflow_contribution = + ContributionParams::new(evaluator_contributor, 600 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT); - let prev_contributors_funding_balances = inst.get_free_statemint_asset_balances_for( - final_contribution_payouts[0].asset_id, - final_contribution_payouts.iter().map(|item| item.account.clone()).collect::>(), - ); + let mut fill_contributions = Vec::new(); + for _i in 0..::MaxContributionsPerUser::get() { + fill_contributions.push(ContributionParams::new( + evaluator_contributor, + 10 * ASSET_UNIT, + 1u8, + AcceptedFundingAsset::USDT, + )); + } - let prev_total_contributor_balance = - prev_contributors_funding_balances.iter().map(|item| item.asset_amount).sum::>(); - let prev_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; + let expected_price = MockInstantiator::calculate_price_from_test_bids(bids.clone()); + let fill_necessary_plmc = + MockInstantiator::calculate_contributed_plmc_spent(fill_contributions.clone(), expected_price); + let fill_necessary_usdt_for_bids = + MockInstantiator::calculate_contributed_funding_asset_spent(fill_contributions.clone(), expected_price); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - assert_eq!( - inst.get_project_details(project_id).cleanup, - Cleaner::Success(CleanerState::Initialized(PhantomData)) + let overflow_necessary_plmc = + MockInstantiator::calculate_contributed_plmc_spent(vec![overflow_contribution.clone()], expected_price); + let overflow_necessary_usdt = MockInstantiator::calculate_contributed_funding_asset_spent( + vec![overflow_contribution.clone()], + expected_price, ); - for bid in final_winning_bids { - inst.execute(|| { - Pallet::::payout_bid_funds_for( - RuntimeOrigin::signed(issuer), - project_id, - bid.bidder, - bid.id, - ) - }) - .unwrap(); - } - for contribution in final_contributions { - inst.execute(|| { - Pallet::::payout_contribution_funds_for( - RuntimeOrigin::signed(issuer), - project_id, - contribution.contributor, - contribution.id, - ) - }) - .unwrap(); - } - let post_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; - let post_contributors_funding_balances = inst.get_free_statemint_asset_balances_for( - final_contribution_payouts[0].asset_id, - final_contribution_payouts.iter().map(|item| item.account.clone()).collect::>(), - ); + let evaluation_bond = + MockInstantiator::sum_balance_mappings(vec![fill_necessary_plmc, overflow_necessary_plmc.clone()]); + let plmc_available_for_participating = + evaluation_bond - ::EvaluatorSlash::get() * evaluation_bond; - let post_total_contributor_balance = - post_contributors_funding_balances.iter().map(|item| item.asset_amount).sum::>(); - let post_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; + let evaluation_usd_amount = ::PriceProvider::get_price(PLMC_STATEMINT_ID) + .unwrap() + .saturating_mul_int(evaluation_bond); + evaluations.push(UserToUSDBalance::new(evaluator_contributor, evaluation_usd_amount)); - let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; - let project_pot_funding_delta = prev_project_pot_funding_balance - post_project_pot_funding_balance; + let (project_id, _) = + inst.create_remainder_contributing_project(project, issuer, evaluations, bids, default_community_buys()); - assert_eq!(issuer_funding_delta - total_expected_bid_payout, total_expected_contribution_payout); - assert_eq!(issuer_funding_delta, project_pot_funding_delta); + inst.mint_plmc_to(vec![UserToPLMCBalance::new( + evaluator_contributor, + evaluation_bond - plmc_available_for_participating, + )]); + inst.mint_statemint_asset_to(fill_necessary_usdt_for_bids); + inst.mint_statemint_asset_to(overflow_necessary_usdt); - assert_eq!(prev_total_contributor_balance, 0u128); - assert_eq!(post_total_contributor_balance, 0u128); - assert_eq!(post_project_pot_funding_balance, 0u128); - } -} + inst.contribute_for_users(project_id, fill_contributions).unwrap(); + inst.contribute_for_users(project_id, vec![overflow_contribution]).unwrap(); -mod community_round_failure { - use super::*; + let evaluation_bonded = inst.execute(|| { + ::NativeCurrency::balance_on_hold( + &LockType::Evaluation(project_id), + &evaluator_contributor, + ) + }); + assert_eq!(evaluation_bonded, ::EvaluatorSlash::get() * evaluation_bond); + } #[test] - pub fn bid_and_community_contribution_funding_assets_are_released_automatically_on_funding_fail() { + fn remainder_round_ends_on_all_ct_sold_exact() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = default_evaluations(); - - let fail_percentage = Percent::from_percent(30u8); - let bids = MockInstantiator::generate_bids_from_total_usd( - fail_percentage * project.total_allocation_size.0, - project.minimum_price, - default_weights(), - default_bidders(), - default_multipliers(), + let (project_id, _) = inst.create_remainder_contributing_project( + default_project(0, ISSUER), + ISSUER, + default_evaluations(), + default_bids(), + default_community_buys(), ); + const BOB: AccountId = 808; - let community_contributions = MockInstantiator::generate_contributions_from_total_usd( - fail_percentage * project.total_allocation_size.1, - project.minimum_price, - default_weights(), - default_community_contributors(), - default_multipliers(), - ); - let remainder_contributions = vec![]; - - let project_id = inst.create_finished_project( - project, - issuer, - evaluations, - bids, - community_contributions.clone(), - remainder_contributions, - ); - let final_bid_payouts = inst.execute(|| { - Bids::::iter_prefix_values((project_id,)) - .map(|bid| { - UserToStatemintAsset::::new( - bid.bidder, - bid.funding_asset_amount_locked, - bid.funding_asset.to_statemint_id(), - ) - }) - .sorted_by_key(|item| item.account) - .collect::>>() - }); - let total_expected_bid_payout = - final_bid_payouts.iter().map(|bid| bid.asset_amount.clone()).sum::>(); - let expected_community_contribution_payouts = MockInstantiator::calculate_contributed_funding_asset_spent( - community_contributions.clone(), - inst.get_project_details(project_id).weighted_average_price.unwrap(), - ); + let remaining_ct = inst.get_project_details(project_id).remaining_contribution_tokens; + let ct_price = inst.get_project_details(project_id).weighted_average_price.expect("CT Price should exist"); - let prev_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; - let prev_bidders_funding_balances = - inst.get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, final_bid_payouts.accounts()); - let prev_contributors_funding_balances = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - community_contributions - .iter() - .map(|test_contribution| test_contribution.contributor.clone()) - .collect::>(), - ); - let prev_total_bidder_balance = - prev_bidders_funding_balances.iter().map(|item| item.asset_amount).sum::>(); + let contributions = + vec![ContributionParams::new(BOB, remaining_ct.0 + remaining_ct.1, 1u8, AcceptedFundingAsset::USDT)]; + let mut plmc_fundings = MockInstantiator::calculate_contributed_plmc_spent(contributions.clone(), ct_price); + let plmc_existential_deposits = contributions.accounts().existential_deposits(); + let plmc_ct_account_deposits = contributions.accounts().ct_account_deposits(); + let statemint_asset_fundings = + MockInstantiator::calculate_contributed_funding_asset_spent(contributions.clone(), ct_price); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - inst.advance_time(10).unwrap(); - assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Failure(CleanerState::Finished(PhantomData))); + inst.mint_plmc_to(plmc_fundings.clone()); + inst.mint_plmc_to(plmc_existential_deposits.clone()); + inst.mint_plmc_to(plmc_ct_account_deposits.clone()); + inst.mint_statemint_asset_to(statemint_asset_fundings.clone()); - let post_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; - let post_bidders_funding_balances = - inst.get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, final_bid_payouts.accounts()); - let post_contributors_funding_balances = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - community_contributions - .iter() - .map(|test_contribution| test_contribution.contributor.clone()) - .collect::>(), - ); - let post_total_bidder_balance = - post_bidders_funding_balances.iter().map(|item| item.asset_amount).sum::>(); - let post_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; + // Buy remaining CTs + inst.contribute_for_users(project_id, contributions) + .expect("The Buyer should be able to buy the exact amount of remaining CTs"); + inst.advance_time(2u64).unwrap(); - let contributors_funding_delta = MockInstantiator::generic_map_operation( - vec![post_contributors_funding_balances, prev_contributors_funding_balances], - MergeOperation::Subtract, + // Check remaining CTs is 0 + assert_eq!( + inst.get_project_details(project_id).remaining_contribution_tokens.0 + + inst.get_project_details(project_id).remaining_contribution_tokens.1, + 0, + "There are still remaining CTs" ); - let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; + // Check project is in FundingEnded state + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingSuccessful); - assert_eq!(issuer_funding_delta, 0); - assert_eq!(prev_total_bidder_balance, 0u128); - assert_eq!(post_total_bidder_balance, total_expected_bid_payout); - assert_eq!(post_project_pot_funding_balance, 0u128); - assert_eq!(post_bidders_funding_balances, final_bid_payouts); - assert_eq!(contributors_funding_delta, expected_community_contribution_payouts) + inst.do_free_plmc_assertions(plmc_existential_deposits); + inst.do_free_statemint_asset_assertions(vec![UserToStatemintAsset::::new( + BOB, + 0_u128, + AcceptedFundingAsset::USDT.to_statemint_id(), + )]); + inst.do_reserved_plmc_assertions(vec![plmc_fundings[0].clone()], LockType::Participation(project_id)); + inst.do_contribution_transferred_statemint_asset_assertions(statemint_asset_fundings, project_id); } #[test] - pub fn bid_and_community_contribution_funding_assets_are_released_manually_on_funding_fail() { + fn remainder_round_ends_on_all_ct_sold_overbuy() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = default_evaluations(); - let bids = MockInstantiator::generate_bids_from_total_usd( - project.total_allocation_size.0 / 2, - project.minimum_price, - default_weights(), - default_bidders(), - default_multipliers(), + let (project_id, _) = inst.create_remainder_contributing_project( + default_project(0, ISSUER), + ISSUER, + default_evaluations(), + default_bids(), + default_community_buys(), ); + const BOB: AccountId = 808; - let community_contributions = vec![ - ContributionParams::new(BUYER_1, 1_000 * ASSET_UNIT, 2u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_2, 500 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_3, 73 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ]; - let remainder_contributions = vec![]; + let remaining_ct = inst.get_project_details(project_id).remaining_contribution_tokens.0 + + inst.get_project_details(project_id).remaining_contribution_tokens.1; - let project_id = inst.create_finished_project( - project, - issuer, - evaluations, - bids, - community_contributions.clone(), - remainder_contributions, - ); - let final_winning_bids = - inst.execute(|| Bids::::iter_prefix_values((project_id,)).collect::>()); - let final_bid_payouts = inst.execute(|| { - Bids::::iter_prefix_values((project_id,)) - .map(|bid| { - UserToStatemintAsset::::new( - bid.bidder, - bid.funding_asset_amount_locked, - bid.funding_asset.to_statemint_id(), - ) - }) - .sorted_by_key(|item| item.account) - .collect::>>() - }); + let ct_price = inst.get_project_details(project_id).weighted_average_price.expect("CT Price should exist"); - let total_expected_bid_payout = - final_bid_payouts.iter().map(|bid| bid.asset_amount.clone()).sum::>(); - let expected_community_contribution_payouts = MockInstantiator::calculate_contributed_funding_asset_spent( - community_contributions.clone(), - inst.get_project_details(project_id).weighted_average_price.unwrap(), - ); + let contributions = vec![ContributionParams::new(BOB, remaining_ct, 1u8, AcceptedFundingAsset::USDT)]; + let mut plmc_fundings = MockInstantiator::calculate_contributed_plmc_spent(contributions.clone(), ct_price); + let plmc_existential_deposits = contributions.accounts().existential_deposits(); + let plmc_ct_account_deposits = contributions.accounts().ct_account_deposits(); + let mut statemint_asset_fundings = + MockInstantiator::calculate_contributed_funding_asset_spent(contributions.clone(), ct_price); - let prev_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; - let prev_bidders_funding_balances = - inst.get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, final_bid_payouts.accounts()); - let prev_contributors_funding_balances = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - community_contributions - .iter() - .map(|test_contribution| test_contribution.contributor.clone()) - .collect::>(), - ); - let prev_total_bidder_balance = - prev_bidders_funding_balances.iter().map(|item| item.asset_amount).sum::>(); + inst.mint_plmc_to(plmc_fundings.clone()); + inst.mint_plmc_to(plmc_existential_deposits.clone()); + inst.mint_plmc_to(plmc_ct_account_deposits.clone()); + inst.mint_statemint_asset_to(statemint_asset_fundings.clone()); - call_and_is_ok!( - inst, - Pallet::::decide_project_outcome( - RuntimeOrigin::signed(issuer), - project_id, - FundingOutcomeDecision::RejectFunding - ) - ); - inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); + // Buy remaining CTs + inst.contribute_for_users(project_id, contributions) + .expect("The Buyer should be able to buy the exact amount of remaining CTs"); + inst.advance_time(2u64).unwrap(); + + // Check remaining CTs is 0 assert_eq!( - inst.get_project_details(project_id).cleanup, - Cleaner::Failure(CleanerState::Initialized(PhantomData)) + inst.get_project_details(project_id).remaining_contribution_tokens.0 + + inst.get_project_details(project_id).remaining_contribution_tokens.1, + 0, + "There are still remaining CTs" ); - for bid in final_winning_bids { - inst.execute(|| { - Pallet::::release_bid_funds_for( - RuntimeOrigin::signed(bid.bidder.clone()), - project_id, - bid.bidder, - bid.id, - ) - }) - .unwrap(); - } + // Check project is in FundingEnded state + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingSuccessful); - let stored_contributions = - inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); - for contribution in stored_contributions { - call_and_is_ok!( - inst, - Pallet::::release_contribution_funds_for( - RuntimeOrigin::signed(contribution.contributor.clone()), - project_id, - contribution.contributor, - contribution.id, - ) - ) - } + let reserved_plmc = plmc_fundings.swap_remove(0).plmc_amount; + let remaining_plmc: BalanceOf = + plmc_fundings.iter().fold(Zero::zero(), |acc, item| item.plmc_amount + acc); - let post_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; - let post_bidders_funding_balances = - inst.get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, final_bid_payouts.accounts()); - let post_total_bidder_balance = - post_bidders_funding_balances.iter().map(|item| item.asset_amount).sum::>(); - let post_contributors_funding_balances = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - community_contributions - .iter() - .map(|test_contribution| test_contribution.contributor.clone()) - .collect::>(), - ); - let post_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; + let actual_funding_transferred = statemint_asset_fundings.swap_remove(0).asset_amount; + let remaining_statemint_assets: BalanceOf = + statemint_asset_fundings.iter().fold(Zero::zero(), |acc, item| item.asset_amount + acc); - let contributors_funding_delta = MockInstantiator::generic_map_operation( - vec![post_contributors_funding_balances, prev_contributors_funding_balances], - MergeOperation::Subtract, + inst.do_free_plmc_assertions(plmc_existential_deposits); + inst.do_free_statemint_asset_assertions(vec![UserToStatemintAsset::::new( + BOB, + remaining_statemint_assets, + AcceptedFundingAsset::USDT.to_statemint_id(), + )]); + inst.do_reserved_plmc_assertions( + vec![UserToPLMCBalance::new(BOB, reserved_plmc)], + LockType::Participation(project_id), + ); + inst.do_contribution_transferred_statemint_asset_assertions( + vec![UserToStatemintAsset::new( + BOB, + actual_funding_transferred, + AcceptedFundingAsset::USDT.to_statemint_id(), + )], + project_id, ); - let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; - - assert_eq!(issuer_funding_delta, 0); - assert_eq!(prev_total_bidder_balance, 0u128); - assert_eq!(post_total_bidder_balance, total_expected_bid_payout); - assert_eq!(post_project_pot_funding_balance, 0u128); - assert_eq!(post_bidders_funding_balances, final_bid_payouts); - assert_eq!(contributors_funding_delta, expected_community_contribution_payouts) } #[test] - pub fn bid_and_community_contribution_plmc_bonded_is_returned_automatically_on_funding_fail() { + pub fn plmc_vesting_schedule_starts_automatically() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); let evaluations = default_evaluations(); - - let bids = MockInstantiator::generate_bids_from_total_usd( - project.total_allocation_size.0 / 2, - project.minimum_price, - default_weights(), - default_bidders(), - default_multipliers(), - ); - - let community_contributions = vec![ - ContributionParams::new(BUYER_1, 1_000 * ASSET_UNIT, 2u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_2, 500 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_3, 73 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ]; - - let remainder_contributions = vec![]; + let mut bids = default_bids(); + let community_contributions = default_community_buys(); + let remainder_contributions = default_remainder_buys(); let project_id = inst.create_finished_project( project, @@ -3767,86 +3443,46 @@ mod community_round_failure { evaluations, bids.clone(), community_contributions.clone(), - remainder_contributions, + remainder_contributions.clone(), ); - let prev_bidders_plmc_balances = - inst.get_free_plmc_balances_for(bids.iter().map(|bid| bid.bidder.clone()).collect::>()); - let prev_contributors_plmc_balances = inst.get_free_plmc_balances_for( - community_contributions.iter().map(|contribution| contribution.contributor.clone()).collect::>(), + let price = inst.get_project_details(project_id).weighted_average_price.unwrap(); + let stored_bids = inst.execute(|| Bids::::iter_prefix_values((project_id,)).collect_vec()); + bids = stored_bids + .into_iter() + .map(|bid| BidParams::from(bid.bidder, bid.final_ct_amount, bid.final_ct_usd_price)) + .collect(); + let auction_locked_plmc = MockInstantiator::calculate_auction_plmc_spent(&bids, Some(price)); + let community_locked_plmc = MockInstantiator::calculate_contributed_plmc_spent(community_contributions, price); + let remainder_locked_plmc = MockInstantiator::calculate_contributed_plmc_spent(remainder_contributions, price); + let all_plmc_locks = MockInstantiator::generic_map_operation( + vec![auction_locked_plmc, community_locked_plmc, remainder_locked_plmc], + MergeOperation::Add, ); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - call_and_is_ok!( - inst, - Pallet::::decide_project_outcome( - RuntimeOrigin::signed(issuer), - project_id, - FundingOutcomeDecision::RejectFunding - ) - ); - inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); - assert_eq!( - inst.get_project_details(project_id).cleanup, - Cleaner::Failure(CleanerState::Initialized(PhantomData)) - ); inst.advance_time(10u64).unwrap(); let details = inst.get_project_details(project_id); - assert_eq!(details.cleanup, Cleaner::Failure(CleanerState::Finished(PhantomData))); - - let post_bidders_plmc_balances = inst.get_free_plmc_balances_for(bids.accounts()); - let post_contributors_plmc_balances = inst.get_free_plmc_balances_for( - community_contributions.iter().map(|contribution| contribution.contributor.clone()).collect::>(), - ); - - let mut delta_bidders_plmc_balances = MockInstantiator::generic_map_operation( - vec![post_bidders_plmc_balances, prev_bidders_plmc_balances], - MergeOperation::Subtract, - ); - delta_bidders_plmc_balances.sort_by_key(|item| item.account); - - let mut delta_contributors_plmc_balances = MockInstantiator::generic_map_operation( - vec![post_contributors_plmc_balances, prev_contributors_plmc_balances], - MergeOperation::Subtract, - ); - delta_contributors_plmc_balances.sort_by_key(|item| item.account); - - let final_price = details.weighted_average_price.unwrap(); - let ct_deposit_required = <::ContributionTokenCurrency as AccountTouch< - ProjectIdOf, - AccountIdOf, - >>::deposit_required(project_id); - - let mut plmc_locked_for_bids = MockInstantiator::calculate_auction_plmc_spent(&bids, Some(final_price)); - plmc_locked_for_bids.sort_by_key(|item| item.account); - plmc_locked_for_bids.iter_mut().for_each(|item| item.plmc_amount += ct_deposit_required); + assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); - let mut plmc_locked_for_contributions = - MockInstantiator::calculate_contributed_plmc_spent(community_contributions, final_price); - plmc_locked_for_contributions.sort_by_key(|item| item.account); - plmc_locked_for_contributions.iter_mut().for_each(|item| item.plmc_amount += ct_deposit_required); + for UserToPLMCBalance { account, plmc_amount } in all_plmc_locks { + let schedule = inst.execute(|| { + ::Vesting::total_scheduled_amount(&account, LockType::Participation(project_id)) + }); - assert_eq!(delta_bidders_plmc_balances, plmc_locked_for_bids); - assert_eq!(delta_contributors_plmc_balances, plmc_locked_for_contributions); + assert_eq!(schedule.unwrap(), plmc_amount); + } } #[test] - pub fn bid_and_community_contribution_plmc_bonded_is_returned_manually_on_funding_fail() { + pub fn plmc_vesting_schedule_starts_manually() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); let evaluations = default_evaluations(); - - let mut bids = MockInstantiator::generate_bids_from_total_usd( - project.total_allocation_size.0, - project.minimum_price, - default_weights(), - default_bidders(), - default_multipliers(), - ); - bids.remove(0); - - let community_contributions = vec![]; - let remainder_contributions = vec![]; + let bids = default_bids(); + let community_contributions = default_community_buys(); + let remainder_contributions = default_remainder_buys(); let project_id = inst.create_finished_project( project, @@ -3854,764 +3490,667 @@ mod community_round_failure { evaluations, bids.clone(), community_contributions.clone(), - remainder_contributions, - ); - let final_winning_bids = - inst.execute(|| Bids::::iter_prefix_values((project_id,)).collect::>()); - let prev_bidders_plmc_balances = - inst.get_free_plmc_balances_for(bids.iter().map(|bid| bid.bidder.clone()).collect::>()); - let prev_contributors_plmc_balances = inst.get_free_plmc_balances_for( - community_contributions.iter().map(|contribution| contribution.contributor.clone()).collect::>(), - ); - call_and_is_ok!( - inst, - Pallet::::decide_project_outcome( - RuntimeOrigin::signed(issuer), - project_id, - FundingOutcomeDecision::RejectFunding - ) - ); - inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); - assert_eq!( - inst.get_project_details(project_id).cleanup, - Cleaner::Failure(CleanerState::Initialized(PhantomData)) + remainder_contributions.clone(), ); - for bid in final_winning_bids { - call_and_is_ok!( - inst, - Pallet::::release_bid_funds_for( - RuntimeOrigin::signed(bid.bidder.clone()), - project_id, - bid.bidder, - bid.id, - ), - Pallet::::bid_unbond_for( - RuntimeOrigin::signed(bid.bidder.clone()), - project_id, - bid.bidder, - bid.id, - ) - ); - } + let details = inst.get_project_details(project_id); + assert_eq!(details.status, ProjectStatus::FundingSuccessful); + assert_eq!(details.cleanup, Cleaner::NotReady); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - let stored_contributions = + let details = inst.get_project_details(project_id); + assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData))); + + let contributions = inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); - for contribution in stored_contributions { + for contribution in contributions { + let prev_scheduled = inst + .execute(|| { + ::Vesting::total_scheduled_amount( + &contribution.contributor, + LockType::Participation(project_id), + ) + }) + .unwrap_or(Zero::zero()); + call_and_is_ok!( inst, - Pallet::::release_contribution_funds_for( - RuntimeOrigin::signed(contribution.contributor.clone()), - project_id, - contribution.contributor, - contribution.id, - ), - Pallet::::contribution_unbond_for( - RuntimeOrigin::signed(contribution.contributor.clone()), + Pallet::::start_contribution_vesting_schedule_for( + RuntimeOrigin::signed(contribution.contributor), project_id, contribution.contributor, contribution.id, ) - ) - } - - let post_bidders_plmc_balances = - inst.get_free_plmc_balances_for(bids.iter().map(|bid| bid.bidder.clone()).collect::>()); - let post_contributors_plmc_balances = inst.get_free_plmc_balances_for( - community_contributions.iter().map(|contribution| contribution.contributor.clone()).collect::>(), - ); + ); - let mut delta_bidders_plmc_balances = MockInstantiator::generic_map_operation( - vec![post_bidders_plmc_balances, prev_bidders_plmc_balances], - MergeOperation::Subtract, - ); - delta_bidders_plmc_balances.sort_by_key(|item| item.account); - let mut delta_contributors_plmc_balances = MockInstantiator::generic_map_operation( - vec![post_contributors_plmc_balances, prev_contributors_plmc_balances], - MergeOperation::Subtract, - ); - delta_contributors_plmc_balances.sort_by_key(|item| item.account); + let post_scheduled = inst + .execute(|| { + ::Vesting::total_scheduled_amount( + &contribution.contributor, + LockType::Participation(project_id), + ) + }) + .unwrap(); - let details = inst.get_project_details(project_id); - let final_price = details.weighted_average_price.unwrap(); - let mut plmc_locked_for_bids = MockInstantiator::calculate_auction_plmc_spent(&bids, Some(final_price)); - plmc_locked_for_bids.sort_by_key(|item| item.account); - let mut plmc_locked_for_contributions = - MockInstantiator::calculate_contributed_plmc_spent(community_contributions, final_price); - plmc_locked_for_contributions.sort_by_key(|item| item.account); + let new_scheduled = post_scheduled - prev_scheduled; - assert_eq!(delta_bidders_plmc_balances, plmc_locked_for_bids); - assert_eq!(delta_contributors_plmc_balances, plmc_locked_for_contributions); + let contribution = inst.execute(|| { + Contributions::::get((project_id, contribution.contributor, contribution.id)).unwrap() + }); + assert_eq!(new_scheduled, contribution.plmc_vesting_info.unwrap().total_amount); + } } #[test] - fn community_contribution_ct_account_deposits_are_returned() { + pub fn plmc_vesting_full_amount() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let project_metadata = default_project(0, ISSUER); - let automatic_fail_funding_percent = Percent::from_percent(30); - let (bid_allocation, contribution_allocation) = project_metadata.total_allocation_size; - let deposit_required = <::ContributionTokenCurrency as AccountTouch< - ProjectIdOf, - AccountIdOf, - >>::deposit_required(0); - - let desired_total_usd_amount_bid = - automatic_fail_funding_percent * project_metadata.minimum_price.saturating_mul_int(bid_allocation); - let desired_total_usd_amount_contributed = - automatic_fail_funding_percent * project_metadata.minimum_price.saturating_mul_int(contribution_allocation); + let issuer = ISSUER; + let project = default_project(inst.get_new_nonce(), issuer); + let evaluations = default_evaluations(); + let bids = default_bids(); + let community_contributions = default_community_buys(); + let remainder_contributions = default_remainder_buys(); - let bids = MockInstantiator::generate_bids_from_total_usd( - desired_total_usd_amount_bid, - project_metadata.minimum_price, - default_weights(), - default_bidders(), - default_bidder_multipliers(), + let project_id = inst.create_finished_project( + project, + issuer, + evaluations, + bids, + community_contributions, + remainder_contributions, ); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - let community_contributions = MockInstantiator::generate_contributions_from_total_usd( - desired_total_usd_amount_contributed, - project_metadata.minimum_price, - default_weights(), - default_community_contributors(), - default_community_contributor_multipliers(), - ); + inst.advance_time(10u64).unwrap(); + let details = inst.get_project_details(project_id); + assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); - let zero_balances = community_contributions - .clone() - .accounts() + let stored_bids = inst.execute(|| Bids::::iter_prefix_values((project_id,)).collect::>()); + let stored_contributions = + inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); + + let bid_plmc_balances = + stored_bids.into_iter().map(|b| (b.bidder, b.plmc_vesting_info.unwrap().total_amount)).collect::>(); + let contributed_plmc_balances = stored_contributions .into_iter() - .map(|acc| UserToPLMCBalance::new(acc, 0u128)) - .collect_vec(); - inst.do_free_plmc_assertions(zero_balances.clone()); - inst.do_reserved_plmc_assertions(zero_balances.clone(), LockType::FutureDeposit(0)); + .map(|c| (c.contributor, c.plmc_vesting_info.unwrap().total_amount)) + .collect::>(); - let (project_id, _) = inst.create_remainder_contributing_project( - project_metadata, - ISSUER, - default_evaluations(), - bids.clone(), - community_contributions.clone(), + let merged_plmc_balances = MockInstantiator::generic_map_merge_reduce( + vec![contributed_plmc_balances.clone(), bid_plmc_balances.clone()], + |(account, _amount)| account.clone(), + BalanceOf::::zero(), + |(_account, amount), total| total + amount, ); + inst.advance_time((1 * DAYS + 1u32).into()).unwrap(); - let required_plmc_bonds = MockInstantiator::calculate_contributed_plmc_spent( - community_contributions, - inst.get_project_details(project_id).weighted_average_price.unwrap(), - ); - let plmc_existential_deposits = required_plmc_bonds.accounts().existential_deposits(); - let plmc_ct_account_deposits = required_plmc_bonds.accounts().ct_account_deposits(); - - let ed_balances = required_plmc_bonds - .accounts() - .into_iter() - .map(|acc| UserToPLMCBalance::new(acc, MockInstantiator::get_ed())) - .collect_vec(); - inst.do_free_plmc_assertions(ed_balances); - let ct_deposit_balances = required_plmc_bonds - .accounts() - .into_iter() - .map(|acc| UserToPLMCBalance::new(acc, deposit_required)) - .collect_vec(); - inst.do_reserved_plmc_assertions(ct_deposit_balances, LockType::FutureDeposit(project_id)); - - inst.advance_time(::RemainderFundingDuration::get() + 1).unwrap(); - - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingFailed); - - inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); - assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Failure(CleanerState::Finished(PhantomData))); - - let final_plmc_amounts = MockInstantiator::generic_map_operation( - vec![required_plmc_bonds, plmc_existential_deposits, plmc_ct_account_deposits], - MergeOperation::Add, - ); - inst.do_free_plmc_assertions(final_plmc_amounts); - inst.do_reserved_plmc_assertions(zero_balances, LockType::FutureDeposit(project_id)); - } -} - -mod remainder_round_success { - use super::*; + for (contributor, plmc_amount) in merged_plmc_balances { + let prev_free_balance = inst.execute(|| ::NativeCurrency::balance(&contributor)); + inst.execute(|| { + Pallet::::do_vest_plmc_for(contributor.clone(), project_id, contributor.clone()) + }) + .unwrap(); - #[test] - fn remainder_round_works() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let _ = inst.create_finished_project( - default_project(inst.get_new_nonce(), ISSUER), - ISSUER, - default_evaluations(), - default_bids(), - default_community_buys(), - default_remainder_buys(), - ); + let post_free_balance = inst.execute(|| ::NativeCurrency::balance(&contributor)); + assert_eq!(plmc_amount, post_free_balance - prev_free_balance); + } } #[test] - fn remainder_contributor_was_evaluator() { + pub fn plmc_vesting_partial_amount() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); - let mut evaluations = default_evaluations(); - let community_contributions = default_community_buys(); - let evaluator_contributor = 69; - let evaluation_amount = 420 * US_DOLLAR; - let remainder_contribution = - ContributionParams::new(evaluator_contributor, 600 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT); - evaluations.push(UserToUSDBalance::new(evaluator_contributor, evaluation_amount)); + let evaluations = default_evaluations(); let bids = default_bids(); + let community_contributions = default_community_buys(); + let remainder_contributions = default_remainder_buys(); - let (project_id, _) = - inst.create_remainder_contributing_project(project, issuer, evaluations, bids, community_contributions); - let ct_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); - let already_bonded_plmc = MockInstantiator::calculate_evaluation_plmc_spent(vec![UserToUSDBalance::new( - evaluator_contributor, - evaluation_amount, - )])[0] - .plmc_amount; - let plmc_available_for_contribution = - already_bonded_plmc - ::EvaluatorSlash::get() * already_bonded_plmc; - let necessary_plmc_for_buy = - MockInstantiator::calculate_contributed_plmc_spent(vec![remainder_contribution.clone()], ct_price)[0] - .plmc_amount; - let necessary_usdt_for_buy = - MockInstantiator::calculate_contributed_funding_asset_spent(vec![remainder_contribution.clone()], ct_price); - - inst.mint_plmc_to(vec![UserToPLMCBalance::new( - evaluator_contributor, - necessary_plmc_for_buy - plmc_available_for_contribution, - )]); - inst.mint_statemint_asset_to(necessary_usdt_for_buy); + let project_id = inst.create_finished_project( + project, + issuer, + evaluations, + bids, + community_contributions, + remainder_contributions, + ); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - inst.contribute_for_users(project_id, vec![remainder_contribution]).unwrap(); - } + inst.advance_time(15u64).unwrap(); + let details = inst.get_project_details(project_id); + assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); + let vest_start_block = details.funding_end_block.unwrap(); - #[test] - fn remainder_contributor_was_evaluator_vec_full() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); - let mut evaluations = default_evaluations(); - let bids = default_bids(); - let evaluator_contributor = 69; - let overflow_contribution = - ContributionParams::new(evaluator_contributor, 600 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT); + let stored_bids = inst.execute(|| Bids::::iter_prefix_values((project_id,)).collect::>()); + let stored_contributions = + inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); - let mut fill_contributions = Vec::new(); - for _i in 0..::MaxContributionsPerUser::get() { - fill_contributions.push(ContributionParams::new( - evaluator_contributor, - 10 * ASSET_UNIT, - 1u8, - AcceptedFundingAsset::USDT, - )); - } + let now = inst.current_block(); - let expected_price = MockInstantiator::calculate_price_from_test_bids(bids.clone()); - let fill_necessary_plmc = - MockInstantiator::calculate_contributed_plmc_spent(fill_contributions.clone(), expected_price); - let fill_necessary_usdt_for_bids = - MockInstantiator::calculate_contributed_funding_asset_spent(fill_contributions.clone(), expected_price); + let bid_plmc_balances = stored_bids + .into_iter() + .map(|b| { + (b.bidder, { + let blocks_vested = min(b.plmc_vesting_info.unwrap().duration, now - vest_start_block); + b.plmc_vesting_info.unwrap().amount_per_block * blocks_vested as u128 + }) + }) + .collect::>(); + let contributed_plmc_balances = stored_contributions + .into_iter() + .map(|c| { + (c.contributor, { + let blocks_vested = min(c.plmc_vesting_info.unwrap().duration, now - vest_start_block); + c.plmc_vesting_info.unwrap().amount_per_block * blocks_vested as u128 + }) + }) + .collect::>(); - let overflow_necessary_plmc = - MockInstantiator::calculate_contributed_plmc_spent(vec![overflow_contribution.clone()], expected_price); - let overflow_necessary_usdt = MockInstantiator::calculate_contributed_funding_asset_spent( - vec![overflow_contribution.clone()], - expected_price, + let merged_plmc_balances = MockInstantiator::generic_map_merge_reduce( + vec![contributed_plmc_balances.clone(), bid_plmc_balances.clone()], + |(account, _amount)| account.clone(), + BalanceOf::::zero(), + |(_account, amount), total| total + amount, ); - let evaluation_bond = - MockInstantiator::sum_balance_mappings(vec![fill_necessary_plmc, overflow_necessary_plmc.clone()]); - let plmc_available_for_participating = - evaluation_bond - ::EvaluatorSlash::get() * evaluation_bond; - - let evaluation_usd_amount = ::PriceProvider::get_price(PLMC_STATEMINT_ID) - .unwrap() - .saturating_mul_int(evaluation_bond); - evaluations.push(UserToUSDBalance::new(evaluator_contributor, evaluation_usd_amount)); - - let (project_id, _) = - inst.create_remainder_contributing_project(project, issuer, evaluations, bids, default_community_buys()); - - inst.mint_plmc_to(vec![UserToPLMCBalance::new( - evaluator_contributor, - evaluation_bond - plmc_available_for_participating, - )]); - inst.mint_statemint_asset_to(fill_necessary_usdt_for_bids); - inst.mint_statemint_asset_to(overflow_necessary_usdt); + for (contributor, amount) in merged_plmc_balances { + let prev_free_balance = inst.execute(|| ::NativeCurrency::balance(&contributor)); - inst.contribute_for_users(project_id, fill_contributions).unwrap(); - inst.contribute_for_users(project_id, vec![overflow_contribution]).unwrap(); + inst.execute(|| Pallet::::do_vest_plmc_for(contributor, project_id, contributor)).unwrap(); - let evaluation_bonded = inst.execute(|| { - ::NativeCurrency::balance_on_hold( - &LockType::Evaluation(project_id), - &evaluator_contributor, - ) - }); - assert_eq!(evaluation_bonded, ::EvaluatorSlash::get() * evaluation_bond); + let post_free_balance = inst.execute(|| ::NativeCurrency::balance(&contributor)); + assert_eq!(amount, post_free_balance - prev_free_balance); + } } +} + +mod remainder_round_failure { + use super::*; #[test] - fn remainder_round_ends_on_all_ct_sold_exact() { + fn remainder_contribution_ct_account_deposits_are_returned() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let (project_id, _) = inst.create_remainder_contributing_project( - default_project(0, ISSUER), - ISSUER, - default_evaluations(), - default_bids(), - default_community_buys(), - ); - const BOB: AccountId = 808; - - let remaining_ct = inst.get_project_details(project_id).remaining_contribution_tokens; - let ct_price = inst.get_project_details(project_id).weighted_average_price.expect("CT Price should exist"); + let project_metadata = default_project(0, ISSUER); + let automatic_fail_funding_percent = Percent::from_percent(30); + let (bid_allocation, contribution_allocation) = project_metadata.total_allocation_size; + let deposit_required = <::ContributionTokenCurrency as AccountTouch< + ProjectIdOf, + AccountIdOf, + >>::deposit_required(0); - let contributions = - vec![ContributionParams::new(BOB, remaining_ct.0 + remaining_ct.1, 1u8, AcceptedFundingAsset::USDT)]; - let mut plmc_fundings = MockInstantiator::calculate_contributed_plmc_spent(contributions.clone(), ct_price); - let plmc_existential_deposits = contributions.accounts().existential_deposits(); - let plmc_ct_account_deposits = contributions.accounts().ct_account_deposits(); - let statemint_asset_fundings = - MockInstantiator::calculate_contributed_funding_asset_spent(contributions.clone(), ct_price); + let remainder_contributors = vec![EVALUATOR_1, BIDDER_3, BUYER_4, BUYER_6, BIDDER_6]; - inst.mint_plmc_to(plmc_fundings.clone()); - inst.mint_plmc_to(plmc_existential_deposits.clone()); - inst.mint_plmc_to(plmc_ct_account_deposits.clone()); - inst.mint_statemint_asset_to(statemint_asset_fundings.clone()); + let desired_total_usd_amount_bid = + automatic_fail_funding_percent * project_metadata.minimum_price.saturating_mul_int(bid_allocation); + let desired_total_usd_amount_contributed = + automatic_fail_funding_percent * project_metadata.minimum_price.saturating_mul_int(contribution_allocation); - // Buy remaining CTs - inst.contribute_for_users(project_id, contributions) - .expect("The Buyer should be able to buy the exact amount of remaining CTs"); - inst.advance_time(2u64).unwrap(); + let bids = MockInstantiator::generate_bids_from_total_usd( + desired_total_usd_amount_bid, + project_metadata.minimum_price, + default_weights(), + default_bidders(), + default_bidder_multipliers(), + ); - // Check remaining CTs is 0 - assert_eq!( - inst.get_project_details(project_id).remaining_contribution_tokens.0 + - inst.get_project_details(project_id).remaining_contribution_tokens.1, - 0, - "There are still remaining CTs" + let community_contributions = MockInstantiator::generate_contributions_from_total_usd( + desired_total_usd_amount_contributed / 2, + project_metadata.minimum_price, + default_weights(), + default_community_contributors(), + default_community_contributor_multipliers(), ); - // Check project is in FundingEnded state - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingSuccessful); + let remainder_contributions = MockInstantiator::generate_contributions_from_total_usd( + desired_total_usd_amount_contributed / 2, + project_metadata.minimum_price, + default_weights(), + default_remainder_contributors(), + default_remainder_contributor_multipliers(), + ); - inst.do_free_plmc_assertions(plmc_existential_deposits); - inst.do_free_statemint_asset_assertions(vec![UserToStatemintAsset::::new( - BOB, - 0_u128, - AcceptedFundingAsset::USDT.to_statemint_id(), - )]); - inst.do_reserved_plmc_assertions(vec![plmc_fundings[0].clone()], LockType::Participation(project_id)); - inst.do_contribution_transferred_statemint_asset_assertions(statemint_asset_fundings, project_id); - } + let zero_balances = remainder_contributions + .clone() + .accounts() + .into_iter() + .map(|acc| UserToPLMCBalance::new(acc, 0u128)) + .collect_vec(); + inst.do_free_plmc_assertions(zero_balances.clone()); + inst.do_reserved_plmc_assertions(zero_balances.clone(), LockType::FutureDeposit(0)); - #[test] - fn remainder_round_ends_on_all_ct_sold_overbuy() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let (project_id, _) = inst.create_remainder_contributing_project( - default_project(0, ISSUER), + let project_id = inst.create_finished_project( + project_metadata, ISSUER, default_evaluations(), - default_bids(), - default_community_buys(), + bids.clone(), + community_contributions.clone(), + remainder_contributions.clone(), ); - const BOB: AccountId = 808; + let wap = inst.get_project_details(project_id).weighted_average_price.unwrap(); - let remaining_ct = inst.get_project_details(project_id).remaining_contribution_tokens.0 + - inst.get_project_details(project_id).remaining_contribution_tokens.1; + let bidder_plmc_bonds = MockInstantiator::calculate_auction_plmc_spent(&bids, Some(wap)); + let community_contributor_plmc_bonds = + MockInstantiator::calculate_contributed_plmc_spent(community_contributions.clone(), wap); + let evaluators_and_contributors_plmc_bonds = + MockInstantiator::calculate_total_plmc_locked_from_evaluations_and_remainder_contributions( + default_evaluations(), + remainder_contributions, + wap, + true, + ); - let ct_price = inst.get_project_details(project_id).weighted_average_price.expect("CT Price should exist"); + let mut expected_final_plmc_balances = MockInstantiator::generic_map_operation( + vec![bidder_plmc_bonds, community_contributor_plmc_bonds, evaluators_and_contributors_plmc_bonds], + MergeOperation::Add, + ); + expected_final_plmc_balances.iter_mut().for_each(|UserToPLMCBalance { account, plmc_amount }| { + *plmc_amount += deposit_required; + }); - let contributions = vec![ContributionParams::new(BOB, remaining_ct, 1u8, AcceptedFundingAsset::USDT)]; - let mut plmc_fundings = MockInstantiator::calculate_contributed_plmc_spent(contributions.clone(), ct_price); - let plmc_existential_deposits = contributions.accounts().existential_deposits(); - let plmc_ct_account_deposits = contributions.accounts().ct_account_deposits(); - let mut statemint_asset_fundings = - MockInstantiator::calculate_contributed_funding_asset_spent(contributions.clone(), ct_price); + let prev_balances = inst.get_free_plmc_balances_for(expected_final_plmc_balances.accounts()); + let ct_deposit_balances = expected_final_plmc_balances + .accounts() + .into_iter() + .map(|acc| UserToPLMCBalance::new(acc, deposit_required)) + .collect_vec(); + inst.do_reserved_plmc_assertions(ct_deposit_balances, LockType::FutureDeposit(project_id)); - inst.mint_plmc_to(plmc_fundings.clone()); - inst.mint_plmc_to(plmc_existential_deposits.clone()); - inst.mint_plmc_to(plmc_ct_account_deposits.clone()); - inst.mint_statemint_asset_to(statemint_asset_fundings.clone()); + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingFailed); + inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); + assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Failure(CleanerState::Finished(PhantomData))); - // Buy remaining CTs - inst.contribute_for_users(project_id, contributions) - .expect("The Buyer should be able to buy the exact amount of remaining CTs"); - inst.advance_time(2u64).unwrap(); + let post_balances = inst.get_free_plmc_balances_for(expected_final_plmc_balances.accounts()); - // Check remaining CTs is 0 - assert_eq!( - inst.get_project_details(project_id).remaining_contribution_tokens.0 + - inst.get_project_details(project_id).remaining_contribution_tokens.1, - 0, - "There are still remaining CTs" - ); + let plmc_deltas = + MockInstantiator::generic_map_operation(vec![post_balances, prev_balances], MergeOperation::Subtract); - // Check project is in FundingEnded state - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingSuccessful); + assert_eq!(plmc_deltas, expected_final_plmc_balances); + inst.do_reserved_plmc_assertions(zero_balances, LockType::FutureDeposit(project_id)); + } +} - let reserved_plmc = plmc_fundings.swap_remove(0).plmc_amount; - let remaining_plmc: BalanceOf = - plmc_fundings.iter().fold(Zero::zero(), |acc, item| item.plmc_amount + acc); +mod funding_end { + use super::*; - let actual_funding_transferred = statemint_asset_fundings.swap_remove(0).asset_amount; - let remaining_statemint_assets: BalanceOf = - statemint_asset_fundings.iter().fold(Zero::zero(), |acc, item| item.asset_amount + acc); + #[test] + fn automatic_fail_less_eq_33_percent() { + for funding_percent in (1..=33).step_by(5) { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let project_metadata = default_project(inst.get_new_nonce(), ISSUER); + let min_price = project_metadata.minimum_price; + let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) * + (project_metadata.minimum_price.checked_mul_int(project_metadata.total_allocation_size.0).unwrap()); + let evaluations = default_evaluations(); + let bids = MockInstantiator::generate_bids_from_total_usd( + Percent::from_percent(50u8) * twenty_percent_funding_usd, + min_price, + default_weights(), + default_bidders(), + default_multipliers(), + ); + let contributions = MockInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(50u8) * twenty_percent_funding_usd, + min_price, + default_weights(), + default_community_contributors(), + default_multipliers(), + ); + let project_id = + inst.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]); + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingFailed); + } + } - inst.do_free_plmc_assertions(plmc_existential_deposits); - inst.do_free_statemint_asset_assertions(vec![UserToStatemintAsset::::new( - BOB, - remaining_statemint_assets, - AcceptedFundingAsset::USDT.to_statemint_id(), - )]); - inst.do_reserved_plmc_assertions( - vec![UserToPLMCBalance::new(BOB, reserved_plmc)], - LockType::Participation(project_id), - ); - inst.do_contribution_transferred_statemint_asset_assertions( - vec![UserToStatemintAsset::new( - BOB, - actual_funding_transferred, - AcceptedFundingAsset::USDT.to_statemint_id(), - )], - project_id, - ); + #[test] + fn automatic_success_bigger_eq_90_percent() { + for funding_percent in (90..=100).step_by(2) { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let project_metadata = default_project(inst.get_new_nonce(), ISSUER); + let min_price = project_metadata.minimum_price; + let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) * + (project_metadata + .minimum_price + .checked_mul_int( + project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1, + ) + .unwrap()); + let evaluations = default_evaluations(); + let bids = MockInstantiator::generate_bids_from_total_usd( + Percent::from_percent(50u8) * twenty_percent_funding_usd, + min_price, + default_weights(), + default_bidders(), + default_multipliers(), + ); + let contributions = MockInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(50u8) * twenty_percent_funding_usd, + min_price, + default_weights(), + default_community_contributors(), + default_multipliers(), + ); + let project_id = + inst.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]); + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingSuccessful); + } } #[test] - pub fn cannot_mint_ct_twice_manually() { + fn manual_outcome_above33_to_below90() { + for funding_percent in (34..90).step_by(5) { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let project_metadata = default_project(inst.get_new_nonce(), ISSUER); + let min_price = project_metadata.minimum_price; + let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) * + (project_metadata + .minimum_price + .checked_mul_int( + project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1, + ) + .unwrap()); + let evaluations = default_evaluations(); + let bids = MockInstantiator::generate_bids_from_total_usd( + Percent::from_percent(50u8) * twenty_percent_funding_usd, + min_price, + default_weights(), + default_bidders(), + default_multipliers(), + ); + let contributions = MockInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(50u8) * twenty_percent_funding_usd, + min_price, + default_weights(), + default_community_contributors(), + default_multipliers(), + ); + let project_id = + inst.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]); + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AwaitingProjectDecision); + } + } + + #[test] + fn manual_acceptance() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); + let project_metadata = default_project(inst.get_new_nonce(), ISSUER); + let min_price = project_metadata.minimum_price; + let twenty_percent_funding_usd = Perquintill::from_percent(55) * + (project_metadata + .minimum_price + .checked_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1) + .unwrap()); let evaluations = default_evaluations(); - let bids = default_bids(); - let community_contributions = default_community_buys(); - let remainder_contributions = default_remainder_buys(); - - let project_id = inst.create_finished_project( - project, - issuer, - evaluations, - bids, - community_contributions, - remainder_contributions.clone(), + let bids = MockInstantiator::generate_bids_from_total_usd( + Percent::from_percent(50u8) * twenty_percent_funding_usd, + min_price, + default_weights(), + default_bidders(), + default_multipliers(), ); - let details = inst.get_project_details(project_id); - assert_eq!(details.status, ProjectStatus::FundingSuccessful); - assert_eq!(details.cleanup, Cleaner::NotReady); + let contributions = MockInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(50u8) * twenty_percent_funding_usd, + min_price, + default_weights(), + default_community_contributors(), + default_multipliers(), + ); + let project_id = + inst.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]); + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AwaitingProjectDecision); - let stored_contributions = inst.execute(|| { - let evaluator_contribution = - Contributions::::iter_prefix_values((project_id, EVALUATOR_2)).next().unwrap(); - let buyer_contribution = - Contributions::::iter_prefix_values((project_id, BUYER_2)).next().unwrap(); - let bidder_contribution = - Contributions::::iter_prefix_values((project_id, BIDDER_1)).next().unwrap(); - vec![evaluator_contribution.clone(), buyer_contribution.clone(), bidder_contribution.clone()] - }); - for contribution in stored_contributions.clone() { - inst.execute(|| { - assert_noop!( - Pallet::::contribution_ct_mint_for( - RuntimeOrigin::signed(contribution.contributor), - project_id, - contribution.contributor, - contribution.id, - ), - Error::::CannotClaimYet - ); - }) - } - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - - let details = inst.get_project_details(project_id); - assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData))); + let project_id = project_id; + inst.execute(|| { + FundingModule::do_decide_project_outcome(ISSUER, project_id, FundingOutcomeDecision::AcceptFunding) + }) + .unwrap(); - for contribution in stored_contributions.clone() { - inst.execute(|| { - Pallet::::contribution_ct_mint_for( - RuntimeOrigin::signed(contribution.contributor), - project_id, - contribution.contributor, - contribution.id, - ) - .unwrap(); + inst.advance_time(1u64).unwrap(); + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingSuccessful); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - assert_noop!( - Pallet::::contribution_ct_mint_for( - RuntimeOrigin::signed(contribution.contributor), - project_id, - contribution.contributor, - contribution.id, - ), - Error::::NotAllowed - ); - }); - } + assert_matches!(inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Initialized(_))); + inst.test_ct_created_for(project_id); inst.advance_time(10u64).unwrap(); - let details = inst.get_project_details(project_id); - assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); - - let evaluator_2_reward = extract_from_event!( - &mut inst, - Event::::EvaluationRewarded { evaluator: EVALUATOR_2, amount, .. }, - amount - ) - .unwrap(); - - let total_remainder_participant_ct_amounts = vec![ - (EVALUATOR_2, 300 * ASSET_UNIT + evaluator_2_reward), - (BUYER_2, 600 * ASSET_UNIT + 200 * ASSET_UNIT), - (BIDDER_1, 40000 * ASSET_UNIT + 4000 * ASSET_UNIT), - ]; - for (contributor, amount) in total_remainder_participant_ct_amounts { - let minted = - inst.execute(|| ::ContributionTokenCurrency::balance(project_id, contributor)); - assert_eq!(minted, amount); - } + assert_matches!( + inst.get_project_details(project_id).cleanup, + Cleaner::Success(CleanerState::Finished(PhantomData)) + ); } #[test] - pub fn cannot_mint_ct_manually_after_automatic_mint() { + fn manual_rejection() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); + let project_metadata = default_project(inst.get_new_nonce(), ISSUER); + let min_price = project_metadata.minimum_price; + let twenty_percent_funding_usd = Perquintill::from_percent(55) * + (project_metadata + .minimum_price + .checked_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1) + .unwrap()); let evaluations = default_evaluations(); - let bids = default_bids(); - let community_contributions = default_community_buys(); - let remainder_contributions = default_remainder_buys(); - - let project_id = inst.create_finished_project( - project, - issuer, - evaluations, - bids, - community_contributions, - remainder_contributions.clone(), + let bids = MockInstantiator::generate_bids_from_total_usd( + Percent::from_percent(50u8) * twenty_percent_funding_usd, + min_price, + default_weights(), + default_bidders(), + default_multipliers(), ); - let details = inst.get_project_details(project_id); - assert_eq!(details.status, ProjectStatus::FundingSuccessful); - assert_eq!(details.cleanup, Cleaner::NotReady); + let contributions = MockInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(50u8) * twenty_percent_funding_usd, + min_price, + default_weights(), + default_community_contributors(), + default_multipliers(), + ); + let project_id = + inst.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]); + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AwaitingProjectDecision); - let stored_contributions = inst.execute(|| { - let evaluator_contribution = - Contributions::::iter_prefix_values((project_id, EVALUATOR_2)).next().unwrap(); - let buyer_contribution = - Contributions::::iter_prefix_values((project_id, BUYER_2)).next().unwrap(); - let bidder_contribution = - Contributions::::iter_prefix_values((project_id, BIDDER_1)).next().unwrap(); - vec![evaluator_contribution.clone(), buyer_contribution.clone(), bidder_contribution.clone()] - }); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + let project_id = project_id; + inst.execute(|| { + FundingModule::do_decide_project_outcome(ISSUER, project_id, FundingOutcomeDecision::RejectFunding) + }) + .unwrap(); - inst.advance_time(10u64).unwrap(); - let details = inst.get_project_details(project_id); - assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); + inst.advance_time(1u64).unwrap(); - let evaluator_2_reward = extract_from_event!( - &mut inst, - Event::::EvaluationRewarded { evaluator: EVALUATOR_2, amount, .. }, - amount - ) - .unwrap(); + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingFailed); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + assert_matches!( + inst.get_project_details(project_id).cleanup, + Cleaner::Failure(CleanerState::Initialized(PhantomData)) + ); - let total_remainder_participant_ct_amounts = vec![ - (EVALUATOR_2, 300 * ASSET_UNIT + evaluator_2_reward), - (BUYER_2, 600 * ASSET_UNIT + 200 * ASSET_UNIT), - (BIDDER_1, 40000 * ASSET_UNIT + 4000 * ASSET_UNIT), - ]; - for (contributor, amount) in total_remainder_participant_ct_amounts { - let minted = - inst.execute(|| ::ContributionTokenCurrency::balance(project_id, contributor)); - assert_eq!(minted, amount); - } + inst.test_ct_not_created_for(project_id); - for contribution in stored_contributions.clone() { - inst.execute(|| { - assert_noop!( - Pallet::::contribution_ct_mint_for( - RuntimeOrigin::signed(contribution.contributor), - project_id, - contribution.contributor, - contribution.id, - ), - Error::::NotAllowed - ); - }); - } + inst.advance_time(10u64).unwrap(); + assert_matches!( + inst.get_project_details(project_id).cleanup, + Cleaner::Failure(CleanerState::Finished(PhantomData)) + ); } #[test] - pub fn plmc_vesting_schedule_starts_automatically() { + fn automatic_acceptance_on_manual_decision_after_time_delta() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); + let project_metadata = default_project(inst.get_new_nonce(), ISSUER); + let min_price = project_metadata.minimum_price; + let twenty_percent_funding_usd = Perquintill::from_percent(55) * + (project_metadata + .minimum_price + .checked_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1) + .unwrap()); let evaluations = default_evaluations(); - let mut bids = default_bids(); - let community_contributions = default_community_buys(); - let remainder_contributions = default_remainder_buys(); - - let project_id = inst.create_finished_project( - project, - issuer, - evaluations, - bids.clone(), - community_contributions.clone(), - remainder_contributions.clone(), + let bids = MockInstantiator::generate_bids_from_total_usd( + Percent::from_percent(50u8) * twenty_percent_funding_usd, + min_price, + default_weights(), + default_bidders(), + default_multipliers(), ); - - let price = inst.get_project_details(project_id).weighted_average_price.unwrap(); - let stored_bids = inst.execute(|| Bids::::iter_prefix_values((project_id,)).collect_vec()); - bids = stored_bids - .into_iter() - .map(|bid| BidParams::from(bid.bidder, bid.final_ct_amount, bid.final_ct_usd_price)) - .collect(); - let auction_locked_plmc = MockInstantiator::calculate_auction_plmc_spent(&bids, Some(price)); - let community_locked_plmc = MockInstantiator::calculate_contributed_plmc_spent(community_contributions, price); - let remainder_locked_plmc = MockInstantiator::calculate_contributed_plmc_spent(remainder_contributions, price); - let all_plmc_locks = MockInstantiator::generic_map_operation( - vec![auction_locked_plmc, community_locked_plmc, remainder_locked_plmc], - MergeOperation::Add, + let contributions = MockInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(50u8) * twenty_percent_funding_usd, + min_price, + default_weights(), + default_community_contributors(), + default_multipliers(), ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + let project_id = + inst.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]); + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AwaitingProjectDecision); - inst.advance_time(10u64).unwrap(); - let details = inst.get_project_details(project_id); - assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); + let project_id = project_id; + inst.advance_time(1u64 + ::ManualAcceptanceDuration::get()).unwrap(); + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingSuccessful); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - for UserToPLMCBalance { account, plmc_amount } in all_plmc_locks { - let schedule = inst.execute(|| { - ::Vesting::total_scheduled_amount(&account, LockType::Participation(project_id)) - }); + assert_matches!( + inst.get_project_details(project_id).cleanup, + Cleaner::Success(CleanerState::Initialized(PhantomData)) + ); + inst.test_ct_created_for(project_id); - assert_eq!(schedule.unwrap(), plmc_amount); - } + inst.advance_time(10u64).unwrap(); + assert_matches!( + inst.get_project_details(project_id).cleanup, + Cleaner::Success(CleanerState::Finished(PhantomData)) + ); } #[test] - pub fn plmc_vesting_schedule_starts_manually() { + fn evaluators_get_slashed_funding_accepted() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = default_evaluations(); - let bids = default_bids(); - let community_contributions = default_community_buys(); - let remainder_contributions = default_remainder_buys(); + let project_id = project_from_funding_reached(&mut inst, 43u64); + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AwaitingProjectDecision); - let project_id = inst.create_finished_project( - project, - issuer, - evaluations, - bids.clone(), - community_contributions.clone(), - remainder_contributions.clone(), + let old_evaluation_locked_plmc = inst + .get_all_reserved_plmc_balances(LockType::Evaluation(project_id)) + .into_iter() + .filter(|item| item.plmc_amount > Zero::zero()) + .collect::>>(); + + let evaluators = old_evaluation_locked_plmc.accounts(); + + let old_participation_locked_plmc = + inst.get_reserved_plmc_balances_for(evaluators.clone(), LockType::Participation(project_id)); + let old_free_plmc = inst.get_free_plmc_balances_for(evaluators.clone()); + + call_and_is_ok!( + inst, + FundingModule::do_decide_project_outcome(ISSUER, project_id, FundingOutcomeDecision::AcceptFunding) + ); + inst.advance_time(1u64).unwrap(); + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingSuccessful); + inst.advance_time(::SuccessToSettlementTime::get() + 10u64).unwrap(); + assert_matches!( + inst.get_project_details(project_id).cleanup, + Cleaner::Success(CleanerState::Finished(PhantomData)) ); - let details = inst.get_project_details(project_id); - assert_eq!(details.status, ProjectStatus::FundingSuccessful); - assert_eq!(details.cleanup, Cleaner::NotReady); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + let slashed_evaluation_locked_plmc = MockInstantiator::slash_evaluator_balances(old_evaluation_locked_plmc); + let expected_evaluator_free_balances = MockInstantiator::generic_map_operation( + vec![slashed_evaluation_locked_plmc, old_participation_locked_plmc, old_free_plmc], + MergeOperation::Add, + ); - let details = inst.get_project_details(project_id); - assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData))); + let actual_evaluator_free_balances = inst.get_free_plmc_balances_for(evaluators.clone()); - let contributions = - inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); - for contribution in contributions { - let prev_scheduled = inst - .execute(|| { - ::Vesting::total_scheduled_amount( - &contribution.contributor, - LockType::Participation(project_id), - ) - }) - .unwrap_or(Zero::zero()); + assert_eq!(actual_evaluator_free_balances, expected_evaluator_free_balances); + } - call_and_is_ok!( - inst, - Pallet::::start_contribution_vesting_schedule_for( - RuntimeOrigin::signed(contribution.contributor), - project_id, - contribution.contributor, - contribution.id, - ) - ); + #[test] + fn evaluators_get_slashed_funding_funding_rejected() { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let project_id = project_from_funding_reached(&mut inst, 56u64); + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AwaitingProjectDecision); - let post_scheduled = inst - .execute(|| { - ::Vesting::total_scheduled_amount( - &contribution.contributor, - LockType::Participation(project_id), - ) - }) - .unwrap(); + let old_evaluation_locked_plmc = inst + .get_all_reserved_plmc_balances(LockType::Evaluation(project_id)) + .into_iter() + .filter(|item| item.plmc_amount > Zero::zero()) + .collect::>>(); - let new_scheduled = post_scheduled - prev_scheduled; + let evaluators = old_evaluation_locked_plmc.accounts(); - let contribution = inst.execute(|| { - Contributions::::get((project_id, contribution.contributor, contribution.id)).unwrap() - }); - assert_eq!(new_scheduled, contribution.plmc_vesting_info.unwrap().total_amount); - } - } + let old_participation_locked_plmc = + inst.get_reserved_plmc_balances_for(evaluators.clone(), LockType::Participation(project_id)); + let old_free_plmc = inst.get_free_plmc_balances_for(evaluators.clone()); - #[test] - pub fn plmc_vesting_full_amount() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = default_evaluations(); - let bids = default_bids(); - let community_contributions = default_community_buys(); - let remainder_contributions = default_remainder_buys(); + call_and_is_ok!( + inst, + FundingModule::do_decide_project_outcome(ISSUER, project_id, FundingOutcomeDecision::RejectFunding) + ); + inst.advance_time(1u64).unwrap(); + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingFailed); + inst.advance_time(::SuccessToSettlementTime::get() + 10u64).unwrap(); + assert_matches!( + inst.get_project_details(project_id).cleanup, + Cleaner::Failure(CleanerState::Finished(PhantomData)) + ); - let project_id = inst.create_finished_project( - project, - issuer, - evaluations, - bids, - community_contributions, - remainder_contributions, + let slashed_evaluation_locked_plmc = MockInstantiator::slash_evaluator_balances(old_evaluation_locked_plmc); + let mut expected_evaluator_free_balances = MockInstantiator::generic_map_operation( + vec![slashed_evaluation_locked_plmc, old_participation_locked_plmc, old_free_plmc], + MergeOperation::Add, ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + let ct_deposit_required = <::ContributionTokenCurrency as AccountTouch< + ProjectIdOf, + AccountIdOf, + >>::deposit_required(project_id); + expected_evaluator_free_balances + .iter_mut() + .for_each(|UserToPLMCBalance { plmc_amount, .. }| *plmc_amount += ct_deposit_required); - inst.advance_time(10u64).unwrap(); - let details = inst.get_project_details(project_id); - assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); + let actual_evaluator_free_balances = inst.get_free_plmc_balances_for(evaluators.clone()); - let stored_bids = inst.execute(|| Bids::::iter_prefix_values((project_id,)).collect::>()); - let stored_contributions = - inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); + assert_eq!(actual_evaluator_free_balances, expected_evaluator_free_balances); + } - let bid_plmc_balances = - stored_bids.into_iter().map(|b| (b.bidder, b.plmc_vesting_info.unwrap().total_amount)).collect::>(); - let contributed_plmc_balances = stored_contributions + #[test] + fn evaluators_get_slashed_funding_failed() { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let project_id = project_from_funding_reached(&mut inst, 24u64); + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingFailed); + + let old_evaluation_locked_plmc = inst + .get_all_reserved_plmc_balances(LockType::Evaluation(project_id)) .into_iter() - .map(|c| (c.contributor, c.plmc_vesting_info.unwrap().total_amount)) + .filter(|item| item.plmc_amount > Zero::zero()) .collect::>(); - let merged_plmc_balances = MockInstantiator::generic_map_merge_reduce( - vec![contributed_plmc_balances.clone(), bid_plmc_balances.clone()], - |(account, _amount)| account.clone(), - BalanceOf::::zero(), - |(_account, amount), total| total + amount, + let evaluators = old_evaluation_locked_plmc.accounts(); + + let old_participation_locked_plmc = + inst.get_reserved_plmc_balances_for(evaluators.clone(), LockType::Participation(project_id)); + let old_free_plmc = inst.get_free_plmc_balances_for(evaluators.clone()); + + inst.advance_time(::SuccessToSettlementTime::get() + 10u64).unwrap(); + assert_matches!( + inst.get_project_details(project_id).cleanup, + Cleaner::Failure(CleanerState::Finished(PhantomData)) ); - inst.advance_time((1 * DAYS + 1u32).into()).unwrap(); - for (contributor, plmc_amount) in merged_plmc_balances { - let prev_free_balance = inst.execute(|| ::NativeCurrency::balance(&contributor)); - inst.execute(|| { - Pallet::::do_vest_plmc_for(contributor.clone(), project_id, contributor.clone()) - }) - .unwrap(); + let slashed_evaluation_locked_plmc = MockInstantiator::slash_evaluator_balances(old_evaluation_locked_plmc); + let mut expected_evaluator_free_balances = MockInstantiator::generic_map_operation( + vec![slashed_evaluation_locked_plmc, old_participation_locked_plmc, old_free_plmc], + MergeOperation::Add, + ); + let ct_deposit_required = <::ContributionTokenCurrency as AccountTouch< + ProjectIdOf, + AccountIdOf, + >>::deposit_required(project_id); + expected_evaluator_free_balances + .iter_mut() + .for_each(|UserToPLMCBalance { plmc_amount, .. }| *plmc_amount += ct_deposit_required); - let post_free_balance = inst.execute(|| ::NativeCurrency::balance(&contributor)); - assert_eq!(plmc_amount, post_free_balance - prev_free_balance); - } + let actual_evaluator_free_balances = inst.get_free_plmc_balances_for(evaluators.clone()); + + assert_eq!(actual_evaluator_free_balances, expected_evaluator_free_balances); } #[test] - pub fn plmc_vesting_partial_amount() { + fn ct_minted_automatically() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); @@ -4623,144 +4162,219 @@ mod remainder_round_success { let project_id = inst.create_finished_project( project, issuer, - evaluations, - bids, - community_contributions, - remainder_contributions, + evaluations.clone(), + bids.clone(), + community_contributions.clone(), + remainder_contributions.clone(), ); + let details = inst.get_project_details(project_id); + assert_eq!(details.status, ProjectStatus::FundingSuccessful); + assert_eq!(details.cleanup, Cleaner::NotReady); inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - inst.advance_time(15u64).unwrap(); + inst.advance_time(10u64).unwrap(); let details = inst.get_project_details(project_id); assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); - let vest_start_block = details.funding_end_block.unwrap(); - - let stored_bids = inst.execute(|| Bids::::iter_prefix_values((project_id,)).collect::>()); - let stored_contributions = - inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); - let now = inst.current_block(); + let evaluators = evaluations.accounts(); + let evaluator_ct_amounts = evaluators + .iter() + .map(|account| { + let evaluations = inst.execute(|| { + Evaluations::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + let total_evaluator_ct_rewarded = evaluations + .iter() + .map(|evaluation| evaluation.rewarded_or_slashed) + .map(|reward_or_slash| { + if let Some(RewardOrSlash::Reward(balance)) = reward_or_slash { + balance + } else { + Zero::zero() + } + }) + .sum::(); - let bid_plmc_balances = stored_bids - .into_iter() - .map(|b| { - (b.bidder, { - let blocks_vested = min(b.plmc_vesting_info.unwrap().duration, now - vest_start_block); - b.plmc_vesting_info.unwrap().amount_per_block * blocks_vested as u128 - }) + (account, total_evaluator_ct_rewarded) }) - .collect::>(); - let contributed_plmc_balances = stored_contributions - .into_iter() - .map(|c| { - (c.contributor, { - let blocks_vested = min(c.plmc_vesting_info.unwrap().duration, now - vest_start_block); - c.plmc_vesting_info.unwrap().amount_per_block * blocks_vested as u128 - }) + .collect_vec(); + + let bidders = bids.accounts(); + let bidder_ct_amounts = bidders + .iter() + .map(|account| { + let bids = inst.execute(|| { + Bids::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + let total_bidder_ct_rewarded = bids.iter().map(|bid| bid.final_ct_amount).sum::(); + + (account, total_bidder_ct_rewarded) }) - .collect::>(); + .collect_vec(); - let merged_plmc_balances = MockInstantiator::generic_map_merge_reduce( - vec![contributed_plmc_balances.clone(), bid_plmc_balances.clone()], - |(account, _amount)| account.clone(), - BalanceOf::::zero(), - |(_account, amount), total| total + amount, - ); + let community_accounts = community_contributions.accounts(); + let remainder_accounts = remainder_contributions.accounts(); + let all_contributors = community_accounts.iter().chain(remainder_accounts.iter()).unique(); + let contributor_ct_amounts = all_contributors + .map(|account| { + let contributions = inst.execute(|| { + Contributions::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + let total_contributor_ct_rewarded = + contributions.iter().map(|contribution| contribution.ct_amount).sum::(); - for (contributor, amount) in merged_plmc_balances { - let prev_free_balance = inst.execute(|| ::NativeCurrency::balance(&contributor)); + (account, total_contributor_ct_rewarded) + }) + .collect_vec(); - inst.execute(|| Pallet::::do_vest_plmc_for(contributor, project_id, contributor)).unwrap(); + let all_ct_expectations = MockInstantiator::generic_map_merge_reduce( + vec![evaluator_ct_amounts, bidder_ct_amounts, contributor_ct_amounts], + |item| item.0, + Zero::zero(), + |item, accumulator| accumulator + item.1, + ); - let post_free_balance = inst.execute(|| ::NativeCurrency::balance(&contributor)); - assert_eq!(amount, post_free_balance - prev_free_balance); + for (account, amount) in all_ct_expectations { + let minted = + inst.execute(|| ::ContributionTokenCurrency::balance(project_id, account)); + assert_eq!(minted, amount); } } #[test] - pub fn remainder_contribution_and_bid_funding_assets_are_paid_automatically_to_issuer() { + fn ct_minted_manually() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); let evaluations = default_evaluations(); let bids = default_bids(); - let community_contributions = vec![]; + let community_contributions = default_community_buys(); let remainder_contributions = default_remainder_buys(); let project_id = inst.create_finished_project( project, issuer, - evaluations, - bids, - community_contributions, - remainder_contributions, + evaluations.clone(), + bids.clone(), + community_contributions.clone(), + remainder_contributions.clone(), + ); + let details = inst.get_project_details(project_id); + assert_eq!(details.status, ProjectStatus::FundingSuccessful); + assert_eq!(details.cleanup, Cleaner::NotReady); + // do_end_funding + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + assert_eq!( + inst.get_project_details(project_id).cleanup, + Cleaner::Success(CleanerState::Initialized(PhantomData)) ); - let final_bid_payouts = inst.execute(|| { - Bids::::iter_prefix_values((project_id,)) - .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) - .map(|bid| { - UserToStatemintAsset::new( - bid.bidder, - bid.funding_asset_amount_locked, - bid.funding_asset.to_statemint_id(), - ) - }) - .collect::>>() - }); - let final_contribution_payouts = inst.execute(|| { - Contributions::::iter_prefix_values((project_id,)) - .map(|contribution| { - UserToStatemintAsset::new( - contribution.contributor, - contribution.funding_asset_amount, - contribution.funding_asset.to_statemint_id(), - ) - }) - .collect::>>() - }); + let evaluators = evaluations.accounts(); + let evaluator_ct_amounts = evaluators + .iter() + .map(|account| { + let evaluations = inst.execute(|| { + Evaluations::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + for evaluation in evaluations.iter() { + inst.execute(|| { + assert_ok!(Pallet::::evaluation_reward_payout_for( + RuntimeOrigin::signed(evaluation.evaluator), + project_id, + evaluation.evaluator, + evaluation.id, + )); + }); + } + let evaluations = inst.execute(|| { + Evaluations::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + let total_evaluator_ct_rewarded = evaluations + .iter() + .map(|evaluation| evaluation.rewarded_or_slashed) + .map(|reward_or_slash| { + if let Some(RewardOrSlash::Reward(balance)) = reward_or_slash { + balance + } else { + Zero::zero() + } + }) + .sum::(); - let total_expected_bid_payout = - final_bid_payouts.iter().map(|bid| bid.asset_amount.clone()).sum::>(); - let total_expected_contribution_payout = final_contribution_payouts + (account, total_evaluator_ct_rewarded) + }) + .collect_vec(); + + let bidders = bids.accounts(); + let bidder_ct_amounts = bidders .iter() - .map(|contribution| contribution.asset_amount.clone()) - .sum::>(); + .map(|account| { + let bids = inst.execute(|| { + Bids::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + for bid in bids.iter() { + inst.execute(|| { + assert_ok!(Pallet::::bid_ct_mint_for( + RuntimeOrigin::signed(bid.bidder), + project_id, + bid.bidder, + bid.id, + )); + }); + } - let prev_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; + let total_bidder_ct_rewarded = bids.iter().map(|bid| bid.final_ct_amount).sum::(); - let prev_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; + (account, total_bidder_ct_rewarded) + }) + .collect_vec(); - inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); - assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); + let community_accounts = community_contributions.accounts(); + let remainder_accounts = remainder_contributions.accounts(); + let all_contributors = community_accounts.iter().chain(remainder_accounts.iter()).unique(); + let contributor_ct_amounts = all_contributors + .map(|account| { + let contributions = inst.execute(|| { + Contributions::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + for contribution in contributions.iter() { + inst.execute(|| { + assert_ok!(Pallet::::contribution_ct_mint_for( + RuntimeOrigin::signed(contribution.contributor), + project_id, + contribution.contributor, + contribution.id, + )); + }); + } - let post_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; + let total_contributor_ct_rewarded = + contributions.iter().map(|contribution| contribution.ct_amount).sum::(); - let post_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; + (account, total_contributor_ct_rewarded) + }) + .collect_vec(); - let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; - let project_pot_funding_delta = prev_project_pot_funding_balance - post_project_pot_funding_balance; + let all_ct_expectations = MockInstantiator::generic_map_merge_reduce( + vec![evaluator_ct_amounts, bidder_ct_amounts, contributor_ct_amounts], + |item| item.0, + Zero::zero(), + |item, accumulator| accumulator + item.1, + ); - assert_eq!(issuer_funding_delta - total_expected_bid_payout, total_expected_contribution_payout); - assert_eq!(issuer_funding_delta, project_pot_funding_delta); + for (account, amount) in all_ct_expectations { + let minted = + inst.execute(|| ::ContributionTokenCurrency::balance(project_id, account)); + assert_eq!(minted, amount, "Account: {}", account); + } - assert_eq!(post_project_pot_funding_balance, 0u128); + let details = inst.get_project_details(project_id); + assert_eq!(details.status, ProjectStatus::FundingSuccessful); + assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData))); } #[test] - pub fn community_contribution_remainder_contribution_and_bid_funding_assets_are_paid_automatically_to_issuer() { + pub fn cannot_mint_ct_twice_manually() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); @@ -4772,1171 +4386,804 @@ mod remainder_round_success { let project_id = inst.create_finished_project( project, issuer, - evaluations, - bids, - community_contributions, - remainder_contributions, + evaluations.clone(), + bids.clone(), + community_contributions.clone(), + remainder_contributions.clone(), + ); + let details = inst.get_project_details(project_id); + assert_eq!(details.status, ProjectStatus::FundingSuccessful); + assert_eq!(details.cleanup, Cleaner::NotReady); + // do_end_funding + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + assert_eq!( + inst.get_project_details(project_id).cleanup, + Cleaner::Success(CleanerState::Initialized(PhantomData)) ); - let final_bid_payouts = inst.execute(|| { - Bids::::iter_prefix_values((project_id,)) - .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) - .map(|bid| { - UserToStatemintAsset::new( - bid.bidder, - bid.funding_asset_amount_locked, - bid.funding_asset.to_statemint_id(), - ) - }) - .collect::>>() - }); - let final_contribution_payouts = inst.execute(|| { - Contributions::::iter_prefix_values((project_id,)) - .map(|contribution| { - UserToStatemintAsset::new( - contribution.contributor, - contribution.funding_asset_amount, - contribution.funding_asset.to_statemint_id(), - ) - }) - .collect::>>() - }); - - let total_expected_bid_payout = - final_bid_payouts.iter().map(|bid| bid.asset_amount.clone()).sum::>(); - let total_expected_contribution_payout = final_contribution_payouts + let evaluators = evaluations.accounts(); + let evaluator_ct_amounts = evaluators .iter() - .map(|contribution| contribution.asset_amount.clone()) - .sum::>(); - - let prev_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; - - let prev_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; - - inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); - assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); + .map(|account| { + let evaluations = inst.execute(|| { + Evaluations::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + for evaluation in evaluations.iter() { + inst.execute(|| { + assert_ok!(Pallet::::evaluation_reward_payout_for( + RuntimeOrigin::signed(evaluation.evaluator), + project_id, + evaluation.evaluator, + evaluation.id, + )); + assert_noop!( + Pallet::::evaluation_reward_payout_for( + RuntimeOrigin::signed(evaluation.evaluator), + project_id, + evaluation.evaluator, + evaluation.id, + ), + Error::::NotAllowed + ); + }); + } + let evaluations = inst.execute(|| { + Evaluations::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + let total_evaluator_ct_rewarded = evaluations + .iter() + .map(|evaluation| evaluation.rewarded_or_slashed) + .map(|reward_or_slash| { + if let Some(RewardOrSlash::Reward(balance)) = reward_or_slash { + balance + } else { + Zero::zero() + } + }) + .sum::(); - let post_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; + (account, total_evaluator_ct_rewarded) + }) + .collect_vec(); - let post_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; + let bidders = bids.accounts(); + let bidder_ct_amounts = bidders + .iter() + .map(|account| { + let bids = inst.execute(|| { + Bids::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + for bid in bids.iter() { + inst.execute(|| { + assert_ok!(Pallet::::bid_ct_mint_for( + RuntimeOrigin::signed(bid.bidder), + project_id, + bid.bidder, + bid.id, + )); + }); + inst.execute(|| { + assert_noop!( + Pallet::::bid_ct_mint_for( + RuntimeOrigin::signed(bid.bidder), + project_id, + bid.bidder, + bid.id, + ), + Error::::NotAllowed + ); + }); + } - let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; - let project_pot_funding_delta = prev_project_pot_funding_balance - post_project_pot_funding_balance; + let total_bidder_ct_rewarded = bids.iter().map(|bid| bid.final_ct_amount).sum::(); - assert_eq!(issuer_funding_delta - total_expected_bid_payout, total_expected_contribution_payout); - assert_eq!(issuer_funding_delta, project_pot_funding_delta); + (account, total_bidder_ct_rewarded) + }) + .collect_vec(); - assert_eq!(post_project_pot_funding_balance, 0u128); - } -} + let community_accounts = community_contributions.accounts(); + let remainder_accounts = remainder_contributions.accounts(); + let all_contributors = community_accounts.iter().chain(remainder_accounts.iter()).unique(); + let contributor_ct_amounts = all_contributors + .map(|account| { + let contributions = inst.execute(|| { + Contributions::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + for contribution in contributions.iter() { + inst.execute(|| { + assert_ok!(Pallet::::contribution_ct_mint_for( + RuntimeOrigin::signed(contribution.contributor), + project_id, + contribution.contributor, + contribution.id, + )); + }); + inst.execute(|| { + assert_noop!( + Pallet::::contribution_ct_mint_for( + RuntimeOrigin::signed(contribution.contributor), + project_id, + contribution.contributor, + contribution.id, + ), + Error::::NotAllowed + ); + }); + } -mod remainder_round_failure { - use super::*; + let total_contributor_ct_rewarded = + contributions.iter().map(|contribution| contribution.ct_amount).sum::(); + + (account, total_contributor_ct_rewarded) + }) + .collect_vec(); + + let all_ct_expectations = MockInstantiator::generic_map_merge_reduce( + vec![evaluator_ct_amounts, bidder_ct_amounts, contributor_ct_amounts], + |item| item.0, + Zero::zero(), + |item, accumulator| accumulator + item.1, + ); + + for (account, amount) in all_ct_expectations { + let minted = + inst.execute(|| ::ContributionTokenCurrency::balance(project_id, account)); + assert_eq!(minted, amount, "Account: {}", account); + } + + let details = inst.get_project_details(project_id); + assert_eq!(details.status, ProjectStatus::FundingSuccessful); + assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData))); + } #[test] - pub fn bids_and_community_and_remainder_contribution_funding_assets_are_released_automatically_on_funding_fail() { + pub fn cannot_mint_ct_manually_after_automatic_mint() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); let evaluations = default_evaluations(); - let bids = MockInstantiator::generate_bids_from_total_usd( - project.total_allocation_size.0 / 4, - project.minimum_price, - default_weights(), - default_bidders(), - default_multipliers(), - ); - - let community_contributions = vec![ - ContributionParams::new(BUYER_1, 1_000 * ASSET_UNIT, 2u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_2, 500 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_3, 73 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ]; - let remainder_contributions = vec![ - ContributionParams::new(EVALUATOR_1, 250 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BIDDER_1, 13_400 * ASSET_UNIT, 3u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_1, 42 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ]; + let bids = default_bids(); + let community_contributions = default_community_buys(); + let remainder_contributions = default_remainder_buys(); let project_id = inst.create_finished_project( project, issuer, - evaluations, + evaluations.clone(), bids.clone(), community_contributions.clone(), remainder_contributions.clone(), ); - let final_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); - let expected_bid_payouts = inst.execute(|| { - Bids::::iter_prefix_values((project_id,)) - .map(|bid| { - UserToStatemintAsset::::new( - bid.bidder, - bid.funding_asset_amount_locked, - bid.funding_asset.to_statemint_id(), - ) - }) - .sorted_by_key(|bid| bid.account.clone()) - .collect::>>() - }); - let expected_community_contribution_payouts = - MockInstantiator::calculate_contributed_funding_asset_spent(community_contributions.clone(), final_price); - let expected_remainder_contribution_payouts = - MockInstantiator::calculate_contributed_funding_asset_spent(remainder_contributions.clone(), final_price); - let all_expected_payouts = MockInstantiator::generic_map_operation( - vec![ - expected_bid_payouts.clone(), - expected_community_contribution_payouts, - expected_remainder_contribution_payouts, - ], - MergeOperation::Add, + let details = inst.get_project_details(project_id); + assert_eq!(details.status, ProjectStatus::FundingSuccessful); + assert_eq!(details.cleanup, Cleaner::NotReady); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + assert_eq!( + inst.get_project_details(project_id).cleanup, + Cleaner::Success(CleanerState::Initialized(PhantomData)) ); + inst.advance_time(1).unwrap(); + assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); - let prev_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(expected_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; - let all_participants = all_expected_payouts.accounts(); - let prev_participants_funding_balances = - inst.get_free_statemint_asset_balances_for(expected_bid_payouts[0].asset_id, all_participants.clone()); + let evaluators = evaluations.accounts(); + let evaluator_ct_amounts = evaluators + .iter() + .map(|account| { + let evaluations = inst.execute(|| { + Evaluations::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + for evaluation in evaluations.iter() { + inst.execute(|| { + assert_noop!( + Pallet::::evaluation_reward_payout_for( + RuntimeOrigin::signed(evaluation.evaluator), + project_id, + evaluation.evaluator, + evaluation.id, + ), + Error::::NotAllowed + ); + }); + } + let evaluations = inst.execute(|| { + Evaluations::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + let total_evaluator_ct_rewarded = evaluations + .iter() + .map(|evaluation| evaluation.rewarded_or_slashed) + .map(|reward_or_slash| { + if let Some(RewardOrSlash::Reward(balance)) = reward_or_slash { + balance + } else { + Zero::zero() + } + }) + .sum::(); - call_and_is_ok!( - inst, - Pallet::::decide_project_outcome( - RuntimeOrigin::signed(issuer), - project_id, - FundingOutcomeDecision::RejectFunding - ) - ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - inst.advance_time(10).unwrap(); - assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Failure(CleanerState::Finished(PhantomData))); + (account, total_evaluator_ct_rewarded) + }) + .collect_vec(); - let post_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(expected_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; - let post_participants_funding_balances = - inst.get_free_statemint_asset_balances_for(expected_bid_payouts[0].asset_id, all_participants); - let post_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - expected_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; + let bidders = bids.accounts(); + let bidder_ct_amounts = bidders + .iter() + .map(|account| { + let bids = inst.execute(|| { + Bids::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + for bid in bids.iter() { + inst.execute(|| { + assert_noop!( + Pallet::::bid_ct_mint_for( + RuntimeOrigin::signed(bid.bidder), + project_id, + bid.bidder, + bid.id, + ), + Error::::NotAllowed + ); + }); + } - let all_participants_funding_delta = MockInstantiator::generic_map_operation( - vec![prev_participants_funding_balances, post_participants_funding_balances], - MergeOperation::Add, - ); + let total_bidder_ct_rewarded = bids.iter().map(|bid| bid.final_ct_amount).sum::(); - let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; + (account, total_bidder_ct_rewarded) + }) + .collect_vec(); - assert_eq!(issuer_funding_delta, 0); - assert_eq!(post_project_pot_funding_balance, 0u128); - assert_eq!(all_expected_payouts, all_participants_funding_delta); + let community_accounts = community_contributions.accounts(); + let remainder_accounts = remainder_contributions.accounts(); + let all_contributors = community_accounts.iter().chain(remainder_accounts.iter()).unique(); + let contributor_ct_amounts = all_contributors + .map(|account| { + let contributions = inst.execute(|| { + Contributions::::iter_prefix_values((project_id, account.clone())).collect::>() + }); + for contribution in contributions.iter() { + inst.execute(|| { + assert_noop!( + Pallet::::contribution_ct_mint_for( + RuntimeOrigin::signed(contribution.contributor), + project_id, + contribution.contributor, + contribution.id, + ), + Error::::NotAllowed + ); + }); + } + + let total_contributor_ct_rewarded = + contributions.iter().map(|contribution| contribution.ct_amount).sum::(); + + (account, total_contributor_ct_rewarded) + }) + .collect_vec(); + + let all_ct_expectations = MockInstantiator::generic_map_merge_reduce( + vec![evaluator_ct_amounts, bidder_ct_amounts, contributor_ct_amounts], + |item| item.0, + Zero::zero(), + |item, accumulator| accumulator + item.1, + ); + + for (account, amount) in all_ct_expectations { + let minted = + inst.execute(|| ::ContributionTokenCurrency::balance(project_id, account)); + assert_eq!(minted, amount, "Account: {}", account); + } } #[test] - pub fn bids_and_community_and_remainder_contribution_funding_assets_are_released_manually_on_funding_fail() { + fn multiplier_gets_correct_vesting_duration() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); let evaluations = default_evaluations(); - let bids = MockInstantiator::generate_bids_from_total_usd( - project.total_allocation_size.0 / 4, - project.minimum_price, - default_weights(), - default_bidders(), - default_multipliers(), - ); - - let community_contributions = vec![ - ContributionParams::new(BUYER_1, 1_000 * ASSET_UNIT, 2u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_2, 500 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_3, 73 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ]; - let remainder_contributions = vec![ - ContributionParams::new(EVALUATOR_1, 250 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BIDDER_1, 13_400 * ASSET_UNIT, 3u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_1, 42 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), + let bids = vec![ + BidParams::new(BIDDER_1, 10_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), + BidParams::new(BIDDER_2, 20_000 * ASSET_UNIT, 1.into(), 2u8, AcceptedFundingAsset::USDT), + BidParams::new(BIDDER_3, 20_000 * ASSET_UNIT, 11.into(), 3u8, AcceptedFundingAsset::USDT), ]; + let community_contributions = default_community_buys(); + let remainder_contributions = vec![]; let project_id = inst.create_finished_project( project, - issuer, - evaluations, - bids.clone(), - community_contributions.clone(), - remainder_contributions.clone(), - ); - let final_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); - let expected_bid_payouts = inst.execute(|| { - Bids::::iter_prefix_values((project_id,)) - .map(|bid| { - UserToStatemintAsset::::new( - bid.bidder, - bid.funding_asset_amount_locked, - bid.funding_asset.to_statemint_id(), - ) - }) - .sorted_by_key(|item| item.account.clone()) - .collect::>>() - }); - let expected_community_contribution_payouts = - MockInstantiator::calculate_contributed_funding_asset_spent(community_contributions.clone(), final_price); - let expected_remainder_contribution_payouts = - MockInstantiator::calculate_contributed_funding_asset_spent(remainder_contributions.clone(), final_price); - let all_expected_payouts = MockInstantiator::generic_map_operation( - vec![ - expected_bid_payouts.clone(), - expected_community_contribution_payouts, - expected_remainder_contribution_payouts, - ], - MergeOperation::Add, - ); - - let prev_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(expected_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; - let all_participants = all_expected_payouts.accounts(); - let prev_participants_funding_balances = - inst.get_free_statemint_asset_balances_for(expected_bid_payouts[0].asset_id, all_participants.clone()); - - call_and_is_ok!( - inst, - Pallet::::decide_project_outcome( - RuntimeOrigin::signed(issuer), - project_id, - FundingOutcomeDecision::RejectFunding - ) - ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - - let stored_bids = inst.execute(|| { - Bids::::iter_prefix_values((project_id,)) - .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) - .collect::>() - }); - let stored_contributions = - inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); - - for bid in stored_bids { - call_and_is_ok!( - inst, - Pallet::::release_bid_funds_for( - RuntimeOrigin::signed(issuer), - project_id, - bid.bidder, - bid.id, - ) - ) - } - - for contribution in stored_contributions { - call_and_is_ok!( - inst, - Pallet::::release_contribution_funds_for( - RuntimeOrigin::signed(issuer), - project_id, - contribution.contributor, - contribution.id, - ) - ) - } - - let post_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(expected_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; - let post_participants_funding_balances = - inst.get_free_statemint_asset_balances_for(expected_bid_payouts[0].asset_id, all_participants); - let post_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - expected_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; - - let all_participants_funding_delta = MockInstantiator::generic_map_operation( - vec![prev_participants_funding_balances, post_participants_funding_balances], - MergeOperation::Add, - ); - - let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; - - assert_eq!(issuer_funding_delta, 0); - assert_eq!(post_project_pot_funding_balance, 0u128); - assert_eq!(all_expected_payouts, all_participants_funding_delta); - } - - #[test] - pub fn bids_and_community_and_remainder_contribution_plmc_bonded_is_returned_automatically_on_funding_fail() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = vec![UserToUSDBalance::new(EVALUATOR_1, 50_000 * US_DOLLAR)]; - let bids = MockInstantiator::generate_bids_from_total_usd( - project.total_allocation_size.0 / 5, - project.minimum_price, - default_weights(), - default_bidders(), - default_multipliers(), - ); - - let community_contributions = vec![ - ContributionParams::new(BUYER_1, 1_000 * ASSET_UNIT, 2u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_2, 500 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_3, 73 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ]; - let remainder_contributions = vec![ - ContributionParams::new(EVALUATOR_1, 250 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BIDDER_1, 13_400 * ASSET_UNIT, 3u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_1, 42 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ]; - - let project_id = inst.create_finished_project( - project, - issuer, - evaluations.clone(), - bids.clone(), - community_contributions.clone(), - remainder_contributions.clone(), - ); - let final_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); - - let expected_evaluator_contributor_return = - MockInstantiator::calculate_total_plmc_locked_from_evaluations_and_remainder_contributions( - vec![UserToUSDBalance::new(EVALUATOR_1, 50_000 * US_DOLLAR)], - vec![ContributionParams::new( - EVALUATOR_1, - 250 * ASSET_UNIT, - 1u8.try_into().unwrap(), - AcceptedFundingAsset::USDT, - )], - final_price, - true, - ); - let stored_bids = inst.execute(|| Bids::::iter_prefix_values((project_id,)).collect_vec()); - let bids = stored_bids - .into_iter() - .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) - .map(|bid| BidParams::from(bid.bidder, bid.final_ct_amount, bid.final_ct_usd_price)) - .collect_vec(); - let expected_bid_payouts = MockInstantiator::calculate_auction_plmc_spent(&bids.clone(), Some(final_price)); - let expected_community_contribution_payouts = - MockInstantiator::calculate_contributed_plmc_spent(community_contributions.clone(), final_price); - let expected_remainder_contribution_payouts = MockInstantiator::calculate_contributed_plmc_spent( - vec![ - ContributionParams::new( - BIDDER_1, - 13_400 * ASSET_UNIT, - 3u8.try_into().unwrap(), - AcceptedFundingAsset::USDT, - ), - ContributionParams::new(BUYER_1, 42 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ], - final_price, - ); - let all_expected_payouts = MockInstantiator::generic_map_operation( - vec![ - expected_evaluator_contributor_return, - expected_bid_payouts.clone(), - expected_community_contribution_payouts, - expected_remainder_contribution_payouts, - ], - MergeOperation::Add, - ); - let deposit_required = <::ContributionTokenCurrency as AccountTouch< - ProjectIdOf, - AccountIdOf, - >>::deposit_required(project_id); - let ed = MockInstantiator::get_ed(); - let all_expected_payouts = all_expected_payouts - .into_iter() - .map(|UserToPLMCBalance { account, plmc_amount }| { - UserToPLMCBalance::new(account, plmc_amount + deposit_required) - }) - .collect::>(); - - let prev_issuer_funding_balance = inst.get_free_plmc_balances_for(vec![issuer.clone()])[0].plmc_amount; - - let all_participants = all_expected_payouts.accounts(); - let prev_participants_plmc_balances = inst.get_free_plmc_balances_for(all_participants.clone()); - - call_and_is_ok!( - inst, - Pallet::::decide_project_outcome( - RuntimeOrigin::signed(issuer), - project_id, - FundingOutcomeDecision::RejectFunding - ) - ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - inst.advance_time(10).unwrap(); - assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Failure(CleanerState::Finished(PhantomData))); - - let post_issuer_funding_balance = inst.get_free_plmc_balances_for(vec![issuer.clone()])[0].plmc_amount; - let post_participants_plmc_balances = inst.get_free_plmc_balances_for(all_participants); - - let all_participants_plmc_deltas = MockInstantiator::generic_map_operation( - vec![post_participants_plmc_balances, prev_participants_plmc_balances], - MergeOperation::Subtract, - ); - - let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; - - let participants = all_participants_plmc_deltas.accounts(); - for participant in participants { - let future_deposit_reserved = inst.execute(||{<::NativeCurrency as fungible::InspectHold>>::balance_on_hold(&LockType::FutureDeposit(project_id), &participant)}); - dbg!("participant {:?} has future deposit reserved {:?}", participant, future_deposit_reserved); - } - assert_eq!(issuer_funding_delta, 0); - assert_eq!(all_participants_plmc_deltas, all_expected_payouts); - } - - #[test] - pub fn bids_and_community_and_remainder_contribution_plmc_bonded_is_returned_manually_on_funding_fail() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = vec![ - UserToUSDBalance::new(EVALUATOR_1, 50_000 * US_DOLLAR), - UserToUSDBalance::new(EVALUATOR_2, 25_000 * US_DOLLAR), - UserToUSDBalance::new(EVALUATOR_3, 32_000 * US_DOLLAR), - ]; - let bids = MockInstantiator::generate_bids_from_total_usd( - project.total_allocation_size.0 / 4, - project.minimum_price, - default_weights(), - default_bidders(), - default_multipliers(), - ); - - let community_contributions = vec![ - ContributionParams::new(BUYER_1, 1_000 * ASSET_UNIT, 2u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_2, 500 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_3, 73 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ]; - let remainder_contributions = vec![ - ContributionParams::new(EVALUATOR_1, 250 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BIDDER_1, 13_400 * ASSET_UNIT, 3u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_1, 42 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ]; - - let project_id = inst.create_finished_project( - project, - issuer, - evaluations.clone(), - bids.clone(), - community_contributions.clone(), - remainder_contributions.clone(), - ); - let final_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); - let expected_evaluator_contributor_return = - MockInstantiator::calculate_total_plmc_locked_from_evaluations_and_remainder_contributions( - vec![UserToUSDBalance::new(EVALUATOR_1, 50_000 * US_DOLLAR)], - vec![ContributionParams::new( - EVALUATOR_1, - 250 * ASSET_UNIT, - 1u8.try_into().unwrap(), - AcceptedFundingAsset::USDT, - )], - final_price, - true, - ); - let expected_bid_payouts = MockInstantiator::calculate_auction_plmc_spent(&bids.clone(), Some(final_price)); - let expected_community_contribution_payouts = - MockInstantiator::calculate_contributed_plmc_spent(community_contributions.clone(), final_price); - let expected_remainder_contribution_payouts = MockInstantiator::calculate_contributed_plmc_spent( - vec![ - ContributionParams::new( - BIDDER_1, - 13_400 * ASSET_UNIT, - 3u8.try_into().unwrap(), - AcceptedFundingAsset::USDT, - ), - ContributionParams::new(BUYER_1, 42 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ], - final_price, - ); - let all_expected_payouts = MockInstantiator::generic_map_operation( - vec![ - expected_evaluator_contributor_return, - expected_bid_payouts.clone(), - expected_community_contribution_payouts, - expected_remainder_contribution_payouts, - ], - MergeOperation::Add, - ); - - let prev_issuer_funding_balance = inst.get_free_plmc_balances_for(vec![issuer.clone()])[0].plmc_amount; - let all_participants = all_expected_payouts.accounts(); - let prev_participants_plmc_balances = inst.get_free_plmc_balances_for(all_participants.clone()); - - call_and_is_ok!( - inst, - Pallet::::decide_project_outcome( - RuntimeOrigin::signed(issuer), - project_id, - FundingOutcomeDecision::RejectFunding - ) - ); - inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); - assert_eq!( - inst.get_project_details(project_id).cleanup, - Cleaner::Failure(CleanerState::Initialized(PhantomData)) - ); - - let stored_evaluations = - inst.execute(|| Evaluations::::iter_prefix_values((project_id,)).collect::>()); - let stored_bids = inst.execute(|| { - Bids::::iter_prefix_values((project_id,)) - .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) - .collect::>() - }); - let stored_contributions = - inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); - - for evaluation in stored_evaluations { - call_and_is_ok!( - inst, - Pallet::::evaluation_slash_for( - RuntimeOrigin::signed(evaluation.evaluator), - project_id, - evaluation.evaluator, - evaluation.id, - ), - Pallet::::evaluation_unbond_for( - RuntimeOrigin::signed(evaluation.evaluator), - project_id, - evaluation.evaluator, - evaluation.id, - ) - ) - } - - for bid in stored_bids { - call_and_is_ok!( - inst, - Pallet::::release_bid_funds_for( - RuntimeOrigin::signed(issuer), - project_id, - bid.bidder, - bid.id, - ), - Pallet::::bid_unbond_for( - RuntimeOrigin::signed(bid.bidder), - project_id, - bid.bidder, - bid.id, - ) - ) - } - - for contribution in stored_contributions { - call_and_is_ok!( - inst, - Pallet::::release_contribution_funds_for( - RuntimeOrigin::signed(issuer), - project_id, - contribution.contributor, - contribution.id, - ), - Pallet::::contribution_unbond_for( - RuntimeOrigin::signed(contribution.contributor), - project_id, - contribution.contributor, - contribution.id, - ) - ) - } - - let post_issuer_funding_balance = inst.get_free_plmc_balances_for(vec![issuer.clone()])[0].plmc_amount; - let post_participants_plmc_balances = inst.get_free_plmc_balances_for(all_participants); - - let all_participants_plmc_deltas = MockInstantiator::generic_map_operation( - vec![post_participants_plmc_balances, prev_participants_plmc_balances], - MergeOperation::Subtract, - ); - - let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; - - assert_eq!(issuer_funding_delta, 0); - assert_eq!(all_expected_payouts, all_participants_plmc_deltas); - } - - #[test] - fn remainder_contribution_ct_account_deposits_are_returned() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let project_metadata = default_project(0, ISSUER); - let automatic_fail_funding_percent = Percent::from_percent(30); - let (bid_allocation, contribution_allocation) = project_metadata.total_allocation_size; - let deposit_required = <::ContributionTokenCurrency as AccountTouch< - ProjectIdOf, - AccountIdOf, - >>::deposit_required(0); - - let remainder_contributors = vec![EVALUATOR_1, BIDDER_3, BUYER_4, BUYER_6, BIDDER_6]; - - let desired_total_usd_amount_bid = - automatic_fail_funding_percent * project_metadata.minimum_price.saturating_mul_int(bid_allocation); - let desired_total_usd_amount_contributed = - automatic_fail_funding_percent * project_metadata.minimum_price.saturating_mul_int(contribution_allocation); - - let bids = MockInstantiator::generate_bids_from_total_usd( - desired_total_usd_amount_bid, - project_metadata.minimum_price, - default_weights(), - default_bidders(), - default_bidder_multipliers(), - ); - - let community_contributions = MockInstantiator::generate_contributions_from_total_usd( - desired_total_usd_amount_contributed / 2, - project_metadata.minimum_price, - default_weights(), - default_community_contributors(), - default_community_contributor_multipliers(), - ); - - let remainder_contributions = MockInstantiator::generate_contributions_from_total_usd( - desired_total_usd_amount_contributed / 2, - project_metadata.minimum_price, - default_weights(), - default_remainder_contributors(), - default_remainder_contributor_multipliers(), - ); - - let zero_balances = remainder_contributions - .clone() - .accounts() - .into_iter() - .map(|acc| UserToPLMCBalance::new(acc, 0u128)) - .collect_vec(); - inst.do_free_plmc_assertions(zero_balances.clone()); - inst.do_reserved_plmc_assertions(zero_balances.clone(), LockType::FutureDeposit(0)); - - let project_id = inst.create_finished_project( - project_metadata, - ISSUER, - default_evaluations(), - bids.clone(), - community_contributions.clone(), - remainder_contributions.clone(), - ); - let wap = inst.get_project_details(project_id).weighted_average_price.unwrap(); - - let bidder_plmc_bonds = MockInstantiator::calculate_auction_plmc_spent(&bids, Some(wap)); - let community_contributor_plmc_bonds = - MockInstantiator::calculate_contributed_plmc_spent(community_contributions.clone(), wap); - let evaluators_and_contributors_plmc_bonds = - MockInstantiator::calculate_total_plmc_locked_from_evaluations_and_remainder_contributions( - default_evaluations(), - remainder_contributions, - wap, - true, - ); - - let mut expected_final_plmc_balances = MockInstantiator::generic_map_operation( - vec![bidder_plmc_bonds, community_contributor_plmc_bonds, evaluators_and_contributors_plmc_bonds], - MergeOperation::Add, - ); - expected_final_plmc_balances.iter_mut().for_each(|UserToPLMCBalance { account, plmc_amount }| { - *plmc_amount += deposit_required; - }); - - let prev_balances = inst.get_free_plmc_balances_for(expected_final_plmc_balances.accounts()); - let ct_deposit_balances = expected_final_plmc_balances - .accounts() - .into_iter() - .map(|acc| UserToPLMCBalance::new(acc, deposit_required)) - .collect_vec(); - inst.do_reserved_plmc_assertions(ct_deposit_balances, LockType::FutureDeposit(project_id)); - - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingFailed); - inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); - assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Failure(CleanerState::Finished(PhantomData))); - - let post_balances = inst.get_free_plmc_balances_for(expected_final_plmc_balances.accounts()); - - let plmc_deltas = - MockInstantiator::generic_map_operation(vec![post_balances, prev_balances], MergeOperation::Subtract); - - assert_eq!(plmc_deltas, expected_final_plmc_balances); - inst.do_reserved_plmc_assertions(zero_balances, LockType::FutureDeposit(project_id)); - } -} - -mod funding_end { - use super::*; - - #[test] - fn automatic_fail_less_eq_33_percent() { - for funding_percent in (1..=33).step_by(5) { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let project_metadata = default_project(inst.get_new_nonce(), ISSUER); - let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) * - (project_metadata.minimum_price.checked_mul_int(project_metadata.total_allocation_size.0).unwrap()); - let evaluations = default_evaluations(); - let bids = MockInstantiator::generate_bids_from_total_usd( - Percent::from_percent(50u8) * twenty_percent_funding_usd, - min_price, - default_weights(), - default_bidders(), - default_multipliers(), - ); - let contributions = MockInstantiator::generate_contributions_from_total_usd( - Percent::from_percent(50u8) * twenty_percent_funding_usd, - min_price, - default_weights(), - default_community_contributors(), - default_multipliers(), - ); - let project_id = - inst.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]); - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingFailed); - } - } - - #[test] - fn automatic_success_bigger_eq_90_percent() { - for funding_percent in (90..=100).step_by(2) { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let project_metadata = default_project(inst.get_new_nonce(), ISSUER); - let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) * - (project_metadata.minimum_price.checked_mul_int(project_metadata.total_allocation_size.0).unwrap()); - let evaluations = default_evaluations(); - let bids = MockInstantiator::generate_bids_from_total_usd( - Percent::from_percent(50u8) * twenty_percent_funding_usd, - min_price, - default_weights(), - default_bidders(), - default_multipliers(), - ); - let contributions = MockInstantiator::generate_contributions_from_total_usd( - Percent::from_percent(50u8) * twenty_percent_funding_usd, - min_price, - default_weights(), - default_community_contributors(), - default_multipliers(), - ); - let project_id = - inst.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]); - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingSuccessful); - } - } - - #[test] - fn manual_outcome_above33_to_below90() { - for funding_percent in (34..90).step_by(5) { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let project_metadata = default_project(inst.get_new_nonce(), ISSUER); - let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) * - (project_metadata.minimum_price.checked_mul_int(project_metadata.total_allocation_size.0).unwrap()); - let evaluations = default_evaluations(); - let bids = MockInstantiator::generate_bids_from_total_usd( - Percent::from_percent(50u8) * twenty_percent_funding_usd, - min_price, - default_weights(), - default_bidders(), - default_multipliers(), - ); - let contributions = MockInstantiator::generate_contributions_from_total_usd( - Percent::from_percent(50u8) * twenty_percent_funding_usd, - min_price, - default_weights(), - default_community_contributors(), - default_multipliers(), - ); - let project_id = - inst.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]); - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AwaitingProjectDecision); - } - } - - #[test] - fn manual_acceptance() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let project_metadata = default_project(inst.get_new_nonce(), ISSUER); - let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(55) * - (project_metadata.minimum_price.checked_mul_int(project_metadata.total_allocation_size.0).unwrap()); - let evaluations = default_evaluations(); - let bids = MockInstantiator::generate_bids_from_total_usd( - Percent::from_percent(50u8) * twenty_percent_funding_usd, - min_price, - default_weights(), - default_bidders(), - default_multipliers(), - ); - let contributions = MockInstantiator::generate_contributions_from_total_usd( - Percent::from_percent(50u8) * twenty_percent_funding_usd, - min_price, - default_weights(), - default_community_contributors(), - default_multipliers(), - ); - let project_id = - inst.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]); - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AwaitingProjectDecision); - - let project_id = project_id; - inst.execute(|| { - FundingModule::do_decide_project_outcome(ISSUER, project_id, FundingOutcomeDecision::AcceptFunding) - }) - .unwrap(); - - inst.advance_time(1u64).unwrap(); - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingSuccessful); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - - assert_matches!(inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Initialized(_))); - inst.test_ct_created_for(project_id); - - inst.advance_time(10u64).unwrap(); - assert_matches!( - inst.get_project_details(project_id).cleanup, - Cleaner::Success(CleanerState::Finished(PhantomData)) - ); - } - - #[test] - fn manual_rejection() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let project_metadata = default_project(inst.get_new_nonce(), ISSUER); - let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(55) * - (project_metadata.minimum_price.checked_mul_int(project_metadata.total_allocation_size.0).unwrap()); - let evaluations = default_evaluations(); - let bids = MockInstantiator::generate_bids_from_total_usd( - Percent::from_percent(50u8) * twenty_percent_funding_usd, - min_price, - default_weights(), - default_bidders(), - default_multipliers(), - ); - let contributions = MockInstantiator::generate_contributions_from_total_usd( - Percent::from_percent(50u8) * twenty_percent_funding_usd, - min_price, - default_weights(), - default_community_contributors(), - default_multipliers(), - ); - let project_id = - inst.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]); - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AwaitingProjectDecision); - - let project_id = project_id; - inst.execute(|| { - FundingModule::do_decide_project_outcome(ISSUER, project_id, FundingOutcomeDecision::RejectFunding) - }) - .unwrap(); - - inst.advance_time(1u64).unwrap(); - - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingFailed); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - assert_matches!( - inst.get_project_details(project_id).cleanup, - Cleaner::Failure(CleanerState::Initialized(PhantomData)) + issuer, + evaluations, + bids, + community_contributions, + remainder_contributions, ); - - inst.test_ct_not_created_for(project_id); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); inst.advance_time(10u64).unwrap(); - assert_matches!( - inst.get_project_details(project_id).cleanup, - Cleaner::Failure(CleanerState::Finished(PhantomData)) + let details = inst.get_project_details(project_id); + assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); + + let mut stored_bids = + inst.execute(|| Bids::::iter_prefix_values((project_id,)).collect::>()); + + stored_bids.sort_by_key(|bid| bid.bidder); + let one_week_in_blocks = DAYS * 7; + assert_eq!(stored_bids[0].plmc_vesting_info.unwrap().duration, 1u64); + assert_eq!( + stored_bids[1].plmc_vesting_info.unwrap().duration, + FixedU128::from_rational(2167, 1000).saturating_mul_int(one_week_in_blocks as u64) + ); + assert_eq!( + stored_bids[2].plmc_vesting_info.unwrap().duration, + FixedU128::from_rational(4334, 1000).saturating_mul_int(one_week_in_blocks as u64) ); } #[test] - fn automatic_acceptance_on_manual_decision_after_time_delta() { + pub fn funding_assets_are_paid_manually_to_issuer() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let project_metadata = default_project(inst.get_new_nonce(), ISSUER); - let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(55) * - (project_metadata.minimum_price.checked_mul_int(project_metadata.total_allocation_size.0).unwrap()); + let issuer = ISSUER; + let project = default_project(inst.get_new_nonce(), issuer); let evaluations = default_evaluations(); - let bids = MockInstantiator::generate_bids_from_total_usd( - Percent::from_percent(50u8) * twenty_percent_funding_usd, - min_price, - default_weights(), - default_bidders(), - default_multipliers(), - ); - let contributions = MockInstantiator::generate_contributions_from_total_usd( - Percent::from_percent(50u8) * twenty_percent_funding_usd, - min_price, - default_weights(), - default_community_contributors(), - default_multipliers(), - ); - let project_id = - inst.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]); - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AwaitingProjectDecision); - - let project_id = project_id; - inst.advance_time(1u64 + ::ManualAcceptanceDuration::get()).unwrap(); - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingSuccessful); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - - assert_matches!( - inst.get_project_details(project_id).cleanup, - Cleaner::Success(CleanerState::Initialized(PhantomData)) - ); - inst.test_ct_created_for(project_id); + let bids = default_bids(); + let community_contributions = default_community_buys(); + let remainder_contributions = default_remainder_buys(); - inst.advance_time(10u64).unwrap(); - assert_matches!( - inst.get_project_details(project_id).cleanup, - Cleaner::Success(CleanerState::Finished(PhantomData)) + let project_id = inst.create_finished_project( + project, + issuer, + evaluations, + bids, + community_contributions, + remainder_contributions, ); - } - #[test] - fn evaluators_get_slashed_funding_accepted() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let project_id = project_from_funding_reached(&mut inst, 43u64); - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AwaitingProjectDecision); + let final_winning_bids = inst.execute(|| { + Bids::::iter_prefix_values((project_id,)) + .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) + .collect::>() + }); + let final_bid_payouts = inst.execute(|| { + Bids::::iter_prefix_values((project_id,)) + .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) + .map(|bid| { + UserToStatemintAsset::new( + bid.bidder, + bid.funding_asset_amount_locked, + bid.funding_asset.to_statemint_id(), + ) + }) + .collect::>>() + }); + let final_contributions = + inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); + let final_contribution_payouts = inst.execute(|| { + Contributions::::iter_prefix_values((project_id,)) + .map(|contribution| { + UserToStatemintAsset::new( + contribution.contributor, + contribution.funding_asset_amount, + contribution.funding_asset.to_statemint_id(), + ) + }) + .collect::>>() + }); - let old_evaluation_locked_plmc = inst - .get_all_reserved_plmc_balances(LockType::Evaluation(project_id)) - .into_iter() - .filter(|item| item.plmc_amount > Zero::zero()) - .collect::>>(); + let total_expected_bid_payout = + final_bid_payouts.iter().map(|bid| bid.asset_amount.clone()).sum::>(); + let total_expected_contribution_payout = final_contribution_payouts + .iter() + .map(|contribution| contribution.asset_amount.clone()) + .sum::>(); - let evaluators = old_evaluation_locked_plmc.accounts(); + let prev_issuer_funding_balance = inst + .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] + .asset_amount; - let old_participation_locked_plmc = - inst.get_reserved_plmc_balances_for(evaluators.clone(), LockType::Participation(project_id)); - let old_free_plmc = inst.get_free_plmc_balances_for(evaluators.clone()); + let prev_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( + final_bid_payouts[0].asset_id, + vec![Pallet::::fund_account_id(project_id)], + )[0] + .asset_amount; - call_and_is_ok!( - inst, - FundingModule::do_decide_project_outcome(ISSUER, project_id, FundingOutcomeDecision::AcceptFunding) - ); - inst.advance_time(1u64).unwrap(); - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingSuccessful); - inst.advance_time(::SuccessToSettlementTime::get() + 10u64).unwrap(); - assert_matches!( + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + assert_eq!( inst.get_project_details(project_id).cleanup, - Cleaner::Success(CleanerState::Finished(PhantomData)) + Cleaner::Success(CleanerState::Initialized(PhantomData)) ); + for bid in final_winning_bids { + inst.execute(|| { + Pallet::::payout_bid_funds_for( + RuntimeOrigin::signed(issuer), + project_id, + bid.bidder, + bid.id, + ) + }) + .unwrap(); + } + for contribution in final_contributions { + inst.execute(|| { + Pallet::::payout_contribution_funds_for( + RuntimeOrigin::signed(issuer), + project_id, + contribution.contributor, + contribution.id, + ) + }) + .unwrap(); + } + let post_issuer_funding_balance = inst + .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] + .asset_amount; - let slashed_evaluation_locked_plmc = MockInstantiator::slash_evaluator_balances(old_evaluation_locked_plmc); - let expected_evaluator_free_balances = MockInstantiator::generic_map_operation( - vec![slashed_evaluation_locked_plmc, old_participation_locked_plmc, old_free_plmc], - MergeOperation::Add, - ); + let post_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( + final_bid_payouts[0].asset_id, + vec![Pallet::::fund_account_id(project_id)], + )[0] + .asset_amount; + let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; + let project_pot_funding_delta = prev_project_pot_funding_balance - post_project_pot_funding_balance; - let actual_evaluator_free_balances = inst.get_free_plmc_balances_for(evaluators.clone()); + assert_eq!(issuer_funding_delta - total_expected_bid_payout, total_expected_contribution_payout); + assert_eq!(issuer_funding_delta, project_pot_funding_delta); - assert_eq!(actual_evaluator_free_balances, expected_evaluator_free_balances); + assert_eq!(post_project_pot_funding_balance, 0u128); } #[test] - fn evaluators_get_slashed_funding_funding_rejected() { + pub fn funding_assets_are_paid_automatically_to_issuer() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let project_id = project_from_funding_reached(&mut inst, 56u64); - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AwaitingProjectDecision); + let issuer = ISSUER; + let project = default_project(inst.get_new_nonce(), issuer); + let evaluations = default_evaluations(); + let bids = default_bids(); + let community_contributions = default_community_buys(); + let remainder_contributions = default_remainder_buys(); - let old_evaluation_locked_plmc = inst - .get_all_reserved_plmc_balances(LockType::Evaluation(project_id)) - .into_iter() - .filter(|item| item.plmc_amount > Zero::zero()) - .collect::>>(); + let project_id = inst.create_finished_project( + project, + issuer, + evaluations, + bids, + community_contributions, + remainder_contributions, + ); - let evaluators = old_evaluation_locked_plmc.accounts(); + let final_bid_payouts = inst.execute(|| { + Bids::::iter_prefix_values((project_id,)) + .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) + .map(|bid| { + UserToStatemintAsset::new( + bid.bidder, + bid.funding_asset_amount_locked, + bid.funding_asset.to_statemint_id(), + ) + }) + .collect::>>() + }); + let final_contribution_payouts = inst.execute(|| { + Contributions::::iter_prefix_values((project_id,)) + .map(|contribution| { + UserToStatemintAsset::new( + contribution.contributor, + contribution.funding_asset_amount, + contribution.funding_asset.to_statemint_id(), + ) + }) + .collect::>>() + }); - let old_participation_locked_plmc = - inst.get_reserved_plmc_balances_for(evaluators.clone(), LockType::Participation(project_id)); - let old_free_plmc = inst.get_free_plmc_balances_for(evaluators.clone()); + let total_expected_bid_payout = + final_bid_payouts.iter().map(|bid| bid.asset_amount.clone()).sum::>(); + let total_expected_contribution_payout = final_contribution_payouts + .iter() + .map(|contribution| contribution.asset_amount.clone()) + .sum::>(); - call_and_is_ok!( - inst, - FundingModule::do_decide_project_outcome(ISSUER, project_id, FundingOutcomeDecision::RejectFunding) - ); - inst.advance_time(1u64).unwrap(); - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingFailed); - inst.advance_time(::SuccessToSettlementTime::get() + 10u64).unwrap(); - assert_matches!( + let prev_issuer_funding_balance = inst + .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] + .asset_amount; + + let prev_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( + final_bid_payouts[0].asset_id, + vec![Pallet::::fund_account_id(project_id)], + )[0] + .asset_amount; + + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + assert_eq!( inst.get_project_details(project_id).cleanup, - Cleaner::Failure(CleanerState::Finished(PhantomData)) + Cleaner::Success(CleanerState::Initialized(PhantomData)) ); + inst.advance_time(1u64).unwrap(); + assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); - let slashed_evaluation_locked_plmc = MockInstantiator::slash_evaluator_balances(old_evaluation_locked_plmc); - let mut expected_evaluator_free_balances = MockInstantiator::generic_map_operation( - vec![slashed_evaluation_locked_plmc, old_participation_locked_plmc, old_free_plmc], - MergeOperation::Add, - ); - let ct_deposit_required = <::ContributionTokenCurrency as AccountTouch< - ProjectIdOf, - AccountIdOf, - >>::deposit_required(project_id); - expected_evaluator_free_balances - .iter_mut() - .for_each(|UserToPLMCBalance { plmc_amount, .. }| *plmc_amount += ct_deposit_required); + let post_issuer_funding_balance = inst + .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] + .asset_amount; - let actual_evaluator_free_balances = inst.get_free_plmc_balances_for(evaluators.clone()); + let post_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( + final_bid_payouts[0].asset_id, + vec![Pallet::::fund_account_id(project_id)], + )[0] + .asset_amount; + let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; + let project_pot_funding_delta = prev_project_pot_funding_balance - post_project_pot_funding_balance; - assert_eq!(actual_evaluator_free_balances, expected_evaluator_free_balances); + assert_eq!(issuer_funding_delta - total_expected_bid_payout, total_expected_contribution_payout); + assert_eq!(issuer_funding_delta, project_pot_funding_delta); + + assert_eq!(post_project_pot_funding_balance, 0u128); } #[test] - fn evaluators_get_slashed_funding_failed() { + pub fn funding_assets_are_released_automatically_on_funding_fail() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let project_id = project_from_funding_reached(&mut inst, 24u64); - assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingFailed); - - let old_evaluation_locked_plmc = inst - .get_all_reserved_plmc_balances(LockType::Evaluation(project_id)) - .into_iter() - .filter(|item| item.plmc_amount > Zero::zero()) - .collect::>(); + let issuer = ISSUER; + let project = default_project(inst.get_new_nonce(), issuer); + let evaluations = default_evaluations(); + let bids = MockInstantiator::generate_bids_from_total_usd( + Percent::from_percent(50u8) * project.total_allocation_size.0, + project.minimum_price, + default_weights(), + default_bidders(), + default_bidder_multipliers(), + ); - let evaluators = old_evaluation_locked_plmc.accounts(); + let community_contributions = MockInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(50u8) * project.total_allocation_size.1 / 2, + project.minimum_price, + default_weights(), + default_community_contributors(), + default_community_contributor_multipliers(), + ); + let remainder_contributions = MockInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(50u8) * project.total_allocation_size.1 / 2, + project.minimum_price, + default_weights(), + default_remainder_contributors(), + default_remainder_contributor_multipliers(), + ); + let project_id = inst.create_finished_project( + project, + issuer, + evaluations, + bids.clone(), + community_contributions.clone(), + remainder_contributions.clone(), + ); + let final_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); + let expected_bid_payouts = inst.execute(|| { + Bids::::iter_prefix_values((project_id,)) + .map(|bid| { + UserToStatemintAsset::::new( + bid.bidder, + bid.funding_asset_amount_locked, + bid.funding_asset.to_statemint_id(), + ) + }) + .sorted_by_key(|bid| bid.account.clone()) + .collect::>>() + }); + let expected_community_contribution_payouts = + MockInstantiator::calculate_contributed_funding_asset_spent(community_contributions.clone(), final_price); + let expected_remainder_contribution_payouts = + MockInstantiator::calculate_contributed_funding_asset_spent(remainder_contributions.clone(), final_price); + let all_expected_payouts = MockInstantiator::generic_map_operation( + vec![ + expected_bid_payouts.clone(), + expected_community_contribution_payouts, + expected_remainder_contribution_payouts, + ], + MergeOperation::Add, + ); - let old_participation_locked_plmc = - inst.get_reserved_plmc_balances_for(evaluators.clone(), LockType::Participation(project_id)); - let old_free_plmc = inst.get_free_plmc_balances_for(evaluators.clone()); + let prev_issuer_funding_balance = inst + .get_free_statemint_asset_balances_for(expected_bid_payouts[0].asset_id, vec![issuer.clone()])[0] + .asset_amount; + let all_participants = all_expected_payouts.accounts(); + let prev_participants_funding_balances = + inst.get_free_statemint_asset_balances_for(expected_bid_payouts[0].asset_id, all_participants.clone()); - inst.advance_time(::SuccessToSettlementTime::get() + 10u64).unwrap(); - assert_matches!( - inst.get_project_details(project_id).cleanup, - Cleaner::Failure(CleanerState::Finished(PhantomData)) + call_and_is_ok!( + inst, + Pallet::::decide_project_outcome( + RuntimeOrigin::signed(issuer), + project_id, + FundingOutcomeDecision::RejectFunding + ) ); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + inst.advance_time(10).unwrap(); + assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Failure(CleanerState::Finished(PhantomData))); - let slashed_evaluation_locked_plmc = MockInstantiator::slash_evaluator_balances(old_evaluation_locked_plmc); - let mut expected_evaluator_free_balances = MockInstantiator::generic_map_operation( - vec![slashed_evaluation_locked_plmc, old_participation_locked_plmc, old_free_plmc], + let post_issuer_funding_balance = inst + .get_free_statemint_asset_balances_for(expected_bid_payouts[0].asset_id, vec![issuer.clone()])[0] + .asset_amount; + let post_participants_funding_balances = + inst.get_free_statemint_asset_balances_for(expected_bid_payouts[0].asset_id, all_participants); + let post_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( + expected_bid_payouts[0].asset_id, + vec![Pallet::::fund_account_id(project_id)], + )[0] + .asset_amount; + + let all_participants_funding_delta = MockInstantiator::generic_map_operation( + vec![prev_participants_funding_balances, post_participants_funding_balances], MergeOperation::Add, ); - let ct_deposit_required = <::ContributionTokenCurrency as AccountTouch< - ProjectIdOf, - AccountIdOf, - >>::deposit_required(project_id); - expected_evaluator_free_balances - .iter_mut() - .for_each(|UserToPLMCBalance { plmc_amount, .. }| *plmc_amount += ct_deposit_required); - let actual_evaluator_free_balances = inst.get_free_plmc_balances_for(evaluators.clone()); + let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; - assert_eq!(actual_evaluator_free_balances, expected_evaluator_free_balances); + assert_eq!(issuer_funding_delta, 0); + assert_eq!(post_project_pot_funding_balance, 0u128); + assert_eq!(all_expected_payouts, all_participants_funding_delta); } #[test] - fn ct_minted_automatically() { + pub fn funding_assets_are_released_manually_on_funding_fail() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); let evaluations = default_evaluations(); - let bids = default_bids(); - let community_contributions = default_community_buys(); - let remainder_contributions = default_remainder_buys(); + let bids = MockInstantiator::generate_bids_from_total_usd( + Percent::from_percent(50u8) * project.total_allocation_size.0, + project.minimum_price, + default_weights(), + default_bidders(), + default_bidder_multipliers(), + ); + + let community_contributions = MockInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(50u8) * project.total_allocation_size.1 / 2, + project.minimum_price, + default_weights(), + default_community_contributors(), + default_community_contributor_multipliers(), + ); + let remainder_contributions = MockInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(50u8) * project.total_allocation_size.1 / 2, + project.minimum_price, + default_weights(), + default_remainder_contributors(), + default_remainder_contributor_multipliers(), + ); let project_id = inst.create_finished_project( project, issuer, - evaluations.clone(), + evaluations, bids.clone(), community_contributions.clone(), remainder_contributions.clone(), ); - let details = inst.get_project_details(project_id); - assert_eq!(details.status, ProjectStatus::FundingSuccessful); - assert_eq!(details.cleanup, Cleaner::NotReady); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - - inst.advance_time(10u64).unwrap(); - let details = inst.get_project_details(project_id); - assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); - - let evaluators = evaluations.accounts(); - let evaluator_ct_amounts = evaluators - .iter() - .map(|account| { - let evaluations = inst.execute(|| { - Evaluations::::iter_prefix_values((project_id, account.clone())).collect::>() - }); - let total_evaluator_ct_rewarded = evaluations - .iter() - .map(|evaluation| evaluation.rewarded_or_slashed) - .map(|reward_or_slash| { - if let Some(RewardOrSlash::Reward(balance)) = reward_or_slash { - balance - } else { - Zero::zero() - } - }) - .sum::(); + let final_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); + let expected_bid_payouts = inst.execute(|| { + Bids::::iter_prefix_values((project_id,)) + .map(|bid| { + UserToStatemintAsset::::new( + bid.bidder, + bid.funding_asset_amount_locked, + bid.funding_asset.to_statemint_id(), + ) + }) + .sorted_by_key(|item| item.account.clone()) + .collect::>>() + }); + let expected_community_contribution_payouts = + MockInstantiator::calculate_contributed_funding_asset_spent(community_contributions.clone(), final_price); + let expected_remainder_contribution_payouts = + MockInstantiator::calculate_contributed_funding_asset_spent(remainder_contributions.clone(), final_price); + let all_expected_payouts = MockInstantiator::generic_map_operation( + vec![ + expected_bid_payouts.clone(), + expected_community_contribution_payouts, + expected_remainder_contribution_payouts, + ], + MergeOperation::Add, + ); - (account, total_evaluator_ct_rewarded) - }) - .collect_vec(); + let prev_issuer_funding_balance = inst + .get_free_statemint_asset_balances_for(expected_bid_payouts[0].asset_id, vec![issuer.clone()])[0] + .asset_amount; + let all_participants = all_expected_payouts.accounts(); + let prev_participants_funding_balances = + inst.get_free_statemint_asset_balances_for(expected_bid_payouts[0].asset_id, all_participants.clone()); - let bidders = bids.accounts(); - let bidder_ct_amounts = bidders - .iter() - .map(|account| { - let bids = inst.execute(|| { - Bids::::iter_prefix_values((project_id, account.clone())).collect::>() - }); - let total_bidder_ct_rewarded = bids.iter().map(|bid| bid.final_ct_amount).sum::(); + call_and_is_ok!( + inst, + Pallet::::decide_project_outcome( + RuntimeOrigin::signed(issuer), + project_id, + FundingOutcomeDecision::RejectFunding + ) + ); - (account, total_bidder_ct_rewarded) - }) - .collect_vec(); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - let community_accounts = community_contributions.accounts(); - let remainder_accounts = remainder_contributions.accounts(); - let all_contributors = community_accounts.iter().chain(remainder_accounts.iter()).unique(); - let contributor_ct_amounts = all_contributors - .map(|account| { - let contributions = inst.execute(|| { - Contributions::::iter_prefix_values((project_id, account.clone())).collect::>() - }); - let total_contributor_ct_rewarded = - contributions.iter().map(|contribution| contribution.ct_amount).sum::(); + let stored_bids = inst.execute(|| { + Bids::::iter_prefix_values((project_id,)) + .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) + .collect::>() + }); + let stored_contributions = + inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); - (account, total_contributor_ct_rewarded) - }) - .collect_vec(); + for bid in stored_bids { + call_and_is_ok!( + inst, + Pallet::::release_bid_funds_for( + RuntimeOrigin::signed(issuer), + project_id, + bid.bidder, + bid.id, + ) + ) + } - let all_ct_expectations = MockInstantiator::generic_map_merge_reduce( - vec![evaluator_ct_amounts, bidder_ct_amounts, contributor_ct_amounts], - |item| item.0, - Zero::zero(), - |item, accumulator| accumulator + item.1, + for contribution in stored_contributions { + call_and_is_ok!( + inst, + Pallet::::release_contribution_funds_for( + RuntimeOrigin::signed(issuer), + project_id, + contribution.contributor, + contribution.id, + ) + ) + } + + let post_issuer_funding_balance = inst + .get_free_statemint_asset_balances_for(expected_bid_payouts[0].asset_id, vec![issuer.clone()])[0] + .asset_amount; + let post_participants_funding_balances = + inst.get_free_statemint_asset_balances_for(expected_bid_payouts[0].asset_id, all_participants); + let post_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( + expected_bid_payouts[0].asset_id, + vec![Pallet::::fund_account_id(project_id)], + )[0] + .asset_amount; + + let all_participants_funding_delta = MockInstantiator::generic_map_operation( + vec![prev_participants_funding_balances, post_participants_funding_balances], + MergeOperation::Add, ); - for (account, amount) in all_ct_expectations { - let minted = - inst.execute(|| ::ContributionTokenCurrency::balance(project_id, account)); - assert_eq!(minted, amount); - } + let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; + + assert_eq!(issuer_funding_delta, 0); + assert_eq!(post_project_pot_funding_balance, 0u128); + assert_eq!(all_expected_payouts, all_participants_funding_delta); } #[test] - fn ct_minted_manually() { + pub fn plmc_bonded_is_returned_automatically_on_funding_fail() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = default_evaluations(); - let bids = default_bids(); - let community_contributions = default_community_buys(); - let remainder_contributions = default_remainder_buys(); + let evaluations = vec![UserToUSDBalance::new(EVALUATOR_1, 50_000 * US_DOLLAR)]; + let bids = MockInstantiator::generate_bids_from_total_usd( + Percent::from_percent(50u8) * project.total_allocation_size.0, + project.minimum_price, + default_weights(), + default_bidders(), + default_bidder_multipliers(), + ); + + let community_contributions = MockInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(50u8) * project.total_allocation_size.1 / 2, + project.minimum_price, + default_weights(), + default_community_contributors(), + default_community_contributor_multipliers(), + ); + let remainder_contributions = MockInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(50u8) * project.total_allocation_size.1 / 2, + project.minimum_price, + default_weights(), + default_remainder_contributors(), + default_remainder_contributor_multipliers(), + ); let project_id = inst.create_finished_project( project, @@ -5946,272 +5193,269 @@ mod funding_end { community_contributions.clone(), remainder_contributions.clone(), ); - let details = inst.get_project_details(project_id); - assert_eq!(details.status, ProjectStatus::FundingSuccessful); - assert_eq!(details.cleanup, Cleaner::NotReady); - // do_end_funding - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData))); - - - let evaluators = evaluations.accounts(); - let evaluator_ct_amounts = evaluators - .iter() - .map(|account| { - let evaluations = inst.execute(|| { - Evaluations::::iter_prefix_values((project_id, account.clone())).collect::>() - }); - for evaluation in evaluations.iter() { - inst.execute(|| { - assert_ok!(Pallet::::evaluation_reward_payout_for( - RuntimeOrigin::signed(evaluation.evaluator), - project_id, - evaluation.evaluator, - evaluation.id, - )); - }); - } - let evaluations = inst.execute(|| { - Evaluations::::iter_prefix_values((project_id, account.clone())).collect::>() - }); - let total_evaluator_ct_rewarded = evaluations - .iter() - .map(|evaluation| evaluation.rewarded_or_slashed) - .map(|reward_or_slash| { - if let Some(RewardOrSlash::Reward(balance)) = reward_or_slash { - balance - } else { - Zero::zero() - } - }) - .sum::(); + let final_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); - (account, total_evaluator_ct_rewarded) - }) + let expected_evaluators_and_contributors_payouts = + MockInstantiator::calculate_total_plmc_locked_from_evaluations_and_remainder_contributions( + evaluations.clone(), + remainder_contributions.clone(), + final_price, + true, + ); + let stored_bids = inst.execute(|| Bids::::iter_prefix_values((project_id,)).collect_vec()); + let bids = stored_bids + .into_iter() + .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) + .map(|bid| BidParams::from(bid.bidder, bid.final_ct_amount, bid.final_ct_usd_price)) .collect_vec(); - - let bidders = bids.accounts(); - let bidder_ct_amounts = bidders - .iter() - .map(|account| { - let bids = inst.execute(|| { - Bids::::iter_prefix_values((project_id, account.clone())).collect::>() - }); - for bid in bids.iter() { - inst.execute(|| { - assert_ok!(Pallet::::bid_ct_mint_for( - RuntimeOrigin::signed(bid.bidder), - project_id, - bid.bidder, - bid.id, - )); - }); - } - - let total_bidder_ct_rewarded = bids.iter().map(|bid| bid.final_ct_amount).sum::(); - - (account, total_bidder_ct_rewarded) + let expected_bid_payouts = MockInstantiator::calculate_auction_plmc_spent(&bids.clone(), Some(final_price)); + let expected_community_contribution_payouts = + MockInstantiator::calculate_contributed_plmc_spent(community_contributions.clone(), final_price); + let all_expected_payouts = MockInstantiator::generic_map_operation( + vec![ + expected_evaluators_and_contributors_payouts.clone(), + expected_bid_payouts.clone(), + expected_community_contribution_payouts, + ], + MergeOperation::Add, + ); + println!("all expected payouts {:?}", all_expected_payouts); + for payout in all_expected_payouts.clone() { + let evaluation_hold = inst.execute(|| { + <::NativeCurrency as fungible::InspectHold>>::balance_on_hold( + &LockType::Evaluation(project_id), + &payout.account, + ) + }); + let participation_hold = inst.execute(|| { + <::NativeCurrency as fungible::InspectHold>>::balance_on_hold( + &LockType::Participation(project_id), + &payout.account, + ) + }); + println!("account {:?} has evaluation hold {:?}", payout.account, evaluation_hold); + println!("account {:?} has participation hold {:?}", payout.account, participation_hold); + } + let deposit_required = <::ContributionTokenCurrency as AccountTouch< + ProjectIdOf, + AccountIdOf, + >>::deposit_required(project_id); + let all_expected_payouts = all_expected_payouts + .into_iter() + .map(|UserToPLMCBalance { account, plmc_amount }| { + UserToPLMCBalance::new(account, plmc_amount + deposit_required) }) - .collect_vec(); + .collect::>(); - let community_accounts = community_contributions.accounts(); - let remainder_accounts = remainder_contributions.accounts(); - let all_contributors = community_accounts.iter().chain(remainder_accounts.iter()).unique(); - let contributor_ct_amounts = all_contributors - .map(|account| { - let contributions = inst.execute(|| { - Contributions::::iter_prefix_values((project_id, account.clone())).collect::>() - }); - for contribution in contributions.iter() { - inst.execute(|| { - assert_ok!(Pallet::::contribution_ct_mint_for( - RuntimeOrigin::signed(contribution.contributor), - project_id, - contribution.contributor, - contribution.id, - )); - }); - } + let prev_issuer_funding_balance = inst.get_free_plmc_balances_for(vec![issuer.clone()])[0].plmc_amount; - let total_contributor_ct_rewarded = - contributions.iter().map(|contribution| contribution.ct_amount).sum::(); + let all_participants = all_expected_payouts.accounts(); + let prev_participants_plmc_balances = inst.get_free_plmc_balances_for(all_participants.clone()); - (account, total_contributor_ct_rewarded) - }) - .collect_vec(); + call_and_is_ok!( + inst, + Pallet::::decide_project_outcome( + RuntimeOrigin::signed(issuer), + project_id, + FundingOutcomeDecision::RejectFunding + ) + ); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + inst.advance_time(10).unwrap(); + assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Failure(CleanerState::Finished(PhantomData))); - let all_ct_expectations = MockInstantiator::generic_map_merge_reduce( - vec![evaluator_ct_amounts, bidder_ct_amounts, contributor_ct_amounts], - |item| item.0, - Zero::zero(), - |item, accumulator| accumulator + item.1, + let post_issuer_funding_balance = inst.get_free_plmc_balances_for(vec![issuer.clone()])[0].plmc_amount; + let post_participants_plmc_balances = inst.get_free_plmc_balances_for(all_participants); + + let all_participants_plmc_deltas = MockInstantiator::generic_map_operation( + vec![post_participants_plmc_balances, prev_participants_plmc_balances], + MergeOperation::Subtract, ); - for (account, amount) in all_ct_expectations { - let minted = - inst.execute(|| ::ContributionTokenCurrency::balance(project_id, account)); - assert_eq!(minted, amount, "Account: {}", account); - } + let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; - let details = inst.get_project_details(project_id); - assert_eq!(details.status, ProjectStatus::FundingSuccessful); - assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData))); + let participants = all_participants_plmc_deltas.accounts(); + for participant in participants { + let future_deposit_reserved = inst.execute(||{<::NativeCurrency as fungible::InspectHold>>::balance_on_hold(&LockType::FutureDeposit(project_id), &participant)}); + println!("participant {:?} has future deposit reserved {:?}", participant, future_deposit_reserved); + } + assert_eq!(issuer_funding_delta, 0); + assert_eq!(all_participants_plmc_deltas, all_expected_payouts); } #[test] - fn multiplier_gets_correct_vesting_duration() { + pub fn plmc_bonded_is_returned_manually_on_funding_fail() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = default_evaluations(); - let bids = vec![ - BidParams::new(BIDDER_1, 10_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), - BidParams::new(BIDDER_2, 20_000 * ASSET_UNIT, 1.into(), 2u8, AcceptedFundingAsset::USDT), - BidParams::new(BIDDER_3, 20_000 * ASSET_UNIT, 11.into(), 3u8, AcceptedFundingAsset::USDT), + let evaluations = vec![ + UserToUSDBalance::new(EVALUATOR_1, 50_000 * US_DOLLAR), + UserToUSDBalance::new(EVALUATOR_2, 25_000 * US_DOLLAR), + UserToUSDBalance::new(EVALUATOR_3, 32_000 * US_DOLLAR), ]; - let community_contributions = default_community_buys(); - let remainder_contributions = vec![]; + let bids = MockInstantiator::generate_bids_from_total_usd( + Percent::from_percent(50u8) * project.total_allocation_size.0, + project.minimum_price, + default_weights(), + default_bidders(), + default_bidder_multipliers(), + ); + + let community_contributions = MockInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(50u8) * project.total_allocation_size.1 / 2, + project.minimum_price, + default_weights(), + default_community_contributors(), + default_community_contributor_multipliers(), + ); + let remainder_contributions = MockInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(50u8) * project.total_allocation_size.1 / 2, + project.minimum_price, + default_weights(), + default_remainder_contributors(), + default_remainder_contributor_multipliers(), + ); let project_id = inst.create_finished_project( project, issuer, - evaluations, - bids, - community_contributions, - remainder_contributions, + evaluations.clone(), + bids.clone(), + community_contributions.clone(), + remainder_contributions.clone(), ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - - inst.advance_time(10u64).unwrap(); - let details = inst.get_project_details(project_id); - assert_eq!(details.cleanup, Cleaner::Success(CleanerState::Finished(PhantomData))); - - let mut stored_bids = - inst.execute(|| Bids::::iter_prefix_values((project_id,)).collect::>()); - - stored_bids.sort_by_key(|bid| bid.bidder); - let one_week_in_blocks = DAYS * 7; - assert_eq!(stored_bids[0].plmc_vesting_info.unwrap().duration, 1u64); - assert_eq!( - stored_bids[1].plmc_vesting_info.unwrap().duration, - FixedU128::from_rational(2167, 1000).saturating_mul_int(one_week_in_blocks as u64) + let final_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); + let expected_evaluator_contributor_return = + MockInstantiator::calculate_total_plmc_locked_from_evaluations_and_remainder_contributions( + vec![UserToUSDBalance::new(EVALUATOR_1, 50_000 * US_DOLLAR)], + vec![ContributionParams::new( + EVALUATOR_1, + 250 * ASSET_UNIT, + 1u8.try_into().unwrap(), + AcceptedFundingAsset::USDT, + )], + final_price, + true, + ); + let expected_bid_payouts = MockInstantiator::calculate_auction_plmc_spent(&bids.clone(), Some(final_price)); + let expected_community_contribution_payouts = + MockInstantiator::calculate_contributed_plmc_spent(community_contributions.clone(), final_price); + let expected_remainder_contribution_payouts = MockInstantiator::calculate_contributed_plmc_spent( + vec![ + ContributionParams::new( + BIDDER_1, + 13_400 * ASSET_UNIT, + 3u8.try_into().unwrap(), + AcceptedFundingAsset::USDT, + ), + ContributionParams::new(BUYER_1, 42 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), + ], + final_price, ); - assert_eq!( - stored_bids[2].plmc_vesting_info.unwrap().duration, - FixedU128::from_rational(4334, 1000).saturating_mul_int(one_week_in_blocks as u64) + let all_expected_payouts = MockInstantiator::generic_map_operation( + vec![ + expected_evaluator_contributor_return, + expected_bid_payouts.clone(), + expected_community_contribution_payouts, + expected_remainder_contribution_payouts, + ], + MergeOperation::Add, ); - } - #[test] - pub fn funding_assets_are_paid_manually_to_issuer() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = default_evaluations(); - let bids = default_bids(); - let community_contributions = default_community_buys(); - let remainder_contributions = default_remainder_buys(); + let prev_issuer_funding_balance = inst.get_free_plmc_balances_for(vec![issuer.clone()])[0].plmc_amount; + let all_participants = all_expected_payouts.accounts(); + let prev_participants_plmc_balances = inst.get_free_plmc_balances_for(all_participants.clone()); - let project_id = inst.create_finished_project( - project, - issuer, - evaluations, - bids, - community_contributions, - remainder_contributions, + call_and_is_ok!( + inst, + Pallet::::decide_project_outcome( + RuntimeOrigin::signed(issuer), + project_id, + FundingOutcomeDecision::RejectFunding + ) + ); + inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); + assert_eq!( + inst.get_project_details(project_id).cleanup, + Cleaner::Failure(CleanerState::Initialized(PhantomData)) ); - let final_winning_bids = inst.execute(|| { + let stored_evaluations = + inst.execute(|| Evaluations::::iter_prefix_values((project_id,)).collect::>()); + let stored_bids = inst.execute(|| { Bids::::iter_prefix_values((project_id,)) .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) .collect::>() }); - let final_bid_payouts = inst.execute(|| { - Bids::::iter_prefix_values((project_id,)) - .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) - .map(|bid| { - UserToStatemintAsset::new( - bid.bidder, - bid.funding_asset_amount_locked, - bid.funding_asset.to_statemint_id(), - ) - }) - .collect::>>() - }); - let final_contributions = + let stored_contributions = inst.execute(|| Contributions::::iter_prefix_values((project_id,)).collect::>()); - let final_contribution_payouts = inst.execute(|| { - Contributions::::iter_prefix_values((project_id,)) - .map(|contribution| { - UserToStatemintAsset::new( - contribution.contributor, - contribution.funding_asset_amount, - contribution.funding_asset.to_statemint_id(), - ) - }) - .collect::>>() - }); - - let total_expected_bid_payout = - final_bid_payouts.iter().map(|bid| bid.asset_amount.clone()).sum::>(); - let total_expected_contribution_payout = final_contribution_payouts - .iter() - .map(|contribution| contribution.asset_amount.clone()) - .sum::>(); - - let prev_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; - let prev_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; + for evaluation in stored_evaluations { + call_and_is_ok!( + inst, + Pallet::::evaluation_slash_for( + RuntimeOrigin::signed(evaluation.evaluator), + project_id, + evaluation.evaluator, + evaluation.id, + ), + Pallet::::evaluation_unbond_for( + RuntimeOrigin::signed(evaluation.evaluator), + project_id, + evaluation.evaluator, + evaluation.id, + ) + ) + } - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - assert_eq!( - inst.get_project_details(project_id).cleanup, - Cleaner::Success(CleanerState::Initialized(PhantomData)) - ); - for bid in final_winning_bids { - inst.execute(|| { - Pallet::::payout_bid_funds_for( + for bid in stored_bids { + call_and_is_ok!( + inst, + Pallet::::release_bid_funds_for( RuntimeOrigin::signed(issuer), project_id, bid.bidder, bid.id, + ), + Pallet::::bid_unbond_for( + RuntimeOrigin::signed(bid.bidder), + project_id, + bid.bidder, + bid.id, ) - }) - .unwrap(); + ) } - for contribution in final_contributions { - inst.execute(|| { - Pallet::::payout_contribution_funds_for( + + for contribution in stored_contributions { + call_and_is_ok!( + inst, + Pallet::::release_contribution_funds_for( RuntimeOrigin::signed(issuer), project_id, contribution.contributor, contribution.id, + ), + Pallet::::contribution_unbond_for( + RuntimeOrigin::signed(contribution.contributor), + project_id, + contribution.contributor, + contribution.id, ) - }) - .unwrap(); + ) } - let post_issuer_funding_balance = inst - .get_free_statemint_asset_balances_for(final_bid_payouts[0].asset_id, vec![issuer.clone()])[0] - .asset_amount; - let post_project_pot_funding_balance = inst.get_free_statemint_asset_balances_for( - final_bid_payouts[0].asset_id, - vec![Pallet::::fund_account_id(project_id)], - )[0] - .asset_amount; - let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; - let project_pot_funding_delta = prev_project_pot_funding_balance - post_project_pot_funding_balance; + let post_issuer_funding_balance = inst.get_free_plmc_balances_for(vec![issuer.clone()])[0].plmc_amount; + let post_participants_plmc_balances = inst.get_free_plmc_balances_for(all_participants); - assert_eq!(issuer_funding_delta - total_expected_bid_payout, total_expected_contribution_payout); - assert_eq!(issuer_funding_delta, project_pot_funding_delta); + let all_participants_plmc_deltas = MockInstantiator::generic_map_operation( + vec![post_participants_plmc_balances, prev_participants_plmc_balances], + MergeOperation::Subtract, + ); - assert_eq!(post_project_pot_funding_balance, 0u128); + let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; + + assert_eq!(issuer_funding_delta, 0); + assert_eq!(all_expected_payouts, all_participants_plmc_deltas); } // i.e consumer increase bug fixed with touch on pallet-assets From 2df11c1878e0f08e50ba556fbc248f930939f063 Mon Sep 17 00:00:00 2001 From: Juan Ignacio RIos Date: Mon, 11 Dec 2023 18:03:04 +0100 Subject: [PATCH 066/212] benchmark tests passing --- integration-tests/src/tests/ct_migration.rs | 12 ++-- justfile | 5 +- pallets/funding/src/benchmarking.rs | 37 +++++++++- pallets/funding/src/instantiator.rs | 2 +- pallets/funding/src/tests.rs | 77 ++++++++++----------- 5 files changed, 80 insertions(+), 53 deletions(-) diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index d0b6a9f8d..fe8c5774e 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -7,6 +7,7 @@ use polimec_common::migration_types::{Migration, MigrationInfo, MigrationOrigin, use polimec_parachain_runtime::PolimecFunding; use sp_runtime::{FixedPointNumber, Perquintill}; use std::collections::HashMap; +use sp_runtime::traits::Convert; use tests::defaults::*; fn execute_cleaner(inst: &mut IntegrationInstantiator) { @@ -63,7 +64,8 @@ fn send_migrations( pallet_funding::Contributions::::iter_prefix_values((project_id, account.clone())); let evaluation_migrations = user_evaluations.map(|evaluation| { - assert!(matches!(evaluation.ct_migration_status, MigrationStatus::Sent(_))); + let evaluator_bytes = ::AccountId32Conversion::convert(evaluation.evaluator.clone()); + assert!(matches!(evaluation.ct_migration_status, MigrationStatus::Sent(_)), "{:?}'s evaluation was not sent {:?}", names()[&evaluator_bytes], evaluation); if let Some(RewardOrSlash::Reward(amount)) = evaluation.rewarded_or_slashed { Migration { info: MigrationInfo { @@ -97,7 +99,7 @@ fn send_migrations( }, } }); - let contribution_ct_amount = user_contributions.map(|contribution| { + let contribution_migrations = user_contributions.map(|contribution| { assert!(matches!(contribution.ct_migration_status, MigrationStatus::Sent(_))); Migration { info: MigrationInfo { @@ -112,7 +114,7 @@ fn send_migrations( } }); - evaluation_migrations.chain(bid_migrations).chain(contribution_ct_amount).collect::() + evaluation_migrations.chain(bid_migrations).chain(contribution_migrations).collect::() }); if migrations.clone().inner().is_empty() { panic!("no migrations for account: {:?}", account) @@ -324,7 +326,7 @@ fn migration_is_sent() { fn migration_is_executed_on_project_and_confirmed_on_polimec() { let mut inst = IntegrationInstantiator::new(None); set_oracle_prices(); - let mut participants = + let participants = vec![EVAL_1, EVAL_2, EVAL_3, BIDDER_2, BIDDER_3, BIDDER_4, BIDDER_5, BUYER_2, BUYER_3, BUYER_4, BUYER_5] .into_iter() .map(|x| AccountId::from(x)) @@ -386,7 +388,7 @@ fn vesting_over_several_blocks_on_project() { bids.push(BidParams { bidder: BIDDER_1.into(), - amount: 2_000 * ASSET_UNIT, + amount: 15_000 * ASSET_UNIT, price: 12u128.into(), multiplier: MultiplierOf::::try_from(20u8).unwrap(), asset: AcceptedFundingAsset::USDT, diff --git a/justfile b/justfile index d7b3d9d69..40dad7441 100644 --- a/justfile +++ b/justfile @@ -82,10 +82,7 @@ benchmark-pallet-linear-release: --template=./.maintain/frame-weight-template.hbs benchmarks-test: - cargo run --features runtime-benchmarks,fast-gov -p polimec-parachain-node benchmark pallet \ - --chain=polimec-rococo-local \ - --pallet="pallet_funding" \ - --extrinsic="*" + cargo test --features runtime-benchmarks -p pallet-funding benchmarks # Build the Node Docker Image docker-build tag = "latest" package= "polimec-parachain-node": diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index b8120ff4e..6c01dce86 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -134,19 +134,19 @@ where vec![ ContributionParams::new( account::>("contributor_1", 0, 0), - (100 * ASSET_UNIT).into(), + (10_000 * ASSET_UNIT).into(), 1u8, AcceptedFundingAsset::USDT, ), ContributionParams::new( account::>("contributor_2", 0, 0), - (200 * ASSET_UNIT).into(), + (6_000 * ASSET_UNIT).into(), 1u8, AcceptedFundingAsset::USDT, ), ContributionParams::new( account::>("contributor_3", 0, 0), - (2000 * ASSET_UNIT).into(), + (30_000 * ASSET_UNIT).into(), 1u8, AcceptedFundingAsset::USDT, ), @@ -177,6 +177,16 @@ pub fn default_contributors() -> Vec> { ] } +pub fn default_bidder_multipliers() -> Vec { + vec![20u8, 3u8, 15u8, 13u8, 9u8] +} +pub fn default_community_contributor_multipliers() -> Vec { + vec![1u8, 5u8, 3u8, 1u8, 2u8] +} +pub fn default_remainder_contributor_multipliers() -> Vec { + vec![1u8, 10u8, 3u8, 2u8, 4u8] +} + #[benchmarks( where T: Config + frame_system::Config::RuntimeEvent> + pallet_balances::Config>, @@ -313,8 +323,10 @@ mod benchmarks { let plmc_for_evaluating = BenchInstantiator::::calculate_evaluation_plmc_spent(vec![evaluation.clone()]); let existential_plmc: Vec> = plmc_for_evaluating.accounts().existential_deposits(); + let ct_account_deposits: Vec> = plmc_for_evaluating.accounts().ct_account_deposits(); inst.mint_plmc_to(existential_plmc); + inst.mint_plmc_to(ct_account_deposits); inst.mint_plmc_to(plmc_for_evaluating.clone()); inst.advance_time(One::one()).unwrap(); @@ -380,8 +392,10 @@ mod benchmarks { let evaluations = default_evaluations(); let plmc_for_evaluating = BenchInstantiator::::calculate_evaluation_plmc_spent(evaluations.clone()); let existential_plmc: Vec> = plmc_for_evaluating.accounts().existential_deposits(); + let ct_account_deposits: Vec> = plmc_for_evaluating.accounts().ct_account_deposits(); inst.mint_plmc_to(existential_plmc); + inst.mint_plmc_to(ct_account_deposits); inst.mint_plmc_to(plmc_for_evaluating); inst.advance_time(One::one()).unwrap(); @@ -431,11 +445,13 @@ mod benchmarks { let necessary_plmc: Vec> = BenchInstantiator::::calculate_auction_plmc_spent(&vec![bid_params.clone()], None); let existential_deposits: Vec> = necessary_plmc.accounts().existential_deposits(); + let ct_account_deposits = necessary_plmc.accounts().ct_account_deposits(); let necessary_usdt: Vec> = BenchInstantiator::::calculate_auction_funding_asset_spent(&vec![bid_params.clone()], None); inst.mint_plmc_to(necessary_plmc.clone()); inst.mint_plmc_to(existential_deposits.clone()); + inst.mint_plmc_to(ct_account_deposits.clone()); inst.mint_statemint_asset_to(necessary_usdt.clone()); #[extrinsic_call] @@ -535,11 +551,13 @@ mod benchmarks { let necessary_plmc = BenchInstantiator::::calculate_contributed_plmc_spent(vec![contribution_params.clone()], price); let existential_deposits: Vec> = necessary_plmc.accounts().existential_deposits(); + let ct_account_deposits: Vec> = necessary_plmc.accounts().ct_account_deposits(); let necessary_usdt = BenchInstantiator::::calculate_contributed_funding_asset_spent(vec![contribution_params.clone()], price); inst.mint_plmc_to(necessary_plmc.clone()); inst.mint_plmc_to(existential_deposits.clone()); + inst.mint_plmc_to(ct_account_deposits.clone()); inst.mint_statemint_asset_to(necessary_usdt.clone()); let contribution_id = NextContributionId::::get(); @@ -635,6 +653,7 @@ mod benchmarks { ); inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingSuccessful); assert_eq!( inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData)) @@ -703,12 +722,14 @@ mod benchmarks { 10u128.into(), default_weights(), default_bidders::(), + default_bidder_multipliers() ); let contributions = BenchInstantiator::generate_contributions_from_total_usd( Percent::from_percent(10) * target_funding_amount, BenchInstantiator::calculate_price_from_test_bids(bids.clone()), default_weights(), default_contributors::(), + default_community_contributor_multipliers() ); let project_id = @@ -1206,6 +1227,7 @@ mod benchmarks { 1u128.into(), default_weights(), default_bidders::(), + default_bidder_multipliers() ); let target_funding_amount: BalanceOf = project_metadata.minimum_price.saturating_mul_int(project_metadata.total_allocation_size.1); @@ -1214,6 +1236,7 @@ mod benchmarks { BenchInstantiator::calculate_price_from_test_bids(bids.clone()), default_weights(), default_contributors::(), + default_community_contributor_multipliers() ); let project_id = @@ -1257,6 +1280,7 @@ mod benchmarks { 10u128.into(), default_weights(), default_bidders::(), + default_bidder_multipliers() ); let bidder = bids[0].bidder.clone(); whitelist_account!(bidder); @@ -1265,6 +1289,7 @@ mod benchmarks { BenchInstantiator::calculate_price_from_test_bids(bids.clone()), default_weights(), default_contributors::(), + default_community_contributor_multipliers() ); let project_id = @@ -1327,6 +1352,7 @@ mod benchmarks { 10u128.into(), default_weights(), default_bidders::(), + default_bidder_multipliers() ); let bidder = bids[0].bidder.clone(); whitelist_account!(bidder); @@ -1335,6 +1361,7 @@ mod benchmarks { BenchInstantiator::calculate_price_from_test_bids(bids.clone()), default_weights(), default_contributors::(), + default_community_contributor_multipliers() ); let project_id = @@ -1398,12 +1425,14 @@ mod benchmarks { 1u128.into(), default_weights(), default_bidders::(), + default_bidder_multipliers() ); let contributions: Vec> = BenchInstantiator::generate_contributions_from_total_usd( Percent::from_percent(10) * target_funding_amount, BenchInstantiator::calculate_price_from_test_bids(bids.clone()), default_weights(), default_contributors::(), + default_community_contributor_multipliers() ); let contributor = contributions[0].contributor.clone(); whitelist_account!(contributor); @@ -1475,12 +1504,14 @@ mod benchmarks { 1u128.into(), default_weights(), default_bidders::(), + default_bidder_multipliers() ); let contributions: Vec> = BenchInstantiator::generate_contributions_from_total_usd( Percent::from_percent(10) * target_funding_amount, BenchInstantiator::calculate_price_from_test_bids(bids.clone()), default_weights(), default_contributors::(), + default_community_contributor_multipliers() ); let contributor = contributions[0].contributor.clone(); whitelist_account!(contributor); diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 0df0d2611..bbf9e82a3 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -11,7 +11,7 @@ use frame_support::{ weights::Weight, Parameter, }; -use std::ops::Not; +use sp_std::ops::Not; use sp_arithmetic::Perquintill; diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 54f754c16..6814cbf54 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -5202,12 +5202,6 @@ mod funding_end { final_price, true, ); - let stored_bids = inst.execute(|| Bids::::iter_prefix_values((project_id,)).collect_vec()); - let bids = stored_bids - .into_iter() - .filter(|bid| matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..))) - .map(|bid| BidParams::from(bid.bidder, bid.final_ct_amount, bid.final_ct_usd_price)) - .collect_vec(); let expected_bid_payouts = MockInstantiator::calculate_auction_plmc_spent(&bids.clone(), Some(final_price)); let expected_community_contribution_payouts = MockInstantiator::calculate_contributed_plmc_spent(community_contributions.clone(), final_price); @@ -5288,11 +5282,7 @@ mod funding_end { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let issuer = ISSUER; let project = default_project(inst.get_new_nonce(), issuer); - let evaluations = vec![ - UserToUSDBalance::new(EVALUATOR_1, 50_000 * US_DOLLAR), - UserToUSDBalance::new(EVALUATOR_2, 25_000 * US_DOLLAR), - UserToUSDBalance::new(EVALUATOR_3, 32_000 * US_DOLLAR), - ]; + let evaluations = vec![UserToUSDBalance::new(EVALUATOR_1, 50_000 * US_DOLLAR)]; let bids = MockInstantiator::generate_bids_from_total_usd( Percent::from_percent(50u8) * project.total_allocation_size.0, project.minimum_price, @@ -5325,44 +5315,49 @@ mod funding_end { remainder_contributions.clone(), ); let final_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); - let expected_evaluator_contributor_return = + + let expected_evaluators_and_contributors_payouts = MockInstantiator::calculate_total_plmc_locked_from_evaluations_and_remainder_contributions( - vec![UserToUSDBalance::new(EVALUATOR_1, 50_000 * US_DOLLAR)], - vec![ContributionParams::new( - EVALUATOR_1, - 250 * ASSET_UNIT, - 1u8.try_into().unwrap(), - AcceptedFundingAsset::USDT, - )], + evaluations.clone(), + remainder_contributions.clone(), final_price, true, ); let expected_bid_payouts = MockInstantiator::calculate_auction_plmc_spent(&bids.clone(), Some(final_price)); let expected_community_contribution_payouts = MockInstantiator::calculate_contributed_plmc_spent(community_contributions.clone(), final_price); - let expected_remainder_contribution_payouts = MockInstantiator::calculate_contributed_plmc_spent( - vec![ - ContributionParams::new( - BIDDER_1, - 13_400 * ASSET_UNIT, - 3u8.try_into().unwrap(), - AcceptedFundingAsset::USDT, - ), - ContributionParams::new(BUYER_1, 42 * ASSET_UNIT, 1u8.try_into().unwrap(), AcceptedFundingAsset::USDT), - ], - final_price, - ); let all_expected_payouts = MockInstantiator::generic_map_operation( vec![ - expected_evaluator_contributor_return, + expected_evaluators_and_contributors_payouts.clone(), expected_bid_payouts.clone(), expected_community_contribution_payouts, - expected_remainder_contribution_payouts, ], MergeOperation::Add, ); + println!("all expected payouts {:?}", all_expected_payouts); + for payout in all_expected_payouts.clone() { + let evaluation_hold = inst.execute(|| { + <::NativeCurrency as fungible::InspectHold>>::balance_on_hold( + &LockType::Evaluation(project_id), + &payout.account, + ) + }); + let participation_hold = inst.execute(|| { + <::NativeCurrency as fungible::InspectHold>>::balance_on_hold( + &LockType::Participation(project_id), + &payout.account, + ) + }); + println!("account {:?} has evaluation hold {:?}", payout.account, evaluation_hold); + println!("account {:?} has participation hold {:?}", payout.account, participation_hold); + } + let deposit_required = <::ContributionTokenCurrency as AccountTouch< + ProjectIdOf, + AccountIdOf, + >>::deposit_required(project_id); let prev_issuer_funding_balance = inst.get_free_plmc_balances_for(vec![issuer.clone()])[0].plmc_amount; + let all_participants = all_expected_payouts.accounts(); let prev_participants_plmc_balances = inst.get_free_plmc_balances_for(all_participants.clone()); @@ -5375,10 +5370,7 @@ mod funding_end { ) ); inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); - assert_eq!( - inst.get_project_details(project_id).cleanup, - Cleaner::Failure(CleanerState::Initialized(PhantomData)) - ); + assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Failure(CleanerState::Initialized(PhantomData))); let stored_evaluations = inst.execute(|| Evaluations::::iter_prefix_values((project_id,)).collect::>()); @@ -5453,9 +5445,15 @@ mod funding_end { ); let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; - + let participants = all_participants_plmc_deltas.accounts(); + for participant in participants { + let future_deposit_reserved = inst.execute(||{<::NativeCurrency as fungible::InspectHold>>::balance_on_hold(&LockType::FutureDeposit(project_id), &participant)}); + println!("participant {:?} has future deposit reserved {:?}", participant, future_deposit_reserved); + } + assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Failure(CleanerState::Initialized(PhantomData))); assert_eq!(issuer_funding_delta, 0); - assert_eq!(all_expected_payouts, all_participants_plmc_deltas); + assert_eq!(all_participants_plmc_deltas, all_expected_payouts); + } // i.e consumer increase bug fixed with touch on pallet-assets @@ -5487,7 +5485,6 @@ mod funding_end { vec![EVALUATOR_1, EVALUATOR_4, BIDDER_6, BUYER_4, BUYER_7], vec![2u8, 1u8, 11u8, 1u8, 3u8], ); - // try doing 1000 projects use std::time::Instant; for i in 0..10 { let now = Instant::now(); From 2b78c6873409cc6a483b70224d563cdb7c09593f Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 11 Dec 2023 18:14:25 +0100 Subject: [PATCH 067/212] fmt. real benchmarks run successfully --- integration-tests/src/tests/ct_migration.rs | 14 ++++++++---- pallets/funding/src/benchmarking.rs | 24 ++++++++++----------- pallets/funding/src/tests.rs | 11 +++++++--- 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index fe8c5774e..617f98a7f 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -5,9 +5,8 @@ use pallet_funding::{ }; use polimec_common::migration_types::{Migration, MigrationInfo, MigrationOrigin, Migrations, ParticipationType}; use polimec_parachain_runtime::PolimecFunding; -use sp_runtime::{FixedPointNumber, Perquintill}; +use sp_runtime::{traits::Convert, FixedPointNumber, Perquintill}; use std::collections::HashMap; -use sp_runtime::traits::Convert; use tests::defaults::*; fn execute_cleaner(inst: &mut IntegrationInstantiator) { @@ -64,8 +63,15 @@ fn send_migrations( pallet_funding::Contributions::::iter_prefix_values((project_id, account.clone())); let evaluation_migrations = user_evaluations.map(|evaluation| { - let evaluator_bytes = ::AccountId32Conversion::convert(evaluation.evaluator.clone()); - assert!(matches!(evaluation.ct_migration_status, MigrationStatus::Sent(_)), "{:?}'s evaluation was not sent {:?}", names()[&evaluator_bytes], evaluation); + let evaluator_bytes = ::AccountId32Conversion::convert( + evaluation.evaluator.clone(), + ); + assert!( + matches!(evaluation.ct_migration_status, MigrationStatus::Sent(_)), + "{:?}'s evaluation was not sent {:?}", + names()[&evaluator_bytes], + evaluation + ); if let Some(RewardOrSlash::Reward(amount)) = evaluation.rewarded_or_slashed { Migration { info: MigrationInfo { diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 6c01dce86..e671ed205 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -722,14 +722,14 @@ mod benchmarks { 10u128.into(), default_weights(), default_bidders::(), - default_bidder_multipliers() + default_bidder_multipliers(), ); let contributions = BenchInstantiator::generate_contributions_from_total_usd( Percent::from_percent(10) * target_funding_amount, BenchInstantiator::calculate_price_from_test_bids(bids.clone()), default_weights(), default_contributors::(), - default_community_contributor_multipliers() + default_community_contributor_multipliers(), ); let project_id = @@ -1227,7 +1227,7 @@ mod benchmarks { 1u128.into(), default_weights(), default_bidders::(), - default_bidder_multipliers() + default_bidder_multipliers(), ); let target_funding_amount: BalanceOf = project_metadata.minimum_price.saturating_mul_int(project_metadata.total_allocation_size.1); @@ -1236,7 +1236,7 @@ mod benchmarks { BenchInstantiator::calculate_price_from_test_bids(bids.clone()), default_weights(), default_contributors::(), - default_community_contributor_multipliers() + default_community_contributor_multipliers(), ); let project_id = @@ -1280,7 +1280,7 @@ mod benchmarks { 10u128.into(), default_weights(), default_bidders::(), - default_bidder_multipliers() + default_bidder_multipliers(), ); let bidder = bids[0].bidder.clone(); whitelist_account!(bidder); @@ -1289,7 +1289,7 @@ mod benchmarks { BenchInstantiator::calculate_price_from_test_bids(bids.clone()), default_weights(), default_contributors::(), - default_community_contributor_multipliers() + default_community_contributor_multipliers(), ); let project_id = @@ -1352,7 +1352,7 @@ mod benchmarks { 10u128.into(), default_weights(), default_bidders::(), - default_bidder_multipliers() + default_bidder_multipliers(), ); let bidder = bids[0].bidder.clone(); whitelist_account!(bidder); @@ -1361,7 +1361,7 @@ mod benchmarks { BenchInstantiator::calculate_price_from_test_bids(bids.clone()), default_weights(), default_contributors::(), - default_community_contributor_multipliers() + default_community_contributor_multipliers(), ); let project_id = @@ -1425,14 +1425,14 @@ mod benchmarks { 1u128.into(), default_weights(), default_bidders::(), - default_bidder_multipliers() + default_bidder_multipliers(), ); let contributions: Vec> = BenchInstantiator::generate_contributions_from_total_usd( Percent::from_percent(10) * target_funding_amount, BenchInstantiator::calculate_price_from_test_bids(bids.clone()), default_weights(), default_contributors::(), - default_community_contributor_multipliers() + default_community_contributor_multipliers(), ); let contributor = contributions[0].contributor.clone(); whitelist_account!(contributor); @@ -1504,14 +1504,14 @@ mod benchmarks { 1u128.into(), default_weights(), default_bidders::(), - default_bidder_multipliers() + default_bidder_multipliers(), ); let contributions: Vec> = BenchInstantiator::generate_contributions_from_total_usd( Percent::from_percent(10) * target_funding_amount, BenchInstantiator::calculate_price_from_test_bids(bids.clone()), default_weights(), default_contributors::(), - default_community_contributor_multipliers() + default_community_contributor_multipliers(), ); let contributor = contributions[0].contributor.clone(); whitelist_account!(contributor); diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 6814cbf54..3a3afb5bf 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -5370,7 +5370,10 @@ mod funding_end { ) ); inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); - assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Failure(CleanerState::Initialized(PhantomData))); + assert_eq!( + inst.get_project_details(project_id).cleanup, + Cleaner::Failure(CleanerState::Initialized(PhantomData)) + ); let stored_evaluations = inst.execute(|| Evaluations::::iter_prefix_values((project_id,)).collect::>()); @@ -5450,10 +5453,12 @@ mod funding_end { let future_deposit_reserved = inst.execute(||{<::NativeCurrency as fungible::InspectHold>>::balance_on_hold(&LockType::FutureDeposit(project_id), &participant)}); println!("participant {:?} has future deposit reserved {:?}", participant, future_deposit_reserved); } - assert_eq!(inst.get_project_details(project_id).cleanup, Cleaner::Failure(CleanerState::Initialized(PhantomData))); + assert_eq!( + inst.get_project_details(project_id).cleanup, + Cleaner::Failure(CleanerState::Initialized(PhantomData)) + ); assert_eq!(issuer_funding_delta, 0); assert_eq!(all_participants_plmc_deltas, all_expected_payouts); - } // i.e consumer increase bug fixed with touch on pallet-assets From 1a76ece197ec51c41d1dbead8a49373b9626a7bf Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 12 Dec 2023 15:42:08 +0100 Subject: [PATCH 068/212] save --- integration-tests/penpal/src/lib.rs | 2 +- pallets/funding/src/functions.rs | 2 +- pallets/funding/src/impls.rs | 8 ++++---- pallets/funding/src/tests.rs | 16 ++++++++-------- pallets/funding/src/types.rs | 4 +--- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/integration-tests/penpal/src/lib.rs b/integration-tests/penpal/src/lib.rs index 0addf71b3..f37276600 100644 --- a/integration-tests/penpal/src/lib.rs +++ b/integration-tests/penpal/src/lib.rs @@ -57,7 +57,7 @@ use sp_runtime::{ create_runtime_str, generic, impl_opaque_keys, traits::{AccountIdLookup, BlakeTwo256, Block as BlockT}, transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, FixedU128, + ApplyExtrinsicResult, }; pub use sp_runtime::{traits::ConvertInto, MultiAddress, Perbill, Permill}; use sp_std::prelude::*; diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 1bf5de676..6cad68c5c 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -43,7 +43,7 @@ use crate::ProjectStatus::FundingSuccessful; use polimec_common::ReleaseSchedule; use crate::traits::{BondingRequirementCalculation, ProvideStatemintPrice, VestingDurationCalculation}; -use polimec_common::migration_types::{Migration, MigrationInfo, MigrationOrigin, Migrations, ParticipationType}; +use polimec_common::migration_types::{MigrationInfo, MigrationOrigin, Migrations, ParticipationType}; use super::*; const POLIMEC_PARA_ID: u32 = 3344u32; diff --git a/pallets/funding/src/impls.rs b/pallets/funding/src/impls.rs index 45c022126..ac5cb7656 100644 --- a/pallets/funding/src/impls.rs +++ b/pallets/funding/src/impls.rs @@ -263,7 +263,7 @@ impl DoRemainingOperation for CleanerState( project_id: ::ProjectIdentifier, - mut remaining_participants: AccountListOf, + remaining_participants: AccountListOf, ) -> (Weight, AccountListOf) { let base_weight = Weight::from_parts(10_000_000, 0); let mut iter_participants = remaining_participants.into_iter(); @@ -339,10 +339,10 @@ fn remaining_contributions(project_id: T::ProjectIdentifier) -> u64 { } fn remaining_participants(project_id: T::ProjectIdentifier) -> AccountListOf { - let evaluators = Evaluations::::iter_key_prefix((project_id,)).map(|(evaluator, evaluation_id)| evaluator); - let bidders = Bids::::iter_key_prefix((project_id,)).map(|(bidder, bid_id)| bidder); + let evaluators = Evaluations::::iter_key_prefix((project_id,)).map(|(evaluator, _evaluation_id)| evaluator); + let bidders = Bids::::iter_key_prefix((project_id,)).map(|(bidder, _bid_id)| bidder); let contributors = - Contributions::::iter_key_prefix((project_id,)).map(|(contributor, contribution_id)| contributor); + Contributions::::iter_key_prefix((project_id,)).map(|(contributor, _contribution_id)| contributor); let all_participants = evaluators.chain(bidders).chain(contributors).collect::>>(); AccountListOf::::force_from( all_participants.into_iter().collect_vec(), diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 9fe662f14..56572fabf 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -639,7 +639,7 @@ mod evaluation_round_failure { inst.mint_plmc_to(plmc_existential_deposits.clone()); inst.mint_plmc_to(plmc_ct_account_deposits.clone()); - inst.bond_for_users(project_id, evaluations); + let _ = inst.bond_for_users(project_id, evaluations); inst.do_free_plmc_assertions(vec![ UserToPLMCBalance::new(EVALUATOR_1, MockInstantiator::get_ed()), @@ -1389,7 +1389,7 @@ mod auction_round_success { let project_id = inst.create_auctioning_project(project, issuer, evaluations); - let mut bidders_plmc = MockInstantiator::calculate_auction_plmc_spent(&bids, None); + let bidders_plmc = MockInstantiator::calculate_auction_plmc_spent(&bids, None); let bidders_existential_deposits = bidders_plmc.accounts().existential_deposits(); let bidders_ct_account_deposits = bidders_plmc.accounts().ct_account_deposits(); inst.mint_plmc_to(bidders_plmc.clone()); @@ -1403,7 +1403,7 @@ mod auction_round_success { inst.start_community_funding(project_id).unwrap(); let final_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); - let mut contributors_plmc = + let contributors_plmc = MockInstantiator::calculate_contributed_plmc_spent(community_contributions.clone(), final_price); let contributors_existential_deposits = contributors_plmc.accounts().existential_deposits(); let contributors_ct_account_deposits = contributors_plmc.accounts().ct_account_deposits(); @@ -2002,7 +2002,7 @@ mod auction_round_failure { let (bid_in, bid_out) = (default_bids()[0].clone(), default_bids()[1].clone()); - let mut plmc_fundings = + let plmc_fundings = MockInstantiator::calculate_auction_plmc_spent(&vec![bid_in.clone(), bid_out.clone()], None); let plmc_existential_amounts = plmc_fundings.accounts().existential_deposits(); let plmc_ct_account_deposits = plmc_fundings.accounts().ct_account_deposits(); @@ -2080,7 +2080,7 @@ mod auction_round_failure { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let project_metadata = default_project(0, ISSUER); let automatic_fail_funding_percent = Percent::from_percent(30); - let (bid_allocation, contribution_allocation) = project_metadata.total_allocation_size; + let (bid_allocation, _contribution_allocation) = project_metadata.total_allocation_size; let deposit_required = <::ContributionTokenCurrency as AccountTouch< ProjectIdOf, AccountIdOf, @@ -2208,7 +2208,7 @@ mod community_round_success { ContributionParams::new(BOB, 4 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), ]; - let mut plmc_funding = MockInstantiator::calculate_contributed_plmc_spent(contributions.clone(), token_price); + let plmc_funding = MockInstantiator::calculate_contributed_plmc_spent(contributions.clone(), token_price); let plmc_existential_deposit = plmc_funding.accounts().existential_deposits(); let plmc_ct_account_deposits = plmc_funding.accounts().ct_account_deposits(); let statemint_funding = @@ -2253,7 +2253,7 @@ mod community_round_success { let ct_price = inst.get_project_details(project_id).weighted_average_price.expect("CT Price should exist"); let contributions = vec![ContributionParams::new(BOB, remaining_ct.1, 1u8, AcceptedFundingAsset::USDT)]; - let mut plmc_fundings = MockInstantiator::calculate_contributed_plmc_spent(contributions.clone(), ct_price); + let plmc_fundings = MockInstantiator::calculate_contributed_plmc_spent(contributions.clone(), ct_price); let plmc_existential_deposits = plmc_fundings.accounts().existential_deposits(); let plmc_ct_account_deposits = plmc_fundings.accounts().ct_account_deposits(); let statemint_asset_fundings = @@ -2331,7 +2331,7 @@ mod community_round_success { assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingSuccessful); let reserved_plmc = plmc_fundings.swap_remove(0).plmc_amount; - let remaining_plmc: BalanceOf = + let _remaining_plmc: BalanceOf = plmc_fundings.iter().fold(0_u128, |acc, item| acc + item.plmc_amount); let actual_funding_transferred = statemint_asset_fundings.swap_remove(0).asset_amount; diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index 55f29b74d..f92b91a57 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -403,8 +403,6 @@ pub mod storage_types { pub mod inner_types { use super::*; - use polimec_common::migration_types::{MigrationOrigin, Migrations}; - use sp_runtime::WeakBoundedVec; use xcm::v3::MaxDispatchErrorLen; #[derive(Default, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] @@ -836,4 +834,4 @@ impl MigrationGenerator { let migration_info: MigrationInfo = (contribution.ct_amount.into(), vesting_duration_local_type.into()).into(); Some(Migration::new(migration_origin, migration_info)) } -} +} \ No newline at end of file From aaf9850a73dfae0e2b4e66c5596a3c9c59392d9a Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 12 Dec 2023 15:47:58 +0100 Subject: [PATCH 069/212] fixes --- pallets/funding/src/tests.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 56572fabf..fb6965bd9 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -1917,7 +1917,7 @@ mod auction_round_failure { vec![glutton_bid_1.clone(), rejected_bid.clone(), glutton_bid_2.clone()], project_id, ); - let mut plmc_fundings = MockInstantiator::calculate_auction_plmc_spent(&bids, None); + let plmc_fundings = MockInstantiator::calculate_auction_plmc_spent(&bids, None); let usdt_fundings = MockInstantiator::calculate_auction_funding_asset_spent(&bids, None); let plmc_existential_amounnts = plmc_fundings.accounts().existential_deposits(); @@ -3296,7 +3296,7 @@ mod remainder_round_success { let contributions = vec![ContributionParams::new(BOB, remaining_ct.0 + remaining_ct.1, 1u8, AcceptedFundingAsset::USDT)]; - let mut plmc_fundings = MockInstantiator::calculate_contributed_plmc_spent(contributions.clone(), ct_price); + let plmc_fundings = MockInstantiator::calculate_contributed_plmc_spent(contributions.clone(), ct_price); let plmc_existential_deposits = contributions.accounts().existential_deposits(); let plmc_ct_account_deposits = contributions.accounts().ct_account_deposits(); let statemint_asset_fundings = @@ -3379,7 +3379,7 @@ mod remainder_round_success { assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingSuccessful); let reserved_plmc = plmc_fundings.swap_remove(0).plmc_amount; - let remaining_plmc: BalanceOf = + let _remaining_plmc: BalanceOf = plmc_fundings.iter().fold(Zero::zero(), |acc, item| item.plmc_amount + acc); let actual_funding_transferred = statemint_asset_fundings.swap_remove(0).asset_amount; @@ -3654,7 +3654,7 @@ mod remainder_round_failure { AccountIdOf, >>::deposit_required(0); - let remainder_contributors = vec![EVALUATOR_1, BIDDER_3, BUYER_4, BUYER_6, BIDDER_6]; + let _remainder_contributors = vec![EVALUATOR_1, BIDDER_3, BUYER_4, BUYER_6, BIDDER_6]; let desired_total_usd_amount_bid = automatic_fail_funding_percent * project_metadata.minimum_price.saturating_mul_int(bid_allocation); @@ -3719,7 +3719,7 @@ mod remainder_round_failure { vec![bidder_plmc_bonds, community_contributor_plmc_bonds, evaluators_and_contributors_plmc_bonds], MergeOperation::Add, ); - expected_final_plmc_balances.iter_mut().for_each(|UserToPLMCBalance { account, plmc_amount }| { + expected_final_plmc_balances.iter_mut().for_each(|UserToPLMCBalance { account: _, plmc_amount }| { *plmc_amount += deposit_required; }); @@ -5319,7 +5319,7 @@ mod funding_end { println!("account {:?} has evaluation hold {:?}", payout.account, evaluation_hold); println!("account {:?} has participation hold {:?}", payout.account, participation_hold); } - let deposit_required = <::ContributionTokenCurrency as AccountTouch< + let _deposit_required = <::ContributionTokenCurrency as AccountTouch< ProjectIdOf, AccountIdOf, >>::deposit_required(project_id); @@ -5460,7 +5460,7 @@ mod funding_end { use std::time::Instant; for i in 0..10 { let now = Instant::now(); - let project_id = inst.create_finished_project( + let _project_id = inst.create_finished_project( default_project(inst.get_new_nonce(), ISSUER), ISSUER, evaluations.clone(), From 99f0c87afc0346a056ad8d4216f3400b6c4a3cd7 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 13 Dec 2023 13:41:01 +0100 Subject: [PATCH 070/212] remove unnecessary time advancement in project creation --- pallets/funding/src/instantiator.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index d52302382..eeff9761b 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -843,7 +843,6 @@ impl< log::trace!("Last project metadata: {:?}", last_project_metadata); }); - self.advance_time(10u32.into()).unwrap(); let created_project_id = self.execute(|| NextProjectId::::get().saturating_sub(One::one())); self.creation_assertions(created_project_id, project_metadata, now); created_project_id @@ -1365,6 +1364,33 @@ impl< } } } +// +// // async instantiations for parallel testing +// impl< +// T: Config + pallet_balances::Config>, +// AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, +// RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, +// > Instantiator +// { +// pub async fn create_new_project( +// &mut self, +// project_metadata: ProjectMetadataOf, +// issuer: AccountIdOf, +// ) -> ProjectIdOf { +// let now = self.current_block(); +// self.mint_plmc_to(vec![UserToPLMCBalance::new(issuer.clone(), Self::get_ed())]); +// self.execute(|| { +// crate::Pallet::::do_create(&issuer, project_metadata.clone()).unwrap(); +// let last_project_metadata = ProjectsMetadata::::iter().last().unwrap(); +// log::trace!("Last project metadata: {:?}", last_project_metadata); +// }); +// +// self.advance_time(10u32.into()).unwrap(); +// let created_project_id = self.execute(|| NextProjectId::::get().saturating_sub(One::one())); +// self.creation_assertions(created_project_id, project_metadata, now); +// created_project_id +// } +// } pub trait Accounts { type Account; From 8b21bb28d025c0e3eb0fbc821d5703c027b7c86d Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 13 Dec 2023 16:44:07 +0100 Subject: [PATCH 071/212] MVP! --- Cargo.lock | 2 + pallets/funding/Cargo.toml | 5 + pallets/funding/src/instantiator.rs | 400 ++++++++++++++++++++++++++-- pallets/funding/src/tests.rs | 64 +++++ pallets/funding/src/types.rs | 2 +- 5 files changed, 445 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 05751671c..3a6630b6f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6073,6 +6073,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "futures", "itertools 0.11.0", "log", "pallet-assets", @@ -6096,6 +6097,7 @@ dependencies = [ "sp-io", "sp-runtime", "sp-std", + "tokio", "xcm", "xcm-builder", "xcm-executor", diff --git a/pallets/funding/Cargo.toml b/pallets/funding/Cargo.toml index 138d8ca29..57e572d71 100644 --- a/pallets/funding/Cargo.toml +++ b/pallets/funding/Cargo.toml @@ -18,6 +18,9 @@ parity-scale-codec = { version = "3.6.5", features = [ scale-info = { version = "2.9.0", default-features = false, features = [ "derive", ] } +tokio = { version = "1", features = ["full"], optional = true } +futures = { version = "0.3.29", optional = true } + log.workspace = true itertools.workspace = true @@ -83,6 +86,8 @@ std = [ "xcm-builder/std", "xcm-executor/std", "xcm/std", + "tokio", + "futures", ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index eeff9761b..0585ebccd 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -1364,33 +1364,379 @@ impl< } } } -// -// // async instantiations for parallel testing -// impl< -// T: Config + pallet_balances::Config>, -// AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, -// RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, -// > Instantiator -// { -// pub async fn create_new_project( -// &mut self, -// project_metadata: ProjectMetadataOf, -// issuer: AccountIdOf, -// ) -> ProjectIdOf { -// let now = self.current_block(); -// self.mint_plmc_to(vec![UserToPLMCBalance::new(issuer.clone(), Self::get_ed())]); -// self.execute(|| { -// crate::Pallet::::do_create(&issuer, project_metadata.clone()).unwrap(); -// let last_project_metadata = ProjectsMetadata::::iter().last().unwrap(); -// log::trace!("Last project metadata: {:?}", last_project_metadata); -// }); -// -// self.advance_time(10u32.into()).unwrap(); -// let created_project_id = self.execute(|| NextProjectId::::get().saturating_sub(One::one())); -// self.creation_assertions(created_project_id, project_metadata, now); -// created_project_id -// } -// } + +#[cfg(feature = "std")] +pub mod async_features { + use super::*; + use std::{ + collections::HashMap, + sync::{ + atomic::{AtomicBool, AtomicU32, Ordering}, + Arc, + }, + time::Duration, + }; + use tokio::{ + sync::{Mutex, Notify}, + time::sleep, + }; + + pub struct BlockOrchestrator { + pub current_block: Arc, + // used for resuming execution of a project that is waiting for a certain block to be reached + pub awaiting_projects: Mutex, Vec>>>, + pub should_continue: Arc, + pub instantiator_phantom: PhantomData<(T, AllPalletsWithoutSystem, RuntimeEvent)>, + } + pub async fn block_controller< + T: Config + pallet_balances::Config>, + AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, + RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, + >( + block_orchestrator: Arc>, + instantiator: Arc>>, + ) { + loop { + if !block_orchestrator.continue_running() { + break + } + + let has_targets = block_orchestrator.advance_to_next_target(instantiator.clone()).await; + + if has_targets { + block_orchestrator.execute_callbacks().await; + } + // leaves some time for the projects to submit their targets to the orchestrator + sleep(Duration::from_millis(100)).await; + } + } + + impl< + T: Config + pallet_balances::Config>, + AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, + RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, + > BlockOrchestrator + { + pub fn new() -> Self { + BlockOrchestrator:: { + current_block: Arc::new(AtomicU32::new(0)), + awaiting_projects: Mutex::new(HashMap::new()), + should_continue: Arc::new(AtomicBool::new(true)), + instantiator_phantom: PhantomData, + } + } + + pub async fn add_awaiting_project(&self, block_number: BlockNumberFor, notify: Arc) { + let mut awaiting_projects = self.awaiting_projects.lock().await; + awaiting_projects.entry(block_number).or_default().push(notify); + } + + pub async fn advance_to_next_target( + &self, + instantiator: Arc>>, + ) -> bool { + let awaiting_projects = self.awaiting_projects.lock().await; + if let Some(&next_block) = awaiting_projects.keys().min() { + // drop(awaiting_projects); // Drop the lock before sleeping + while self.get_current_block() < next_block { + let mut inst = instantiator.lock().await; + inst.advance_time(One::one()).unwrap(); + self.current_block.fetch_add(1, Ordering::SeqCst); + + println!("Advanced to block {}", self.get_current_block()); + } + true + } else { + false + } + } + + pub async fn execute_callbacks(&self) { + let mut awaiting_projects = self.awaiting_projects.lock().await; + if let Some(notifies) = awaiting_projects.remove(&self.get_current_block()) { + for notify in notifies { + notify.notify_one(); + } + } + } + + pub async fn is_empty(&self) -> bool { + self.awaiting_projects.lock().await.is_empty() + } + + // Method to check if the loop should continue + pub fn continue_running(&self) -> bool { + self.should_continue.load(Ordering::SeqCst) + } + + // Method to get the current block number + pub fn get_current_block(&self) -> BlockNumberFor { + self.current_block.load(Ordering::SeqCst).into() + } + } + + // async instantiations for parallel testing + pub async fn async_create_new_project< + T: Config + pallet_balances::Config>, + AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, + RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, + >( + instantiator: Arc>>, + project_metadata: ProjectMetadataOf, + issuer: AccountIdOf, + ) -> ProjectIdOf { + let mut inst = instantiator.lock().await; + let now = inst.current_block(); + inst.mint_plmc_to(vec![UserToPLMCBalance::new(issuer.clone(), Instantiator::::get_ed())]); + inst.execute(|| { + crate::Pallet::::do_create(&issuer, project_metadata.clone()).unwrap(); + let last_project_metadata = ProjectsMetadata::::iter().last().unwrap(); + log::trace!("Last project metadata: {:?}", last_project_metadata); + }); + + let created_project_id = inst.execute(|| NextProjectId::::get().saturating_sub(One::one())); + inst.creation_assertions(created_project_id, project_metadata, now); + created_project_id + } + + pub async fn async_create_evaluating_project< + T: Config + pallet_balances::Config>, + AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, + RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, + >( + instantiator: Arc>>, + project_metadata: ProjectMetadataOf, + issuer: AccountIdOf, + ) -> ProjectIdOf { + let mut inst = instantiator.lock().await; + let project_id = inst.create_new_project(project_metadata, issuer.clone()); + inst.start_evaluation(project_id, issuer).unwrap(); + project_id + } + + pub async fn async_start_auction< + T: Config + pallet_balances::Config>, + AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, + RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, + >( + instantiator: Arc>>, + block_orchestrator: Arc>, + project_id: ProjectIdOf, + caller: AccountIdOf, + ) -> Result<(), DispatchError> { + let mut inst = instantiator.lock().await; + + let project_details = inst.get_project_details(project_id); + + if project_details.status == ProjectStatus::EvaluationRound { + let evaluation_end = project_details.phase_transition_points.evaluation.end().unwrap(); + let auction_start = evaluation_end.saturating_add(2u32.into()); + + let notify = Arc::new(Notify::new()); + block_orchestrator.add_awaiting_project(auction_start, notify.clone()).await; + // Wait for the notification that our desired block was reached to continue + drop(inst); + notify.notified().await; + inst = instantiator.lock().await; + }; + + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AuctionInitializePeriod); + + inst.execute(|| crate::Pallet::::do_english_auction(caller, project_id))?; + + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AuctionRound(AuctionPhase::English)); + + Ok(()) + } + + pub async fn async_create_auctioning_project< + T: Config + pallet_balances::Config>, + AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, + RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, + >( + instantiator: Arc>>, + block_orchestrator: Arc>, + project_metadata: ProjectMetadataOf, + issuer: AccountIdOf, + evaluations: Vec>, + ) -> ProjectIdOf { + let mut inst = instantiator.lock().await; + let project_id = inst.create_evaluating_project(project_metadata, issuer.clone()); + + let evaluators = evaluations.accounts(); + let prev_supply = inst.get_plmc_total_supply(); + let prev_plmc_balances = inst.get_free_plmc_balances_for(evaluators.clone()); + + let plmc_eval_deposits: Vec> = Instantiator::::calculate_evaluation_plmc_spent(evaluations.clone()); + let plmc_existential_deposits: Vec> = evaluators.existential_deposits(); + let plmc_ct_account_deposits: Vec> = evaluators.ct_account_deposits(); + + let expected_remaining_plmc: Vec> = Instantiator::::generic_map_operation( + vec![prev_plmc_balances, plmc_existential_deposits.clone()], + MergeOperation::Add, + ); + + inst.mint_plmc_to(plmc_eval_deposits.clone()); + inst.mint_plmc_to(plmc_existential_deposits.clone()); + inst.mint_plmc_to(plmc_ct_account_deposits.clone()); + + inst.bond_for_users(project_id, evaluations).unwrap(); + + let expected_evaluator_balances = Instantiator::::sum_balance_mappings(vec![ + plmc_eval_deposits.clone(), + plmc_existential_deposits.clone(), + plmc_ct_account_deposits, + ]); + + let expected_total_supply = prev_supply + expected_evaluator_balances; + + inst.evaluation_assertions(project_id, expected_remaining_plmc, plmc_eval_deposits, expected_total_supply); + drop(inst); + async_start_auction(instantiator, block_orchestrator, project_id, issuer).await.unwrap(); + project_id + } + + pub async fn async_start_community_funding< + T: Config + pallet_balances::Config>, + AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, + RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, + >( + instantiator: Arc>>, + block_orchestrator: Arc>, + project_id: ProjectIdOf, + ) -> Result<(), DispatchError> { + let mut inst = instantiator.lock().await; + let english_end = inst + .get_project_details(project_id) + .phase_transition_points + .english_auction + .end() + .expect("English end point should exist"); + + let candle_start = english_end + 2u32.into(); + + let notify = Arc::new(Notify::new()); + block_orchestrator.add_awaiting_project(candle_start, notify.clone()).await; + // Wait for the notification that our desired block was reached to continue + notify.notified().await; + + let candle_end = inst + .get_project_details(project_id) + .phase_transition_points + .candle_auction + .end() + .expect("Candle end point should exist"); + + let community_start = candle_end + 2u32.into(); + + let notify = Arc::new(Notify::new()); + block_orchestrator.add_awaiting_project(community_start, notify.clone()).await; + // Wait for the notification that our desired block was reached to continue + notify.notified().await; + + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::CommunityRound); + + Ok(()) + } + + pub async fn async_create_community_contributing_project< + T: Config + pallet_balances::Config>, + AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, + RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, + >( + instantiator: Arc>>, + block_orchestrator: Arc>, + project_metadata: ProjectMetadataOf, + issuer: AccountIdOf, + evaluations: Vec>, + bids: Vec>, + ) -> (ProjectIdOf, Vec>) { + if bids.is_empty() { + panic!("Cannot start community funding without bids") + } + let mut inst = instantiator.lock().await; + let project_id = inst.create_auctioning_project(project_metadata.clone(), issuer, evaluations.clone()); + let bids = inst.simulate_bids_with_bucket(bids, project_id); + let bidders = bids.accounts(); + let bidders_non_evaluators = + bidders.clone().into_iter().filter(|account| evaluations.accounts().contains(account).not()).collect_vec(); + let asset_id = bids[0].asset.to_statemint_id(); + let prev_plmc_balances = inst.get_free_plmc_balances_for(bidders.clone()); + let prev_funding_asset_balances = inst.get_free_statemint_asset_balances_for(asset_id, bidders.clone()); + let plmc_evaluation_deposits: Vec> = Instantiator::::calculate_evaluation_plmc_spent(evaluations); + let plmc_bid_deposits: Vec> = Instantiator::::calculate_auction_plmc_spent(&bids, None); + let participation_usable_evaluation_deposits = plmc_evaluation_deposits + .into_iter() + .map(|mut x| { + x.plmc_amount = x.plmc_amount.saturating_sub(::EvaluatorSlash::get() * x.plmc_amount); + x + }) + .collect::>>(); + let necessary_plmc_mint = Instantiator::::generic_map_operation( + vec![plmc_bid_deposits.clone(), participation_usable_evaluation_deposits], + MergeOperation::Subtract, + ); + let total_plmc_participation_locked = plmc_bid_deposits; + let plmc_existential_deposits: Vec> = bidders.existential_deposits(); + let plmc_ct_account_deposits: Vec> = bidders_non_evaluators.ct_account_deposits(); + let funding_asset_deposits = Instantiator::::calculate_auction_funding_asset_spent(&bids, None); + + let bidder_balances = Instantiator::::sum_balance_mappings(vec![ + necessary_plmc_mint.clone(), + plmc_existential_deposits.clone(), + plmc_ct_account_deposits.clone(), + ]); + + let expected_free_plmc_balances = Instantiator::::generic_map_operation( + vec![prev_plmc_balances, plmc_existential_deposits.clone()], + MergeOperation::Add, + ); + + let prev_supply = inst.get_plmc_total_supply(); + let post_supply = prev_supply + bidder_balances; + + inst.mint_plmc_to(necessary_plmc_mint.clone()); + inst.mint_plmc_to(plmc_existential_deposits.clone()); + inst.mint_plmc_to(plmc_ct_account_deposits.clone()); + inst.mint_statemint_asset_to(funding_asset_deposits.clone()); + + inst.bid_for_users(project_id, bids.clone()).expect("Bidding should work"); + + inst.do_reserved_plmc_assertions( + total_plmc_participation_locked.merge_accounts(MergeOperation::Add), + LockType::Participation(project_id), + ); + inst.do_bid_transferred_statemint_asset_assertions( + funding_asset_deposits.merge_accounts(MergeOperation::Add), + project_id, + ); + inst.do_free_plmc_assertions(expected_free_plmc_balances.merge_accounts(MergeOperation::Add)); + inst.do_free_statemint_asset_assertions(prev_funding_asset_balances.merge_accounts(MergeOperation::Add)); + assert_eq!(inst.get_plmc_total_supply(), post_supply); + + drop(inst); + async_start_community_funding(instantiator.clone(), block_orchestrator, project_id).await.unwrap(); + let mut inst = instantiator.lock().await; + + let weighted_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); + let accepted_bids = Instantiator::::filter_bids_after_auction(bids, project_metadata.total_allocation_size.0); + let bid_expectations = accepted_bids + .iter() + .map(|bid| BidInfoFilter:: { + bidder: Some(bid.bidder.clone()), + final_ct_amount: Some(bid.amount), + final_ct_usd_price: Some(if bid.price < weighted_price { bid.price } else { weighted_price }), + ..Default::default() + }) + .collect_vec(); + + let total_ct_sold = accepted_bids.iter().map(|bid| bid.amount).fold(Zero::zero(), |acc, item| item + acc); + + inst.finalized_bids_assertions(project_id, bid_expectations, total_ct_sold); + + (project_id, accepted_bids) + } +} pub trait Accounts { type Account; diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index fb6965bd9..85e46d266 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -5846,3 +5846,67 @@ mod misc_features { assert!(true); } } + +mod async_tests { + use super::*; + use core::sync::atomic::Ordering; + use futures::FutureExt; + use instantiator::async_features::*; + use sp_std::sync::Arc; + use tokio::{ + runtime::Runtime, + sync::{Mutex, Notify}, + }; + + #[test] + fn sandbox() { + let tokio_runtime = Runtime::new().unwrap(); + let inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + + let inst = tokio_runtime.block_on(async { + let block_orchestrator = Arc::new(BlockOrchestrator::new()); + let mutex_inst = Arc::new(Mutex::new(inst)); + + let controller_handle = tokio::spawn(block_controller(block_orchestrator.clone(), mutex_inst.clone())); + + let project_creations = vec![ + async_create_new_project(mutex_inst.clone(), default_project(0, ISSUER), ISSUER).boxed(), + async_create_evaluating_project(mutex_inst.clone(), default_project(1, ISSUER), ISSUER).boxed(), + async_create_auctioning_project( + mutex_inst.clone(), + block_orchestrator.clone(), + default_project(2, ISSUER), + ISSUER, + default_evaluations(), + ) + .boxed(), + // async_create_community_contributing_project( + // mutex_inst, + // block_orchestrator.clone(), + // default_project(inst.get_new_nonce(), ISSUER), + // ISSUER, + // default_evaluations(), + // default_bids(), + // ) + // .boxed(), + ]; + // Wait for all project creation tasks to complete + futures::future::join_all(project_creations).await; + + // Now that all projects have been set up, signal the block_controller to stop + block_orchestrator.should_continue.store(false, Ordering::SeqCst); + + // Wait for the block controller to finish + controller_handle.await.unwrap(); + + let mut inst = mutex_inst.lock().await; + let events = inst.execute(|| {frame_system::Pallet::::events()}); + dbg!(inst.get_project_details(0)); + dbg!(inst.get_project_details(1)); + dbg!(inst.get_project_details(2)); + + }); + + + } +} diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index f92b91a57..aa730157a 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -834,4 +834,4 @@ impl MigrationGenerator { let migration_info: MigrationInfo = (contribution.ct_amount.into(), vesting_duration_local_type.into()).into(); Some(Migration::new(migration_origin, migration_info)) } -} \ No newline at end of file +} From 797c3ed0624280ec4c330bc6293e94a6993a1249 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 14 Dec 2023 10:09:12 +0100 Subject: [PATCH 072/212] multiple community projects can be parallelized --- pallets/funding/src/instantiator.rs | 122 ++++++++++++++++++++++------ pallets/funding/src/mock.rs | 14 ++-- pallets/funding/src/tests.rs | 62 ++++++++++---- 3 files changed, 148 insertions(+), 50 deletions(-) diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 0585ebccd..da6a5d2f1 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -1427,8 +1427,11 @@ pub mod async_features { } pub async fn add_awaiting_project(&self, block_number: BlockNumberFor, notify: Arc) { + println!("add_awaiting_project requesting lock"); let mut awaiting_projects = self.awaiting_projects.lock().await; + println!("add_awaiting_project lock given"); awaiting_projects.entry(block_number).or_default().push(notify); + drop(awaiting_projects); } pub async fn advance_to_next_target( @@ -1437,13 +1440,14 @@ pub mod async_features { ) -> bool { let awaiting_projects = self.awaiting_projects.lock().await; if let Some(&next_block) = awaiting_projects.keys().min() { - // drop(awaiting_projects); // Drop the lock before sleeping + drop(awaiting_projects); while self.get_current_block() < next_block { let mut inst = instantiator.lock().await; inst.advance_time(One::one()).unwrap(); - self.current_block.fetch_add(1, Ordering::SeqCst); + let now = inst.current_block().try_into().unwrap_or_else(|_|panic!("Block number should fit into u32")); + self.current_block.store(now, Ordering::SeqCst); - println!("Advanced to block {}", self.get_current_block()); + println!("Advanced to block {}", now); } true } else { @@ -1485,9 +1489,14 @@ pub mod async_features { project_metadata: ProjectMetadataOf, issuer: AccountIdOf, ) -> ProjectIdOf { + println!("async_create_new_project requesting lock"); let mut inst = instantiator.lock().await; + println!("async_create_new_project lock given"); let now = inst.current_block(); - inst.mint_plmc_to(vec![UserToPLMCBalance::new(issuer.clone(), Instantiator::::get_ed())]); + inst.mint_plmc_to(vec![UserToPLMCBalance::new( + issuer.clone(), + Instantiator::::get_ed(), + )]); inst.execute(|| { crate::Pallet::::do_create(&issuer, project_metadata.clone()).unwrap(); let last_project_metadata = ProjectsMetadata::::iter().last().unwrap(); @@ -1508,8 +1517,12 @@ pub mod async_features { project_metadata: ProjectMetadataOf, issuer: AccountIdOf, ) -> ProjectIdOf { + println!("create new project inside evaluating"); + let project_id = async_create_new_project(instantiator.clone(), project_metadata, issuer.clone()).await; + println!("done"); + println!("async_create_evaluating_project requesting lock"); let mut inst = instantiator.lock().await; - let project_id = inst.create_new_project(project_metadata, issuer.clone()); + println!("async_create_evaluating_project lock given"); inst.start_evaluation(project_id, issuer).unwrap(); project_id } @@ -1524,7 +1537,9 @@ pub mod async_features { project_id: ProjectIdOf, caller: AccountIdOf, ) -> Result<(), DispatchError> { + println!("async_start_auction requesting lock"); let mut inst = instantiator.lock().await; + println!("async_start_auction lock given"); let project_details = inst.get_project_details(project_id); @@ -1533,13 +1548,23 @@ pub mod async_features { let auction_start = evaluation_end.saturating_add(2u32.into()); let notify = Arc::new(Notify::new()); + println!("async_start_auction adding to awaiting projects"); block_orchestrator.add_awaiting_project(auction_start, notify.clone()).await; + println!("async_start_auction awaiting projects added"); // Wait for the notification that our desired block was reached to continue + + println!("async_start_auction dropping lock"); drop(inst); + println!("async_start_auction lock dropped"); + println!("async_start_auction awaiting notification"); notify.notified().await; + println!("async_start_auction notification received"); + println!("async_start_auction requesting lock"); inst = instantiator.lock().await; + println!("async_start_auction lock given"); }; + println!("async_start_auction getting details"); assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AuctionInitializePeriod); inst.execute(|| crate::Pallet::::do_english_auction(caller, project_id))?; @@ -1560,21 +1585,27 @@ pub mod async_features { issuer: AccountIdOf, evaluations: Vec>, ) -> ProjectIdOf { + println!("creating evaluating project inside auctioning"); + let project_id = async_create_evaluating_project(instantiator.clone(), project_metadata, issuer.clone()).await; + println!("async_create_auctioning_project requesting lock"); let mut inst = instantiator.lock().await; - let project_id = inst.create_evaluating_project(project_metadata, issuer.clone()); - + println!("async_create_auctioning_project lock given"); let evaluators = evaluations.accounts(); let prev_supply = inst.get_plmc_total_supply(); let prev_plmc_balances = inst.get_free_plmc_balances_for(evaluators.clone()); - let plmc_eval_deposits: Vec> = Instantiator::::calculate_evaluation_plmc_spent(evaluations.clone()); + let plmc_eval_deposits: Vec> = + Instantiator::::calculate_evaluation_plmc_spent( + evaluations.clone(), + ); let plmc_existential_deposits: Vec> = evaluators.existential_deposits(); let plmc_ct_account_deposits: Vec> = evaluators.ct_account_deposits(); - let expected_remaining_plmc: Vec> = Instantiator::::generic_map_operation( - vec![prev_plmc_balances, plmc_existential_deposits.clone()], - MergeOperation::Add, - ); + let expected_remaining_plmc: Vec> = + Instantiator::::generic_map_operation( + vec![prev_plmc_balances, plmc_existential_deposits.clone()], + MergeOperation::Add, + ); inst.mint_plmc_to(plmc_eval_deposits.clone()); inst.mint_plmc_to(plmc_existential_deposits.clone()); @@ -1582,16 +1613,20 @@ pub mod async_features { inst.bond_for_users(project_id, evaluations).unwrap(); - let expected_evaluator_balances = Instantiator::::sum_balance_mappings(vec![ - plmc_eval_deposits.clone(), - plmc_existential_deposits.clone(), - plmc_ct_account_deposits, - ]); + let expected_evaluator_balances = + Instantiator::::sum_balance_mappings(vec![ + plmc_eval_deposits.clone(), + plmc_existential_deposits.clone(), + plmc_ct_account_deposits, + ]); let expected_total_supply = prev_supply + expected_evaluator_balances; inst.evaluation_assertions(project_id, expected_remaining_plmc, plmc_eval_deposits, expected_total_supply); + println!("async_create_auctioning_project dropping lock"); drop(inst); + println!("async_create_auctioning_project lock dropped"); + println!("async_create_auctioning_project awaiting start auction"); async_start_auction(instantiator, block_orchestrator, project_id, issuer).await.unwrap(); project_id } @@ -1605,7 +1640,10 @@ pub mod async_features { block_orchestrator: Arc>, project_id: ProjectIdOf, ) -> Result<(), DispatchError> { + println!("async_start_community_funding requesting lock"); let mut inst = instantiator.lock().await; + println!("async_start_community_funding lock given"); + let english_end = inst .get_project_details(project_id) .phase_transition_points @@ -1616,10 +1654,18 @@ pub mod async_features { let candle_start = english_end + 2u32.into(); let notify = Arc::new(Notify::new()); + println!("async_start_community_funding adding to awaiting projects"); block_orchestrator.add_awaiting_project(candle_start, notify.clone()).await; + println!("async_start_community_funding awaiting projects added"); // Wait for the notification that our desired block was reached to continue + println!("async_start_community_funding dropping lock"); + drop(inst); + println!("async_start_community_funding lock dropped"); + println!("async_start_community_funding awaiting notification"); notify.notified().await; - + println!("async_start_community_funding notification received"); + println!("async_start_community_funding requesting lock"); + inst = instantiator.lock().await; let candle_end = inst .get_project_details(project_id) .phase_transition_points @@ -1630,9 +1676,19 @@ pub mod async_features { let community_start = candle_end + 2u32.into(); let notify = Arc::new(Notify::new()); + println!("async_start_community_funding adding to awaiting projects"); block_orchestrator.add_awaiting_project(community_start, notify.clone()).await; // Wait for the notification that our desired block was reached to continue + println!("async_start_community_funding dropping lock"); + drop(inst); + println!("async_start_community_funding lock dropped"); + println!("async_start_community_funding awaiting notification"); notify.notified().await; + println!("async_start_community_funding notification received"); + + println!("async_start_community_funding requesting lock"); + inst = instantiator.lock().await; + println!("async_start_community_funding lock given"); assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::CommunityRound); @@ -1654,8 +1710,11 @@ pub mod async_features { if bids.is_empty() { panic!("Cannot start community funding without bids") } + println!("creating auctioning project inside community project"); + let project_id = async_create_auctioning_project(instantiator.clone(), block_orchestrator.clone(), project_metadata.clone(), issuer, evaluations.clone()).await; + println!("requesting inst lock"); let mut inst = instantiator.lock().await; - let project_id = inst.create_auctioning_project(project_metadata.clone(), issuer, evaluations.clone()); + println!("lock given"); let bids = inst.simulate_bids_with_bucket(bids, project_id); let bidders = bids.accounts(); let bidders_non_evaluators = @@ -1663,8 +1722,10 @@ pub mod async_features { let asset_id = bids[0].asset.to_statemint_id(); let prev_plmc_balances = inst.get_free_plmc_balances_for(bidders.clone()); let prev_funding_asset_balances = inst.get_free_statemint_asset_balances_for(asset_id, bidders.clone()); - let plmc_evaluation_deposits: Vec> = Instantiator::::calculate_evaluation_plmc_spent(evaluations); - let plmc_bid_deposits: Vec> = Instantiator::::calculate_auction_plmc_spent(&bids, None); + let plmc_evaluation_deposits: Vec> = + Instantiator::::calculate_evaluation_plmc_spent(evaluations); + let plmc_bid_deposits: Vec> = + Instantiator::::calculate_auction_plmc_spent(&bids, None); let participation_usable_evaluation_deposits = plmc_evaluation_deposits .into_iter() .map(|mut x| { @@ -1679,7 +1740,10 @@ pub mod async_features { let total_plmc_participation_locked = plmc_bid_deposits; let plmc_existential_deposits: Vec> = bidders.existential_deposits(); let plmc_ct_account_deposits: Vec> = bidders_non_evaluators.ct_account_deposits(); - let funding_asset_deposits = Instantiator::::calculate_auction_funding_asset_spent(&bids, None); + let funding_asset_deposits = + Instantiator::::calculate_auction_funding_asset_spent( + &bids, None, + ); let bidder_balances = Instantiator::::sum_balance_mappings(vec![ necessary_plmc_mint.clone(), @@ -1687,10 +1751,11 @@ pub mod async_features { plmc_ct_account_deposits.clone(), ]); - let expected_free_plmc_balances = Instantiator::::generic_map_operation( - vec![prev_plmc_balances, plmc_existential_deposits.clone()], - MergeOperation::Add, - ); + let expected_free_plmc_balances = + Instantiator::::generic_map_operation( + vec![prev_plmc_balances, plmc_existential_deposits.clone()], + MergeOperation::Add, + ); let prev_supply = inst.get_plmc_total_supply(); let post_supply = prev_supply + bidder_balances; @@ -1719,7 +1784,10 @@ pub mod async_features { let mut inst = instantiator.lock().await; let weighted_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); - let accepted_bids = Instantiator::::filter_bids_after_auction(bids, project_metadata.total_allocation_size.0); + let accepted_bids = Instantiator::::filter_bids_after_auction( + bids, + project_metadata.total_allocation_size.0, + ); let bid_expectations = accepted_bids .iter() .map(|bid| BidInfoFilter:: { diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index d23d4e095..7734dcd70 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -266,15 +266,15 @@ pub const HOURS: BlockNumber = 300u64; // REMARK: In the production configuration we use DAYS instead of HOURS. parameter_types! { - pub const EvaluationDuration: BlockNumber = (28 * HOURS) as BlockNumber; - pub const AuctionInitializePeriodDuration: BlockNumber = (7 * HOURS) as BlockNumber; - pub const EnglishAuctionDuration: BlockNumber = (2 * HOURS) as BlockNumber; - pub const CandleAuctionDuration: BlockNumber = (3 * HOURS) as BlockNumber; - pub const CommunityRoundDuration: BlockNumber = (5 * HOURS) as BlockNumber; + pub const EvaluationDuration: BlockNumber = (28) as BlockNumber; + pub const AuctionInitializePeriodDuration: BlockNumber = (7) as BlockNumber; + pub const EnglishAuctionDuration: BlockNumber = (2) as BlockNumber; + pub const CandleAuctionDuration: BlockNumber = (3) as BlockNumber; + pub const CommunityRoundDuration: BlockNumber = (5) as BlockNumber; pub const RemainderFundingDuration: BlockNumber = HOURS as BlockNumber; pub const FundingPalletId: PalletId = PalletId(*b"py/cfund"); - pub const ManualAcceptanceDuration: BlockNumber = (3 * HOURS) as BlockNumber; - pub const SuccessToSettlementTime: BlockNumber =(4 * HOURS) as BlockNumber; + pub const ManualAcceptanceDuration: BlockNumber = (3) as BlockNumber; + pub const SuccessToSettlementTime: BlockNumber =(4) as BlockNumber; pub PriceMap: BTreeMap = BTreeMap::from_iter(vec![ (0u32, FixedU128::from_float(69f64)), // DOT (420u32, FixedU128::from_float(0.97f64)), // USDC diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 85e46d266..4b40a3442 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -5870,25 +5870,58 @@ mod async_tests { let controller_handle = tokio::spawn(block_controller(block_orchestrator.clone(), mutex_inst.clone())); let project_creations = vec![ - async_create_new_project(mutex_inst.clone(), default_project(0, ISSUER), ISSUER).boxed(), - async_create_evaluating_project(mutex_inst.clone(), default_project(1, ISSUER), ISSUER).boxed(), - async_create_auctioning_project( - mutex_inst.clone(), - block_orchestrator.clone(), - default_project(2, ISSUER), - ISSUER, - default_evaluations(), - ) - .boxed(), + // async_create_new_project(mutex_inst.clone(), default_project(0, ISSUER), ISSUER).boxed(), + // async_create_evaluating_project(mutex_inst.clone(), default_project(1, ISSUER), ISSUER).boxed(), + // async_create_auctioning_project( + // mutex_inst.clone(), + // block_orchestrator.clone(), + // default_project(2, ISSUER), + // ISSUER, + // default_evaluations(), + // ) + // .boxed(), // async_create_community_contributing_project( - // mutex_inst, + // mutex_inst.clone(), // block_orchestrator.clone(), - // default_project(inst.get_new_nonce(), ISSUER), + // default_project(3, ISSUER), // ISSUER, // default_evaluations(), // default_bids(), // ) + // .map(|(project_id, _)| project_id) // .boxed(), + // + + async_create_community_contributing_project( + mutex_inst.clone(), + block_orchestrator.clone(), + default_project(0, ISSUER), + ISSUER, + default_evaluations(), + default_bids(), + ) + .map(|(project_id, _)| project_id) + .boxed(), + async_create_community_contributing_project( + mutex_inst.clone(), + block_orchestrator.clone(), + default_project(1, ISSUER), + ISSUER, + default_evaluations(), + default_bids(), + ) + .map(|(project_id, _)| project_id) + .boxed(), + async_create_community_contributing_project( + mutex_inst.clone(), + block_orchestrator.clone(), + default_project(2, ISSUER), + ISSUER, + default_evaluations(), + default_bids(), + ) + .map(|(project_id, _)| project_id) + .boxed(), ]; // Wait for all project creation tasks to complete futures::future::join_all(project_creations).await; @@ -5900,13 +5933,10 @@ mod async_tests { controller_handle.await.unwrap(); let mut inst = mutex_inst.lock().await; - let events = inst.execute(|| {frame_system::Pallet::::events()}); + let events = inst.execute(|| frame_system::Pallet::::events()); dbg!(inst.get_project_details(0)); dbg!(inst.get_project_details(1)); dbg!(inst.get_project_details(2)); - }); - - } } From 963f0278b35a6e8a9a990a43b05f1c7591b8db7f Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 14 Dec 2023 11:29:20 +0100 Subject: [PATCH 073/212] all async creation functions working --- pallets/funding/src/instantiator.rs | 378 +++++++++++++++++++++++++++- pallets/funding/src/tests.rs | 131 +++++++--- 2 files changed, 473 insertions(+), 36 deletions(-) diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index da6a5d2f1..d009ba6a5 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -247,6 +247,7 @@ impl< for UserToPLMCBalance { account, plmc_amount } in correct_funds { self.execute(|| { let free = ::NativeCurrency::balance(&account); + println!("account: {:?}, free: {:?}, plmc_amount: {:?}", account, free, plmc_amount); assert_eq!(free, plmc_amount); }); } @@ -1444,7 +1445,8 @@ pub mod async_features { while self.get_current_block() < next_block { let mut inst = instantiator.lock().await; inst.advance_time(One::one()).unwrap(); - let now = inst.current_block().try_into().unwrap_or_else(|_|panic!("Block number should fit into u32")); + let now = + inst.current_block().try_into().unwrap_or_else(|_| panic!("Block number should fit into u32")); self.current_block.store(now, Ordering::SeqCst); println!("Advanced to block {}", now); @@ -1492,6 +1494,11 @@ pub mod async_features { println!("async_create_new_project requesting lock"); let mut inst = instantiator.lock().await; println!("async_create_new_project lock given"); + let asset_account_deposit = + inst.execute(|| ::ContributionTokenCurrency::deposit_required(One::one())); + let ed = Instantiator::::get_ed(); + dbg!(asset_account_deposit); + dbg!(ed); let now = inst.current_block(); inst.mint_plmc_to(vec![UserToPLMCBalance::new( issuer.clone(), @@ -1711,7 +1718,14 @@ pub mod async_features { panic!("Cannot start community funding without bids") } println!("creating auctioning project inside community project"); - let project_id = async_create_auctioning_project(instantiator.clone(), block_orchestrator.clone(), project_metadata.clone(), issuer, evaluations.clone()).await; + let project_id = async_create_auctioning_project( + instantiator.clone(), + block_orchestrator.clone(), + project_metadata.clone(), + issuer, + evaluations.clone(), + ) + .await; println!("requesting inst lock"); let mut inst = instantiator.lock().await; println!("lock given"); @@ -1804,6 +1818,366 @@ pub mod async_features { (project_id, accepted_bids) } + + pub async fn async_start_remainder_or_end_funding< + T: Config + pallet_balances::Config>, + AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, + RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, + >( + instantiator: Arc>>, + block_orchestrator: Arc>, + project_id: ProjectIdOf, + ) -> Result<(), DispatchError> { + println!("async_start_remainder_or_end_funding requesting lock"); + let mut inst = instantiator.lock().await; + println!("async_start_remainder_or_end_funding lock given"); + + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::CommunityRound); + let community_funding_end = inst + .get_project_details(project_id) + .phase_transition_points + .community + .end() + .expect("Community funding end point should exist"); + let remainder_start = community_funding_end + 1u32.into(); + + let notify = Arc::new(Notify::new()); + println!("async_start_remainder_or_end_funding adding to awaiting projects"); + block_orchestrator.add_awaiting_project(remainder_start, notify.clone()).await; + println!("async_start_remainder_or_end_funding awaiting projects added"); + // Wait for the notification that our desired block was reached to continue + println!("dropping inst lock"); + drop(inst); + println!("inst lock dropped"); + println!("async_start_remainder_or_end_funding awaiting notification"); + notify.notified().await; + println!("async_start_remainder_or_end_funding notification received"); + + println!("async_start_remainder_or_end_funding requesting inst lock"); + let mut inst = instantiator.lock().await; + println!("async_start_remainder_or_end_funding lock given"); + match inst.get_project_details(project_id).status { + ProjectStatus::RemainderRound | ProjectStatus::FundingSuccessful => Ok(()), + _ => panic!("Bad state"), + } + } + + pub async fn async_create_remainder_contributing_project< + T: Config + pallet_balances::Config>, + AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, + RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, + >( + instantiator: Arc>>, + block_orchestrator: Arc>, + project_metadata: ProjectMetadataOf, + issuer: AccountIdOf, + evaluations: Vec>, + bids: Vec>, + contributions: Vec>, + ) -> (ProjectIdOf, Vec>) { + println!("creating community project inside remainder project"); + let (project_id, accepted_bids) = async_create_community_contributing_project( + instantiator.clone(), + block_orchestrator.clone(), + project_metadata, + issuer, + evaluations.clone(), + bids, + ) + .await; + println!("done"); + + if contributions.is_empty() { + async_start_remainder_or_end_funding(instantiator.clone(), block_orchestrator.clone(), project_id) + .await + .unwrap(); + return (project_id, accepted_bids) + } + + println!("requesting inst lock"); + let mut inst = instantiator.lock().await; + println!("lock given"); + + let ct_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); + let contributors = contributions.accounts(); + let contributors_non_evaluators = contributors + .clone() + .into_iter() + .filter(|account| evaluations.accounts().contains(account).not()) + .collect_vec(); + let asset_id = contributions[0].asset.to_statemint_id(); + let prev_plmc_balances = inst.get_free_plmc_balances_for(contributors.clone()); + let prev_funding_asset_balances = inst.get_free_statemint_asset_balances_for(asset_id, contributors.clone()); + + let plmc_evaluation_deposits = + Instantiator::::calculate_evaluation_plmc_spent(evaluations); + let plmc_bid_deposits = Instantiator::::calculate_auction_plmc_spent( + &accepted_bids, + Some(ct_price), + ); + + let plmc_contribution_deposits = + Instantiator::::calculate_contributed_plmc_spent( + contributions.clone(), + ct_price, + ); + + let necessary_plmc_mint = Instantiator::::generic_map_operation( + vec![plmc_contribution_deposits.clone(), plmc_evaluation_deposits], + MergeOperation::Subtract, + ); + let total_plmc_participation_locked = + Instantiator::::generic_map_operation( + vec![plmc_bid_deposits, plmc_contribution_deposits], + MergeOperation::Add, + ); + let plmc_existential_deposits = contributors.existential_deposits(); + let plmc_ct_account_deposits = contributors_non_evaluators.ct_account_deposits(); + + let funding_asset_deposits = + Instantiator::::calculate_contributed_funding_asset_spent( + contributions.clone(), + ct_price, + ); + let contributor_balances = + Instantiator::::sum_balance_mappings(vec![ + necessary_plmc_mint.clone(), + plmc_existential_deposits.clone(), + plmc_ct_account_deposits.clone(), + ]); + + let expected_free_plmc_balances = + Instantiator::::generic_map_operation( + vec![prev_plmc_balances, plmc_existential_deposits.clone()], + MergeOperation::Add, + ); + + let prev_supply = inst.get_plmc_total_supply(); + let post_supply = prev_supply + contributor_balances; + + inst.mint_plmc_to(necessary_plmc_mint.clone()); + inst.mint_plmc_to(plmc_existential_deposits.clone()); + inst.mint_plmc_to(plmc_ct_account_deposits.clone()); + inst.mint_statemint_asset_to(funding_asset_deposits.clone()); + + inst.contribute_for_users(project_id, contributions).expect("Contributing should work"); + + inst.do_reserved_plmc_assertions( + total_plmc_participation_locked.merge_accounts(MergeOperation::Add), + LockType::Participation(project_id), + ); + inst.do_contribution_transferred_statemint_asset_assertions( + funding_asset_deposits.merge_accounts(MergeOperation::Add), + project_id, + ); + inst.do_free_plmc_assertions(expected_free_plmc_balances.merge_accounts(MergeOperation::Add)); + inst.do_free_statemint_asset_assertions(prev_funding_asset_balances.merge_accounts(MergeOperation::Add)); + assert_eq!(inst.get_plmc_total_supply(), post_supply); + drop(inst); + async_start_remainder_or_end_funding(instantiator.clone(), block_orchestrator.clone(), project_id) + .await + .unwrap(); + (project_id, accepted_bids) + } + + pub async fn async_finish_funding< + T: Config + pallet_balances::Config>, + AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, + RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, + >( + instantiator: Arc>>, + block_orchestrator: Arc>, + project_id: ProjectIdOf, + ) -> Result<(), DispatchError> { + println!("async_finish_funding requesting lock"); + let mut inst = instantiator.lock().await; + println!("async_finish_funding lock given"); + + let (update_block, _) = inst.get_update_pair(project_id); + let current_block = inst.current_block(); + inst.advance_time(update_block.saturating_sub(current_block)).unwrap(); + if inst.get_project_details(project_id).status == ProjectStatus::RemainderRound { + let (end_block, _) = inst.get_update_pair(project_id); + drop(inst); + + let notify = Arc::new(Notify::new()); + println!("async_finish_funding adding to awaiting projects"); + block_orchestrator.add_awaiting_project(end_block, notify.clone()).await; + println!("async_finish_funding awaiting projects added"); + // Wait for the notification that our desired block was reached to continue + println!("async_finish_funding awaiting notification"); + notify.notified().await; + println!("async_finish_funding notification received"); + + println!("async_finish_funding requesting lock"); + inst = instantiator.lock().await; + println!("async_finish_funding lock given"); + } + + let project_details = inst.get_project_details(project_id); + assert!( + matches!( + project_details.status, + ProjectStatus::FundingSuccessful | + ProjectStatus::FundingFailed | + ProjectStatus::AwaitingProjectDecision + ), + "Project should be in Finished status" + ); + Ok(()) + } + + pub async fn async_create_finished_project< + T: Config + pallet_balances::Config>, + AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, + RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, + >( + instantiator: Arc>>, + block_orchestrator: Arc>, + project_metadata: ProjectMetadataOf, + issuer: AccountIdOf, + evaluations: Vec>, + bids: Vec>, + community_contributions: Vec>, + remainder_contributions: Vec>, + ) -> ProjectIdOf { + println!("creating remainder project inside finished project"); + let (project_id, accepted_bids) = async_create_remainder_contributing_project( + instantiator.clone(), + block_orchestrator.clone(), + project_metadata.clone(), + issuer, + evaluations.clone(), + bids.clone(), + community_contributions.clone(), + ) + .await; + println!("done"); + + println!("requesting inst lock"); + let mut inst = instantiator.lock().await; + println!("lock given"); + + match inst.get_project_details(project_id).status { + ProjectStatus::FundingSuccessful => return project_id, + ProjectStatus::RemainderRound if remainder_contributions.is_empty() => { + inst.finish_funding(project_id).unwrap(); + return project_id + }, + _ => {}, + }; + + let ct_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); + let contributors = remainder_contributions.accounts(); + let new_contributors = contributors + .clone() + .into_iter() + .filter(|account| { + evaluations.accounts().contains(account).not() && + bids.accounts().contains(account).not() && + community_contributions.accounts().contains(account).not() + }) + .collect_vec(); + let asset_id = remainder_contributions[0].asset.to_statemint_id(); + let prev_plmc_balances = inst.get_free_plmc_balances_for(contributors.clone()); + let prev_funding_asset_balances = inst.get_free_statemint_asset_balances_for(asset_id, contributors.clone()); + + let plmc_evaluation_deposits = + Instantiator::::calculate_evaluation_plmc_spent(evaluations); + let plmc_bid_deposits = Instantiator::::calculate_auction_plmc_spent( + &accepted_bids, + Some(ct_price), + ); + let plmc_community_contribution_deposits = + Instantiator::::calculate_contributed_plmc_spent( + community_contributions.clone(), + ct_price, + ); + let plmc_remainder_contribution_deposits = + Instantiator::::calculate_contributed_plmc_spent( + remainder_contributions.clone(), + ct_price, + ); + + let necessary_plmc_mint = Instantiator::::generic_map_operation( + vec![plmc_remainder_contribution_deposits.clone(), plmc_evaluation_deposits], + MergeOperation::Subtract, + ); + let total_plmc_participation_locked = + Instantiator::::generic_map_operation( + vec![plmc_bid_deposits, plmc_community_contribution_deposits, plmc_remainder_contribution_deposits], + MergeOperation::Add, + ); + let plmc_existential_deposits = contributors.existential_deposits(); + let plmc_ct_account_deposits = new_contributors.ct_account_deposits(); + let funding_asset_deposits = + Instantiator::::calculate_contributed_funding_asset_spent( + remainder_contributions.clone(), + ct_price, + ); + + let contributor_balances = + Instantiator::::sum_balance_mappings(vec![ + necessary_plmc_mint.clone(), + plmc_existential_deposits.clone(), + plmc_ct_account_deposits.clone(), + ]); + + let expected_free_plmc_balances = + Instantiator::::generic_map_operation( + vec![prev_plmc_balances, plmc_existential_deposits.clone()], + MergeOperation::Add, + ); + + let prev_supply = inst.get_plmc_total_supply(); + let post_supply = prev_supply + contributor_balances; + + inst.mint_plmc_to(necessary_plmc_mint.clone()); + inst.mint_plmc_to(plmc_existential_deposits.clone()); + inst.mint_plmc_to(plmc_ct_account_deposits.clone()); + inst.mint_statemint_asset_to(funding_asset_deposits.clone()); + + inst.contribute_for_users(project_id, remainder_contributions.clone()) + .expect("Remainder Contributing should work"); + + inst.do_reserved_plmc_assertions( + total_plmc_participation_locked.merge_accounts(MergeOperation::Add), + LockType::Participation(project_id), + ); + inst.do_contribution_transferred_statemint_asset_assertions( + funding_asset_deposits.merge_accounts(MergeOperation::Add), + project_id, + ); + inst.do_free_plmc_assertions(expected_free_plmc_balances.merge_accounts(MergeOperation::Add)); + inst.do_free_statemint_asset_assertions(prev_funding_asset_balances.merge_accounts(MergeOperation::Add)); + assert_eq!(inst.get_plmc_total_supply(), post_supply); + + drop(inst); + async_finish_funding(instantiator.clone(), block_orchestrator.clone(), project_id).await.unwrap(); + let mut inst = instantiator.lock().await; + + if inst.get_project_details(project_id).status == ProjectStatus::FundingSuccessful { + // Check that remaining CTs are updated + let project_details = inst.get_project_details(project_id); + let auction_bought_tokens = + accepted_bids.iter().map(|bid| bid.amount).fold(Zero::zero(), |acc, item| item + acc); + let community_bought_tokens = + community_contributions.iter().map(|cont| cont.amount).fold(Zero::zero(), |acc, item| item + acc); + let remainder_bought_tokens = + remainder_contributions.iter().map(|cont| cont.amount).fold(Zero::zero(), |acc, item| item + acc); + + assert_eq!( + project_details.remaining_contribution_tokens.0 + project_details.remaining_contribution_tokens.1, + project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1 - + auction_bought_tokens - + community_bought_tokens - + remainder_bought_tokens, + "Remaining CTs are incorrect" + ); + } + + project_id + } } pub trait Accounts { diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 4b40a3442..06d03081d 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -5870,58 +5870,112 @@ mod async_tests { let controller_handle = tokio::spawn(block_controller(block_orchestrator.clone(), mutex_inst.clone())); let project_creations = vec![ - // async_create_new_project(mutex_inst.clone(), default_project(0, ISSUER), ISSUER).boxed(), - // async_create_evaluating_project(mutex_inst.clone(), default_project(1, ISSUER), ISSUER).boxed(), - // async_create_auctioning_project( - // mutex_inst.clone(), - // block_orchestrator.clone(), - // default_project(2, ISSUER), - // ISSUER, - // default_evaluations(), - // ) - // .boxed(), - // async_create_community_contributing_project( - // mutex_inst.clone(), - // block_orchestrator.clone(), - // default_project(3, ISSUER), - // ISSUER, - // default_evaluations(), - // default_bids(), - // ) - // .map(|(project_id, _)| project_id) - // .boxed(), - // - + async_create_new_project(mutex_inst.clone(), default_project(0, ISSUER), ISSUER).boxed(), + async_create_evaluating_project(mutex_inst.clone(), default_project(1, ISSUER), ISSUER).boxed(), + async_create_auctioning_project( + mutex_inst.clone(), + block_orchestrator.clone(), + default_project(2, ISSUER), + ISSUER, + default_evaluations(), + ) + .boxed(), async_create_community_contributing_project( mutex_inst.clone(), block_orchestrator.clone(), - default_project(0, ISSUER), + default_project(3, ISSUER), ISSUER, default_evaluations(), default_bids(), ) - .map(|(project_id, _)| project_id) - .boxed(), + .map(|(project_id, _)| project_id) + .boxed(), async_create_community_contributing_project( mutex_inst.clone(), block_orchestrator.clone(), - default_project(1, ISSUER), + default_project(4, ISSUER), ISSUER, default_evaluations(), default_bids(), ) - .map(|(project_id, _)| project_id) - .boxed(), + .map(|(project_id, _)| project_id) + .boxed(), async_create_community_contributing_project( mutex_inst.clone(), block_orchestrator.clone(), - default_project(2, ISSUER), + default_project(5, ISSUER), + ISSUER, + default_evaluations(), + default_bids(), + ) + .map(|(project_id, _)| project_id) + .boxed(), + async_create_remainder_contributing_project( + mutex_inst.clone(), + block_orchestrator.clone(), + default_project(6, ISSUER), + ISSUER, + default_evaluations(), + default_bids(), + default_community_buys(), + ) + .map(|(project_id, _)| project_id) + .boxed(), + async_create_remainder_contributing_project( + mutex_inst.clone(), + block_orchestrator.clone(), + default_project(7, ISSUER), + ISSUER, + default_evaluations(), + default_bids(), + default_community_buys(), + ) + .map(|(project_id, _)| project_id) + .boxed(), + async_create_remainder_contributing_project( + mutex_inst.clone(), + block_orchestrator.clone(), + default_project(8, ISSUER), + ISSUER, + default_evaluations(), + default_bids(), + default_community_buys(), + ) + .map(|(project_id, _)| project_id) + .boxed(), + async_create_finished_project( + mutex_inst.clone(), + block_orchestrator.clone(), + default_project(9, ISSUER), + ISSUER, + default_evaluations(), + default_bids(), + default_community_buys(), + default_remainder_buys(), + ) + .boxed(), + async_create_finished_project( + mutex_inst.clone(), + block_orchestrator.clone(), + default_project(10, ISSUER), + ISSUER, + default_evaluations(), + default_bids(), + default_community_buys(), + default_remainder_buys(), + ) + .boxed(), + async_create_finished_project( + mutex_inst.clone(), + block_orchestrator.clone(), + default_project(11, ISSUER), ISSUER, default_evaluations(), default_bids(), + default_community_buys(), + default_remainder_buys(), ) - .map(|(project_id, _)| project_id) - .boxed(), + .boxed(), ]; // Wait for all project creation tasks to complete futures::future::join_all(project_creations).await; @@ -5934,9 +5988,18 @@ mod async_tests { let mut inst = mutex_inst.lock().await; let events = inst.execute(|| frame_system::Pallet::::events()); - dbg!(inst.get_project_details(0)); - dbg!(inst.get_project_details(1)); - dbg!(inst.get_project_details(2)); + dbg!(inst.get_project_details(0).status); + dbg!(inst.get_project_details(1).status); + dbg!(inst.get_project_details(2).status); + dbg!(inst.get_project_details(3).status); + dbg!(inst.get_project_details(4).status); + dbg!(inst.get_project_details(5).status); + dbg!(inst.get_project_details(6).status); + dbg!(inst.get_project_details(7).status); + dbg!(inst.get_project_details(8).status); + dbg!(inst.get_project_details(9).status); + dbg!(inst.get_project_details(10).status); + dbg!(inst.get_project_details(11).status); }); } } From aad3f8e83fb0ae4f5b09be2703fbda690c0b8b85 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 14 Dec 2023 13:07:25 +0100 Subject: [PATCH 074/212] bid refund test not passing --- pallets/funding/src/instantiator.rs | 91 +++++++++++++++++++++++++++++ pallets/funding/src/lib.rs | 17 ------ 2 files changed, 91 insertions(+), 17 deletions(-) diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index d009ba6a5..0b2c49a99 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -50,6 +50,23 @@ impl Default for BoxToFunction { BoxToFunction(Box::new(|| ())) } } + +#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr( + feature = "std", + serde(rename_all = "camelCase", deny_unknown_fields, bound(serialize = ""), bound(deserialize = "")) +)] +#[derive(Clone, PartialEq, Eq, Debug, Encode, Decode)] +pub struct TestProjectParams { + pub expected_state: ProjectStatus, + pub metadata: ProjectMetadataOf, + pub issuer: AccountIdOf, + pub evaluations: Vec>, + pub bids: Vec>, + pub community_contributions: Vec>, + pub remainder_contributions: Vec>, +} + pub struct Instantiator< T: Config + pallet_balances::Config>, AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, @@ -1369,6 +1386,7 @@ impl< #[cfg(feature = "std")] pub mod async_features { use super::*; + use futures::FutureExt; use std::{ collections::HashMap, sync::{ @@ -2178,6 +2196,79 @@ pub mod async_features { project_id } + + pub async fn create_project_at< + T: Config + pallet_balances::Config>, + AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, + RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, + >( + instantiator: Arc>>, + block_orchestrator: Arc>, + test_project_params: TestProjectParams, + ) -> ProjectIdOf { + match test_project_params.expected_state { + ProjectStatus::FundingSuccessful => + async_create_finished_project( + instantiator, + block_orchestrator, + test_project_params.metadata, + test_project_params.issuer, + test_project_params.evaluations, + test_project_params.bids, + test_project_params.community_contributions, + test_project_params.remainder_contributions, + ) + .await, + ProjectStatus::RemainderRound => + async_create_remainder_contributing_project( + instantiator, + block_orchestrator, + test_project_params.metadata, + test_project_params.issuer, + test_project_params.evaluations, + test_project_params.bids, + test_project_params.community_contributions, + ) + .map(|(project_id, _)| project_id) + .await, + ProjectStatus::CommunityRound => + async_create_community_contributing_project( + instantiator, + block_orchestrator, + test_project_params.metadata, + test_project_params.issuer, + test_project_params.evaluations, + test_project_params.bids, + ) + .map(|(project_id, _)| project_id) + .await, + ProjectStatus::AuctionRound(AuctionPhase::English) => + async_create_auctioning_project( + instantiator, + block_orchestrator, + test_project_params.metadata, + test_project_params.issuer, + test_project_params.evaluations, + ) + .await, + ProjectStatus::EvaluationRound => + async_create_evaluating_project(instantiator, test_project_params.metadata, test_project_params.issuer) + .await, + ProjectStatus::Application => + async_create_new_project(instantiator, test_project_params.metadata, test_project_params.issuer).await, + _ => panic!("unsupported project creation in that status"), + } + } + + pub async fn create_multiple_projects_at< + T: Config + pallet_balances::Config>, + AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, + RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, + >( + projects: Vec>, + ) { + todo!(); + } } pub trait Accounts { diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index c4d47dc95..dba58d4bb 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1355,23 +1355,6 @@ pub mod pallet { use frame_support::traits::{OnFinalize, OnIdle, OnInitialize, OriginTrait}; use pallet_xcm::ensure_response; - #[cfg(all(feature = "testing-node", feature = "std"))] - #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] - #[cfg_attr( - feature = "std", - serde(rename_all = "camelCase", deny_unknown_fields, bound(serialize = ""), bound(deserialize = "")) - )] - #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode)] - pub struct TestProject { - pub expected_state: ProjectStatus, - pub metadata: ProjectMetadataOf, - pub issuer: AccountIdOf, - pub evaluations: Vec>, - pub bids: Vec>, - pub community_contributions: Vec>, - pub remainder_contributions: Vec>, - } - #[pallet::genesis_config] pub struct GenesisConfig { #[cfg(all(feature = "testing-node", feature = "std"))] From 7117d84ad1c7f88a06e9bcc1b1174f76547f1345 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 14 Dec 2023 13:18:49 +0100 Subject: [PATCH 075/212] fixed --- pallets/funding/src/mock.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 7734dcd70..d23d4e095 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -266,15 +266,15 @@ pub const HOURS: BlockNumber = 300u64; // REMARK: In the production configuration we use DAYS instead of HOURS. parameter_types! { - pub const EvaluationDuration: BlockNumber = (28) as BlockNumber; - pub const AuctionInitializePeriodDuration: BlockNumber = (7) as BlockNumber; - pub const EnglishAuctionDuration: BlockNumber = (2) as BlockNumber; - pub const CandleAuctionDuration: BlockNumber = (3) as BlockNumber; - pub const CommunityRoundDuration: BlockNumber = (5) as BlockNumber; + pub const EvaluationDuration: BlockNumber = (28 * HOURS) as BlockNumber; + pub const AuctionInitializePeriodDuration: BlockNumber = (7 * HOURS) as BlockNumber; + pub const EnglishAuctionDuration: BlockNumber = (2 * HOURS) as BlockNumber; + pub const CandleAuctionDuration: BlockNumber = (3 * HOURS) as BlockNumber; + pub const CommunityRoundDuration: BlockNumber = (5 * HOURS) as BlockNumber; pub const RemainderFundingDuration: BlockNumber = HOURS as BlockNumber; pub const FundingPalletId: PalletId = PalletId(*b"py/cfund"); - pub const ManualAcceptanceDuration: BlockNumber = (3) as BlockNumber; - pub const SuccessToSettlementTime: BlockNumber =(4) as BlockNumber; + pub const ManualAcceptanceDuration: BlockNumber = (3 * HOURS) as BlockNumber; + pub const SuccessToSettlementTime: BlockNumber =(4 * HOURS) as BlockNumber; pub PriceMap: BTreeMap = BTreeMap::from_iter(vec![ (0u32, FixedU128::from_float(69f64)), // DOT (420u32, FixedU128::from_float(0.97f64)), // USDC From 36073328f116695aedccadfc9b7dd57008fac668 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 15 Dec 2023 14:46:45 +0100 Subject: [PATCH 076/212] projects meeting together at the desired state (they start at different points automatically) --- pallets/funding/src/instantiator.rs | 205 +++++++++++++++++++++++++--- pallets/funding/src/mock.rs | 26 ++-- pallets/funding/src/tests.rs | 73 +++++++++- 3 files changed, 277 insertions(+), 27 deletions(-) diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 0b2c49a99..f88e81e54 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -1386,6 +1386,7 @@ impl< #[cfg(feature = "std")] pub mod async_features { use super::*; + use crate::mock::{BlockNumber, new_test_ext}; use futures::FutureExt; use std::{ collections::HashMap, @@ -1396,6 +1397,7 @@ pub mod async_features { time::Duration, }; use tokio::{ + runtime::Runtime, sync::{Mutex, Notify}, time::sleep, }; @@ -1420,10 +1422,10 @@ pub mod async_features { break } - let has_targets = block_orchestrator.advance_to_next_target(instantiator.clone()).await; + let maybe_target_reached = block_orchestrator.advance_to_next_target(instantiator.clone()).await; - if has_targets { - block_orchestrator.execute_callbacks().await; + if let Some(target_reached) = maybe_target_reached { + block_orchestrator.execute_callbacks(target_reached).await; } // leaves some time for the projects to submit their targets to the orchestrator sleep(Duration::from_millis(100)).await; @@ -1449,6 +1451,7 @@ pub mod async_features { println!("add_awaiting_project requesting lock"); let mut awaiting_projects = self.awaiting_projects.lock().await; println!("add_awaiting_project lock given"); + println!("adding project to block {}", block_number); awaiting_projects.entry(block_number).or_default().push(notify); drop(awaiting_projects); } @@ -1456,28 +1459,33 @@ pub mod async_features { pub async fn advance_to_next_target( &self, instantiator: Arc>>, - ) -> bool { + ) -> Option> { + let mut inst = instantiator.lock().await; + let now: u32 = + inst.current_block().try_into().unwrap_or_else(|_| panic!("Block number should fit into u32")); + self.current_block.store(now, Ordering::SeqCst); + let awaiting_projects = self.awaiting_projects.lock().await; + if let Some(&next_block) = awaiting_projects.keys().min() { drop(awaiting_projects); + println!("advancing to block {}", next_block); while self.get_current_block() < next_block { - let mut inst = instantiator.lock().await; inst.advance_time(One::one()).unwrap(); - let now = - inst.current_block().try_into().unwrap_or_else(|_| panic!("Block number should fit into u32")); - self.current_block.store(now, Ordering::SeqCst); + let current_block: u32 = self.get_current_block().try_into().unwrap_or_else(|_| panic!("Block number should fit into u32")); + self.current_block.store(current_block + 1u32, Ordering::SeqCst); - println!("Advanced to block {}", now); + println!("Advanced to block {}", current_block + 1u32); } - true + Some(next_block) } else { - false + None } } - pub async fn execute_callbacks(&self) { + pub async fn execute_callbacks(&self, block_number: BlockNumberFor) { let mut awaiting_projects = self.awaiting_projects.lock().await; - if let Some(notifies) = awaiting_projects.remove(&self.get_current_block()) { + if let Some(notifies) = awaiting_projects.remove(&block_number) { for notify in notifies { notify.notify_one(); } @@ -2260,14 +2268,175 @@ pub mod async_features { } } - pub async fn create_multiple_projects_at< - T: Config + pallet_balances::Config>, - AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, + pub async fn async_create_project_at< + T: Config + pallet_balances::Config> + std::marker::Sync + std::marker::Send, + AllPalletsWithoutSystem: OnFinalize> + + OnIdle> + + OnInitialize> + + Sync + + Send + + 'static, + RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, + >( + mutex_inst: Arc>>, + block_orchestrator: Arc>, + test_project_params: TestProjectParams, + ) -> ProjectIdOf { + let time_to_new_project: BlockNumberFor = Zero::zero(); + let time_to_evaluation: BlockNumberFor = time_to_new_project + Zero::zero(); + // we immediately start the auction, so we dont wait for T::AuctionInitializePeriodDuration. + let time_to_auction: BlockNumberFor = time_to_evaluation + ::EvaluationDuration::get(); + let time_to_community: BlockNumberFor = time_to_auction + + ::EnglishAuctionDuration::get() + + ::CandleAuctionDuration::get(); + let time_to_remainder: BlockNumberFor = time_to_community + ::CommunityFundingDuration::get(); + let time_to_finish: BlockNumberFor = time_to_remainder + ::RemainderFundingDuration::get(); + let now = mutex_inst.lock().await.current_block(); + + match test_project_params.expected_state { + ProjectStatus::Application => { + println!("application project creation requested"); + let notify = Arc::new(Notify::new()); + block_orchestrator + .add_awaiting_project(now + time_to_finish - time_to_new_project, notify.clone()) + .await; + // Wait for the notification that our desired block was reached to continue + notify.notified().await; + async_create_new_project(mutex_inst.clone(), test_project_params.metadata, test_project_params.issuer) + .await + }, + ProjectStatus::EvaluationRound => { + println!("evaluation project creation requested"); + let notify = Arc::new(Notify::new()); + block_orchestrator + .add_awaiting_project(now + time_to_finish - time_to_evaluation, notify.clone()) + .await; + // Wait for the notification that our desired block was reached to continue + notify.notified().await; + async_create_evaluating_project( + mutex_inst.clone(), + test_project_params.metadata, + test_project_params.issuer, + ) + .await + }, + ProjectStatus::AuctionRound(_) => { + println!("auction project creation requested"); + let notify = Arc::new(Notify::new()); + block_orchestrator.add_awaiting_project(now + time_to_finish - time_to_auction, notify.clone()).await; + // Wait for the notification that our desired block was reached to continue + notify.notified().await; + async_create_auctioning_project( + mutex_inst.clone(), + block_orchestrator.clone(), + test_project_params.metadata, + test_project_params.issuer, + test_project_params.evaluations, + ) + .await + }, + ProjectStatus::CommunityRound => { + println!("community project creation requested"); + let notify = Arc::new(Notify::new()); + block_orchestrator.add_awaiting_project(now + time_to_finish - time_to_community, notify.clone()).await; + // Wait for the notification that our desired block was reached to continue + notify.notified().await; + async_create_community_contributing_project( + mutex_inst.clone(), + block_orchestrator.clone(), + test_project_params.metadata, + test_project_params.issuer, + test_project_params.evaluations, + test_project_params.bids, + ) + .map(|(project_id, _)| project_id) + .await + }, + ProjectStatus::RemainderRound => { + println!("remainder project creation requested"); + let notify = Arc::new(Notify::new()); + block_orchestrator.add_awaiting_project(now + time_to_finish - time_to_remainder, notify.clone()).await; + // Wait for the notification that our desired block was reached to continue + notify.notified().await; + async_create_remainder_contributing_project( + mutex_inst.clone(), + block_orchestrator.clone(), + test_project_params.metadata, + test_project_params.issuer, + test_project_params.evaluations, + test_project_params.bids, + test_project_params.community_contributions, + ) + .map(|(project_id, _)| project_id) + .await + }, + ProjectStatus::FundingSuccessful => { + println!("finished project creation requested"); + let notify = Arc::new(Notify::new()); + block_orchestrator.add_awaiting_project(now + time_to_finish - time_to_finish, notify.clone()).await; + // Wait for the notification that our desired block was reached to continue + notify.notified().await; + async_create_finished_project( + mutex_inst.clone(), + block_orchestrator.clone(), + test_project_params.metadata, + test_project_params.issuer, + test_project_params.evaluations, + test_project_params.bids, + test_project_params.community_contributions, + test_project_params.remainder_contributions, + ) + .await + }, + _ => unimplemented!("Unsupported project creation in that status"), + } + } + + pub fn create_multiple_projects_at< + T: Config + pallet_balances::Config> + std::marker::Sync + std::marker::Send, + AllPalletsWithoutSystem: OnFinalize> + + OnIdle> + + OnInitialize> + + Sync + + Send + + 'static, RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, >( + instantiator: Instantiator, projects: Vec>, - ) { - todo!(); + ) -> Instantiator + where + ::ProjectIdentifier: Send + Sync, + ::Balance: Send + Sync, + ::Price: Send + Sync, + ::StringLimit: Send + Sync, + ::Multiplier: Send + Sync, + { + let tokio_runtime = Runtime::new().unwrap(); + + tokio_runtime.block_on(async { + let block_orchestrator = Arc::new(BlockOrchestrator::new()); + let mutex_inst = Arc::new(Mutex::new(instantiator)); + + let project_futures = projects.into_iter().map(|project| { + let block_orchestrator = block_orchestrator.clone(); + let mutex_inst = mutex_inst.clone(); + tokio::spawn(async { async_create_project_at(mutex_inst, block_orchestrator, project).await }) + }); + + // Wait for all project creation tasks to complete + let joined_project_futures = futures::future::join_all(project_futures); + let controller_handle = tokio::spawn(block_controller(block_orchestrator.clone(), mutex_inst.clone())); + joined_project_futures.await; + + // Now that all projects have been set up, signal the block_controller to stop + block_orchestrator.should_continue.store(false, Ordering::SeqCst); + + // Wait for the block controller to finish + controller_handle.await.unwrap(); + + Arc::try_unwrap(mutex_inst).unwrap_or_else(|_| panic!("mutex in use")).into_inner() + }) } } diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index d23d4e095..43ee5fc40 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -266,15 +266,25 @@ pub const HOURS: BlockNumber = 300u64; // REMARK: In the production configuration we use DAYS instead of HOURS. parameter_types! { - pub const EvaluationDuration: BlockNumber = (28 * HOURS) as BlockNumber; - pub const AuctionInitializePeriodDuration: BlockNumber = (7 * HOURS) as BlockNumber; - pub const EnglishAuctionDuration: BlockNumber = (2 * HOURS) as BlockNumber; - pub const CandleAuctionDuration: BlockNumber = (3 * HOURS) as BlockNumber; - pub const CommunityRoundDuration: BlockNumber = (5 * HOURS) as BlockNumber; - pub const RemainderFundingDuration: BlockNumber = HOURS as BlockNumber; + // pub const EvaluationDuration: BlockNumber = (28 * HOURS) as BlockNumber; + // pub const AuctionInitializePeriodDuration: BlockNumber = (7 * HOURS) as BlockNumber; + // pub const EnglishAuctionDuration: BlockNumber = (2 * HOURS) as BlockNumber; + // pub const CandleAuctionDuration: BlockNumber = (3 * HOURS) as BlockNumber; + // pub const CommunityRoundDuration: BlockNumber = (5 * HOURS) as BlockNumber; + // pub const RemainderFundingDuration: BlockNumber = (1 * HOURS) as BlockNumber; + // pub const ManualAcceptanceDuration: BlockNumber = (3 * HOURS) as BlockNumber; + // pub const SuccessToSettlementTime: BlockNumber =(4 * HOURS) as BlockNumber; + // + pub const EvaluationDuration: BlockNumber = (28) as BlockNumber; + pub const AuctionInitializePeriodDuration: BlockNumber = (7) as BlockNumber; + pub const EnglishAuctionDuration: BlockNumber = (2) as BlockNumber; + pub const CandleAuctionDuration: BlockNumber = (3) as BlockNumber; + pub const CommunityRoundDuration: BlockNumber = (5) as BlockNumber; + pub const RemainderFundingDuration: BlockNumber = (1) as BlockNumber; + pub const ManualAcceptanceDuration: BlockNumber = (3) as BlockNumber; + pub const SuccessToSettlementTime: BlockNumber =(4) as BlockNumber; + pub const FundingPalletId: PalletId = PalletId(*b"py/cfund"); - pub const ManualAcceptanceDuration: BlockNumber = (3 * HOURS) as BlockNumber; - pub const SuccessToSettlementTime: BlockNumber =(4 * HOURS) as BlockNumber; pub PriceMap: BTreeMap = BTreeMap::from_iter(vec![ (0u32, FixedU128::from_float(69f64)), // DOT (420u32, FixedU128::from_float(0.97f64)), // USDC diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 06d03081d..b28d76f65 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -5859,7 +5859,7 @@ mod async_tests { }; #[test] - fn sandbox() { + fn prototype_1() { let tokio_runtime = Runtime::new().unwrap(); let inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); @@ -6002,4 +6002,75 @@ mod async_tests { dbg!(inst.get_project_details(11).status); }); } + + #[test] + fn prototype_2() { + let inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + + let project_params = vec![ + TestProjectParams { + expected_state: ProjectStatus::Application, + metadata: default_project(inst.get_new_nonce(), ISSUER), + issuer: ISSUER, + evaluations: vec![], + bids: vec![], + community_contributions: vec![], + remainder_contributions: vec![], + }, + TestProjectParams { + expected_state: ProjectStatus::EvaluationRound, + metadata: default_project(inst.get_new_nonce(), ISSUER), + issuer: ISSUER, + evaluations: vec![], + bids: vec![], + community_contributions: vec![], + remainder_contributions: vec![], + }, + TestProjectParams { + expected_state: ProjectStatus::AuctionRound(AuctionPhase::English), + metadata: default_project(inst.get_new_nonce(), ISSUER), + issuer: ISSUER, + evaluations: default_evaluations(), + bids: vec![], + community_contributions: vec![], + remainder_contributions: vec![], + }, + TestProjectParams { + expected_state: ProjectStatus::CommunityRound, + metadata: default_project(inst.get_new_nonce(), ISSUER), + issuer: ISSUER, + evaluations: default_evaluations(), + bids: default_bids(), + community_contributions: vec![], + remainder_contributions: vec![], + }, + TestProjectParams { + expected_state: ProjectStatus::RemainderRound, + metadata: default_project(inst.get_new_nonce(), ISSUER), + issuer: ISSUER, + evaluations: default_evaluations(), + bids: default_bids(), + community_contributions: default_community_buys(), + remainder_contributions: vec![], + }, + TestProjectParams { + expected_state: ProjectStatus::FundingSuccessful, + metadata: default_project(inst.get_new_nonce(), ISSUER), + issuer: ISSUER, + evaluations: default_evaluations(), + bids: default_bids(), + community_contributions: default_community_buys(), + remainder_contributions: default_remainder_buys(), + }, + ]; + + let mut inst = create_multiple_projects_at(inst, project_params); + + dbg!(inst.get_project_details(0).status); + dbg!(inst.get_project_details(1).status); + dbg!(inst.get_project_details(2).status); + dbg!(inst.get_project_details(3).status); + dbg!(inst.get_project_details(4).status); + dbg!(inst.get_project_details(5).status); + } } From 5ca32f78d3b1755b5e33724015125eb8cdabd134 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 18 Dec 2023 13:16:05 +0100 Subject: [PATCH 077/212] save --- Cargo.lock | 1 + Cargo.toml | 8 +- .../macros => macros}/Cargo.toml | 0 .../src/generate_accounts.rs | 0 .../macros => macros}/src/lib.rs | 0 .../macros => macros}/tests/Cargo.toml | 0 .../macros => macros}/tests/src/lib.rs | 0 nodes/parachain/Cargo.toml | 2 + nodes/parachain/src/chain_spec/testnet.rs | 150 +++++++----------- pallets/funding/src/instantiator.rs | 6 +- pallets/funding/src/lib.rs | 4 +- .../rococo-statemine-polimec-penpal.toml | 13 +- 12 files changed, 83 insertions(+), 101 deletions(-) rename {integration-tests/macros => macros}/Cargo.toml (100%) rename {integration-tests/macros => macros}/src/generate_accounts.rs (100%) rename {integration-tests/macros => macros}/src/lib.rs (100%) rename {integration-tests/macros => macros}/tests/Cargo.toml (100%) rename {integration-tests/macros => macros}/tests/src/lib.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 3a6630b6f..f48eee388 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7434,6 +7434,7 @@ dependencies = [ "hex-literal 0.3.4", "jsonrpsee", "log", + "macros", "pallet-funding", "pallet-transaction-payment-rpc", "parachains-common", diff --git a/Cargo.toml b/Cargo.toml index 33b252315..aeba59809 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,8 +5,8 @@ members = [ "pallets/*", "integration-tests", "integration-tests/penpal", - "integration-tests/macros", - "integration-tests/macros/tests", + "macros", + "macros/tests", "polimec-common", ] @@ -61,8 +61,8 @@ polimec-xcm-executor = { path = "pallets/xcm-executor", default-features = false polimec-receiver = { path = "pallets/polimec-receiver", default-features = false } # Internal macros -macros = { path = "integration-tests/macros" } -macros-tests = { path = "integration-tests/macros/tests" } +macros = { path = "macros" } +macros-tests = { path = "macros/tests" } # External pallets (with default disabled) diff --git a/integration-tests/macros/Cargo.toml b/macros/Cargo.toml similarity index 100% rename from integration-tests/macros/Cargo.toml rename to macros/Cargo.toml diff --git a/integration-tests/macros/src/generate_accounts.rs b/macros/src/generate_accounts.rs similarity index 100% rename from integration-tests/macros/src/generate_accounts.rs rename to macros/src/generate_accounts.rs diff --git a/integration-tests/macros/src/lib.rs b/macros/src/lib.rs similarity index 100% rename from integration-tests/macros/src/lib.rs rename to macros/src/lib.rs diff --git a/integration-tests/macros/tests/Cargo.toml b/macros/tests/Cargo.toml similarity index 100% rename from integration-tests/macros/tests/Cargo.toml rename to macros/tests/Cargo.toml diff --git a/integration-tests/macros/tests/src/lib.rs b/macros/tests/src/lib.rs similarity index 100% rename from integration-tests/macros/tests/src/lib.rs rename to macros/tests/src/lib.rs diff --git a/nodes/parachain/Cargo.toml b/nodes/parachain/Cargo.toml index 1ca1b2c7a..ab6ca7a38 100644 --- a/nodes/parachain/Cargo.toml +++ b/nodes/parachain/Cargo.toml @@ -24,6 +24,7 @@ futures.workspace = true polimec-parachain-runtime.workspace = true polimec-base-runtime.workspace = true pallet-funding.workspace = true +macros = { workspace = true, optional = true } # Substrate frame-benchmarking.workspace = true @@ -137,4 +138,5 @@ testing-node = [ "pallet-funding/testing-node", "polimec-base-runtime/testing-node", "polimec-parachain-runtime/testing-node", + "macros", ] diff --git a/nodes/parachain/src/chain_spec/testnet.rs b/nodes/parachain/src/chain_spec/testnet.rs index 4d07f09d3..1e0deec7b 100644 --- a/nodes/parachain/src/chain_spec/testnet.rs +++ b/nodes/parachain/src/chain_spec/testnet.rs @@ -279,9 +279,11 @@ use sp_runtime::BoundedVec; #[cfg(all(feature = "testing-node", feature = "std"))] mod testing_helpers { use super::*; + use macros::generate_accounts; use polimec_parachain_runtime::AccountId; use sp_core::H256; use sp_runtime::traits::ConstU32; + pub const METADATA: &str = r#"METADATA { "whitepaper":"ipfs_url", @@ -293,66 +295,10 @@ mod testing_helpers { pub const ASSET_DECIMALS: u8 = 10; pub const ASSET_UNIT: u128 = 10_u128.pow(10 as u32); - pub fn issuer() -> AccountId { - get_account_id_from_seed::("issuer") - } - pub fn eval_1() -> AccountId { - get_account_id_from_seed::("eval_1") - } - pub fn eval_2() -> AccountId { - get_account_id_from_seed::("eval_2") - } - pub fn eval_3() -> AccountId { - get_account_id_from_seed::("eval_3") - } - pub fn bidder_1() -> AccountId { - get_account_id_from_seed::("bidder_1") - } - pub fn bidder_2() -> AccountId { - get_account_id_from_seed::("bidder_2") - } - pub fn bidder_3() -> AccountId { - get_account_id_from_seed::("bidder_3") - } - pub fn bidder_4() -> AccountId { - get_account_id_from_seed::("bidder_4") - } - pub fn bidder_5() -> AccountId { - get_account_id_from_seed::("bidder_5") - } - pub fn buyer_1() -> AccountId { - get_account_id_from_seed::("buyer_1") - } - pub fn buyer_2() -> AccountId { - get_account_id_from_seed::("buyer_2") - } - pub fn buyer_3() -> AccountId { - get_account_id_from_seed::("buyer_3") - } - pub fn buyer_4() -> AccountId { - get_account_id_from_seed::("buyer_4") - } - pub fn buyer_5() -> AccountId { - get_account_id_from_seed::("buyer_5") - } - pub fn all_testing_accounts() -> Vec { - vec![ - issuer(), - eval_1(), - eval_2(), - eval_3(), - bidder_1(), - bidder_2(), - bidder_3(), - bidder_4(), - bidder_5(), - buyer_1(), - buyer_2(), - buyer_3(), - buyer_4(), - buyer_5(), - ] - } + generate_accounts!( + ISSUER, EVAL_1, EVAL_2, EVAL_3, EVAL_4, BIDDER_1, BIDDER_2, BIDDER_3, BIDDER_4, BIDDER_5, BIDDER_6, BUYER_1, + BUYER_2, BUYER_3, BUYER_4, BUYER_5, BUYER_6, + ); pub fn bounded_name() -> BoundedVec> { BoundedVec::try_from("Contribution Token TEST".as_bytes().to_vec()).unwrap() } @@ -387,17 +333,30 @@ mod testing_helpers { } pub fn default_evaluations() -> Vec> { vec![ - UserToUSDBalance::new(eval_1(), 50_000 * PLMC), - UserToUSDBalance::new(eval_2(), 25_000 * PLMC), - UserToUSDBalance::new(eval_3(), 32_000 * PLMC), + UserToUSDBalance::new(EVAL_1.into(), 50_000 * PLMC), + UserToUSDBalance::new(EVAL_2.into(), 25_000 * PLMC), + UserToUSDBalance::new(EVAL_3.into(), 32_000 * PLMC), ] } pub fn default_bidders() -> Vec { - vec![bidder_1(), bidder_2(), bidder_3(), bidder_4(), bidder_5()] + vec![BIDDER_1.into(), BIDDER_2.into(), BIDDER_3.into(), BIDDER_4.into(), BIDDER_5.into()] + } + pub fn default_bidder_multipliers() -> Vec { + vec![20u8, 3u8, 15u8, 13u8, 9u8] + } + pub fn default_community_contributor_multipliers() -> Vec { + vec![1u8, 5u8, 3u8, 1u8, 2u8] + } + pub fn default_remainder_contributor_multipliers() -> Vec { + vec![1u8, 10u8, 3u8, 2u8, 4u8] + } + + pub fn default_community_contributors() -> Vec { + vec![BUYER_1.into(), BUYER_2.into(), BUYER_3.into(), BUYER_4.into(), BUYER_5.into()] } - pub fn default_contributors() -> Vec { - vec![buyer_1(), buyer_2(), buyer_3(), buyer_4(), buyer_5()] + pub fn default_remainder_contributors() -> Vec { + vec![EVAL_1.into(), BIDDER_3.into(), BUYER_4.into(), BUYER_6.into(), BIDDER_6.into()] } pub fn hashed(data: impl AsRef<[u8]>) -> sp_core::H256 { ::hash(data.as_ref()) @@ -421,13 +380,13 @@ fn testing_genesis( mut endowed_accounts: Vec<(AccountId, Balance)>, sudo_account: AccountId, id: ParaId, -) -> GenesisConfig { +) -> RuntimeGenesisConfig { use sp_runtime::{traits::PhantomData, FixedPointNumber, Perquintill}; use testing_helpers::*; // only used to generate some values, and not for chain interactions let funding_percent = 93u64; - let project_metadata = default_project(issuer(), 69u32); + let project_metadata = default_project(ISSUER.into(), 0u32); let min_price = project_metadata.minimum_price; let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) * (project_metadata.minimum_price.checked_mul_int(project_metadata.total_allocation_size.0).unwrap()); @@ -437,32 +396,40 @@ fn testing_genesis( min_price, default_weights(), default_bidders(), + default_bidder_multipliers(), ); - let contributions = GenesisInstantiator::generate_contributions_from_total_usd( - Percent::from_percent(50u8) * twenty_percent_funding_usd, + let community_contributions = GenesisInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(30u8) * twenty_percent_funding_usd, + min_price, + default_weights(), + default_community_contributors(), + default_community_contributor_multipliers(), + ); + let remainder_contributions = GenesisInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(30u8) * twenty_percent_funding_usd, min_price, default_weights(), - default_contributors(), + default_remainder_contributors(), + default_remainder_contributor_multipliers(), ); let test_balance = 5 * MinCandidateStk::get(); - for account in all_testing_accounts() { - endowed_accounts.push((account, test_balance)); - } + // for account in all_testing_accounts() { + // endowed_accounts.push((account, test_balance)); + // } let accounts = endowed_accounts.iter().map(|(account, _)| account.clone()).collect::>(); - endowed_accounts - .push((::PalletId::get().into_account_truncating(), EXISTENTIAL_DEPOSIT)); - GenesisConfig { + endowed_accounts.push((::PalletId::get().into_account_truncating(), EXISTENTIAL_DEPOSIT)); + RuntimeGenesisConfig { system: SystemConfig { code: wasm_binary.to_vec(), ..Default::default() }, polimec_funding: polimec_parachain_runtime::PolimecFundingConfig { - starting_projects: vec![pallet_funding::TestProject:: { + starting_projects: vec![instantiator::TestProjectParams:: { expected_state: ProjectStatus::FundingSuccessful, - metadata: project_metadata, - issuer: issuer(), + metadata: default_project(ISSUER.into(), 0u32), + issuer: ISSUER.into(), evaluations, bids, - community_contributions: contributions, - remainder_contributions: vec![], + community_contributions, + remainder_contributions, }], phantom: PhantomData, }, @@ -477,12 +444,9 @@ fn testing_genesis( metadata: vec![], accounts: vec![], }, - parachain_info: ParachainInfoConfig { parachain_id: id }, + parachain_info: ParachainInfoConfig { parachain_id: id, ..Default::default() }, parachain_staking: ParachainStakingConfig { - candidates: stakers - .iter() - .map(|(accunt, _, balance)| (accunt.clone(), balance.clone())) - .collect::>(), + candidates: stakers.iter().map(|(accunt, _, balance)| (accunt.clone(), *balance)).collect::>(), inflation_config, delegations: vec![], collator_commission: COLLATOR_COMMISSION, @@ -507,12 +471,20 @@ fn testing_genesis( }) .collect::>(), }, - polkadot_xcm: PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION) }, + polkadot_xcm: PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION), ..Default::default() }, treasury: Default::default(), sudo: SudoConfig { key: Some(sudo_account) }, council: CouncilConfig { members: accounts.clone(), phantom: Default::default() }, - technical_committee: TechnicalCommitteeConfig { members: accounts.clone(), phantom: Default::default() }, + technical_committee: TechnicalCommitteeConfig { members: accounts, phantom: Default::default() }, democracy: Default::default(), linear_vesting: LinearVestingConfig { vesting: vec![] }, + oracle_providers_membership: OracleProvidersMembershipConfig { + members: bounded_vec![ + get_account_id_from_seed::("Alice"), + get_account_id_from_seed::("Bob"), + get_account_id_from_seed::("Charlie"), + ], + phantom: Default::default(), + }, } } diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index f88e81e54..6af25f7f7 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -1386,7 +1386,6 @@ impl< #[cfg(feature = "std")] pub mod async_features { use super::*; - use crate::mock::{BlockNumber, new_test_ext}; use futures::FutureExt; use std::{ collections::HashMap, @@ -1472,7 +1471,10 @@ pub mod async_features { println!("advancing to block {}", next_block); while self.get_current_block() < next_block { inst.advance_time(One::one()).unwrap(); - let current_block: u32 = self.get_current_block().try_into().unwrap_or_else(|_| panic!("Block number should fit into u32")); + let current_block: u32 = self + .get_current_block() + .try_into() + .unwrap_or_else(|_| panic!("Block number should fit into u32")); self.current_block.store(current_block + 1u32, Ordering::SeqCst); println!("Advanced to block {}", current_block + 1u32); diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index dba58d4bb..94f039c61 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1351,6 +1351,8 @@ pub mod pallet { } } + #[cfg(all(feature = "testing-node", feature = "std"))] + use crate::instantiator::TestProjectParams; #[cfg(all(feature = "testing-node", feature = "std"))] use frame_support::traits::{OnFinalize, OnIdle, OnInitialize, OriginTrait}; use pallet_xcm::ensure_response; @@ -1358,7 +1360,7 @@ pub mod pallet { #[pallet::genesis_config] pub struct GenesisConfig { #[cfg(all(feature = "testing-node", feature = "std"))] - pub starting_projects: Vec>, + pub starting_projects: Vec>, pub phantom: PhantomData, } diff --git a/scripts/zombienet/native/rococo-statemine-polimec-penpal.toml b/scripts/zombienet/native/rococo-statemine-polimec-penpal.toml index 5663f6148..2e1eda126 100644 --- a/scripts/zombienet/native/rococo-statemine-polimec-penpal.toml +++ b/scripts/zombienet/native/rococo-statemine-polimec-penpal.toml @@ -33,12 +33,15 @@ chain = "statemint-local" name = "statemint-collator" command = "polkadot-parachain" -[[parachains]] -id = 2000 - [[parachains.collators]] - name = "polimec-collator" - command = "polimec-parachain-node" +[[parachains]] +id = 3344 +chain = "polimec-testing" +[[parachains.collators]] +name = "polimec-testing" +command = "./target/release/polimec-parachain-node" +args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] +ws_port = 8888 [[parachains]] id = 3000 From acb601ba7ed7b9974fd7f52af6dbb090e0ac9ebd Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 18 Dec 2023 14:35:51 +0100 Subject: [PATCH 078/212] fixed tests. they were failing due to debug durations not disabled --- pallets/funding/src/mock.rs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 43ee5fc40..febaff87f 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -266,23 +266,23 @@ pub const HOURS: BlockNumber = 300u64; // REMARK: In the production configuration we use DAYS instead of HOURS. parameter_types! { - // pub const EvaluationDuration: BlockNumber = (28 * HOURS) as BlockNumber; - // pub const AuctionInitializePeriodDuration: BlockNumber = (7 * HOURS) as BlockNumber; - // pub const EnglishAuctionDuration: BlockNumber = (2 * HOURS) as BlockNumber; - // pub const CandleAuctionDuration: BlockNumber = (3 * HOURS) as BlockNumber; - // pub const CommunityRoundDuration: BlockNumber = (5 * HOURS) as BlockNumber; - // pub const RemainderFundingDuration: BlockNumber = (1 * HOURS) as BlockNumber; - // pub const ManualAcceptanceDuration: BlockNumber = (3 * HOURS) as BlockNumber; - // pub const SuccessToSettlementTime: BlockNumber =(4 * HOURS) as BlockNumber; - // - pub const EvaluationDuration: BlockNumber = (28) as BlockNumber; - pub const AuctionInitializePeriodDuration: BlockNumber = (7) as BlockNumber; - pub const EnglishAuctionDuration: BlockNumber = (2) as BlockNumber; - pub const CandleAuctionDuration: BlockNumber = (3) as BlockNumber; - pub const CommunityRoundDuration: BlockNumber = (5) as BlockNumber; - pub const RemainderFundingDuration: BlockNumber = (1) as BlockNumber; - pub const ManualAcceptanceDuration: BlockNumber = (3) as BlockNumber; - pub const SuccessToSettlementTime: BlockNumber =(4) as BlockNumber; + pub const EvaluationDuration: BlockNumber = (28 * HOURS) as BlockNumber; + pub const AuctionInitializePeriodDuration: BlockNumber = (7 * HOURS) as BlockNumber; + pub const EnglishAuctionDuration: BlockNumber = (2 * HOURS) as BlockNumber; + pub const CandleAuctionDuration: BlockNumber = (3 * HOURS) as BlockNumber; + pub const CommunityRoundDuration: BlockNumber = (5 * HOURS) as BlockNumber; + pub const RemainderFundingDuration: BlockNumber = (1 * HOURS) as BlockNumber; + pub const ManualAcceptanceDuration: BlockNumber = (3 * HOURS) as BlockNumber; + pub const SuccessToSettlementTime: BlockNumber =(4 * HOURS) as BlockNumber; + + // pub const EvaluationDuration: BlockNumber = (28) as BlockNumber; + // pub const AuctionInitializePeriodDuration: BlockNumber = (7) as BlockNumber; + // pub const EnglishAuctionDuration: BlockNumber = (2) as BlockNumber; + // pub const CandleAuctionDuration: BlockNumber = (3) as BlockNumber; + // pub const CommunityRoundDuration: BlockNumber = (5) as BlockNumber; + // pub const RemainderFundingDuration: BlockNumber = (1) as BlockNumber; + // pub const ManualAcceptanceDuration: BlockNumber = (3) as BlockNumber; + // pub const SuccessToSettlementTime: BlockNumber =(4) as BlockNumber; pub const FundingPalletId: PalletId = PalletId(*b"py/cfund"); pub PriceMap: BTreeMap = BTreeMap::from_iter(vec![ From 441bbed1f2e3ab01687a18673648543c9e06e494 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 18 Dec 2023 16:28:08 +0100 Subject: [PATCH 079/212] traits broken :( --- integration-tests/src/constants.rs | 2 +- integration-tests/src/tests/defaults.rs | 92 ++++++++-------- integration-tests/src/tests/oracle.rs | 11 ++ nodes/parachain/src/chain_spec/testnet.rs | 100 +++++++++++++----- pallets/funding/src/instantiator.rs | 1 - pallets/funding/src/lib.rs | 57 +++++----- pallets/funding/src/traits.rs | 4 +- runtimes/testnet/src/lib.rs | 22 ++-- ...pless-rococo-statemint-polimec-penpal.toml | 4 +- 9 files changed, 182 insertions(+), 111 deletions(-) diff --git a/integration-tests/src/constants.rs b/integration-tests/src/constants.rs index 38bcfe4cc..c8ce53fab 100644 --- a/integration-tests/src/constants.rs +++ b/integration-tests/src/constants.rs @@ -255,7 +255,6 @@ pub mod polimec { .to_vec(), ..Default::default() }, - polimec_funding: Default::default(), balances: polimec_parachain_runtime::BalancesConfig { balances: funded_accounts }, parachain_info: polimec_parachain_runtime::ParachainInfoConfig { parachain_id: PARA_ID.into(), @@ -303,6 +302,7 @@ pub mod polimec { }, technical_committee: Default::default(), treasury: Default::default(), + polimec_funding: Default::default(), linear_vesting: Default::default(), }; diff --git a/integration-tests/src/tests/defaults.rs b/integration-tests/src/tests/defaults.rs index a7268ae03..40e4a0e9c 100644 --- a/integration-tests/src/tests/defaults.rs +++ b/integration-tests/src/tests/defaults.rs @@ -133,52 +133,52 @@ pub fn default_remainder_contributors() -> Vec { use crate::{Polimec, PolimecRuntime, ALICE, BOB, CHARLIE}; pub fn set_oracle_prices() { - Polimec::execute_with(|| { - fn values( - values: [f64; 4], - ) -> BoundedVec< - (u32, FixedU128), - >::MaxFeedValues, - > { - let [dot, usdc, usdt, plmc] = values; - bounded_vec![ - (0u32, FixedU128::from_float(dot)), - (420u32, FixedU128::from_float(usdc)), - (1984u32, FixedU128::from_float(usdt)), - (2069u32, FixedU128::from_float(plmc)) - ] - } - - let alice = Polimec::account_id_of(ALICE); - assert_ok!(polimec_parachain_runtime::Oracle::feed_values( - PolimecOrigin::signed(alice.clone()), - values([4.84, 1.0, 1.0, 0.4]) - )); - - let bob = Polimec::account_id_of(BOB); - assert_ok!(polimec_parachain_runtime::Oracle::feed_values( - PolimecOrigin::signed(bob.clone()), - values([4.84, 1.0, 1.0, 0.4]) - )); - - let charlie = Polimec::account_id_of(CHARLIE); - assert_ok!(polimec_parachain_runtime::Oracle::feed_values( - PolimecOrigin::signed(charlie.clone()), - values([4.84, 1.0, 1.0, 0.4]) - )); - - let expected_values = HashMap::from([ - (0u32, FixedU128::from_float(4.84)), - (420u32, FixedU128::from_float(1.0)), - (1984u32, FixedU128::from_float(1.0)), - (2069u32, FixedU128::from_float(0.4)), - ]); - - for (key, value) in polimec_parachain_runtime::Oracle::get_all_values() { - assert!(value.is_some()); - assert_eq!(expected_values.get(&key).unwrap(), &value.unwrap().value); - } - }); + // Polimec::execute_with(|| { + // fn values( + // values: [f64; 4], + // ) -> BoundedVec< + // (u32, FixedU128), + // >::MaxFeedValues, + // > { + // let [dot, usdc, usdt, plmc] = values; + // bounded_vec![ + // (0u32, FixedU128::from_float(dot)), + // (420u32, FixedU128::from_float(usdc)), + // (1984u32, FixedU128::from_float(usdt)), + // (2069u32, FixedU128::from_float(plmc)) + // ] + // } + // + // let alice = Polimec::account_id_of(ALICE); + // assert_ok!(polimec_parachain_runtime::Oracle::feed_values( + // PolimecOrigin::signed(alice.clone()), + // values([4.84, 1.0, 1.0, 0.4]) + // )); + // + // let bob = Polimec::account_id_of(BOB); + // assert_ok!(polimec_parachain_runtime::Oracle::feed_values( + // PolimecOrigin::signed(bob.clone()), + // values([4.84, 1.0, 1.0, 0.4]) + // )); + // + // let charlie = Polimec::account_id_of(CHARLIE); + // assert_ok!(polimec_parachain_runtime::Oracle::feed_values( + // PolimecOrigin::signed(charlie.clone()), + // values([4.84, 1.0, 1.0, 0.4]) + // )); + // + // let expected_values = HashMap::from([ + // (0u32, FixedU128::from_float(4.84)), + // (420u32, FixedU128::from_float(1.0)), + // (1984u32, FixedU128::from_float(1.0)), + // (2069u32, FixedU128::from_float(0.4)), + // ]); + // + // for (key, value) in polimec_parachain_runtime::Oracle::get_all_values() { + // assert!(value.is_some()); + // assert_eq!(expected_values.get(&key).unwrap(), &value.unwrap().value); + // } + // }); } #[test] diff --git a/integration-tests/src/tests/oracle.rs b/integration-tests/src/tests/oracle.rs index 9e155f916..43e65929c 100644 --- a/integration-tests/src/tests/oracle.rs +++ b/integration-tests/src/tests/oracle.rs @@ -24,7 +24,11 @@ fn values( #[test] fn members_can_feed_data() { + let mut inst = IntegrationInstantiator::new(None); + Polimec::execute_with(|| { + // pallet_funding genesis builder already inputs prices, so we need to advance one block to feed new values. + inst.advance_time(1u32); let alice = Polimec::account_id_of(ALICE); assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(alice.clone()), values([4.84, 1.0, 1.0, 0.4]))); @@ -61,7 +65,11 @@ fn non_members_cannot_feed_data() { #[test] fn data_is_correctly_combined() { + let mut inst = IntegrationInstantiator::new(None); Polimec::execute_with(|| { + // pallet_funding genesis builder already inputs prices, so we need to advance one block to feed new values. + inst.advance_time(1u32); + let alice = Polimec::account_id_of(ALICE); assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(alice.clone()), values([1.0, 1.5, 1.1, 0.11111]))); @@ -91,6 +99,9 @@ fn pallet_funding_works() { let mut inst = IntegrationInstantiator::new(None); Polimec::execute_with(|| { + // pallet_funding genesis builder already inputs prices, so we need to advance one block to feed new values. + inst.advance_time(1u32); + let alice = Polimec::account_id_of(ALICE); assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(alice.clone()), values([4.84, 1.0, 1.0, 0.4]))); diff --git a/nodes/parachain/src/chain_spec/testnet.rs b/nodes/parachain/src/chain_spec/testnet.rs index 1e0deec7b..ae157e242 100644 --- a/nodes/parachain/src/chain_spec/testnet.rs +++ b/nodes/parachain/src/chain_spec/testnet.rs @@ -279,10 +279,12 @@ use sp_runtime::BoundedVec; #[cfg(all(feature = "testing-node", feature = "std"))] mod testing_helpers { use super::*; + use frame_benchmarking::frame_support::assert_ok; use macros::generate_accounts; - use polimec_parachain_runtime::AccountId; + use polimec_parachain_runtime::{AccountId, FixedU128}; use sp_core::H256; use sp_runtime::traits::ConstU32; + use std::collections::HashMap; pub const METADATA: &str = r#"METADATA { @@ -296,9 +298,10 @@ mod testing_helpers { pub const ASSET_UNIT: u128 = 10_u128.pow(10 as u32); generate_accounts!( - ISSUER, EVAL_1, EVAL_2, EVAL_3, EVAL_4, BIDDER_1, BIDDER_2, BIDDER_3, BIDDER_4, BIDDER_5, BIDDER_6, BUYER_1, - BUYER_2, BUYER_3, BUYER_4, BUYER_5, BUYER_6, + ALICE, BOB, CHARLIE, ISSUER, EVAL_1, EVAL_2, EVAL_3, EVAL_4, BIDDER_1, BIDDER_2, BIDDER_3, BIDDER_4, BIDDER_5, + BIDDER_6, BUYER_1, BUYER_2, BUYER_3, BUYER_4, BUYER_5, BUYER_6, ); + pub fn bounded_name() -> BoundedVec> { BoundedVec::try_from("Contribution Token TEST".as_bytes().to_vec()).unwrap() } @@ -381,6 +384,7 @@ fn testing_genesis( sudo_account: AccountId, id: ParaId, ) -> RuntimeGenesisConfig { + use instantiator::TestProjectParams; use sp_runtime::{traits::PhantomData, FixedPointNumber, Perquintill}; use testing_helpers::*; @@ -389,7 +393,10 @@ fn testing_genesis( let project_metadata = default_project(ISSUER.into(), 0u32); let min_price = project_metadata.minimum_price; let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) * - (project_metadata.minimum_price.checked_mul_int(project_metadata.total_allocation_size.0).unwrap()); + (project_metadata + .minimum_price + .checked_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1) + .unwrap()); let evaluations = default_evaluations(); let bids = GenesisInstantiator::generate_bids_from_total_usd( Percent::from_percent(50u8) * twenty_percent_funding_usd, @@ -412,25 +419,76 @@ fn testing_genesis( default_remainder_contributors(), default_remainder_contributor_multipliers(), ); - let test_balance = 5 * MinCandidateStk::get(); - // for account in all_testing_accounts() { - // endowed_accounts.push((account, test_balance)); - // } let accounts = endowed_accounts.iter().map(|(account, _)| account.clone()).collect::>(); endowed_accounts.push((::PalletId::get().into_account_truncating(), EXISTENTIAL_DEPOSIT)); RuntimeGenesisConfig { system: SystemConfig { code: wasm_binary.to_vec(), ..Default::default() }, + oracle_providers_membership: OracleProvidersMembershipConfig { + members: bounded_vec![ + get_account_id_from_seed::("Alice"), + get_account_id_from_seed::("Bob"), + get_account_id_from_seed::("Charlie"), + ], + phantom: Default::default(), + }, polimec_funding: polimec_parachain_runtime::PolimecFundingConfig { - starting_projects: vec![instantiator::TestProjectParams:: { - expected_state: ProjectStatus::FundingSuccessful, - metadata: default_project(ISSUER.into(), 0u32), - issuer: ISSUER.into(), - evaluations, - bids, - community_contributions, - remainder_contributions, - }], + starting_projects: vec![ + TestProjectParams:: { + expected_state: ProjectStatus::FundingSuccessful, + metadata: default_project(ISSUER.into(), 0u32), + issuer: ISSUER.into(), + evaluations: evaluations.clone(), + bids: bids.clone(), + community_contributions: community_contributions.clone(), + remainder_contributions: remainder_contributions.clone(), + }, + TestProjectParams:: { + expected_state: ProjectStatus::RemainderRound, + metadata: default_project(ISSUER.into(), 1u32), + issuer: ISSUER.into(), + evaluations: evaluations.clone(), + bids: bids.clone(), + community_contributions: community_contributions.clone(), + remainder_contributions: vec![], + }, + TestProjectParams:: { + expected_state: ProjectStatus::CommunityRound, + metadata: default_project(ISSUER.into(), 2u32), + issuer: ISSUER.into(), + evaluations: evaluations.clone(), + bids: bids.clone(), + community_contributions: vec![], + remainder_contributions: vec![], + }, + TestProjectParams:: { + expected_state: ProjectStatus::AuctionRound(AuctionPhase::English), + metadata: default_project(ISSUER.into(), 3u32), + issuer: ISSUER.into(), + evaluations: evaluations.clone(), + bids: vec![], + community_contributions: vec![], + remainder_contributions: vec![], + }, + TestProjectParams:: { + expected_state: ProjectStatus::EvaluationRound, + metadata: default_project(ISSUER.into(), 4u32), + issuer: ISSUER.into(), + evaluations: vec![], + bids: vec![], + community_contributions: vec![], + remainder_contributions: vec![], + }, + TestProjectParams:: { + expected_state: ProjectStatus::Application, + metadata: default_project(ISSUER.into(), 5u32), + issuer: ISSUER.into(), + evaluations: vec![], + bids: vec![], + community_contributions: vec![], + remainder_contributions: vec![], + }, + ], phantom: PhantomData, }, balances: BalancesConfig { balances: endowed_accounts.clone() }, @@ -478,13 +536,5 @@ fn testing_genesis( technical_committee: TechnicalCommitteeConfig { members: accounts, phantom: Default::default() }, democracy: Default::default(), linear_vesting: LinearVestingConfig { vesting: vec![] }, - oracle_providers_membership: OracleProvidersMembershipConfig { - members: bounded_vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Charlie"), - ], - phantom: Default::default(), - }, } } diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 6af25f7f7..ec0d75695 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -264,7 +264,6 @@ impl< for UserToPLMCBalance { account, plmc_amount } in correct_funds { self.execute(|| { let free = ::NativeCurrency::balance(&account); - println!("account: {:?}, free: {:?}, plmc_amount: {:?}", account, free, plmc_amount); assert_eq!(free, plmc_amount); }); } diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 94f039c61..8f57bf158 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -269,6 +269,9 @@ pub mod pallet { use crate::traits::{BondingRequirementCalculation, ProvideStatemintPrice, VestingDurationCalculation}; + #[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] + use crate::traits::SetPrices; + use super::*; #[pallet::pallet] @@ -278,8 +281,8 @@ pub mod pallet { pub trait Config: frame_system::Config + pallet_balances::Config> + pallet_xcm::Config { - #[cfg(feature = "runtime-benchmarks")] - type SetPrices: traits::SetPrices; + #[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] + type SetPrices: SetPrices; type AllPalletsWithoutSystem: frame_support::traits::OnFinalize> + frame_support::traits::OnIdle> @@ -1351,6 +1354,7 @@ pub mod pallet { } } + use crate::instantiator::async_features::create_multiple_projects_at; #[cfg(all(feature = "testing-node", feature = "std"))] use crate::instantiator::TestProjectParams; #[cfg(all(feature = "testing-node", feature = "std"))] @@ -1391,46 +1395,51 @@ pub mod pallet { } #[cfg(all(feature = "testing-node", feature = "std"))] - impl BuildGenesisConfig for GenesisConfig + impl BuildGenesisConfig for GenesisConfig where - T: Config + pallet_balances::Config>, - ::AllPalletsWithoutSystem: - OnFinalize> + OnIdle> + OnInitialize>, + T: Config + pallet_balances::Config> + Sync + Send, + ::AllPalletsWithoutSystem: OnFinalize> + + OnIdle> + + OnInitialize> + + Sync + + Send + + 'static, ::RuntimeEvent: From> + TryInto> + Parameter + Member, // AccountIdOf: Into< as OriginTrait>::AccountId> + sp_std::fmt::Debug, ::Balance: Into>, + ::ProjectIdentifier: Send + Sync, + ::Balance: Send + Sync, + ::Price: Send + Sync, + ::StringLimit: Send + Sync, + ::Multiplier: Send + Sync, { fn build(&self) { { type GenesisInstantiator = instantiator::Instantiator::AllPalletsWithoutSystem, ::RuntimeEvent>; let mut inst = GenesisInstantiator::::new(None); - - for test_project in self.starting_projects.clone() { - inst.create_project_at( - test_project.expected_state, - test_project.metadata, - test_project.issuer, - test_project.evaluations, - test_project.bids, - test_project.community_contributions, - test_project.remainder_contributions, - ); - } + ::SetPrices::set_prices(); + create_multiple_projects_at(inst, self.starting_projects.clone()); } } } #[cfg(all(feature = "testing-node", feature = "std"))] impl GenesisConfig where - T: Config - + frame_system::Config::RuntimeEvent> - + pallet_balances::Config>, - T::AllPalletsWithoutSystem: - OnFinalize> + OnIdle> + OnInitialize>, + T: Config + pallet_balances::Config> + Sync + Send, + ::AllPalletsWithoutSystem: OnFinalize> + + OnIdle> + + OnInitialize> + + Sync + + Send + + 'static, ::RuntimeEvent: From> + TryInto> + Parameter + Member, - AccountIdOf: Into< as OriginTrait>::AccountId> + sp_std::fmt::Debug, ::Balance: Into>, + ::ProjectIdentifier: Send + Sync, + ::Balance: Send + Sync, + ::Price: Send + Sync, + ::StringLimit: Send + Sync, + ::Multiplier: Send + Sync, { /// Direct implementation of `GenesisBuild::build_storage`. /// diff --git a/pallets/funding/src/traits.rs b/pallets/funding/src/traits.rs index b93e4d1b0..175f3e2ba 100644 --- a/pallets/funding/src/traits.rs +++ b/pallets/funding/src/traits.rs @@ -24,12 +24,12 @@ pub trait DoRemainingOperation { fn do_one_operation(&mut self, project_id: T::ProjectIdentifier) -> Result; } -#[cfg(feature = "runtime-benchmarks")] +#[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] pub trait SetPrices { fn set_prices(); } -#[cfg(feature = "runtime-benchmarks")] +#[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] impl SetPrices for () { fn set_prices() {} } diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index f706d6318..06eaf3504 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -71,13 +71,13 @@ use pallet_funding::{BondTypeOf, DaysToBlocks}; pub use pallet_parachain_staking; pub use shared_configuration::*; -#[cfg(feature = "runtime-benchmarks")] +#[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] use pallet_funding::AcceptedFundingAsset; -#[cfg(feature = "runtime-benchmarks")] +#[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] use frame_support::BoundedVec; -#[cfg(feature = "runtime-benchmarks")] +#[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] use pallet_funding::traits::SetPrices; pub type NegativeImbalanceOf = @@ -145,9 +145,9 @@ pub fn native_version() -> NativeVersion { NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } } -#[cfg(feature = "runtime-benchmarks")] +#[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] pub struct SetOraclePrices; -#[cfg(feature = "runtime-benchmarks")] +#[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] impl SetPrices for SetOraclePrices { fn set_prices() { let dot = (AcceptedFundingAsset::DOT.to_statemint_id(), FixedU128::from_rational(69, 1)); @@ -551,7 +551,8 @@ impl ConvertBack for ConvertSelf { } impl pallet_funding::Config for Runtime { type AccountId32Conversion = ConvertSelf; - type AllPalletsWithoutSystem = (Balances, LocalAssets, StatemintAssets, PolimecFunding, LinearVesting, Random); + type AllPalletsWithoutSystem = + (Balances, LocalAssets, StatemintAssets, Oracle, PolimecFunding, LinearVesting, Random); type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; type Balance = Balance; type BlockNumber = BlockNumber; @@ -589,7 +590,7 @@ impl pallet_funding::Config for Runtime { type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; - #[cfg(feature = "runtime-benchmarks")] + #[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] type SetPrices = SetOraclePrices; type StringLimit = ConstU32<64>; type SuccessToSettlementTime = SuccessToSettlementTime; @@ -705,6 +706,9 @@ construct_runtime!( AuraExt: cumulus_pallet_aura_ext::{Pallet, Storage, Config} = 24, ParachainStaking: pallet_parachain_staking::{Pallet, Call, Storage, Event, Config} = 25, + // Oracle + Oracle: orml_oracle:: = 30, + OracleProvidersMembership: pallet_membership:: = 31, // Governance Treasury: pallet_treasury = 40, @@ -721,9 +725,7 @@ construct_runtime!( Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 61, Random: pallet_insecure_randomness_collective_flip = 62, - // Oracle - Oracle: orml_oracle:: = 70, - OracleProvidersMembership: pallet_membership:: = 71, + // Among others: Send and receive DMP and XCMP messages. ParachainSystem: cumulus_pallet_parachain_system = 80, diff --git a/scripts/zombienet/native/hrmpless-rococo-statemint-polimec-penpal.toml b/scripts/zombienet/native/hrmpless-rococo-statemint-polimec-penpal.toml index cd4ea1cab..c23809241 100644 --- a/scripts/zombienet/native/hrmpless-rococo-statemint-polimec-penpal.toml +++ b/scripts/zombienet/native/hrmpless-rococo-statemint-polimec-penpal.toml @@ -33,7 +33,7 @@ chain = "statemint-local" [[parachains.collators]] name = "statemint-dev" command = "../cumulus/target/release/polkadot-parachain" - args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] + args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] ws_port = 7777 @@ -52,5 +52,5 @@ chain = "penpal-polkadot-3000" [[parachains.collators]] name = "penpal-collator" command = "../cumulus/target/release/polkadot-parachain" - args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] + args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] ws_port = 9999 \ No newline at end of file From 8a525ca73e7ea9883aed03ed2ee5e490f500a87f Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 18 Dec 2023 18:28:04 +0100 Subject: [PATCH 080/212] save --- nodes/parachain/src/chain_spec/testnet.rs | 90 ++++++++++----------- pallets/funding/src/instantiator.rs | 4 +- pallets/funding/src/lib.rs | 95 ++++++++++++++++++----- 3 files changed, 125 insertions(+), 64 deletions(-) diff --git a/nodes/parachain/src/chain_spec/testnet.rs b/nodes/parachain/src/chain_spec/testnet.rs index ae157e242..2b16e0fdc 100644 --- a/nodes/parachain/src/chain_spec/testnet.rs +++ b/nodes/parachain/src/chain_spec/testnet.rs @@ -443,51 +443,51 @@ fn testing_genesis( community_contributions: community_contributions.clone(), remainder_contributions: remainder_contributions.clone(), }, - TestProjectParams:: { - expected_state: ProjectStatus::RemainderRound, - metadata: default_project(ISSUER.into(), 1u32), - issuer: ISSUER.into(), - evaluations: evaluations.clone(), - bids: bids.clone(), - community_contributions: community_contributions.clone(), - remainder_contributions: vec![], - }, - TestProjectParams:: { - expected_state: ProjectStatus::CommunityRound, - metadata: default_project(ISSUER.into(), 2u32), - issuer: ISSUER.into(), - evaluations: evaluations.clone(), - bids: bids.clone(), - community_contributions: vec![], - remainder_contributions: vec![], - }, - TestProjectParams:: { - expected_state: ProjectStatus::AuctionRound(AuctionPhase::English), - metadata: default_project(ISSUER.into(), 3u32), - issuer: ISSUER.into(), - evaluations: evaluations.clone(), - bids: vec![], - community_contributions: vec![], - remainder_contributions: vec![], - }, - TestProjectParams:: { - expected_state: ProjectStatus::EvaluationRound, - metadata: default_project(ISSUER.into(), 4u32), - issuer: ISSUER.into(), - evaluations: vec![], - bids: vec![], - community_contributions: vec![], - remainder_contributions: vec![], - }, - TestProjectParams:: { - expected_state: ProjectStatus::Application, - metadata: default_project(ISSUER.into(), 5u32), - issuer: ISSUER.into(), - evaluations: vec![], - bids: vec![], - community_contributions: vec![], - remainder_contributions: vec![], - }, + // TestProjectParams:: { + // expected_state: ProjectStatus::RemainderRound, + // metadata: default_project(ISSUER.into(), 1u32), + // issuer: ISSUER.into(), + // evaluations: evaluations.clone(), + // bids: bids.clone(), + // community_contributions: community_contributions.clone(), + // remainder_contributions: vec![], + // }, + // TestProjectParams:: { + // expected_state: ProjectStatus::CommunityRound, + // metadata: default_project(ISSUER.into(), 2u32), + // issuer: ISSUER.into(), + // evaluations: evaluations.clone(), + // bids: bids.clone(), + // community_contributions: vec![], + // remainder_contributions: vec![], + // }, + // TestProjectParams:: { + // expected_state: ProjectStatus::AuctionRound(AuctionPhase::English), + // metadata: default_project(ISSUER.into(), 3u32), + // issuer: ISSUER.into(), + // evaluations: evaluations.clone(), + // bids: vec![], + // community_contributions: vec![], + // remainder_contributions: vec![], + // }, + // TestProjectParams:: { + // expected_state: ProjectStatus::EvaluationRound, + // metadata: default_project(ISSUER.into(), 4u32), + // issuer: ISSUER.into(), + // evaluations: vec![], + // bids: vec![], + // community_contributions: vec![], + // remainder_contributions: vec![], + // }, + // TestProjectParams:: { + // expected_state: ProjectStatus::Application, + // metadata: default_project(ISSUER.into(), 5u32), + // issuer: ISSUER.into(), + // evaluations: vec![], + // bids: vec![], + // community_contributions: vec![], + // remainder_contributions: vec![], + // }, ], phantom: PhantomData, }, diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index ec0d75695..752ed2ca0 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -2292,7 +2292,9 @@ pub mod async_features { ::CandleAuctionDuration::get(); let time_to_remainder: BlockNumberFor = time_to_community + ::CommunityFundingDuration::get(); let time_to_finish: BlockNumberFor = time_to_remainder + ::RemainderFundingDuration::get(); - let now = mutex_inst.lock().await.current_block(); + let mut inst = mutex_inst.lock().await; + let now = inst.current_block(); + drop(inst); match test_project_params.expected_state { ProjectStatus::Application => { diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 8f57bf158..ccb11b769 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -264,6 +264,9 @@ pub mod pallet { use frame_system::pallet_prelude::*; use sp_arithmetic::Percent; use sp_runtime::traits::{Convert, ConvertBack}; + use frame_support::traits::OnFinalize; + use frame_support::traits::OnIdle; + use frame_support::traits::OnInitialize; use local_macros::*; @@ -279,14 +282,16 @@ pub mod pallet { #[pallet::config] pub trait Config: - frame_system::Config + pallet_balances::Config> + pallet_xcm::Config + frame_system::Config + pallet_balances::Config> + pallet_xcm::Config + Send + Sync { #[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] type SetPrices: SetPrices; - type AllPalletsWithoutSystem: frame_support::traits::OnFinalize> - + frame_support::traits::OnIdle> - + frame_support::traits::OnInitialize>; + type AllPalletsWithoutSystem: OnFinalize> + + OnIdle> + + OnInitialize> + //testing-node + + Send + Sync; type RuntimeEvent: From> + TryInto> @@ -305,7 +310,9 @@ pub mod pallet { type RuntimeCall: Parameter + IsType<::RuntimeCall> + From>; /// Global identifier for the projects. - type ProjectIdentifier: Parameter + Copy + Default + One + Saturating + From + Ord + MaxEncodedLen; + type ProjectIdentifier: Parameter + Copy + Default + One + Saturating + From + Ord + MaxEncodedLen + //testing-node + + Send + Sync; // TODO: PLMC-153 + MaybeSerializeDeserialize: Maybe needed for JSON serialization @ Genesis: https://github.com/paritytech/substrate/issues/12738#issuecomment-1320921201 /// Multiplier that decides how much PLMC needs to be bonded for a token buy/bid @@ -316,13 +323,19 @@ pub mod pallet { + Copy + TryFrom + MaxEncodedLen - + MaybeSerializeDeserialize; + + MaybeSerializeDeserialize + //testing-node + + Send + Sync; /// The inner balance type we will use for all of our outer currency types. (e.g native, funding, CTs) - type Balance: Balance + From + FixedPointOperand + MaybeSerializeDeserialize + Into; + type Balance: Balance + From + FixedPointOperand + MaybeSerializeDeserialize + Into + //testing-node + + Send + Sync; /// Represents the value of something in USD - type Price: FixedPointNumber + Parameter + Copy + MaxEncodedLen + MaybeSerializeDeserialize; + type Price: FixedPointNumber + Parameter + Copy + MaxEncodedLen + MaybeSerializeDeserialize + //testing-node + + Send + Sync; /// The chains native currency type NativeCurrency: fungible::InspectHold, Balance = BalanceOf> @@ -355,7 +368,9 @@ pub mod pallet { /// The maximum length of data stored on-chain. #[pallet::constant] - type StringLimit: Get; + type StringLimit: Get + //testing-node + + Send + Sync; /// The maximum size of a preimage allowed, expressed in bytes. #[pallet::constant] @@ -1354,16 +1369,49 @@ pub mod pallet { } } + #[cfg(all(feature = "testing-node", feature = "std"))] use crate::instantiator::async_features::create_multiple_projects_at; #[cfg(all(feature = "testing-node", feature = "std"))] use crate::instantiator::TestProjectParams; - #[cfg(all(feature = "testing-node", feature = "std"))] - use frame_support::traits::{OnFinalize, OnIdle, OnInitialize, OriginTrait}; + use pallet_xcm::ensure_response; #[pallet::genesis_config] + #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr( + feature = "std", + serde(rename_all = "camelCase", deny_unknown_fields, bound(serialize = ""), bound(deserialize = "")) + )] + #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode)] + #[cfg(not(all(feature = "testing-node", feature = "std")))] pub struct GenesisConfig { - #[cfg(all(feature = "testing-node", feature = "std"))] + pub phantom: PhantomData, + } + + #[cfg(all(feature = "testing-node", feature = "std"))] + #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] + #[cfg_attr( + feature = "std", + serde(rename_all = "camelCase", deny_unknown_fields, bound(serialize = ""), bound(deserialize = "")) + )] + #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode)] + pub struct GenesisConfig + where + T: Config + pallet_balances::Config>, + ::AllPalletsWithoutSystem: OnFinalize> + + OnIdle> + + OnInitialize> + + Sync + + Send + + 'static, + ::RuntimeEvent: From> + TryInto> + Parameter + Member, + ::Balance: Into>, + ::ProjectIdentifier: Send + Sync, + ::Balance: Send + Sync, + ::Price: Send + Sync, + ::StringLimit: Send + Sync, + ::Multiplier: Send + Sync, + { pub starting_projects: Vec>, pub phantom: PhantomData, } @@ -1372,9 +1420,20 @@ pub mod pallet { impl Default for GenesisConfig where T: Config + pallet_balances::Config>, - T::AllPalletsWithoutSystem: - OnFinalize> + OnIdle> + OnInitialize>, + ::AllPalletsWithoutSystem: OnFinalize> + + OnIdle> + + OnInitialize> + + Sync + + Send + + 'static, ::RuntimeEvent: From> + TryInto> + Parameter + Member, + // AccountIdOf: Into< as OriginTrait>::AccountId> + sp_std::fmt::Debug, + ::Balance: Into>, + ::ProjectIdentifier: Send + Sync, + ::Balance: Send + Sync, + ::Price: Send + Sync, + ::StringLimit: Send + Sync, + ::Multiplier: Send + Sync, { fn default() -> Self { Self { starting_projects: vec![], phantom: PhantomData } @@ -1395,9 +1454,9 @@ pub mod pallet { } #[cfg(all(feature = "testing-node", feature = "std"))] - impl BuildGenesisConfig for GenesisConfig + impl BuildGenesisConfig for GenesisConfig where - T: Config + pallet_balances::Config> + Sync + Send, + T: Config + pallet_balances::Config>, ::AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize> @@ -1405,7 +1464,6 @@ pub mod pallet { + Send + 'static, ::RuntimeEvent: From> + TryInto> + Parameter + Member, - // AccountIdOf: Into< as OriginTrait>::AccountId> + sp_std::fmt::Debug, ::Balance: Into>, ::ProjectIdentifier: Send + Sync, ::Balance: Send + Sync, @@ -1419,6 +1477,7 @@ pub mod pallet { instantiator::Instantiator::AllPalletsWithoutSystem, ::RuntimeEvent>; let mut inst = GenesisInstantiator::::new(None); ::SetPrices::set_prices(); + let current_block = >::block_number(); create_multiple_projects_at(inst, self.starting_projects.clone()); } } @@ -1426,7 +1485,7 @@ pub mod pallet { #[cfg(all(feature = "testing-node", feature = "std"))] impl GenesisConfig where - T: Config + pallet_balances::Config> + Sync + Send, + T: Config + pallet_balances::Config>, ::AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize> From 937a97f97c94556e9116eb0caeb5df077c9e8afa Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 3 Jan 2024 15:55:15 +0100 Subject: [PATCH 081/212] conditionally adding genesis config --- integration-tests/src/lib.rs | 2 +- nodes/parachain/src/chain_spec/testnet.rs | 3 +- pallets/funding/src/genesis_config.rs | 118 +++++++++++++++ pallets/funding/src/lib.rs | 142 +----------------- runtimes/testnet/src/lib.rs | 63 +++++++- ...pless-rococo-statemint-polimec-penpal.toml | 34 ++--- 6 files changed, 203 insertions(+), 159 deletions(-) create mode 100644 pallets/funding/src/genesis_config.rs diff --git a/integration-tests/src/lib.rs b/integration-tests/src/lib.rs index 23e9bb666..86fa3a886 100644 --- a/integration-tests/src/lib.rs +++ b/integration-tests/src/lib.rs @@ -13,10 +13,10 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#![cfg(all(test, feature = "std", feature = "testing-node"))] pub mod constants; -#[cfg(all(test, feature = "std", feature = "testing-node"))] mod tests; pub use constants::{accounts::*, penpal, polimec, polkadot, statemint}; diff --git a/nodes/parachain/src/chain_spec/testnet.rs b/nodes/parachain/src/chain_spec/testnet.rs index 2b16e0fdc..92909c99e 100644 --- a/nodes/parachain/src/chain_spec/testnet.rs +++ b/nodes/parachain/src/chain_spec/testnet.rs @@ -214,7 +214,6 @@ fn testnet_genesis( .push((::PalletId::get().into_account_truncating(), EXISTENTIAL_DEPOSIT)); RuntimeGenesisConfig { system: SystemConfig { code: wasm_binary.to_vec(), ..Default::default() }, - polimec_funding: Default::default(), balances: BalancesConfig { balances: endowed_accounts.clone() }, statemint_assets: StatemintAssetsConfig { assets: vec![( @@ -236,6 +235,8 @@ fn testnet_genesis( blocks_per_round: BLOCKS_PER_ROUND, num_selected_candidates: NUM_SELECTED_CANDIDATES, }, + #[cfg(all(feature = "testing-node", feature = "std"))] + polimec_funding: Default::default(), // no need to pass anything to aura, in fact it will panic if we do. Session will take care // of this. aura: Default::default(), diff --git a/pallets/funding/src/genesis_config.rs b/pallets/funding/src/genesis_config.rs new file mode 100644 index 000000000..3e051489e --- /dev/null +++ b/pallets/funding/src/genesis_config.rs @@ -0,0 +1,118 @@ +use frame_support::pallet_macros::*; + +#[cfg(all(feature = "testing-node", feature = "std"))] +#[pallet_section] +mod genesis_config { + use crate::instantiator::async_features::create_multiple_projects_at; + use crate::instantiator::TestProjectParams; + use sp_std::marker::PhantomData; + use frame_support::dispatch::{Decode, Encode}; + use frame_support::pallet_prelude::BuildGenesisConfig; + use frame_support::Parameter; + use frame_system::pallet_prelude::BlockNumberFor; + use sp_runtime::traits::Member; + use crate::{BalanceOf, instantiator, pallet}; + + #[pallet::genesis_config] + #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode)] + pub struct GenesisConfig + where + T: Config + pallet_balances::Config>, + ::AllPalletsWithoutSystem: OnFinalize> + + OnIdle> + + OnInitialize> + + Sync + + Send + + 'static, + ::RuntimeEvent: From> + TryInto> + Parameter + Member, + ::Balance: Into>, + ::ProjectIdentifier: Send + Sync, + ::Balance: Send + Sync, + ::Price: Send + Sync, + ::StringLimit: Send + Sync, + ::Multiplier: Send + Sync, + { + pub starting_projects: Vec>, + pub phantom: PhantomData, + } + + impl Default for GenesisConfig + where + T: Config + pallet_balances::Config>, + ::AllPalletsWithoutSystem: OnFinalize> + + OnIdle> + + OnInitialize> + + Sync + + Send + + 'static, + ::RuntimeEvent: From> + TryInto> + Parameter + Member, + ::Balance: Into>, + ::ProjectIdentifier: Send + Sync, + ::Balance: Send + Sync, + ::Price: Send + Sync, + ::StringLimit: Send + Sync, + ::Multiplier: Send + Sync, + { + fn default() -> Self { + Self { starting_projects: vec![], phantom: PhantomData } + } + } + + #[pallet::genesis_build] + impl BuildGenesisConfig for GenesisConfig + where + T: Config + pallet_balances::Config>, + ::AllPalletsWithoutSystem: OnFinalize> + + OnIdle> + + OnInitialize> + + Sync + + Send + + 'static, + ::RuntimeEvent: From> + TryInto> + Parameter + Member, + ::Balance: Into>, + ::ProjectIdentifier: Send + Sync, + ::Balance: Send + Sync, + ::Price: Send + Sync, + ::StringLimit: Send + Sync, + ::Multiplier: Send + Sync, + { + fn build(&self) { + { + type GenesisInstantiator = + instantiator::Instantiator::AllPalletsWithoutSystem, ::RuntimeEvent>; + let mut inst = GenesisInstantiator::::new(None); + ::SetPrices::set_prices(); + let current_block = >::block_number(); + create_multiple_projects_at(inst, self.starting_projects.clone()); + } + } + } + impl GenesisConfig + where + T: Config + pallet_balances::Config>, + ::AllPalletsWithoutSystem: OnFinalize> + + OnIdle> + + OnInitialize> + + Sync + + Send + + 'static, + ::RuntimeEvent: From> + TryInto> + Parameter + Member, + ::Balance: Into>, + ::ProjectIdentifier: Send + Sync, + ::Balance: Send + Sync, + ::Price: Send + Sync, + ::StringLimit: Send + Sync, + ::Multiplier: Send + Sync, + { + /// Direct implementation of `GenesisBuild::build_storage`. + /// + /// Kept in order not to break dependency. + pub fn build(&self) { + ::build(self) + } + } +} + +#[cfg(not(all(feature = "testing-node", feature = "std")))] +#[pallet_section] +mod genesis_config {} \ No newline at end of file diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index ccb11b769..f8458950b 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -191,11 +191,10 @@ use sp_runtime::{traits::AccountIdConversion, FixedPointNumber, FixedPointOperan use sp_std::{marker::PhantomData, prelude::*}; pub use types::*; use xcm::v3::{opaque::Instruction, prelude::*, SendXcm}; - +use frame_support::pallet_macros::*; pub mod functions; pub mod types; pub mod weights; - #[cfg(test)] pub mod mock; @@ -208,6 +207,7 @@ pub mod impls; #[cfg(any(feature = "runtime-benchmarks", test, all(feature = "testing-node", feature = "std")))] pub mod instantiator; pub mod traits; +mod genesis_config; pub type AccountIdOf = ::AccountId; pub type ProjectIdOf = ::ProjectIdentifier; @@ -258,6 +258,7 @@ pub type WeightInfoOf = ::WeightInfo; pub const PLMC_STATEMINT_ID: u32 = 2069; +#[import_section(genesis_config::genesis_config)] #[frame_support::pallet] pub mod pallet { use frame_support::pallet_prelude::*; @@ -1368,145 +1369,8 @@ pub mod pallet { max_weight.saturating_sub(remaining_weight) } } - - #[cfg(all(feature = "testing-node", feature = "std"))] - use crate::instantiator::async_features::create_multiple_projects_at; - #[cfg(all(feature = "testing-node", feature = "std"))] - use crate::instantiator::TestProjectParams; - use pallet_xcm::ensure_response; - #[pallet::genesis_config] - #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] - #[cfg_attr( - feature = "std", - serde(rename_all = "camelCase", deny_unknown_fields, bound(serialize = ""), bound(deserialize = "")) - )] - #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode)] - #[cfg(not(all(feature = "testing-node", feature = "std")))] - pub struct GenesisConfig { - pub phantom: PhantomData, - } - - #[cfg(all(feature = "testing-node", feature = "std"))] - #[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))] - #[cfg_attr( - feature = "std", - serde(rename_all = "camelCase", deny_unknown_fields, bound(serialize = ""), bound(deserialize = "")) - )] - #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode)] - pub struct GenesisConfig - where - T: Config + pallet_balances::Config>, - ::AllPalletsWithoutSystem: OnFinalize> - + OnIdle> - + OnInitialize> - + Sync - + Send - + 'static, - ::RuntimeEvent: From> + TryInto> + Parameter + Member, - ::Balance: Into>, - ::ProjectIdentifier: Send + Sync, - ::Balance: Send + Sync, - ::Price: Send + Sync, - ::StringLimit: Send + Sync, - ::Multiplier: Send + Sync, - { - pub starting_projects: Vec>, - pub phantom: PhantomData, - } - - #[cfg(all(feature = "testing-node", feature = "std"))] - impl Default for GenesisConfig - where - T: Config + pallet_balances::Config>, - ::AllPalletsWithoutSystem: OnFinalize> - + OnIdle> - + OnInitialize> - + Sync - + Send - + 'static, - ::RuntimeEvent: From> + TryInto> + Parameter + Member, - // AccountIdOf: Into< as OriginTrait>::AccountId> + sp_std::fmt::Debug, - ::Balance: Into>, - ::ProjectIdentifier: Send + Sync, - ::Balance: Send + Sync, - ::Price: Send + Sync, - ::StringLimit: Send + Sync, - ::Multiplier: Send + Sync, - { - fn default() -> Self { - Self { starting_projects: vec![], phantom: PhantomData } - } - } - - #[cfg(not(all(feature = "testing-node", feature = "std")))] - impl Default for GenesisConfig { - fn default() -> Self { - Self { phantom: PhantomData } - } - } - - #[pallet::genesis_build] - #[cfg(not(all(feature = "testing-node", feature = "std")))] - impl BuildGenesisConfig for GenesisConfig { - fn build(&self) {} - } - - #[cfg(all(feature = "testing-node", feature = "std"))] - impl BuildGenesisConfig for GenesisConfig - where - T: Config + pallet_balances::Config>, - ::AllPalletsWithoutSystem: OnFinalize> - + OnIdle> - + OnInitialize> - + Sync - + Send - + 'static, - ::RuntimeEvent: From> + TryInto> + Parameter + Member, - ::Balance: Into>, - ::ProjectIdentifier: Send + Sync, - ::Balance: Send + Sync, - ::Price: Send + Sync, - ::StringLimit: Send + Sync, - ::Multiplier: Send + Sync, - { - fn build(&self) { - { - type GenesisInstantiator = - instantiator::Instantiator::AllPalletsWithoutSystem, ::RuntimeEvent>; - let mut inst = GenesisInstantiator::::new(None); - ::SetPrices::set_prices(); - let current_block = >::block_number(); - create_multiple_projects_at(inst, self.starting_projects.clone()); - } - } - } - #[cfg(all(feature = "testing-node", feature = "std"))] - impl GenesisConfig - where - T: Config + pallet_balances::Config>, - ::AllPalletsWithoutSystem: OnFinalize> - + OnIdle> - + OnInitialize> - + Sync - + Send - + 'static, - ::RuntimeEvent: From> + TryInto> + Parameter + Member, - ::Balance: Into>, - ::ProjectIdentifier: Send + Sync, - ::Balance: Send + Sync, - ::Price: Send + Sync, - ::StringLimit: Send + Sync, - ::Multiplier: Send + Sync, - { - /// Direct implementation of `GenesisBuild::build_storage`. - /// - /// Kept in order not to break dependency. - pub fn build(&self) { - ::build(self) - } - } } pub mod xcm_executor_impl { diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 06eaf3504..5e2f72e5b 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -680,7 +680,7 @@ impl orml_oracle::Config for Runtime { } // Create the runtime by composing the FRAME pallets that were previously configured. - +#[cfg(all(feature = "testing-node", feature = "std"))] construct_runtime!( pub enum Runtime { @@ -727,6 +727,67 @@ construct_runtime!( + // Among others: Send and receive DMP and XCMP messages. + ParachainSystem: cumulus_pallet_parachain_system = 80, + ParachainInfo: parachain_info::{Pallet, Storage, Config} = 81, + // Wrap and unwrap XCMP messages to send and receive them. Queue them for later processing. + XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event} = 82, + // Build XCM scripts. + PolkadotXcm: pallet_xcm::{Pallet, Call, Event, Origin, Config} = 83, + // Does nothing cool, just provides an origin. + CumulusXcm: cumulus_pallet_xcm::{Pallet, Event, Origin} = 84, + // Queue and pass DMP messages on to be executed. + DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event} = 85, + } +); + +#[cfg(not(all(feature = "testing-node", feature = "std")))] +construct_runtime!( + pub enum Runtime + { + // System support stuff. + System: frame_system::{Pallet, Call, Config, Storage, Event} = 0, + Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 2, + Sudo: pallet_sudo = 4, + Utility: pallet_utility::{Pallet, Call, Event} = 5, + Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 6, + + // Monetary stuff. + Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 10, + TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event} = 11, + AssetTxPayment: pallet_asset_tx_payment::{Pallet, Storage, Event} = 12, + LocalAssets: pallet_assets::::{Pallet, Storage, Event} = 13, + StatemintAssets: pallet_assets::::{Pallet, Call, Config, Storage, Event} = 14, + + + // Collator support. the order of these 5 are important and shall not change. + Authorship: pallet_authorship::{Pallet, Storage} = 20, + Session: pallet_session::{Pallet, Call, Storage, Event, Config} = 22, + Aura: pallet_aura::{Pallet, Storage, Config} = 23, + AuraExt: cumulus_pallet_aura_ext::{Pallet, Storage, Config} = 24, + ParachainStaking: pallet_parachain_staking::{Pallet, Call, Storage, Event, Config} = 25, + + // Oracle + Oracle: orml_oracle:: = 30, + OracleProvidersMembership: pallet_membership:: = 31, + + // Governance + Treasury: pallet_treasury = 40, + Democracy: pallet_democracy = 41, + Council: pallet_collective:: = 42, + TechnicalCommittee: pallet_collective:: = 43, + Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 44, + + // Polimec Core + PolimecFunding: pallet_funding::{Pallet, Call, Storage, Event} = 52, + LinearVesting: pallet_linear_release::{Pallet, Call, Storage, Event, Config} = 53, + + // Utilities + Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 61, + Random: pallet_insecure_randomness_collective_flip = 62, + + + // Among others: Send and receive DMP and XCMP messages. ParachainSystem: cumulus_pallet_parachain_system = 80, ParachainInfo: parachain_info::{Pallet, Storage, Config} = 81, diff --git a/scripts/zombienet/native/hrmpless-rococo-statemint-polimec-penpal.toml b/scripts/zombienet/native/hrmpless-rococo-statemint-polimec-penpal.toml index c23809241..821f2786d 100644 --- a/scripts/zombienet/native/hrmpless-rococo-statemint-polimec-penpal.toml +++ b/scripts/zombienet/native/hrmpless-rococo-statemint-polimec-penpal.toml @@ -26,15 +26,15 @@ chain = "rococo-local" [[relaychain.nodes]] name = "ferdie" -[[parachains]] -id = 1000 -chain = "statemint-local" - - [[parachains.collators]] - name = "statemint-dev" - command = "../cumulus/target/release/polkadot-parachain" - args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] - ws_port = 7777 +#[[parachains]] +#id = 1000 +#chain = "statemint-local" +# +# [[parachains.collators]] +# name = "statemint-dev" +# command = "../cumulus/target/release/polkadot-parachain" +# args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] +# ws_port = 7777 [[parachains]] @@ -46,11 +46,11 @@ chain = "polimec-testing" args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] ws_port = 8888 -[[parachains]] -id = 3000 -chain = "penpal-polkadot-3000" - [[parachains.collators]] - name = "penpal-collator" - command = "../cumulus/target/release/polkadot-parachain" - args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] - ws_port = 9999 \ No newline at end of file +#[[parachains]] +#id = 3000 +#chain = "penpal-polkadot-3000" +# [[parachains.collators]] +# name = "penpal-collator" +# command = "../cumulus/target/release/polkadot-parachain" +# args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] +# ws_port = 9999 \ No newline at end of file From 59dc6e8ed4d955058b36f6a9398811ff22061bb0 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 3 Jan 2024 17:52:33 +0100 Subject: [PATCH 082/212] Fixed the externalities issue by using the single threaded tokio runtime. added check for asking more remainder CT buys that are available --- pallets/funding/src/genesis_config.rs | 1 + pallets/funding/src/instantiator.rs | 26 ++++++++++++++++++++++++-- pallets/funding/src/lib.rs | 2 ++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/pallets/funding/src/genesis_config.rs b/pallets/funding/src/genesis_config.rs index 3e051489e..9669ca55d 100644 --- a/pallets/funding/src/genesis_config.rs +++ b/pallets/funding/src/genesis_config.rs @@ -1,4 +1,5 @@ use frame_support::pallet_macros::*; +use frame_support::pallet_macros::pallet_section; #[cfg(all(feature = "testing-node", feature = "std"))] #[pallet_section] diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 752ed2ca0..85ca31491 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -2068,6 +2068,7 @@ pub mod async_features { community_contributions: Vec>, remainder_contributions: Vec>, ) -> ProjectIdOf { + println!("creating remainder project inside finished project"); let (project_id, accepted_bids) = async_create_remainder_contributing_project( instantiator.clone(), @@ -2085,6 +2086,18 @@ pub mod async_features { let mut inst = instantiator.lock().await; println!("lock given"); + let real_bid_amounts = inst.simulate_bids_with_bucket(bids.clone(), project_id); + let total_ct_sold_in_bids = real_bid_amounts.iter().map(|bid| bid.amount).fold(Zero::zero(), |acc, item| item + acc); + let total_ct_sold_in_community_contributions = community_contributions.iter().map(|cont| cont.amount).fold(Zero::zero(), |acc, item| item + acc); + let total_ct_sold_in_remainder_contributions = remainder_contributions.iter().map(|cont| cont.amount).fold(Zero::zero(), |acc, item| item + acc); + + let total_ct_sold = total_ct_sold_in_bids + total_ct_sold_in_community_contributions + total_ct_sold_in_remainder_contributions; + let total_ct_available = project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1; + assert!( + total_ct_sold <= total_ct_available, + "Some CT buys are getting less than expected due to running out of CTs. This is ok in the runtime, but likely unexpected from the parameters of this instantiation" + ); + match inst.get_project_details(project_id).status { ProjectStatus::FundingSuccessful => return project_id, ProjectStatus::RemainderRound if remainder_contributions.is_empty() => { @@ -2167,10 +2180,13 @@ pub mod async_features { inst.contribute_for_users(project_id, remainder_contributions.clone()) .expect("Remainder Contributing should work"); + let merged = total_plmc_participation_locked.merge_accounts(MergeOperation::Add); + inst.do_reserved_plmc_assertions( - total_plmc_participation_locked.merge_accounts(MergeOperation::Add), + merged, LockType::Participation(project_id), ); + inst.do_contribution_transferred_statemint_asset_assertions( funding_asset_deposits.merge_accounts(MergeOperation::Add), project_id, @@ -2415,7 +2431,13 @@ pub mod async_features { ::StringLimit: Send + Sync, ::Multiplier: Send + Sync, { - let tokio_runtime = Runtime::new().unwrap(); + // let tokio_runtime = Runtime::new().unwrap(); + + use tokio::runtime::Builder; + let tokio_runtime = Builder::new_current_thread() + .enable_all() + .build() + .unwrap(); tokio_runtime.block_on(async { let block_orchestrator = Arc::new(BlockOrchestrator::new()); diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index f8458950b..541a3baee 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -207,6 +207,8 @@ pub mod impls; #[cfg(any(feature = "runtime-benchmarks", test, all(feature = "testing-node", feature = "std")))] pub mod instantiator; pub mod traits; + + mod genesis_config; pub type AccountIdOf = ::AccountId; From c48caa57527aaec589d0e5918740e982348ec737 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 4 Jan 2024 10:00:24 +0100 Subject: [PATCH 083/212] removed conditional instantiator fields and conditional genesis config on pallet-funding. --- nodes/parachain/src/chain_spec/testnet.rs | 3 +- pallets/funding/src/genesis_config.rs | 236 ++++++++++++---------- pallets/funding/src/instantiator.rs | 48 ++--- pallets/funding/src/lib.rs | 63 ++++-- pallets/funding/src/mock.rs | 2 +- pallets/funding/src/tests.rs | 24 ++- runtimes/testnet/src/lib.rs | 122 +++++------ 7 files changed, 269 insertions(+), 229 deletions(-) diff --git a/nodes/parachain/src/chain_spec/testnet.rs b/nodes/parachain/src/chain_spec/testnet.rs index 92909c99e..971baf3a7 100644 --- a/nodes/parachain/src/chain_spec/testnet.rs +++ b/nodes/parachain/src/chain_spec/testnet.rs @@ -235,7 +235,6 @@ fn testnet_genesis( blocks_per_round: BLOCKS_PER_ROUND, num_selected_candidates: NUM_SELECTED_CANDIDATES, }, - #[cfg(all(feature = "testing-node", feature = "std"))] polimec_funding: Default::default(), // no need to pass anything to aura, in fact it will panic if we do. Session will take care // of this. @@ -414,7 +413,7 @@ fn testing_genesis( default_community_contributor_multipliers(), ); let remainder_contributions = GenesisInstantiator::generate_contributions_from_total_usd( - Percent::from_percent(30u8) * twenty_percent_funding_usd, + Percent::from_percent(20u8) * twenty_percent_funding_usd, min_price, default_weights(), default_remainder_contributors(), diff --git a/pallets/funding/src/genesis_config.rs b/pallets/funding/src/genesis_config.rs index 9669ca55d..5518545c0 100644 --- a/pallets/funding/src/genesis_config.rs +++ b/pallets/funding/src/genesis_config.rs @@ -1,119 +1,139 @@ -use frame_support::pallet_macros::*; -use frame_support::pallet_macros::pallet_section; +use frame_support::pallet_macros::{pallet_section, *}; #[cfg(all(feature = "testing-node", feature = "std"))] #[pallet_section] mod genesis_config { - use crate::instantiator::async_features::create_multiple_projects_at; - use crate::instantiator::TestProjectParams; - use sp_std::marker::PhantomData; - use frame_support::dispatch::{Decode, Encode}; - use frame_support::pallet_prelude::BuildGenesisConfig; - use frame_support::Parameter; - use frame_system::pallet_prelude::BlockNumberFor; - use sp_runtime::traits::Member; - use crate::{BalanceOf, instantiator, pallet}; + use crate::{ + instantiator, + instantiator::{async_features::create_multiple_projects_at, TestProjectParams}, + pallet, BalanceOf, + }; + use frame_support::{ + dispatch::{Decode, Encode}, + pallet_prelude::BuildGenesisConfig, + Parameter, + }; + use frame_system::pallet_prelude::BlockNumberFor; + use sp_runtime::traits::Member; + use sp_std::marker::PhantomData; - #[pallet::genesis_config] - #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode)] - pub struct GenesisConfig - where - T: Config + pallet_balances::Config>, - ::AllPalletsWithoutSystem: OnFinalize> - + OnIdle> - + OnInitialize> - + Sync - + Send - + 'static, - ::RuntimeEvent: From> + TryInto> + Parameter + Member, - ::Balance: Into>, - ::ProjectIdentifier: Send + Sync, - ::Balance: Send + Sync, - ::Price: Send + Sync, - ::StringLimit: Send + Sync, - ::Multiplier: Send + Sync, - { - pub starting_projects: Vec>, - pub phantom: PhantomData, - } + #[pallet::genesis_config] + #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode)] + pub struct GenesisConfig + where + T: Config + pallet_balances::Config>, + ::AllPalletsWithoutSystem: OnFinalize> + + OnIdle> + + OnInitialize> + + Sync + + Send + + 'static, + ::RuntimeEvent: From> + TryInto> + Parameter + Member, + ::Balance: Into>, + ::ProjectIdentifier: Send + Sync, + ::Balance: Send + Sync, + ::Price: Send + Sync, + ::StringLimit: Send + Sync, + ::Multiplier: Send + Sync, + { + pub starting_projects: Vec>, + pub phantom: PhantomData, + } - impl Default for GenesisConfig - where - T: Config + pallet_balances::Config>, - ::AllPalletsWithoutSystem: OnFinalize> - + OnIdle> - + OnInitialize> - + Sync - + Send - + 'static, - ::RuntimeEvent: From> + TryInto> + Parameter + Member, - ::Balance: Into>, - ::ProjectIdentifier: Send + Sync, - ::Balance: Send + Sync, - ::Price: Send + Sync, - ::StringLimit: Send + Sync, - ::Multiplier: Send + Sync, - { - fn default() -> Self { - Self { starting_projects: vec![], phantom: PhantomData } - } - } + impl Default for GenesisConfig + where + T: Config + pallet_balances::Config>, + ::AllPalletsWithoutSystem: OnFinalize> + + OnIdle> + + OnInitialize> + + Sync + + Send + + 'static, + ::RuntimeEvent: From> + TryInto> + Parameter + Member, + ::Balance: Into>, + ::ProjectIdentifier: Send + Sync, + ::Balance: Send + Sync, + ::Price: Send + Sync, + ::StringLimit: Send + Sync, + ::Multiplier: Send + Sync, + { + fn default() -> Self { + Self { starting_projects: vec![], phantom: PhantomData } + } + } - #[pallet::genesis_build] - impl BuildGenesisConfig for GenesisConfig - where - T: Config + pallet_balances::Config>, - ::AllPalletsWithoutSystem: OnFinalize> - + OnIdle> - + OnInitialize> - + Sync - + Send - + 'static, - ::RuntimeEvent: From> + TryInto> + Parameter + Member, - ::Balance: Into>, - ::ProjectIdentifier: Send + Sync, - ::Balance: Send + Sync, - ::Price: Send + Sync, - ::StringLimit: Send + Sync, - ::Multiplier: Send + Sync, - { - fn build(&self) { - { - type GenesisInstantiator = - instantiator::Instantiator::AllPalletsWithoutSystem, ::RuntimeEvent>; - let mut inst = GenesisInstantiator::::new(None); - ::SetPrices::set_prices(); - let current_block = >::block_number(); - create_multiple_projects_at(inst, self.starting_projects.clone()); - } - } - } - impl GenesisConfig - where - T: Config + pallet_balances::Config>, - ::AllPalletsWithoutSystem: OnFinalize> - + OnIdle> - + OnInitialize> - + Sync - + Send - + 'static, - ::RuntimeEvent: From> + TryInto> + Parameter + Member, - ::Balance: Into>, - ::ProjectIdentifier: Send + Sync, - ::Balance: Send + Sync, - ::Price: Send + Sync, - ::StringLimit: Send + Sync, - ::Multiplier: Send + Sync, - { - /// Direct implementation of `GenesisBuild::build_storage`. - /// - /// Kept in order not to break dependency. - pub fn build(&self) { - ::build(self) - } - } + #[pallet::genesis_build] + impl BuildGenesisConfig for GenesisConfig + where + T: Config + pallet_balances::Config>, + ::AllPalletsWithoutSystem: OnFinalize> + + OnIdle> + + OnInitialize> + + Sync + + Send + + 'static, + ::RuntimeEvent: From> + TryInto> + Parameter + Member, + ::Balance: Into>, + ::ProjectIdentifier: Send + Sync, + ::Balance: Send + Sync, + ::Price: Send + Sync, + ::StringLimit: Send + Sync, + ::Multiplier: Send + Sync, + { + fn build(&self) { + { + type GenesisInstantiator = + instantiator::Instantiator::AllPalletsWithoutSystem, ::RuntimeEvent>; + let mut inst = GenesisInstantiator::::new(None); + ::SetPrices::set_prices(); + let current_block = >::block_number(); + create_multiple_projects_at(inst, self.starting_projects.clone()); + } + } + } + impl GenesisConfig + where + T: Config + pallet_balances::Config>, + ::AllPalletsWithoutSystem: OnFinalize> + + OnIdle> + + OnInitialize> + + Sync + + Send + + 'static, + ::RuntimeEvent: From> + TryInto> + Parameter + Member, + ::Balance: Into>, + ::ProjectIdentifier: Send + Sync, + ::Balance: Send + Sync, + ::Price: Send + Sync, + ::StringLimit: Send + Sync, + ::Multiplier: Send + Sync, + { + /// Direct implementation of `GenesisBuild::build_storage`. + /// + /// Kept in order not to break dependency. + pub fn build(&self) { + ::build(self) + } + } } #[cfg(not(all(feature = "testing-node", feature = "std")))] #[pallet_section] -mod genesis_config {} \ No newline at end of file +mod genesis_config { + #[pallet::genesis_config] + pub struct GenesisConfig { + phantom: PhantomData, + } + + impl Default for GenesisConfig { + fn default() -> Self { + Self {phantom: PhantomData} + } + } + + #[pallet::genesis_build] + impl BuildGenesisConfig for GenesisConfig { + fn build(&self) {} + } + +} diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 85ca31491..4c53fb6c8 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -72,10 +72,7 @@ pub struct Instantiator< AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, > { - #[cfg(all(feature = "std", not(feature = "testing-node")))] ext: Option>, - #[cfg(not(all(feature = "std", not(feature = "testing-node"))))] - ext: Option<()>, nonce: RefCell, _marker: PhantomData<(T, AllPalletsWithoutSystem, RuntimeEvent)>, } @@ -88,27 +85,25 @@ impl< > Instantiator { pub fn new( - #[cfg(all(feature = "std", not(feature = "testing-node")))] ext: Option>, - #[cfg(not(all(feature = "std", not(feature = "testing-node"))))] ext: Option<()>, + ext: Option>, ) -> Self { Self { ext, nonce: RefCell::new(0u64), _marker: PhantomData } } pub fn set_ext( &mut self, - #[cfg(all(feature = "std", not(feature = "testing-node")))] ext: Option>, - #[cfg(not(all(feature = "std", not(feature = "testing-node"))))] ext: Option<()>, + ext: Option>, ) { self.ext = ext; } pub fn execute(&mut self, execution: impl FnOnce() -> R) -> R { - #[cfg(all(feature = "std", not(feature = "testing-node")))] if let Some(ext) = &self.ext { return ext.borrow_mut().execute_with(execution) + } else { + execution() } - execution() } pub fn get_new_nonce(&self) -> u64 { @@ -1395,7 +1390,6 @@ pub mod async_features { time::Duration, }; use tokio::{ - runtime::Runtime, sync::{Mutex, Notify}, time::sleep, }; @@ -2068,7 +2062,6 @@ pub mod async_features { community_contributions: Vec>, remainder_contributions: Vec>, ) -> ProjectIdOf { - println!("creating remainder project inside finished project"); let (project_id, accepted_bids) = async_create_remainder_contributing_project( instantiator.clone(), @@ -2087,11 +2080,15 @@ pub mod async_features { println!("lock given"); let real_bid_amounts = inst.simulate_bids_with_bucket(bids.clone(), project_id); - let total_ct_sold_in_bids = real_bid_amounts.iter().map(|bid| bid.amount).fold(Zero::zero(), |acc, item| item + acc); - let total_ct_sold_in_community_contributions = community_contributions.iter().map(|cont| cont.amount).fold(Zero::zero(), |acc, item| item + acc); - let total_ct_sold_in_remainder_contributions = remainder_contributions.iter().map(|cont| cont.amount).fold(Zero::zero(), |acc, item| item + acc); - - let total_ct_sold = total_ct_sold_in_bids + total_ct_sold_in_community_contributions + total_ct_sold_in_remainder_contributions; + let total_ct_sold_in_bids = + real_bid_amounts.iter().map(|bid| bid.amount).fold(Zero::zero(), |acc, item| item + acc); + let total_ct_sold_in_community_contributions = + community_contributions.iter().map(|cont| cont.amount).fold(Zero::zero(), |acc, item| item + acc); + let total_ct_sold_in_remainder_contributions = + remainder_contributions.iter().map(|cont| cont.amount).fold(Zero::zero(), |acc, item| item + acc); + + let total_ct_sold = + total_ct_sold_in_bids + total_ct_sold_in_community_contributions + total_ct_sold_in_remainder_contributions; let total_ct_available = project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1; assert!( total_ct_sold <= total_ct_available, @@ -2182,10 +2179,7 @@ pub mod async_features { let merged = total_plmc_participation_locked.merge_accounts(MergeOperation::Add); - inst.do_reserved_plmc_assertions( - merged, - LockType::Participation(project_id), - ); + inst.do_reserved_plmc_assertions(merged, LockType::Participation(project_id)); inst.do_contribution_transferred_statemint_asset_assertions( funding_asset_deposits.merge_accounts(MergeOperation::Add), @@ -2423,7 +2417,7 @@ pub mod async_features { >( instantiator: Instantiator, projects: Vec>, - ) -> Instantiator + ) -> (Vec>, Instantiator) where ::ProjectIdentifier: Send + Sync, ::Balance: Send + Sync, @@ -2434,10 +2428,7 @@ pub mod async_features { // let tokio_runtime = Runtime::new().unwrap(); use tokio::runtime::Builder; - let tokio_runtime = Builder::new_current_thread() - .enable_all() - .build() - .unwrap(); + let tokio_runtime = Builder::new_current_thread().enable_all().build().unwrap(); tokio_runtime.block_on(async { let block_orchestrator = Arc::new(BlockOrchestrator::new()); @@ -2452,7 +2443,7 @@ pub mod async_features { // Wait for all project creation tasks to complete let joined_project_futures = futures::future::join_all(project_futures); let controller_handle = tokio::spawn(block_controller(block_orchestrator.clone(), mutex_inst.clone())); - joined_project_futures.await; + let projects = joined_project_futures.await; // Now that all projects have been set up, signal the block_controller to stop block_orchestrator.should_continue.store(false, Ordering::SeqCst); @@ -2460,7 +2451,10 @@ pub mod async_features { // Wait for the block controller to finish controller_handle.await.unwrap(); - Arc::try_unwrap(mutex_inst).unwrap_or_else(|_| panic!("mutex in use")).into_inner() + let inst = Arc::try_unwrap(mutex_inst).unwrap_or_else(|_| panic!("mutex in use")).into_inner(); + let project_ids = projects.into_iter().map(|project| project.unwrap()).collect_vec(); + + (project_ids, inst) }) } } diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 541a3baee..13f7cbbf1 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -175,6 +175,7 @@ use crate::traits::DoRemainingOperation; pub use crate::weights::WeightInfo; use frame_support::{ + pallet_macros::*, traits::{ tokens::{fungible, fungibles, Balance}, AccountTouch, ContainsPair, Randomness, @@ -191,12 +192,11 @@ use sp_runtime::{traits::AccountIdConversion, FixedPointNumber, FixedPointOperan use sp_std::{marker::PhantomData, prelude::*}; pub use types::*; use xcm::v3::{opaque::Instruction, prelude::*, SendXcm}; -use frame_support::pallet_macros::*; pub mod functions; -pub mod types; -pub mod weights; #[cfg(test)] pub mod mock; +pub mod types; +pub mod weights; #[cfg(test)] pub mod tests; @@ -208,7 +208,6 @@ pub mod impls; pub mod instantiator; pub mod traits; - mod genesis_config; pub type AccountIdOf = ::AccountId; @@ -263,13 +262,13 @@ pub const PLMC_STATEMINT_ID: u32 = 2069; #[import_section(genesis_config::genesis_config)] #[frame_support::pallet] pub mod pallet { - use frame_support::pallet_prelude::*; + use frame_support::{ + pallet_prelude::*, + traits::{OnFinalize, OnIdle, OnInitialize}, + }; use frame_system::pallet_prelude::*; use sp_arithmetic::Percent; use sp_runtime::traits::{Convert, ConvertBack}; - use frame_support::traits::OnFinalize; - use frame_support::traits::OnIdle; - use frame_support::traits::OnInitialize; use local_macros::*; @@ -294,7 +293,8 @@ pub mod pallet { + OnIdle> + OnInitialize> //testing-node - + Send + Sync; + + Send + + Sync; type RuntimeEvent: From> + TryInto> @@ -313,9 +313,17 @@ pub mod pallet { type RuntimeCall: Parameter + IsType<::RuntimeCall> + From>; /// Global identifier for the projects. - type ProjectIdentifier: Parameter + Copy + Default + One + Saturating + From + Ord + MaxEncodedLen - //testing-node - + Send + Sync; + type ProjectIdentifier: Parameter + + Copy + + Default + + One + + Saturating + + From + + Ord + + MaxEncodedLen + //testing-node + + Send + + Sync; // TODO: PLMC-153 + MaybeSerializeDeserialize: Maybe needed for JSON serialization @ Genesis: https://github.com/paritytech/substrate/issues/12738#issuecomment-1320921201 /// Multiplier that decides how much PLMC needs to be bonded for a token buy/bid @@ -328,17 +336,28 @@ pub mod pallet { + MaxEncodedLen + MaybeSerializeDeserialize //testing-node - + Send + Sync; + + Send + + Sync; /// The inner balance type we will use for all of our outer currency types. (e.g native, funding, CTs) - type Balance: Balance + From + FixedPointOperand + MaybeSerializeDeserialize + Into - //testing-node - + Send + Sync; + type Balance: Balance + + From + + FixedPointOperand + + MaybeSerializeDeserialize + + Into + //testing-node + + Send + + Sync; /// Represents the value of something in USD - type Price: FixedPointNumber + Parameter + Copy + MaxEncodedLen + MaybeSerializeDeserialize - //testing-node - + Send + Sync; + type Price: FixedPointNumber + + Parameter + + Copy + + MaxEncodedLen + + MaybeSerializeDeserialize + //testing-node + + Send + + Sync; /// The chains native currency type NativeCurrency: fungible::InspectHold, Balance = BalanceOf> @@ -372,8 +391,9 @@ pub mod pallet { /// The maximum length of data stored on-chain. #[pallet::constant] type StringLimit: Get - //testing-node - + Send + Sync; + //testing-node + + Send + + Sync; /// The maximum size of a preimage allowed, expressed in bytes. #[pallet::constant] @@ -1372,7 +1392,6 @@ pub mod pallet { } } use pallet_xcm::ensure_response; - } pub mod xcm_executor_impl { diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index febaff87f..43865b44e 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -387,7 +387,7 @@ impl Config for TestRuntime { type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; - #[cfg(feature = "runtime-benchmarks")] + #[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] type SetPrices = (); type StringLimit = ConstU32<64>; type SuccessToSettlementTime = SuccessToSettlementTime; diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index b28d76f65..79766d938 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -5988,6 +5988,7 @@ mod async_tests { let mut inst = mutex_inst.lock().await; let events = inst.execute(|| frame_system::Pallet::::events()); + dbg!(events); dbg!(inst.get_project_details(0).status); dbg!(inst.get_project_details(1).status); dbg!(inst.get_project_details(2).status); @@ -6064,13 +6065,20 @@ mod async_tests { }, ]; - let mut inst = create_multiple_projects_at(inst, project_params); - - dbg!(inst.get_project_details(0).status); - dbg!(inst.get_project_details(1).status); - dbg!(inst.get_project_details(2).status); - dbg!(inst.get_project_details(3).status); - dbg!(inst.get_project_details(4).status); - dbg!(inst.get_project_details(5).status); + let (project_ids, mut inst) = create_multiple_projects_at(inst, project_params); + + dbg!(inst.get_project_details(project_ids[0]).status); + dbg!(inst.get_project_details(project_ids[1]).status); + dbg!(inst.get_project_details(project_ids[2]).status); + dbg!(inst.get_project_details(project_ids[3]).status); + dbg!(inst.get_project_details(project_ids[4]).status); + dbg!(inst.get_project_details(project_ids[5]).status); + + assert_eq!(inst.get_project_details(project_ids[0]).status, ProjectStatus::Application); + assert_eq!(inst.get_project_details(project_ids[1]).status, ProjectStatus::EvaluationRound); + assert_eq!(inst.get_project_details(project_ids[2]).status, ProjectStatus::AuctionRound(AuctionPhase::English)); + assert_eq!(inst.get_project_details(project_ids[3]).status, ProjectStatus::CommunityRound); + assert_eq!(inst.get_project_details(project_ids[4]).status, ProjectStatus::RemainderRound); + assert_eq!(inst.get_project_details(project_ids[5]).status, ProjectStatus::FundingSuccessful); } } diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 5e2f72e5b..7dc513cf1 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -680,7 +680,7 @@ impl orml_oracle::Config for Runtime { } // Create the runtime by composing the FRAME pallets that were previously configured. -#[cfg(all(feature = "testing-node", feature = "std"))] +// #[cfg(all(feature = "testing-node", feature = "std"))] construct_runtime!( pub enum Runtime { @@ -741,66 +741,66 @@ construct_runtime!( } ); -#[cfg(not(all(feature = "testing-node", feature = "std")))] -construct_runtime!( - pub enum Runtime - { - // System support stuff. - System: frame_system::{Pallet, Call, Config, Storage, Event} = 0, - Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 2, - Sudo: pallet_sudo = 4, - Utility: pallet_utility::{Pallet, Call, Event} = 5, - Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 6, - - // Monetary stuff. - Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 10, - TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event} = 11, - AssetTxPayment: pallet_asset_tx_payment::{Pallet, Storage, Event} = 12, - LocalAssets: pallet_assets::::{Pallet, Storage, Event} = 13, - StatemintAssets: pallet_assets::::{Pallet, Call, Config, Storage, Event} = 14, - - - // Collator support. the order of these 5 are important and shall not change. - Authorship: pallet_authorship::{Pallet, Storage} = 20, - Session: pallet_session::{Pallet, Call, Storage, Event, Config} = 22, - Aura: pallet_aura::{Pallet, Storage, Config} = 23, - AuraExt: cumulus_pallet_aura_ext::{Pallet, Storage, Config} = 24, - ParachainStaking: pallet_parachain_staking::{Pallet, Call, Storage, Event, Config} = 25, - - // Oracle - Oracle: orml_oracle:: = 30, - OracleProvidersMembership: pallet_membership:: = 31, - - // Governance - Treasury: pallet_treasury = 40, - Democracy: pallet_democracy = 41, - Council: pallet_collective:: = 42, - TechnicalCommittee: pallet_collective:: = 43, - Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 44, - - // Polimec Core - PolimecFunding: pallet_funding::{Pallet, Call, Storage, Event} = 52, - LinearVesting: pallet_linear_release::{Pallet, Call, Storage, Event, Config} = 53, - - // Utilities - Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 61, - Random: pallet_insecure_randomness_collective_flip = 62, - - - - // Among others: Send and receive DMP and XCMP messages. - ParachainSystem: cumulus_pallet_parachain_system = 80, - ParachainInfo: parachain_info::{Pallet, Storage, Config} = 81, - // Wrap and unwrap XCMP messages to send and receive them. Queue them for later processing. - XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event} = 82, - // Build XCM scripts. - PolkadotXcm: pallet_xcm::{Pallet, Call, Event, Origin, Config} = 83, - // Does nothing cool, just provides an origin. - CumulusXcm: cumulus_pallet_xcm::{Pallet, Event, Origin} = 84, - // Queue and pass DMP messages on to be executed. - DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event} = 85, - } -); +// #[cfg(not(all(feature = "testing-node", feature = "std")))] +// construct_runtime!( +// pub enum Runtime +// { +// // System support stuff. +// System: frame_system::{Pallet, Call, Config, Storage, Event} = 0, +// Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 2, +// Sudo: pallet_sudo = 4, +// Utility: pallet_utility::{Pallet, Call, Event} = 5, +// Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 6, +// +// // Monetary stuff. +// Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 10, +// TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event} = 11, +// AssetTxPayment: pallet_asset_tx_payment::{Pallet, Storage, Event} = 12, +// LocalAssets: pallet_assets::::{Pallet, Storage, Event} = 13, +// StatemintAssets: pallet_assets::::{Pallet, Call, Config, Storage, Event} = 14, +// +// +// // Collator support. the order of these 5 are important and shall not change. +// Authorship: pallet_authorship::{Pallet, Storage} = 20, +// Session: pallet_session::{Pallet, Call, Storage, Event, Config} = 22, +// Aura: pallet_aura::{Pallet, Storage, Config} = 23, +// AuraExt: cumulus_pallet_aura_ext::{Pallet, Storage, Config} = 24, +// ParachainStaking: pallet_parachain_staking::{Pallet, Call, Storage, Event, Config} = 25, +// +// // Oracle +// Oracle: orml_oracle:: = 30, +// OracleProvidersMembership: pallet_membership:: = 31, +// +// // Governance +// Treasury: pallet_treasury = 40, +// Democracy: pallet_democracy = 41, +// Council: pallet_collective:: = 42, +// TechnicalCommittee: pallet_collective:: = 43, +// Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 44, +// +// // Polimec Core +// PolimecFunding: pallet_funding::{Pallet, Call, Storage, Event} = 52, +// LinearVesting: pallet_linear_release::{Pallet, Call, Storage, Event, Config} = 53, +// +// // Utilities +// Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 61, +// Random: pallet_insecure_randomness_collective_flip = 62, +// +// +// +// // Among others: Send and receive DMP and XCMP messages. +// ParachainSystem: cumulus_pallet_parachain_system = 80, +// ParachainInfo: parachain_info::{Pallet, Storage, Config} = 81, +// // Wrap and unwrap XCMP messages to send and receive them. Queue them for later processing. +// XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event} = 82, +// // Build XCM scripts. +// PolkadotXcm: pallet_xcm::{Pallet, Call, Event, Origin, Config} = 83, +// // Does nothing cool, just provides an origin. +// CumulusXcm: cumulus_pallet_xcm::{Pallet, Event, Origin} = 84, +// // Queue and pass DMP messages on to be executed. +// DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event} = 85, +// } +// ); #[cfg(feature = "runtime-benchmarks")] mod benches { From b6f27fb45ee7e90d7ed4b2ebf09199de3f08ef87 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 4 Jan 2024 10:25:25 +0100 Subject: [PATCH 084/212] fixes --- pallets/funding/src/genesis_config.rs | 2 +- pallets/funding/src/tests.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/funding/src/genesis_config.rs b/pallets/funding/src/genesis_config.rs index 5518545c0..1d8638002 100644 --- a/pallets/funding/src/genesis_config.rs +++ b/pallets/funding/src/genesis_config.rs @@ -1,4 +1,4 @@ -use frame_support::pallet_macros::{pallet_section, *}; +use frame_support::pallet_macros::{pallet_section}; #[cfg(all(feature = "testing-node", feature = "std"))] #[pallet_section] diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 79766d938..aee7dd46a 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -5855,7 +5855,7 @@ mod async_tests { use sp_std::sync::Arc; use tokio::{ runtime::Runtime, - sync::{Mutex, Notify}, + sync::{Mutex}, }; #[test] @@ -5863,7 +5863,7 @@ mod async_tests { let tokio_runtime = Runtime::new().unwrap(); let inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let inst = tokio_runtime.block_on(async { + let _inst = tokio_runtime.block_on(async { let block_orchestrator = Arc::new(BlockOrchestrator::new()); let mutex_inst = Arc::new(Mutex::new(inst)); From 2544d0fe66586e1b050dff4fcbe97777819bc03a Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 4 Jan 2024 10:46:05 +0100 Subject: [PATCH 085/212] trying to remove Sync and Send traits --- pallets/funding/src/genesis_config.rs | 40 +++------------------------ pallets/funding/src/instantiator.rs | 31 +++++++-------------- pallets/funding/src/lib.rs | 33 ++++++---------------- 3 files changed, 22 insertions(+), 82 deletions(-) diff --git a/pallets/funding/src/genesis_config.rs b/pallets/funding/src/genesis_config.rs index 1d8638002..9321cdf60 100644 --- a/pallets/funding/src/genesis_config.rs +++ b/pallets/funding/src/genesis_config.rs @@ -24,17 +24,9 @@ mod genesis_config { T: Config + pallet_balances::Config>, ::AllPalletsWithoutSystem: OnFinalize> + OnIdle> - + OnInitialize> - + Sync - + Send - + 'static, + + OnInitialize>, ::RuntimeEvent: From> + TryInto> + Parameter + Member, ::Balance: Into>, - ::ProjectIdentifier: Send + Sync, - ::Balance: Send + Sync, - ::Price: Send + Sync, - ::StringLimit: Send + Sync, - ::Multiplier: Send + Sync, { pub starting_projects: Vec>, pub phantom: PhantomData, @@ -45,17 +37,9 @@ mod genesis_config { T: Config + pallet_balances::Config>, ::AllPalletsWithoutSystem: OnFinalize> + OnIdle> - + OnInitialize> - + Sync - + Send - + 'static, + + OnInitialize>, ::RuntimeEvent: From> + TryInto> + Parameter + Member, ::Balance: Into>, - ::ProjectIdentifier: Send + Sync, - ::Balance: Send + Sync, - ::Price: Send + Sync, - ::StringLimit: Send + Sync, - ::Multiplier: Send + Sync, { fn default() -> Self { Self { starting_projects: vec![], phantom: PhantomData } @@ -68,17 +52,9 @@ mod genesis_config { T: Config + pallet_balances::Config>, ::AllPalletsWithoutSystem: OnFinalize> + OnIdle> - + OnInitialize> - + Sync - + Send - + 'static, + + OnInitialize>, ::RuntimeEvent: From> + TryInto> + Parameter + Member, ::Balance: Into>, - ::ProjectIdentifier: Send + Sync, - ::Balance: Send + Sync, - ::Price: Send + Sync, - ::StringLimit: Send + Sync, - ::Multiplier: Send + Sync, { fn build(&self) { { @@ -96,17 +72,9 @@ mod genesis_config { T: Config + pallet_balances::Config>, ::AllPalletsWithoutSystem: OnFinalize> + OnIdle> - + OnInitialize> - + Sync - + Send - + 'static, + + OnInitialize>, ::RuntimeEvent: From> + TryInto> + Parameter + Member, ::Balance: Into>, - ::ProjectIdentifier: Send + Sync, - ::Balance: Send + Sync, - ::Price: Send + Sync, - ::StringLimit: Send + Sync, - ::Multiplier: Send + Sync, { /// Direct implementation of `GenesisBuild::build_storage`. /// diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 4c53fb6c8..3ff991d6d 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -2280,13 +2280,10 @@ pub mod async_features { } pub async fn async_create_project_at< - T: Config + pallet_balances::Config> + std::marker::Sync + std::marker::Send, + T: Config + pallet_balances::Config>, AllPalletsWithoutSystem: OnFinalize> + OnIdle> - + OnInitialize> - + Sync - + Send - + 'static, + + OnInitialize>, RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, >( mutex_inst: Arc>>, @@ -2406,43 +2403,34 @@ pub mod async_features { } pub fn create_multiple_projects_at< - T: Config + pallet_balances::Config> + std::marker::Sync + std::marker::Send, + T: Config + pallet_balances::Config>, AllPalletsWithoutSystem: OnFinalize> + OnIdle> - + OnInitialize> - + Sync - + Send - + 'static, + + OnInitialize>, RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, >( instantiator: Instantiator, projects: Vec>, ) -> (Vec>, Instantiator) - where - ::ProjectIdentifier: Send + Sync, - ::Balance: Send + Sync, - ::Price: Send + Sync, - ::StringLimit: Send + Sync, - ::Multiplier: Send + Sync, { // let tokio_runtime = Runtime::new().unwrap(); use tokio::runtime::Builder; let tokio_runtime = Builder::new_current_thread().enable_all().build().unwrap(); - - tokio_runtime.block_on(async { + let local = tokio::task::LocalSet::new(); + let execution = local.run_until(async move { let block_orchestrator = Arc::new(BlockOrchestrator::new()); let mutex_inst = Arc::new(Mutex::new(instantiator)); let project_futures = projects.into_iter().map(|project| { let block_orchestrator = block_orchestrator.clone(); let mutex_inst = mutex_inst.clone(); - tokio::spawn(async { async_create_project_at(mutex_inst, block_orchestrator, project).await }) + tokio::task::spawn_local(async { async_create_project_at(mutex_inst, block_orchestrator, project).await }) }); // Wait for all project creation tasks to complete let joined_project_futures = futures::future::join_all(project_futures); - let controller_handle = tokio::spawn(block_controller(block_orchestrator.clone(), mutex_inst.clone())); + let controller_handle = tokio::task::spawn_local(block_controller(block_orchestrator.clone(), mutex_inst.clone())); let projects = joined_project_futures.await; // Now that all projects have been set up, signal the block_controller to stop @@ -2455,7 +2443,8 @@ pub mod async_features { let project_ids = projects.into_iter().map(|project| project.unwrap()).collect_vec(); (project_ids, inst) - }) + }); + tokio_runtime.block_on(execution) } } diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 13f7cbbf1..c9a8295ed 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -284,17 +284,14 @@ pub mod pallet { #[pallet::config] pub trait Config: - frame_system::Config + pallet_balances::Config> + pallet_xcm::Config + Send + Sync + frame_system::Config + pallet_balances::Config> + pallet_xcm::Config { #[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] type SetPrices: SetPrices; type AllPalletsWithoutSystem: OnFinalize> + OnIdle> - + OnInitialize> - //testing-node - + Send - + Sync; + + OnInitialize>; type RuntimeEvent: From> + TryInto> @@ -320,10 +317,8 @@ pub mod pallet { + Saturating + From + Ord - + MaxEncodedLen - //testing-node - + Send - + Sync; + + MaxEncodedLen; + // TODO: PLMC-153 + MaybeSerializeDeserialize: Maybe needed for JSON serialization @ Genesis: https://github.com/paritytech/substrate/issues/12738#issuecomment-1320921201 /// Multiplier that decides how much PLMC needs to be bonded for a token buy/bid @@ -334,30 +329,21 @@ pub mod pallet { + Copy + TryFrom + MaxEncodedLen - + MaybeSerializeDeserialize - //testing-node - + Send - + Sync; + + MaybeSerializeDeserialize; /// The inner balance type we will use for all of our outer currency types. (e.g native, funding, CTs) type Balance: Balance + From + FixedPointOperand + MaybeSerializeDeserialize - + Into - //testing-node - + Send - + Sync; + + Into; /// Represents the value of something in USD type Price: FixedPointNumber + Parameter + Copy + MaxEncodedLen - + MaybeSerializeDeserialize - //testing-node - + Send - + Sync; + + MaybeSerializeDeserialize; /// The chains native currency type NativeCurrency: fungible::InspectHold, Balance = BalanceOf> @@ -390,10 +376,7 @@ pub mod pallet { /// The maximum length of data stored on-chain. #[pallet::constant] - type StringLimit: Get - //testing-node - + Send - + Sync; + type StringLimit: Get; /// The maximum size of a preimage allowed, expressed in bytes. #[pallet::constant] From 44861bf5bd8a4630c5516675f434599c4a87dd46 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 4 Jan 2024 11:03:50 +0100 Subject: [PATCH 086/212] trying to have one genesis config --- pallets/funding/src/genesis_config.rs | 41 +++++++++--------- pallets/funding/src/instantiator.rs | 2 +- runtimes/testnet/src/lib.rs | 62 --------------------------- 3 files changed, 21 insertions(+), 84 deletions(-) diff --git a/pallets/funding/src/genesis_config.rs b/pallets/funding/src/genesis_config.rs index 9321cdf60..1d546f34f 100644 --- a/pallets/funding/src/genesis_config.rs +++ b/pallets/funding/src/genesis_config.rs @@ -1,6 +1,5 @@ use frame_support::pallet_macros::{pallet_section}; -#[cfg(all(feature = "testing-node", feature = "std"))] #[pallet_section] mod genesis_config { use crate::{ @@ -85,23 +84,23 @@ mod genesis_config { } } -#[cfg(not(all(feature = "testing-node", feature = "std")))] -#[pallet_section] -mod genesis_config { - #[pallet::genesis_config] - pub struct GenesisConfig { - phantom: PhantomData, - } - - impl Default for GenesisConfig { - fn default() -> Self { - Self {phantom: PhantomData} - } - } - - #[pallet::genesis_build] - impl BuildGenesisConfig for GenesisConfig { - fn build(&self) {} - } - -} +// #[cfg(not(all(feature = "testing-node", feature = "std")))] +// #[pallet_section] +// mod genesis_config { +// #[pallet::genesis_config] +// pub struct GenesisConfig { +// phantom: PhantomData, +// } +// +// impl Default for GenesisConfig { +// fn default() -> Self { +// Self {phantom: PhantomData} +// } +// } +// +// #[pallet::genesis_build] +// impl BuildGenesisConfig for GenesisConfig { +// fn build(&self) {} +// } +// +// } diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 3ff991d6d..15a30814b 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -2406,7 +2406,7 @@ pub mod async_features { T: Config + pallet_balances::Config>, AllPalletsWithoutSystem: OnFinalize> + OnIdle> - + OnInitialize>, + + OnInitialize> + 'static + 'static, RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, >( instantiator: Instantiator, diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 7dc513cf1..43128c710 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -680,7 +680,6 @@ impl orml_oracle::Config for Runtime { } // Create the runtime by composing the FRAME pallets that were previously configured. -// #[cfg(all(feature = "testing-node", feature = "std"))] construct_runtime!( pub enum Runtime { @@ -741,67 +740,6 @@ construct_runtime!( } ); -// #[cfg(not(all(feature = "testing-node", feature = "std")))] -// construct_runtime!( -// pub enum Runtime -// { -// // System support stuff. -// System: frame_system::{Pallet, Call, Config, Storage, Event} = 0, -// Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 2, -// Sudo: pallet_sudo = 4, -// Utility: pallet_utility::{Pallet, Call, Event} = 5, -// Multisig: pallet_multisig::{Pallet, Call, Storage, Event} = 6, -// -// // Monetary stuff. -// Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 10, -// TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event} = 11, -// AssetTxPayment: pallet_asset_tx_payment::{Pallet, Storage, Event} = 12, -// LocalAssets: pallet_assets::::{Pallet, Storage, Event} = 13, -// StatemintAssets: pallet_assets::::{Pallet, Call, Config, Storage, Event} = 14, -// -// -// // Collator support. the order of these 5 are important and shall not change. -// Authorship: pallet_authorship::{Pallet, Storage} = 20, -// Session: pallet_session::{Pallet, Call, Storage, Event, Config} = 22, -// Aura: pallet_aura::{Pallet, Storage, Config} = 23, -// AuraExt: cumulus_pallet_aura_ext::{Pallet, Storage, Config} = 24, -// ParachainStaking: pallet_parachain_staking::{Pallet, Call, Storage, Event, Config} = 25, -// -// // Oracle -// Oracle: orml_oracle:: = 30, -// OracleProvidersMembership: pallet_membership:: = 31, -// -// // Governance -// Treasury: pallet_treasury = 40, -// Democracy: pallet_democracy = 41, -// Council: pallet_collective:: = 42, -// TechnicalCommittee: pallet_collective:: = 43, -// Preimage: pallet_preimage::{Pallet, Call, Storage, Event} = 44, -// -// // Polimec Core -// PolimecFunding: pallet_funding::{Pallet, Call, Storage, Event} = 52, -// LinearVesting: pallet_linear_release::{Pallet, Call, Storage, Event, Config} = 53, -// -// // Utilities -// Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event} = 61, -// Random: pallet_insecure_randomness_collective_flip = 62, -// -// -// -// // Among others: Send and receive DMP and XCMP messages. -// ParachainSystem: cumulus_pallet_parachain_system = 80, -// ParachainInfo: parachain_info::{Pallet, Storage, Config} = 81, -// // Wrap and unwrap XCMP messages to send and receive them. Queue them for later processing. -// XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event} = 82, -// // Build XCM scripts. -// PolkadotXcm: pallet_xcm::{Pallet, Call, Event, Origin, Config} = 83, -// // Does nothing cool, just provides an origin. -// CumulusXcm: cumulus_pallet_xcm::{Pallet, Event, Origin} = 84, -// // Queue and pass DMP messages on to be executed. -// DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event} = 85, -// } -// ); - #[cfg(feature = "runtime-benchmarks")] mod benches { define_benchmarks!( From 8d6074610e4bd598575c80ebc1eed262168b3364 Mon Sep 17 00:00:00 2001 From: Juan Ignacio RIos Date: Thu, 4 Jan 2024 11:10:42 +0100 Subject: [PATCH 087/212] save Signed-off-by: Juan Ignacio Rios --- integration-tests/src/lib.rs | 2 -- nodes/parachain/src/chain_spec/testnet.rs | 6 +----- nodes/parachain/src/command.rs | 1 - pallets/funding/src/genesis_config.rs | 23 +++++++++----------- pallets/funding/src/lib.rs | 26 +++++------------------ pallets/funding/src/mock.rs | 2 +- pallets/funding/src/traits.rs | 4 ++-- runtimes/testnet/src/lib.rs | 12 +++++------ 8 files changed, 25 insertions(+), 51 deletions(-) diff --git a/integration-tests/src/lib.rs b/integration-tests/src/lib.rs index 86fa3a886..1c2848163 100644 --- a/integration-tests/src/lib.rs +++ b/integration-tests/src/lib.rs @@ -13,8 +13,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#![cfg(all(test, feature = "std", feature = "testing-node"))] - pub mod constants; mod tests; diff --git a/nodes/parachain/src/chain_spec/testnet.rs b/nodes/parachain/src/chain_spec/testnet.rs index 971baf3a7..b4baafa46 100644 --- a/nodes/parachain/src/chain_spec/testnet.rs +++ b/nodes/parachain/src/chain_spec/testnet.rs @@ -72,7 +72,7 @@ pub fn get_testnet_session_keys(keys: AuthorityId) -> polimec_parachain_runtime: polimec_parachain_runtime::SessionKeys { aura: keys } } -#[cfg(all(feature = "testing-node", feature = "std"))] +#[cfg(all(feature = "std"))] pub fn get_chain_spec_testing() -> Result { let properties = get_properties("PLMC", 10, 41); let wasm = polimec_parachain_runtime::WASM_BINARY.ok_or("No WASM")?; @@ -271,12 +271,9 @@ fn testnet_genesis( } } -#[cfg(all(feature = "testing-node", feature = "std"))] use pallet_funding::{instantiator::UserToUSDBalance, *}; -#[cfg(all(feature = "testing-node", feature = "std"))] use sp_runtime::BoundedVec; -#[cfg(all(feature = "testing-node", feature = "std"))] mod testing_helpers { use super::*; use frame_benchmarking::frame_support::assert_ok; @@ -374,7 +371,6 @@ mod testing_helpers { } #[allow(clippy::too_many_arguments)] -#[cfg(all(feature = "testing-node", feature = "std"))] fn testing_genesis( wasm_binary: &[u8], stakers: Vec<(AccountId, Option, Balance)>, diff --git a/nodes/parachain/src/command.rs b/nodes/parachain/src/command.rs index 5d2b95472..9954423f7 100644 --- a/nodes/parachain/src/command.rs +++ b/nodes/parachain/src/command.rs @@ -93,7 +93,6 @@ fn load_spec(id: &str) -> std::result::Result, String> { "base-polkadot" => Box::new(chain_spec::base::get_polkadot_base_chain_spec()?), "base-rococo" => Box::new(chain_spec::base::get_rococo_base_chain_spec()?), // Testnet runtime - #[cfg(all(feature = "testing-node", feature = "std"))] "polimec-testing" => Box::new(chain_spec::testnet::get_chain_spec_testing()?), "polimec-rococo-local" => Box::new(chain_spec::testnet::get_chain_spec_dev()?), "polimec-polkadot" => Box::new(chain_spec::testnet::get_prod_chain_spec()?), diff --git a/pallets/funding/src/genesis_config.rs b/pallets/funding/src/genesis_config.rs index 1d546f34f..6c75d6b65 100644 --- a/pallets/funding/src/genesis_config.rs +++ b/pallets/funding/src/genesis_config.rs @@ -1,5 +1,6 @@ -use frame_support::pallet_macros::{pallet_section}; +use frame_support::pallet_macros::pallet_section; +#[cfg(feature = "std")] #[pallet_section] mod genesis_config { use crate::{ @@ -21,9 +22,8 @@ mod genesis_config { pub struct GenesisConfig where T: Config + pallet_balances::Config>, - ::AllPalletsWithoutSystem: OnFinalize> - + OnIdle> - + OnInitialize>, + ::AllPalletsWithoutSystem: + OnFinalize> + OnIdle> + OnInitialize>, ::RuntimeEvent: From> + TryInto> + Parameter + Member, ::Balance: Into>, { @@ -34,9 +34,8 @@ mod genesis_config { impl Default for GenesisConfig where T: Config + pallet_balances::Config>, - ::AllPalletsWithoutSystem: OnFinalize> - + OnIdle> - + OnInitialize>, + ::AllPalletsWithoutSystem: + OnFinalize> + OnIdle> + OnInitialize>, ::RuntimeEvent: From> + TryInto> + Parameter + Member, ::Balance: Into>, { @@ -49,9 +48,8 @@ mod genesis_config { impl BuildGenesisConfig for GenesisConfig where T: Config + pallet_balances::Config>, - ::AllPalletsWithoutSystem: OnFinalize> - + OnIdle> - + OnInitialize>, + ::AllPalletsWithoutSystem: + OnFinalize> + OnIdle> + OnInitialize>, ::RuntimeEvent: From> + TryInto> + Parameter + Member, ::Balance: Into>, { @@ -69,9 +67,8 @@ mod genesis_config { impl GenesisConfig where T: Config + pallet_balances::Config>, - ::AllPalletsWithoutSystem: OnFinalize> - + OnIdle> - + OnInitialize>, + ::AllPalletsWithoutSystem: + OnFinalize> + OnIdle> + OnInitialize>, ::RuntimeEvent: From> + TryInto> + Parameter + Member, ::Balance: Into>, { diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index c9a8295ed..8770ab793 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -204,7 +204,6 @@ pub mod tests; #[cfg(feature = "runtime-benchmarks")] pub mod benchmarking; pub mod impls; -#[cfg(any(feature = "runtime-benchmarks", test, all(feature = "testing-node", feature = "std")))] pub mod instantiator; pub mod traits; @@ -274,7 +273,7 @@ pub mod pallet { use crate::traits::{BondingRequirementCalculation, ProvideStatemintPrice, VestingDurationCalculation}; - #[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] + #[cfg(any(feature = "runtime-benchmarks", feature = "std"))] use crate::traits::SetPrices; use super::*; @@ -286,7 +285,7 @@ pub mod pallet { pub trait Config: frame_system::Config + pallet_balances::Config> + pallet_xcm::Config { - #[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] + #[cfg(any(feature = "runtime-benchmarks", feature = "std"))] type SetPrices: SetPrices; type AllPalletsWithoutSystem: OnFinalize> @@ -310,14 +309,7 @@ pub mod pallet { type RuntimeCall: Parameter + IsType<::RuntimeCall> + From>; /// Global identifier for the projects. - type ProjectIdentifier: Parameter - + Copy - + Default - + One - + Saturating - + From - + Ord - + MaxEncodedLen; + type ProjectIdentifier: Parameter + Copy + Default + One + Saturating + From + Ord + MaxEncodedLen; // TODO: PLMC-153 + MaybeSerializeDeserialize: Maybe needed for JSON serialization @ Genesis: https://github.com/paritytech/substrate/issues/12738#issuecomment-1320921201 @@ -332,18 +324,10 @@ pub mod pallet { + MaybeSerializeDeserialize; /// The inner balance type we will use for all of our outer currency types. (e.g native, funding, CTs) - type Balance: Balance - + From - + FixedPointOperand - + MaybeSerializeDeserialize - + Into; + type Balance: Balance + From + FixedPointOperand + MaybeSerializeDeserialize + Into; /// Represents the value of something in USD - type Price: FixedPointNumber - + Parameter - + Copy - + MaxEncodedLen - + MaybeSerializeDeserialize; + type Price: FixedPointNumber + Parameter + Copy + MaxEncodedLen + MaybeSerializeDeserialize; /// The chains native currency type NativeCurrency: fungible::InspectHold, Balance = BalanceOf> diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 43865b44e..9adbca0d9 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -387,7 +387,7 @@ impl Config for TestRuntime { type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; - #[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] + #[cfg(any(feature = "runtime-benchmarks", feature = "std"))] type SetPrices = (); type StringLimit = ConstU32<64>; type SuccessToSettlementTime = SuccessToSettlementTime; diff --git a/pallets/funding/src/traits.rs b/pallets/funding/src/traits.rs index 175f3e2ba..2cf3de3e0 100644 --- a/pallets/funding/src/traits.rs +++ b/pallets/funding/src/traits.rs @@ -24,12 +24,12 @@ pub trait DoRemainingOperation { fn do_one_operation(&mut self, project_id: T::ProjectIdentifier) -> Result; } -#[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] +#[cfg(any(feature = "runtime-benchmarks", feature = "std"))] pub trait SetPrices { fn set_prices(); } -#[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] +#[cfg(any(feature = "runtime-benchmarks", feature = "std"))] impl SetPrices for () { fn set_prices() {} } diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 43128c710..4d0cde9e9 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -71,13 +71,13 @@ use pallet_funding::{BondTypeOf, DaysToBlocks}; pub use pallet_parachain_staking; pub use shared_configuration::*; -#[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] +#[cfg(any(feature = "runtime-benchmarks", feature = "std"))] use pallet_funding::AcceptedFundingAsset; -#[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] +#[cfg(any(feature = "runtime-benchmarks", feature = "std"))] use frame_support::BoundedVec; -#[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] +#[cfg(any(feature = "runtime-benchmarks", feature = "std"))] use pallet_funding::traits::SetPrices; pub type NegativeImbalanceOf = @@ -145,9 +145,9 @@ pub fn native_version() -> NativeVersion { NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } } -#[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] +#[cfg(any(feature = "runtime-benchmarks", feature = "std"))] pub struct SetOraclePrices; -#[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] +#[cfg(any(feature = "runtime-benchmarks", feature = "std"))] impl SetPrices for SetOraclePrices { fn set_prices() { let dot = (AcceptedFundingAsset::DOT.to_statemint_id(), FixedU128::from_rational(69, 1)); @@ -590,7 +590,7 @@ impl pallet_funding::Config for Runtime { type RuntimeCall = RuntimeCall; type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; - #[cfg(any(feature = "runtime-benchmarks", feature = "testing-node"))] + #[cfg(any(feature = "runtime-benchmarks", feature = "std"))] type SetPrices = SetOraclePrices; type StringLimit = ConstU32<64>; type SuccessToSettlementTime = SuccessToSettlementTime; From 68fb714305167f527bd0d22ee53f9b15426114d8 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 4 Jan 2024 12:29:46 +0100 Subject: [PATCH 088/212] save Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/genesis_config.rs | 8 ++- pallets/funding/src/instantiator.rs | 28 ++++------ pallets/funding/src/lib.rs | 78 +++++++++++++++++++++++++-- pallets/funding/src/tests.rs | 5 +- 4 files changed, 87 insertions(+), 32 deletions(-) diff --git a/pallets/funding/src/genesis_config.rs b/pallets/funding/src/genesis_config.rs index 6c75d6b65..ff11c9cb0 100644 --- a/pallets/funding/src/genesis_config.rs +++ b/pallets/funding/src/genesis_config.rs @@ -1,11 +1,9 @@ use frame_support::pallet_macros::pallet_section; -#[cfg(feature = "std")] #[pallet_section] mod genesis_config { use crate::{ - instantiator, - instantiator::{async_features::create_multiple_projects_at, TestProjectParams}, + instantiator::{Instantiator, TestProjectParams}, pallet, BalanceOf, }; use frame_support::{ @@ -56,11 +54,11 @@ mod genesis_config { fn build(&self) { { type GenesisInstantiator = - instantiator::Instantiator::AllPalletsWithoutSystem, ::RuntimeEvent>; + Instantiator::AllPalletsWithoutSystem, ::RuntimeEvent>; let mut inst = GenesisInstantiator::::new(None); ::SetPrices::set_prices(); let current_block = >::block_number(); - create_multiple_projects_at(inst, self.starting_projects.clone()); + instantiator::async_features::create_multiple_projects_at(inst, self.starting_projects.clone()); } } } diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 15a30814b..d1a7080b3 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -84,16 +84,11 @@ impl< RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, > Instantiator { - pub fn new( - ext: Option>, - ) -> Self { + pub fn new(ext: Option>) -> Self { Self { ext, nonce: RefCell::new(0u64), _marker: PhantomData } } - pub fn set_ext( - &mut self, - ext: Option>, - ) { + pub fn set_ext(&mut self, ext: Option>) { self.ext = ext; } @@ -103,7 +98,6 @@ impl< } else { execution() } - } pub fn get_new_nonce(&self) -> u64 { @@ -2281,9 +2275,7 @@ pub mod async_features { pub async fn async_create_project_at< T: Config + pallet_balances::Config>, - AllPalletsWithoutSystem: OnFinalize> - + OnIdle> - + OnInitialize>, + AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, >( mutex_inst: Arc>>, @@ -2404,15 +2396,12 @@ pub mod async_features { pub fn create_multiple_projects_at< T: Config + pallet_balances::Config>, - AllPalletsWithoutSystem: OnFinalize> - + OnIdle> - + OnInitialize> + 'static + 'static, + AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize> + 'static + 'static, RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, >( instantiator: Instantiator, projects: Vec>, - ) -> (Vec>, Instantiator) - { + ) -> (Vec>, Instantiator) { // let tokio_runtime = Runtime::new().unwrap(); use tokio::runtime::Builder; @@ -2425,12 +2414,15 @@ pub mod async_features { let project_futures = projects.into_iter().map(|project| { let block_orchestrator = block_orchestrator.clone(); let mutex_inst = mutex_inst.clone(); - tokio::task::spawn_local(async { async_create_project_at(mutex_inst, block_orchestrator, project).await }) + tokio::task::spawn_local(async { + async_create_project_at(mutex_inst, block_orchestrator, project).await + }) }); // Wait for all project creation tasks to complete let joined_project_futures = futures::future::join_all(project_futures); - let controller_handle = tokio::task::spawn_local(block_controller(block_orchestrator.clone(), mutex_inst.clone())); + let controller_handle = + tokio::task::spawn_local(block_controller(block_orchestrator.clone(), mutex_inst.clone())); let projects = joined_project_futures.await; // Now that all projects have been set up, signal the block_controller to stop diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 8770ab793..7d32511c2 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -171,16 +171,16 @@ // This recursion limit is needed because we have too many benchmarks and benchmarking will fail if // we add more without this limit. #![cfg_attr(feature = "runtime-benchmarks", recursion_limit = "512")] - -use crate::traits::DoRemainingOperation; pub use crate::weights::WeightInfo; use frame_support::{ + dispatch::{Decode, Encode}, pallet_macros::*, + pallet_prelude::BuildGenesisConfig, traits::{ tokens::{fungible, fungibles, Balance}, AccountTouch, ContainsPair, Randomness, }, - BoundedVec, PalletId, + BoundedVec, PalletId, Parameter, }; use frame_system::pallet_prelude::BlockNumberFor; pub use pallet::*; @@ -188,8 +188,12 @@ use polimec_common::migration_types::*; use polkadot_parachain::primitives::Id as ParaId; use sp_arithmetic::traits::{One, Saturating}; use sp_core::ConstU32; -use sp_runtime::{traits::AccountIdConversion, FixedPointNumber, FixedPointOperand, FixedU128, WeakBoundedVec}; +use sp_runtime::{ + traits::{AccountIdConversion, Member}, + FixedPointNumber, FixedPointOperand, FixedU128, WeakBoundedVec, +}; use sp_std::{marker::PhantomData, prelude::*}; +use traits::DoRemainingOperation; pub use types::*; use xcm::v3::{opaque::Instruction, prelude::*, SendXcm}; pub mod functions; @@ -258,7 +262,6 @@ pub type WeightInfoOf = ::WeightInfo; pub const PLMC_STATEMINT_ID: u32 = 2069; -#[import_section(genesis_config::genesis_config)] #[frame_support::pallet] pub mod pallet { use frame_support::{ @@ -1359,6 +1362,71 @@ pub mod pallet { } } use pallet_xcm::ensure_response; + + #[pallet::genesis_config] + #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode)] + pub struct GenesisConfig + where + T: Config + pallet_balances::Config>, + ::AllPalletsWithoutSystem: + OnFinalize> + OnIdle> + OnInitialize>, + ::RuntimeEvent: From> + TryInto> + Parameter + Member, + ::Balance: Into>, + { + #[cfg(features = "std")] + pub starting_projects: Vec>, + pub phantom: PhantomData, + } + + impl Default for GenesisConfig + where + T: Config + pallet_balances::Config>, + ::AllPalletsWithoutSystem: + OnFinalize> + OnIdle> + OnInitialize>, + ::RuntimeEvent: From> + TryInto> + Parameter + Member, + ::Balance: Into>, + { + fn default() -> Self { + Self { starting_projects: vec![], phantom: PhantomData } + } + } + + #[cfg(feature = "std")] + #[pallet::genesis_build] + impl BuildGenesisConfig for GenesisConfig + where + T: Config + pallet_balances::Config>, + ::AllPalletsWithoutSystem: + OnFinalize> + OnIdle> + OnInitialize>, + ::RuntimeEvent: From> + TryInto> + Parameter + Member, + ::Balance: Into>, + { + fn build(&self) { + { + type GenesisInstantiator = + instantiator::Instantiator::AllPalletsWithoutSystem, ::RuntimeEvent>; + let mut inst = GenesisInstantiator::::new(None); + ::SetPrices::set_prices(); + let current_block = >::block_number(); + instantiator::async_features::create_multiple_projects_at(inst, self.starting_projects.clone()); + } + } + } + impl GenesisConfig + where + T: Config + pallet_balances::Config>, + ::AllPalletsWithoutSystem: + OnFinalize> + OnIdle> + OnInitialize>, + ::RuntimeEvent: From> + TryInto> + Parameter + Member, + ::Balance: Into>, + { + /// Direct implementation of `GenesisBuild::build_storage`. + /// + /// Kept in order not to break dependency. + pub fn build(&self) { + ::build(self) + } + } } pub mod xcm_executor_impl { diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index aee7dd46a..f50e79d6b 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -5853,10 +5853,7 @@ mod async_tests { use futures::FutureExt; use instantiator::async_features::*; use sp_std::sync::Arc; - use tokio::{ - runtime::Runtime, - sync::{Mutex}, - }; + use tokio::{runtime::Runtime, sync::Mutex}; #[test] fn prototype_1() { From 574a8ac515060aa03554d68bc0d2173681015a3d Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 4 Jan 2024 12:37:28 +0100 Subject: [PATCH 089/212] save Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/lib.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 7d32511c2..4997937a3 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1373,8 +1373,8 @@ pub mod pallet { ::RuntimeEvent: From> + TryInto> + Parameter + Member, ::Balance: Into>, { - #[cfg(features = "std")] - pub starting_projects: Vec>, + #[cfg(feature = "std")] + pub starting_projects: Vec>, pub phantom: PhantomData, } @@ -1387,11 +1387,14 @@ pub mod pallet { ::Balance: Into>, { fn default() -> Self { - Self { starting_projects: vec![], phantom: PhantomData } + Self { + #[cfg(feature = "std")] + starting_projects: vec![], + phantom: PhantomData, + } } } - #[cfg(feature = "std")] #[pallet::genesis_build] impl BuildGenesisConfig for GenesisConfig where @@ -1402,6 +1405,7 @@ pub mod pallet { ::Balance: Into>, { fn build(&self) { + #[cfg(feature = "std")] { type GenesisInstantiator = instantiator::Instantiator::AllPalletsWithoutSystem, ::RuntimeEvent>; @@ -1412,6 +1416,7 @@ pub mod pallet { } } } + #[cfg(feature = "std")] impl GenesisConfig where T: Config + pallet_balances::Config>, From dcf41d50343173ae5b83ffad3ed117aa8eea7f07 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 4 Jan 2024 17:04:23 +0100 Subject: [PATCH 090/212] build-spec working but some logic in instantiator is failing bids Signed-off-by: Juan Ignacio Rios --- nodes/parachain/Cargo.toml | 8 +- nodes/parachain/src/chain_spec/testnet.rs | 92 ++++++------ nodes/parachain/src/command.rs | 1 + pallets/funding/Cargo.toml | 20 ++- pallets/funding/src/instantiator.rs | 116 +++++---------- pallets/funding/src/lib.rs | 2 + pallets/funding/src/mock.rs | 34 ++--- pallets/funding/src/tests.rs | 163 ++++++++++++++++++++-- pallets/sandbox/src/mock.rs | 2 +- pallets/sandbox/src/tests.rs | 14 +- 10 files changed, 276 insertions(+), 176 deletions(-) diff --git a/nodes/parachain/Cargo.toml b/nodes/parachain/Cargo.toml index ab6ca7a38..51e1a01d3 100644 --- a/nodes/parachain/Cargo.toml +++ b/nodes/parachain/Cargo.toml @@ -24,7 +24,7 @@ futures.workspace = true polimec-parachain-runtime.workspace = true polimec-base-runtime.workspace = true pallet-funding.workspace = true -macros = { workspace = true, optional = true } +macros = { workspace = true } # Substrate frame-benchmarking.workspace = true @@ -134,9 +134,3 @@ std = [ "sp-transaction-pool/std", "xcm/std", ] -testing-node = [ - "pallet-funding/testing-node", - "polimec-base-runtime/testing-node", - "polimec-parachain-runtime/testing-node", - "macros", -] diff --git a/nodes/parachain/src/chain_spec/testnet.rs b/nodes/parachain/src/chain_spec/testnet.rs index b4baafa46..44fbba209 100644 --- a/nodes/parachain/src/chain_spec/testnet.rs +++ b/nodes/parachain/src/chain_spec/testnet.rs @@ -72,7 +72,7 @@ pub fn get_testnet_session_keys(keys: AuthorityId) -> polimec_parachain_runtime: polimec_parachain_runtime::SessionKeys { aura: keys } } -#[cfg(all(feature = "std"))] +#[cfg(feature = "std")] pub fn get_chain_spec_testing() -> Result { let properties = get_properties("PLMC", 10, 41); let wasm = polimec_parachain_runtime::WASM_BINARY.ok_or("No WASM")?; @@ -439,51 +439,51 @@ fn testing_genesis( community_contributions: community_contributions.clone(), remainder_contributions: remainder_contributions.clone(), }, - // TestProjectParams:: { - // expected_state: ProjectStatus::RemainderRound, - // metadata: default_project(ISSUER.into(), 1u32), - // issuer: ISSUER.into(), - // evaluations: evaluations.clone(), - // bids: bids.clone(), - // community_contributions: community_contributions.clone(), - // remainder_contributions: vec![], - // }, - // TestProjectParams:: { - // expected_state: ProjectStatus::CommunityRound, - // metadata: default_project(ISSUER.into(), 2u32), - // issuer: ISSUER.into(), - // evaluations: evaluations.clone(), - // bids: bids.clone(), - // community_contributions: vec![], - // remainder_contributions: vec![], - // }, - // TestProjectParams:: { - // expected_state: ProjectStatus::AuctionRound(AuctionPhase::English), - // metadata: default_project(ISSUER.into(), 3u32), - // issuer: ISSUER.into(), - // evaluations: evaluations.clone(), - // bids: vec![], - // community_contributions: vec![], - // remainder_contributions: vec![], - // }, - // TestProjectParams:: { - // expected_state: ProjectStatus::EvaluationRound, - // metadata: default_project(ISSUER.into(), 4u32), - // issuer: ISSUER.into(), - // evaluations: vec![], - // bids: vec![], - // community_contributions: vec![], - // remainder_contributions: vec![], - // }, - // TestProjectParams:: { - // expected_state: ProjectStatus::Application, - // metadata: default_project(ISSUER.into(), 5u32), - // issuer: ISSUER.into(), - // evaluations: vec![], - // bids: vec![], - // community_contributions: vec![], - // remainder_contributions: vec![], - // }, + TestProjectParams:: { + expected_state: ProjectStatus::RemainderRound, + metadata: default_project(ISSUER.into(), 1u32), + issuer: ISSUER.into(), + evaluations: evaluations.clone(), + bids: bids.clone(), + community_contributions: community_contributions.clone(), + remainder_contributions: vec![], + }, + TestProjectParams:: { + expected_state: ProjectStatus::CommunityRound, + metadata: default_project(ISSUER.into(), 2u32), + issuer: ISSUER.into(), + evaluations: evaluations.clone(), + bids: bids.clone(), + community_contributions: vec![], + remainder_contributions: vec![], + }, + TestProjectParams:: { + expected_state: ProjectStatus::AuctionRound(AuctionPhase::English), + metadata: default_project(ISSUER.into(), 3u32), + issuer: ISSUER.into(), + evaluations: evaluations.clone(), + bids: vec![], + community_contributions: vec![], + remainder_contributions: vec![], + }, + TestProjectParams:: { + expected_state: ProjectStatus::EvaluationRound, + metadata: default_project(ISSUER.into(), 4u32), + issuer: ISSUER.into(), + evaluations: vec![], + bids: vec![], + community_contributions: vec![], + remainder_contributions: vec![], + }, + TestProjectParams:: { + expected_state: ProjectStatus::Application, + metadata: default_project(ISSUER.into(), 5u32), + issuer: ISSUER.into(), + evaluations: vec![], + bids: vec![], + community_contributions: vec![], + remainder_contributions: vec![], + }, ], phantom: PhantomData, }, diff --git a/nodes/parachain/src/command.rs b/nodes/parachain/src/command.rs index 9954423f7..03dda0d7f 100644 --- a/nodes/parachain/src/command.rs +++ b/nodes/parachain/src/command.rs @@ -93,6 +93,7 @@ fn load_spec(id: &str) -> std::result::Result, String> { "base-polkadot" => Box::new(chain_spec::base::get_polkadot_base_chain_spec()?), "base-rococo" => Box::new(chain_spec::base::get_rococo_base_chain_spec()?), // Testnet runtime + #[cfg(feature = "std")] "polimec-testing" => Box::new(chain_spec::testnet::get_chain_spec_testing()?), "polimec-rococo-local" => Box::new(chain_spec::testnet::get_chain_spec_dev()?), "polimec-polkadot" => Box::new(chain_spec::testnet::get_prod_chain_spec()?), diff --git a/pallets/funding/Cargo.toml b/pallets/funding/Cargo.toml index 57e572d71..9d5b26ae4 100644 --- a/pallets/funding/Cargo.toml +++ b/pallets/funding/Cargo.toml @@ -47,15 +47,22 @@ polkadot-runtime-parachains.workspace = true polkadot-parachain.workspace = true polimec-receiver.workspace = true +# cargo expand visibility +# pallet-insecure-randomness-collective-flip.workspace = { workspace = true, optional = true } +# pallet-assets.workspace = { workspace = true, optional = true } +# pallet-linear-release.workspace = { workspace = true, optional = true } +# assert_matches2.workspace = { workspace = true, optional = true } +# xcm-executor.workspace = { workspace = true, optional = true } + [dev-dependencies] pallet-insecure-randomness-collective-flip.workspace = true pallet-assets.workspace = true pallet-linear-release.workspace = true assert_matches2.workspace = true -xcm-builder.workspace = true xcm-executor.workspace = true + [features] -default = [ "std" ] +default = [ "std", "cargo-expand-visible" ] std = [ "frame-benchmarking?/std", "frame-support/std", @@ -88,6 +95,8 @@ std = [ "xcm/std", "tokio", "futures", + "cargo-expand-visible", + ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", @@ -126,3 +135,10 @@ try-runtime = [ "sp-runtime/try-runtime", ] testing-node = [ "pallet-linear-release/testing-node" ] +cargo-expand-visible = [ + # "pallet-insecure-randomness-collective-flip", + # "pallet-assets", + # "pallet-linear-release", + # "assert_matches2", + # "xcm-executor", +] diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index d1a7080b3..551b92651 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -1434,10 +1434,7 @@ pub mod async_features { } pub async fn add_awaiting_project(&self, block_number: BlockNumberFor, notify: Arc) { - println!("add_awaiting_project requesting lock"); let mut awaiting_projects = self.awaiting_projects.lock().await; - println!("add_awaiting_project lock given"); - println!("adding project to block {}", block_number); awaiting_projects.entry(block_number).or_default().push(notify); drop(awaiting_projects); } @@ -1455,7 +1452,7 @@ pub mod async_features { if let Some(&next_block) = awaiting_projects.keys().min() { drop(awaiting_projects); - println!("advancing to block {}", next_block); + while self.get_current_block() < next_block { inst.advance_time(One::one()).unwrap(); let current_block: u32 = self @@ -1463,8 +1460,6 @@ pub mod async_features { .try_into() .unwrap_or_else(|_| panic!("Block number should fit into u32")); self.current_block.store(current_block + 1u32, Ordering::SeqCst); - - println!("Advanced to block {}", current_block + 1u32); } Some(next_block) } else { @@ -1506,9 +1501,8 @@ pub mod async_features { project_metadata: ProjectMetadataOf, issuer: AccountIdOf, ) -> ProjectIdOf { - println!("async_create_new_project requesting lock"); let mut inst = instantiator.lock().await; - println!("async_create_new_project lock given"); + let asset_account_deposit = inst.execute(|| ::ContributionTokenCurrency::deposit_required(One::one())); let ed = Instantiator::::get_ed(); @@ -1539,12 +1533,10 @@ pub mod async_features { project_metadata: ProjectMetadataOf, issuer: AccountIdOf, ) -> ProjectIdOf { - println!("create new project inside evaluating"); let project_id = async_create_new_project(instantiator.clone(), project_metadata, issuer.clone()).await; - println!("done"); - println!("async_create_evaluating_project requesting lock"); + let mut inst = instantiator.lock().await; - println!("async_create_evaluating_project lock given"); + inst.start_evaluation(project_id, issuer).unwrap(); project_id } @@ -1559,9 +1551,7 @@ pub mod async_features { project_id: ProjectIdOf, caller: AccountIdOf, ) -> Result<(), DispatchError> { - println!("async_start_auction requesting lock"); let mut inst = instantiator.lock().await; - println!("async_start_auction lock given"); let project_details = inst.get_project_details(project_id); @@ -1570,23 +1560,18 @@ pub mod async_features { let auction_start = evaluation_end.saturating_add(2u32.into()); let notify = Arc::new(Notify::new()); - println!("async_start_auction adding to awaiting projects"); + block_orchestrator.add_awaiting_project(auction_start, notify.clone()).await; - println!("async_start_auction awaiting projects added"); + // Wait for the notification that our desired block was reached to continue - println!("async_start_auction dropping lock"); drop(inst); - println!("async_start_auction lock dropped"); - println!("async_start_auction awaiting notification"); + notify.notified().await; - println!("async_start_auction notification received"); - println!("async_start_auction requesting lock"); + inst = instantiator.lock().await; - println!("async_start_auction lock given"); }; - println!("async_start_auction getting details"); assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AuctionInitializePeriod); inst.execute(|| crate::Pallet::::do_english_auction(caller, project_id))?; @@ -1607,11 +1592,10 @@ pub mod async_features { issuer: AccountIdOf, evaluations: Vec>, ) -> ProjectIdOf { - println!("creating evaluating project inside auctioning"); let project_id = async_create_evaluating_project(instantiator.clone(), project_metadata, issuer.clone()).await; - println!("async_create_auctioning_project requesting lock"); + let mut inst = instantiator.lock().await; - println!("async_create_auctioning_project lock given"); + let evaluators = evaluations.accounts(); let prev_supply = inst.get_plmc_total_supply(); let prev_plmc_balances = inst.get_free_plmc_balances_for(evaluators.clone()); @@ -1645,10 +1629,9 @@ pub mod async_features { let expected_total_supply = prev_supply + expected_evaluator_balances; inst.evaluation_assertions(project_id, expected_remaining_plmc, plmc_eval_deposits, expected_total_supply); - println!("async_create_auctioning_project dropping lock"); + drop(inst); - println!("async_create_auctioning_project lock dropped"); - println!("async_create_auctioning_project awaiting start auction"); + async_start_auction(instantiator, block_orchestrator, project_id, issuer).await.unwrap(); project_id } @@ -1662,9 +1645,7 @@ pub mod async_features { block_orchestrator: Arc>, project_id: ProjectIdOf, ) -> Result<(), DispatchError> { - println!("async_start_community_funding requesting lock"); let mut inst = instantiator.lock().await; - println!("async_start_community_funding lock given"); let english_end = inst .get_project_details(project_id) @@ -1676,17 +1657,15 @@ pub mod async_features { let candle_start = english_end + 2u32.into(); let notify = Arc::new(Notify::new()); - println!("async_start_community_funding adding to awaiting projects"); + block_orchestrator.add_awaiting_project(candle_start, notify.clone()).await; - println!("async_start_community_funding awaiting projects added"); + // Wait for the notification that our desired block was reached to continue - println!("async_start_community_funding dropping lock"); + drop(inst); - println!("async_start_community_funding lock dropped"); - println!("async_start_community_funding awaiting notification"); + notify.notified().await; - println!("async_start_community_funding notification received"); - println!("async_start_community_funding requesting lock"); + inst = instantiator.lock().await; let candle_end = inst .get_project_details(project_id) @@ -1698,19 +1677,15 @@ pub mod async_features { let community_start = candle_end + 2u32.into(); let notify = Arc::new(Notify::new()); - println!("async_start_community_funding adding to awaiting projects"); + block_orchestrator.add_awaiting_project(community_start, notify.clone()).await; // Wait for the notification that our desired block was reached to continue - println!("async_start_community_funding dropping lock"); + drop(inst); - println!("async_start_community_funding lock dropped"); - println!("async_start_community_funding awaiting notification"); + notify.notified().await; - println!("async_start_community_funding notification received"); - println!("async_start_community_funding requesting lock"); inst = instantiator.lock().await; - println!("async_start_community_funding lock given"); assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::CommunityRound); @@ -1732,7 +1707,7 @@ pub mod async_features { if bids.is_empty() { panic!("Cannot start community funding without bids") } - println!("creating auctioning project inside community project"); + let project_id = async_create_auctioning_project( instantiator.clone(), block_orchestrator.clone(), @@ -1741,9 +1716,9 @@ pub mod async_features { evaluations.clone(), ) .await; - println!("requesting inst lock"); + let mut inst = instantiator.lock().await; - println!("lock given"); + let bids = inst.simulate_bids_with_bucket(bids, project_id); let bidders = bids.accounts(); let bidders_non_evaluators = @@ -1843,9 +1818,7 @@ pub mod async_features { block_orchestrator: Arc>, project_id: ProjectIdOf, ) -> Result<(), DispatchError> { - println!("async_start_remainder_or_end_funding requesting lock"); let mut inst = instantiator.lock().await; - println!("async_start_remainder_or_end_funding lock given"); assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::CommunityRound); let community_funding_end = inst @@ -1857,20 +1830,17 @@ pub mod async_features { let remainder_start = community_funding_end + 1u32.into(); let notify = Arc::new(Notify::new()); - println!("async_start_remainder_or_end_funding adding to awaiting projects"); + block_orchestrator.add_awaiting_project(remainder_start, notify.clone()).await; - println!("async_start_remainder_or_end_funding awaiting projects added"); + // Wait for the notification that our desired block was reached to continue - println!("dropping inst lock"); + drop(inst); - println!("inst lock dropped"); - println!("async_start_remainder_or_end_funding awaiting notification"); + notify.notified().await; - println!("async_start_remainder_or_end_funding notification received"); - println!("async_start_remainder_or_end_funding requesting inst lock"); let mut inst = instantiator.lock().await; - println!("async_start_remainder_or_end_funding lock given"); + match inst.get_project_details(project_id).status { ProjectStatus::RemainderRound | ProjectStatus::FundingSuccessful => Ok(()), _ => panic!("Bad state"), @@ -1890,7 +1860,6 @@ pub mod async_features { bids: Vec>, contributions: Vec>, ) -> (ProjectIdOf, Vec>) { - println!("creating community project inside remainder project"); let (project_id, accepted_bids) = async_create_community_contributing_project( instantiator.clone(), block_orchestrator.clone(), @@ -1900,7 +1869,6 @@ pub mod async_features { bids, ) .await; - println!("done"); if contributions.is_empty() { async_start_remainder_or_end_funding(instantiator.clone(), block_orchestrator.clone(), project_id) @@ -1909,9 +1877,7 @@ pub mod async_features { return (project_id, accepted_bids) } - println!("requesting inst lock"); let mut inst = instantiator.lock().await; - println!("lock given"); let ct_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); let contributors = contributions.accounts(); @@ -2004,9 +1970,7 @@ pub mod async_features { block_orchestrator: Arc>, project_id: ProjectIdOf, ) -> Result<(), DispatchError> { - println!("async_finish_funding requesting lock"); let mut inst = instantiator.lock().await; - println!("async_finish_funding lock given"); let (update_block, _) = inst.get_update_pair(project_id); let current_block = inst.current_block(); @@ -2016,17 +1980,14 @@ pub mod async_features { drop(inst); let notify = Arc::new(Notify::new()); - println!("async_finish_funding adding to awaiting projects"); + block_orchestrator.add_awaiting_project(end_block, notify.clone()).await; - println!("async_finish_funding awaiting projects added"); + // Wait for the notification that our desired block was reached to continue - println!("async_finish_funding awaiting notification"); + notify.notified().await; - println!("async_finish_funding notification received"); - println!("async_finish_funding requesting lock"); inst = instantiator.lock().await; - println!("async_finish_funding lock given"); } let project_details = inst.get_project_details(project_id); @@ -2056,7 +2017,6 @@ pub mod async_features { community_contributions: Vec>, remainder_contributions: Vec>, ) -> ProjectIdOf { - println!("creating remainder project inside finished project"); let (project_id, accepted_bids) = async_create_remainder_contributing_project( instantiator.clone(), block_orchestrator.clone(), @@ -2067,11 +2027,8 @@ pub mod async_features { community_contributions.clone(), ) .await; - println!("done"); - println!("requesting inst lock"); let mut inst = instantiator.lock().await; - println!("lock given"); let real_bid_amounts = inst.simulate_bids_with_bucket(bids.clone(), project_id); let total_ct_sold_in_bids = @@ -2297,7 +2254,6 @@ pub mod async_features { match test_project_params.expected_state { ProjectStatus::Application => { - println!("application project creation requested"); let notify = Arc::new(Notify::new()); block_orchestrator .add_awaiting_project(now + time_to_finish - time_to_new_project, notify.clone()) @@ -2308,7 +2264,6 @@ pub mod async_features { .await }, ProjectStatus::EvaluationRound => { - println!("evaluation project creation requested"); let notify = Arc::new(Notify::new()); block_orchestrator .add_awaiting_project(now + time_to_finish - time_to_evaluation, notify.clone()) @@ -2323,7 +2278,6 @@ pub mod async_features { .await }, ProjectStatus::AuctionRound(_) => { - println!("auction project creation requested"); let notify = Arc::new(Notify::new()); block_orchestrator.add_awaiting_project(now + time_to_finish - time_to_auction, notify.clone()).await; // Wait for the notification that our desired block was reached to continue @@ -2338,7 +2292,6 @@ pub mod async_features { .await }, ProjectStatus::CommunityRound => { - println!("community project creation requested"); let notify = Arc::new(Notify::new()); block_orchestrator.add_awaiting_project(now + time_to_finish - time_to_community, notify.clone()).await; // Wait for the notification that our desired block was reached to continue @@ -2355,7 +2308,6 @@ pub mod async_features { .await }, ProjectStatus::RemainderRound => { - println!("remainder project creation requested"); let notify = Arc::new(Notify::new()); block_orchestrator.add_awaiting_project(now + time_to_finish - time_to_remainder, notify.clone()).await; // Wait for the notification that our desired block was reached to continue @@ -2373,7 +2325,6 @@ pub mod async_features { .await }, ProjectStatus::FundingSuccessful => { - println!("finished project creation requested"); let notify = Arc::new(Notify::new()); block_orchestrator.add_awaiting_project(now + time_to_finish - time_to_finish, notify.clone()).await; // Wait for the notification that our desired block was reached to continue @@ -2866,7 +2817,7 @@ pub mod testing_macros { // // events.iter().find_map(|event_record| { // if let frame_system::EventRecord { - // event: RuntimeEvent::FundingModule(desired_event @ $pattern), + // event: RuntimeEvent::PolimecFunding(desired_event @ $pattern), // .. // } = event_record // { @@ -2886,7 +2837,8 @@ pub mod testing_macros { let events = System::events(); events.iter().find_map(|event_record| { - if let frame_system::EventRecord { event: RuntimeEvent::FundingModule($pattern), .. } = event_record + if let frame_system::EventRecord { event: RuntimeEvent::PolimecFunding($pattern), .. } = + event_record { Some($field.clone()) } else { diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 4997937a3..748495222 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -197,6 +197,7 @@ use traits::DoRemainingOperation; pub use types::*; use xcm::v3::{opaque::Instruction, prelude::*, SendXcm}; pub mod functions; + #[cfg(test)] pub mod mock; pub mod types; @@ -208,6 +209,7 @@ pub mod tests; #[cfg(feature = "runtime-benchmarks")] pub mod benchmarking; pub mod impls; +#[cfg(any(feature = "runtime-benchmarks", feature = "std"))] pub mod instantiator; pub mod traits; diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 9adbca0d9..406624fb8 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -19,7 +19,9 @@ //! Test environment for Funding pallet. use super::*; +use crate as pallet_funding; use frame_support::{ + construct_runtime, pallet_prelude::Weight, parameter_types, traits::{AsEnsureOriginWithArg, ConstU16, ConstU32, WithdrawReasons}, @@ -51,21 +53,6 @@ pub const EXISTENTIAL_DEPOSIT: Balance = 10 * MILLI_PLMC; const US_DOLLAR: u128 = 1_0_000_000_000u128; -// Configure a mock runtime to test the pallet. -frame_support::construct_runtime!( - pub enum TestRuntime - { - System: frame_system, - RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip, - Balances: pallet_balances, - FundingModule: crate, - Vesting: pallet_linear_release, - LocalAssets: pallet_assets::::{Pallet, Call, Storage, Event}, - StatemintAssets: pallet_assets::::{Pallet, Call, Storage, Event, Config}, - PolkadotXcm: pallet_xcm, - } -); - pub type LocalAssetsInstance = pallet_assets::Instance1; pub type StatemintAssetsInstance = pallet_assets::Instance2; @@ -396,11 +383,26 @@ impl Config for TestRuntime { type WeightInfo = weights::SubstrateWeight; } +// Configure a mock runtime to test the pallet. +construct_runtime!( + pub enum TestRuntime + { + System: frame_system, + RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip, + Balances: pallet_balances, + Vesting: pallet_linear_release, + LocalAssets: pallet_assets::::{Pallet, Call, Storage, Event}, + StatemintAssets: pallet_assets::::{Pallet, Call, Storage, Event, Config}, + PolkadotXcm: pallet_xcm, + PolimecFunding: pallet_funding::{Pallet, Call, Storage, Event, Config} = 52, + } +); + // Build genesis storage according to the mock runtime. pub fn new_test_ext() -> sp_io::TestExternalities { let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - GenesisConfig { + RuntimeGenesisConfig { balances: BalancesConfig { balances: vec![( ::PalletId::get().into_account_truncating(), diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index f50e79d6b..08c8755e1 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -28,12 +28,14 @@ use frame_support::{ use itertools::Itertools; use parachains_common::DAYS; use sp_arithmetic::{traits::Zero, Percent, Perquintill}; +use sp_runtime::BuildStorage; use sp_std::{cell::RefCell, marker::PhantomData}; use std::{cmp::min, iter::zip}; use defaults::*; use polimec_common::ReleaseSchedule; +use super::*; use crate::{ instantiator::*, mock::*, @@ -42,10 +44,6 @@ use crate::{ UpdateType::{CommunityFundingStart, RemainderFundingStart}, }; -use mock::TestRuntime; - -use super::*; - type MockInstantiator = Instantiator; const METADATA: &str = r#"METADATA @@ -1780,7 +1778,7 @@ mod auction_round_failure { let project_id = inst.create_evaluating_project(default_project(0, ISSUER), ISSUER); inst.execute(|| { assert_noop!( - FundingModule::start_auction(RuntimeOrigin::signed(ISSUER), project_id), + PolimecFunding::start_auction(RuntimeOrigin::signed(ISSUER), project_id), Error::::EvaluationPeriodNotEnded ); }); @@ -1792,7 +1790,7 @@ mod auction_round_failure { let _ = inst.create_evaluating_project(default_project(0, ISSUER), ISSUER); inst.execute(|| { assert_noop!( - FundingModule::bid( + PolimecFunding::bid( RuntimeOrigin::signed(BIDDER_2), 0, 1, @@ -1810,7 +1808,7 @@ mod auction_round_failure { let project_id = inst.create_evaluating_project(default_project(0, ISSUER), ISSUER); inst.execute(|| { assert_noop!( - FundingModule::contribute( + PolimecFunding::contribute( RuntimeOrigin::signed(BIDDER_1), project_id, 100, @@ -3876,7 +3874,7 @@ mod funding_end { let project_id = project_id; inst.execute(|| { - FundingModule::do_decide_project_outcome(ISSUER, project_id, FundingOutcomeDecision::AcceptFunding) + PolimecFunding::do_decide_project_outcome(ISSUER, project_id, FundingOutcomeDecision::AcceptFunding) }) .unwrap(); @@ -3925,7 +3923,7 @@ mod funding_end { let project_id = project_id; inst.execute(|| { - FundingModule::do_decide_project_outcome(ISSUER, project_id, FundingOutcomeDecision::RejectFunding) + PolimecFunding::do_decide_project_outcome(ISSUER, project_id, FundingOutcomeDecision::RejectFunding) }) .unwrap(); @@ -4014,7 +4012,7 @@ mod funding_end { call_and_is_ok!( inst, - FundingModule::do_decide_project_outcome(ISSUER, project_id, FundingOutcomeDecision::AcceptFunding) + PolimecFunding::do_decide_project_outcome(ISSUER, project_id, FundingOutcomeDecision::AcceptFunding) ); inst.advance_time(1u64).unwrap(); assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingSuccessful); @@ -4055,7 +4053,7 @@ mod funding_end { call_and_is_ok!( inst, - FundingModule::do_decide_project_outcome(ISSUER, project_id, FundingOutcomeDecision::RejectFunding) + PolimecFunding::do_decide_project_outcome(ISSUER, project_id, FundingOutcomeDecision::RejectFunding) ); inst.advance_time(1u64).unwrap(); assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingFailed); @@ -5790,16 +5788,16 @@ mod misc_features { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let now = inst.current_block(); inst.execute(|| { - FundingModule::add_to_update_store(now + 10u64, (&42u32, CommunityFundingStart)); - FundingModule::add_to_update_store(now + 20u64, (&69u32, RemainderFundingStart)); - FundingModule::add_to_update_store(now + 5u64, (&404u32, RemainderFundingStart)); + PolimecFunding::add_to_update_store(now + 10u64, (&42u32, CommunityFundingStart)); + PolimecFunding::add_to_update_store(now + 20u64, (&69u32, RemainderFundingStart)); + PolimecFunding::add_to_update_store(now + 5u64, (&404u32, RemainderFundingStart)); }); inst.advance_time(2u64).unwrap(); inst.execute(|| { let stored = ProjectsToUpdate::::iter_values().collect::>(); assert_eq!(stored.len(), 3, "There should be 3 blocks scheduled for updating"); - FundingModule::remove_from_update_store(&69u32).unwrap(); + PolimecFunding::remove_from_update_store(&69u32).unwrap(); let stored = ProjectsToUpdate::::iter_values().collect::>(); assert_eq!(stored[2], vec![], "Vector should be empty for that block after deletion"); @@ -6078,4 +6076,139 @@ mod async_tests { assert_eq!(inst.get_project_details(project_ids[4]).status, ProjectStatus::RemainderRound); assert_eq!(inst.get_project_details(project_ids[5]).status, ProjectStatus::FundingSuccessful); } + + #[test] + fn genesis_parallel_instantiaton() { + let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); + + // only used to generate some values, and not for chain interactions + let funding_percent = 93u64; + let project_metadata = default_project(0u64, ISSUER.into()); + let min_price = project_metadata.minimum_price; + let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) * + (project_metadata + .minimum_price + .checked_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1) + .unwrap()); + let evaluations = default_evaluations(); + let bids = MockInstantiator::generate_bids_from_total_usd( + Percent::from_percent(50u8) * twenty_percent_funding_usd, + min_price, + default_weights(), + default_bidders(), + default_bidder_multipliers(), + ); + let community_contributions = MockInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(30u8) * twenty_percent_funding_usd, + min_price, + default_weights(), + default_community_contributors(), + default_community_contributor_multipliers(), + ); + let remainder_contributions = MockInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(20u8) * twenty_percent_funding_usd, + min_price, + default_weights(), + default_remainder_contributors(), + default_remainder_contributor_multipliers(), + ); + mock::RuntimeGenesisConfig { + balances: BalancesConfig { + balances: vec![( + ::PalletId::get().into_account_truncating(), + ::ExistentialDeposit::get(), + )], + }, + statemint_assets: StatemintAssetsConfig { + assets: vec![( + AcceptedFundingAsset::USDT.to_statemint_id(), + ::PalletId::get().into_account_truncating(), + false, + 10, + )], + metadata: vec![], + accounts: vec![], + }, + polimec_funding: PolimecFundingConfig { + starting_projects: vec![ + TestProjectParams:: { + expected_state: ProjectStatus::FundingSuccessful, + metadata: default_project(0u64, ISSUER.into()), + issuer: ISSUER.into(), + evaluations: evaluations.clone(), + bids: bids.clone(), + community_contributions: community_contributions.clone(), + remainder_contributions: remainder_contributions.clone(), + }, + TestProjectParams:: { + expected_state: ProjectStatus::RemainderRound, + metadata: default_project(1u64, ISSUER.into()), + issuer: ISSUER.into(), + evaluations: evaluations.clone(), + bids: bids.clone(), + community_contributions: community_contributions.clone(), + remainder_contributions: vec![], + }, + TestProjectParams:: { + expected_state: ProjectStatus::CommunityRound, + metadata: default_project(2u64, ISSUER.into()), + issuer: ISSUER.into(), + evaluations: evaluations.clone(), + bids: bids.clone(), + community_contributions: vec![], + remainder_contributions: vec![], + }, + TestProjectParams:: { + expected_state: ProjectStatus::AuctionRound(AuctionPhase::English), + metadata: default_project(3u64, ISSUER.into()), + issuer: ISSUER.into(), + evaluations: evaluations.clone(), + bids: vec![], + community_contributions: vec![], + remainder_contributions: vec![], + }, + TestProjectParams:: { + expected_state: ProjectStatus::EvaluationRound, + metadata: default_project(4u64, ISSUER.into()), + issuer: ISSUER.into(), + evaluations: vec![], + bids: vec![], + community_contributions: vec![], + remainder_contributions: vec![], + }, + TestProjectParams:: { + expected_state: ProjectStatus::Application, + metadata: default_project(5u64, ISSUER.into()), + issuer: ISSUER.into(), + evaluations: vec![], + bids: vec![], + community_contributions: vec![], + remainder_contributions: vec![], + }, + ], + phantom: PhantomData, + }, + + ..Default::default() + } + .assimilate_storage(&mut t) + .unwrap(); + + let mut ext = sp_io::TestExternalities::new(t); + let mut inst = MockInstantiator::new(Some(RefCell::new(ext))); + + dbg!(inst.get_project_details(0).status); + dbg!(inst.get_project_details(1).status); + dbg!(inst.get_project_details(2).status); + dbg!(inst.get_project_details(3).status); + dbg!(inst.get_project_details(4).status); + dbg!(inst.get_project_details(5).status); + + assert_eq!(inst.get_project_details(5).status, ProjectStatus::Application); + assert_eq!(inst.get_project_details(4).status, ProjectStatus::EvaluationRound); + assert_eq!(inst.get_project_details(3).status, ProjectStatus::AuctionRound(AuctionPhase::English)); + assert_eq!(inst.get_project_details(2).status, ProjectStatus::CommunityRound); + assert_eq!(inst.get_project_details(1).status, ProjectStatus::RemainderRound); + assert_eq!(inst.get_project_details(0).status, ProjectStatus::FundingSuccessful); + } } diff --git a/pallets/sandbox/src/mock.rs b/pallets/sandbox/src/mock.rs index 44bb461ca..a4f71e3c0 100644 --- a/pallets/sandbox/src/mock.rs +++ b/pallets/sandbox/src/mock.rs @@ -53,7 +53,7 @@ // RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip, // Assets: pallet_assets, // Balances: pallet_balances, -// FundingModule: pallet_funding, +// PolimecFunding: pallet_funding, // Sandbox: crate, // } // ); diff --git a/pallets/sandbox/src/tests.rs b/pallets/sandbox/src/tests.rs index 9f47a7534..26c25cf8c 100644 --- a/pallets/sandbox/src/tests.rs +++ b/pallets/sandbox/src/tests.rs @@ -17,9 +17,9 @@ // let contributor = 4; // let project = default_project(0); -// assert_ok!(FundingModule::create(RuntimeOrigin::signed(creator), project.clone(),)); -// assert_ok!(FundingModule::start_evaluation(RuntimeOrigin::signed(creator), 0)); -// assert_ok!(FundingModule::bond_evaluation(RuntimeOrigin::signed(evaluator), 0, 120_000 * PLMC)); +// assert_ok!(PolimecFunding::create(RuntimeOrigin::signed(creator), project.clone(),)); +// assert_ok!(PolimecFunding::start_evaluation(RuntimeOrigin::signed(creator), 0)); +// assert_ok!(PolimecFunding::bond_evaluation(RuntimeOrigin::signed(evaluator), 0, 120_000 * PLMC)); // // advance time // for _block in 0..::EvaluationDuration::get() + 10 { @@ -29,7 +29,7 @@ // >::on_initialize(System::block_number()); // } -// assert_ok!(FundingModule::start_auction(RuntimeOrigin::signed(creator), 0)); +// assert_ok!(PolimecFunding::start_auction(RuntimeOrigin::signed(creator), 0)); // // advance time // for _block in 0..2 { @@ -39,7 +39,7 @@ // >::on_initialize(System::block_number()); // } -// assert_ok!(FundingModule::bid(RuntimeOrigin::signed(bidder), 0, 1000, 100 * PLMC, None, 1984)); +// assert_ok!(PolimecFunding::bid(RuntimeOrigin::signed(bidder), 0, 1000, 100 * PLMC, None, 1984)); // // advance time // for _block in 0..(::EnglishAuctionDuration::get() + @@ -52,11 +52,11 @@ // >::on_initialize(System::block_number()); // } -// assert_ok!(FundingModule::contribute(RuntimeOrigin::signed(contributor), 0, 1, None, 1984)); +// assert_ok!(PolimecFunding::contribute(RuntimeOrigin::signed(contributor), 0, 1, None, 1984)); // assert!(Sandbox::buy_if_popular(RuntimeOrigin::signed(4), 0, 1000, 1984).is_err()); -// assert_ok!(FundingModule::contribute(RuntimeOrigin::signed(contributor), 0, 10000, None, 1984)); +// assert_ok!(PolimecFunding::contribute(RuntimeOrigin::signed(contributor), 0, 10000, None, 1984)); // assert_ok!(Sandbox::buy_if_popular(RuntimeOrigin::signed(4), 0, 1000, 1984)); // }); From 28da8b4f8dbbd72f8e4d572ca8133a0c6358de6f Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 5 Jan 2024 17:24:09 +0100 Subject: [PATCH 091/212] node instantiation confirmed to be working, and a test was written in integration-tests Signed-off-by: Juan Ignacio Rios --- integration-tests/Cargo.toml | 3 +- integration-tests/src/tests/build_spec.rs | 31 ++++++++++++++++ integration-tests/src/tests/mod.rs | 1 + pallets/funding/src/functions.rs | 19 +++++++++- pallets/funding/src/instantiator.rs | 15 +++++--- ...pless-rococo-statemint-polimec-penpal.toml | 34 ++++++++--------- scripts/zombienet/native/ui-test.toml | 37 +++++++++++++++++++ 7 files changed, 114 insertions(+), 26 deletions(-) create mode 100644 integration-tests/src/tests/build_spec.rs create mode 100644 scripts/zombienet/native/ui-test.toml diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index f2cd336c1..7230ad436 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -21,7 +21,6 @@ scale-info = { workspace = true, features = ["derive"] } polimec-receiver.workspace = true macros.workspace = true polimec-common.workspace = true - sp-arithmetic.workspace = true frame-system.workspace = true frame-support.workspace = true @@ -112,7 +111,7 @@ std = [ "xcm-builder/std", "xcm-executor/std", "xcm/std", - "itertools/use_std" + "itertools/use_std", ] runtime-benchmarks = [ diff --git a/integration-tests/src/tests/build_spec.rs b/integration-tests/src/tests/build_spec.rs new file mode 100644 index 000000000..661ca3f99 --- /dev/null +++ b/integration-tests/src/tests/build_spec.rs @@ -0,0 +1,31 @@ +#[test] +fn build_spec_testing_node() { + // run the polimec-parachain-node compiled with "std" with the build-spec command and --raw flag + // This makes sure our async parallel instantiation of projects is working as intended. + // We need this to test the protocol with the UI. + + match std::env::current_dir() { + Ok(path) => { + println!("The current directory is {}", path.display()); + }, + Err(e) => { + println!("Error getting the current directory: {}", e); + }, + } + + let output = std::process::Command::new("../target/release/polimec-parachain-node") + .arg("build-spec") + .arg("--chain=polimec-testing") + .arg("--disable-default-bootnode") + .arg("--raw") + .output() + .expect("failed to execute process"); + + assert_eq!( + output.status.success(), + true, + "Make sure you compile the node with \"std\" feature enabled before running this test." + ); + + dbg!(output); +} diff --git a/integration-tests/src/tests/mod.rs b/integration-tests/src/tests/mod.rs index 21790eb6c..2e5c58a5f 100644 --- a/integration-tests/src/tests/mod.rs +++ b/integration-tests/src/tests/mod.rs @@ -1,4 +1,5 @@ mod basic_comms; +mod build_spec; mod ct_migration; mod defaults; mod e2e; diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 6cad68c5c..bdaa02069 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -26,7 +26,7 @@ use frame_support::{ fungible::{InspectHold, MutateHold as FungibleMutateHold}, fungibles::{metadata::Mutate as MetadataMutate, Create, Inspect, Mutate as FungiblesMutate}, tokens::{Fortitude, Precision, Preservation, Restriction}, - Get, + ExistenceRequirement, Get, }, }; use frame_system::pallet_prelude::BlockNumberFor; @@ -43,6 +43,7 @@ use crate::ProjectStatus::FundingSuccessful; use polimec_common::ReleaseSchedule; use crate::traits::{BondingRequirementCalculation, ProvideStatemintPrice, VestingDurationCalculation}; +use frame_support::traits::fungible::Mutate; use polimec_common::migration_types::{MigrationInfo, MigrationOrigin, Migrations, ParticipationType}; use super::*; @@ -119,6 +120,18 @@ impl Pallet { }; let bucket: BucketOf = Self::create_bucket_from_metadata(&initial_metadata)?; + + // Each project needs an escrow system account to temporarily hold the USDT/USDC. We need to create it by depositing `ED` amount of PLMC into it. + // This should be paid by the issuer. + let escrow_account = Self::fund_account_id(project_id); + // transfer ED from issuer to escrow + T::NativeCurrency::transfer( + &issuer, + &escrow_account, + ::ExistentialDeposit::get(), + Preservation::Preserve, + )?; + // * Update storage * ProjectsMetadata::::insert(project_id, &initial_metadata); ProjectsDetails::::insert(project_id, project_details); @@ -2312,7 +2325,8 @@ impl Pallet { /// value and only call this once. #[inline(always)] pub fn fund_account_id(index: T::ProjectIdentifier) -> AccountIdOf { - T::PalletId::get().into_sub_account_truncating(index) + // since the project_id starts at 0, we need to add 1 to get a different sub_account than the pallet account. + T::PalletId::get().into_sub_account_truncating(index.saturating_add(One::one())) } /// Adds a project to the ProjectsToUpdate storage, so it can be updated at some later point in time. @@ -2674,6 +2688,7 @@ impl Pallet { ) -> DispatchResult { let fund_account = Self::fund_account_id(project_id); + // The USDT/USDC account should be created by using a provider reference (as opposed to a deposit with `touch()`), so we don't care if it gets destroyed now. T::FundingCurrency::transfer(asset_id, who, &fund_account, amount, Preservation::Expendable)?; Ok(()) diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 551b92651..1f563448c 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -842,7 +842,8 @@ impl< issuer: AccountIdOf, ) -> ProjectIdOf { let now = self.current_block(); - self.mint_plmc_to(vec![UserToPLMCBalance::new(issuer.clone(), Self::get_ed())]); + // one ED for the issuer, one ED for the escrow account + self.mint_plmc_to(vec![UserToPLMCBalance::new(issuer.clone(), Self::get_ed() * 2u64.into())]); self.execute(|| { crate::Pallet::::do_create(&issuer, project_metadata.clone()).unwrap(); let last_project_metadata = ProjectsMetadata::::iter().last().unwrap(); @@ -1509,9 +1510,10 @@ pub mod async_features { dbg!(asset_account_deposit); dbg!(ed); let now = inst.current_block(); + // One ED for the issuer, one for the escrow account inst.mint_plmc_to(vec![UserToPLMCBalance::new( issuer.clone(), - Instantiator::::get_ed(), + Instantiator::::get_ed() * 2u64.into(), )]); inst.execute(|| { crate::Pallet::::do_create(&issuer, project_metadata.clone()).unwrap(); @@ -1673,7 +1675,7 @@ pub mod async_features { .candle_auction .end() .expect("Candle end point should exist"); - + let prev = inst.current_block(); let community_start = candle_end + 2u32.into(); let notify = Arc::new(Notify::new()); @@ -1686,6 +1688,7 @@ pub mod async_features { notify.notified().await; inst = instantiator.lock().await; + let now = inst.current_block(); assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::CommunityRound); @@ -1783,6 +1786,7 @@ pub mod async_features { inst.do_free_statemint_asset_assertions(prev_funding_asset_balances.merge_accounts(MergeOperation::Add)); assert_eq!(inst.get_plmc_total_supply(), post_supply); + let details = inst.get_project_details(project_id); drop(inst); async_start_community_funding(instantiator.clone(), block_orchestrator, project_id).await.unwrap(); let mut inst = instantiator.lock().await; @@ -1973,8 +1977,9 @@ pub mod async_features { let mut inst = instantiator.lock().await; let (update_block, _) = inst.get_update_pair(project_id); - let current_block = inst.current_block(); - inst.advance_time(update_block.saturating_sub(current_block)).unwrap(); + + let notify = Arc::new(Notify::new()); + block_orchestrator.add_awaiting_project(update_block, notify.clone()).await; if inst.get_project_details(project_id).status == ProjectStatus::RemainderRound { let (end_block, _) = inst.get_update_pair(project_id); drop(inst); diff --git a/scripts/zombienet/native/hrmpless-rococo-statemint-polimec-penpal.toml b/scripts/zombienet/native/hrmpless-rococo-statemint-polimec-penpal.toml index 821f2786d..c23809241 100644 --- a/scripts/zombienet/native/hrmpless-rococo-statemint-polimec-penpal.toml +++ b/scripts/zombienet/native/hrmpless-rococo-statemint-polimec-penpal.toml @@ -26,15 +26,15 @@ chain = "rococo-local" [[relaychain.nodes]] name = "ferdie" -#[[parachains]] -#id = 1000 -#chain = "statemint-local" -# -# [[parachains.collators]] -# name = "statemint-dev" -# command = "../cumulus/target/release/polkadot-parachain" -# args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] -# ws_port = 7777 +[[parachains]] +id = 1000 +chain = "statemint-local" + + [[parachains.collators]] + name = "statemint-dev" + command = "../cumulus/target/release/polkadot-parachain" + args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] + ws_port = 7777 [[parachains]] @@ -46,11 +46,11 @@ chain = "polimec-testing" args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] ws_port = 8888 -#[[parachains]] -#id = 3000 -#chain = "penpal-polkadot-3000" -# [[parachains.collators]] -# name = "penpal-collator" -# command = "../cumulus/target/release/polkadot-parachain" -# args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] -# ws_port = 9999 \ No newline at end of file +[[parachains]] +id = 3000 +chain = "penpal-polkadot-3000" + [[parachains.collators]] + name = "penpal-collator" + command = "../cumulus/target/release/polkadot-parachain" + args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] + ws_port = 9999 \ No newline at end of file diff --git a/scripts/zombienet/native/ui-test.toml b/scripts/zombienet/native/ui-test.toml new file mode 100644 index 000000000..ca0d602e6 --- /dev/null +++ b/scripts/zombienet/native/ui-test.toml @@ -0,0 +1,37 @@ +[settings] +timeout = 1000 +provider = "native" + +[relaychain] +default_command = "../polkadot/target/release/polkadot" +chain = "rococo-local" + + +[[relaychain.nodes]] +name = "alice" +ws_port = 6969 +args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] +[[relaychain.nodes]] +name = "bob" + +[[relaychain.nodes]] +name = "charlie" + +[[relaychain.nodes]] +name = "dave" + +[[relaychain.nodes]] +name = "eve" + +[[relaychain.nodes]] +name = "ferdie" + + +[[parachains]] +id = 3344 +chain = "polimec-testing" +[[parachains.collators]] +name = "polimec-testing" +command = "./target/release/polimec-parachain-node" +args = ["-lerror", "-lxcm::process_instruction=trace", "-lxcm::execute_xcm_in_credit=trace", "-lxcm::barriers=trace", "-lpallet_funding::hrmp=trace", "-lpallet_funding::test=trace", "--execution=native", ] +ws_port = 8888 \ No newline at end of file From df4390eededed306026def9d9d96fd51837ccad4 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 8 Jan 2024 12:37:07 +0100 Subject: [PATCH 092/212] fix: fmt Signed-off-by: Juan Ignacio Rios --- integration-tests/src/tests/basic_comms.rs | 1 + integration-tests/src/tests/ct_migration.rs | 11 ++-- integration-tests/src/tests/defaults.rs | 57 +-------------------- integration-tests/src/tests/e2e.rs | 7 --- nodes/parachain/src/chain_spec/testnet.rs | 2 + pallets/funding/src/benchmarking.rs | 2 + pallets/funding/src/functions.rs | 2 +- pallets/funding/src/instantiator.rs | 4 -- pallets/funding/src/lib.rs | 13 ++--- pallets/funding/src/tests.rs | 2 +- 10 files changed, 14 insertions(+), 87 deletions(-) diff --git a/integration-tests/src/tests/basic_comms.rs b/integration-tests/src/tests/basic_comms.rs index d7ca133c6..557e08152 100644 --- a/integration-tests/src/tests/basic_comms.rs +++ b/integration-tests/src/tests/basic_comms.rs @@ -1,3 +1,4 @@ +#[allow(unused_imports)] use crate::*; const MAX_REF_TIME: u64 = 300_000_000; diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index 617f98a7f..040dc9412 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -1,11 +1,11 @@ use crate::*; use pallet_funding::{ - assert_close_enough, traits::VestingDurationCalculation, AcceptedFundingAsset, BidStatus, EvaluatorsOutcome, - MigrationStatus, Multiplier, MultiplierOf, ProjectIdOf, RewardOrSlash, + assert_close_enough, traits::VestingDurationCalculation, BidStatus, EvaluatorsOutcome, MigrationStatus, Multiplier, + ProjectIdOf, RewardOrSlash, }; use polimec_common::migration_types::{Migration, MigrationInfo, MigrationOrigin, Migrations, ParticipationType}; use polimec_parachain_runtime::PolimecFunding; -use sp_runtime::{traits::Convert, FixedPointNumber, Perquintill}; +use sp_runtime::{traits::Convert, Perquintill}; use std::collections::HashMap; use tests::defaults::*; @@ -262,7 +262,6 @@ fn migrations_are_vested(grouped_migrations: Vec) { #[test] fn migration_check() { let mut inst = IntegrationInstantiator::new(None); - set_oracle_prices(); let project_id = Polimec::execute_with(|| { let project_id = inst.create_finished_project( default_project(ISSUER.into(), 0), @@ -285,7 +284,6 @@ fn migration_check() { #[test] fn migration_is_sent() { let mut inst = IntegrationInstantiator::new(None); - set_oracle_prices(); let mut participants = vec![EVAL_1, EVAL_2, EVAL_3, BIDDER_1, BIDDER_2, BIDDER_3, BIDDER_4, BUYER_1, BUYER_2, BUYER_3, BUYER_4] .into_iter() @@ -331,7 +329,6 @@ fn migration_is_sent() { #[test] fn migration_is_executed_on_project_and_confirmed_on_polimec() { let mut inst = IntegrationInstantiator::new(None); - set_oracle_prices(); let participants = vec![EVAL_1, EVAL_2, EVAL_3, BIDDER_2, BIDDER_3, BIDDER_4, BIDDER_5, BUYER_2, BUYER_3, BUYER_4, BUYER_5] .into_iter() @@ -382,7 +379,6 @@ fn migration_is_executed_on_project_and_confirmed_on_polimec() { #[test] fn vesting_over_several_blocks_on_project() { let mut inst = IntegrationInstantiator::new(None); - set_oracle_prices(); let participants = vec![EVAL_1, EVAL_2, EVAL_3, BIDDER_1, BIDDER_2, BUYER_1, BUYER_2, BUYER_3] .into_iter() .map(|x| AccountId::from(x)) @@ -478,7 +474,6 @@ fn vesting_over_several_blocks_on_project() { #[test] fn disallow_duplicated_migrations_on_receiver_pallet() { let mut inst = IntegrationInstantiator::new(None); - set_oracle_prices(); let project_id = Polimec::execute_with(|| { inst.create_finished_project( diff --git a/integration-tests/src/tests/defaults.rs b/integration-tests/src/tests/defaults.rs index 40e4a0e9c..679b12ae5 100644 --- a/integration-tests/src/tests/defaults.rs +++ b/integration-tests/src/tests/defaults.rs @@ -1,3 +1,4 @@ +use crate::{Polimec, PolimecRuntime, ALICE, BOB, CHARLIE}; use frame_support::{assert_ok, bounded_vec, BoundedVec}; pub use pallet_funding::instantiator::{BidParams, ContributionParams, UserToPLMCBalance, UserToUSDBalance}; use pallet_funding::{ @@ -129,59 +130,3 @@ pub fn default_community_contributors() -> Vec { pub fn default_remainder_contributors() -> Vec { vec![EVAL_4.into(), BUYER_6.into(), BIDDER_6.into(), EVAL_1.into(), BUYER_1.into(), BIDDER_1.into()] } - -use crate::{Polimec, PolimecRuntime, ALICE, BOB, CHARLIE}; - -pub fn set_oracle_prices() { - // Polimec::execute_with(|| { - // fn values( - // values: [f64; 4], - // ) -> BoundedVec< - // (u32, FixedU128), - // >::MaxFeedValues, - // > { - // let [dot, usdc, usdt, plmc] = values; - // bounded_vec![ - // (0u32, FixedU128::from_float(dot)), - // (420u32, FixedU128::from_float(usdc)), - // (1984u32, FixedU128::from_float(usdt)), - // (2069u32, FixedU128::from_float(plmc)) - // ] - // } - // - // let alice = Polimec::account_id_of(ALICE); - // assert_ok!(polimec_parachain_runtime::Oracle::feed_values( - // PolimecOrigin::signed(alice.clone()), - // values([4.84, 1.0, 1.0, 0.4]) - // )); - // - // let bob = Polimec::account_id_of(BOB); - // assert_ok!(polimec_parachain_runtime::Oracle::feed_values( - // PolimecOrigin::signed(bob.clone()), - // values([4.84, 1.0, 1.0, 0.4]) - // )); - // - // let charlie = Polimec::account_id_of(CHARLIE); - // assert_ok!(polimec_parachain_runtime::Oracle::feed_values( - // PolimecOrigin::signed(charlie.clone()), - // values([4.84, 1.0, 1.0, 0.4]) - // )); - // - // let expected_values = HashMap::from([ - // (0u32, FixedU128::from_float(4.84)), - // (420u32, FixedU128::from_float(1.0)), - // (1984u32, FixedU128::from_float(1.0)), - // (2069u32, FixedU128::from_float(0.4)), - // ]); - // - // for (key, value) in polimec_parachain_runtime::Oracle::get_all_values() { - // assert!(value.is_some()); - // assert_eq!(expected_values.get(&key).unwrap(), &value.unwrap().value); - // } - // }); -} - -#[test] -fn something() { - assert!(true); -} diff --git a/integration-tests/src/tests/e2e.rs b/integration-tests/src/tests/e2e.rs index 4d7e27026..9eedfb7c8 100644 --- a/integration-tests/src/tests/e2e.rs +++ b/integration-tests/src/tests/e2e.rs @@ -245,7 +245,6 @@ fn evaluation_round_completed() { let issuer = ISSUER.into(); let project = excel_project(inst.get_new_nonce()); let evaluations = excel_evaluators(); - set_oracle_prices(); Polimec::execute_with(|| { inst.create_auctioning_project(project, issuer, evaluations); @@ -260,7 +259,6 @@ fn auction_round_completed() { let project = excel_project(inst.get_new_nonce()); let evaluations = excel_evaluators(); let bids = excel_bidders(); - set_oracle_prices(); Polimec::execute_with(|| { //let filtered_bids = MockInstantiator::filter_bids_after_auction(bids.clone(), project.total_allocation_size.0); @@ -292,7 +290,6 @@ fn auction_round_completed() { #[test] fn community_round_completed() { let mut inst = IntegrationInstantiator::new(None); - set_oracle_prices(); Polimec::execute_with(|| { let _ = inst.create_remainder_contributing_project( @@ -327,7 +324,6 @@ fn community_round_completed() { #[test] fn remainder_round_completed() { let mut inst = IntegrationInstantiator::new(None); - set_oracle_prices(); Polimec::execute_with(|| { let project_id = inst.create_finished_project( @@ -373,7 +369,6 @@ fn remainder_round_completed() { #[test] fn funds_raised() { let mut inst = IntegrationInstantiator::new(None); - set_oracle_prices(); Polimec::execute_with(|| { let project_id = inst.create_finished_project( @@ -402,7 +397,6 @@ fn funds_raised() { #[test] fn ct_minted() { let mut inst = IntegrationInstantiator::new(None); - set_oracle_prices(); Polimec::execute_with(|| { let _ = inst.create_finished_project( @@ -428,7 +422,6 @@ fn ct_minted() { #[test] fn ct_migrated() { let mut inst = IntegrationInstantiator::new(None); - set_oracle_prices(); let project_id = Polimec::execute_with(|| { let project_id = inst.create_finished_project( diff --git a/nodes/parachain/src/chain_spec/testnet.rs b/nodes/parachain/src/chain_spec/testnet.rs index 44fbba209..34f42849e 100644 --- a/nodes/parachain/src/chain_spec/testnet.rs +++ b/nodes/parachain/src/chain_spec/testnet.rs @@ -274,6 +274,7 @@ fn testnet_genesis( use pallet_funding::{instantiator::UserToUSDBalance, *}; use sp_runtime::BoundedVec; +#[cfg(feature = "std")] mod testing_helpers { use super::*; use frame_benchmarking::frame_support::assert_ok; @@ -370,6 +371,7 @@ mod testing_helpers { >; } +#[cfg(feature = "std")] #[allow(clippy::too_many_arguments)] fn testing_genesis( wasm_binary: &[u8], diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index e671ed205..23967b858 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -211,9 +211,11 @@ mod benchmarks { ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + let ed = BenchInstantiator::::get_ed(); let issuer = account::>("issuer", 0, 0); whitelist_account!(issuer); + inst.mint_plmc_to(vec![UserToPLMCBalance::new(issuer.clone(), ed * 2u64.into())]); let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index bdaa02069..1b70f8a3e 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -26,7 +26,7 @@ use frame_support::{ fungible::{InspectHold, MutateHold as FungibleMutateHold}, fungibles::{metadata::Mutate as MetadataMutate, Create, Inspect, Mutate as FungiblesMutate}, tokens::{Fortitude, Precision, Preservation, Restriction}, - ExistenceRequirement, Get, + Get, }, }; use frame_system::pallet_prelude::BlockNumberFor; diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 1f563448c..582c817e4 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -1675,20 +1675,17 @@ pub mod async_features { .candle_auction .end() .expect("Candle end point should exist"); - let prev = inst.current_block(); let community_start = candle_end + 2u32.into(); let notify = Arc::new(Notify::new()); block_orchestrator.add_awaiting_project(community_start, notify.clone()).await; - // Wait for the notification that our desired block was reached to continue drop(inst); notify.notified().await; inst = instantiator.lock().await; - let now = inst.current_block(); assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::CommunityRound); @@ -1786,7 +1783,6 @@ pub mod async_features { inst.do_free_statemint_asset_assertions(prev_funding_asset_balances.merge_accounts(MergeOperation::Add)); assert_eq!(inst.get_plmc_total_supply(), post_supply); - let details = inst.get_project_details(project_id); drop(inst); async_start_community_funding(instantiator.clone(), block_orchestrator, project_id).await.unwrap(); let mut inst = instantiator.lock().await; diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 748495222..c9765e5b6 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -173,14 +173,11 @@ #![cfg_attr(feature = "runtime-benchmarks", recursion_limit = "512")] pub use crate::weights::WeightInfo; use frame_support::{ - dispatch::{Decode, Encode}, - pallet_macros::*, - pallet_prelude::BuildGenesisConfig, traits::{ tokens::{fungible, fungibles, Balance}, AccountTouch, ContainsPair, Randomness, }, - BoundedVec, PalletId, Parameter, + BoundedVec, PalletId, }; use frame_system::pallet_prelude::BlockNumberFor; pub use pallet::*; @@ -188,10 +185,7 @@ use polimec_common::migration_types::*; use polkadot_parachain::primitives::Id as ParaId; use sp_arithmetic::traits::{One, Saturating}; use sp_core::ConstU32; -use sp_runtime::{ - traits::{AccountIdConversion, Member}, - FixedPointNumber, FixedPointOperand, FixedU128, WeakBoundedVec, -}; +use sp_runtime::{traits::AccountIdConversion, FixedPointNumber, FixedPointOperand, FixedU128, WeakBoundedVec}; use sp_std::{marker::PhantomData, prelude::*}; use traits::DoRemainingOperation; pub use types::*; @@ -1411,9 +1405,8 @@ pub mod pallet { { type GenesisInstantiator = instantiator::Instantiator::AllPalletsWithoutSystem, ::RuntimeEvent>; - let mut inst = GenesisInstantiator::::new(None); + let inst = GenesisInstantiator::::new(None); ::SetPrices::set_prices(); - let current_block = >::block_number(); instantiator::async_features::create_multiple_projects_at(inst, self.starting_projects.clone()); } } diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 08c8755e1..8b6f8a422 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -6194,7 +6194,7 @@ mod async_tests { .assimilate_storage(&mut t) .unwrap(); - let mut ext = sp_io::TestExternalities::new(t); + let ext = sp_io::TestExternalities::new(t); let mut inst = MockInstantiator::new(Some(RefCell::new(ext))); dbg!(inst.get_project_details(0).status); From a29c351ab02c13bc12f53ccfc44e66e524ff5b36 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 8 Jan 2024 12:48:55 +0100 Subject: [PATCH 093/212] fix tests Signed-off-by: Juan Ignacio Rios --- integration-tests/src/tests/ct_migration.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index 040dc9412..cc51ce90a 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -1,14 +1,13 @@ use crate::*; use pallet_funding::{ - assert_close_enough, traits::VestingDurationCalculation, BidStatus, EvaluatorsOutcome, MigrationStatus, Multiplier, - ProjectIdOf, RewardOrSlash, + assert_close_enough, traits::VestingDurationCalculation, AcceptedFundingAsset, BidStatus, EvaluatorsOutcome, + MigrationStatus, Multiplier, MultiplierOf, ProjectIdOf, RewardOrSlash, }; use polimec_common::migration_types::{Migration, MigrationInfo, MigrationOrigin, Migrations, ParticipationType}; use polimec_parachain_runtime::PolimecFunding; -use sp_runtime::{traits::Convert, Perquintill}; +use sp_runtime::{traits::Convert, FixedPointNumber, Perquintill}; use std::collections::HashMap; use tests::defaults::*; - fn execute_cleaner(inst: &mut IntegrationInstantiator) { Polimec::execute_with(|| { inst.advance_time(::SuccessToSettlementTime::get() + 1u32).unwrap(); From b8af2ada30e4f1b24589962bd8a973e8caa80fa5 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 8 Jan 2024 13:54:33 +0100 Subject: [PATCH 094/212] merge fixes Signed-off-by: Juan Ignacio Rios --- Cargo.lock | 18 ++++++ integration-tests/src/constants.rs | 2 +- integration-tests/src/tests/build_spec.rs | 2 +- integration-tests/src/tests/ct_migration.rs | 1 + nodes/parachain/src/chain_spec/base.rs | 3 +- nodes/parachain/src/chain_spec/testnet.rs | 1 - pallets/funding/src/functions.rs | 29 ++++----- pallets/funding/src/impls.rs | 11 ++-- pallets/funding/src/instantiator.rs | 34 +++++------ pallets/funding/src/lib.rs | 14 ++--- pallets/funding/src/mock.rs | 17 +----- pallets/funding/src/tests.rs | 68 ++++++++++----------- pallets/parachain-staking/Cargo.toml | 2 +- runtimes/base/Cargo.toml | 8 +-- runtimes/testnet/Cargo.toml | 8 +-- runtimes/testnet/src/lib.rs | 3 +- 16 files changed, 112 insertions(+), 109 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f48eee388..1961d18ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -299,6 +299,7 @@ dependencies = [ "frame-system", "frame-system-benchmarking", "frame-system-rpc-runtime-api", + "frame-try-runtime", "hex-literal 0.4.1", "log", "pallet-asset-tx-payment", @@ -3897,8 +3898,10 @@ dependencies = [ "pallet-balances", "pallet-funding", "pallet-im-online", + "pallet-linear-release", "pallet-membership", "pallet-message-queue", + "pallet-parachain-staking", "pallet-staking", "pallet-vesting", "pallet-xcm", @@ -3906,6 +3909,7 @@ dependencies = [ "parachains-common", "parity-scale-codec", "penpal-runtime", + "polimec-base-runtime", "polimec-common", "polimec-parachain-runtime", "polimec-receiver", @@ -6224,6 +6228,7 @@ dependencies = [ "parity-scale-codec", "polimec-common", "scale-info", + "serde", "sp-core", "sp-io", "sp-runtime", @@ -6448,6 +6453,7 @@ dependencies = [ "pallet-session", "pallet-timestamp", "parity-scale-codec", + "polimec-common", "scale-info", "serde", "similar-asserts", @@ -7360,17 +7366,22 @@ dependencies = [ "pallet-aura", "pallet-authorship", "pallet-balances", + "pallet-multisig", "pallet-parachain-staking", + "pallet-proxy", "pallet-session", "pallet-sudo", "pallet-timestamp", "pallet-transaction-payment", "pallet-transaction-payment-rpc-runtime-api", "pallet-treasury", + "pallet-utility", + "pallet-vesting", "pallet-xcm", "parachain-info", "parachains-common", "parity-scale-codec", + "polimec-common", "polkadot-parachain", "polkadot-primitives", "polkadot-runtime-common", @@ -7532,6 +7543,7 @@ dependencies = [ "parachain-info", "parachains-common", "parity-scale-codec", + "polimec-common", "polimec-xcm-executor", "polkadot-parachain", "polkadot-primitives", @@ -11259,8 +11271,14 @@ dependencies = [ "frame-support", "frame-system", "orml-traits", + "pallet-authorship", + "pallet-balances", "pallet-funding", + "pallet-parachain-staking", + "pallet-transaction-payment", "parachains-common", + "parity-scale-codec", + "scale-info", "smallvec", "sp-arithmetic", "sp-std", diff --git a/integration-tests/src/constants.rs b/integration-tests/src/constants.rs index 17ff27c38..e60442a0e 100644 --- a/integration-tests/src/constants.rs +++ b/integration-tests/src/constants.rs @@ -358,7 +358,7 @@ pub mod polimec { }, technical_committee: Default::default(), treasury: Default::default(), - polimec_funding: Default::default(), + polimec_funding: Default::default(), vesting: Default::default(), }; diff --git a/integration-tests/src/tests/build_spec.rs b/integration-tests/src/tests/build_spec.rs index 661ca3f99..150de50d6 100644 --- a/integration-tests/src/tests/build_spec.rs +++ b/integration-tests/src/tests/build_spec.rs @@ -24,7 +24,7 @@ fn build_spec_testing_node() { assert_eq!( output.status.success(), true, - "Make sure you compile the node with \"std\" feature enabled before running this test." + "Make sure you compile the node with \"std\" and \"fast-gov\" feature enabled before running this test." ); dbg!(output); diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index 3227c29a1..96a90415a 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -555,6 +555,7 @@ fn disallow_duplicated_migrations_on_receiver_pallet() { migrations_are_vested(grouped_migrations.clone()); } +#[ignore] #[test] fn failing_bid_doesnt_get_migrated() { todo!(); diff --git a/nodes/parachain/src/chain_spec/base.rs b/nodes/parachain/src/chain_spec/base.rs index a51ed4203..49e3bb6fa 100644 --- a/nodes/parachain/src/chain_spec/base.rs +++ b/nodes/parachain/src/chain_spec/base.rs @@ -78,7 +78,8 @@ pub fn get_local_base_chain_spec() -> Result { // This operation can be done using https://www.shawntabrizi.com/substrate-js-utilities/ // 1. "Module ID" to Address plmc/stk -> 5EYCAe5ij8xKJ2biBy4zUGNwdNhpz3BaS5iiuseJqTEtWQTc // 2. AccountId to Hex -> 0x6d6f646c706c6d632f73746b0000000000000000000000000000000000000000 - const BLOCKCHAIN_OPERATION_TREASURY: [u8; 32] = hex_literal::hex!["6d6f646c706c6d632f73746b0000000000000000000000000000000000000000"]; + const BLOCKCHAIN_OPERATION_TREASURY: [u8; 32] = + hex_literal::hex!["6d6f646c706c6d632f73746b0000000000000000000000000000000000000000"]; Ok(ChainSpec::from_genesis( "Polimec Base Develop", diff --git a/nodes/parachain/src/chain_spec/testnet.rs b/nodes/parachain/src/chain_spec/testnet.rs index a036a5663..a5f1bbfc5 100644 --- a/nodes/parachain/src/chain_spec/testnet.rs +++ b/nodes/parachain/src/chain_spec/testnet.rs @@ -533,7 +533,6 @@ fn testing_genesis( council: CouncilConfig { members: accounts.clone(), phantom: Default::default() }, technical_committee: TechnicalCommitteeConfig { members: accounts, phantom: Default::default() }, democracy: Default::default(), - linear_release: LinearReleaseConfig { vesting: vec![] }, vesting: Default::default(), } } diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index d0a3e6bc6..d44da7ebf 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -805,8 +805,8 @@ impl Pallet { // * Update Storage * // Reserve plmc deposit to create a contribution token account for this project - if T::NativeCurrency::balance_on_hold(&LockType::FutureDeposit(project_id), &evaluator) < ct_deposit { - T::NativeCurrency::hold(&LockType::FutureDeposit(project_id), &evaluator, ct_deposit)?; + if T::NativeCurrency::balance_on_hold(&HoldReason::FutureDeposit(project_id).into(), &evaluator) < ct_deposit { + T::NativeCurrency::hold(&HoldReason::FutureDeposit(project_id).into(), &evaluator, ct_deposit)?; } if caller_existing_evaluations.len() < T::MaxEvaluationsPerUser::get() as usize { @@ -882,8 +882,8 @@ impl Pallet { ensure!(ct_amount <= project_metadata.total_allocation_size.0, Error::::NotAllowed); // Reserve plmc deposit to create a contribution token account for this project - if T::NativeCurrency::balance_on_hold(&LockType::FutureDeposit(project_id), &bidder) < ct_deposit { - T::NativeCurrency::hold(&LockType::FutureDeposit(project_id), &bidder, ct_deposit)?; + if T::NativeCurrency::balance_on_hold(&HoldReason::FutureDeposit(project_id).into(), &bidder) < ct_deposit { + T::NativeCurrency::hold(&HoldReason::FutureDeposit(project_id).into(), &bidder, ct_deposit)?; } // Fetch current bucket details and other required info @@ -1093,8 +1093,9 @@ impl Pallet { // * Update storage * // Reserve plmc deposit to create a contribution token account for this project - if T::NativeCurrency::balance_on_hold(&LockType::FutureDeposit(project_id), &contributor) < ct_deposit { - T::NativeCurrency::hold(&LockType::FutureDeposit(project_id), &contributor, ct_deposit)?; + if T::NativeCurrency::balance_on_hold(&HoldReason::FutureDeposit(project_id).into(), &contributor) < ct_deposit + { + T::NativeCurrency::hold(&HoldReason::FutureDeposit(project_id).into(), &contributor, ct_deposit)?; } // Try adding the new contribution to the system @@ -1243,7 +1244,7 @@ impl Pallet { // * Update storage * if !T::ContributionTokenCurrency::contains(&project_id, &bid.bidder) { T::NativeCurrency::release( - &LockType::FutureDeposit(project_id), + &HoldReason::FutureDeposit(project_id).into(), &bid.bidder, T::ContributionTokenCurrency::deposit_required(project_id), Precision::Exact, @@ -1287,7 +1288,7 @@ impl Pallet { // * Update storage * if !T::ContributionTokenCurrency::contains(&project_id, &contribution.contributor) { T::NativeCurrency::release( - &LockType::FutureDeposit(project_id), + &HoldReason::FutureDeposit(project_id).into(), &contribution.contributor, T::ContributionTokenCurrency::deposit_required(project_id), Precision::Exact, @@ -1397,7 +1398,7 @@ impl Pallet { // * Update storage * if !T::ContributionTokenCurrency::contains(&project_id, &evaluation.evaluator) { T::NativeCurrency::release( - &LockType::FutureDeposit(project_id), + &HoldReason::FutureDeposit(project_id).into(), &evaluation.evaluator, T::ContributionTokenCurrency::deposit_required(project_id), Precision::Exact, @@ -1844,12 +1845,12 @@ impl Pallet { pub fn do_release_future_ct_deposit_for( caller: &AccountIdOf, - project_id: T::ProjectIdentifier, + project_id: ProjectId, participant: &AccountIdOf, ) -> DispatchResult { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; - let held_plmc = T::NativeCurrency::balance_on_hold(&LockType::FutureDeposit(project_id), participant); + let held_plmc = T::NativeCurrency::balance_on_hold(&HoldReason::FutureDeposit(project_id).into(), participant); // * Validity checks * ensure!( matches!(project_details.status, ProjectStatus::EvaluationFailed | ProjectStatus::FundingFailed), @@ -1859,7 +1860,7 @@ impl Pallet { // * Update storage * T::NativeCurrency::release( - &LockType::FutureDeposit(project_id), + &HoldReason::FutureDeposit(project_id).into(), participant, T::ContributionTokenCurrency::deposit_required(project_id), Precision::Exact, @@ -2328,8 +2329,8 @@ impl Pallet { /// value and only call this once. #[inline(always)] pub fn fund_account_id(index: ProjectId) -> AccountIdOf { - // since the project_id starts at 0, we need to add 1 to get a different sub_account than the pallet account. - T::PalletId::get().into_sub_account_truncating(index.saturating_add(One::one())) + // since the project_id starts at 0, we need to add 1 to get a different sub_account than the pallet account. + T::PalletId::get().into_sub_account_truncating(index.saturating_add(One::one())) } /// Adds a project to the ProjectsToUpdate storage, so it can be updated at some later point in time. diff --git a/pallets/funding/src/impls.rs b/pallets/funding/src/impls.rs index 41a470083..9fd09755d 100644 --- a/pallets/funding/src/impls.rs +++ b/pallets/funding/src/impls.rs @@ -17,7 +17,7 @@ impl DoRemainingOperation for Cleaner> { } } - pub fn do_one_operation(&mut self, project_id: ProjectId) -> Result { + fn do_one_operation(&mut self, project_id: ProjectId) -> Result { match self { Cleaner::NotReady => Err(DispatchError::Other("Cleaner not ready")), Cleaner::Success(state) => @@ -298,10 +298,7 @@ fn release_future_ct_deposit_one_participant( return (base_weight, iter_participants.collect_vec().try_into().expect("Vec is equal or smaller, so has to fit")) } -fn remaining_evaluators_to_reward_or_slash( - project_id: ProjectId, - outcome: EvaluatorsOutcomeOf, -) -> u64 { +fn remaining_evaluators_to_reward_or_slash(project_id: ProjectId, outcome: EvaluatorsOutcomeOf) -> u64 { if outcome == EvaluatorsOutcomeOf::::Unchanged { 0u64 } else { @@ -338,7 +335,7 @@ fn remaining_contributions(project_id: ProjectId) -> u64 { Contributions::::iter_prefix_values((project_id,)).count() as u64 } -fn remaining_participants(project_id: T::ProjectIdentifier) -> AccountListOf { +fn remaining_participants(project_id: ProjectId) -> AccountListOf { let evaluators = Evaluations::::iter_key_prefix((project_id,)).map(|(evaluator, _evaluation_id)| evaluator); let bidders = Bids::::iter_key_prefix((project_id,)).map(|(bidder, _bid_id)| bidder); let contributors = @@ -350,7 +347,7 @@ fn remaining_participants(project_id: T::ProjectIdentifier) -> Accoun ) } -fn remaining_bids_without_ct_minted(project_id: T::ProjectIdentifier) -> u64 { +fn remaining_bids_without_ct_minted(project_id: ProjectId) -> u64 { let project_bids = Bids::::iter_prefix_values((project_id,)); project_bids.filter(|bid| !bid.ct_minted).count() as u64 } diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 55c956f22..2eb078ffc 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -393,7 +393,7 @@ impl< assert_eq!(project_details.status, ProjectStatus::EvaluationRound); assert_eq!(self.get_plmc_total_supply(), total_plmc_supply); self.do_free_plmc_assertions(expected_free_plmc_balances); - self.do_reserved_plmc_assertions(expected_reserved_plmc_balances, HoldReason::Evaluation(project_id).into()); + self.do_reserved_plmc_assertions(expected_reserved_plmc_balances, HoldReason::Evaluation(project_id).into()); self.do_reserved_plmc_assertions(expected_ct_account_deposits, HoldReason::FutureDeposit(project_id).into()); } @@ -1484,7 +1484,7 @@ pub mod async_features { instantiator: Arc>>, project_metadata: ProjectMetadataOf, issuer: AccountIdOf, - ) -> ProjectIdOf { + ) -> ProjectId { let mut inst = instantiator.lock().await; let asset_account_deposit = @@ -1517,7 +1517,7 @@ pub mod async_features { instantiator: Arc>>, project_metadata: ProjectMetadataOf, issuer: AccountIdOf, - ) -> ProjectIdOf { + ) -> ProjectId { let project_id = async_create_new_project(instantiator.clone(), project_metadata, issuer.clone()).await; let mut inst = instantiator.lock().await; @@ -1533,7 +1533,7 @@ pub mod async_features { >( instantiator: Arc>>, block_orchestrator: Arc>, - project_id: ProjectIdOf, + project_id: ProjectId, caller: AccountIdOf, ) -> Result<(), DispatchError> { let mut inst = instantiator.lock().await; @@ -1576,7 +1576,7 @@ pub mod async_features { project_metadata: ProjectMetadataOf, issuer: AccountIdOf, evaluations: Vec>, - ) -> ProjectIdOf { + ) -> ProjectId { let project_id = async_create_evaluating_project(instantiator.clone(), project_metadata, issuer.clone()).await; let mut inst = instantiator.lock().await; @@ -1628,7 +1628,7 @@ pub mod async_features { >( instantiator: Arc>>, block_orchestrator: Arc>, - project_id: ProjectIdOf, + project_id: ProjectId, ) -> Result<(), DispatchError> { let mut inst = instantiator.lock().await; @@ -1686,7 +1686,7 @@ pub mod async_features { issuer: AccountIdOf, evaluations: Vec>, bids: Vec>, - ) -> (ProjectIdOf, Vec>) { + ) -> (ProjectId, Vec>) { if bids.is_empty() { panic!("Cannot start community funding without bids") } @@ -1756,7 +1756,7 @@ pub mod async_features { inst.do_reserved_plmc_assertions( total_plmc_participation_locked.merge_accounts(MergeOperation::Add), - LockType::Participation(project_id), + HoldReason::Participation(project_id).into(), ); inst.do_bid_transferred_statemint_asset_assertions( funding_asset_deposits.merge_accounts(MergeOperation::Add), @@ -1799,7 +1799,7 @@ pub mod async_features { >( instantiator: Arc>>, block_orchestrator: Arc>, - project_id: ProjectIdOf, + project_id: ProjectId, ) -> Result<(), DispatchError> { let mut inst = instantiator.lock().await; @@ -1842,7 +1842,7 @@ pub mod async_features { evaluations: Vec>, bids: Vec>, contributions: Vec>, - ) -> (ProjectIdOf, Vec>) { + ) -> (ProjectId, Vec>) { let (project_id, accepted_bids) = async_create_community_contributing_project( instantiator.clone(), block_orchestrator.clone(), @@ -1928,7 +1928,7 @@ pub mod async_features { inst.do_reserved_plmc_assertions( total_plmc_participation_locked.merge_accounts(MergeOperation::Add), - LockType::Participation(project_id), + HoldReason::Participation(project_id).into(), ); inst.do_contribution_transferred_statemint_asset_assertions( funding_asset_deposits.merge_accounts(MergeOperation::Add), @@ -1951,7 +1951,7 @@ pub mod async_features { >( instantiator: Arc>>, block_orchestrator: Arc>, - project_id: ProjectIdOf, + project_id: ProjectId, ) -> Result<(), DispatchError> { let mut inst = instantiator.lock().await; @@ -2000,7 +2000,7 @@ pub mod async_features { bids: Vec>, community_contributions: Vec>, remainder_contributions: Vec>, - ) -> ProjectIdOf { + ) -> ProjectId { let (project_id, accepted_bids) = async_create_remainder_contributing_project( instantiator.clone(), block_orchestrator.clone(), @@ -2114,7 +2114,7 @@ pub mod async_features { let merged = total_plmc_participation_locked.merge_accounts(MergeOperation::Add); - inst.do_reserved_plmc_assertions(merged, LockType::Participation(project_id)); + inst.do_reserved_plmc_assertions(merged, HoldReason::Participation(project_id).into()); inst.do_contribution_transferred_statemint_asset_assertions( funding_asset_deposits.merge_accounts(MergeOperation::Add), @@ -2159,7 +2159,7 @@ pub mod async_features { instantiator: Arc>>, block_orchestrator: Arc>, test_project_params: TestProjectParams, - ) -> ProjectIdOf { + ) -> ProjectId { match test_project_params.expected_state { ProjectStatus::FundingSuccessful => async_create_finished_project( @@ -2222,7 +2222,7 @@ pub mod async_features { mutex_inst: Arc>>, block_orchestrator: Arc>, test_project_params: TestProjectParams, - ) -> ProjectIdOf { + ) -> ProjectId { let time_to_new_project: BlockNumberFor = Zero::zero(); let time_to_evaluation: BlockNumberFor = time_to_new_project + Zero::zero(); // we immediately start the auction, so we dont wait for T::AuctionInitializePeriodDuration. @@ -2336,7 +2336,7 @@ pub mod async_features { >( instantiator: Instantiator, projects: Vec>, - ) -> (Vec>, Instantiator) { + ) -> (Vec, Instantiator) { // let tokio_runtime = Runtime::new().unwrap(); use tokio::runtime::Builder; diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 2cde46eff..1842da06e 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -265,11 +265,11 @@ pub mod pallet { #[cfg(any(feature = "runtime-benchmarks", feature = "std"))] use crate::traits::SetPrices; - #[pallet::composite_enum] + #[pallet::composite_enum] pub enum HoldReason { Evaluation(ProjectId), Participation(ProjectId), - // We require a PLMC deposit to create an account for minting the CTs to this user. + // We require a PLMC deposit to create an account for minting the CTs to this user. // Here we make sure the user has this amount before letting him participate. FutureDeposit(ProjectId), } @@ -346,8 +346,8 @@ pub mod pallet { + fungibles::metadata::Mutate> + fungibles::Mutate, Balance = BalanceOf> + fungibles::roles::Inspect> - + AccountTouch, Balance = BalanceOf> - + ContainsPair>; + + AccountTouch, Balance = BalanceOf> + + ContainsPair>; type PriceProvider: ProvideStatemintPrice; @@ -491,7 +491,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn project_details)] /// StorageMap containing additional information for the projects, relevant for correctness of the protocol - pub type ProjectsDetails = StorageMap<_, Blake2_128Concat, T::ProjectIdentifier, ProjectDetailsOf>; + pub type ProjectsDetails = StorageMap<_, Blake2_128Concat, ProjectId, ProjectDetailsOf>; #[pallet::storage] #[pallet::getter(fn projects_to_update)] @@ -829,12 +829,12 @@ pub mod pallet { migration_origins: BoundedVec>, }, ReleaseFutureCTDepositFailed { - project_id: ProjectIdOf, + project_id: ProjectId, participant: AccountIdOf, error: DispatchError, }, FutureCTDepositReleased { - project_id: ProjectIdOf, + project_id: ProjectId, participant: AccountIdOf, caller: AccountIdOf, }, diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index f9cc714fd..247d69c83 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -53,21 +53,6 @@ pub const EXISTENTIAL_DEPOSIT: Balance = 10 * MILLI_PLMC; const US_DOLLAR: u128 = 1_0_000_000_000u128; -// Configure a mock runtime to test the pallet. -frame_support::construct_runtime!( - pub enum TestRuntime - { - System: frame_system, - RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip, - Balances: pallet_balances, - FundingModule: crate::{Pallet, Call, Storage, Event, Config, HoldReason}, - Vesting: pallet_linear_release, - LocalAssets: pallet_assets::::{Pallet, Call, Storage, Event}, - StatemintAssets: pallet_assets::::{Pallet, Call, Storage, Event, Config}, - PolkadotXcm: pallet_xcm, - } -); - pub type LocalAssetsInstance = pallet_assets::Instance1; pub type StatemintAssetsInstance = pallet_assets::Instance2; @@ -409,7 +394,7 @@ construct_runtime!( LocalAssets: pallet_assets::::{Pallet, Call, Storage, Event}, StatemintAssets: pallet_assets::::{Pallet, Call, Storage, Event, Config}, PolkadotXcm: pallet_xcm, - PolimecFunding: pallet_funding::{Pallet, Call, Storage, Event, Config} = 52, + PolimecFunding: pallet_funding::{Pallet, Call, Storage, Event, Config, HoldReason} = 52, } ); diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index dadd31805..f04e60bb7 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -508,7 +508,7 @@ mod evaluation_round_success { let slashed_amounts = MockInstantiator::slash_evaluator_balances(MockInstantiator::calculate_evaluation_plmc_spent(evaluations)); let deposit_required = <::ContributionTokenCurrency as AccountTouch< - ProjectIdOf, + ProjectId, AccountIdOf, >>::deposit_required(project_id); @@ -612,7 +612,7 @@ mod evaluation_round_failure { UserToUSDBalance::new(EVALUATOR_3, evaluator_bond), ]; let deposit_required = <::ContributionTokenCurrency as AccountTouch< - ProjectIdOf, + ProjectId, AccountIdOf, >>::deposit_required(project_id); inst.do_free_plmc_assertions(vec![ @@ -626,7 +626,7 @@ mod evaluation_round_failure { UserToPLMCBalance::new(EVALUATOR_2, 0u128), UserToPLMCBalance::new(EVALUATOR_3, 0u128), ], - LockType::FutureDeposit(project_id), + HoldReason::FutureDeposit(project_id).into(), ); let required_plmc_bonds = MockInstantiator::calculate_evaluation_plmc_spent(evaluations.clone()); @@ -650,7 +650,7 @@ mod evaluation_round_failure { UserToPLMCBalance::new(EVALUATOR_2, deposit_required), UserToPLMCBalance::new(EVALUATOR_3, deposit_required), ], - LockType::FutureDeposit(project_id), + HoldReason::FutureDeposit(project_id).into(), ); inst.advance_time(::EvaluationDuration::get() + 1).unwrap(); @@ -668,7 +668,7 @@ mod evaluation_round_failure { UserToPLMCBalance::new(EVALUATOR_2, 0u128), UserToPLMCBalance::new(EVALUATOR_3, 0u128), ], - LockType::FutureDeposit(project_id), + HoldReason::FutureDeposit(project_id).into(), ); } } @@ -1685,7 +1685,7 @@ mod auction_round_success { let mut plmc_locked_for_bids = MockInstantiator::calculate_auction_plmc_spent(&bids, Some(final_price)); plmc_locked_for_bids.sort_by_key(|item| item.account); let ct_deposit_required = <::ContributionTokenCurrency as AccountTouch< - ProjectIdOf, + ProjectId, AccountIdOf, >>::deposit_required(project_id); plmc_locked_for_bids.iter_mut().for_each(|item| item.plmc_amount += ct_deposit_required); @@ -2083,7 +2083,7 @@ mod auction_round_failure { let automatic_fail_funding_percent = Percent::from_percent(30); let (bid_allocation, _contribution_allocation) = project_metadata.total_allocation_size; let deposit_required = <::ContributionTokenCurrency as AccountTouch< - ProjectIdOf, + ProjectId, AccountIdOf, >>::deposit_required(0); @@ -2101,7 +2101,7 @@ mod auction_round_failure { let zero_balances = bids.clone().accounts().into_iter().map(|acc| UserToPLMCBalance::new(acc, 0u128)).collect_vec(); inst.do_free_plmc_assertions(zero_balances.clone()); - inst.do_reserved_plmc_assertions(zero_balances.clone(), LockType::FutureDeposit(0)); + inst.do_reserved_plmc_assertions(zero_balances.clone(), HoldReason::FutureDeposit(0).into()); let required_plmc_bonds = MockInstantiator::calculate_auction_plmc_spent(&bids, None); let plmc_existential_deposits = required_plmc_bonds.accounts().existential_deposits(); @@ -2121,7 +2121,7 @@ mod auction_round_failure { .into_iter() .map(|acc| UserToPLMCBalance::new(acc, deposit_required)) .collect_vec(); - inst.do_reserved_plmc_assertions(ct_deposit_balances, LockType::FutureDeposit(project_id)); + inst.do_reserved_plmc_assertions(ct_deposit_balances, HoldReason::FutureDeposit(project_id).into()); inst.advance_time(::CommunityFundingDuration::get() + 1).unwrap(); inst.advance_time(::RemainderFundingDuration::get() + 1).unwrap(); @@ -2136,7 +2136,7 @@ mod auction_round_failure { MergeOperation::Add, ); inst.do_free_plmc_assertions(final_plmc_amounts); - inst.do_reserved_plmc_assertions(zero_balances, LockType::FutureDeposit(project_id)); + inst.do_reserved_plmc_assertions(zero_balances, HoldReason::FutureDeposit(project_id).into()); } } @@ -3096,7 +3096,7 @@ mod community_round_failure { let automatic_fail_funding_percent = Percent::from_percent(30); let (bid_allocation, contribution_allocation) = project_metadata.total_allocation_size; let deposit_required = <::ContributionTokenCurrency as AccountTouch< - ProjectIdOf, + ProjectId, AccountIdOf, >>::deposit_required(0); @@ -3128,7 +3128,7 @@ mod community_round_failure { .map(|acc| UserToPLMCBalance::new(acc, 0u128)) .collect_vec(); inst.do_free_plmc_assertions(zero_balances.clone()); - inst.do_reserved_plmc_assertions(zero_balances.clone(), LockType::FutureDeposit(0)); + inst.do_reserved_plmc_assertions(zero_balances.clone(), HoldReason::FutureDeposit(0).into()); let (project_id, _) = inst.create_remainder_contributing_project( project_metadata, @@ -3156,7 +3156,7 @@ mod community_round_failure { .into_iter() .map(|acc| UserToPLMCBalance::new(acc, deposit_required)) .collect_vec(); - inst.do_reserved_plmc_assertions(ct_deposit_balances, LockType::FutureDeposit(project_id)); + inst.do_reserved_plmc_assertions(ct_deposit_balances, HoldReason::FutureDeposit(project_id).into()); inst.advance_time(::RemainderFundingDuration::get() + 1).unwrap(); @@ -3170,7 +3170,7 @@ mod community_round_failure { MergeOperation::Add, ); inst.do_free_plmc_assertions(final_plmc_amounts); - inst.do_reserved_plmc_assertions(zero_balances, LockType::FutureDeposit(project_id)); + inst.do_reserved_plmc_assertions(zero_balances, HoldReason::FutureDeposit(project_id).into()); } } @@ -3669,7 +3669,7 @@ mod remainder_round_failure { let automatic_fail_funding_percent = Percent::from_percent(30); let (bid_allocation, contribution_allocation) = project_metadata.total_allocation_size; let deposit_required = <::ContributionTokenCurrency as AccountTouch< - ProjectIdOf, + ProjectId, AccountIdOf, >>::deposit_required(0); @@ -3711,7 +3711,7 @@ mod remainder_round_failure { .map(|acc| UserToPLMCBalance::new(acc, 0u128)) .collect_vec(); inst.do_free_plmc_assertions(zero_balances.clone()); - inst.do_reserved_plmc_assertions(zero_balances.clone(), LockType::FutureDeposit(0)); + inst.do_reserved_plmc_assertions(zero_balances.clone(), HoldReason::FutureDeposit(0).into()); let project_id = inst.create_finished_project( project_metadata, @@ -3748,7 +3748,7 @@ mod remainder_round_failure { .into_iter() .map(|acc| UserToPLMCBalance::new(acc, deposit_required)) .collect_vec(); - inst.do_reserved_plmc_assertions(ct_deposit_balances, LockType::FutureDeposit(project_id)); + inst.do_reserved_plmc_assertions(ct_deposit_balances, HoldReason::FutureDeposit(project_id).into()); assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingFailed); inst.advance_time(::SuccessToSettlementTime::get() + 1).unwrap(); @@ -3760,7 +3760,7 @@ mod remainder_round_failure { MockInstantiator::generic_map_operation(vec![post_balances, prev_balances], MergeOperation::Subtract); assert_eq!(plmc_deltas, expected_final_plmc_balances); - inst.do_reserved_plmc_assertions(zero_balances, LockType::FutureDeposit(project_id)); + inst.do_reserved_plmc_assertions(zero_balances, HoldReason::FutureDeposit(project_id).into()); } } @@ -4020,7 +4020,7 @@ mod funding_end { assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AwaitingProjectDecision); let old_evaluation_locked_plmc = inst - .get_all_reserved_plmc_balances(LockType::Evaluation(project_id)) + .get_all_reserved_plmc_balances(HoldReason::Evaluation(project_id).into()) .into_iter() .filter(|item| item.plmc_amount > Zero::zero()) .collect::>>(); @@ -4028,7 +4028,7 @@ mod funding_end { let evaluators = old_evaluation_locked_plmc.accounts(); let old_participation_locked_plmc = - inst.get_reserved_plmc_balances_for(evaluators.clone(), LockType::Participation(project_id)); + inst.get_reserved_plmc_balances_for(evaluators.clone(), HoldReason::Participation(project_id).into()); let old_free_plmc = inst.get_free_plmc_balances_for(evaluators.clone()); call_and_is_ok!( @@ -4061,7 +4061,7 @@ mod funding_end { assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AwaitingProjectDecision); let old_evaluation_locked_plmc = inst - .get_all_reserved_plmc_balances(LockType::Evaluation(project_id)) + .get_all_reserved_plmc_balances(HoldReason::Evaluation(project_id).into()) .into_iter() .filter(|item| item.plmc_amount > Zero::zero()) .collect::>>(); @@ -4069,7 +4069,7 @@ mod funding_end { let evaluators = old_evaluation_locked_plmc.accounts(); let old_participation_locked_plmc = - inst.get_reserved_plmc_balances_for(evaluators.clone(), LockType::Participation(project_id)); + inst.get_reserved_plmc_balances_for(evaluators.clone(), HoldReason::Participation(project_id).into()); let old_free_plmc = inst.get_free_plmc_balances_for(evaluators.clone()); call_and_is_ok!( @@ -4090,7 +4090,7 @@ mod funding_end { MergeOperation::Add, ); let ct_deposit_required = <::ContributionTokenCurrency as AccountTouch< - ProjectIdOf, + ProjectId, AccountIdOf, >>::deposit_required(project_id); expected_evaluator_free_balances @@ -4109,7 +4109,7 @@ mod funding_end { assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingFailed); let old_evaluation_locked_plmc = inst - .get_all_reserved_plmc_balances(LockType::Evaluation(project_id)) + .get_all_reserved_plmc_balances(HoldReason::Evaluation(project_id).into()) .into_iter() .filter(|item| item.plmc_amount > Zero::zero()) .collect::>(); @@ -4117,7 +4117,7 @@ mod funding_end { let evaluators = old_evaluation_locked_plmc.accounts(); let old_participation_locked_plmc = - inst.get_reserved_plmc_balances_for(evaluators.clone(), LockType::Participation(project_id)); + inst.get_reserved_plmc_balances_for(evaluators.clone(), HoldReason::Participation(project_id).into()); let old_free_plmc = inst.get_free_plmc_balances_for(evaluators.clone()); inst.advance_time(::SuccessToSettlementTime::get() + 10u64).unwrap(); @@ -4132,7 +4132,7 @@ mod funding_end { MergeOperation::Add, ); let ct_deposit_required = <::ContributionTokenCurrency as AccountTouch< - ProjectIdOf, + ProjectId, AccountIdOf, >>::deposit_required(project_id); expected_evaluator_free_balances @@ -5204,13 +5204,13 @@ mod funding_end { for payout in all_expected_payouts.clone() { let evaluation_hold = inst.execute(|| { <::NativeCurrency as fungible::InspectHold>>::balance_on_hold( - &LockType::Evaluation(project_id), + &HoldReason::Evaluation(project_id).into(), &payout.account, ) }); let participation_hold = inst.execute(|| { <::NativeCurrency as fungible::InspectHold>>::balance_on_hold( - &LockType::Participation(project_id), + &HoldReason::Participation(project_id).into(), &payout.account, ) }); @@ -5218,7 +5218,7 @@ mod funding_end { println!("account {:?} has participation hold {:?}", payout.account, participation_hold); } let deposit_required = <::ContributionTokenCurrency as AccountTouch< - ProjectIdOf, + ProjectId, AccountIdOf, >>::deposit_required(project_id); let all_expected_payouts = all_expected_payouts @@ -5257,7 +5257,7 @@ mod funding_end { let participants = all_participants_plmc_deltas.accounts(); for participant in participants { - let future_deposit_reserved = inst.execute(||{<::NativeCurrency as fungible::InspectHold>>::balance_on_hold(&LockType::FutureDeposit(project_id), &participant)}); + let future_deposit_reserved = inst.execute(||{<::NativeCurrency as fungible::InspectHold>>::balance_on_hold(&HoldReason::FutureDeposit(project_id).into(), &participant)}); println!("participant {:?} has future deposit reserved {:?}", participant, future_deposit_reserved); } assert_eq!(issuer_funding_delta, 0); @@ -5325,13 +5325,13 @@ mod funding_end { for payout in all_expected_payouts.clone() { let evaluation_hold = inst.execute(|| { <::NativeCurrency as fungible::InspectHold>>::balance_on_hold( - &LockType::Evaluation(project_id), + &HoldReason::Evaluation(project_id).into(), &payout.account, ) }); let participation_hold = inst.execute(|| { <::NativeCurrency as fungible::InspectHold>>::balance_on_hold( - &LockType::Participation(project_id), + &HoldReason::Participation(project_id).into(), &payout.account, ) }); @@ -5339,7 +5339,7 @@ mod funding_end { println!("account {:?} has participation hold {:?}", payout.account, participation_hold); } let _deposit_required = <::ContributionTokenCurrency as AccountTouch< - ProjectIdOf, + ProjectId, AccountIdOf, >>::deposit_required(project_id); @@ -5436,7 +5436,7 @@ mod funding_end { let issuer_funding_delta = post_issuer_funding_balance - prev_issuer_funding_balance; let participants = all_participants_plmc_deltas.accounts(); for participant in participants { - let future_deposit_reserved = inst.execute(||{<::NativeCurrency as fungible::InspectHold>>::balance_on_hold(&LockType::FutureDeposit(project_id), &participant)}); + let future_deposit_reserved = inst.execute(||{<::NativeCurrency as fungible::InspectHold>>::balance_on_hold(&HoldReason::FutureDeposit(project_id).into(), &participant)}); println!("participant {:?} has future deposit reserved {:?}", participant, future_deposit_reserved); } assert_eq!( diff --git a/pallets/parachain-staking/Cargo.toml b/pallets/parachain-staking/Cargo.toml index 4cc6140f0..fe2fa8cf1 100644 --- a/pallets/parachain-staking/Cargo.toml +++ b/pallets/parachain-staking/Cargo.toml @@ -20,7 +20,7 @@ parity-scale-codec = { workspace = true, features = [ scale-info = { workspace = true, features = ["derive"] } # Polimec -polimec-traits.workspace = true +polimec-common.workspace = true # FRAME frame-benchmarking = { workspace = true, optional = true } diff --git a/runtimes/base/Cargo.toml b/runtimes/base/Cargo.toml index 85b351c4d..0bf77051b 100644 --- a/runtimes/base/Cargo.toml +++ b/runtimes/base/Cargo.toml @@ -27,7 +27,7 @@ smallvec = "1.11.0" # Local pallet-parachain-staking.workspace = true shared-configuration.workspace = true -polimec-traits.workspace = true +polimec-common.workspace = true # Substrate frame-benchmarking = { workspace = true, optional = true } @@ -125,7 +125,7 @@ std = [ "parachain-info/std", "parachains-common/std", "parity-scale-codec/std", - "polimec-traits/std", + "polimec-common/std", "polkadot-parachain/std", "polkadot-primitives/std", "polkadot-runtime-common/std", @@ -167,7 +167,7 @@ runtime-benchmarks = [ "pallet-utility/runtime-benchmarks", "pallet-vesting/runtime-benchmarks", "pallet-xcm/runtime-benchmarks", - "polimec-traits/runtime-benchmarks", + "polimec-common/runtime-benchmarks", "polkadot-parachain/runtime-benchmarks", "polkadot-primitives/runtime-benchmarks", "polkadot-runtime-common/runtime-benchmarks", @@ -202,7 +202,7 @@ try-runtime = [ "pallet-vesting/try-runtime", "pallet-xcm/try-runtime", "parachain-info/try-runtime", - "polimec-traits/try-runtime", + "polimec-common/try-runtime", "polkadot-runtime-common/try-runtime", "shared-configuration/try-runtime", "sp-runtime/try-runtime", diff --git a/runtimes/testnet/Cargo.toml b/runtimes/testnet/Cargo.toml index a56de3492..8df4598d8 100644 --- a/runtimes/testnet/Cargo.toml +++ b/runtimes/testnet/Cargo.toml @@ -25,7 +25,7 @@ smallvec.workspace = true pallet-funding.workspace = true pallet-linear-release.workspace = true shared-configuration.workspace = true -polimec-traits.workspace = true +polimec-common.workspace = true # FRAME frame-benchmarking = { workspace = true, optional = true } @@ -150,7 +150,7 @@ std = [ "polkadot-parachain/std", "polkadot-primitives/std", "polkadot-runtime-common/std", - "polimec-traits/std", + "polimec-common/std", "scale-info/std", "serde", "serde?/std", @@ -203,7 +203,7 @@ runtime-benchmarks = [ "polkadot-parachain/runtime-benchmarks", "polkadot-primitives/runtime-benchmarks", "polkadot-runtime-common/runtime-benchmarks", - "polimec-traits/runtime-benchmarks", + "polimec-common/runtime-benchmarks", "shared-configuration/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", @@ -248,7 +248,7 @@ try-runtime = [ "parachain-info/try-runtime", "polimec-xcm-executor/try-runtime", "polkadot-runtime-common/try-runtime", - "polimec-traits/try-runtime", + "polimec-common/try-runtime", "shared-configuration/try-runtime", "sp-runtime/try-runtime", ] diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index d72c64def..41511e3fa 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -553,7 +553,8 @@ impl ConvertBack for ConvertSelf { } impl pallet_funding::Config for Runtime { type AccountId32Conversion = ConvertSelf; - type AllPalletsWithoutSystem = (Balances, LocalAssets, StatemintAssets, Oracle, PolimecFunding, LinearRelease, Random); + type AllPalletsWithoutSystem = + (Balances, LocalAssets, StatemintAssets, Oracle, PolimecFunding, LinearRelease, Random); type AuctionInitializePeriodDuration = AuctionInitializePeriodDuration; type Balance = Balance; type BlockNumber = BlockNumber; From 89b38687e04f268ba21ea6703d4176d21b8852f3 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 8 Jan 2024 17:38:15 +0100 Subject: [PATCH 095/212] new test Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/functions.rs | 3 ++- pallets/funding/src/lib.rs | 2 ++ pallets/funding/src/tests.rs | 13 +++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index d44da7ebf..b1730f3fb 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -130,7 +130,8 @@ impl Pallet { &escrow_account, ::ExistentialDeposit::get(), Preservation::Preserve, - )?; + ) + .map_err(|_| Error::::NotEnoughFundsForEscrowCreation)?; // * Update storage * ProjectsMetadata::::insert(project_id, &initial_metadata); diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 1842da06e..ffa0d3805 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -937,6 +937,8 @@ pub mod pallet { BadConversion, /// Tried to release the PLMC deposit held for a future CT mint, but there was nothing to release NoFutureDepositHeld, + /// The issuer doesn't have enough funds (ExistentialDeposit), to create the escrow account + NotEnoughFundsForEscrowCreation, } #[pallet::call] diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index f04e60bb7..c28de0d6a 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -318,6 +318,19 @@ mod creation_round_failure { inst.execute(|| Pallet::::create(RuntimeOrigin::signed(ISSUER), wrong_project).unwrap_err()); assert_eq!(project_err, Error::::TicketSizeError.into()); } + + #[test] + fn issuer_cannot_pay_for_escrow_ed() { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let project_metadata = default_project(0, ISSUER); + let ed = MockInstantiator::get_ed(); + + inst.mint_plmc_to(vec![UserToPLMCBalance::new(ISSUER, ed)]); + + let project_err = inst + .execute(|| Pallet::::create(RuntimeOrigin::signed(ISSUER), project_metadata).unwrap_err()); + assert_eq!(project_err, Error::::NotEnoughFundsForEscrowCreation.into()); + } } mod evaluation_round_success { From 92eaf58589ad7d0448f5fcfd96ee1a340783d02a Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 9 Jan 2024 16:15:45 +0100 Subject: [PATCH 096/212] remove testing-node feature Signed-off-by: Juan Ignacio Rios --- integration-tests/Cargo.toml | 4 ---- integration-tests/README.md | 2 +- justfile | 2 +- pallets/funding/Cargo.toml | 8 -------- pallets/funding/src/genesis_config.rs | 1 - pallets/linear-release/Cargo.toml | 1 - pallets/sandbox/Cargo.toml | 1 - runtimes/base/Cargo.toml | 1 - runtimes/shared-configuration/Cargo.toml | 1 - runtimes/testnet/Cargo.toml | 5 ----- 10 files changed, 2 insertions(+), 24 deletions(-) diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index a42f6a460..37218e727 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -147,10 +147,6 @@ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", ] -testing-node = [ - "pallet-funding/testing-node", - "polimec-parachain-runtime/testing-node", -] try-runtime = [ "asset-hub-polkadot-runtime/try-runtime", "cumulus-pallet-xcm/try-runtime", diff --git a/integration-tests/README.md b/integration-tests/README.md index 46e33fa86..a0bd52c84 100644 --- a/integration-tests/README.md +++ b/integration-tests/README.md @@ -14,5 +14,5 @@ with the latest chain specs to provide a realistic testing environment. ```bash $ cd polimec-node/integration-tests/ -$ cargo test --features std,testing-node,fast-gov +$ cargo test --features std,fast-gov ``` diff --git a/justfile b/justfile index 451c0fab1..efe1b7f77 100644 --- a/justfile +++ b/justfile @@ -32,7 +32,7 @@ test-runtime-features: # Run the integration tests test-integration: - cargo test -p integration-tests --features std,testing-node,fast-gov + cargo test -p integration-tests --features std,fast-gov # Benchmark the "Testnet" Runtime benchmark-runtime-funding: diff --git a/pallets/funding/Cargo.toml b/pallets/funding/Cargo.toml index 9d5b26ae4..3ca152d33 100644 --- a/pallets/funding/Cargo.toml +++ b/pallets/funding/Cargo.toml @@ -134,11 +134,3 @@ try-runtime = [ "polkadot-runtime/try-runtime", "sp-runtime/try-runtime", ] -testing-node = [ "pallet-linear-release/testing-node" ] -cargo-expand-visible = [ - # "pallet-insecure-randomness-collective-flip", - # "pallet-assets", - # "pallet-linear-release", - # "assert_matches2", - # "xcm-executor", -] diff --git a/pallets/funding/src/genesis_config.rs b/pallets/funding/src/genesis_config.rs index ff11c9cb0..4cad95085 100644 --- a/pallets/funding/src/genesis_config.rs +++ b/pallets/funding/src/genesis_config.rs @@ -79,7 +79,6 @@ mod genesis_config { } } -// #[cfg(not(all(feature = "testing-node", feature = "std")))] // #[pallet_section] // mod genesis_config { // #[pallet::genesis_config] diff --git a/pallets/linear-release/Cargo.toml b/pallets/linear-release/Cargo.toml index 3a4f38019..eee46609c 100644 --- a/pallets/linear-release/Cargo.toml +++ b/pallets/linear-release/Cargo.toml @@ -69,4 +69,3 @@ try-runtime = [ "polimec-common/try-runtime", "sp-runtime/try-runtime", ] -testing-node = [ "pallet-funding/testing-node" ] diff --git a/pallets/sandbox/Cargo.toml b/pallets/sandbox/Cargo.toml index 3e053079f..ee5f1f03e 100644 --- a/pallets/sandbox/Cargo.toml +++ b/pallets/sandbox/Cargo.toml @@ -78,4 +78,3 @@ try-runtime = [ "pallet-insecure-randomness-collective-flip/try-runtime", "sp-runtime/try-runtime", ] -testing-node = [ "pallet-funding/testing-node" ] diff --git a/runtimes/base/Cargo.toml b/runtimes/base/Cargo.toml index 0bf77051b..626803317 100644 --- a/runtimes/base/Cargo.toml +++ b/runtimes/base/Cargo.toml @@ -207,4 +207,3 @@ try-runtime = [ "shared-configuration/try-runtime", "sp-runtime/try-runtime", ] -testing-node = [ "shared-configuration/testing-node" ] diff --git a/runtimes/shared-configuration/Cargo.toml b/runtimes/shared-configuration/Cargo.toml index 58b862238..b98ef0ffa 100644 --- a/runtimes/shared-configuration/Cargo.toml +++ b/runtimes/shared-configuration/Cargo.toml @@ -59,7 +59,6 @@ runtime-benchmarks = [ "pallet-funding/runtime-benchmarks", "pallet-parachain-staking/runtime-benchmarks", ] -testing-node = [ "pallet-funding/testing-node" ] try-runtime = [ "frame-support/try-runtime", "frame-system/try-runtime", diff --git a/runtimes/testnet/Cargo.toml b/runtimes/testnet/Cargo.toml index 8df4598d8..236037fcb 100644 --- a/runtimes/testnet/Cargo.toml +++ b/runtimes/testnet/Cargo.toml @@ -252,8 +252,3 @@ try-runtime = [ "shared-configuration/try-runtime", "sp-runtime/try-runtime", ] -testing-node = [ - "pallet-funding/testing-node", - "pallet-linear-release/testing-node", - "shared-configuration/testing-node", -] From 405cdf20129c3469f374f3fa8a7b1698bdbd88df Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 9 Jan 2024 16:16:52 +0100 Subject: [PATCH 097/212] remove cargo-expand-visible feature and unused modular genesis_config.rs Signed-off-by: Juan Ignacio Rios --- pallets/funding/Cargo.toml | 3 - pallets/funding/src/genesis_config.rs | 100 -------------------------- pallets/funding/src/lib.rs | 2 - 3 files changed, 105 deletions(-) delete mode 100644 pallets/funding/src/genesis_config.rs diff --git a/pallets/funding/Cargo.toml b/pallets/funding/Cargo.toml index 3ca152d33..9e1aa54e1 100644 --- a/pallets/funding/Cargo.toml +++ b/pallets/funding/Cargo.toml @@ -62,7 +62,6 @@ assert_matches2.workspace = true xcm-executor.workspace = true [features] -default = [ "std", "cargo-expand-visible" ] std = [ "frame-benchmarking?/std", "frame-support/std", @@ -95,8 +94,6 @@ std = [ "xcm/std", "tokio", "futures", - "cargo-expand-visible", - ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/pallets/funding/src/genesis_config.rs b/pallets/funding/src/genesis_config.rs deleted file mode 100644 index 4cad95085..000000000 --- a/pallets/funding/src/genesis_config.rs +++ /dev/null @@ -1,100 +0,0 @@ -use frame_support::pallet_macros::pallet_section; - -#[pallet_section] -mod genesis_config { - use crate::{ - instantiator::{Instantiator, TestProjectParams}, - pallet, BalanceOf, - }; - use frame_support::{ - dispatch::{Decode, Encode}, - pallet_prelude::BuildGenesisConfig, - Parameter, - }; - use frame_system::pallet_prelude::BlockNumberFor; - use sp_runtime::traits::Member; - use sp_std::marker::PhantomData; - - #[pallet::genesis_config] - #[derive(Clone, PartialEq, Eq, Debug, Encode, Decode)] - pub struct GenesisConfig - where - T: Config + pallet_balances::Config>, - ::AllPalletsWithoutSystem: - OnFinalize> + OnIdle> + OnInitialize>, - ::RuntimeEvent: From> + TryInto> + Parameter + Member, - ::Balance: Into>, - { - pub starting_projects: Vec>, - pub phantom: PhantomData, - } - - impl Default for GenesisConfig - where - T: Config + pallet_balances::Config>, - ::AllPalletsWithoutSystem: - OnFinalize> + OnIdle> + OnInitialize>, - ::RuntimeEvent: From> + TryInto> + Parameter + Member, - ::Balance: Into>, - { - fn default() -> Self { - Self { starting_projects: vec![], phantom: PhantomData } - } - } - - #[pallet::genesis_build] - impl BuildGenesisConfig for GenesisConfig - where - T: Config + pallet_balances::Config>, - ::AllPalletsWithoutSystem: - OnFinalize> + OnIdle> + OnInitialize>, - ::RuntimeEvent: From> + TryInto> + Parameter + Member, - ::Balance: Into>, - { - fn build(&self) { - { - type GenesisInstantiator = - Instantiator::AllPalletsWithoutSystem, ::RuntimeEvent>; - let mut inst = GenesisInstantiator::::new(None); - ::SetPrices::set_prices(); - let current_block = >::block_number(); - instantiator::async_features::create_multiple_projects_at(inst, self.starting_projects.clone()); - } - } - } - impl GenesisConfig - where - T: Config + pallet_balances::Config>, - ::AllPalletsWithoutSystem: - OnFinalize> + OnIdle> + OnInitialize>, - ::RuntimeEvent: From> + TryInto> + Parameter + Member, - ::Balance: Into>, - { - /// Direct implementation of `GenesisBuild::build_storage`. - /// - /// Kept in order not to break dependency. - pub fn build(&self) { - ::build(self) - } - } -} - -// #[pallet_section] -// mod genesis_config { -// #[pallet::genesis_config] -// pub struct GenesisConfig { -// phantom: PhantomData, -// } -// -// impl Default for GenesisConfig { -// fn default() -> Self { -// Self {phantom: PhantomData} -// } -// } -// -// #[pallet::genesis_build] -// impl BuildGenesisConfig for GenesisConfig { -// fn build(&self) {} -// } -// -// } diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index ffa0d3805..592a83222 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -206,8 +206,6 @@ pub mod impls; pub mod instantiator; pub mod traits; -mod genesis_config; - pub type AccountIdOf = ::AccountId; pub type ProjectId = u32; pub type MultiplierOf = ::Multiplier; From 6c8198e8a0787c3a99d21dfa0c602f9f4c68559a Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 9 Jan 2024 16:53:51 +0100 Subject: [PATCH 098/212] remove unused mut https://github.com/Polimec/polimec-node/pull/130#discussion_r1445793434 Signed-off-by: Juan Ignacio Rios --- integration-tests/src/tests/ct_migration.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index 96a90415a..810cc3a71 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -280,7 +280,7 @@ fn migration_check() { #[test] fn migration_is_sent() { let mut inst = IntegrationInstantiator::new(None); - let mut participants = + let participants = vec![EVAL_1, EVAL_2, EVAL_3, BIDDER_1, BIDDER_2, BIDDER_3, BIDDER_4, BUYER_1, BUYER_2, BUYER_3, BUYER_4] .into_iter() .map(|x| AccountId::from(x)) From f9c341186ff5cbd317815c5f3ddd3999fba282e8 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 9 Jan 2024 16:57:24 +0100 Subject: [PATCH 099/212] remove unused mut https://github.com/Polimec/polimec-node/pull/130#discussion_r1445795866 Signed-off-by: Juan Ignacio Rios --- integration-tests/src/tests/ct_migration.rs | 2 +- integration-tests/src/tests/oracle.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/src/tests/ct_migration.rs b/integration-tests/src/tests/ct_migration.rs index 810cc3a71..f2004024e 100644 --- a/integration-tests/src/tests/ct_migration.rs +++ b/integration-tests/src/tests/ct_migration.rs @@ -489,7 +489,7 @@ fn disallow_duplicated_migrations_on_receiver_pallet() { panic!("should be rewarded") } - let mut participants = vec![ + let participants = vec![ EVAL_1, EVAL_2, EVAL_3, EVAL_4, BIDDER_1, BIDDER_2, BIDDER_3, BIDDER_4, BIDDER_5, BIDDER_6, BUYER_1, BUYER_2, BUYER_3, BUYER_4, BUYER_5, BUYER_6, ] diff --git a/integration-tests/src/tests/oracle.rs b/integration-tests/src/tests/oracle.rs index 43e65929c..0d4642fbe 100644 --- a/integration-tests/src/tests/oracle.rs +++ b/integration-tests/src/tests/oracle.rs @@ -28,7 +28,7 @@ fn members_can_feed_data() { Polimec::execute_with(|| { // pallet_funding genesis builder already inputs prices, so we need to advance one block to feed new values. - inst.advance_time(1u32); + inst.advance_time(1u32).unwrap(); let alice = Polimec::account_id_of(ALICE); assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(alice.clone()), values([4.84, 1.0, 1.0, 0.4]))); From dcba4f2d86d0c5aaa80e4bdb0b38acf30d86e873 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 9 Jan 2024 17:16:14 +0100 Subject: [PATCH 100/212] TODO added https://github.com/Polimec/polimec-node/pull/130#discussion_r1445838795 Signed-off-by: Juan Ignacio Rios --- integration-tests/src/tests/oracle.rs | 2 +- pallets/funding/src/impls.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/integration-tests/src/tests/oracle.rs b/integration-tests/src/tests/oracle.rs index 0d4642fbe..19ac889d5 100644 --- a/integration-tests/src/tests/oracle.rs +++ b/integration-tests/src/tests/oracle.rs @@ -68,7 +68,7 @@ fn data_is_correctly_combined() { let mut inst = IntegrationInstantiator::new(None); Polimec::execute_with(|| { // pallet_funding genesis builder already inputs prices, so we need to advance one block to feed new values. - inst.advance_time(1u32); + inst.advance_time(1u32).unwrap(); let alice = Polimec::account_id_of(ALICE); assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(alice.clone()), values([1.0, 1.5, 1.1, 0.11111]))); diff --git a/pallets/funding/src/impls.rs b/pallets/funding/src/impls.rs index 9fd09755d..3458700bb 100644 --- a/pallets/funding/src/impls.rs +++ b/pallets/funding/src/impls.rs @@ -274,6 +274,7 @@ fn release_future_ct_deposit_one_participant( project_id, &account, ) { + // TODO: replace when benchmark is done // Ok(_) => return (base_weight.saturating_add(WeightInfoOf::::release_future_ct_deposit_for()), iter_participants.collect_vec()), Ok(_) => return ( From 9149b143d8012c724bbe0c0b49b7b36df4a62d5a Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 10 Jan 2024 11:36:28 +0100 Subject: [PATCH 101/212] remove unused old genesis builder https://github.com/Polimec/polimec-node/pull/130#discussion_r1445855143 Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/lib.rs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 592a83222..739f5b7cd 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1401,22 +1401,6 @@ pub mod pallet { } } } - #[cfg(feature = "std")] - impl GenesisConfig - where - T: Config + pallet_balances::Config>, - ::AllPalletsWithoutSystem: - OnFinalize> + OnIdle> + OnInitialize>, - ::RuntimeEvent: From> + TryInto> + Parameter + Member, - ::Balance: Into>, - { - /// Direct implementation of `GenesisBuild::build_storage`. - /// - /// Kept in order not to break dependency. - pub fn build(&self) { - ::build(self) - } - } } pub mod xcm_executor_impl { From 13e97de4b5fedcd05fdfccef59f49bdb928542ff Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 10 Jan 2024 11:38:27 +0100 Subject: [PATCH 102/212] remove else statement https://github.com/Polimec/polimec-node/pull/130#discussion_r1445861196 Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/instantiator.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 2eb078ffc..8c20ab3c0 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -90,9 +90,8 @@ impl< pub fn execute(&mut self, execution: impl FnOnce() -> R) -> R { if let Some(ext) = &self.ext { return ext.borrow_mut().execute_with(execution) - } else { - execution() } + execution() } pub fn get_new_nonce(&self) -> u64 { From c60ad31bdafe43af71f18908855c8c5912140123 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 10 Jan 2024 11:40:38 +0100 Subject: [PATCH 103/212] remove commented out lines https://github.com/Polimec/polimec-node/pull/130#discussion_r1445888533 Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/mock.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 247d69c83..1b25945d8 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -262,15 +262,6 @@ parameter_types! { pub const ManualAcceptanceDuration: BlockNumber = (3 * HOURS) as BlockNumber; pub const SuccessToSettlementTime: BlockNumber =(4 * HOURS) as BlockNumber; - // pub const EvaluationDuration: BlockNumber = (28) as BlockNumber; - // pub const AuctionInitializePeriodDuration: BlockNumber = (7) as BlockNumber; - // pub const EnglishAuctionDuration: BlockNumber = (2) as BlockNumber; - // pub const CandleAuctionDuration: BlockNumber = (3) as BlockNumber; - // pub const CommunityRoundDuration: BlockNumber = (5) as BlockNumber; - // pub const RemainderFundingDuration: BlockNumber = (1) as BlockNumber; - // pub const ManualAcceptanceDuration: BlockNumber = (3) as BlockNumber; - // pub const SuccessToSettlementTime: BlockNumber =(4) as BlockNumber; - pub const FundingPalletId: PalletId = PalletId(*b"py/cfund"); pub PriceMap: BTreeMap = BTreeMap::from_iter(vec![ (0u32, FixedU128::from_float(69f64)), // DOT From 67753368c2decf828a59defa93055ac42a23bf48 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 10 Jan 2024 14:11:43 +0100 Subject: [PATCH 104/212] remove AccountList and use same pattern as other functions https://github.com/Polimec/polimec-node/pull/130#discussion_r1445890382. Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/impls.rs | 138 +++++++++++++++------------- pallets/funding/src/instantiator.rs | 1 - pallets/funding/src/lib.rs | 26 ++---- pallets/funding/src/types.rs | 23 ++--- 4 files changed, 86 insertions(+), 102 deletions(-) diff --git a/pallets/funding/src/impls.rs b/pallets/funding/src/impls.rs index 3458700bb..da1a3f90b 100644 --- a/pallets/funding/src/impls.rs +++ b/pallets/funding/src/impls.rs @@ -1,4 +1,7 @@ -use frame_support::{traits::Get, weights::Weight}; +use frame_support::{ + traits::{fungible::InspectHold, Get}, + weights::Weight, +}; use itertools::Itertools; use sp_arithmetic::traits::Zero; use sp_runtime::{traits::AccountIdConversion, DispatchError}; @@ -6,14 +9,14 @@ use sp_std::{collections::btree_set::BTreeSet, marker::PhantomData}; use crate::{traits::DoRemainingOperation, *}; -impl DoRemainingOperation for Cleaner> { +impl DoRemainingOperation for Cleaner { fn has_remaining_operations(&self) -> bool { match self { Cleaner::NotReady => false, Cleaner::Success(state) => - > as DoRemainingOperation>::has_remaining_operations(state), + as DoRemainingOperation>::has_remaining_operations(state), Cleaner::Failure(state) => - > as DoRemainingOperation>::has_remaining_operations(state), + as DoRemainingOperation>::has_remaining_operations(state), } } @@ -21,18 +24,14 @@ impl DoRemainingOperation for Cleaner> { match self { Cleaner::NotReady => Err(DispatchError::Other("Cleaner not ready")), Cleaner::Success(state) => - > as DoRemainingOperation>::do_one_operation( - state, project_id, - ), + as DoRemainingOperation>::do_one_operation(state, project_id), Cleaner::Failure(state) => - > as DoRemainingOperation>::do_one_operation( - state, project_id, - ), + as DoRemainingOperation>::do_one_operation(state, project_id), } } } -impl DoRemainingOperation for CleanerState> { +impl DoRemainingOperation for CleanerState { fn has_remaining_operations(&self) -> bool { !matches!(self, CleanerState::Finished(_)) } @@ -147,7 +146,7 @@ impl DoRemainingOperation for CleanerState DoRemainingOperation for CleanerState> { +impl DoRemainingOperation for CleanerState { fn has_remaining_operations(&self) -> bool { !matches!(self, CleanerState::Finished(PhantomData::)) } @@ -171,7 +170,7 @@ impl DoRemainingOperation for CleanerState) => if *remaining == 0 { *self = CleanerState::FutureDepositRelease( - remaining_participants::(project_id), + remaining_participants_with_future_ct_deposit::(project_id), PhantomData::, ); Ok(base_weight) @@ -181,8 +180,8 @@ impl DoRemainingOperation for CleanerState) => - if remaining_participants.is_empty() { + CleanerState::FutureDepositRelease(remaining, PhantomData::) => + if *remaining == 0 { *self = CleanerState::EvaluationUnbonding( remaining_evaluations::(project_id), PhantomData::, @@ -190,7 +189,7 @@ impl DoRemainingOperation for CleanerState(project_id, remaining_participants.clone()); + release_future_ct_deposit_one_participant::(project_id); *self = CleanerState::FutureDepositRelease(remaining_participants, PhantomData::); Ok(consumed_weight) }, @@ -261,44 +260,6 @@ impl DoRemainingOperation for CleanerState( - project_id: ProjectId, - remaining_participants: AccountListOf, -) -> (Weight, AccountListOf) { - let base_weight = Weight::from_parts(10_000_000, 0); - let mut iter_participants = remaining_participants.into_iter(); - - while let Some(account) = iter_participants.next() { - match Pallet::::do_release_future_ct_deposit_for( - &T::PalletId::get().into_account_truncating(), - project_id, - &account, - ) { - // TODO: replace when benchmark is done - // Ok(_) => return (base_weight.saturating_add(WeightInfoOf::::release_future_ct_deposit_for()), iter_participants.collect_vec()), - Ok(_) => - return ( - base_weight, - iter_participants.collect_vec().try_into().expect("Vec is equal or smaller, so has to fit"), - ), - Err(e) if e == Error::::NoFutureDepositHeld.into() => continue, - Err(e) => { - Pallet::::deposit_event(Event::ReleaseFutureCTDepositFailed { - project_id, - participant: account.clone(), - error: e, - }); - // return (base_weight.saturating_add(WeightInfoOf::::release_future_ct_deposit_for()), iter_participants.collect_vec()); - return ( - base_weight.saturating_add(base_weight), - iter_participants.collect_vec().try_into().expect("Vec is equal or smaller, so has to fit"), - ) - }, - }; - } - return (base_weight, iter_participants.collect_vec().try_into().expect("Vec is equal or smaller, so has to fit")) -} - fn remaining_evaluators_to_reward_or_slash(project_id: ProjectId, outcome: EvaluatorsOutcomeOf) -> u64 { if outcome == EvaluatorsOutcomeOf::::Unchanged { 0u64 @@ -336,18 +297,6 @@ fn remaining_contributions(project_id: ProjectId) -> u64 { Contributions::::iter_prefix_values((project_id,)).count() as u64 } -fn remaining_participants(project_id: ProjectId) -> AccountListOf { - let evaluators = Evaluations::::iter_key_prefix((project_id,)).map(|(evaluator, _evaluation_id)| evaluator); - let bidders = Bids::::iter_key_prefix((project_id,)).map(|(bidder, _bid_id)| bidder); - let contributors = - Contributions::::iter_key_prefix((project_id,)).map(|(contributor, _contribution_id)| contributor); - let all_participants = evaluators.chain(bidders).chain(contributors).collect::>>(); - AccountListOf::::force_from( - all_participants.into_iter().collect_vec(), - Some("getting remaining participants in Cleaner"), - ) -} - fn remaining_bids_without_ct_minted(project_id: ProjectId) -> u64 { let project_bids = Bids::::iter_prefix_values((project_id,)); project_bids.filter(|bid| !bid.ct_minted).count() as u64 @@ -366,6 +315,21 @@ fn remaining_contributions_without_issuer_payout(project_id: ProjectI Contributions::::iter_prefix_values((project_id,)).filter(|bid| !bid.funds_released).count() as u64 } +fn remaining_participants_with_future_ct_deposit(project_id: ProjectId) -> u64 { + let evaluators = Evaluations::::iter_key_prefix((project_id,)).map(|(evaluator, _evaluation_id)| evaluator); + let bidders = Bids::::iter_key_prefix((project_id,)).map(|(bidder, _bid_id)| bidder); + let contributors = + Contributions::::iter_key_prefix((project_id,)).map(|(contributor, _contribution_id)| contributor); + let all_participants = evaluators.chain(bidders).chain(contributors).collect::>>(); + all_participants + .into_iter() + .filter(|account| { + ::NativeCurrency::balance_on_hold(&HoldReason::FutureDeposit(project_id).into(), account) > + Zero::zero() + }) + .count() as u64 +} + fn reward_or_slash_one_evaluation(project_id: ProjectId) -> Result<(Weight, u64), DispatchError> { let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectNotFound)?; let project_evaluations = Evaluations::::iter_prefix_values((project_id,)); @@ -504,6 +468,48 @@ fn unbond_one_bid(project_id: ProjectId) -> (Weight, u64) { } } +fn release_future_ct_deposit_one_participant(project_id: ProjectId) -> (Weight, u64) { + let base_weight = Weight::from_parts(10_000_000, 0); + let evaluators = Evaluations::::iter_key_prefix((project_id,)).map(|(evaluator, _evaluation_id)| evaluator); + let bidders = Bids::::iter_key_prefix((project_id,)).map(|(bidder, _bid_id)| bidder); + let contributors = + Contributions::::iter_key_prefix((project_id,)).map(|(contributor, _contribution_id)| contributor); + let all_participants = evaluators.chain(bidders).chain(contributors).collect::>>(); + let remaining_participants = all_participants + .into_iter() + .filter(|account| { + ::NativeCurrency::balance_on_hold(&HoldReason::FutureDeposit(project_id).into(), account) > + Zero::zero() + }) + .collect_vec(); + let mut iter_participants = remaining_participants.into_iter(); + + if let Some(account) = iter_participants.next() { + match Pallet::::do_release_future_ct_deposit_for( + &T::PalletId::get().into_account_truncating(), + project_id, + &account, + ) { + // TODO: replace when benchmark is done + // Ok(_) => return (base_weight.saturating_add(WeightInfoOf::::release_future_ct_deposit_for()), iter_participants.collect_vec()), + Ok(_) => return (base_weight, iter_participants.count() as u64), + // TODO: use when storing remaining accounts in outer function calling do_one_operation https://linear.app/polimec/issue/PLMC-410/cleaner-remaining-users-calculation + // Err(e) if e == Error::::NoFutureDepositHeld.into() => continue, + Err(e) => { + Pallet::::deposit_event(Event::ReleaseFutureCTDepositFailed { + project_id, + participant: account.clone(), + error: e, + }); + // TODO: replace when benchmark is done + // return (base_weight.saturating_add(WeightInfoOf::::release_future_ct_deposit_for()), iter_participants.collect_vec()); + return (base_weight, iter_participants.count() as u64) + }, + }; + } + return (base_weight, 0u64) +} + fn release_funds_one_contribution(project_id: ProjectId) -> (Weight, u64) { let project_contributions = Contributions::::iter_prefix_values((project_id,)); let mut remaining_contributions = project_contributions.filter(|contribution| !contribution.funds_released); diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 8c20ab3c0..d88f75ef7 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -33,7 +33,6 @@ use sp_std::{ iter::zip, marker::PhantomData, ops::Not, - prelude::*, }; pub use testing_macros::*; diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 739f5b7cd..d5032a71d 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -183,8 +183,7 @@ pub use pallet::*; use polimec_common::migration_types::*; use polkadot_parachain::primitives::Id as ParaId; use sp_arithmetic::traits::{One, Saturating}; -use sp_core::ConstU32; -use sp_runtime::{traits::AccountIdConversion, FixedPointNumber, FixedPointOperand, FixedU128, WeakBoundedVec}; +use sp_runtime::{traits::AccountIdConversion, FixedPointNumber, FixedPointOperand, FixedU128}; use sp_std::{marker::PhantomData, prelude::*}; use traits::DoRemainingOperation; pub use types::*; @@ -217,20 +216,12 @@ pub type HashOf = ::Hash; pub type AssetIdOf = <::FundingCurrency as fungibles::Inspect<::AccountId>>::AssetId; pub type RewardInfoOf = RewardInfo>; - -pub type AccountListOf = WeakBoundedVec, ConstU32<1000u32>>; pub type EvaluatorsOutcomeOf = EvaluatorsOutcome>; pub type ProjectMetadataOf = ProjectMetadata>, BalanceOf, PriceOf, AccountIdOf, HashOf>; -pub type ProjectDetailsOf = ProjectDetails< - AccountIdOf, - BlockNumberFor, - PriceOf, - BalanceOf, - EvaluationRoundInfoOf, - AccountListOf, ->; +pub type ProjectDetailsOf = + ProjectDetails, BlockNumberFor, PriceOf, BalanceOf, EvaluationRoundInfoOf>; pub type EvaluationRoundInfoOf = EvaluationRoundInfo>; pub type VestingInfoOf = VestingInfo, BalanceOf>; pub type EvaluationInfoOf = EvaluationInfo, BalanceOf, BlockNumberFor>; @@ -1300,10 +1291,7 @@ pub mod pallet { let projects_needing_cleanup = ProjectsDetails::::iter() .filter_map(|(project_id, info)| match info.cleanup { - cleaner - if > as DoRemainingOperation>::has_remaining_operations( - &cleaner, - ) => + cleaner if >::has_remaining_operations(&cleaner) => Some((project_id, cleaner)), _ => None, }) @@ -1323,10 +1311,8 @@ pub mod pallet { // let mut consumed_weight = WeightInfoOf::::insert_cleaned_project(); let mut consumed_weight = Weight::from_parts(6_034_000, 0); while !consumed_weight.any_gt(max_weight_per_project) { - if let Ok(weight) = > as DoRemainingOperation>::do_one_operation( - &mut cleaner, - project_id, - ) { + if let Ok(weight) = >::do_one_operation(&mut cleaner, project_id) + { consumed_weight.saturating_accrue(weight); } else { break diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index d40c17bd7..e5f195c1f 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -203,14 +203,7 @@ pub mod storage_types { } #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)] - pub struct ProjectDetails< - AccountId, - BlockNumber, - Price: FixedPointNumber, - Balance: BalanceT, - EvaluationRoundInfo, - AccountList, - > { + pub struct ProjectDetails { pub issuer: AccountId, /// Whether the project is frozen, so no `metadata` changes are allowed. pub is_frozen: bool, @@ -227,7 +220,7 @@ pub mod storage_types { /// Funding reached amount in USD equivalent pub funding_amount_reached: Balance, /// Cleanup operations remaining - pub cleanup: Cleaner, + pub cleanup: Cleaner, /// Information about the total amount bonded, and the outcome in regards to reward/slash/nothing pub evaluation_round_info: EvaluationRoundInfo, /// When the Funding Round ends @@ -637,7 +630,7 @@ pub mod inner_types { pub struct Failure; #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] - pub enum CleanerState { + pub enum CleanerState { Initialized(PhantomData), // Success or Failure EvaluationRewardOrSlash(u64, PhantomData), @@ -655,19 +648,19 @@ pub mod inner_types { BidUnbonding(u64, PhantomData), ContributionFundingRelease(u64, PhantomData), ContributionUnbonding(u64, PhantomData), - FutureDepositRelease(AccountList, PhantomData), + FutureDepositRelease(u64, PhantomData), // Merge // Success or Failure Finished(PhantomData), } #[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)] - pub enum Cleaner { + pub enum Cleaner { NotReady, - Success(CleanerState), - Failure(CleanerState), + Success(CleanerState), + Failure(CleanerState), } - impl TryFrom for Cleaner { + impl TryFrom for Cleaner { type Error = (); fn try_from(value: ProjectStatus) -> Result { From fba9d69c565ddbd60e55bafb4c370a7646302086 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 10 Jan 2024 14:15:49 +0100 Subject: [PATCH 105/212] updated comment on Expendable reason https://github.com/Polimec/polimec-node/pull/130#discussion_r1445846983 Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/functions.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index b1730f3fb..638144f92 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -2703,7 +2703,10 @@ impl Pallet { ) -> DispatchResult { let fund_account = Self::fund_account_id(project_id); - // The USDT/USDC account should be created by using a provider reference (as opposed to a deposit with `touch()`), so we don't care if it gets destroyed now. + // Why `Preservation::Expendable`? + // the min_balance of funding assets (e.g USDT) are low enough so we don't expect users to care about their balance being dusted. + // We do think the UX would be bad if they cannot use all of their available tokens. + // Specially since a new funding asset account can be easily created by increasing the provider reference T::FundingCurrency::transfer(asset_id, who, &fund_account, amount, Preservation::Expendable)?; Ok(()) From 68f9e3876da0060da7665fc5746c721bb8a92cdd Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 12 Jan 2024 17:31:25 +0100 Subject: [PATCH 106/212] fix: could not compile pallet-funding alone due to missing `default = ["std"]"` in Cargo.toml Signed-off-by: Juan Ignacio Rios --- pallets/funding/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pallets/funding/Cargo.toml b/pallets/funding/Cargo.toml index 9e1aa54e1..2a38979a2 100644 --- a/pallets/funding/Cargo.toml +++ b/pallets/funding/Cargo.toml @@ -62,6 +62,7 @@ assert_matches2.workspace = true xcm-executor.workspace = true [features] +default = ["std"] std = [ "frame-benchmarking?/std", "frame-support/std", From 09ecb409dec75be89327daba99aa830e979f8d37 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 11 Jan 2024 15:56:31 +0100 Subject: [PATCH 107/212] save Signed-off-by: Juan Ignacio Rios --- integration-tests/Cargo.toml | 2 ++ integration-tests/penpal/Cargo.toml | 2 ++ pallets/funding/Cargo.toml | 1 + pallets/linear-release/Cargo.toml | 1 + pallets/parachain-staking/Cargo.toml | 2 ++ pallets/parachain-staking/src/benchmarks.rs | 3 +-- 6 files changed, 9 insertions(+), 2 deletions(-) diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 37218e727..5215b2c9d 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -115,6 +115,7 @@ std = [ "xcm-builder/std", "xcm-executor/std", "xcm/std", + "polimec-common/std" ] runtime-benchmarks = [ @@ -146,6 +147,7 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", + "polimec-common/runtime-benchmarks" ] try-runtime = [ "asset-hub-polkadot-runtime/try-runtime", diff --git a/integration-tests/penpal/Cargo.toml b/integration-tests/penpal/Cargo.toml index 18e844d35..1114b1689 100644 --- a/integration-tests/penpal/Cargo.toml +++ b/integration-tests/penpal/Cargo.toml @@ -137,6 +137,7 @@ std = [ "xcm-builder/std", "xcm-executor/std", "xcm/std", + "polimec-common/std" ] runtime-benchmarks = [ @@ -164,6 +165,7 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", + "polimec-common/runtime-benchmarks" ] try-runtime = [ diff --git a/pallets/funding/Cargo.toml b/pallets/funding/Cargo.toml index 2a38979a2..71d52a362 100644 --- a/pallets/funding/Cargo.toml +++ b/pallets/funding/Cargo.toml @@ -132,3 +132,4 @@ try-runtime = [ "polkadot-runtime/try-runtime", "sp-runtime/try-runtime", ] + diff --git a/pallets/linear-release/Cargo.toml b/pallets/linear-release/Cargo.toml index eee46609c..b8716fcfd 100644 --- a/pallets/linear-release/Cargo.toml +++ b/pallets/linear-release/Cargo.toml @@ -49,6 +49,7 @@ std = [ "sp-runtime/std", "sp-std/std", "xcm-builder?/std", + "serde/std" ] runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", diff --git a/pallets/parachain-staking/Cargo.toml b/pallets/parachain-staking/Cargo.toml index fe2fa8cf1..0604087e4 100644 --- a/pallets/parachain-staking/Cargo.toml +++ b/pallets/parachain-staking/Cargo.toml @@ -64,6 +64,7 @@ std = [ "sp-staking/std", "sp-std/std", "substrate-fixed/std", + "polimec-common/std" ] runtime-benchmarks = [ "frame-benchmarking", @@ -74,6 +75,7 @@ runtime-benchmarks = [ "pallet-timestamp/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "sp-staking/runtime-benchmarks", + "polimec-common/runtime-benchmarks" ] try-runtime = [ "frame-support/try-runtime", diff --git a/pallets/parachain-staking/src/benchmarks.rs b/pallets/parachain-staking/src/benchmarks.rs index c420794e0..c8732e4f5 100644 --- a/pallets/parachain-staking/src/benchmarks.rs +++ b/pallets/parachain-staking/src/benchmarks.rs @@ -22,11 +22,10 @@ use crate::{ ParachainBondInfo, Points, Range, RewardPayment, Round, ScheduledRequest, Staked, TopDelegations, }; use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, vec}; -use frame_support::traits::{Currency, Get, OnFinalize, OnInitialize}; +use frame_support::traits::{fungible::Balanced, Currency, Get, OnFinalize, OnInitialize}; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use sp_runtime::{Perbill, Percent}; use sp_std::vec::Vec; - /// Minimum collator candidate stake fn min_candidate_stk() -> BalanceOf { <::MinCandidateStk as Get>>::get() From fc02b00cc0a3b16b08b4703523c210d1d7a114b3 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 12 Jan 2024 17:32:21 +0100 Subject: [PATCH 108/212] fix linear-release benchmarks Signed-off-by: Juan Ignacio Rios --- pallets/linear-release/src/benchmarking.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pallets/linear-release/src/benchmarking.rs b/pallets/linear-release/src/benchmarking.rs index dfaca63e9..c6908ad1f 100644 --- a/pallets/linear-release/src/benchmarking.rs +++ b/pallets/linear-release/src/benchmarking.rs @@ -25,12 +25,11 @@ use frame_support::{ traits::{tokens::Preservation::Expendable, OriginTrait}, }; use frame_system::{pallet_prelude::BlockNumberFor, Pallet as System, RawOrigin}; -use pallet_funding::LockType; +use pallet_funding::HoldReason; use sp_runtime::traits::{CheckedDiv, CheckedMul}; - const SEED: u32 = 0; -fn add_holds>>(who: &T::AccountId, n: u32) { +fn add_holds>(who: &T::AccountId, n: u32) { for id in 0..n { let locked = 256u32; let reason: ReasonOf = HoldReason::Participation(id).into(); @@ -70,7 +69,7 @@ fn add_vesting_schedules( #[benchmarks( where - T: Config + frame_system::Config::RuntimeEvent> + crate::Config>, + T: Config + frame_system::Config::RuntimeEvent> + crate::Config, ::AccountId: Into<<::RuntimeOrigin as OriginTrait>::AccountId> + sp_std::fmt::Debug, )] mod benches { From dab1d801c86a6ee46d0fe8c47f8fecb6e14e6559 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 12 Jan 2024 18:20:19 +0100 Subject: [PATCH 109/212] fix staking benchmarks and add optional compilation for externalities on instantiator Signed-off-by: Juan Ignacio Rios --- justfile | 1 + pallets/funding/src/instantiator.rs | 13 ++++++++++--- pallets/linear-release/src/benchmarking.rs | 8 ++++++-- pallets/parachain-staking/src/benchmarks.rs | 14 ++++++++------ 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/justfile b/justfile index efe1b7f77..b38338cca 100644 --- a/justfile +++ b/justfile @@ -46,6 +46,7 @@ benchmark-runtime-funding: --heap-pages=4096 \ --output=runtimes/testnet/src/weights/pallet_funding.rs + # Benchmark the "Testnet" Runtime benchmark-runtime-linear-release: cargo run --features runtime-benchmarks --release -p polimec-parachain-node benchmark pallet \ diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index d88f75ef7..b3fefa5c4 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -61,12 +61,18 @@ pub struct TestProjectParams { pub remainder_contributions: Vec>, } +#[cfg(feature = "std")] +type OptionalExternalities = Option>; + +#[cfg(not(feature = "std"))] +type OptionalExternalities = Option<()>; + pub struct Instantiator< T: Config + pallet_balances::Config>, AllPalletsWithoutSystem: OnFinalize> + OnIdle> + OnInitialize>, RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, > { - ext: Option>, + ext: OptionalExternalities, nonce: RefCell, _marker: PhantomData<(T, AllPalletsWithoutSystem, RuntimeEvent)>, } @@ -78,15 +84,16 @@ impl< RuntimeEvent: From> + TryInto> + Parameter + Member + IsType<::RuntimeEvent>, > Instantiator { - pub fn new(ext: Option>) -> Self { + pub fn new(ext: OptionalExternalities) -> Self { Self { ext, nonce: RefCell::new(0u64), _marker: PhantomData } } - pub fn set_ext(&mut self, ext: Option>) { + pub fn set_ext(&mut self, ext: OptionalExternalities) { self.ext = ext; } pub fn execute(&mut self, execution: impl FnOnce() -> R) -> R { + #[cfg(feature = "std")] if let Some(ext) = &self.ext { return ext.borrow_mut().execute_with(execution) } diff --git a/pallets/linear-release/src/benchmarking.rs b/pallets/linear-release/src/benchmarking.rs index c6908ad1f..a77d2225c 100644 --- a/pallets/linear-release/src/benchmarking.rs +++ b/pallets/linear-release/src/benchmarking.rs @@ -29,7 +29,10 @@ use pallet_funding::HoldReason; use sp_runtime::traits::{CheckedDiv, CheckedMul}; const SEED: u32 = 0; -fn add_holds>(who: &T::AccountId, n: u32) { +fn add_holds(who: &T::AccountId, n: u32) +where + ::RuntimeHoldReason: From, +{ for id in 0..n { let locked = 256u32; let reason: ReasonOf = HoldReason::Participation(id).into(); @@ -69,8 +72,9 @@ fn add_vesting_schedules( #[benchmarks( where - T: Config + frame_system::Config::RuntimeEvent> + crate::Config, + T: Config + frame_system::Config::RuntimeEvent> + crate::Config, ::AccountId: Into<<::RuntimeOrigin as OriginTrait>::AccountId> + sp_std::fmt::Debug, + ::RuntimeHoldReason: From, )] mod benches { use super::*; diff --git a/pallets/parachain-staking/src/benchmarks.rs b/pallets/parachain-staking/src/benchmarks.rs index c8732e4f5..bdb2fd9cb 100644 --- a/pallets/parachain-staking/src/benchmarks.rs +++ b/pallets/parachain-staking/src/benchmarks.rs @@ -21,8 +21,10 @@ use crate::{ AwardedPts, BalanceOf, Call, CandidateBondLessRequest, Config, DelegationAction, Pallet, ParachainBondConfig, ParachainBondInfo, Points, Range, RewardPayment, Round, ScheduledRequest, Staked, TopDelegations, }; +use frame_support::traits::fungible::{Inspect, Mutate}; + use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, vec}; -use frame_support::traits::{fungible::Balanced, Currency, Get, OnFinalize, OnInitialize}; +use frame_support::traits::{fungible::Balanced, Get, OnFinalize, OnInitialize}; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use sp_runtime::{Perbill, Percent}; use sp_std::vec::Vec; @@ -44,7 +46,7 @@ fn create_funded_user(string: &'static str, n: u32, extra: BalanceOf< let user = account(string, n, SEED); let min_candidate_stk = min_candidate_stk::(); let total = min_candidate_stk + extra; - T::Currency::make_free_balance_be(&user, total); + T::Currency::set_balance(&user, total); T::Currency::issue(total); (user, total) } @@ -1022,13 +1024,13 @@ benchmarks! { verify { // collator should have been paid assert!( - T::Currency::free_balance(&sole_collator) > initial_stake_amount, + T::Currency::balance(&sole_collator) > initial_stake_amount, "collator should have been paid in pay_one_collator_reward" ); // nominators should have been paid for delegator in &delegators { assert!( - T::Currency::free_balance(&delegator) > initial_stake_amount, + T::Currency::balance(&delegator) > initial_stake_amount, "delegator should have been paid in pay_one_collator_reward" ); } @@ -1248,12 +1250,12 @@ benchmarks! { true, 1, )?; - let original_free_balance = T::Currency::free_balance(&collator); + let original_free_balance = T::Currency::balance(&collator); }: { Pallet::::mint_collator_reward(1u32.into(), collator.clone(), 50u32.into()) } verify { - assert_eq!(T::Currency::free_balance(&collator), original_free_balance + 50u32.into()); + assert_eq!(T::Currency::balance(&collator), original_free_balance + 50u32.into()); } } From 2ae3fec7d6f76c5775e6764533d0ee90ebcaae36 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 15 Jan 2024 11:01:18 +0100 Subject: [PATCH 110/212] pallet_funding benchmarks fixed. Signed-off-by: Juan Ignacio Rios --- Cargo.lock | 861 ++-------------------------- Cargo.toml | 6 +- integration-tests/Cargo.toml | 1 + integration-tests/src/lib.rs | 1 + pallets/funding/src/benchmarking.rs | 62 +- 5 files changed, 83 insertions(+), 848 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1961d18ad..0911c1acb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -125,12 +125,6 @@ dependencies = [ "libc", ] -[[package]] -name = "anes" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" - [[package]] name = "ansi_term" version = "0.12.1" @@ -278,98 +272,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15832d94c458da98cac0ffa6eca52cc19c2a3c6c951058500a5ae8f01f0fdf56" -[[package]] -name = "asset-hub-polkadot-runtime" -version = "0.9.420" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "assets-common", - "cumulus-pallet-aura-ext", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-session-benchmarking", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "cumulus-primitives-timestamp", - "cumulus-primitives-utility", - "frame-benchmarking", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal 0.4.1", - "log", - "pallet-asset-tx-payment", - "pallet-assets", - "pallet-aura", - "pallet-authorship", - "pallet-balances", - "pallet-collator-selection", - "pallet-multisig", - "pallet-nfts", - "pallet-nfts-runtime-api", - "pallet-proxy", - "pallet-session", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-uniques", - "pallet-utility", - "pallet-xcm", - "pallet-xcm-benchmarks", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "polkadot-core-primitives", - "polkadot-parachain", - "polkadot-runtime-common", - "polkadot-runtime-constants", - "scale-info", - "smallvec", - "sp-api", - "sp-block-builder", - "sp-consensus-aura", - "sp-core", - "sp-inherents", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "sp-weights", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "assets-common" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "cumulus-primitives-core", - "frame-support", - "log", - "pallet-asset-conversion", - "pallet-asset-tx-payment", - "pallet-xcm", - "parachains-common", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-runtime", - "sp-std", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", -] - [[package]] name = "async-channel" version = "1.9.0" @@ -808,21 +710,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "casey" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614586263949597dcc18675da12ef9b429135e13628d92eb8b8c6fa50ca5656b" -dependencies = [ - "syn 1.0.109", -] - -[[package]] -name = "cast" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" - [[package]] name = "cc" version = "1.0.83" @@ -901,33 +788,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "ciborium" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" -dependencies = [ - "ciborium-io", - "ciborium-ll", - "serde", -] - -[[package]] -name = "ciborium-io" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" - -[[package]] -name = "ciborium-ll" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" -dependencies = [ - "ciborium-io", - "half", -] - [[package]] name = "cid" version = "0.9.0" @@ -1298,44 +1158,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "criterion" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" -dependencies = [ - "anes", - "cast", - "ciborium", - "clap", - "criterion-plot", - "futures", - "is-terminal", - "itertools 0.10.5", - "num-traits", - "once_cell", - "oorandom", - "plotters", - "rayon", - "regex", - "serde", - "serde_derive", - "serde_json", - "tinytemplate", - "tokio", - "walkdir", -] - -[[package]] -name = "criterion-plot" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" -dependencies = [ - "cast", - "itertools 0.10.5", -] - [[package]] name = "crossbeam-deque" version = "0.8.3" @@ -1561,29 +1383,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cumulus-client-consensus-relay-chain" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "async-trait", - "cumulus-client-consensus-common", - "cumulus-primitives-core", - "cumulus-relay-chain-interface", - "futures", - "parking_lot 0.12.1", - "sc-consensus", - "sp-api", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-inherents", - "sp-runtime", - "substrate-prometheus-endpoint", - "tracing", -] - [[package]] name = "cumulus-client-network" version = "0.1.0" @@ -1992,123 +1791,10 @@ source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c2 dependencies = [ "cumulus-primitives-core", "parity-scale-codec", - "polkadot-primitives", - "sp-runtime", - "sp-state-machine", - "sp-std", -] - -[[package]] -name = "cumulus-test-relay-validation-worker-provider" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "polkadot-node-core-pvf", - "toml 0.7.8", -] - -[[package]] -name = "cumulus-test-runtime" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "cumulus-pallet-parachain-system", - "cumulus-primitives-core", - "cumulus-primitives-timestamp", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-rpc-runtime-api", - "pallet-balances", - "pallet-glutton", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-block-builder", - "sp-core", - "sp-inherents", - "sp-io", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", -] - -[[package]] -name = "cumulus-test-service" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "async-trait", - "clap", - "criterion", - "cumulus-client-cli", - "cumulus-client-consensus-common", - "cumulus-client-consensus-relay-chain", - "cumulus-client-pov-recovery", - "cumulus-client-service", - "cumulus-pallet-parachain-system", - "cumulus-primitives-core", - "cumulus-primitives-parachain-inherent", - "cumulus-relay-chain-inprocess-interface", - "cumulus-relay-chain-interface", - "cumulus-relay-chain-minimal-node", - "cumulus-test-relay-sproof-builder", - "cumulus-test-relay-validation-worker-provider", - "cumulus-test-runtime", - "frame-system", - "frame-system-rpc-runtime-api", - "jsonrpsee", - "pallet-timestamp", - "pallet-transaction-payment", - "parachains-common", - "parity-scale-codec", - "polkadot-cli", - "polkadot-node-subsystem", - "polkadot-overseer", - "polkadot-primitives", - "polkadot-service", - "polkadot-test-service", - "rand 0.8.5", - "sc-basic-authorship", - "sc-block-builder", - "sc-chain-spec", - "sc-cli", - "sc-client-api", - "sc-consensus", - "sc-executor", - "sc-executor-common", - "sc-executor-wasmtime", - "sc-network", - "sc-service", - "sc-telemetry", - "sc-tracing", - "sc-transaction-pool", - "sc-transaction-pool-api", - "serde", - "sp-api", - "sp-arithmetic", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-io", - "sp-keyring", + "polkadot-primitives", "sp-runtime", "sp-state-machine", - "sp-timestamp", - "sp-tracing", - "sp-trie", - "substrate-test-client", - "tempfile", - "tokio", - "tracing", - "url", + "sp-std", ] [[package]] @@ -3467,12 +3153,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "half" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" - [[package]] name = "handlebars" version = "4.5.0" @@ -3881,61 +3561,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "integration-tests" -version = "0.1.0" -dependencies = [ - "asset-hub-polkadot-runtime", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "frame-support", - "frame-system", - "itertools 0.11.0", - "macros", - "orml-oracle", - "pallet-assets", - "pallet-balances", - "pallet-funding", - "pallet-im-online", - "pallet-linear-release", - "pallet-membership", - "pallet-message-queue", - "pallet-parachain-staking", - "pallet-staking", - "pallet-vesting", - "pallet-xcm", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "penpal-runtime", - "polimec-base-runtime", - "polimec-common", - "polimec-parachain-runtime", - "polimec-receiver", - "polkadot-core-primitives", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime", - "polkadot-runtime-constants", - "polkadot-runtime-parachains", - "polkadot-service", - "sc-consensus-grandpa", - "scale-info", - "sp-arithmetic", - "sp-authority-discovery", - "sp-consensus-babe", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-emulator", - "xcm-executor", -] - [[package]] name = "io-lifetimes" version = "1.0.11" @@ -5570,12 +5195,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "oorandom" -version = "11.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" - [[package]] name = "opaque-debug" version = "0.2.3" @@ -5688,24 +5307,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-asset-conversion" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-asset-tx-payment" version = "4.0.0-dev" @@ -6107,24 +5708,6 @@ dependencies = [ "xcm-executor", ] -[[package]] -name = "pallet-glutton" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "blake2", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-grandpa" version = "4.0.0-dev" @@ -6305,35 +5888,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-nfts" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "enumflags2", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-nfts-runtime-api" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "frame-support", - "pallet-nfts", - "parity-scale-codec", - "sp-api", -] - [[package]] name = "pallet-nis" version = "4.0.0-dev" @@ -6827,21 +6381,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-uniques" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-utility" version = "4.0.0-dev" @@ -7072,124 +6611,61 @@ dependencies = [ ] [[package]] -name = "parking_lot_core" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall 0.4.1", - "smallvec", - "windows-targets 0.48.5", -] - -[[package]] -name = "partial_sort" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" - -[[package]] -name = "paste" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" - -[[package]] -name = "pbkdf2" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" -dependencies = [ - "crypto-mac 0.11.1", -] - -[[package]] -name = "pbkdf2" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - -[[package]] -name = "pem" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" -dependencies = [ - "base64 0.13.1", -] - -[[package]] -name = "penpal-runtime" -version = "0.9.27" -dependencies = [ - "cumulus-pallet-aura-ext", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-session-benchmarking", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "cumulus-primitives-timestamp", - "cumulus-primitives-utility", - "frame-benchmarking", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal 0.4.1", - "log", - "pallet-asset-tx-payment", - "pallet-assets", - "pallet-aura", - "pallet-authorship", - "pallet-balances", - "pallet-collator-selection", - "pallet-session", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-vesting", - "pallet-xcm", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "polimec-common", - "polimec-receiver", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "scale-info", - "smallvec", - "sp-api", - "sp-block-builder", - "sp-consensus-aura", - "sp-core", - "sp-inherents", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", +name = "parking_lot_core" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.4.1", + "smallvec", + "windows-targets 0.48.5", +] + +[[package]] +name = "partial_sort" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" + +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "pbkdf2" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" +dependencies = [ + "crypto-mac 0.11.1", +] + +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "pem" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" +dependencies = [ + "base64 0.13.1", ] [[package]] @@ -7313,34 +6789,6 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" -[[package]] -name = "plotters" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" -dependencies = [ - "num-traits", - "plotters-backend", - "plotters-svg", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "plotters-backend" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" - -[[package]] -name = "plotters-svg" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" -dependencies = [ - "plotters-backend", -] - [[package]] name = "polimec-base-runtime" version = "0.1.0" @@ -8795,118 +8243,6 @@ dependencies = [ "sp-core", ] -[[package]] -name = "polkadot-test-runtime" -version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" -dependencies = [ - "bitvec", - "frame-election-provider-support", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-rpc-runtime-api", - "log", - "pallet-authority-discovery", - "pallet-authorship", - "pallet-babe", - "pallet-balances", - "pallet-grandpa", - "pallet-indices", - "pallet-offences", - "pallet-session", - "pallet-staking", - "pallet-staking-reward-curve", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-vesting", - "pallet-xcm", - "parity-scale-codec", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "rustc-hex", - "scale-info", - "serde", - "serde_derive", - "smallvec", - "sp-api", - "sp-authority-discovery", - "sp-block-builder", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-core", - "sp-inherents", - "sp-io", - "sp-mmr-primitives", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", - "test-runtime-constants", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "polkadot-test-service" -version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" -dependencies = [ - "frame-system", - "futures", - "hex", - "pallet-balances", - "pallet-staking", - "pallet-transaction-payment", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-overseer", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-rpc", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "polkadot-service", - "polkadot-test-runtime", - "rand 0.8.5", - "sc-authority-discovery", - "sc-chain-spec", - "sc-cli", - "sc-client-api", - "sc-consensus", - "sc-consensus-babe", - "sc-consensus-grandpa", - "sc-network", - "sc-service", - "sc-tracing", - "sc-transaction-pool", - "sp-arithmetic", - "sp-authority-discovery", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-consensus-grandpa", - "sp-core", - "sp-inherents", - "sp-keyring", - "sp-runtime", - "sp-state-machine", - "substrate-test-client", - "tempfile", - "test-runtime-constants", - "tokio", - "tracing-gum", -] - [[package]] name = "polling" version = "3.3.1" @@ -12392,32 +11728,6 @@ dependencies = [ "trie-db", ] -[[package]] -name = "substrate-test-client" -version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "array-bytes", - "async-trait", - "futures", - "parity-scale-codec", - "sc-client-api", - "sc-client-db", - "sc-consensus", - "sc-executor", - "sc-offchain", - "sc-service", - "serde", - "serde_json", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-keyring", - "sp-keystore", - "sp-runtime", - "sp-state-machine", -] - [[package]] name = "substrate-typenum" version = "1.16.0" @@ -12547,20 +11857,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" -[[package]] -name = "test-runtime-constants" -version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" -dependencies = [ - "frame-support", - "polkadot-primitives", - "polkadot-runtime-common", - "smallvec", - "sp-core", - "sp-runtime", - "sp-weights", -] - [[package]] name = "thiserror" version = "1.0.50" @@ -12697,16 +11993,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "tinytemplate" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" -dependencies = [ - "serde", - "serde_json", -] - [[package]] name = "tinyvec" version = "1.6.0" @@ -14150,39 +13436,6 @@ dependencies = [ "xcm-executor", ] -[[package]] -name = "xcm-emulator" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "casey", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "cumulus-primitives-parachain-inherent", - "cumulus-test-relay-sproof-builder", - "cumulus-test-service", - "frame-support", - "frame-system", - "log", - "pallet-balances", - "pallet-message-queue", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "paste", - "polkadot-primitives", - "polkadot-runtime-parachains", - "quote", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-std", - "sp-trie", - "xcm", -] - [[package]] name = "xcm-executor" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index 5f61f8341..0e4a5dd65 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,8 +3,8 @@ members = [ "nodes/*", "runtimes/*", "pallets/*", - "integration-tests", - "integration-tests/penpal", +# "integration-tests", +# "integration-tests/penpal", "macros", "macros/tests", "polimec-common", @@ -99,6 +99,7 @@ frame-executive = { git = "https://github.com/paritytech/substrate", default-fea frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } +frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } frame-try-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } @@ -223,7 +224,6 @@ substrate-build-script-utils = { git = "https://github.com/paritytech/substrate" # Benchmarking (with default disabled) cumulus-pallet-session-benchmarking = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "release-v1.0.0" } -frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } # Runtimes polimec-parachain-runtime = { path = "runtimes/testnet" } diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 5215b2c9d..671b0d8ad 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -147,6 +147,7 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", + "xcm-emulator/runtime-benchmarks", "polimec-common/runtime-benchmarks" ] try-runtime = [ diff --git a/integration-tests/src/lib.rs b/integration-tests/src/lib.rs index 032493822..01d1e7580 100644 --- a/integration-tests/src/lib.rs +++ b/integration-tests/src/lib.rs @@ -13,6 +13,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . + pub mod constants; mod tests; diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 636abbe6f..74c70c5d0 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -208,7 +208,6 @@ mod benchmarks { fn create() { // * setup * let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); let ed = BenchInstantiator::::get_ed(); @@ -241,7 +240,6 @@ mod benchmarks { fn edit_metadata() { // * setup * let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -271,7 +269,6 @@ mod benchmarks { fn start_evaluation() { // * setup * let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -309,7 +306,6 @@ mod benchmarks { fn bond_evaluation() { // setup let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -382,7 +378,6 @@ mod benchmarks { fn start_auction() { // * setup * let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -425,7 +420,6 @@ mod benchmarks { fn bid() { // * setup * let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -531,7 +525,6 @@ mod benchmarks { fn contribute() { // setup let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -637,7 +630,6 @@ mod benchmarks { fn evaluation_unbond_for() { // setup let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -707,7 +699,6 @@ mod benchmarks { fn evaluation_slash_for() { // setup let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -791,7 +782,6 @@ mod benchmarks { fn evaluation_reward_payout_for() { // setup let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -861,7 +851,6 @@ mod benchmarks { fn bid_ct_mint_for() { // setup let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -912,7 +901,6 @@ mod benchmarks { fn contribution_ct_mint_for() { // setup let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -974,7 +962,6 @@ mod benchmarks { fn start_bid_vesting_schedule_for() { // setup let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -1030,7 +1017,6 @@ mod benchmarks { fn start_contribution_vesting_schedule_for() { // setup let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -1093,7 +1079,6 @@ mod benchmarks { fn payout_bid_funds_for() { // setup let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -1147,7 +1132,6 @@ mod benchmarks { fn payout_contribution_funds_for() { // setup let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -1213,7 +1197,6 @@ mod benchmarks { fn decide_project_outcome() { // setup let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -1268,7 +1251,6 @@ mod benchmarks { fn release_bid_funds_for() { // setup let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -1340,7 +1322,6 @@ mod benchmarks { fn bid_unbond_for() { // setup let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -1413,7 +1394,6 @@ mod benchmarks { fn release_contribution_funds_for() { // setup let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -1492,7 +1472,6 @@ mod benchmarks { fn contribution_unbond_for() { // setup let mut inst = BenchInstantiator::::new(None); - ::SetPrices::set_prices(); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -1596,24 +1575,25 @@ mod benchmarks { // ); // } - // #[macro_export] - // macro_rules! find_event { - // ($env: expr, $pattern:pat) => { - // $env.execute(|| { - // let events: Vec::RuntimeEvent, T::Hash>> = frame_system::Pallet::::events(); - // - // events.iter().find_map(|event_record| { - // let runtime_event = event_record.event.clone(); - // if let Ok(eve) = runtime_event.try_into() { - // if let $pattern = &eve { - // return Some(Rc::new(eve)) - // } else { - // return None - // } - // } - // return None - // }) - // }) - // }; - // } + #[macro_export] + macro_rules! find_event { + ($env: expr, $pattern:pat) => { + $env.execute(|| { + let events: Vec::RuntimeEvent, T::Hash>> = + frame_system::Pallet::::events(); + + events.iter().find_map(|event_record| { + let runtime_event = event_record.event.clone(); + if let Ok(eve) = runtime_event.try_into() { + if let $pattern = &eve { + return Some(Rc::new(eve)) + } else { + return None + } + } + return None + }) + }) + }; + } } From e0c6466b1eb64ed233b32f23ce0f6ddc2a1b1807 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 15 Jan 2024 11:01:55 +0100 Subject: [PATCH 111/212] uncommented integration-tests. Had to do it to compile workspace with `runtime-benchmarks` Signed-off-by: Juan Ignacio Rios --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0e4a5dd65..0451e3542 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,8 +3,8 @@ members = [ "nodes/*", "runtimes/*", "pallets/*", -# "integration-tests", -# "integration-tests/penpal", + "integration-tests", + "integration-tests/penpal", "macros", "macros/tests", "polimec-common", From 9f02b4c82211fcd9575990fbc38d868e61d1696d Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 15 Jan 2024 11:42:52 +0100 Subject: [PATCH 112/212] all benchmarks running to completion Signed-off-by: Juan Ignacio Rios --- Cargo.lock | 747 +++++++++++++++++++++++++++++++++++ integration-tests/Cargo.toml | 1 - runtimes/testnet/src/lib.rs | 12 +- 3 files changed, 758 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0911c1acb..1961d18ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -125,6 +125,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + [[package]] name = "ansi_term" version = "0.12.1" @@ -272,6 +278,98 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15832d94c458da98cac0ffa6eca52cc19c2a3c6c951058500a5ae8f01f0fdf56" +[[package]] +name = "asset-hub-polkadot-runtime" +version = "0.9.420" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "assets-common", + "cumulus-pallet-aura-ext", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-session-benchmarking", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-timestamp", + "cumulus-primitives-utility", + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal 0.4.1", + "log", + "pallet-asset-tx-payment", + "pallet-assets", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-multisig", + "pallet-nfts", + "pallet-nfts-runtime-api", + "pallet-proxy", + "pallet-session", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-uniques", + "pallet-utility", + "pallet-xcm", + "pallet-xcm-benchmarks", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-runtime-common", + "polkadot-runtime-constants", + "scale-info", + "smallvec", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "sp-weights", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "assets-common" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "cumulus-primitives-core", + "frame-support", + "log", + "pallet-asset-conversion", + "pallet-asset-tx-payment", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-runtime", + "sp-std", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + [[package]] name = "async-channel" version = "1.9.0" @@ -710,6 +808,21 @@ dependencies = [ "thiserror", ] +[[package]] +name = "casey" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614586263949597dcc18675da12ef9b429135e13628d92eb8b8c6fa50ca5656b" +dependencies = [ + "syn 1.0.109", +] + +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + [[package]] name = "cc" version = "1.0.83" @@ -788,6 +901,33 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "ciborium" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" + +[[package]] +name = "ciborium-ll" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" +dependencies = [ + "ciborium-io", + "half", +] + [[package]] name = "cid" version = "0.9.0" @@ -1158,6 +1298,44 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "criterion" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" +dependencies = [ + "anes", + "cast", + "ciborium", + "clap", + "criterion-plot", + "futures", + "is-terminal", + "itertools 0.10.5", + "num-traits", + "once_cell", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_derive", + "serde_json", + "tinytemplate", + "tokio", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" +dependencies = [ + "cast", + "itertools 0.10.5", +] + [[package]] name = "crossbeam-deque" version = "0.8.3" @@ -1383,6 +1561,29 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cumulus-client-consensus-relay-chain" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "async-trait", + "cumulus-client-consensus-common", + "cumulus-primitives-core", + "cumulus-relay-chain-interface", + "futures", + "parking_lot 0.12.1", + "sc-consensus", + "sp-api", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-inherents", + "sp-runtime", + "substrate-prometheus-endpoint", + "tracing", +] + [[package]] name = "cumulus-client-network" version = "0.1.0" @@ -1797,6 +1998,119 @@ dependencies = [ "sp-std", ] +[[package]] +name = "cumulus-test-relay-validation-worker-provider" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "polkadot-node-core-pvf", + "toml 0.7.8", +] + +[[package]] +name = "cumulus-test-runtime" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "cumulus-pallet-parachain-system", + "cumulus-primitives-core", + "cumulus-primitives-timestamp", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "pallet-balances", + "pallet-glutton", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-block-builder", + "sp-core", + "sp-inherents", + "sp-io", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", +] + +[[package]] +name = "cumulus-test-service" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "async-trait", + "clap", + "criterion", + "cumulus-client-cli", + "cumulus-client-consensus-common", + "cumulus-client-consensus-relay-chain", + "cumulus-client-pov-recovery", + "cumulus-client-service", + "cumulus-pallet-parachain-system", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-relay-chain-inprocess-interface", + "cumulus-relay-chain-interface", + "cumulus-relay-chain-minimal-node", + "cumulus-test-relay-sproof-builder", + "cumulus-test-relay-validation-worker-provider", + "cumulus-test-runtime", + "frame-system", + "frame-system-rpc-runtime-api", + "jsonrpsee", + "pallet-timestamp", + "pallet-transaction-payment", + "parachains-common", + "parity-scale-codec", + "polkadot-cli", + "polkadot-node-subsystem", + "polkadot-overseer", + "polkadot-primitives", + "polkadot-service", + "polkadot-test-service", + "rand 0.8.5", + "sc-basic-authorship", + "sc-block-builder", + "sc-chain-spec", + "sc-cli", + "sc-client-api", + "sc-consensus", + "sc-executor", + "sc-executor-common", + "sc-executor-wasmtime", + "sc-network", + "sc-service", + "sc-telemetry", + "sc-tracing", + "sc-transaction-pool", + "sc-transaction-pool-api", + "serde", + "sp-api", + "sp-arithmetic", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-io", + "sp-keyring", + "sp-runtime", + "sp-state-machine", + "sp-timestamp", + "sp-tracing", + "sp-trie", + "substrate-test-client", + "tempfile", + "tokio", + "tracing", + "url", +] + [[package]] name = "curve25519-dalek" version = "2.1.3" @@ -3153,6 +3467,12 @@ dependencies = [ "tracing", ] +[[package]] +name = "half" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" + [[package]] name = "handlebars" version = "4.5.0" @@ -3561,6 +3881,61 @@ dependencies = [ "num-traits", ] +[[package]] +name = "integration-tests" +version = "0.1.0" +dependencies = [ + "asset-hub-polkadot-runtime", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "frame-support", + "frame-system", + "itertools 0.11.0", + "macros", + "orml-oracle", + "pallet-assets", + "pallet-balances", + "pallet-funding", + "pallet-im-online", + "pallet-linear-release", + "pallet-membership", + "pallet-message-queue", + "pallet-parachain-staking", + "pallet-staking", + "pallet-vesting", + "pallet-xcm", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "penpal-runtime", + "polimec-base-runtime", + "polimec-common", + "polimec-parachain-runtime", + "polimec-receiver", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime", + "polkadot-runtime-constants", + "polkadot-runtime-parachains", + "polkadot-service", + "sc-consensus-grandpa", + "scale-info", + "sp-arithmetic", + "sp-authority-discovery", + "sp-consensus-babe", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-emulator", + "xcm-executor", +] + [[package]] name = "io-lifetimes" version = "1.0.11" @@ -5195,6 +5570,12 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +[[package]] +name = "oorandom" +version = "11.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" + [[package]] name = "opaque-debug" version = "0.2.3" @@ -5307,6 +5688,24 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-asset-conversion" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-asset-tx-payment" version = "4.0.0-dev" @@ -5708,6 +6107,24 @@ dependencies = [ "xcm-executor", ] +[[package]] +name = "pallet-glutton" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "blake2", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-grandpa" version = "4.0.0-dev" @@ -5888,6 +6305,35 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-nfts" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "enumflags2", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-nfts-runtime-api" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "frame-support", + "pallet-nfts", + "parity-scale-codec", + "sp-api", +] + [[package]] name = "pallet-nis" version = "4.0.0-dev" @@ -6381,6 +6827,21 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-uniques" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-utility" version = "4.0.0-dev" @@ -6668,6 +7129,69 @@ dependencies = [ "base64 0.13.1", ] +[[package]] +name = "penpal-runtime" +version = "0.9.27" +dependencies = [ + "cumulus-pallet-aura-ext", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-session-benchmarking", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-timestamp", + "cumulus-primitives-utility", + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal 0.4.1", + "log", + "pallet-asset-tx-payment", + "pallet-assets", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-session", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-vesting", + "pallet-xcm", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "polimec-common", + "polimec-receiver", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "scale-info", + "smallvec", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -6789,6 +7313,34 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" +[[package]] +name = "plotters" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" + +[[package]] +name = "plotters-svg" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +dependencies = [ + "plotters-backend", +] + [[package]] name = "polimec-base-runtime" version = "0.1.0" @@ -8243,6 +8795,118 @@ dependencies = [ "sp-core", ] +[[package]] +name = "polkadot-test-runtime" +version = "1.0.0" +source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" +dependencies = [ + "bitvec", + "frame-election-provider-support", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "log", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", + "pallet-balances", + "pallet-grandpa", + "pallet-indices", + "pallet-offences", + "pallet-session", + "pallet-staking", + "pallet-staking-reward-curve", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-vesting", + "pallet-xcm", + "parity-scale-codec", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "rustc-hex", + "scale-info", + "serde", + "serde_derive", + "smallvec", + "sp-api", + "sp-authority-discovery", + "sp-block-builder", + "sp-consensus-babe", + "sp-consensus-beefy", + "sp-core", + "sp-inherents", + "sp-io", + "sp-mmr-primitives", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", + "test-runtime-constants", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "polkadot-test-service" +version = "1.0.0" +source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" +dependencies = [ + "frame-system", + "futures", + "hex", + "pallet-balances", + "pallet-staking", + "pallet-transaction-payment", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-overseer", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-rpc", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "polkadot-service", + "polkadot-test-runtime", + "rand 0.8.5", + "sc-authority-discovery", + "sc-chain-spec", + "sc-cli", + "sc-client-api", + "sc-consensus", + "sc-consensus-babe", + "sc-consensus-grandpa", + "sc-network", + "sc-service", + "sc-tracing", + "sc-transaction-pool", + "sp-arithmetic", + "sp-authority-discovery", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-consensus-grandpa", + "sp-core", + "sp-inherents", + "sp-keyring", + "sp-runtime", + "sp-state-machine", + "substrate-test-client", + "tempfile", + "test-runtime-constants", + "tokio", + "tracing-gum", +] + [[package]] name = "polling" version = "3.3.1" @@ -11728,6 +12392,32 @@ dependencies = [ "trie-db", ] +[[package]] +name = "substrate-test-client" +version = "2.0.1" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "array-bytes", + "async-trait", + "futures", + "parity-scale-codec", + "sc-client-api", + "sc-client-db", + "sc-consensus", + "sc-executor", + "sc-offchain", + "sc-service", + "serde", + "serde_json", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-keyring", + "sp-keystore", + "sp-runtime", + "sp-state-machine", +] + [[package]] name = "substrate-typenum" version = "1.16.0" @@ -11857,6 +12547,20 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" +[[package]] +name = "test-runtime-constants" +version = "1.0.0" +source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" +dependencies = [ + "frame-support", + "polkadot-primitives", + "polkadot-runtime-common", + "smallvec", + "sp-core", + "sp-runtime", + "sp-weights", +] + [[package]] name = "thiserror" version = "1.0.50" @@ -11993,6 +12697,16 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -13436,6 +14150,39 @@ dependencies = [ "xcm-executor", ] +[[package]] +name = "xcm-emulator" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "casey", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-test-relay-sproof-builder", + "cumulus-test-service", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "pallet-message-queue", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "paste", + "polkadot-primitives", + "polkadot-runtime-parachains", + "quote", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-std", + "sp-trie", + "xcm", +] + [[package]] name = "xcm-executor" version = "1.0.0" diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 671b0d8ad..5215b2c9d 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -147,7 +147,6 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "xcm-emulator/runtime-benchmarks", "polimec-common/runtime-benchmarks" ] try-runtime = [ diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 41511e3fa..a6e828fd7 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -959,7 +959,17 @@ impl_runtime_apis! { use frame_benchmarking::{BenchmarkError, Benchmarking, BenchmarkBatch}; use frame_system_benchmarking::Pallet as SystemBench; - impl frame_system_benchmarking::Config for Runtime {} + impl frame_system_benchmarking::Config for Runtime { + fn setup_set_code_requirements(code: &sp_std::vec::Vec) -> Result<(), BenchmarkError> { + ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32); + Ok(()) + } + + fn verify_set_code() { + System::assert_last_event(cumulus_pallet_parachain_system::Event::::ValidationFunctionStored.into()); + } + } + use cumulus_pallet_session_benchmarking::Pallet as SessionBench; impl cumulus_pallet_session_benchmarking::Config for Runtime {} From c152e8f4febcf240de92732828e3140f26c76c90 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 15 Jan 2024 13:24:10 +0100 Subject: [PATCH 113/212] save Signed-off-by: Juan Ignacio Rios --- Cargo.lock | 861 ++------------------ Cargo.toml | 4 +- pallets/parachain-staking/src/benchmarks.rs | 2 +- 3 files changed, 60 insertions(+), 807 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8f9a558e8..3dc45f621 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -125,12 +125,6 @@ dependencies = [ "libc", ] -[[package]] -name = "anes" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" - [[package]] name = "ansi_term" version = "0.12.1" @@ -278,98 +272,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15832d94c458da98cac0ffa6eca52cc19c2a3c6c951058500a5ae8f01f0fdf56" -[[package]] -name = "asset-hub-polkadot-runtime" -version = "0.9.420" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "assets-common", - "cumulus-pallet-aura-ext", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-session-benchmarking", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "cumulus-primitives-timestamp", - "cumulus-primitives-utility", - "frame-benchmarking", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal 0.4.1", - "log", - "pallet-asset-tx-payment", - "pallet-assets", - "pallet-aura", - "pallet-authorship", - "pallet-balances", - "pallet-collator-selection", - "pallet-multisig", - "pallet-nfts", - "pallet-nfts-runtime-api", - "pallet-proxy", - "pallet-session", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-uniques", - "pallet-utility", - "pallet-xcm", - "pallet-xcm-benchmarks", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "polkadot-core-primitives", - "polkadot-parachain", - "polkadot-runtime-common", - "polkadot-runtime-constants", - "scale-info", - "smallvec", - "sp-api", - "sp-block-builder", - "sp-consensus-aura", - "sp-core", - "sp-inherents", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "sp-weights", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "assets-common" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "cumulus-primitives-core", - "frame-support", - "log", - "pallet-asset-conversion", - "pallet-asset-tx-payment", - "pallet-xcm", - "parachains-common", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-runtime", - "sp-std", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", -] - [[package]] name = "async-channel" version = "1.9.0" @@ -817,21 +719,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "casey" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614586263949597dcc18675da12ef9b429135e13628d92eb8b8c6fa50ca5656b" -dependencies = [ - "syn 1.0.109", -] - -[[package]] -name = "cast" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" - [[package]] name = "cc" version = "1.0.83" @@ -910,33 +797,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "ciborium" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" -dependencies = [ - "ciborium-io", - "ciborium-ll", - "serde", -] - -[[package]] -name = "ciborium-io" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" - -[[package]] -name = "ciborium-ll" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" -dependencies = [ - "ciborium-io", - "half", -] - [[package]] name = "cid" version = "0.9.0" @@ -1307,44 +1167,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "criterion" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" -dependencies = [ - "anes", - "cast", - "ciborium", - "clap", - "criterion-plot", - "futures", - "is-terminal", - "itertools 0.10.5", - "num-traits", - "once_cell", - "oorandom", - "plotters", - "rayon", - "regex", - "serde", - "serde_derive", - "serde_json", - "tinytemplate", - "tokio", - "walkdir", -] - -[[package]] -name = "criterion-plot" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" -dependencies = [ - "cast", - "itertools 0.10.5", -] - [[package]] name = "critical-section" version = "1.1.2" @@ -1576,29 +1398,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cumulus-client-consensus-relay-chain" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "async-trait", - "cumulus-client-consensus-common", - "cumulus-primitives-core", - "cumulus-relay-chain-interface", - "futures", - "parking_lot 0.12.1", - "sc-consensus", - "sp-api", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-inherents", - "sp-runtime", - "substrate-prometheus-endpoint", - "tracing", -] - [[package]] name = "cumulus-client-network" version = "0.1.0" @@ -2007,123 +1806,10 @@ source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c2 dependencies = [ "cumulus-primitives-core", "parity-scale-codec", - "polkadot-primitives", - "sp-runtime", - "sp-state-machine", - "sp-std", -] - -[[package]] -name = "cumulus-test-relay-validation-worker-provider" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "polkadot-node-core-pvf", - "toml 0.7.8", -] - -[[package]] -name = "cumulus-test-runtime" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "cumulus-pallet-parachain-system", - "cumulus-primitives-core", - "cumulus-primitives-timestamp", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-rpc-runtime-api", - "pallet-balances", - "pallet-glutton", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-block-builder", - "sp-core", - "sp-inherents", - "sp-io", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", -] - -[[package]] -name = "cumulus-test-service" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "async-trait", - "clap", - "criterion", - "cumulus-client-cli", - "cumulus-client-consensus-common", - "cumulus-client-consensus-relay-chain", - "cumulus-client-pov-recovery", - "cumulus-client-service", - "cumulus-pallet-parachain-system", - "cumulus-primitives-core", - "cumulus-primitives-parachain-inherent", - "cumulus-relay-chain-inprocess-interface", - "cumulus-relay-chain-interface", - "cumulus-relay-chain-minimal-node", - "cumulus-test-relay-sproof-builder", - "cumulus-test-relay-validation-worker-provider", - "cumulus-test-runtime", - "frame-system", - "frame-system-rpc-runtime-api", - "jsonrpsee", - "pallet-timestamp", - "pallet-transaction-payment", - "parachains-common", - "parity-scale-codec", - "polkadot-cli", - "polkadot-node-subsystem", - "polkadot-overseer", - "polkadot-primitives", - "polkadot-service", - "polkadot-test-service", - "rand 0.8.5", - "sc-basic-authorship", - "sc-block-builder", - "sc-chain-spec", - "sc-cli", - "sc-client-api", - "sc-consensus", - "sc-executor", - "sc-executor-common", - "sc-executor-wasmtime", - "sc-network", - "sc-service", - "sc-telemetry", - "sc-tracing", - "sc-transaction-pool", - "sc-transaction-pool-api", - "serde", - "sp-api", - "sp-arithmetic", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-io", - "sp-keyring", + "polkadot-primitives", "sp-runtime", "sp-state-machine", - "sp-timestamp", - "sp-tracing", - "sp-trie", - "substrate-test-client", - "tempfile", - "tokio", - "tracing", - "url", + "sp-std", ] [[package]] @@ -3482,12 +3168,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "half" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" - [[package]] name = "handlebars" version = "4.5.0" @@ -3919,61 +3599,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "integration-tests" -version = "0.3.2" -dependencies = [ - "asset-hub-polkadot-runtime", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "frame-support", - "frame-system", - "itertools 0.11.0", - "macros", - "orml-oracle", - "pallet-assets", - "pallet-balances", - "pallet-funding", - "pallet-im-online", - "pallet-linear-release", - "pallet-membership", - "pallet-message-queue", - "pallet-parachain-staking", - "pallet-staking", - "pallet-vesting", - "pallet-xcm", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "penpal-runtime", - "polimec-base-runtime", - "polimec-common", - "polimec-parachain-runtime", - "polimec-receiver", - "polkadot-core-primitives", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime", - "polkadot-runtime-constants", - "polkadot-runtime-parachains", - "polkadot-service", - "sc-consensus-grandpa", - "scale-info", - "sp-arithmetic", - "sp-authority-discovery", - "sp-consensus-babe", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-emulator", - "xcm-executor", -] - [[package]] name = "io-lifetimes" version = "1.0.11" @@ -5608,12 +5233,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "oorandom" -version = "11.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" - [[package]] name = "opaque-debug" version = "0.2.3" @@ -5726,24 +5345,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-asset-conversion" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-asset-tx-payment" version = "4.0.0-dev" @@ -6145,24 +5746,6 @@ dependencies = [ "xcm-executor", ] -[[package]] -name = "pallet-glutton" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "blake2", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-grandpa" version = "4.0.0-dev" @@ -6343,35 +5926,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-nfts" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "enumflags2", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-nfts-runtime-api" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "frame-support", - "pallet-nfts", - "parity-scale-codec", - "sp-api", -] - [[package]] name = "pallet-nis" version = "4.0.0-dev" @@ -6889,21 +6443,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-uniques" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-utility" version = "4.0.0-dev" @@ -7134,124 +6673,61 @@ dependencies = [ ] [[package]] -name = "parking_lot_core" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall 0.4.1", - "smallvec", - "windows-targets 0.48.5", -] - -[[package]] -name = "partial_sort" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" - -[[package]] -name = "paste" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" - -[[package]] -name = "pbkdf2" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" -dependencies = [ - "crypto-mac 0.11.1", -] - -[[package]] -name = "pbkdf2" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - -[[package]] -name = "pem" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" -dependencies = [ - "base64 0.13.1", -] - -[[package]] -name = "penpal-runtime" -version = "0.9.27" -dependencies = [ - "cumulus-pallet-aura-ext", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-session-benchmarking", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "cumulus-primitives-timestamp", - "cumulus-primitives-utility", - "frame-benchmarking", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal 0.4.1", - "log", - "pallet-asset-tx-payment", - "pallet-assets", - "pallet-aura", - "pallet-authorship", - "pallet-balances", - "pallet-collator-selection", - "pallet-session", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-vesting", - "pallet-xcm", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "polimec-common", - "polimec-receiver", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "scale-info", - "smallvec", - "sp-api", - "sp-block-builder", - "sp-consensus-aura", - "sp-core", - "sp-inherents", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", +name = "parking_lot_core" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.4.1", + "smallvec", + "windows-targets 0.48.5", +] + +[[package]] +name = "partial_sort" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" + +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "pbkdf2" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" +dependencies = [ + "crypto-mac 0.11.1", +] + +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "pem" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" +dependencies = [ + "base64 0.13.1", ] [[package]] @@ -7375,34 +6851,6 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" -[[package]] -name = "plotters" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" -dependencies = [ - "num-traits", - "plotters-backend", - "plotters-svg", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "plotters-backend" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" - -[[package]] -name = "plotters-svg" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" -dependencies = [ - "plotters-backend", -] - [[package]] name = "polimec-base-runtime" version = "0.3.2" @@ -8861,118 +8309,6 @@ dependencies = [ "sp-core", ] -[[package]] -name = "polkadot-test-runtime" -version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" -dependencies = [ - "bitvec", - "frame-election-provider-support", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-rpc-runtime-api", - "log", - "pallet-authority-discovery", - "pallet-authorship", - "pallet-babe", - "pallet-balances", - "pallet-grandpa", - "pallet-indices", - "pallet-offences", - "pallet-session", - "pallet-staking", - "pallet-staking-reward-curve", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-vesting", - "pallet-xcm", - "parity-scale-codec", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "rustc-hex", - "scale-info", - "serde", - "serde_derive", - "smallvec", - "sp-api", - "sp-authority-discovery", - "sp-block-builder", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-core", - "sp-inherents", - "sp-io", - "sp-mmr-primitives", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", - "test-runtime-constants", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "polkadot-test-service" -version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" -dependencies = [ - "frame-system", - "futures", - "hex", - "pallet-balances", - "pallet-staking", - "pallet-transaction-payment", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-overseer", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-rpc", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "polkadot-service", - "polkadot-test-runtime", - "rand 0.8.5", - "sc-authority-discovery", - "sc-chain-spec", - "sc-cli", - "sc-client-api", - "sc-consensus", - "sc-consensus-babe", - "sc-consensus-grandpa", - "sc-network", - "sc-service", - "sc-tracing", - "sc-transaction-pool", - "sp-arithmetic", - "sp-authority-discovery", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-consensus-grandpa", - "sp-core", - "sp-inherents", - "sp-keyring", - "sp-runtime", - "sp-state-machine", - "substrate-test-client", - "tempfile", - "test-runtime-constants", - "tokio", - "tracing-gum", -] - [[package]] name = "polling" version = "3.3.1" @@ -12471,32 +11807,6 @@ dependencies = [ "trie-db", ] -[[package]] -name = "substrate-test-client" -version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "array-bytes", - "async-trait", - "futures", - "parity-scale-codec", - "sc-client-api", - "sc-client-db", - "sc-consensus", - "sc-executor", - "sc-offchain", - "sc-service", - "serde", - "serde_json", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-keyring", - "sp-keystore", - "sp-runtime", - "sp-state-machine", -] - [[package]] name = "substrate-typenum" version = "1.16.0" @@ -12626,20 +11936,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" -[[package]] -name = "test-runtime-constants" -version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" -dependencies = [ - "frame-support", - "polkadot-primitives", - "polkadot-runtime-common", - "smallvec", - "sp-core", - "sp-runtime", - "sp-weights", -] - [[package]] name = "thiserror" version = "1.0.50" @@ -12776,16 +12072,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "tinytemplate" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" -dependencies = [ - "serde", - "serde_json", -] - [[package]] name = "tinyvec" version = "1.6.0" @@ -14229,39 +13515,6 @@ dependencies = [ "xcm-executor", ] -[[package]] -name = "xcm-emulator" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "casey", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "cumulus-primitives-parachain-inherent", - "cumulus-test-relay-sproof-builder", - "cumulus-test-service", - "frame-support", - "frame-system", - "log", - "pallet-balances", - "pallet-message-queue", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "paste", - "polkadot-primitives", - "polkadot-runtime-parachains", - "quote", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-std", - "sp-trie", - "xcm", -] - [[package]] name = "xcm-executor" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index e0d0ea4df..e208475bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,8 +3,8 @@ members = [ "nodes/*", "runtimes/*", "pallets/*", - "integration-tests", - "integration-tests/penpal", +# "integration-tests", +# "integration-tests/penpal", "macros", "macros/tests", "polimec-common", diff --git a/pallets/parachain-staking/src/benchmarks.rs b/pallets/parachain-staking/src/benchmarks.rs index bdb2fd9cb..86c5e9db3 100644 --- a/pallets/parachain-staking/src/benchmarks.rs +++ b/pallets/parachain-staking/src/benchmarks.rs @@ -1266,7 +1266,7 @@ mod tests { use sp_io::TestExternalities; pub fn new_test_ext() -> TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); TestExternalities::new(t) } From 1a60a774946fca93966d65b6556c7f9ad03fe5ec Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 15 Jan 2024 13:50:34 +0100 Subject: [PATCH 114/212] fix testnet runtime, bad merge with main Signed-off-by: Juan Ignacio Rios --- integration-tests/src/tests/build_spec.rs | 2 +- runtimes/testnet/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/integration-tests/src/tests/build_spec.rs b/integration-tests/src/tests/build_spec.rs index 150de50d6..edfe1798e 100644 --- a/integration-tests/src/tests/build_spec.rs +++ b/integration-tests/src/tests/build_spec.rs @@ -24,7 +24,7 @@ fn build_spec_testing_node() { assert_eq!( output.status.success(), true, - "Make sure you compile the node with \"std\" and \"fast-gov\" feature enabled before running this test." + "Make sure you compile the polimec-parachain-node with \"--release\" and \"--features std,fast-gov\" before running this test." ); dbg!(output); diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 261c5681d..6a31e8659 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -805,9 +805,9 @@ construct_runtime!( ParachainStaking: pallet_parachain_staking::{Pallet, Call, Storage, Event, Config, HoldReason} = 25, // Oracle - Oracle: orml_oracle:: = 30, + Oracle: orml_oracle::{Pallet, Call, Storage, Event} = 30, OracleProvidersMembership: pallet_membership:: = 31, - OracleOffchainWorker: pallet_oracle_ocw::{Pallet, Event} = 32, + OracleOffchainWorker: pallet_oracle_ocw::{Pallet, Event} = 32, // Governance Treasury: pallet_treasury = 40, From 03e916c6deb132a34ffcd0f88307cc3afd7bce8b Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 15 Jan 2024 13:55:47 +0100 Subject: [PATCH 115/212] fix import Signed-off-by: Juan Ignacio Rios --- nodes/parachain/src/chain_spec/testnet.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nodes/parachain/src/chain_spec/testnet.rs b/nodes/parachain/src/chain_spec/testnet.rs index a5f1bbfc5..a53c7af68 100644 --- a/nodes/parachain/src/chain_spec/testnet.rs +++ b/nodes/parachain/src/chain_spec/testnet.rs @@ -279,9 +279,9 @@ mod testing_helpers { use super::*; use frame_benchmarking::frame_support::assert_ok; use macros::generate_accounts; - use polimec_parachain_runtime::{AccountId, FixedU128}; + use polimec_parachain_runtime::AccountId; use sp_core::H256; - use sp_runtime::traits::ConstU32; + use sp_runtime::{traits::ConstU32, FixedU128}; use std::collections::HashMap; pub const METADATA: &str = r#"METADATA From 57516e2e61b14f6196d7b0b17b4e4a397396b0a8 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 15 Jan 2024 15:09:01 +0100 Subject: [PATCH 116/212] fixed staking benchmarks Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/mock.rs | 4 +++ pallets/linear-release/src/benchmarking.rs | 30 ++++++++----------- pallets/linear-release/src/lib.rs | 4 +++ pallets/linear-release/src/mock.rs | 5 ++++ .../parachain-staking/src/auto_compound.rs | 1 + pallets/parachain-staking/src/benchmarks.rs | 15 ++++++---- pallets/parachain-staking/src/lib.rs | 1 + runtimes/testnet/src/lib.rs | 4 +++ 8 files changed, 42 insertions(+), 22 deletions(-) diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 1b25945d8..bd6cc013c 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -287,9 +287,13 @@ parameter_types! { pub PolimecReceiverInfo: xcm::v3::PalletInfo = xcm::v3::PalletInfo::new( 51, "PolimecReceiver".into(), "polimec_receiver".into(), 0, 1, 0 ).unwrap(); + #[cfg(feature = "runtime-benchmarks")] + pub BenchmarkReason: RuntimeHoldReason = RuntimeHoldReason::PolimecFunding(crate::HoldReason::Participation(0)); } impl pallet_linear_release::Config for TestRuntime { type Balance = Balance; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkReason = BenchmarkReason; type BlockNumberToBalance = ConvertInto; type Currency = Balances; type MinVestedTransfer = MinVestedTransfer; diff --git a/pallets/linear-release/src/benchmarking.rs b/pallets/linear-release/src/benchmarking.rs index a77d2225c..125c5cf6b 100644 --- a/pallets/linear-release/src/benchmarking.rs +++ b/pallets/linear-release/src/benchmarking.rs @@ -29,13 +29,10 @@ use pallet_funding::HoldReason; use sp_runtime::traits::{CheckedDiv, CheckedMul}; const SEED: u32 = 0; -fn add_holds(who: &T::AccountId, n: u32) -where - ::RuntimeHoldReason: From, -{ +fn add_holds(who: &T::AccountId, n: u32) { for id in 0..n { let locked = 256u32; - let reason: ReasonOf = HoldReason::Participation(id).into(); + let reason: ReasonOf = T::BenchmarkReason::get(); let _ = T::Currency::hold(&reason, who, locked.into()); } } @@ -74,7 +71,6 @@ fn add_vesting_schedules( where T: Config + frame_system::Config::RuntimeEvent> + crate::Config, ::AccountId: Into<<::RuntimeOrigin as OriginTrait>::AccountId> + sp_std::fmt::Debug, - ::RuntimeHoldReason: From, )] mod benches { use super::*; @@ -93,7 +89,7 @@ mod benches { T::Currency::set_balance(&caller, T::Currency::minimum_balance().saturating_add(1024u32.into())); add_holds::(&caller, l); - let reason = HoldReason::Participation(l).into(); + let reason: ReasonOf = T::BenchmarkReason::get(); let _ = add_vesting_schedules::(caller.clone(), s, reason)?; // At block zero, everything is vested. @@ -123,7 +119,7 @@ mod benches { T::Currency::set_balance(&caller, T::Currency::minimum_balance().saturating_add(1024u32.into())); add_holds::(&caller, l); - let reason = HoldReason::Participation(l).into(); + let reason: ReasonOf = T::BenchmarkReason::get(); let held = add_vesting_schedules::(caller.clone(), s, reason)?; // At block 21, everything is unlocked. @@ -157,7 +153,7 @@ mod benches { T::Currency::set_balance(&other, T::Currency::minimum_balance().saturating_add(1024u32.into())); add_holds::(&other, l); - let reason = HoldReason::Participation(l).into(); + let reason: ReasonOf = T::BenchmarkReason::get(); let _ = add_vesting_schedules::(other.clone(), s, reason)?; // At block zero, everything is vested. @@ -190,7 +186,7 @@ mod benches { T::Currency::set_balance(&other, T::Currency::minimum_balance().saturating_add(1024u32.into())); add_holds::(&other, l); - let reason = HoldReason::Participation(l).into(); + let reason: ReasonOf = T::BenchmarkReason::get(); let held = add_vesting_schedules::(other.clone(), s, reason)?; // At block 21 everything is unlocked. @@ -220,7 +216,7 @@ mod benches { add_holds::(&target, l); // Add one vesting schedules. - let reason = HoldReason::Participation(l).into(); + let reason: ReasonOf = T::BenchmarkReason::get(); let mut expected_balance = add_vesting_schedules::(target.clone(), s, reason)?; let transfer_amount = T::MinVestedTransfer::get(); @@ -254,7 +250,7 @@ mod benches { add_holds::(&target, l); // Add one less than max vesting schedules - let reason = HoldReason::Participation(l).into(); + let reason: ReasonOf = T::BenchmarkReason::get(); let mut expected_balance = add_vesting_schedules::(target.clone(), s, reason)?; let transfer_amount = T::MinVestedTransfer::get(); @@ -285,7 +281,7 @@ mod benches { T::Currency::set_balance(&caller, T::Currency::minimum_balance().saturating_add(1024u32.into())); add_holds::(&caller, l); // Add max vesting schedules. - let reason = HoldReason::Participation(l).into(); + let reason: ReasonOf = T::BenchmarkReason::get(); let _ = add_vesting_schedules::(caller.clone(), s, reason)?; // Schedules are not vesting at block 0. @@ -338,7 +334,7 @@ mod benches { T::Currency::set_balance(&caller, T::Currency::minimum_balance().saturating_add(1024u32.into())); add_holds::(&caller, l); // Add max vesting schedules. - let reason = HoldReason::Participation(l).into(); + let reason: ReasonOf = T::BenchmarkReason::get(); let held = add_vesting_schedules::(caller.clone(), s, reason)?; // Go to about half way through all the schedules duration. (They all start at 1, and have a duration of 10 or 11). @@ -392,7 +388,7 @@ mod benches { add_holds::(&caller, l); // At block zero, everything is vested. assert_eq!(System::::block_number(), BlockNumberFor::::zero()); - let reason = HoldReason::Participation(l).into(); + let reason: ReasonOf = T::BenchmarkReason::get(); let _ = add_vesting_schedules::(caller.clone(), s, reason)?; assert_eq!( PalletLinearRelease::::vesting_balance(&caller, reason), @@ -404,7 +400,7 @@ mod benches { vest_all(RawOrigin::Signed(caller.clone())); for _ in 0..l { - let reason = HoldReason::Participation(l).into(); + let reason: ReasonOf = T::BenchmarkReason::get(); // Nothing happened since everything is still vested. assert_eq!( PalletLinearRelease::::vesting_balance(&caller, reason), @@ -423,7 +419,7 @@ mod benches { T::Currency::set_balance(&other, T::Currency::minimum_balance().saturating_add(1024u32.into())); add_holds::(&other, l); - let reason = HoldReason::Participation(l).into(); + let reason: ReasonOf = T::BenchmarkReason::get(); let _ = add_vesting_schedules::(other.clone(), s, reason)?; // At block zero, everything is vested. diff --git a/pallets/linear-release/src/lib.rs b/pallets/linear-release/src/lib.rs index 3c9a709de..6d6c0daf0 100644 --- a/pallets/linear-release/src/lib.rs +++ b/pallets/linear-release/src/lib.rs @@ -142,6 +142,10 @@ pub mod pallet { /// Weight information for extrinsics in this pallet. type WeightInfo: WeightInfo; + + /// Reason used when running benchmarks + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkReason: Get; } #[pallet::extra_constants] diff --git a/pallets/linear-release/src/mock.rs b/pallets/linear-release/src/mock.rs index 316db7f6a..69627b302 100644 --- a/pallets/linear-release/src/mock.rs +++ b/pallets/linear-release/src/mock.rs @@ -86,8 +86,13 @@ impl pallet_balances::Config for Test { type WeightInfo = (); } +parameter_types! { + pub BenchmarkReason: MockRuntimeHoldReason = MockRuntimeHoldReason::Reason; +} impl Config for Test { type Balance = u64; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkReason = BenchmarkReason; type BlockNumberToBalance = Identity; type Currency = Balances; // TODO: Use the type from Balances. diff --git a/pallets/parachain-staking/src/auto_compound.rs b/pallets/parachain-staking/src/auto_compound.rs index 214b212c0..1841c5382 100644 --- a/pallets/parachain-staking/src/auto_compound.rs +++ b/pallets/parachain-staking/src/auto_compound.rs @@ -154,6 +154,7 @@ where delegation_count_hint: u32, ) -> DispatchResultWithPostInfo { // check that caller can lock the amount before any changes to storage + let dbg = >::get_delegator_stakable_free_balance(&delegator); ensure!( >::get_delegator_stakable_free_balance(&delegator) >= amount, Error::::InsufficientBalance diff --git a/pallets/parachain-staking/src/benchmarks.rs b/pallets/parachain-staking/src/benchmarks.rs index 86c5e9db3..bef87e0bf 100644 --- a/pallets/parachain-staking/src/benchmarks.rs +++ b/pallets/parachain-staking/src/benchmarks.rs @@ -26,8 +26,11 @@ use frame_support::traits::fungible::{Inspect, Mutate}; use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, vec}; use frame_support::traits::{fungible::Balanced, Get, OnFinalize, OnInitialize}; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; +#[cfg(feature = "std")] +use sp_runtime::BuildStorage; use sp_runtime::{Perbill, Percent}; -use sp_std::vec::Vec; +use sp_std::{default::Default, vec::Vec}; + /// Minimum collator candidate stake fn min_candidate_stk() -> BalanceOf { <::MinCandidateStk as Get>>::get() @@ -46,8 +49,7 @@ fn create_funded_user(string: &'static str, n: u32, extra: BalanceOf< let user = account(string, n, SEED); let min_candidate_stk = min_candidate_stk::(); let total = min_candidate_stk + extra; - T::Currency::set_balance(&user, total); - T::Currency::issue(total); + T::Currency::set_balance(&user, total + 1u32.into()); (user, total) } @@ -1246,11 +1248,14 @@ benchmarks! { let collator = create_funded_collator::( "collator", seed.take(), - 0u32.into(), + 1u32.into(), true, 1, )?; let original_free_balance = T::Currency::balance(&collator); + let pay_master = T::PayMaster::get(); + T::Currency::set_balance(&pay_master, 100u32.into()); + }: { Pallet::::mint_collator_reward(1u32.into(), collator.clone(), 50u32.into()) } @@ -1266,7 +1271,7 @@ mod tests { use sp_io::TestExternalities; pub fn new_test_ext() -> TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); + let t = frame_system::GenesisConfig::::default().build_storage().unwrap(); TestExternalities::new(t) } diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index d15fc6cd5..d04651602 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -908,6 +908,7 @@ pub mod pallet { let old_count = candidates.0.len() as u32; ensure!(candidate_count >= old_count, Error::::TooLowCandidateCountWeightHintJoinCandidates); ensure!(candidates.insert(Bond { owner: acc.clone(), amount: bond }), Error::::CandidateExists); + let dbg = Self::get_collator_stakable_free_balance(&acc); ensure!(Self::get_collator_stakable_free_balance(&acc) >= bond, Error::::InsufficientBalance,); T::Currency::hold(&HoldReason::StakingCollator.into(), &acc, bond)?; let candidate = CandidateMetadata::new(bond); diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index ee8416cdd..f046564cb 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -604,10 +604,14 @@ parameter_types! { pub const MinVestedTransfer: Balance = PLMC; pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); + #[cfg(feature = "runtime-benchmarks")] + pub BenchmarkReason: RuntimeHoldReason = RuntimeHoldReason::PolimecFunding(pallet_funding::HoldReason::Participation(0)); } impl pallet_linear_release::Config for Runtime { type Balance = Balance; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkReason = BenchmarkReason; type BlockNumberToBalance = ConvertInto; type Currency = Balances; type MinVestedTransfer = MinVestedTransfer; From 3d55eeda64f2c7356bb336fdaa4ea67daf947504 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 15 Jan 2024 16:02:13 +0100 Subject: [PATCH 117/212] cleanup Signed-off-by: Juan Ignacio Rios --- pallets/parachain-staking/src/auto_compound.rs | 1 - pallets/parachain-staking/src/lib.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/pallets/parachain-staking/src/auto_compound.rs b/pallets/parachain-staking/src/auto_compound.rs index 1841c5382..214b212c0 100644 --- a/pallets/parachain-staking/src/auto_compound.rs +++ b/pallets/parachain-staking/src/auto_compound.rs @@ -154,7 +154,6 @@ where delegation_count_hint: u32, ) -> DispatchResultWithPostInfo { // check that caller can lock the amount before any changes to storage - let dbg = >::get_delegator_stakable_free_balance(&delegator); ensure!( >::get_delegator_stakable_free_balance(&delegator) >= amount, Error::::InsufficientBalance diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index d04651602..d15fc6cd5 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -908,7 +908,6 @@ pub mod pallet { let old_count = candidates.0.len() as u32; ensure!(candidate_count >= old_count, Error::::TooLowCandidateCountWeightHintJoinCandidates); ensure!(candidates.insert(Bond { owner: acc.clone(), amount: bond }), Error::::CandidateExists); - let dbg = Self::get_collator_stakable_free_balance(&acc); ensure!(Self::get_collator_stakable_free_balance(&acc) >= bond, Error::::InsufficientBalance,); T::Currency::hold(&HoldReason::StakingCollator.into(), &acc, bond)?; let candidate = CandidateMetadata::new(bond); From e476f50b1cad4764ab5dc2915fdb0df6b9f10b81 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 15 Jan 2024 16:04:22 +0100 Subject: [PATCH 118/212] uncomment integration-tests Signed-off-by: Juan Ignacio Rios --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e208475bb..e0d0ea4df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,8 +3,8 @@ members = [ "nodes/*", "runtimes/*", "pallets/*", -# "integration-tests", -# "integration-tests/penpal", + "integration-tests", + "integration-tests/penpal", "macros", "macros/tests", "polimec-common", From 6daf6f93c56df900be7075d812de94f9e809c296 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 16 Jan 2024 10:29:53 +0100 Subject: [PATCH 119/212] remove pallet_funding dependency from linear-release Signed-off-by: Juan Ignacio Rios --- Cargo.lock | 748 ++++++++++++++++++++- pallets/linear-release/Cargo.toml | 5 - pallets/linear-release/src/benchmarking.rs | 1 - 3 files changed, 747 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3dc45f621..1ce199dfc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -125,6 +125,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + [[package]] name = "ansi_term" version = "0.12.1" @@ -272,6 +278,98 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15832d94c458da98cac0ffa6eca52cc19c2a3c6c951058500a5ae8f01f0fdf56" +[[package]] +name = "asset-hub-polkadot-runtime" +version = "0.9.420" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "assets-common", + "cumulus-pallet-aura-ext", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-session-benchmarking", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-timestamp", + "cumulus-primitives-utility", + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal 0.4.1", + "log", + "pallet-asset-tx-payment", + "pallet-assets", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-multisig", + "pallet-nfts", + "pallet-nfts-runtime-api", + "pallet-proxy", + "pallet-session", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-uniques", + "pallet-utility", + "pallet-xcm", + "pallet-xcm-benchmarks", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-runtime-common", + "polkadot-runtime-constants", + "scale-info", + "smallvec", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "sp-weights", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "assets-common" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "cumulus-primitives-core", + "frame-support", + "log", + "pallet-asset-conversion", + "pallet-asset-tx-payment", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-runtime", + "sp-std", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + [[package]] name = "async-channel" version = "1.9.0" @@ -719,6 +817,21 @@ dependencies = [ "thiserror", ] +[[package]] +name = "casey" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614586263949597dcc18675da12ef9b429135e13628d92eb8b8c6fa50ca5656b" +dependencies = [ + "syn 1.0.109", +] + +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + [[package]] name = "cc" version = "1.0.83" @@ -797,6 +910,33 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "ciborium" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" + +[[package]] +name = "ciborium-ll" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" +dependencies = [ + "ciborium-io", + "half", +] + [[package]] name = "cid" version = "0.9.0" @@ -1167,6 +1307,44 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "criterion" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" +dependencies = [ + "anes", + "cast", + "ciborium", + "clap", + "criterion-plot", + "futures", + "is-terminal", + "itertools 0.10.5", + "num-traits", + "once_cell", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_derive", + "serde_json", + "tinytemplate", + "tokio", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" +dependencies = [ + "cast", + "itertools 0.10.5", +] + [[package]] name = "critical-section" version = "1.1.2" @@ -1398,6 +1576,29 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cumulus-client-consensus-relay-chain" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "async-trait", + "cumulus-client-consensus-common", + "cumulus-primitives-core", + "cumulus-relay-chain-interface", + "futures", + "parking_lot 0.12.1", + "sc-consensus", + "sp-api", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-inherents", + "sp-runtime", + "substrate-prometheus-endpoint", + "tracing", +] + [[package]] name = "cumulus-client-network" version = "0.1.0" @@ -1812,6 +2013,119 @@ dependencies = [ "sp-std", ] +[[package]] +name = "cumulus-test-relay-validation-worker-provider" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "polkadot-node-core-pvf", + "toml 0.7.8", +] + +[[package]] +name = "cumulus-test-runtime" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "cumulus-pallet-parachain-system", + "cumulus-primitives-core", + "cumulus-primitives-timestamp", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "pallet-balances", + "pallet-glutton", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-block-builder", + "sp-core", + "sp-inherents", + "sp-io", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", +] + +[[package]] +name = "cumulus-test-service" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "async-trait", + "clap", + "criterion", + "cumulus-client-cli", + "cumulus-client-consensus-common", + "cumulus-client-consensus-relay-chain", + "cumulus-client-pov-recovery", + "cumulus-client-service", + "cumulus-pallet-parachain-system", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-relay-chain-inprocess-interface", + "cumulus-relay-chain-interface", + "cumulus-relay-chain-minimal-node", + "cumulus-test-relay-sproof-builder", + "cumulus-test-relay-validation-worker-provider", + "cumulus-test-runtime", + "frame-system", + "frame-system-rpc-runtime-api", + "jsonrpsee", + "pallet-timestamp", + "pallet-transaction-payment", + "parachains-common", + "parity-scale-codec", + "polkadot-cli", + "polkadot-node-subsystem", + "polkadot-overseer", + "polkadot-primitives", + "polkadot-service", + "polkadot-test-service", + "rand 0.8.5", + "sc-basic-authorship", + "sc-block-builder", + "sc-chain-spec", + "sc-cli", + "sc-client-api", + "sc-consensus", + "sc-executor", + "sc-executor-common", + "sc-executor-wasmtime", + "sc-network", + "sc-service", + "sc-telemetry", + "sc-tracing", + "sc-transaction-pool", + "sc-transaction-pool-api", + "serde", + "sp-api", + "sp-arithmetic", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-io", + "sp-keyring", + "sp-runtime", + "sp-state-machine", + "sp-timestamp", + "sp-tracing", + "sp-trie", + "substrate-test-client", + "tempfile", + "tokio", + "tracing", + "url", +] + [[package]] name = "curve25519-dalek" version = "2.1.3" @@ -3168,6 +3482,12 @@ dependencies = [ "tracing", ] +[[package]] +name = "half" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" + [[package]] name = "handlebars" version = "4.5.0" @@ -3599,6 +3919,61 @@ dependencies = [ "num-traits", ] +[[package]] +name = "integration-tests" +version = "0.3.2" +dependencies = [ + "asset-hub-polkadot-runtime", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "frame-support", + "frame-system", + "itertools 0.11.0", + "macros", + "orml-oracle", + "pallet-assets", + "pallet-balances", + "pallet-funding", + "pallet-im-online", + "pallet-linear-release", + "pallet-membership", + "pallet-message-queue", + "pallet-parachain-staking", + "pallet-staking", + "pallet-vesting", + "pallet-xcm", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "penpal-runtime", + "polimec-base-runtime", + "polimec-common", + "polimec-parachain-runtime", + "polimec-receiver", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime", + "polkadot-runtime-constants", + "polkadot-runtime-parachains", + "polkadot-service", + "sc-consensus-grandpa", + "scale-info", + "sp-arithmetic", + "sp-authority-discovery", + "sp-consensus-babe", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-emulator", + "xcm-executor", +] + [[package]] name = "io-lifetimes" version = "1.0.11" @@ -5233,6 +5608,12 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +[[package]] +name = "oorandom" +version = "11.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" + [[package]] name = "opaque-debug" version = "0.2.3" @@ -5345,6 +5726,24 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-asset-conversion" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-asset-tx-payment" version = "4.0.0-dev" @@ -5746,6 +6145,24 @@ dependencies = [ "xcm-executor", ] +[[package]] +name = "pallet-glutton" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "blake2", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-grandpa" version = "4.0.0-dev" @@ -5845,7 +6262,6 @@ dependencies = [ "frame-system", "log", "pallet-balances", - "pallet-funding", "parity-scale-codec", "polimec-common", "scale-info", @@ -5926,6 +6342,35 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-nfts" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "enumflags2", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-nfts-runtime-api" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "frame-support", + "pallet-nfts", + "parity-scale-codec", + "sp-api", +] + [[package]] name = "pallet-nis" version = "4.0.0-dev" @@ -6443,6 +6888,21 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-uniques" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-utility" version = "4.0.0-dev" @@ -6730,6 +7190,69 @@ dependencies = [ "base64 0.13.1", ] +[[package]] +name = "penpal-runtime" +version = "0.9.27" +dependencies = [ + "cumulus-pallet-aura-ext", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-session-benchmarking", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-timestamp", + "cumulus-primitives-utility", + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal 0.4.1", + "log", + "pallet-asset-tx-payment", + "pallet-assets", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-session", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-vesting", + "pallet-xcm", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "polimec-common", + "polimec-receiver", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "scale-info", + "smallvec", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -6851,6 +7374,34 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" +[[package]] +name = "plotters" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" + +[[package]] +name = "plotters-svg" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +dependencies = [ + "plotters-backend", +] + [[package]] name = "polimec-base-runtime" version = "0.3.2" @@ -8309,6 +8860,118 @@ dependencies = [ "sp-core", ] +[[package]] +name = "polkadot-test-runtime" +version = "1.0.0" +source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" +dependencies = [ + "bitvec", + "frame-election-provider-support", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "log", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", + "pallet-balances", + "pallet-grandpa", + "pallet-indices", + "pallet-offences", + "pallet-session", + "pallet-staking", + "pallet-staking-reward-curve", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-vesting", + "pallet-xcm", + "parity-scale-codec", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "rustc-hex", + "scale-info", + "serde", + "serde_derive", + "smallvec", + "sp-api", + "sp-authority-discovery", + "sp-block-builder", + "sp-consensus-babe", + "sp-consensus-beefy", + "sp-core", + "sp-inherents", + "sp-io", + "sp-mmr-primitives", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", + "test-runtime-constants", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "polkadot-test-service" +version = "1.0.0" +source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" +dependencies = [ + "frame-system", + "futures", + "hex", + "pallet-balances", + "pallet-staking", + "pallet-transaction-payment", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-overseer", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-rpc", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "polkadot-service", + "polkadot-test-runtime", + "rand 0.8.5", + "sc-authority-discovery", + "sc-chain-spec", + "sc-cli", + "sc-client-api", + "sc-consensus", + "sc-consensus-babe", + "sc-consensus-grandpa", + "sc-network", + "sc-service", + "sc-tracing", + "sc-transaction-pool", + "sp-arithmetic", + "sp-authority-discovery", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-consensus-grandpa", + "sp-core", + "sp-inherents", + "sp-keyring", + "sp-runtime", + "sp-state-machine", + "substrate-test-client", + "tempfile", + "test-runtime-constants", + "tokio", + "tracing-gum", +] + [[package]] name = "polling" version = "3.3.1" @@ -11807,6 +12470,32 @@ dependencies = [ "trie-db", ] +[[package]] +name = "substrate-test-client" +version = "2.0.1" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "array-bytes", + "async-trait", + "futures", + "parity-scale-codec", + "sc-client-api", + "sc-client-db", + "sc-consensus", + "sc-executor", + "sc-offchain", + "sc-service", + "serde", + "serde_json", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-keyring", + "sp-keystore", + "sp-runtime", + "sp-state-machine", +] + [[package]] name = "substrate-typenum" version = "1.16.0" @@ -11936,6 +12625,20 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" +[[package]] +name = "test-runtime-constants" +version = "1.0.0" +source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" +dependencies = [ + "frame-support", + "polkadot-primitives", + "polkadot-runtime-common", + "smallvec", + "sp-core", + "sp-runtime", + "sp-weights", +] + [[package]] name = "thiserror" version = "1.0.50" @@ -12072,6 +12775,16 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -13515,6 +14228,39 @@ dependencies = [ "xcm-executor", ] +[[package]] +name = "xcm-emulator" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "casey", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-test-relay-sproof-builder", + "cumulus-test-service", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "pallet-message-queue", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "paste", + "polkadot-primitives", + "polkadot-runtime-parachains", + "quote", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-std", + "sp-trie", + "xcm", +] + [[package]] name = "xcm-executor" version = "1.0.0" diff --git a/pallets/linear-release/Cargo.toml b/pallets/linear-release/Cargo.toml index b8716fcfd..648f294f0 100644 --- a/pallets/linear-release/Cargo.toml +++ b/pallets/linear-release/Cargo.toml @@ -22,7 +22,6 @@ sp-std.workspace = true sp-runtime.workspace = true polimec-common.workspace = true frame-benchmarking = { workspace = true, optional = true } -pallet-funding = { workspace = true, optional = true } xcm-builder = { workspace = true, optional = true } [dev-dependencies] @@ -40,7 +39,6 @@ std = [ "frame-system/std", "log/std", "pallet-balances/std", - "pallet-funding/std", "parity-scale-codec/std", "polimec-common/std", "scale-info/std", @@ -56,8 +54,6 @@ runtime-benchmarks = [ "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "pallet-balances/runtime-benchmarks", - "pallet-funding", - "pallet-funding?/runtime-benchmarks", "polimec-common/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", @@ -66,7 +62,6 @@ try-runtime = [ "frame-support/try-runtime", "frame-system/try-runtime", "pallet-balances/try-runtime", - "pallet-funding/try-runtime", "polimec-common/try-runtime", "sp-runtime/try-runtime", ] diff --git a/pallets/linear-release/src/benchmarking.rs b/pallets/linear-release/src/benchmarking.rs index 125c5cf6b..319425d2a 100644 --- a/pallets/linear-release/src/benchmarking.rs +++ b/pallets/linear-release/src/benchmarking.rs @@ -25,7 +25,6 @@ use frame_support::{ traits::{tokens::Preservation::Expendable, OriginTrait}, }; use frame_system::{pallet_prelude::BlockNumberFor, Pallet as System, RawOrigin}; -use pallet_funding::HoldReason; use sp_runtime::traits::{CheckedDiv, CheckedMul}; const SEED: u32 = 0; From 98e042b6e3ae6866d696f702351fb36bd62c88b4 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 16 Jan 2024 11:02:27 +0100 Subject: [PATCH 120/212] write single test for each benchmark Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 270 ++++++++++++++++++++++------ 1 file changed, 213 insertions(+), 57 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 74c70c5d0..b383f2a6d 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -21,9 +21,13 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -use crate::{instantiator::*, traits::SetPrices}; +use crate::{ + instantiator::*, + mock::{new_test_ext, TestRuntime}, + traits::SetPrices, +}; use frame_benchmarking::v2::*; -use frame_support::{dispatch::RawOrigin, traits::OriginTrait, Parameter}; +use frame_support::{assert_ok, dispatch::RawOrigin, traits::OriginTrait, Parameter}; #[allow(unused_imports)] use pallet::Pallet as PalletFunding; use polimec_common::ReleaseSchedule; @@ -201,7 +205,7 @@ mod benchmarks { use super::*; use itertools::Itertools; - impl_benchmark_test_suite!(PalletFunding, crate::mock::new_test_ext(), crate::mock::TestRuntime); + impl_benchmark_test_suite!(PalletFunding, super::new_test_ext(), super::TestRuntime); type BenchInstantiator = Instantiator::AllPalletsWithoutSystem, ::RuntimeEvent>; #[benchmark] @@ -1319,7 +1323,7 @@ mod benchmarks { } #[benchmark] - fn bid_unbond_for() { + fn release_contribution_funds_for() { // setup let mut inst = BenchInstantiator::::new(None); @@ -1335,20 +1339,20 @@ mod benchmarks { let bids: Vec> = BenchInstantiator::generate_bids_from_total_usd( Percent::from_percent(15) * target_funding_amount, - 10u128.into(), + 1u128.into(), default_weights(), default_bidders::(), default_bidder_multipliers(), ); - let bidder = bids[0].bidder.clone(); - whitelist_account!(bidder); - let contributions = BenchInstantiator::generate_contributions_from_total_usd( + let contributions: Vec> = BenchInstantiator::generate_contributions_from_total_usd( Percent::from_percent(10) * target_funding_amount, BenchInstantiator::calculate_price_from_test_bids(bids.clone()), default_weights(), default_contributors::(), default_community_contributor_multipliers(), ); + let contributor = contributions[0].contributor.clone(); + whitelist_account!(contributor); let project_id = inst.create_finished_project(project_metadata, issuer, evaluations, bids, contributions, vec![]); @@ -1359,39 +1363,45 @@ mod benchmarks { Cleaner::Failure(CleanerState::Initialized(PhantomData)) ); - let stored_bid = inst.execute(|| Bids::::iter_prefix_values((project_id, bidder.clone())).next().unwrap()); - - inst.execute(|| { - PalletFunding::::release_bid_funds_for( - ::RuntimeOrigin::signed(bidder.clone().into()), - project_id, - bidder.clone(), - stored_bid.id, - ) - .expect("Funds are released") - }); + let contribution_to_payout = + inst.execute(|| Contributions::::iter_prefix_values((project_id, contributor.clone())).next().unwrap()); + let asset = contribution_to_payout.funding_asset.to_statemint_id(); + let free_assets_before = + inst.get_free_statemint_asset_balances_for(asset, vec![contributor.clone()])[0].asset_amount; #[extrinsic_call] - bid_unbond_for(RawOrigin::Signed(bidder.clone()), project_id, bidder.clone(), stored_bid.id); + release_contribution_funds_for( + RawOrigin::Signed(contributor.clone()), + project_id, + contributor.clone(), + contribution_to_payout.id, + ); // * validity checks * // Storage - assert!(!Bids::::contains_key((project_id, bidder.clone(), stored_bid.id))); + let stored_contribution = + Contributions::::get((project_id, contributor.clone(), contribution_to_payout.id)).unwrap(); + assert!(stored_contribution.funds_released); + // Balances - let reserved_plmc = inst - .get_reserved_plmc_balances_for(vec![bidder.clone()], HoldReason::Participation(project_id).into())[0] - .plmc_amount; - assert_eq!(reserved_plmc, 0.into()); + let free_assets = inst.get_free_statemint_asset_balances_for(asset, vec![contributor.clone()])[0].asset_amount; + assert_eq!(free_assets, stored_contribution.funding_asset_amount + free_assets_before); // Events frame_system::Pallet::::assert_last_event( - Event::BondReleased { project_id, amount: stored_bid.plmc_bond, bonder: bidder.clone(), releaser: bidder } - .into(), + Event::ContributionFundingReleased { + project_id, + contributor: contributor.clone(), + id: stored_contribution.id, + amount: stored_contribution.funding_asset_amount, + caller: contributor, + } + .into(), ); } #[benchmark] - fn release_contribution_funds_for() { + fn bid_unbond_for() { // setup let mut inst = BenchInstantiator::::new(None); @@ -1407,20 +1417,20 @@ mod benchmarks { let bids: Vec> = BenchInstantiator::generate_bids_from_total_usd( Percent::from_percent(15) * target_funding_amount, - 1u128.into(), + 10u128.into(), default_weights(), default_bidders::(), default_bidder_multipliers(), ); - let contributions: Vec> = BenchInstantiator::generate_contributions_from_total_usd( + let bidder = bids[0].bidder.clone(); + whitelist_account!(bidder); + let contributions = BenchInstantiator::generate_contributions_from_total_usd( Percent::from_percent(10) * target_funding_amount, BenchInstantiator::calculate_price_from_test_bids(bids.clone()), default_weights(), default_contributors::(), default_community_contributor_multipliers(), ); - let contributor = contributions[0].contributor.clone(); - whitelist_account!(contributor); let project_id = inst.create_finished_project(project_metadata, issuer, evaluations, bids, contributions, vec![]); @@ -1431,40 +1441,34 @@ mod benchmarks { Cleaner::Failure(CleanerState::Initialized(PhantomData)) ); - let contribution_to_payout = - inst.execute(|| Contributions::::iter_prefix_values((project_id, contributor.clone())).next().unwrap()); + let stored_bid = inst.execute(|| Bids::::iter_prefix_values((project_id, bidder.clone())).next().unwrap()); + + inst.execute(|| { + PalletFunding::::release_bid_funds_for( + ::RuntimeOrigin::signed(bidder.clone().into()), + project_id, + bidder.clone(), + stored_bid.id, + ) + .expect("Funds are released") + }); - let asset = contribution_to_payout.funding_asset.to_statemint_id(); - let free_assets_before = - inst.get_free_statemint_asset_balances_for(asset, vec![contributor.clone()])[0].asset_amount; #[extrinsic_call] - release_contribution_funds_for( - RawOrigin::Signed(contributor.clone()), - project_id, - contributor.clone(), - contribution_to_payout.id, - ); + bid_unbond_for(RawOrigin::Signed(bidder.clone()), project_id, bidder.clone(), stored_bid.id); // * validity checks * // Storage - let stored_contribution = - Contributions::::get((project_id, contributor.clone(), contribution_to_payout.id)).unwrap(); - assert!(stored_contribution.funds_released); - + assert!(!Bids::::contains_key((project_id, bidder.clone(), stored_bid.id))); // Balances - let free_assets = inst.get_free_statemint_asset_balances_for(asset, vec![contributor.clone()])[0].asset_amount; - assert_eq!(free_assets, stored_contribution.funding_asset_amount + free_assets_before); + let reserved_plmc = inst + .get_reserved_plmc_balances_for(vec![bidder.clone()], HoldReason::Participation(project_id).into())[0] + .plmc_amount; + assert_eq!(reserved_plmc, 0.into()); // Events frame_system::Pallet::::assert_last_event( - Event::ContributionFundingReleased { - project_id, - contributor: contributor.clone(), - id: stored_contribution.id, - amount: stored_contribution.funding_asset_amount, - caller: contributor, - } - .into(), + Event::BondReleased { project_id, amount: stored_bid.plmc_bond, bonder: bidder.clone(), releaser: bidder } + .into(), ); } @@ -1596,4 +1600,156 @@ mod benchmarks { }) }; } + + #[cfg(test)] + mod tests { + use super::*; + + #[test] + fn bench_create() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_create()); + }); + } + + #[test] + fn bench_edit_metadata() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_edit_metadata()); + }); + } + + #[test] + fn bench_start_evaluation() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_start_evaluation()); + }); + } + + #[test] + fn bench_bond_evaluation() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_bond_evaluation()); + }); + } + + #[test] + fn bench_start_auction() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_start_auction()); + }); + } + + #[test] + fn bench_bid() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_bid()); + }); + } + + #[test] + fn bench_contribute() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_contribute()); + }); + } + + #[test] + fn bench_evaluation_unbond_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_evaluation_unbond_for()); + }); + } + + #[test] + fn bench_evaluation_slash_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_evaluation_slash_for()); + }); + } + + #[test] + fn bench_evaluation_reward_payout_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_evaluation_reward_payout_for()); + }); + } + + #[test] + fn bench_bid_ct_mint_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_bid_ct_mint_for()); + }); + } + + #[test] + fn bench_contribution_ct_mint_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_contribution_ct_mint_for()); + }); + } + + #[test] + fn bench_start_bid_vesting_schedule_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_start_bid_vesting_schedule_for()); + }); + } + + #[test] + fn bench_start_contribution_vesting_schedule_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_start_contribution_vesting_schedule_for()); + }); + } + + #[test] + fn bench_payout_bid_funds_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_payout_bid_funds_for()); + }); + } + + #[test] + fn bench_payout_contribution_funds_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_payout_contribution_funds_for()); + }); + } + + #[test] + fn bench_decide_project_outcome() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_decide_project_outcome()); + }); + } + + #[test] + fn bench_release_bid_funds_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_release_bid_funds_for()); + }); + } + + #[test] + fn bench_release_contribution_funds_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_release_contribution_funds_for()); + }); + } + + #[test] + fn bench_bid_unbond_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_bid_unbond_for()); + }); + } + + #[test] + fn bench_contribution_unbond_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_contribution_unbond_for()); + }); + } + } } From 17bff14141d3aa757ef38c52087b8a81bcb2ea88 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 16 Jan 2024 11:58:02 +0100 Subject: [PATCH 121/212] successfully added the async parallel instantiaton in a real benchmark :) Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 112 +++++++++++++++++++++++++--- pallets/funding/src/instantiator.rs | 2 - 2 files changed, 102 insertions(+), 12 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index b383f2a6d..6b1a4e67a 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -18,24 +18,24 @@ //! Benchmarking setup for Funding pallet -#![cfg(feature = "runtime-benchmarks")] +use sp_runtime::traits::TrailingZeroInput; use super::*; -use crate::{ - instantiator::*, - mock::{new_test_ext, TestRuntime}, - traits::SetPrices, -}; +use crate::{instantiator::*, traits::SetPrices}; + use frame_benchmarking::v2::*; use frame_support::{assert_ok, dispatch::RawOrigin, traits::OriginTrait, Parameter}; #[allow(unused_imports)] use pallet::Pallet as PalletFunding; +use parity_scale_codec::{Decode, Encode}; use polimec_common::ReleaseSchedule; use scale_info::prelude::format; use sp_arithmetic::Percent; use sp_core::H256; +use sp_io::hashing::blake2_256; use sp_runtime::traits::{BlakeTwo256, Get, Member}; -use sp_std::marker::PhantomData; +use sp_std::prelude::*; + const METADATA: &str = r#" { "whitepaper":"ipfs_url", @@ -58,6 +58,7 @@ const EDITED_METADATA: &str = r#" const ASSET_DECIMALS: u8 = 10; const US_DOLLAR: u128 = 1_0_000_000_000u128; const ASSET_UNIT: u128 = 1_0_000_000_000u128; +type BenchInstantiator = Instantiator::AllPalletsWithoutSystem, ::RuntimeEvent>; pub fn usdt_id() -> u32 { AcceptedFundingAsset::USDT.to_statemint_id() @@ -157,6 +158,33 @@ where ] } +pub fn default_remainder_contributions() -> Vec> +where + ::Price: From, + ::Balance: From, +{ + vec![ + ContributionParams::new( + account::>("contributor_1", 0, 0), + (10 * ASSET_UNIT).into(), + 1u8, + AcceptedFundingAsset::USDT, + ), + ContributionParams::new( + account::>("bidder_1", 0, 0), + (60 * ASSET_UNIT).into(), + 1u8, + AcceptedFundingAsset::USDT, + ), + ContributionParams::new( + account::>("evaluator_1", 0, 0), + (30 * ASSET_UNIT).into(), + 1u8, + AcceptedFundingAsset::USDT, + ), + ] +} + pub fn default_weights() -> Vec { vec![20u8, 15u8, 10u8, 25u8, 30u8] } @@ -191,6 +219,64 @@ pub fn default_remainder_contributor_multipliers() -> Vec { vec![1u8, 10u8, 3u8, 2u8, 4u8] } +/// Grab an account, seeded by a name and index. +pub fn string_account( + name: scale_info::prelude::string::String, + index: u32, + seed: u32, +) -> AccountId { + let entropy = (name, index, seed).using_encoded(blake2_256); + Decode::decode(&mut TrailingZeroInput::new(entropy.as_ref())) + .expect("infinite length input; no invalid inputs for type; qed") +} + +#[cfg(feature = "std")] +pub fn populate_with_projects(amount: u32, inst: BenchInstantiator) -> BenchInstantiator +where + T: Config + + frame_system::Config::RuntimeEvent> + + pallet_balances::Config>, + ::RuntimeEvent: TryInto> + Parameter + Member, + ::Price: From, + ::Balance: From, + T::Hash: From, + ::AccountId: + Into<<::RuntimeOrigin as OriginTrait>::AccountId> + sp_std::fmt::Debug, + ::Balance: Into>, +{ + let states = vec![ + ProjectStatus::Application, + ProjectStatus::EvaluationRound, + ProjectStatus::AuctionRound(AuctionPhase::English), + ProjectStatus::CommunityRound, + ProjectStatus::RemainderRound, + ProjectStatus::FundingSuccessful, + ] + .into_iter() + .cycle() + .take(amount as usize); + + let instantiation_details = states + .map(|state| { + let nonce = inst.get_new_nonce(); + let issuer_name: String = format!("issuer_{}", nonce); + + let issuer = string_account::>(issuer_name, 0, 0); + TestProjectParams:: { + expected_state: state, + metadata: default_project::(inst.get_new_nonce(), issuer.clone()), + issuer: issuer.clone(), + evaluations: default_evaluations::(), + bids: default_bids::(), + community_contributions: default_community_contributions::(), + remainder_contributions: default_remainder_contributions::(), + } + }) + .collect::>>(); + + async_features::create_multiple_projects_at(inst, instantiation_details).1 +} + #[benchmarks( where T: Config + frame_system::Config::RuntimeEvent> + pallet_balances::Config>, @@ -205,15 +291,20 @@ mod benchmarks { use super::*; use itertools::Itertools; - impl_benchmark_test_suite!(PalletFunding, super::new_test_ext(), super::TestRuntime); + impl_benchmark_test_suite!(PalletFunding, crate::mock::new_test_ext(), crate::mock::TestRuntime); - type BenchInstantiator = Instantiator::AllPalletsWithoutSystem, ::RuntimeEvent>; #[benchmark] - fn create() { + fn create(x: Linear<1, 10>) { // * setup * let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + + let projects_details_count = ProjectsDetails::::iter().count(); + let ed = BenchInstantiator::::get_ed(); let issuer = account::>("issuer", 0, 0); @@ -1604,6 +1695,7 @@ mod benchmarks { #[cfg(test)] mod tests { use super::*; + use crate::mock::{new_test_ext, TestRuntime}; #[test] fn bench_create() { diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index b3fefa5c4..65870c884 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -2342,8 +2342,6 @@ pub mod async_features { instantiator: Instantiator, projects: Vec>, ) -> (Vec, Instantiator) { - // let tokio_runtime = Runtime::new().unwrap(); - use tokio::runtime::Builder; let tokio_runtime = Builder::new_current_thread().enable_all().build().unwrap(); let local = tokio::task::LocalSet::new(); From 7b4385085609b792f923bb472eedd9607d1499a3 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 16 Jan 2024 16:36:43 +0100 Subject: [PATCH 122/212] save Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 196 +++++++++++++++++++++++++--- pallets/funding/src/instantiator.rs | 2 - 2 files changed, 175 insertions(+), 23 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 6b1a4e67a..3e25e7a46 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -277,6 +277,88 @@ where async_features::create_multiple_projects_at(inst, instantiation_details).1 } +pub fn generate_evaluations(amount: u32) -> Vec> +where + ::Balance: From, +{ + const TARGET_USD: u128 = 107_000u128 * US_DOLLAR; + let amount_per_participant = TARGET_USD / amount as u128; + let mut evaluations = Vec::new(); + for i in 0..amount { + let evaluator_name: String = format!("evaluator_{}", i); + let evaluator = string_account::>(evaluator_name, 0, 0); + evaluations.push(UserToUSDBalance::new(evaluator, (amount_per_participant).into())); + } + evaluations +} + +pub fn generate_bids(amount: u32) -> Vec> +where + ::Price: From, + ::Balance: From, +{ + const TARGET_USD: u128 = 45_000 * US_DOLLAR; + let amount_per_participant = TARGET_USD / amount as u128; + let mut bids = Vec::new(); + for i in 0..amount { + let bidder_name: String = format!("bidder_{}", i); + let bidder = string_account::>(bidder_name, 0, 0); + bids.push(BidParams::new( + bidder, + (amount_per_participant).into(), + 1_u128.into(), + 1u8, + AcceptedFundingAsset::USDT, + )); + } + bids +} + +pub fn generate_community_contributions(amount: u32) -> Vec> +where + ::Price: From, + ::Balance: From, +{ + const TARGET_USD: u128 = 46_000 * US_DOLLAR; + let amount_per_participant = TARGET_USD / amount as u128; + let mut contributions = Vec::new(); + for i in 0..amount { + let contributor_name: String = format!("contributor_{}", i); + let contributor = string_account::>(contributor_name, 0, 0); + contributions.push(ContributionParams::new( + contributor, + (amount_per_participant).into(), + 1u8, + AcceptedFundingAsset::USDT, + )); + } + contributions +} + +pub fn generate_remainder_contributions(amount: u32) -> Vec> +where + ::Price: From, + ::Balance: From, +{ + const TARGET_USD: u128 = 100 * US_DOLLAR; + let amount_per_participant = TARGET_USD / amount as u128; + let mut contributions = Vec::new(); + let mut user_kind = vec!["evaluator", "bidder", "contributor"].into_iter().cycle(); + let mut counters = vec![0, 0, 0]; + for i in 0..amount { + let kind = user_kind.next().unwrap(); + let contributor_name: String = match kind {}; + let contributor = string_account::>(contributor_name, 0, 0); + contributions.push(ContributionParams::new( + contributor, + (amount_per_participant).into(), + 1u8, + AcceptedFundingAsset::USDT, + )); + } + contributions +} + #[benchmarks( where T: Config + frame_system::Config::RuntimeEvent> + pallet_balances::Config>, @@ -294,7 +376,7 @@ mod benchmarks { impl_benchmark_test_suite!(PalletFunding, crate::mock::new_test_ext(), crate::mock::TestRuntime); #[benchmark] - fn create(x: Linear<1, 10>) { + fn create(x: Linear<1, 20>) { // * setup * let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 @@ -332,13 +414,16 @@ mod benchmarks { } #[benchmark] - fn edit_metadata() { + fn edit_metadata(x: Linear<1, 20>) { // * setup * let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + let issuer = account::>("issuer", 0, 0); whitelist_account!(issuer); @@ -361,13 +446,16 @@ mod benchmarks { } #[benchmark] - fn start_evaluation() { + fn start_evaluation(x: Linear<1, 20>) { // * setup * let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + let issuer = account::>("issuer", 0, 0); whitelist_account!(issuer); @@ -398,13 +486,16 @@ mod benchmarks { } #[benchmark] - fn bond_evaluation() { + fn bond_evaluation(x: Linear<1, 20>) { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + let issuer = account::>("issuer", 0, 0); let test_evaluator = account::>("evaluator", 0, 0); whitelist_account!(test_evaluator); @@ -470,13 +561,16 @@ mod benchmarks { } #[benchmark] - fn start_auction() { + fn start_auction(x: Linear<1, 20>) { // * setup * let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + let issuer = account::>("issuer", 0, 0); whitelist_account!(issuer); @@ -512,13 +606,16 @@ mod benchmarks { } #[benchmark] - fn bid() { + fn bid(x: Linear<1, 20>) { // * setup * let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + let issuer = account::>("issuer", 0, 0); let bidder = account::>("bidder", 0, 0); whitelist_account!(bidder); @@ -617,12 +714,27 @@ mod benchmarks { } #[benchmark] - fn contribute() { + // assume for now community contribution + fn contribute( + // Existing projects count + a: Linear<1, 10>, + // Evaluations count + b: Linear<1, 10>, + // Bids count + c: Linear<1, 10>, + // Community contributions count + d: Linear<1, 10>, + // User contributions count + e: Linear<1, 10>, + ) { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + #[cfg(feature = "std")] + let mut inst = populate_with_projects(a, inst); + let issuer = account::>("issuer", 0, 0); let contributor = account::>("contributor", 0, 0); whitelist_account!(contributor); @@ -722,13 +834,16 @@ mod benchmarks { } #[benchmark] - fn evaluation_unbond_for() { + fn evaluation_unbond_for(x: Linear<1, 20>) { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + let issuer = account::>("issuer", 0, 0); let evaluations = default_evaluations::(); let evaluator = evaluations[0].account.clone(); @@ -791,13 +906,16 @@ mod benchmarks { } #[benchmark] - fn evaluation_slash_for() { + fn evaluation_slash_for(x: Linear<1, 20>) { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + let issuer = account::>("issuer", 0, 0); let evaluations = default_evaluations::(); let evaluator = evaluations[0].account.clone(); @@ -874,13 +992,16 @@ mod benchmarks { } #[benchmark] - fn evaluation_reward_payout_for() { + fn evaluation_reward_payout_for(x: Linear<1, 20>) { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + let issuer = account::>("issuer", 0, 0); let evaluations = default_evaluations::(); let evaluator = evaluations[0].account.clone(); @@ -943,13 +1064,16 @@ mod benchmarks { } #[benchmark] - fn bid_ct_mint_for() { + fn bid_ct_mint_for(x: Linear<1, 20>) { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + let issuer = account::>("issuer", 0, 0); let bids = default_bids::(); let bidder = bids[0].bidder.clone(); @@ -993,13 +1117,16 @@ mod benchmarks { } #[benchmark] - fn contribution_ct_mint_for() { + fn contribution_ct_mint_for(x: Linear<1, 20>) { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + let issuer = account::>("issuer", 0, 0); let contributions = default_community_contributions::(); let contributor = contributions[0].contributor.clone(); @@ -1054,13 +1181,16 @@ mod benchmarks { } #[benchmark] - fn start_bid_vesting_schedule_for() { + fn start_bid_vesting_schedule_for(x: Linear<1, 20>) { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + let issuer = account::>("issuer", 0, 0); let bids = default_bids::(); let bidder = bids[0].bidder.clone(); @@ -1109,13 +1239,16 @@ mod benchmarks { } #[benchmark] - fn start_contribution_vesting_schedule_for() { + fn start_contribution_vesting_schedule_for(x: Linear<1, 20>) { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + let issuer = account::>("issuer", 0, 0); let contributions = default_community_contributions::(); let contributor = contributions[0].contributor.clone(); @@ -1171,13 +1304,16 @@ mod benchmarks { } #[benchmark] - fn payout_bid_funds_for() { + fn payout_bid_funds_for(x: Linear<1, 20>) { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + let issuer = account::>("issuer", 0, 0); let bids = default_bids::(); let bidder = bids[0].bidder.clone(); @@ -1224,13 +1360,16 @@ mod benchmarks { } #[benchmark] - fn payout_contribution_funds_for() { + fn payout_contribution_funds_for(x: Linear<1, 20>) { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + let issuer = account::>("issuer", 0, 0); let contributions = default_community_contributions::(); let contributor = contributions[0].contributor.clone(); @@ -1289,13 +1428,16 @@ mod benchmarks { } #[benchmark] - fn decide_project_outcome() { + fn decide_project_outcome(x: Linear<1, 20>) { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + let issuer = account::>("issuer", 0, 0); let evaluations = default_evaluations::(); let evaluator = evaluations[0].account.clone(); @@ -1343,13 +1485,16 @@ mod benchmarks { } #[benchmark] - fn release_bid_funds_for() { + fn release_bid_funds_for(x: Linear<1, 20>) { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + let issuer = account::>("issuer", 0, 0); let evaluations = default_evaluations::(); @@ -1414,13 +1559,16 @@ mod benchmarks { } #[benchmark] - fn release_contribution_funds_for() { + fn release_contribution_funds_for(x: Linear<1, 20>) { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + let issuer = account::>("issuer", 0, 0); let evaluations = default_evaluations::(); @@ -1492,13 +1640,16 @@ mod benchmarks { } #[benchmark] - fn bid_unbond_for() { + fn bid_unbond_for(x: Linear<1, 20>) { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + let issuer = account::>("issuer", 0, 0); let evaluations = default_evaluations::(); @@ -1564,13 +1715,16 @@ mod benchmarks { } #[benchmark] - fn contribution_unbond_for() { + fn contribution_unbond_for(x: Linear<1, 20>) { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + let issuer = account::>("issuer", 0, 0); let evaluations = default_evaluations::(); diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 65870c884..549dba012 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -1495,8 +1495,6 @@ pub mod async_features { let asset_account_deposit = inst.execute(|| ::ContributionTokenCurrency::deposit_required(One::one())); let ed = Instantiator::::get_ed(); - dbg!(asset_account_deposit); - dbg!(ed); let now = inst.current_block(); // One ED for the issuer, one for the escrow account inst.mint_plmc_to(vec![UserToPLMCBalance::new( From aed27012ad709d7351cb63a677573af96660856b Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 16 Jan 2024 17:30:07 +0100 Subject: [PATCH 123/212] save Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 3e25e7a46..374283a67 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -718,14 +718,14 @@ mod benchmarks { fn contribute( // Existing projects count a: Linear<1, 10>, - // Evaluations count - b: Linear<1, 10>, - // Bids count - c: Linear<1, 10>, - // Community contributions count - d: Linear<1, 10>, - // User contributions count - e: Linear<1, 10>, + // // Evaluations count + // b: Linear<1, 10>, + // // Bids count + // c: Linear<1, 10>, + // // Community contributions count + // d: Linear<1, 10>, + // // User contributions count + // e: Linear<1, 10>, ) { // setup let mut inst = BenchInstantiator::::new(None); From c38d54687c47ddaee660bb31554d5e4b79be9da0 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 17 Jan 2024 18:03:05 +0100 Subject: [PATCH 124/212] rename start_evaluation fn Signed-off-by: Juan Ignacio Rios From 0a7a40837f2739e1ff97136145aa2fdacaf854fa Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 17 Jan 2024 18:08:39 +0100 Subject: [PATCH 125/212] remove unnecessary parameters from `create` and `edit_metadata` Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 56 +++++++++++++---------------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 374283a67..7b7a3b884 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -335,29 +335,29 @@ where contributions } -pub fn generate_remainder_contributions(amount: u32) -> Vec> -where - ::Price: From, - ::Balance: From, -{ - const TARGET_USD: u128 = 100 * US_DOLLAR; - let amount_per_participant = TARGET_USD / amount as u128; - let mut contributions = Vec::new(); - let mut user_kind = vec!["evaluator", "bidder", "contributor"].into_iter().cycle(); - let mut counters = vec![0, 0, 0]; - for i in 0..amount { - let kind = user_kind.next().unwrap(); - let contributor_name: String = match kind {}; - let contributor = string_account::>(contributor_name, 0, 0); - contributions.push(ContributionParams::new( - contributor, - (amount_per_participant).into(), - 1u8, - AcceptedFundingAsset::USDT, - )); - } - contributions -} +// pub fn generate_remainder_contributions(amount: u32) -> Vec> +// where +// ::Price: From, +// ::Balance: From, +// { +// const TARGET_USD: u128 = 100 * US_DOLLAR; +// let amount_per_participant = TARGET_USD / amount as u128; +// let mut contributions = Vec::new(); +// let mut user_kind = vec!["evaluator", "bidder", "contributor"].into_iter().cycle(); +// let mut counters = vec![0, 0, 0]; +// for i in 0..amount { +// let kind = user_kind.next().unwrap(); +// let contributor_name: String = match kind {}; +// let contributor = string_account::>(contributor_name, 0, 0); +// contributions.push(ContributionParams::new( +// contributor, +// (amount_per_participant).into(), +// 1u8, +// AcceptedFundingAsset::USDT, +// )); +// } +// contributions +// } #[benchmarks( where @@ -376,15 +376,12 @@ mod benchmarks { impl_benchmark_test_suite!(PalletFunding, crate::mock::new_test_ext(), crate::mock::TestRuntime); #[benchmark] - fn create(x: Linear<1, 20>) { + fn create() { // * setup * let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - let projects_details_count = ProjectsDetails::::iter().count(); let ed = BenchInstantiator::::get_ed(); @@ -414,16 +411,13 @@ mod benchmarks { } #[benchmark] - fn edit_metadata(x: Linear<1, 20>) { + fn edit_metadata() { // * setup * let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - let issuer = account::>("issuer", 0, 0); whitelist_account!(issuer); From 43b6fccbd552835359f2a1bd2b35b7179cfe0b13 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 17 Jan 2024 18:26:43 +0100 Subject: [PATCH 126/212] fix testnet pallet config Signed-off-by: Juan Ignacio Rios --- runtimes/testnet/src/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index b4cdae971..21ca772a3 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -604,9 +604,7 @@ parameter_types! { pub const MinVestedTransfer: Balance = PLMC; pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); - #[cfg(feature = "runtime-benchmarks")] - pub BenchmarkReason: RuntimeHoldReason = RuntimeHoldReason::PolimecFunding(pallet_funding::HoldReason::Participation(0)); -} +fi} #[cfg(feature = "runtime-benchmarks")] parameter_types! { From d5c691ce8f9bf9ca0a6edd0bf6f9471c05fcd26e Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 17 Jan 2024 18:30:47 +0100 Subject: [PATCH 127/212] changed add_to_update_store Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/functions.rs | 12 ++++++++---- pallets/funding/src/lib.rs | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 638144f92..8a9078c88 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -2335,14 +2335,18 @@ impl Pallet { } /// Adds a project to the ProjectsToUpdate storage, so it can be updated at some later point in time. - pub fn add_to_update_store(block_number: BlockNumberFor, store: (&ProjectId, UpdateType)) { + pub fn add_to_update_store(block_number: BlockNumberFor, store: (&ProjectId, UpdateType)) -> DispatchResult { // Try to get the project into the earliest possible block to update. // There is a limit for how many projects can update each block, so we need to make sure we don't exceed that limit let mut block_number = block_number; - while ProjectsToUpdate::::try_append(block_number, store.clone()).is_err() { - // TODO: Should we end the loop if we iterated over too many blocks? - block_number += 1u32.into(); + for _ in T::MaxProjectToUpdateInsertionAttempts::get() { + if ProjectsToUpdate::::try_append(block_number, store.clone()).is_err() { + block_number += 1u32.into(); + } else { + return Ok(()) + } } + return Err(Error::::TooManyInsertionAttempts.into()) } pub fn remove_from_update_store(project_id: &ProjectId) -> DispatchResult { diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index d5032a71d..2901e94a3 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -436,6 +436,8 @@ pub mod pallet { type RequiredMaxCapacity: Get; /// max_message_size config required for the channel from polimec to the project type RequiredMaxMessageSize: Get; + /// max iterations for trying to insert a project into the projects_to_update storage + type MaxProjectToUpdateInsertionAttempts: Get; } #[pallet::storage] @@ -928,6 +930,8 @@ pub mod pallet { NoFutureDepositHeld, /// The issuer doesn't have enough funds (ExistentialDeposit), to create the escrow account NotEnoughFundsForEscrowCreation, + /// Too many attempts to insert project in to ProjectsToUpdate storage + TooManyInsertionAttempts, } #[pallet::call] From 31dee573e5a1a0ca660d7b492905ae885f1debd2 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 17 Jan 2024 19:01:11 +0100 Subject: [PATCH 128/212] check tests pass, add new draft tests Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/functions.rs | 28 ++++++++++++++-------------- pallets/funding/src/mock.rs | 6 +++++- pallets/funding/src/tests.rs | 18 +++++++++++++++--- runtimes/testnet/src/lib.rs | 3 ++- 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 8a9078c88..4e83190eb 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -186,7 +186,7 @@ impl Pallet { // * Update storage * ProjectsDetails::::insert(project_id, project_details); - Self::add_to_update_store(evaluation_end_block + 1u32.into(), (&project_id, UpdateType::EvaluationEnd)); + Self::add_to_update_store(evaluation_end_block + 1u32.into(), (&project_id, UpdateType::EvaluationEnd))?; // * Emit events * Self::deposit_event(Event::EvaluationStarted { project_id }); @@ -268,7 +268,7 @@ impl Pallet { Self::add_to_update_store( auction_initialize_period_end_block + 1u32.into(), (&project_id, UpdateType::EnglishAuctionStart), - ); + )?; // * Emit events * Self::deposit_event(Event::AuctionInitializePeriod { @@ -357,7 +357,7 @@ impl Pallet { Self::remove_from_update_store(&project_id)?; } // Schedule for automatic transition to candle auction round - Self::add_to_update_store(english_end_block + 1u32.into(), (&project_id, UpdateType::CandleAuctionStart)); + Self::add_to_update_store(english_end_block + 1u32.into(), (&project_id, UpdateType::CandleAuctionStart))?; // * Emit events * Self::deposit_event(Event::EnglishAuctionStarted { project_id, when: now }); @@ -411,7 +411,7 @@ impl Pallet { project_details.status = ProjectStatus::AuctionRound(AuctionPhase::Candle); ProjectsDetails::::insert(project_id, project_details); // Schedule for automatic check by on_initialize. Success depending on enough funding reached - Self::add_to_update_store(candle_end_block + 1u32.into(), (&project_id, UpdateType::CommunityFundingStart)); + Self::add_to_update_store(candle_end_block + 1u32.into(), (&project_id, UpdateType::CommunityFundingStart))?; // * Emit events * Self::deposit_event(Event::CandleAuctionStarted { project_id, when: now }); @@ -474,7 +474,7 @@ impl Pallet { Self::add_to_update_store( >::block_number() + 1u32.into(), (&project_id, UpdateType::FundingEnd), - ); + )?; // * Emit events * Self::deposit_event(Event::AuctionFailed { project_id }); @@ -494,7 +494,7 @@ impl Pallet { Self::add_to_update_store( community_end_block + 1u32.into(), (&project_id, UpdateType::RemainderFundingStart), - ); + )?; // * Emit events * Self::deposit_event(Event::CommunityFundingStarted { project_id }); @@ -548,7 +548,7 @@ impl Pallet { project_details.status = ProjectStatus::RemainderRound; ProjectsDetails::::insert(project_id, project_details); // Schedule for automatic transition by `on_initialize` - Self::add_to_update_store(remainder_end_block + 1u32.into(), (&project_id, UpdateType::FundingEnd)); + Self::add_to_update_store(remainder_end_block + 1u32.into(), (&project_id, UpdateType::FundingEnd))?; // * Emit events * Self::deposit_event(Event::RemainderFundingStarted { project_id }); @@ -624,7 +624,7 @@ impl Pallet { Self::add_to_update_store( now + T::ManualAcceptanceDuration::get() + 1u32.into(), (&project_id, UpdateType::ProjectDecision(FundingOutcomeDecision::AcceptFunding)), - ); + )?; ProjectsDetails::::insert(project_id, project_details); Ok(()) } else if funding_ratio < Perquintill::from_percent(90u64) { @@ -633,7 +633,7 @@ impl Pallet { Self::add_to_update_store( now + T::ManualAcceptanceDuration::get() + 1u32.into(), (&project_id, UpdateType::ProjectDecision(FundingOutcomeDecision::AcceptFunding)), - ); + )?; ProjectsDetails::::insert(project_id, project_details); Ok(()) } else { @@ -1162,7 +1162,7 @@ impl Pallet { // If no CTs remain, end the funding phase if remaining_cts_after_purchase.is_zero() { Self::remove_from_update_store(&project_id)?; - Self::add_to_update_store(now + 1u32.into(), (&project_id, UpdateType::FundingEnd)); + Self::add_to_update_store(now + 1u32.into(), (&project_id, UpdateType::FundingEnd))?; } // * Emit events * @@ -1215,7 +1215,7 @@ impl Pallet { // * Update storage * Self::remove_from_update_store(&project_id)?; - Self::add_to_update_store(now + 1u32.into(), (&project_id, UpdateType::ProjectDecision(decision))); + Self::add_to_update_store(now + 1u32.into(), (&project_id, UpdateType::ProjectDecision(decision)))?; Self::deposit_event(Event::ProjectOutcomeDecided { project_id, decision }); @@ -2339,7 +2339,7 @@ impl Pallet { // Try to get the project into the earliest possible block to update. // There is a limit for how many projects can update each block, so we need to make sure we don't exceed that limit let mut block_number = block_number; - for _ in T::MaxProjectToUpdateInsertionAttempts::get() { + for _ in 0..T::MaxProjectToUpdateInsertionAttempts::get() { if ProjectsToUpdate::::try_append(block_number, store.clone()).is_err() { block_number += 1u32.into(); } else { @@ -2828,7 +2828,7 @@ impl Pallet { project_details.status = ProjectStatus::FundingSuccessful; ProjectsDetails::::insert(project_id, project_details); - Self::add_to_update_store(now + settlement_delta, (&project_id, UpdateType::StartSettlement)); + Self::add_to_update_store(now + settlement_delta, (&project_id, UpdateType::StartSettlement))?; Self::deposit_event(Event::FundingEnded { project_id, outcome: FundingOutcome::Success(reason) }); @@ -2845,7 +2845,7 @@ impl Pallet { project_details.status = ProjectStatus::FundingFailed; ProjectsDetails::::insert(project_id, project_details); - Self::add_to_update_store(now + settlement_delta, (&project_id, UpdateType::StartSettlement)); + Self::add_to_update_store(now + settlement_delta, (&project_id, UpdateType::StartSettlement))?; Self::deposit_event(Event::FundingEnded { project_id, outcome: FundingOutcome::Failure(reason) }); Ok(()) } diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index bd6cc013c..edaf095db 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -287,7 +287,10 @@ parameter_types! { pub PolimecReceiverInfo: xcm::v3::PalletInfo = xcm::v3::PalletInfo::new( 51, "PolimecReceiver".into(), "polimec_receiver".into(), 0, 1, 0 ).unwrap(); - #[cfg(feature = "runtime-benchmarks")] +} + +#[cfg(feature = "runtime-benchmarks")] +parameter_types! { pub BenchmarkReason: RuntimeHoldReason = RuntimeHoldReason::PolimecFunding(crate::HoldReason::Participation(0)); } impl pallet_linear_release::Config for TestRuntime { @@ -353,6 +356,7 @@ impl Config for TestRuntime { type MaxContributionsPerUser = ConstU32<4>; type MaxEvaluationsPerUser = ConstU32<4>; type MaxMessageSizeThresholds = MaxMessageSizeThresholds; + type MaxProjectToUpdateInsertionAttempts = ConstU32<100>; type MaxProjectsToUpdatePerBlock = ConstU32<100>; type Multiplier = Multiplier; type NativeCurrency = Balances; diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index c28de0d6a..74cbc0837 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -5822,9 +5822,9 @@ mod misc_features { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let now = inst.current_block(); inst.execute(|| { - PolimecFunding::add_to_update_store(now + 10u64, (&42u32, CommunityFundingStart)); - PolimecFunding::add_to_update_store(now + 20u64, (&69u32, RemainderFundingStart)); - PolimecFunding::add_to_update_store(now + 5u64, (&404u32, RemainderFundingStart)); + assert_ok!(PolimecFunding::add_to_update_store(now + 10u64, (&42u32, CommunityFundingStart))); + assert_ok!(PolimecFunding::add_to_update_store(now + 20u64, (&69u32, RemainderFundingStart))); + assert_ok!(PolimecFunding::add_to_update_store(now + 5u64, (&404u32, RemainderFundingStart))); }); inst.advance_time(2u64).unwrap(); inst.execute(|| { @@ -6246,3 +6246,15 @@ mod async_tests { assert_eq!(inst.get_project_details(0).status, ProjectStatus::FundingSuccessful); } } + +mod draft_tests { + #[test] + fn transition_failed_too_many_insertion_tries() { + todo!() + } + + #[test] + fn transition_can_happen_after_too_many_insertions_error() { + todo!() + } +} diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 21ca772a3..c6bbac301 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -575,6 +575,7 @@ impl pallet_funding::Config for Runtime { type MaxContributionsPerUser = ConstU32<256>; type MaxEvaluationsPerUser = ConstU32<256>; type MaxMessageSizeThresholds = MaxMessageSizeThresholds; + type MaxProjectToUpdateInsertionAttempts = ConstU32<100>; type MaxProjectsToUpdatePerBlock = ConstU32<100>; type Multiplier = pallet_funding::types::Multiplier; type NativeCurrency = Balances; @@ -604,7 +605,7 @@ parameter_types! { pub const MinVestedTransfer: Balance = PLMC; pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); -fi} +} #[cfg(feature = "runtime-benchmarks")] parameter_types! { From 8f959a63225416eb4a8d75a91662ef6ee2e9a3a2 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 19 Jan 2024 11:28:54 +0100 Subject: [PATCH 129/212] add_to_update_store benchmark in start_evaluation Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 132 +++++++++++++++------------- pallets/funding/src/functions.rs | 13 +-- pallets/funding/src/instantiator.rs | 2 +- pallets/funding/src/lib.rs | 4 +- pallets/funding/src/mock.rs | 2 +- runtimes/testnet/src/lib.rs | 2 +- 6 files changed, 84 insertions(+), 71 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 7b7a3b884..a0278a4ea 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -277,63 +277,63 @@ where async_features::create_multiple_projects_at(inst, instantiation_details).1 } -pub fn generate_evaluations(amount: u32) -> Vec> -where - ::Balance: From, -{ - const TARGET_USD: u128 = 107_000u128 * US_DOLLAR; - let amount_per_participant = TARGET_USD / amount as u128; - let mut evaluations = Vec::new(); - for i in 0..amount { - let evaluator_name: String = format!("evaluator_{}", i); - let evaluator = string_account::>(evaluator_name, 0, 0); - evaluations.push(UserToUSDBalance::new(evaluator, (amount_per_participant).into())); - } - evaluations -} - -pub fn generate_bids(amount: u32) -> Vec> -where - ::Price: From, - ::Balance: From, -{ - const TARGET_USD: u128 = 45_000 * US_DOLLAR; - let amount_per_participant = TARGET_USD / amount as u128; - let mut bids = Vec::new(); - for i in 0..amount { - let bidder_name: String = format!("bidder_{}", i); - let bidder = string_account::>(bidder_name, 0, 0); - bids.push(BidParams::new( - bidder, - (amount_per_participant).into(), - 1_u128.into(), - 1u8, - AcceptedFundingAsset::USDT, - )); - } - bids -} - -pub fn generate_community_contributions(amount: u32) -> Vec> -where - ::Price: From, - ::Balance: From, -{ - const TARGET_USD: u128 = 46_000 * US_DOLLAR; - let amount_per_participant = TARGET_USD / amount as u128; - let mut contributions = Vec::new(); - for i in 0..amount { - let contributor_name: String = format!("contributor_{}", i); - let contributor = string_account::>(contributor_name, 0, 0); - contributions.push(ContributionParams::new( - contributor, - (amount_per_participant).into(), - 1u8, - AcceptedFundingAsset::USDT, - )); - } - contributions -} +// pub fn generate_evaluations(amount: u32) -> Vec> +// where +// ::Balance: From, +// { +// const TARGET_USD: u128 = 107_000u128 * US_DOLLAR; +// let amount_per_participant = TARGET_USD / amount as u128; +// let mut evaluations = Vec::new(); +// for i in 0..amount { +// let evaluator_name: String = format!("evaluator_{}", i); +// let evaluator = string_account::>(evaluator_name, 0, 0); +// evaluations.push(UserToUSDBalance::new(evaluator, (amount_per_participant).into())); +// } +// evaluations +// } +// +// pub fn generate_bids(amount: u32) -> Vec> +// where +// ::Price: From, +// ::Balance: From, +// { +// const TARGET_USD: u128 = 45_000 * US_DOLLAR; +// let amount_per_participant = TARGET_USD / amount as u128; +// let mut bids = Vec::new(); +// for i in 0..amount { +// let bidder_name: String = format!("bidder_{}", i); +// let bidder = string_account::>(bidder_name, 0, 0); +// bids.push(BidParams::new( +// bidder, +// (amount_per_participant).into(), +// 1_u128.into(), +// 1u8, +// AcceptedFundingAsset::USDT, +// )); +// } +// bids +// } +// +// pub fn generate_community_contributions(amount: u32) -> Vec> +// where +// ::Price: From, +// ::Balance: From, +// { +// const TARGET_USD: u128 = 46_000 * US_DOLLAR; +// let amount_per_participant = TARGET_USD / amount as u128; +// let mut contributions = Vec::new(); +// for i in 0..amount { +// let contributor_name: String = format!("contributor_{}", i); +// let contributor = string_account::>(contributor_name, 0, 0); +// contributions.push(ContributionParams::new( +// contributor, +// (amount_per_participant).into(), +// 1u8, +// AcceptedFundingAsset::USDT, +// )); +// } +// contributions +// } // pub fn generate_remainder_contributions(amount: u32) -> Vec> // where @@ -440,22 +440,32 @@ mod benchmarks { } #[benchmark] - fn start_evaluation(x: Linear<1, 20>) { + fn start_evaluation( + // insertion attempts in add_to_update_store. + x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() }>, + ) { // * setup * let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - let issuer = account::>("issuer", 0, 0); whitelist_account!(issuer); let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); let project_id = inst.create_new_project(project_metadata, issuer.clone()); + let mut block_number: BlockNumberFor = 1u32.into(); + + // fill the `ProjectsToUpdate` vectors from @ block_number to @ block_number+x, to benchmark all the failed insertion attempts + for _ in 0..x { + while ProjectsToUpdate::::try_append(block_number, (&69u32, UpdateType::EvaluationEnd)).is_ok() { + continue + } + block_number += 1u32.into(); + } + #[extrinsic_call] start_evaluation(RawOrigin::Signed(issuer), project_id); diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 4e83190eb..b5098cb5b 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -71,7 +71,7 @@ impl Pallet { /// /// # Next step /// The issuer will call an extrinsic to start the evaluation round of the project. - /// [`do_evaluation_start`](Self::do_evaluation_start) will be executed. + /// [`do_start_evaluation`](Self::do_start_evaluation) will be executed. pub fn do_create(issuer: &AccountIdOf, initial_metadata: ProjectMetadataOf) -> DispatchResult { // * Get variables * let project_id = Self::next_project_id(); @@ -165,7 +165,7 @@ impl Pallet { /// # Next step /// Users will pond PLMC for this project, and when the time comes, the project will be transitioned /// to the next round by `on_initialize` using [`do_evaluation_end`](Self::do_evaluation_end) - pub fn do_evaluation_start(caller: AccountIdOf, project_id: ProjectId) -> DispatchResult { + pub fn do_start_evaluation(caller: AccountIdOf, project_id: ProjectId) -> DispatchResult { // * Get variables * let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; @@ -2335,15 +2335,18 @@ impl Pallet { } /// Adds a project to the ProjectsToUpdate storage, so it can be updated at some later point in time. - pub fn add_to_update_store(block_number: BlockNumberFor, store: (&ProjectId, UpdateType)) -> DispatchResult { + pub fn add_to_update_store( + block_number: BlockNumberFor, + store: (&ProjectId, UpdateType), + ) -> Result { // Try to get the project into the earliest possible block to update. // There is a limit for how many projects can update each block, so we need to make sure we don't exceed that limit let mut block_number = block_number; - for _ in 0..T::MaxProjectToUpdateInsertionAttempts::get() { + for i in 1..T::MaxProjectsToUpdateInsertionAttempts::get() + 1 { if ProjectsToUpdate::::try_append(block_number, store.clone()).is_err() { block_number += 1u32.into(); } else { - return Ok(()) + return Ok(i) } } return Err(Error::::TooManyInsertionAttempts.into()) diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 549dba012..6a05372dc 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -849,7 +849,7 @@ impl< pub fn start_evaluation(&mut self, project_id: ProjectId, caller: AccountIdOf) -> Result<(), DispatchError> { assert_eq!(self.get_project_details(project_id).status, ProjectStatus::Application); - self.execute(|| crate::Pallet::::do_evaluation_start(caller, project_id))?; + self.execute(|| crate::Pallet::::do_start_evaluation(caller, project_id))?; assert_eq!(self.get_project_details(project_id).status, ProjectStatus::EvaluationRound); Ok(()) diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 2901e94a3..dac080f27 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -437,7 +437,7 @@ pub mod pallet { /// max_message_size config required for the channel from polimec to the project type RequiredMaxMessageSize: Get; /// max iterations for trying to insert a project into the projects_to_update storage - type MaxProjectToUpdateInsertionAttempts: Get; + type MaxProjectsToUpdateInsertionAttempts: Get; } #[pallet::storage] @@ -962,7 +962,7 @@ pub mod pallet { #[pallet::weight(WeightInfoOf::::start_evaluation())] pub fn start_evaluation(origin: OriginFor, project_id: ProjectId) -> DispatchResult { let issuer = ensure_signed(origin)?; - Self::do_evaluation_start(issuer, project_id) + Self::do_start_evaluation(issuer, project_id) } /// Starts the auction round for a project. From the next block forward, any professional or diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index edaf095db..6a2f4f712 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -356,7 +356,7 @@ impl Config for TestRuntime { type MaxContributionsPerUser = ConstU32<4>; type MaxEvaluationsPerUser = ConstU32<4>; type MaxMessageSizeThresholds = MaxMessageSizeThresholds; - type MaxProjectToUpdateInsertionAttempts = ConstU32<100>; + type MaxProjectsToUpdateInsertionAttempts = ConstU32<100>; type MaxProjectsToUpdatePerBlock = ConstU32<100>; type Multiplier = Multiplier; type NativeCurrency = Balances; diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index c6bbac301..14c232539 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -575,7 +575,7 @@ impl pallet_funding::Config for Runtime { type MaxContributionsPerUser = ConstU32<256>; type MaxEvaluationsPerUser = ConstU32<256>; type MaxMessageSizeThresholds = MaxMessageSizeThresholds; - type MaxProjectToUpdateInsertionAttempts = ConstU32<100>; + type MaxProjectsToUpdateInsertionAttempts = ConstU32<100>; type MaxProjectsToUpdatePerBlock = ConstU32<100>; type Multiplier = pallet_funding::types::Multiplier; type NativeCurrency = Balances; From db3ffb9d94f43533ad24b5c37cbbd93ea18d8493 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 19 Jan 2024 11:33:46 +0100 Subject: [PATCH 130/212] new pr template Signed-off-by: Juan Ignacio Rios --- .../pull_request_template_v1.md} | 0 .../PULL_REQUEST_TEMPLATE/pull_request_template_v2.md | 11 +++++++++++ 2 files changed, 11 insertions(+) rename .github/{workflows/pull_request_template.md => PULL_REQUEST_TEMPLATE/pull_request_template_v1.md} (100%) create mode 100644 .github/PULL_REQUEST_TEMPLATE/pull_request_template_v2.md diff --git a/.github/workflows/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template_v1.md similarity index 100% rename from .github/workflows/pull_request_template.md rename to .github/PULL_REQUEST_TEMPLATE/pull_request_template_v1.md diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template_v2.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template_v2.md new file mode 100644 index 000000000..d2c78e25c --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template_v2.md @@ -0,0 +1,11 @@ +## What? + +## Why? + +## How? + +## Testing? + +## Screenshots (optional) + +## Anything Else? From 3d393849a28b60588db433278f573b257b77b6e9 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 19 Jan 2024 11:36:34 +0100 Subject: [PATCH 131/212] only one pr template Signed-off-by: Juan Ignacio Rios --- ...request_template_v2.md => PULL_REQUEST_TEMPLATE.md} | 0 .../PULL_REQUEST_TEMPLATE/pull_request_template_v1.md | 10 ---------- 2 files changed, 10 deletions(-) rename .github/{PULL_REQUEST_TEMPLATE/pull_request_template_v2.md => PULL_REQUEST_TEMPLATE.md} (100%) delete mode 100644 .github/PULL_REQUEST_TEMPLATE/pull_request_template_v1.md diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template_v2.md b/.github/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from .github/PULL_REQUEST_TEMPLATE/pull_request_template_v2.md rename to .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template_v1.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template_v1.md deleted file mode 100644 index b4e3b3ed0..000000000 --- a/.github/PULL_REQUEST_TEMPLATE/pull_request_template_v1.md +++ /dev/null @@ -1,10 +0,0 @@ -## Describe your changes - -## Changes Made - -## Additional Notes - -## Checklist before requesting a review -- [ ] I have performed a self-review of my code -- [ ] If it is a core feature, I have added thorough tests. -- [ ] If it is a core feature, I have added thorough benchmarks. From 7f1fefbf81aeb6fcc9eae32fc04669996c86fd27 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 19 Jan 2024 16:13:11 +0100 Subject: [PATCH 132/212] new ProjectToUpdate functions that return parameters for weight functions. Benchmark functions broken Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 125 ++++++++++------- pallets/funding/src/functions.rs | 208 +++++++++++++++++++++++----- pallets/funding/src/instantiator.rs | 6 +- pallets/funding/src/lib.rs | 37 ++--- pallets/funding/src/weights.rs | 28 ++-- 5 files changed, 288 insertions(+), 116 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index a0278a4ea..2a2f9b9ce 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -456,8 +456,8 @@ mod benchmarks { let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); let project_id = inst.create_new_project(project_metadata, issuer.clone()); - let mut block_number: BlockNumberFor = 1u32.into(); - + // start_evaluation fn will try to add an automatic transition 1 block after the last evaluation block + let mut block_number: BlockNumberFor = inst.current_block() + T::EvaluationDuration::get() + One::one(); // fill the `ProjectsToUpdate` vectors from @ block_number to @ block_number+x, to benchmark all the failed insertion attempts for _ in 0..x { while ProjectsToUpdate::::try_append(block_number, (&69u32, UpdateType::EvaluationEnd)).is_ok() { @@ -489,6 +489,71 @@ mod benchmarks { frame_system::Pallet::::assert_last_event(Event::EvaluationStarted { project_id }.into()) } + #[benchmark] + // it will also iterate through the `ProjectsToUpdate` vector, to remove the automatic transition scheduled. + fn start_auction_manually( + // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate` + x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() }>, + // Total amount of storage items iterated through in `ProjectsToUpdate` when trying to remove our project in `remove_from_update_store`. + // We assume an upper bound of 10_000 projects at one time in storage waiting to update, and in different blocks. + y: Linear<1, 10_000>, + // The average amount of projects in each update block iterated through in remove_from_update_store when looking for our project + z: Linear<1, { ::MaxProjectsToUpdatePerBlock::get() }>, + ) { + // * setup * + let mut inst = BenchInstantiator::::new(None); + + // real benchmark starts at block 0, and we can't call `events()` at block 0 + inst.advance_time(1u32.into()).unwrap(); + + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + + let issuer = account::>("issuer", 0, 0); + whitelist_account!(issuer); + + let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); + let project_id = inst.create_evaluating_project(project_metadata, issuer.clone()); + + let evaluations = default_evaluations(); + let plmc_for_evaluating = BenchInstantiator::::calculate_evaluation_plmc_spent(evaluations.clone()); + let existential_plmc: Vec> = plmc_for_evaluating.accounts().existential_deposits(); + let ct_account_deposits: Vec> = plmc_for_evaluating.accounts().ct_account_deposits(); + + inst.mint_plmc_to(existential_plmc); + inst.mint_plmc_to(ct_account_deposits); + inst.mint_plmc_to(plmc_for_evaluating); + + inst.advance_time(One::one()).unwrap(); + inst.bond_for_users(project_id, evaluations).expect("All evaluations are accepted"); + + inst.advance_time(::EvaluationDuration::get() + One::one()).unwrap(); + let block_number = frame_system::Pallet::::block_number(); + + // start_evaluation fn will try to add an automatic transition 1 block after the last evaluation block + let mut block_number: BlockNumberFor = + inst.current_block() + T::EvaluationDuration::get() + T::EnglishAuctionDuration::get() + One::one(); + // fill the `ProjectsToUpdate` vectors from @ block_number to @ block_number+x, to benchmark all the failed insertion attempts + for _ in 0..x { + while ProjectsToUpdate::::try_append(block_number, (&69u32, UpdateType::EvaluationEnd)).is_ok() { + continue + } + block_number += 1u32.into(); + } + #[extrinsic_call] + start_auction(RawOrigin::Signed(issuer), project_id); + + // * validity checks * + // Storage + let stored_details = ProjectsDetails::::get(project_id).unwrap(); + assert_eq!(stored_details.status, ProjectStatus::AuctionRound(AuctionPhase::English)); + + // Events + frame_system::Pallet::::assert_last_event( + Event::::EnglishAuctionStarted { project_id, when: block_number.into() }.into(), + ); + } + #[benchmark] fn bond_evaluation(x: Linear<1, 20>) { // setup @@ -564,51 +629,6 @@ mod benchmarks { ); } - #[benchmark] - fn start_auction(x: Linear<1, 20>) { - // * setup * - let mut inst = BenchInstantiator::::new(None); - - // real benchmark starts at block 0, and we can't call `events()` at block 0 - inst.advance_time(1u32.into()).unwrap(); - - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - - let issuer = account::>("issuer", 0, 0); - whitelist_account!(issuer); - - let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); - let project_id = inst.create_evaluating_project(project_metadata, issuer.clone()); - - let evaluations = default_evaluations(); - let plmc_for_evaluating = BenchInstantiator::::calculate_evaluation_plmc_spent(evaluations.clone()); - let existential_plmc: Vec> = plmc_for_evaluating.accounts().existential_deposits(); - let ct_account_deposits: Vec> = plmc_for_evaluating.accounts().ct_account_deposits(); - - inst.mint_plmc_to(existential_plmc); - inst.mint_plmc_to(ct_account_deposits); - inst.mint_plmc_to(plmc_for_evaluating); - - inst.advance_time(One::one()).unwrap(); - inst.bond_for_users(project_id, evaluations).expect("All evaluations are accepted"); - - inst.advance_time(::EvaluationDuration::get() + One::one()).unwrap(); - let block_number = frame_system::Pallet::::block_number(); - #[extrinsic_call] - start_auction(RawOrigin::Signed(issuer), project_id); - - // * validity checks * - // Storage - let stored_details = ProjectsDetails::::get(project_id).unwrap(); - assert_eq!(stored_details.status, ProjectStatus::AuctionRound(AuctionPhase::English)); - - // Events - frame_system::Pallet::::assert_last_event( - Event::::EnglishAuctionStarted { project_id, when: block_number.into() }.into(), - ); - } - #[benchmark] fn bid(x: Linear<1, 20>) { // * setup * @@ -1884,12 +1904,19 @@ mod benchmarks { } #[test] - fn bench_start_auction() { + fn bench_start_auction_manually() { new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_start_auction()); + assert_ok!(PalletFunding::::test_start_auction_manually()); }); } + // #[test] + // fn bench_start_auction_automatically() { + // new_test_ext().execute_with(|| { + // assert_ok!(PalletFunding::::test_start_auction_automatically()); + // }); + // } + #[test] fn bench_bid() { new_test_ext().execute_with(|| { diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index b5098cb5b..24d94758d 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -18,6 +18,8 @@ //! Functions for the Funding pallet. +use frame_support::dispatch::{DispatchErrorWithPostInfo, DispatchResultWithPostInfo, PostDispatchInfo}; + use frame_support::{ dispatch::DispatchResult, ensure, @@ -45,6 +47,7 @@ use polimec_common::ReleaseSchedule; use crate::traits::{BondingRequirementCalculation, ProvideStatemintPrice, VestingDurationCalculation}; use frame_support::traits::fungible::Mutate; use polimec_common::migration_types::{MigrationInfo, MigrationOrigin, Migrations, ParticipationType}; +use sp_runtime::DispatchResultWithInfo; use super::*; const POLIMEC_PARA_ID: u32 = 3344u32; @@ -165,7 +168,7 @@ impl Pallet { /// # Next step /// Users will pond PLMC for this project, and when the time comes, the project will be transitioned /// to the next round by `on_initialize` using [`do_evaluation_end`](Self::do_evaluation_end) - pub fn do_start_evaluation(caller: AccountIdOf, project_id: ProjectId) -> DispatchResult { + pub fn do_start_evaluation(caller: AccountIdOf, project_id: ProjectId) -> DispatchResultWithPostInfo { // * Get variables * let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; @@ -186,12 +189,28 @@ impl Pallet { // * Update storage * ProjectsDetails::::insert(project_id, project_details); - Self::add_to_update_store(evaluation_end_block + 1u32.into(), (&project_id, UpdateType::EvaluationEnd))?; + let actual_insertion_attempts = match Self::add_to_update_store( + evaluation_end_block + 1u32.into(), + (&project_id, UpdateType::EvaluationEnd), + ) { + Ok(insertions) => insertions, + Err(insertions) => + return Err(DispatchErrorWithPostInfo { + post_info: PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::start_evaluation(insertions)), + pays_fee: Pays::Yes, + }, + error: Error::::TooManyInsertionAttempts.into(), + }), + }; // * Emit events * Self::deposit_event(Event::EvaluationStarted { project_id }); - Ok(()) + Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::start_evaluation(actual_insertion_attempts)), + pays_fee: Pays::Yes, + }) } /// Called automatically by on_initialize. @@ -265,10 +284,14 @@ impl Pallet { .update(Some(auction_initialize_period_start_block), Some(auction_initialize_period_end_block)); project_details.status = ProjectStatus::AuctionInitializePeriod; ProjectsDetails::::insert(project_id, project_details); - Self::add_to_update_store( + // TODO: return real weights + let insertions_attempts = match Self::add_to_update_store( auction_initialize_period_end_block + 1u32.into(), (&project_id, UpdateType::EnglishAuctionStart), - )?; + ) { + Ok(insertions) => insertions, + Err(insertions) => return Err(Error::::TooManyInsertionAttempts.into()), + }; // * Emit events * Self::deposit_event(Event::AuctionInitializePeriod { @@ -313,7 +336,7 @@ impl Pallet { /// Professional and Institutional users set bids for the project using the [`bid`](Self::bid) extrinsic. /// Later on, `on_initialize` transitions the project into the candle auction round, by calling /// [`do_candle_auction`](Self::do_candle_auction). - pub fn do_english_auction(caller: AccountIdOf, project_id: ProjectId) -> DispatchResult { + pub fn do_english_auction(caller: AccountIdOf, project_id: ProjectId) -> DispatchResultWithPostInfo { // * Get variables * let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let now = >::block_number(); @@ -353,16 +376,64 @@ impl Pallet { // If this function was called inside the period, then it was called by the extrinsic and we need to // remove the scheduled automatic transition + let mut remove_attempts: u32 = 0u32; + let mut average_vec_passes: u32 = 0u32; + let mut insertion_attempts: u32 = 0u32; if now <= auction_initialize_period_end_block { - Self::remove_from_update_store(&project_id)?; + match Self::remove_from_update_store(&project_id) { + Ok(iterations) => { + remove_attempts = iterations.0; + average_vec_passes = iterations.1 + }, + Err(iterations) => + return Err(DispatchErrorWithPostInfo { + post_info: PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::start_auction_manually( + 0u32, + iterations.0, + iterations.1, + )), + pays_fee: Pays::Yes, + }, + error: Error::::ProjectNotInUpdateStore.into(), + }), + } } // Schedule for automatic transition to candle auction round - Self::add_to_update_store(english_end_block + 1u32.into(), (&project_id, UpdateType::CandleAuctionStart))?; + match Self::add_to_update_store(english_end_block + 1u32.into(), (&project_id, UpdateType::CandleAuctionStart)) + { + Ok(iterations) => { + insertion_attempts = iterations; + }, + Err(insertion_attempts) => + return Err(DispatchErrorWithPostInfo { + post_info: PostDispatchInfo { + actual_weight: if remove_attempts == 0u32 { + Some(WeightInfoOf::::start_auction_automatically(insertion_attempts)) + } else { + Some(WeightInfoOf::::start_auction_manually( + insertion_attempts, + remove_attempts, + average_vec_passes, + )) + }, + pays_fee: Pays::Yes, + }, + error: Error::::ProjectNotInUpdateStore.into(), + }), + }; // * Emit events * Self::deposit_event(Event::EnglishAuctionStarted { project_id, when: now }); - Ok(()) + Ok(PostDispatchInfo { + actual_weight: if remove_attempts == 0u32 { + Some(WeightInfoOf::::start_auction_automatically(insertion_attempts)) + } else { + Some(WeightInfoOf::::start_auction_manually(insertion_attempts, remove_attempts, average_vec_passes)) + }, + pays_fee: Pays::Yes, + }) } /// Called automatically by on_initialize @@ -411,7 +482,14 @@ impl Pallet { project_details.status = ProjectStatus::AuctionRound(AuctionPhase::Candle); ProjectsDetails::::insert(project_id, project_details); // Schedule for automatic check by on_initialize. Success depending on enough funding reached - Self::add_to_update_store(candle_end_block + 1u32.into(), (&project_id, UpdateType::CommunityFundingStart))?; + // TODO: return real weights + let iterations = match Self::add_to_update_store( + candle_end_block + 1u32.into(), + (&project_id, UpdateType::CommunityFundingStart), + ) { + Ok(iterations) => iterations, + Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + }; // * Emit events * Self::deposit_event(Event::CandleAuctionStarted { project_id, when: now }); @@ -471,10 +549,14 @@ impl Pallet { Err(pallet_error) if pallet_error == Error::::NoBidsFound.into() => { project_details.status = ProjectStatus::FundingFailed; ProjectsDetails::::insert(project_id, project_details); - Self::add_to_update_store( + // TODO: return real weights + let iterations = match Self::add_to_update_store( >::block_number() + 1u32.into(), (&project_id, UpdateType::FundingEnd), - )?; + ) { + Ok(iterations) => iterations, + Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + }; // * Emit events * Self::deposit_event(Event::AuctionFailed { project_id }); @@ -491,10 +573,14 @@ impl Pallet { .update(Some(community_start_block), Some(community_end_block)); project_details.status = ProjectStatus::CommunityRound; ProjectsDetails::::insert(project_id, project_details); - Self::add_to_update_store( + // TODO: return real weights + let iterations = match Self::add_to_update_store( community_end_block + 1u32.into(), (&project_id, UpdateType::RemainderFundingStart), - )?; + ) { + Ok(iterations) => iterations, + Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + }; // * Emit events * Self::deposit_event(Event::CommunityFundingStarted { project_id }); @@ -548,7 +634,12 @@ impl Pallet { project_details.status = ProjectStatus::RemainderRound; ProjectsDetails::::insert(project_id, project_details); // Schedule for automatic transition by `on_initialize` - Self::add_to_update_store(remainder_end_block + 1u32.into(), (&project_id, UpdateType::FundingEnd))?; + // TODO: return real weights + let iterations = + match Self::add_to_update_store(remainder_end_block + 1u32.into(), (&project_id, UpdateType::FundingEnd)) { + Ok(iterations) => iterations, + Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + }; // * Emit events * Self::deposit_event(Event::RemainderFundingStarted { project_id }); @@ -621,19 +712,27 @@ impl Pallet { } else if funding_ratio <= Perquintill::from_percent(75u64) { project_details.evaluation_round_info.evaluators_outcome = EvaluatorsOutcome::Slashed; project_details.status = ProjectStatus::AwaitingProjectDecision; - Self::add_to_update_store( + // TODO: return real weights + let iterations = match Self::add_to_update_store( now + T::ManualAcceptanceDuration::get() + 1u32.into(), (&project_id, UpdateType::ProjectDecision(FundingOutcomeDecision::AcceptFunding)), - )?; + ) { + Ok(iterations) => iterations, + Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + }; ProjectsDetails::::insert(project_id, project_details); Ok(()) } else if funding_ratio < Perquintill::from_percent(90u64) { project_details.evaluation_round_info.evaluators_outcome = EvaluatorsOutcome::Unchanged; project_details.status = ProjectStatus::AwaitingProjectDecision; - Self::add_to_update_store( + // TODO: return real weights + let iterations = match Self::add_to_update_store( now + T::ManualAcceptanceDuration::get() + 1u32.into(), (&project_id, UpdateType::ProjectDecision(FundingOutcomeDecision::AcceptFunding)), - )?; + ) { + Ok(iterations) => iterations, + Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + }; ProjectsDetails::::insert(project_id, project_details); Ok(()) } else { @@ -1161,8 +1260,15 @@ impl Pallet { ProjectsDetails::::insert(project_id, project_details); // If no CTs remain, end the funding phase if remaining_cts_after_purchase.is_zero() { - Self::remove_from_update_store(&project_id)?; - Self::add_to_update_store(now + 1u32.into(), (&project_id, UpdateType::FundingEnd))?; + // TODO: return real weights + let iterations = match Self::remove_from_update_store(&project_id) { + Ok(iterations) => iterations, + Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + }; + let iterations = match Self::add_to_update_store(now + 1u32.into(), (&project_id, UpdateType::FundingEnd)) { + Ok(iterations) => iterations, + Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + }; } // * Emit events * @@ -1214,8 +1320,16 @@ impl Pallet { ensure!(project_details.status == ProjectStatus::AwaitingProjectDecision, Error::::NotAllowed); // * Update storage * - Self::remove_from_update_store(&project_id)?; - Self::add_to_update_store(now + 1u32.into(), (&project_id, UpdateType::ProjectDecision(decision)))?; + // TODO: return real weights + let iterations = match Self::remove_from_update_store(&project_id) { + Ok(iterations) => iterations, + Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + }; + let iterations = + match Self::add_to_update_store(now + 1u32.into(), (&project_id, UpdateType::ProjectDecision(decision))) { + Ok(iterations) => iterations, + Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + }; Self::deposit_event(Event::ProjectOutcomeDecided { project_id, decision }); @@ -2335,10 +2449,7 @@ impl Pallet { } /// Adds a project to the ProjectsToUpdate storage, so it can be updated at some later point in time. - pub fn add_to_update_store( - block_number: BlockNumberFor, - store: (&ProjectId, UpdateType), - ) -> Result { + pub fn add_to_update_store(block_number: BlockNumberFor, store: (&ProjectId, UpdateType)) -> Result { // Try to get the project into the earliest possible block to update. // There is a limit for how many projects can update each block, so we need to make sure we don't exceed that limit let mut block_number = block_number; @@ -2349,22 +2460,43 @@ impl Pallet { return Ok(i) } } - return Err(Error::::TooManyInsertionAttempts.into()) + return Err(T::MaxProjectsToUpdateInsertionAttempts::get()) } - pub fn remove_from_update_store(project_id: &ProjectId) -> DispatchResult { + fn average_u32(numbers: Vec) -> u32 { + if numbers.is_empty() { + return 0 + } + + // Use u64 for the sum to prevent overflow. + let sum: u64 = numbers.iter().map(|&x| x as u64).sum(); + let count = numbers.len() as u64; + + // Perform the division in u64, then cast back to u32. + // This will naturally floor the division result. + sum.saturating_div(count) as u32 + } + + // returns the actual iterations for weight calculation either as an Err type or Ok type so the caller can add that + // to the corresponding weight function. + pub fn remove_from_update_store(project_id: &ProjectId) -> Result<(u32, u32), (u32, u32)> { + // used for extrinsic weight calculation + let mut total_iterations = 0u32; + let mut project_vec_lengths: Vec = Vec::new(); let (block_position, project_index) = ProjectsToUpdate::::iter() .find_map(|(block, project_vec)| { + total_iterations += 1; + project_vec_lengths.push(project_vec.len() as u32); let project_index = project_vec.iter().position(|(id, _update_type)| id == project_id)?; Some((block, project_index)) }) - .ok_or(Error::::ProjectNotInUpdateStore)?; + .ok_or((total_iterations, Self::average_u32(project_vec_lengths.clone())))?; ProjectsToUpdate::::mutate(block_position, |project_vec| { project_vec.remove(project_index); }); - Ok(()) + Ok((total_iterations, Self::average_u32(project_vec_lengths))) } pub fn create_bucket_from_metadata(metadata: &ProjectMetadataOf) -> Result, DispatchError> { @@ -2831,7 +2963,12 @@ impl Pallet { project_details.status = ProjectStatus::FundingSuccessful; ProjectsDetails::::insert(project_id, project_details); - Self::add_to_update_store(now + settlement_delta, (&project_id, UpdateType::StartSettlement))?; + // TODO: add real weights + let iterations = + match Self::add_to_update_store(now + settlement_delta, (&project_id, UpdateType::StartSettlement)) { + Ok(iterations) => iterations, + Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + }; Self::deposit_event(Event::FundingEnded { project_id, outcome: FundingOutcome::Success(reason) }); @@ -2848,7 +2985,12 @@ impl Pallet { project_details.status = ProjectStatus::FundingFailed; ProjectsDetails::::insert(project_id, project_details); - Self::add_to_update_store(now + settlement_delta, (&project_id, UpdateType::StartSettlement))?; + // TODO: add real weights + let iterations = + match Self::add_to_update_store(now + settlement_delta, (&project_id, UpdateType::StartSettlement)) { + Ok(iterations) => iterations, + Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + }; Self::deposit_event(Event::FundingEnded { project_id, outcome: FundingOutcome::Failure(reason) }); Ok(()) } diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 6a05372dc..89daf8ce6 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -849,7 +849,7 @@ impl< pub fn start_evaluation(&mut self, project_id: ProjectId, caller: AccountIdOf) -> Result<(), DispatchError> { assert_eq!(self.get_project_details(project_id).status, ProjectStatus::Application); - self.execute(|| crate::Pallet::::do_start_evaluation(caller, project_id))?; + self.execute(|| crate::Pallet::::do_start_evaluation(caller, project_id).unwrap()); assert_eq!(self.get_project_details(project_id).status, ProjectStatus::EvaluationRound); Ok(()) @@ -888,7 +888,7 @@ impl< assert_eq!(self.get_project_details(project_id).status, ProjectStatus::AuctionInitializePeriod); - self.execute(|| crate::Pallet::::do_english_auction(caller, project_id))?; + self.execute(|| crate::Pallet::::do_english_auction(caller, project_id).unwrap()); assert_eq!(self.get_project_details(project_id).status, ProjectStatus::AuctionRound(AuctionPhase::English)); @@ -1562,7 +1562,7 @@ pub mod async_features { assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AuctionInitializePeriod); - inst.execute(|| crate::Pallet::::do_english_auction(caller, project_id))?; + inst.execute(|| crate::Pallet::::do_english_auction(caller, project_id).unwrap()); assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AuctionRound(AuctionPhase::English)); diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index dac080f27..2cfa36de7 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -243,13 +243,17 @@ pub mod pallet { use super::*; use crate::traits::{BondingRequirementCalculation, ProvideStatemintPrice, VestingDurationCalculation}; use frame_support::{ + dispatch::PostDispatchInfo, pallet_prelude::*, traits::{OnFinalize, OnIdle, OnInitialize}, }; use frame_system::pallet_prelude::*; use local_macros::*; use sp_arithmetic::Percent; - use sp_runtime::traits::{Convert, ConvertBack}; + use sp_runtime::{ + traits::{Convert, ConvertBack}, + DispatchErrorWithPostInfo, + }; #[cfg(any(feature = "runtime-benchmarks", feature = "std"))] use crate::traits::SetPrices; @@ -436,7 +440,7 @@ pub mod pallet { type RequiredMaxCapacity: Get; /// max_message_size config required for the channel from polimec to the project type RequiredMaxMessageSize: Get; - /// max iterations for trying to insert a project into the projects_to_update storage + /// max iterations for trying to insert a project on the projects_to_update storage type MaxProjectsToUpdateInsertionAttempts: Get; } @@ -959,8 +963,8 @@ pub mod pallet { /// Starts the evaluation round of a project. It needs to be called by the project issuer. #[pallet::call_index(2)] - #[pallet::weight(WeightInfoOf::::start_evaluation())] - pub fn start_evaluation(origin: OriginFor, project_id: ProjectId) -> DispatchResult { + #[pallet::weight(WeightInfoOf::::start_evaluation(::MaxProjectsToUpdateInsertionAttempts::get()))] + pub fn start_evaluation(origin: OriginFor, project_id: ProjectId) -> DispatchResultWithPostInfo { let issuer = ensure_signed(origin)?; Self::do_start_evaluation(issuer, project_id) } @@ -969,8 +973,8 @@ pub mod pallet { /// institutional user can set bids for a token_amount/token_price pair. /// Any bids from this point until the candle_auction starts, will be considered as valid. #[pallet::call_index(3)] - #[pallet::weight(WeightInfoOf::::start_auction())] - pub fn start_auction(origin: OriginFor, project_id: ProjectId) -> DispatchResult { + #[pallet::weight(WeightInfoOf::::start_auction_manually(0u32, 0u32, 0u32))] + pub fn start_auction(origin: OriginFor, project_id: ProjectId) -> DispatchResultWithPostInfo { let issuer = ensure_signed(origin)?; Self::do_english_auction(issuer, project_id) } @@ -1245,7 +1249,7 @@ pub mod pallet { match update_type { // EvaluationRound -> AuctionInitializePeriod | EvaluationFailed UpdateType::EvaluationEnd => { - unwrap_result_or_skip!(Self::do_evaluation_end(project_id), project_id); + unwrap_result_or_skip!(Self::do_evaluation_end(project_id), project_id, |e| e); }, // AuctionInitializePeriod -> AuctionRound(AuctionPhase::English) @@ -1253,36 +1257,37 @@ pub mod pallet { UpdateType::EnglishAuctionStart => { unwrap_result_or_skip!( Self::do_english_auction(T::PalletId::get().into_account_truncating(), project_id), - project_id + project_id, + |e: DispatchErrorWithPostInfo| { e.error } ); }, // AuctionRound(AuctionPhase::English) -> AuctionRound(AuctionPhase::Candle) UpdateType::CandleAuctionStart => { - unwrap_result_or_skip!(Self::do_candle_auction(project_id), project_id); + unwrap_result_or_skip!(Self::do_candle_auction(project_id), project_id, |e| e); }, // AuctionRound(AuctionPhase::Candle) -> CommunityRound UpdateType::CommunityFundingStart => { - unwrap_result_or_skip!(Self::do_community_funding(project_id), project_id); + unwrap_result_or_skip!(Self::do_community_funding(project_id), project_id, |e| e); }, // CommunityRound -> RemainderRound UpdateType::RemainderFundingStart => { - unwrap_result_or_skip!(Self::do_remainder_funding(project_id), project_id) + unwrap_result_or_skip!(Self::do_remainder_funding(project_id), project_id, |e| e) }, // CommunityRound || RemainderRound -> FundingEnded UpdateType::FundingEnd => { - unwrap_result_or_skip!(Self::do_end_funding(project_id), project_id) + unwrap_result_or_skip!(Self::do_end_funding(project_id), project_id, |e| e) }, UpdateType::ProjectDecision(decision) => { - unwrap_result_or_skip!(Self::do_project_decision(project_id, decision), project_id) + unwrap_result_or_skip!(Self::do_project_decision(project_id, decision), project_id, |e| e) }, UpdateType::StartSettlement => { - unwrap_result_or_skip!(Self::do_start_settlement(project_id), project_id) + unwrap_result_or_skip!(Self::do_start_settlement(project_id), project_id, |e| e) }, } } @@ -1430,11 +1435,11 @@ pub mod local_macros { /// used to unwrap storage values that can be Err in places where an error cannot be returned, /// but an event should be emitted, and skip to the next iteration of a loop macro_rules! unwrap_result_or_skip { - ($option:expr, $project_id:expr) => { + ($option:expr, $project_id:expr, $error_handler:expr) => { match $option { Ok(val) => val, Err(err) => { - Self::deposit_event(Event::TransitionError { project_id: $project_id, error: err }); + Self::deposit_event(Event::TransitionError { project_id: $project_id, error: $error_handler(err) }); continue }, } diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index ffca8c7e9..6fa2ff015 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -45,6 +45,7 @@ #![allow(unused_imports)] #![allow(missing_docs)] +use sp_arithmetic::traits::Zero; use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use core::marker::PhantomData; @@ -52,8 +53,9 @@ use core::marker::PhantomData; pub trait WeightInfo { fn create() -> Weight; fn edit_metadata() -> Weight; - fn start_evaluation() -> Weight; - fn start_auction() -> Weight; + fn start_evaluation(x: u32) -> Weight; + fn start_auction_manually(x: u32, y: u32, z: u32) -> Weight; + fn start_auction_automatically(x: u32) -> Weight; fn bond_evaluation() -> Weight; fn bid() -> Weight; fn contribute() -> Weight; @@ -114,7 +116,7 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) /// Storage: PolimecFunding ProjectsToUpdate (r:1 w:1) /// Proof Skipped: PolimecFunding ProjectsToUpdate (max_values: None, max_size: None, mode: Measured) - fn start_evaluation() -> Weight { + fn start_evaluation(x: u32) -> Weight { // Proof Size summary in bytes: // Measured: `467` // Estimated: `3932` @@ -123,18 +125,12 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } - /// Storage: PolimecFunding ProjectsDetails (r:1 w:1) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding ProjectsToUpdate (r:3 w:2) - /// Proof Skipped: PolimecFunding ProjectsToUpdate (max_values: None, max_size: None, mode: Measured) - fn start_auction() -> Weight { - // Proof Size summary in bytes: - // Measured: `380` - // Estimated: `8795` - // Minimum execution time: 33_000_000 picoseconds. - Weight::from_parts(37_000_000, 8795) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + fn start_auction_manually(x: u32, y: u32, z: u32) -> Weight { + Zero::zero() + } + + fn start_auction_automatically(x: u32) -> Weight { + Zero::zero() } /// Storage: PolimecFunding ProjectsDetails (r:1 w:1) /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) @@ -433,4 +429,6 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } + + } \ No newline at end of file From 45417be10f142ae1f8ca278e9db680aeefd3ee1f Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 22 Jan 2024 10:43:26 +0100 Subject: [PATCH 133/212] fixed eval start bench Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 2a2f9b9ce..8d8c6dfd7 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -442,7 +442,7 @@ mod benchmarks { #[benchmark] fn start_evaluation( // insertion attempts in add_to_update_store. - x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() }>, + x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, ) { // * setup * let mut inst = BenchInstantiator::::new(None); @@ -493,7 +493,7 @@ mod benchmarks { // it will also iterate through the `ProjectsToUpdate` vector, to remove the automatic transition scheduled. fn start_auction_manually( // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate` - x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() }>, + x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, // Total amount of storage items iterated through in `ProjectsToUpdate` when trying to remove our project in `remove_from_update_store`. // We assume an upper bound of 10_000 projects at one time in storage waiting to update, and in different blocks. y: Linear<1, 10_000>, @@ -528,7 +528,7 @@ mod benchmarks { inst.bond_for_users(project_id, evaluations).expect("All evaluations are accepted"); inst.advance_time(::EvaluationDuration::get() + One::one()).unwrap(); - let block_number = frame_system::Pallet::::block_number(); + let start_block_number = frame_system::Pallet::::block_number(); // start_evaluation fn will try to add an automatic transition 1 block after the last evaluation block let mut block_number: BlockNumberFor = @@ -550,7 +550,7 @@ mod benchmarks { // Events frame_system::Pallet::::assert_last_event( - Event::::EnglishAuctionStarted { project_id, when: block_number.into() }.into(), + Event::::EnglishAuctionStarted { project_id, when: start_block_number.into() }.into(), ); } From 3b1ae08fabb4412e95793402d0f5dc936cff1c9b Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 22 Jan 2024 12:13:22 +0100 Subject: [PATCH 134/212] fix manual auction benchmark Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 8d8c6dfd7..7bd42966b 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -506,9 +506,6 @@ mod benchmarks { // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - let issuer = account::>("issuer", 0, 0); whitelist_account!(issuer); From 285b4edc7ac63937b29c3140216ccafb59fa4123 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 22 Jan 2024 15:42:43 +0100 Subject: [PATCH 135/212] english_start benchmarked Signed-off-by: Juan Ignacio Rios --- Cargo.lock | 861 ++-------------------------- Cargo.toml | 4 +- debug_weight_gen.rs | 78 +++ pallets/funding/src/benchmarking.rs | 53 +- pallets/funding/src/functions.rs | 2 +- 5 files changed, 183 insertions(+), 815 deletions(-) create mode 100644 debug_weight_gen.rs diff --git a/Cargo.lock b/Cargo.lock index b6d794904..924ea35d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -125,12 +125,6 @@ dependencies = [ "libc", ] -[[package]] -name = "anes" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" - [[package]] name = "ansi_term" version = "0.12.1" @@ -278,98 +272,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15832d94c458da98cac0ffa6eca52cc19c2a3c6c951058500a5ae8f01f0fdf56" -[[package]] -name = "asset-hub-polkadot-runtime" -version = "0.9.420" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "assets-common", - "cumulus-pallet-aura-ext", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-session-benchmarking", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "cumulus-primitives-timestamp", - "cumulus-primitives-utility", - "frame-benchmarking", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal 0.4.1", - "log", - "pallet-asset-tx-payment", - "pallet-assets", - "pallet-aura", - "pallet-authorship", - "pallet-balances", - "pallet-collator-selection", - "pallet-multisig", - "pallet-nfts", - "pallet-nfts-runtime-api", - "pallet-proxy", - "pallet-session", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-uniques", - "pallet-utility", - "pallet-xcm", - "pallet-xcm-benchmarks", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "polkadot-core-primitives", - "polkadot-parachain", - "polkadot-runtime-common", - "polkadot-runtime-constants", - "scale-info", - "smallvec", - "sp-api", - "sp-block-builder", - "sp-consensus-aura", - "sp-core", - "sp-inherents", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "sp-weights", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "assets-common" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "cumulus-primitives-core", - "frame-support", - "log", - "pallet-asset-conversion", - "pallet-asset-tx-payment", - "pallet-xcm", - "parachains-common", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-runtime", - "sp-std", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", -] - [[package]] name = "async-channel" version = "1.9.0" @@ -817,21 +719,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "casey" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614586263949597dcc18675da12ef9b429135e13628d92eb8b8c6fa50ca5656b" -dependencies = [ - "syn 1.0.109", -] - -[[package]] -name = "cast" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" - [[package]] name = "cc" version = "1.0.83" @@ -910,33 +797,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "ciborium" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" -dependencies = [ - "ciborium-io", - "ciborium-ll", - "serde", -] - -[[package]] -name = "ciborium-io" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" - -[[package]] -name = "ciborium-ll" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" -dependencies = [ - "ciborium-io", - "half", -] - [[package]] name = "cid" version = "0.9.0" @@ -1307,44 +1167,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "criterion" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" -dependencies = [ - "anes", - "cast", - "ciborium", - "clap", - "criterion-plot", - "futures", - "is-terminal", - "itertools 0.10.5", - "num-traits", - "once_cell", - "oorandom", - "plotters", - "rayon", - "regex", - "serde", - "serde_derive", - "serde_json", - "tinytemplate", - "tokio", - "walkdir", -] - -[[package]] -name = "criterion-plot" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" -dependencies = [ - "cast", - "itertools 0.10.5", -] - [[package]] name = "critical-section" version = "1.1.2" @@ -1576,29 +1398,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cumulus-client-consensus-relay-chain" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "async-trait", - "cumulus-client-consensus-common", - "cumulus-primitives-core", - "cumulus-relay-chain-interface", - "futures", - "parking_lot 0.12.1", - "sc-consensus", - "sp-api", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-inherents", - "sp-runtime", - "substrate-prometheus-endpoint", - "tracing", -] - [[package]] name = "cumulus-client-network" version = "0.1.0" @@ -2007,123 +1806,10 @@ source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c2 dependencies = [ "cumulus-primitives-core", "parity-scale-codec", - "polkadot-primitives", - "sp-runtime", - "sp-state-machine", - "sp-std", -] - -[[package]] -name = "cumulus-test-relay-validation-worker-provider" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "polkadot-node-core-pvf", - "toml 0.7.8", -] - -[[package]] -name = "cumulus-test-runtime" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "cumulus-pallet-parachain-system", - "cumulus-primitives-core", - "cumulus-primitives-timestamp", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-rpc-runtime-api", - "pallet-balances", - "pallet-glutton", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-block-builder", - "sp-core", - "sp-inherents", - "sp-io", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", -] - -[[package]] -name = "cumulus-test-service" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "async-trait", - "clap", - "criterion", - "cumulus-client-cli", - "cumulus-client-consensus-common", - "cumulus-client-consensus-relay-chain", - "cumulus-client-pov-recovery", - "cumulus-client-service", - "cumulus-pallet-parachain-system", - "cumulus-primitives-core", - "cumulus-primitives-parachain-inherent", - "cumulus-relay-chain-inprocess-interface", - "cumulus-relay-chain-interface", - "cumulus-relay-chain-minimal-node", - "cumulus-test-relay-sproof-builder", - "cumulus-test-relay-validation-worker-provider", - "cumulus-test-runtime", - "frame-system", - "frame-system-rpc-runtime-api", - "jsonrpsee", - "pallet-timestamp", - "pallet-transaction-payment", - "parachains-common", - "parity-scale-codec", - "polkadot-cli", - "polkadot-node-subsystem", - "polkadot-overseer", - "polkadot-primitives", - "polkadot-service", - "polkadot-test-service", - "rand 0.8.5", - "sc-basic-authorship", - "sc-block-builder", - "sc-chain-spec", - "sc-cli", - "sc-client-api", - "sc-consensus", - "sc-executor", - "sc-executor-common", - "sc-executor-wasmtime", - "sc-network", - "sc-service", - "sc-telemetry", - "sc-tracing", - "sc-transaction-pool", - "sc-transaction-pool-api", - "serde", - "sp-api", - "sp-arithmetic", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-io", - "sp-keyring", + "polkadot-primitives", "sp-runtime", "sp-state-machine", - "sp-timestamp", - "sp-tracing", - "sp-trie", - "substrate-test-client", - "tempfile", - "tokio", - "tracing", - "url", + "sp-std", ] [[package]] @@ -3482,12 +3168,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "half" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" - [[package]] name = "handlebars" version = "4.5.0" @@ -3919,61 +3599,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "integration-tests" -version = "0.4.0" -dependencies = [ - "asset-hub-polkadot-runtime", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "frame-support", - "frame-system", - "itertools 0.11.0", - "macros", - "orml-oracle", - "pallet-assets", - "pallet-balances", - "pallet-funding", - "pallet-im-online", - "pallet-linear-release", - "pallet-membership", - "pallet-message-queue", - "pallet-parachain-staking", - "pallet-staking", - "pallet-vesting", - "pallet-xcm", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "penpal-runtime", - "polimec-base-runtime", - "polimec-common", - "polimec-parachain-runtime", - "polimec-receiver", - "polkadot-core-primitives", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime", - "polkadot-runtime-constants", - "polkadot-runtime-parachains", - "polkadot-service", - "sc-consensus-grandpa", - "scale-info", - "sp-arithmetic", - "sp-authority-discovery", - "sp-consensus-babe", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-emulator", - "xcm-executor", -] - [[package]] name = "io-lifetimes" version = "1.0.11" @@ -5608,12 +5233,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "oorandom" -version = "11.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" - [[package]] name = "opaque-debug" version = "0.2.3" @@ -5726,24 +5345,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-asset-conversion" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-asset-tx-payment" version = "4.0.0-dev" @@ -6145,24 +5746,6 @@ dependencies = [ "xcm-executor", ] -[[package]] -name = "pallet-glutton" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "blake2", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-grandpa" version = "4.0.0-dev" @@ -6342,35 +5925,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-nfts" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "enumflags2", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-nfts-runtime-api" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "frame-support", - "pallet-nfts", - "parity-scale-codec", - "sp-api", -] - [[package]] name = "pallet-nis" version = "4.0.0-dev" @@ -6888,21 +6442,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-uniques" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-utility" version = "4.0.0-dev" @@ -7133,124 +6672,61 @@ dependencies = [ ] [[package]] -name = "parking_lot_core" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall 0.4.1", - "smallvec", - "windows-targets 0.48.5", -] - -[[package]] -name = "partial_sort" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" - -[[package]] -name = "paste" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" - -[[package]] -name = "pbkdf2" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" -dependencies = [ - "crypto-mac 0.11.1", -] - -[[package]] -name = "pbkdf2" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - -[[package]] -name = "pem" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" -dependencies = [ - "base64 0.13.1", -] - -[[package]] -name = "penpal-runtime" -version = "0.9.27" -dependencies = [ - "cumulus-pallet-aura-ext", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-session-benchmarking", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "cumulus-primitives-timestamp", - "cumulus-primitives-utility", - "frame-benchmarking", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal 0.4.1", - "log", - "pallet-asset-tx-payment", - "pallet-assets", - "pallet-aura", - "pallet-authorship", - "pallet-balances", - "pallet-collator-selection", - "pallet-session", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-vesting", - "pallet-xcm", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "polimec-common", - "polimec-receiver", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "scale-info", - "smallvec", - "sp-api", - "sp-block-builder", - "sp-consensus-aura", - "sp-core", - "sp-inherents", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", +name = "parking_lot_core" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.4.1", + "smallvec", + "windows-targets 0.48.5", +] + +[[package]] +name = "partial_sort" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" + +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "pbkdf2" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" +dependencies = [ + "crypto-mac 0.11.1", +] + +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "pem" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" +dependencies = [ + "base64 0.13.1", ] [[package]] @@ -7374,34 +6850,6 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" -[[package]] -name = "plotters" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" -dependencies = [ - "num-traits", - "plotters-backend", - "plotters-svg", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "plotters-backend" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" - -[[package]] -name = "plotters-svg" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" -dependencies = [ - "plotters-backend", -] - [[package]] name = "polimec-base-runtime" version = "0.4.0" @@ -8860,118 +8308,6 @@ dependencies = [ "sp-core", ] -[[package]] -name = "polkadot-test-runtime" -version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" -dependencies = [ - "bitvec", - "frame-election-provider-support", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-rpc-runtime-api", - "log", - "pallet-authority-discovery", - "pallet-authorship", - "pallet-babe", - "pallet-balances", - "pallet-grandpa", - "pallet-indices", - "pallet-offences", - "pallet-session", - "pallet-staking", - "pallet-staking-reward-curve", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-vesting", - "pallet-xcm", - "parity-scale-codec", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "rustc-hex", - "scale-info", - "serde", - "serde_derive", - "smallvec", - "sp-api", - "sp-authority-discovery", - "sp-block-builder", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-core", - "sp-inherents", - "sp-io", - "sp-mmr-primitives", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", - "test-runtime-constants", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "polkadot-test-service" -version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" -dependencies = [ - "frame-system", - "futures", - "hex", - "pallet-balances", - "pallet-staking", - "pallet-transaction-payment", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-overseer", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-rpc", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "polkadot-service", - "polkadot-test-runtime", - "rand 0.8.5", - "sc-authority-discovery", - "sc-chain-spec", - "sc-cli", - "sc-client-api", - "sc-consensus", - "sc-consensus-babe", - "sc-consensus-grandpa", - "sc-network", - "sc-service", - "sc-tracing", - "sc-transaction-pool", - "sp-arithmetic", - "sp-authority-discovery", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-consensus-grandpa", - "sp-core", - "sp-inherents", - "sp-keyring", - "sp-runtime", - "sp-state-machine", - "substrate-test-client", - "tempfile", - "test-runtime-constants", - "tokio", - "tracing-gum", -] - [[package]] name = "polling" version = "3.3.1" @@ -12470,32 +11806,6 @@ dependencies = [ "trie-db", ] -[[package]] -name = "substrate-test-client" -version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "array-bytes", - "async-trait", - "futures", - "parity-scale-codec", - "sc-client-api", - "sc-client-db", - "sc-consensus", - "sc-executor", - "sc-offchain", - "sc-service", - "serde", - "serde_json", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-keyring", - "sp-keystore", - "sp-runtime", - "sp-state-machine", -] - [[package]] name = "substrate-typenum" version = "1.16.0" @@ -12625,20 +11935,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" -[[package]] -name = "test-runtime-constants" -version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" -dependencies = [ - "frame-support", - "polkadot-primitives", - "polkadot-runtime-common", - "smallvec", - "sp-core", - "sp-runtime", - "sp-weights", -] - [[package]] name = "thiserror" version = "1.0.50" @@ -12775,16 +12071,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "tinytemplate" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" -dependencies = [ - "serde", - "serde_json", -] - [[package]] name = "tinyvec" version = "1.6.0" @@ -14228,39 +13514,6 @@ dependencies = [ "xcm-executor", ] -[[package]] -name = "xcm-emulator" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "casey", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "cumulus-primitives-parachain-inherent", - "cumulus-test-relay-sproof-builder", - "cumulus-test-service", - "frame-support", - "frame-system", - "log", - "pallet-balances", - "pallet-message-queue", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "paste", - "polkadot-primitives", - "polkadot-runtime-parachains", - "quote", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-std", - "sp-trie", - "xcm", -] - [[package]] name = "xcm-executor" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index e1c5f0966..c4d6a365b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,8 +3,8 @@ members = [ "nodes/*", "runtimes/*", "pallets/*", - "integration-tests", - "integration-tests/penpal", +# "integration-tests", +# "integration-tests/penpal", "macros", "macros/tests", "polimec-common", diff --git a/debug_weight_gen.rs b/debug_weight_gen.rs new file mode 100644 index 000000000..971c85245 --- /dev/null +++ b/debug_weight_gen.rs @@ -0,0 +1,78 @@ + +//! Autogenerated weights for `pallet_funding` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2024-01-22, STEPS: `10`, REPEAT: `5`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `Juans-MBP.home`, CPU: `` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: 1024 + +// Executed Command: +// target/debug/polimec-parachain-node +// benchmark +// pallet +// --chain=polimec-rococo-local +// --steps=10 +// --repeat=5 +// --pallet=pallet_funding +// --extrinsic=start_evaluation,start_auction_manually +// --output +// ./debug_weight_gen.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_funding`. +pub struct WeightInfo(PhantomData); +impl pallet_funding::WeightInfo for WeightInfo { + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_evaluation(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `560 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 313_000_000 picoseconds. + Weight::from_parts(277_026_432, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 177_230 + .saturating_add(Weight::from_parts(36_411_429, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:4554 w:2) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + /// The range of component `y` is `[1, 10000]`. + /// The range of component `z` is `[1, 100]`. + fn start_auction_manually(x: u32, y: u32, _z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + x * (8678 ±0) + y * (249 ±0) + z * (22472 ±0)` + // Estimated: `316884 + x * (20887 ±12_728) + y * (1199 ±125)` + // Minimum execution time: 5_710_000_000 picoseconds. + Weight::from_parts(5_718_000_000, 0) + .saturating_add(Weight::from_parts(0, 316884)) + // Standard Error: 281_211_660 + .saturating_add(Weight::from_parts(385_812_210, 0).saturating_mul(x.into())) + // Standard Error: 2_780_420 + .saturating_add(Weight::from_parts(25_829_204, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(103)) + .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(3)) + .saturating_add(Weight::from_parts(0, 20887).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 1199).saturating_mul(y.into())) + } +} diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 7bd42966b..323cf5c20 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -492,7 +492,7 @@ mod benchmarks { #[benchmark] // it will also iterate through the `ProjectsToUpdate` vector, to remove the automatic transition scheduled. fn start_auction_manually( - // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate` + // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the extrinsic pass x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, // Total amount of storage items iterated through in `ProjectsToUpdate` when trying to remove our project in `remove_from_update_store`. // We assume an upper bound of 10_000 projects at one time in storage waiting to update, and in different blocks. @@ -502,9 +502,17 @@ mod benchmarks { ) { // * setup * let mut inst = BenchInstantiator::::new(None); - + // println!("------"); + // dbg!(x); + // dbg!(y); + // dbg!(z); + // println!("------"); + // println!("\n"); // real benchmark starts at block 0, and we can't call `events()` at block 0 - inst.advance_time(1u32.into()).unwrap(); + // We need to leave enough block numbers to fill `ProjectsToUpdate` before our project insertion + let u32_remaining_vecs: u32 = y.saturating_sub(x).into(); + let time_advance: u32 = 1 + u32_remaining_vecs + 1; + inst.advance_time(time_advance.into()).unwrap(); let issuer = account::>("issuer", 0, 0); whitelist_account!(issuer); @@ -525,11 +533,13 @@ mod benchmarks { inst.bond_for_users(project_id, evaluations).expect("All evaluations are accepted"); inst.advance_time(::EvaluationDuration::get() + One::one()).unwrap(); - let start_block_number = frame_system::Pallet::::block_number(); - // start_evaluation fn will try to add an automatic transition 1 block after the last evaluation block - let mut block_number: BlockNumberFor = - inst.current_block() + T::EvaluationDuration::get() + T::EnglishAuctionDuration::get() + One::one(); + let current_block = inst.current_block(); + // `do_english_auction` fn will try to add an automatic transition 1 block after the last english round block + let insertion_block_number: BlockNumberFor = current_block + T::EnglishAuctionDuration::get() + One::one(); + let mut block_number = insertion_block_number; + + // dbg!(ProjectsToUpdate::::iter().collect::>()); // fill the `ProjectsToUpdate` vectors from @ block_number to @ block_number+x, to benchmark all the failed insertion attempts for _ in 0..x { while ProjectsToUpdate::::try_append(block_number, (&69u32, UpdateType::EvaluationEnd)).is_ok() { @@ -537,6 +547,33 @@ mod benchmarks { } block_number += 1u32.into(); } + // dbg!(ProjectsToUpdate::::iter().collect::>()); + + // fill `ProjectsToUpdate` with `y` different BlockNumber->Vec(len=`z`) items to benchmark deletion of our project from the map + // We keep in mind that we already filled `x` amount of vecs to max capacity + let remaining_vecs = y.saturating_sub(x); + if remaining_vecs > 0 { + let vec_limit = ::MaxProjectsToUpdatePerBlock::get(); + let added_total_items = x * vec_limit; + let desired_total_items = y * z; + let remaining_total_items = desired_total_items.saturating_sub(added_total_items); + // if we surpassed the desired items, we still need at least 1 per vec to test for iterating over different vecs for removal + let remaining_items_per_vec = (remaining_total_items / remaining_vecs).max(1u32); + let mut block_number = insertion_block_number - One::one(); + for _ in 0..remaining_vecs { + // To iterate over all expected items when looking to remove, we need to insert everything _before_ our project's block_number + let mut vec: Vec<(ProjectId, UpdateType)> = ProjectsToUpdate::::get(block_number).to_vec(); + let items_to_fill = remaining_items_per_vec - vec.len() as u32; + for _ in 0..items_to_fill { + vec.push((69u32, UpdateType::EvaluationEnd)); + } + let bounded_vec: BoundedVec<(ProjectId, UpdateType), T::MaxProjectsToUpdatePerBlock> = + vec.try_into().unwrap(); + ProjectsToUpdate::::insert(block_number, bounded_vec); + block_number -= One::one(); + } + } + #[extrinsic_call] start_auction(RawOrigin::Signed(issuer), project_id); @@ -547,7 +584,7 @@ mod benchmarks { // Events frame_system::Pallet::::assert_last_event( - Event::::EnglishAuctionStarted { project_id, when: start_block_number.into() }.into(), + Event::::EnglishAuctionStarted { project_id, when: current_block.into() }.into(), ); } diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 24d94758d..347f3ebb5 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -419,7 +419,7 @@ impl Pallet { }, pays_fee: Pays::Yes, }, - error: Error::::ProjectNotInUpdateStore.into(), + error: Error::::TooManyInsertionAttempts.into(), }), }; From ccddcb7c2b514f40da585192b8ea63a1cc388b72 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 22 Jan 2024 16:04:03 +0100 Subject: [PATCH 136/212] trying to remove `z` and add automatic auction bench Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 109 ++++++++++++++++++++++------ pallets/funding/src/lib.rs | 8 +- pallets/funding/src/weights.rs | 2 +- 3 files changed, 92 insertions(+), 27 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 323cf5c20..9790bdf2d 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -490,25 +490,16 @@ mod benchmarks { } #[benchmark] - // it will also iterate through the `ProjectsToUpdate` vector, to remove the automatic transition scheduled. fn start_auction_manually( // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the extrinsic pass x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, // Total amount of storage items iterated through in `ProjectsToUpdate` when trying to remove our project in `remove_from_update_store`. - // We assume an upper bound of 10_000 projects at one time in storage waiting to update, and in different blocks. + // Upper bound is assumed to be enough y: Linear<1, 10_000>, - // The average amount of projects in each update block iterated through in remove_from_update_store when looking for our project - z: Linear<1, { ::MaxProjectsToUpdatePerBlock::get() }>, ) { // * setup * let mut inst = BenchInstantiator::::new(None); - // println!("------"); - // dbg!(x); - // dbg!(y); - // dbg!(z); - // println!("------"); - // println!("\n"); - // real benchmark starts at block 0, and we can't call `events()` at block 0 + // We need to leave enough block numbers to fill `ProjectsToUpdate` before our project insertion let u32_remaining_vecs: u32 = y.saturating_sub(x).into(); let time_advance: u32 = 1 + u32_remaining_vecs + 1; @@ -539,7 +530,6 @@ mod benchmarks { let insertion_block_number: BlockNumberFor = current_block + T::EnglishAuctionDuration::get() + One::one(); let mut block_number = insertion_block_number; - // dbg!(ProjectsToUpdate::::iter().collect::>()); // fill the `ProjectsToUpdate` vectors from @ block_number to @ block_number+x, to benchmark all the failed insertion attempts for _ in 0..x { while ProjectsToUpdate::::try_append(block_number, (&69u32, UpdateType::EvaluationEnd)).is_ok() { @@ -547,23 +537,98 @@ mod benchmarks { } block_number += 1u32.into(); } - // dbg!(ProjectsToUpdate::::iter().collect::>()); - // fill `ProjectsToUpdate` with `y` different BlockNumber->Vec(len=`z`) items to benchmark deletion of our project from the map + // fill `ProjectsToUpdate` with `y` different BlockNumber->Vec items to benchmark deletion of our project from the map + // We keep in mind that we already filled `x` amount of vecs to max capacity + let remaining_vecs = y.saturating_sub(x); + if remaining_vecs > 0 { + // we benchmarked this with different values and it had no impact on the weight, so we use a low value to speed up the benchmark + let items_per_vec = 5u32; + let mut block_number = insertion_block_number - One::one(); + for _ in 0..remaining_vecs { + // To iterate over all expected items when looking to remove, we need to insert everything _before_ our project's block_number + let mut vec: Vec<(ProjectId, UpdateType)> = ProjectsToUpdate::::get(block_number).to_vec(); + let items_to_fill = items_per_vec - vec.len() as u32; + for _ in 0..items_to_fill { + vec.push((69u32, UpdateType::EvaluationEnd)); + } + let bounded_vec: BoundedVec<(ProjectId, UpdateType), T::MaxProjectsToUpdatePerBlock> = + vec.try_into().unwrap(); + ProjectsToUpdate::::insert(block_number, bounded_vec); + block_number -= One::one(); + } + } + + #[extrinsic_call] + start_auction(RawOrigin::Signed(issuer), project_id); + + // * validity checks * + // Storage + let stored_details = ProjectsDetails::::get(project_id).unwrap(); + assert_eq!(stored_details.status, ProjectStatus::AuctionRound(AuctionPhase::English)); + + // Events + frame_system::Pallet::::assert_last_event( + Event::::EnglishAuctionStarted { project_id, when: current_block.into() }.into(), + ); + } + + #[benchmark] + fn start_auction_automatically( + // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the extrinsic pass + x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, + // No `y` param because we don't need to remove the automatic transition from storage + ) { + // * setup * + let mut inst = BenchInstantiator::::new(None); + + // real benchmark starts at block 0, and we can't call `events()` at block 0 + inst.advance_time(1u32.into()).unwrap(); + + let issuer = account::>("issuer", 0, 0); + whitelist_account!(issuer); + + let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); + let project_id = inst.create_evaluating_project(project_metadata, issuer.clone()); + + let evaluations = default_evaluations(); + let plmc_for_evaluating = BenchInstantiator::::calculate_evaluation_plmc_spent(evaluations.clone()); + let existential_plmc: Vec> = plmc_for_evaluating.accounts().existential_deposits(); + let ct_account_deposits: Vec> = plmc_for_evaluating.accounts().ct_account_deposits(); + + inst.mint_plmc_to(existential_plmc); + inst.mint_plmc_to(ct_account_deposits); + inst.mint_plmc_to(plmc_for_evaluating); + + inst.advance_time(One::one()).unwrap(); + inst.bond_for_users(project_id, evaluations).expect("All evaluations are accepted"); + + inst.advance_time(::EvaluationDuration::get() + One::one()).unwrap(); + + let current_block = inst.current_block(); + // `do_english_auction` fn will try to add an automatic transition 1 block after the last english round block + let insertion_block_number: BlockNumberFor = current_block + T::EnglishAuctionDuration::get() + One::one(); + let mut block_number = insertion_block_number; + + // fill the `ProjectsToUpdate` vectors from @ block_number to @ block_number+x, to benchmark all the failed insertion attempts + for _ in 0..x { + while ProjectsToUpdate::::try_append(block_number, (&69u32, UpdateType::EvaluationEnd)).is_ok() { + continue + } + block_number += 1u32.into(); + } + + // fill `ProjectsToUpdate` with `y` different BlockNumber->Vec items to benchmark deletion of our project from the map // We keep in mind that we already filled `x` amount of vecs to max capacity let remaining_vecs = y.saturating_sub(x); if remaining_vecs > 0 { - let vec_limit = ::MaxProjectsToUpdatePerBlock::get(); - let added_total_items = x * vec_limit; - let desired_total_items = y * z; - let remaining_total_items = desired_total_items.saturating_sub(added_total_items); - // if we surpassed the desired items, we still need at least 1 per vec to test for iterating over different vecs for removal - let remaining_items_per_vec = (remaining_total_items / remaining_vecs).max(1u32); + // we benchmarked this with different values and it had no impact on the weight, so we use a low value to speed up the benchmark + let items_per_vec = 5u32; let mut block_number = insertion_block_number - One::one(); for _ in 0..remaining_vecs { // To iterate over all expected items when looking to remove, we need to insert everything _before_ our project's block_number let mut vec: Vec<(ProjectId, UpdateType)> = ProjectsToUpdate::::get(block_number).to_vec(); - let items_to_fill = remaining_items_per_vec - vec.len() as u32; + let items_to_fill = items_per_vec - vec.len() as u32; for _ in 0..items_to_fill { vec.push((69u32, UpdateType::EvaluationEnd)); } @@ -589,7 +654,7 @@ mod benchmarks { } #[benchmark] - fn bond_evaluation(x: Linear<1, 20>) { + fn evaluate(x: Linear<1, 20>) { // setup let mut inst = BenchInstantiator::::new(None); diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 2cfa36de7..a42e9a6f9 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -45,7 +45,7 @@ //! |---------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------| //! | Creation | Issuer creates a project with the [`create()`](Pallet::create) extrinsic. | [`Application`](ProjectStatus::Application) | //! | Evaluation Start | Issuer starts the evaluation round with the [`start_evaluation()`](Pallet::start_evaluation) extrinsic. | [`EvaluationRound`](ProjectStatus::EvaluationRound) | -//! | Evaluation Submissions | Evaluators assess the project information, and if they think it is good enough to get funding, they bond Polimec's native token PLMC with [`bond_evaluation()`](Pallet::bond_evaluation) | [`EvaluationRound`](ProjectStatus::EvaluationRound) | +//! | Evaluation Submissions | Evaluators assess the project information, and if they think it is good enough to get funding, they bond Polimec's native token PLMC with [`bond_evaluation()`](Pallet::evaluate) | [`EvaluationRound`](ProjectStatus::EvaluationRound) | //! | Evaluation End | Evaluation round ends automatically after the [`Config::EvaluationDuration`] has passed. This is achieved by the [`on_initialize()`](Pallet::on_initialize) function. | [`AuctionInitializePeriod`](ProjectStatus::AuctionInitializePeriod) | //! | Auction Start | Issuer starts the auction round within the [`Config::AuctionInitializePeriodDuration`], by calling the extrinsic [`start_auction()`](Pallet::start_auction) | [`AuctionRound(English)`](ProjectStatus::AuctionRound) | //! | Bid Submissions | Institutional and Professional users can place bids with [`bid()`](Pallet::bid) by choosing their desired token price, amount, and multiplier (for vesting). Their bids are guaranteed to be considered | [`AuctionRound(English)`](ProjectStatus::AuctionRound) | | | @@ -66,7 +66,7 @@ //! * [`edit_metadata`](Pallet::edit_metadata) : Submit a new Hash of the project metadata. //! * [`start_evaluation`](Pallet::start_evaluation) : Start the Evaluation round of a project. //! * [`start_auction`](Pallet::start_auction) : Start the English Auction round of a project. -//! * [`bond_evaluation`](Pallet::bond_evaluation) : Bond PLMC on a project in the evaluation stage. A sort of "bet" that you think the project will be funded +//! * [`bond_evaluation`](Pallet::evaluate) : Bond PLMC on a project in the evaluation stage. A sort of "bet" that you think the project will be funded //! * [`failed_evaluation_unbond_for`](Pallet::failed_evaluation_unbond_for) : Unbond the PLMC bonded on a project's evaluation round for any user, if the project failed the evaluation. //! * [`bid`](Pallet::bid) : Perform a bid during the English or Candle Auction Round. //! * [`contribute`](Pallet::contribute) : Buy contribution tokens if a project during the Community or Remainder round @@ -981,8 +981,8 @@ pub mod pallet { /// Bond PLMC for a project in the evaluation stage #[pallet::call_index(4)] - #[pallet::weight(WeightInfoOf::::bond_evaluation())] - pub fn bond_evaluation( + #[pallet::weight(WeightInfoOf::::evaluate())] + pub fn evaluate( origin: OriginFor, project_id: ProjectId, #[pallet::compact] usd_amount: BalanceOf, diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index 6fa2ff015..55431e496 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -56,7 +56,7 @@ pub trait WeightInfo { fn start_evaluation(x: u32) -> Weight; fn start_auction_manually(x: u32, y: u32, z: u32) -> Weight; fn start_auction_automatically(x: u32) -> Weight; - fn bond_evaluation() -> Weight; + fn evaluate() -> Weight; fn bid() -> Weight; fn contribute() -> Weight; fn evaluation_unbond_for() -> Weight; From bdb40db353f62ce7e679efe51b080b5e0b9646bd Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 22 Jan 2024 16:32:02 +0100 Subject: [PATCH 137/212] finished automatic auction benchmark, now running it for real Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 51 +++++++++++------------------ pallets/funding/src/weights.rs | 2 +- 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 9790bdf2d..176a8a660 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -606,8 +606,10 @@ mod benchmarks { inst.advance_time(::EvaluationDuration::get() + One::one()).unwrap(); let current_block = inst.current_block(); - // `do_english_auction` fn will try to add an automatic transition 1 block after the last english round block - let insertion_block_number: BlockNumberFor = current_block + T::EnglishAuctionDuration::get() + One::one(); + let automatic_transition_block = + current_block + ::AuctionInitializePeriodDuration::get() + One::one(); + let insertion_block_number: BlockNumberFor = + automatic_transition_block + T::EnglishAuctionDuration::get() + One::one(); let mut block_number = insertion_block_number; // fill the `ProjectsToUpdate` vectors from @ block_number to @ block_number+x, to benchmark all the failed insertion attempts @@ -618,26 +620,12 @@ mod benchmarks { block_number += 1u32.into(); } - // fill `ProjectsToUpdate` with `y` different BlockNumber->Vec items to benchmark deletion of our project from the map - // We keep in mind that we already filled `x` amount of vecs to max capacity - let remaining_vecs = y.saturating_sub(x); - if remaining_vecs > 0 { - // we benchmarked this with different values and it had no impact on the weight, so we use a low value to speed up the benchmark - let items_per_vec = 5u32; - let mut block_number = insertion_block_number - One::one(); - for _ in 0..remaining_vecs { - // To iterate over all expected items when looking to remove, we need to insert everything _before_ our project's block_number - let mut vec: Vec<(ProjectId, UpdateType)> = ProjectsToUpdate::::get(block_number).to_vec(); - let items_to_fill = items_per_vec - vec.len() as u32; - for _ in 0..items_to_fill { - vec.push((69u32, UpdateType::EvaluationEnd)); - } - let bounded_vec: BoundedVec<(ProjectId, UpdateType), T::MaxProjectsToUpdatePerBlock> = - vec.try_into().unwrap(); - ProjectsToUpdate::::insert(block_number, bounded_vec); - block_number -= One::one(); - } - } + let now = inst.current_block(); + inst.advance_time(automatic_transition_block - now - One::one()).unwrap(); + let now = inst.current_block(); + // we don't use advance time to avoid triggering on_initialize. This benchmark should only measure the extrinsic + // weight and not the whole on_initialize call weight + frame_system::Pallet::::set_block_number(now + One::one()); #[extrinsic_call] start_auction(RawOrigin::Signed(issuer), project_id); @@ -648,6 +636,7 @@ mod benchmarks { assert_eq!(stored_details.status, ProjectStatus::AuctionRound(AuctionPhase::English)); // Events + let current_block = inst.current_block(); frame_system::Pallet::::assert_last_event( Event::::EnglishAuctionStarted { project_id, when: current_block.into() }.into(), ); @@ -684,7 +673,7 @@ mod benchmarks { inst.advance_time(One::one()).unwrap(); #[extrinsic_call] - bond_evaluation(RawOrigin::Signed(test_evaluator.clone()), test_project_id, evaluation.usd_amount); + evaluate(RawOrigin::Signed(test_evaluator.clone()), test_project_id, evaluation.usd_amount); // * validity checks * // Storage @@ -1996,9 +1985,9 @@ mod benchmarks { } #[test] - fn bench_bond_evaluation() { + fn bench_evaluate() { new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_bond_evaluation()); + assert_ok!(PalletFunding::::test_evaluate()); }); } @@ -2009,12 +1998,12 @@ mod benchmarks { }); } - // #[test] - // fn bench_start_auction_automatically() { - // new_test_ext().execute_with(|| { - // assert_ok!(PalletFunding::::test_start_auction_automatically()); - // }); - // } + #[test] + fn bench_start_auction_automatically() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_start_auction_automatically()); + }); + } #[test] fn bench_bid() { diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index 55431e496..4d814a740 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -140,7 +140,7 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: PolimecFunding Evaluations (max_values: None, max_size: None, mode: Measured) /// Storage: Balances Holds (r:1 w:1) /// Proof: Balances Holds (max_values: None, max_size: Some(1099), added: 3574, mode: MaxEncodedLen) - fn bond_evaluation() -> Weight { + fn evaluate() -> Weight { // Proof Size summary in bytes: // Measured: `428` // Estimated: `4564` From 4f51f36cd5a2d62f95b45e302f50b8e2ddb09f4f Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 22 Jan 2024 17:41:23 +0100 Subject: [PATCH 138/212] new weight gen Signed-off-by: Juan Ignacio Rios --- debug_weight_gen.rs | 62 +++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/debug_weight_gen.rs b/debug_weight_gen.rs index 971c85245..a85b2fdf7 100644 --- a/debug_weight_gen.rs +++ b/debug_weight_gen.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `pallet_funding` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-01-22, STEPS: `10`, REPEAT: `5`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-01-22, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `Juans-MBP.home`, CPU: `` //! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: 1024 @@ -12,10 +12,10 @@ // benchmark // pallet // --chain=polimec-rococo-local -// --steps=10 -// --repeat=5 +// --steps=20 +// --repeat=10 // --pallet=pallet_funding -// --extrinsic=start_evaluation,start_auction_manually +// --extrinsic=start_evaluation,start_auction_manually,start_auction_automatically // --output // ./debug_weight_gen.rs @@ -39,13 +39,13 @@ impl pallet_funding::WeightInfo for WeightInfo { /// The range of component `x` is `[1, 99]`. fn start_evaluation(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `560 + x * (529 ±0)` + // Measured: `563 + x * (529 ±0)` // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 313_000_000 picoseconds. - Weight::from_parts(277_026_432, 0) + // Minimum execution time: 298_000_000 picoseconds. + Weight::from_parts(267_225_295, 0) .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 177_230 - .saturating_add(Weight::from_parts(36_411_429, 0).saturating_mul(x.into())) + // Standard Error: 72_655 + .saturating_add(Weight::from_parts(36_324_750, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().writes(2)) @@ -57,22 +57,40 @@ impl pallet_funding::WeightInfo for WeightInfo { /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. /// The range of component `y` is `[1, 10000]`. - /// The range of component `z` is `[1, 100]`. - fn start_auction_manually(x: u32, y: u32, _z: u32, ) -> Weight { + fn start_auction_manually(x: u32, y: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + x * (8678 ±0) + y * (249 ±0) + z * (22472 ±0)` - // Estimated: `316884 + x * (20887 ±12_728) + y * (1199 ±125)` - // Minimum execution time: 5_710_000_000 picoseconds. - Weight::from_parts(5_718_000_000, 0) + // Measured: `0 + x * (811 ±0) + y * (30 ±0)` + // Estimated: `316884 + x * (17288 ±8_684) + y * (1305 ±85)` + // Minimum execution time: 5_603_000_000 picoseconds. + Weight::from_parts(5_897_000_000, 0) .saturating_add(Weight::from_parts(0, 316884)) - // Standard Error: 281_211_660 - .saturating_add(Weight::from_parts(385_812_210, 0).saturating_mul(x.into())) - // Standard Error: 2_780_420 - .saturating_add(Weight::from_parts(25_829_204, 0).saturating_mul(y.into())) + // Standard Error: 195_897_326 + .saturating_add(Weight::from_parts(383_791_795, 0).saturating_mul(x.into())) + // Standard Error: 1_938_243 + .saturating_add(Weight::from_parts(29_385_710, 0).saturating_mul(y.into())) .saturating_add(T::DbWeight::get().reads(103)) - .saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().writes(3)) - .saturating_add(Weight::from_parts(0, 20887).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 1199).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 17288).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 1305).saturating_mul(y.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_auction_automatically(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `412 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 254_000_000 picoseconds. + Weight::from_parts(257_107_151, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 129_758 + .saturating_add(Weight::from_parts(34_258_180, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) } } From d4ae47c711033a858a759fc9dc87740b10cb8579 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 23 Jan 2024 16:39:54 +0100 Subject: [PATCH 139/212] evaluation benchmarks. fix auction round extrinsic Signed-off-by: Juan Ignacio Rios --- debug_weight_gen.rs | 110 ++++++------- pallets/funding/src/benchmarking.rs | 174 +++++++++++++++++---- pallets/funding/src/functions.rs | 64 ++++---- pallets/funding/src/instantiator.rs | 4 +- pallets/funding/src/lib.rs | 6 +- pallets/funding/src/weights.rs | 39 ++--- pallets/linear-release/src/benchmarking.rs | 2 +- 7 files changed, 253 insertions(+), 146 deletions(-) diff --git a/debug_weight_gen.rs b/debug_weight_gen.rs index a85b2fdf7..1af778286 100644 --- a/debug_weight_gen.rs +++ b/debug_weight_gen.rs @@ -2,9 +2,9 @@ //! Autogenerated weights for `pallet_funding` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-01-22, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-01-23, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `Juans-MBP.home`, CPU: `` +//! HOSTNAME: `Juans-MacBook-Pro.local`, CPU: `` //! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: 1024 // Executed Command: @@ -15,7 +15,7 @@ // --steps=20 // --repeat=10 // --pallet=pallet_funding -// --extrinsic=start_evaluation,start_auction_manually,start_auction_automatically +// --extrinsic=first_evaluation,second_to_limit_evaluation,evaluation_over_limit // --output // ./debug_weight_gen.rs @@ -30,67 +30,69 @@ use core::marker::PhantomData; /// Weight functions for `pallet_funding`. pub struct WeightInfo(PhantomData); impl pallet_funding::WeightInfo for WeightInfo { - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn start_evaluation(x: u32, ) -> Weight { + /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) + /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn first_evaluation() -> Weight { // Proof Size summary in bytes: - // Measured: `563 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 298_000_000 picoseconds. - Weight::from_parts(267_225_295, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 72_655 - .saturating_add(Weight::from_parts(36_324_750, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + // Measured: `676` + // Estimated: `4614` + // Minimum execution time: 1_398_000_000 picoseconds. + Weight::from_parts(1_451_000_000, 0) + .saturating_add(Weight::from_parts(0, 4614)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:4554 w:2) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - /// The range of component `y` is `[1, 10000]`. - fn start_auction_manually(x: u32, y: u32, ) -> Weight { + /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) + /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:255 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 255]`. + fn second_to_limit_evaluation(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + x * (811 ±0) + y * (30 ±0)` - // Estimated: `316884 + x * (17288 ±8_684) + y * (1305 ±85)` - // Minimum execution time: 5_603_000_000 picoseconds. - Weight::from_parts(5_897_000_000, 0) - .saturating_add(Weight::from_parts(0, 316884)) - // Standard Error: 195_897_326 - .saturating_add(Weight::from_parts(383_791_795, 0).saturating_mul(x.into())) - // Standard Error: 1_938_243 - .saturating_add(Weight::from_parts(29_385_710, 0).saturating_mul(y.into())) - .saturating_add(T::DbWeight::get().reads(103)) - .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(3)) - .saturating_add(Weight::from_parts(0, 17288).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 1305).saturating_mul(y.into())) + // Measured: `889 + x * (137 ±0)` + // Estimated: `4614 + x * (2820 ±0)` + // Minimum execution time: 1_048_000_000 picoseconds. + Weight::from_parts(829_226_001, 0) + .saturating_add(Weight::from_parts(0, 4614)) + // Standard Error: 159_622 + .saturating_add(Weight::from_parts(63_317_508, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(4)) + .saturating_add(Weight::from_parts(0, 2820).saturating_mul(x.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn start_auction_automatically(x: u32, ) -> Weight { + /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) + /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:257 w:2) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn evaluation_over_limit() -> Weight { // Proof Size summary in bytes: - // Measured: `412 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 254_000_000 picoseconds. - Weight::from_parts(257_107_151, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 129_758 - .saturating_add(Weight::from_parts(34_258_180, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + // Measured: `36120` + // Estimated: `725730` + // Minimum execution time: 17_581_000_000 picoseconds. + Weight::from_parts(17_943_000_000, 0) + .saturating_add(Weight::from_parts(0, 725730)) + .saturating_add(T::DbWeight::get().reads(261)) + .saturating_add(T::DbWeight::get().writes(5)) } } diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 176a8a660..59753f76a 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -642,17 +642,27 @@ mod benchmarks { ); } - #[benchmark] - fn evaluate(x: Linear<1, 20>) { + // possible branches: + // - pays ct account deposit + // - we know this happens only if param x = 0, but we cannot fit it in the linear regression + // - is over max evals per user, and needs to unbond the lowest evaluation + // - this case, we know they paid already for ct account deposit + + fn evaluation_setup( + x: u32, + ) -> (BenchInstantiator, ProjectId, UserToUSDBalance, BalanceOf, BalanceOf) + where + ::Balance: From, + ::Price: From, + T::Hash: From, + ::RuntimeEvent: From>, + { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - let issuer = account::>("issuer", 0, 0); let test_evaluator = account::>("evaluator", 0, 0); whitelist_account!(test_evaluator); @@ -660,24 +670,58 @@ mod benchmarks { let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); let test_project_id = inst.create_evaluating_project(project_metadata, issuer); - let evaluation = UserToUSDBalance::new(test_evaluator.clone(), (50_000 * US_DOLLAR).into()); + let existing_evaluation = UserToUSDBalance::new(test_evaluator.clone(), (100 * US_DOLLAR).into()); + let extrinsic_evaluation = UserToUSDBalance::new(test_evaluator.clone(), (1_000 * US_DOLLAR).into()); + let existing_evaluations = vec![existing_evaluation; x as usize]; - let plmc_for_evaluating = BenchInstantiator::::calculate_evaluation_plmc_spent(vec![evaluation.clone()]); - let existential_plmc: Vec> = plmc_for_evaluating.accounts().existential_deposits(); - let ct_account_deposits: Vec> = plmc_for_evaluating.accounts().ct_account_deposits(); + let plmc_for_existing_evaluations = + BenchInstantiator::::calculate_evaluation_plmc_spent(existing_evaluations.clone()); + let plmc_for_extrinsic_evaluation = + BenchInstantiator::::calculate_evaluation_plmc_spent(vec![extrinsic_evaluation.clone()]); + let existential_plmc: Vec> = + plmc_for_extrinsic_evaluation.accounts().existential_deposits(); + let ct_account_deposits: Vec> = + plmc_for_extrinsic_evaluation.accounts().ct_account_deposits(); inst.mint_plmc_to(existential_plmc); inst.mint_plmc_to(ct_account_deposits); - inst.mint_plmc_to(plmc_for_evaluating.clone()); + inst.mint_plmc_to(plmc_for_existing_evaluations.clone()); + inst.mint_plmc_to(plmc_for_extrinsic_evaluation.clone()); inst.advance_time(One::one()).unwrap(); - #[extrinsic_call] - evaluate(RawOrigin::Signed(test_evaluator.clone()), test_project_id, evaluation.usd_amount); + // do "x" evaluations for this user + inst.bond_for_users(test_project_id, existing_evaluations).expect("All evaluations are accepted"); + + let extrinsic_plmc_bonded = plmc_for_extrinsic_evaluation[0].plmc_amount; + let mut total_expected_plmc_bonded = BenchInstantiator::::sum_balance_mappings(vec![ + plmc_for_existing_evaluations.clone(), + plmc_for_extrinsic_evaluation.clone(), + ]); + + // if we are going to unbond evaluations due to being over the limit per user, then deduct them from the total expected plmc bond + if x >= ::MaxEvaluationsPerUser::get() { + total_expected_plmc_bonded -= plmc_for_existing_evaluations[0].plmc_amount * + (x as u128 - ::MaxEvaluationsPerUser::get() as u128 + 1u128).into(); + } + (inst, test_project_id, extrinsic_evaluation, extrinsic_plmc_bonded, total_expected_plmc_bonded) + } + fn evaluation_verification( + mut inst: BenchInstantiator, + project_id: ProjectId, + evaluation: UserToUSDBalance, + extrinsic_plmc_bonded: BalanceOf, + total_expected_plmc_bonded: BalanceOf, + ) where + ::Balance: From, + ::Price: From, + T::Hash: From, + ::RuntimeEvent: From>, + { // * validity checks * // Storage - let stored_evaluation = Evaluations::::iter_prefix_values((test_project_id, test_evaluator.clone())) + let stored_evaluation = Evaluations::::iter_prefix_values((project_id, evaluation.account.clone())) .sorted_by(|a, b| a.id.cmp(&b.id)) .last() .unwrap(); @@ -691,29 +735,92 @@ mod benchmarks { rewarded_or_slashed, .. } if project_id == project_id && - evaluator == test_evaluator.clone() && - original_plmc_bond == plmc_for_evaluating[0].plmc_amount && - current_plmc_bond == plmc_for_evaluating[0].plmc_amount && + evaluator == evaluation.account.clone() && + original_plmc_bond == extrinsic_plmc_bonded && + current_plmc_bond == extrinsic_plmc_bonded && rewarded_or_slashed.is_none() => {}, _ => assert!(false, "Evaluation is not stored correctly"), } // Balances let bonded_plmc = inst.get_reserved_plmc_balances_for( - vec![test_evaluator.clone()], - HoldReason::Evaluation(test_project_id).into(), + vec![evaluation.account.clone()], + HoldReason::Evaluation(project_id).into(), )[0] .plmc_amount; - assert_eq!(bonded_plmc, plmc_for_evaluating[0].plmc_amount); + assert_eq!(bonded_plmc, total_expected_plmc_bonded); // Events frame_system::Pallet::::assert_last_event( - Event::::FundsBonded { - project_id: test_project_id, - amount: plmc_for_evaluating[0].plmc_amount, - bonder: test_evaluator.clone(), - } - .into(), + Event::::FundsBonded { project_id, amount: extrinsic_plmc_bonded, bonder: evaluation.account.clone() } + .into(), + ); + } + + // - We know how many iterations it does in storage + // - We know that it requires a ct deposit + // - We know that it does not require to unbond the lowest evaluation + #[benchmark] + fn first_evaluation() { + // How many other evaluations the user did for that same project + let x = 0; + let (inst, project_id, extrinsic_evaluation, extrinsic_plmc_bonded, total_expected_plmc_bonded) = + evaluation_setup::(x); + + #[extrinsic_call] + evaluate(RawOrigin::Signed(extrinsic_evaluation.account.clone()), project_id, extrinsic_evaluation.usd_amount); + + evaluation_verification::( + inst, + project_id, + extrinsic_evaluation, + extrinsic_plmc_bonded, + total_expected_plmc_bonded, + ); + } + + // - We know that it does not require a ct deposit + // - We know that it does not require to unbond the lowest evaluation. + // - We don't know how many iterations it does in storage (i.e "x") + #[benchmark] + fn second_to_limit_evaluation( + // How many other evaluations the user did for that same project + x: Linear<1, { T::MaxEvaluationsPerUser::get() - 1 }>, + ) { + let (inst, project_id, extrinsic_evaluation, extrinsic_plmc_bonded, total_expected_plmc_bonded) = + evaluation_setup::(x); + + #[extrinsic_call] + evaluate(RawOrigin::Signed(extrinsic_evaluation.account.clone()), project_id, extrinsic_evaluation.usd_amount); + + evaluation_verification::( + inst, + project_id, + extrinsic_evaluation, + extrinsic_plmc_bonded, + total_expected_plmc_bonded, + ); + } + + // - We know how many iterations it does in storage + // - We know that it does not require a ct deposit + // - We know that it requires to unbond the lowest evaluation + #[benchmark] + fn evaluation_over_limit() { + // How many other evaluations the user did for that same project + let x = ::MaxEvaluationsPerUser::get(); + let (inst, project_id, extrinsic_evaluation, extrinsic_plmc_bonded, total_expected_plmc_bonded) = + evaluation_setup::(x); + + #[extrinsic_call] + evaluate(RawOrigin::Signed(extrinsic_evaluation.account.clone()), project_id, extrinsic_evaluation.usd_amount); + + evaluation_verification::( + inst, + project_id, + extrinsic_evaluation, + extrinsic_plmc_bonded, + total_expected_plmc_bonded, ); } @@ -1985,9 +2092,22 @@ mod benchmarks { } #[test] - fn bench_evaluate() { + fn bench_first_evaluation() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_first_evaluation()); + }); + } + #[test] + fn bench_second_to_limit_evaluation() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_second_to_limit_evaluation()); + }); + } + + #[test] + fn bench_evaluation_over_limit() { new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_evaluate()); + assert_ok!(PalletFunding::::test_evaluation_over_limit()); }); } diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 347f3ebb5..498907036 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -377,22 +377,16 @@ impl Pallet { // If this function was called inside the period, then it was called by the extrinsic and we need to // remove the scheduled automatic transition let mut remove_attempts: u32 = 0u32; - let mut average_vec_passes: u32 = 0u32; let mut insertion_attempts: u32 = 0u32; if now <= auction_initialize_period_end_block { match Self::remove_from_update_store(&project_id) { Ok(iterations) => { - remove_attempts = iterations.0; - average_vec_passes = iterations.1 + remove_attempts = iterations; }, Err(iterations) => return Err(DispatchErrorWithPostInfo { post_info: PostDispatchInfo { - actual_weight: Some(WeightInfoOf::::start_auction_manually( - 0u32, - iterations.0, - iterations.1, - )), + actual_weight: Some(WeightInfoOf::::start_auction_manually(0u32, iterations)), pays_fee: Pays::Yes, }, error: Error::::ProjectNotInUpdateStore.into(), @@ -409,13 +403,9 @@ impl Pallet { return Err(DispatchErrorWithPostInfo { post_info: PostDispatchInfo { actual_weight: if remove_attempts == 0u32 { - Some(WeightInfoOf::::start_auction_automatically(insertion_attempts)) + Some(WeightInfoOf::::start_auction_automatically()) } else { - Some(WeightInfoOf::::start_auction_manually( - insertion_attempts, - remove_attempts, - average_vec_passes, - )) + Some(WeightInfoOf::::start_auction_manually(insertion_attempts, remove_attempts)) }, pays_fee: Pays::Yes, }, @@ -428,9 +418,9 @@ impl Pallet { Ok(PostDispatchInfo { actual_weight: if remove_attempts == 0u32 { - Some(WeightInfoOf::::start_auction_automatically(insertion_attempts)) + Some(WeightInfoOf::::start_auction_automatically()) } else { - Some(WeightInfoOf::::start_auction_manually(insertion_attempts, remove_attempts, average_vec_passes)) + Some(WeightInfoOf::::start_auction_manually(insertion_attempts, remove_attempts)) }, pays_fee: Pays::Yes, }) @@ -853,7 +843,11 @@ impl Pallet { } // Note: usd_amount needs to have the same amount of decimals as PLMC,, so when multiplied by the plmc-usd price, it gives us the PLMC amount with the decimals we wanted. - pub fn do_evaluate(evaluator: &AccountIdOf, project_id: ProjectId, usd_amount: BalanceOf) -> DispatchResult { + pub fn do_evaluate( + evaluator: &AccountIdOf, + project_id: ProjectId, + usd_amount: BalanceOf, + ) -> DispatchResultWithPostInfo { // * Get variables * let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let now = >::block_number(); @@ -910,6 +904,9 @@ impl Pallet { } if caller_existing_evaluations.len() < T::MaxEvaluationsPerUser::get() as usize { + use frame_support::traits::fungible::Inspect; + + let dbg = T::NativeCurrency::balance(evaluator); T::NativeCurrency::hold(&HoldReason::Evaluation(project_id.into()).into(), evaluator, plmc_bond)?; } else { let (low_id, lowest_evaluation) = caller_existing_evaluations @@ -944,7 +941,16 @@ impl Pallet { // * Emit events * Self::deposit_event(Event::FundsBonded { project_id, amount: plmc_bond, bonder: evaluator.clone() }); - Ok(()) + let existing_evaluations_count = caller_existing_evaluations.len() as u32; + let actual_weight = if existing_evaluations_count == 0 { + WeightInfoOf::::first_evaluation() + } else if existing_evaluations_count < T::MaxEvaluationsPerUser::get() { + WeightInfoOf::::second_to_limit_evaluation(existing_evaluations_count) + } else { + WeightInfoOf::::evaluation_over_limit() + }; + + Ok(PostDispatchInfo { actual_weight: Some(actual_weight), pays_fee: Pays::Yes }) } /// Bid for a project in the bidding stage. @@ -2463,40 +2469,24 @@ impl Pallet { return Err(T::MaxProjectsToUpdateInsertionAttempts::get()) } - fn average_u32(numbers: Vec) -> u32 { - if numbers.is_empty() { - return 0 - } - - // Use u64 for the sum to prevent overflow. - let sum: u64 = numbers.iter().map(|&x| x as u64).sum(); - let count = numbers.len() as u64; - - // Perform the division in u64, then cast back to u32. - // This will naturally floor the division result. - sum.saturating_div(count) as u32 - } - // returns the actual iterations for weight calculation either as an Err type or Ok type so the caller can add that // to the corresponding weight function. - pub fn remove_from_update_store(project_id: &ProjectId) -> Result<(u32, u32), (u32, u32)> { + pub fn remove_from_update_store(project_id: &ProjectId) -> Result { // used for extrinsic weight calculation let mut total_iterations = 0u32; - let mut project_vec_lengths: Vec = Vec::new(); let (block_position, project_index) = ProjectsToUpdate::::iter() .find_map(|(block, project_vec)| { total_iterations += 1; - project_vec_lengths.push(project_vec.len() as u32); let project_index = project_vec.iter().position(|(id, _update_type)| id == project_id)?; Some((block, project_index)) }) - .ok_or((total_iterations, Self::average_u32(project_vec_lengths.clone())))?; + .ok_or(total_iterations)?; ProjectsToUpdate::::mutate(block_position, |project_vec| { project_vec.remove(project_index); }); - Ok((total_iterations, Self::average_u32(project_vec_lengths))) + Ok(total_iterations) } pub fn create_bucket_from_metadata(metadata: &ProjectMetadataOf) -> Result, DispatchError> { diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 89daf8ce6..81e58e6a7 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -869,11 +869,11 @@ impl< &mut self, project_id: ProjectId, bonds: Vec>, - ) -> Result<(), DispatchError> { + ) -> DispatchResultWithPostInfo { for UserToUSDBalance { account, usd_amount } in bonds { self.execute(|| crate::Pallet::::do_evaluate(&account, project_id, usd_amount))?; } - Ok(()) + Ok(().into()) } pub fn start_auction(&mut self, project_id: ProjectId, caller: AccountIdOf) -> Result<(), DispatchError> { diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index a42e9a6f9..6949afa03 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -973,7 +973,7 @@ pub mod pallet { /// institutional user can set bids for a token_amount/token_price pair. /// Any bids from this point until the candle_auction starts, will be considered as valid. #[pallet::call_index(3)] - #[pallet::weight(WeightInfoOf::::start_auction_manually(0u32, 0u32, 0u32))] + #[pallet::weight(WeightInfoOf::::start_auction_manually(::MaxProjectsToUpdateInsertionAttempts::get(), 10_000u32))] pub fn start_auction(origin: OriginFor, project_id: ProjectId) -> DispatchResultWithPostInfo { let issuer = ensure_signed(origin)?; Self::do_english_auction(issuer, project_id) @@ -981,12 +981,12 @@ pub mod pallet { /// Bond PLMC for a project in the evaluation stage #[pallet::call_index(4)] - #[pallet::weight(WeightInfoOf::::evaluate())] + #[pallet::weight(WeightInfoOf::::evaluation_over_limit())] pub fn evaluate( origin: OriginFor, project_id: ProjectId, #[pallet::compact] usd_amount: BalanceOf, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { let evaluator = ensure_signed(origin)?; Self::do_evaluate(&evaluator, project_id, usd_amount) } diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index 4d814a740..a53b85ae5 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -54,9 +54,11 @@ pub trait WeightInfo { fn create() -> Weight; fn edit_metadata() -> Weight; fn start_evaluation(x: u32) -> Weight; - fn start_auction_manually(x: u32, y: u32, z: u32) -> Weight; - fn start_auction_automatically(x: u32) -> Weight; - fn evaluate() -> Weight; + fn start_auction_manually(x: u32, y: u32) -> Weight; + fn start_auction_automatically() -> Weight; + fn first_evaluation() -> Weight; + fn second_to_limit_evaluation(x: u32) -> Weight; + fn evaluation_over_limit() -> Weight; fn bid() -> Weight; fn contribute() -> Weight; fn evaluation_unbond_for() -> Weight; @@ -125,30 +127,23 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } - fn start_auction_manually(x: u32, y: u32, z: u32) -> Weight { + fn start_auction_manually(x: u32, y: u32) -> Weight { Zero::zero() } - fn start_auction_automatically(x: u32) -> Weight { + fn start_auction_automatically() -> Weight { Zero::zero() } - /// Storage: PolimecFunding ProjectsDetails (r:1 w:1) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding NextEvaluationId (r:1 w:1) - /// Proof Skipped: PolimecFunding NextEvaluationId (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: PolimecFunding Evaluations (r:1 w:1) - /// Proof Skipped: PolimecFunding Evaluations (max_values: None, max_size: None, mode: Measured) - /// Storage: Balances Holds (r:1 w:1) - /// Proof: Balances Holds (max_values: None, max_size: Some(1099), added: 3574, mode: MaxEncodedLen) - fn evaluate() -> Weight { - // Proof Size summary in bytes: - // Measured: `428` - // Estimated: `4564` - // Minimum execution time: 53_000_000 picoseconds. - Weight::from_parts(58_000_000, 4564) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) - } + + fn first_evaluation() -> Weight { + Weight::from_parts(20_000_000, 3932) } + + fn second_to_limit_evaluation(x: u32) -> Weight { + Weight::from_parts(20_000_000, 3932) } + + fn evaluation_over_limit() -> Weight { + Weight::from_parts(20_000_000, 3932) } + /// Storage: PolimecFunding ProjectsMetadata (r:1 w:0) /// Proof Skipped: PolimecFunding ProjectsMetadata (max_values: None, max_size: None, mode: Measured) /// Storage: PolimecFunding ProjectsDetails (r:1 w:0) diff --git a/pallets/linear-release/src/benchmarking.rs b/pallets/linear-release/src/benchmarking.rs index 319425d2a..f31a9905e 100644 --- a/pallets/linear-release/src/benchmarking.rs +++ b/pallets/linear-release/src/benchmarking.rs @@ -29,7 +29,7 @@ use sp_runtime::traits::{CheckedDiv, CheckedMul}; const SEED: u32 = 0; fn add_holds(who: &T::AccountId, n: u32) { - for id in 0..n { + for _id in 0..n { let locked = 256u32; let reason: ReasonOf = T::BenchmarkReason::get(); let _ = T::Currency::hold(&reason, who, locked.into()); From b3bde81eb6ca437ab5666d9cab56c436e50e69d2 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 24 Jan 2024 13:41:15 +0100 Subject: [PATCH 140/212] save contributions extrinsic Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 102 ++++++++++++++++++---------- pallets/funding/src/functions.rs | 12 ++-- 2 files changed, 71 insertions(+), 43 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 59753f76a..345a30132 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -824,6 +824,10 @@ mod benchmarks { ); } + // branches: + // - ct account deposit + // - amount of times where `perform_bid` is called (i.e how many buckets) + // - reached max bids and needs to unbond one #[benchmark] fn bid(x: Linear<1, 20>) { // * setup * @@ -932,28 +936,14 @@ mod benchmarks { ); } - #[benchmark] - // assume for now community contribution - fn contribute( - // Existing projects count - a: Linear<1, 10>, - // // Evaluations count - // b: Linear<1, 10>, - // // Bids count - // c: Linear<1, 10>, - // // Community contributions count - // d: Linear<1, 10>, - // // User contributions count - // e: Linear<1, 10>, - ) { + fn contribution_setup( + x: u32, + ) -> (BenchInstantiator, ProjectId, UserToUSDBalance, BalanceOf, BalanceOf) { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(a, inst); - let issuer = account::>("issuer", 0, 0); let contributor = account::>("contributor", 0, 0); whitelist_account!(contributor); @@ -969,31 +959,51 @@ mod benchmarks { let price = inst.get_project_details(project_id).weighted_average_price.unwrap(); - let contribution_params = + let existing_contribution = + ContributionParams::new(contributor.clone(), (50 * ASSET_UNIT).into(), 1u8, AcceptedFundingAsset::USDT); + let extrinsic_contribution = ContributionParams::new(contributor.clone(), (100 * ASSET_UNIT).into(), 1u8, AcceptedFundingAsset::USDT); - let necessary_plmc = - BenchInstantiator::::calculate_contributed_plmc_spent(vec![contribution_params.clone()], price); - let existential_deposits: Vec> = necessary_plmc.accounts().existential_deposits(); - let ct_account_deposits: Vec> = necessary_plmc.accounts().ct_account_deposits(); - let necessary_usdt = - BenchInstantiator::::calculate_contributed_funding_asset_spent(vec![contribution_params.clone()], price); + let existing_contributions = vec![existing_contribution; x as usize]; - inst.mint_plmc_to(necessary_plmc.clone()); + let plmc_for_existing_contributions = + BenchInstantiator::::calculate_contributed_plmc_spent(existing_contributions.clone(), price); + let plmc_for_extrinsic_contribution = + BenchInstantiator::::calculate_contributed_plmc_spent(vec![extrinsic_contribution.clone()], price); + let usdt_for_existing_contributions = + BenchInstantiator::::calculate_contributed_funding_asset_spent(existing_contributions.clone(), price); + let usdt_for_extrinsic_contribution = BenchInstantiator::::calculate_contributed_funding_asset_spent( + vec![extrinsic_contribution.clone()], + price, + ); + + let existential_deposits: Vec> = + plmc_for_extrinsic_contribution.accounts().existential_deposits(); + let ct_account_deposits: Vec> = + plmc_for_extrinsic_contribution.accounts().ct_account_deposits(); + + inst.mint_plmc_to(plmc_for_existing_contributions.clone()); + inst.mint_plmc_to(plmc_for_extrinsic_contribution.clone()); inst.mint_plmc_to(existential_deposits.clone()); inst.mint_plmc_to(ct_account_deposits.clone()); - inst.mint_statemint_asset_to(necessary_usdt.clone()); + inst.mint_statemint_asset_to(usdt_for_existing_contributions.clone()); + inst.mint_statemint_asset_to(usdt_for_extrinsic_contribution.clone()); - let contribution_id = NextContributionId::::get(); + // do "x" contributions for this user + inst.bond_for_users(project_id, existing_contributions).expect("All evaluations are accepted"); - #[extrinsic_call] - contribute( - RawOrigin::Signed(contributor.clone()), - project_id, - contribution_params.amount, - contribution_params.multiplier, - contribution_params.asset, - ); + let total_plmc_bonded = BenchInstantiator::::sum_balance_mappings(vec![ + plmc_for_existing_contributions.clone(), + plmc_for_extrinsic_contribution.clone(), + ]); + let total_usdt_locked = BenchInstantiator::::sum_balance_mappings(vec![ + usdt_for_existing_contributions.clone(), + usdt_for_extrinsic_contribution.clone(), + ]); + + (inst, project_id, extrinsic_contribution, total_plmc_bonded, total_usdt_locked) + } + fn contribution_verification() { // * validity checks * // Storage let stored_contribution = Contributions::::iter_prefix_values((project_id, contributor.clone())) @@ -1018,8 +1028,6 @@ mod benchmarks { }; assert_eq!(stored_contribution, contribution); - assert_eq!(NextContributionId::::get(), contribution_id.saturating_add(One::one())); - let stored_project_details = ProjectsDetails::::get(project_id).unwrap(); assert_eq!( @@ -1052,6 +1060,26 @@ mod benchmarks { ); } + // branches: + // - ct account deposit + // - contribution over limit + // - if last ct sold, automatic transition to failed removed, and automatic transition to success inserted + #[benchmark] + // assume for now community contribution + fn contribute( + // How many other contributions the user did for that same project + x: Linear<1, { T::MaxContributionsPerUser::get() - 1 }>, + ) { + #[extrinsic_call] + contribute( + RawOrigin::Signed(contributor.clone()), + project_id, + contribution_params.amount, + contribution_params.multiplier, + contribution_params.asset, + ); + } + #[benchmark] fn evaluation_unbond_for(x: Linear<1, 20>) { // setup diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 498907036..19f0daa58 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -906,7 +906,6 @@ impl Pallet { if caller_existing_evaluations.len() < T::MaxEvaluationsPerUser::get() as usize { use frame_support::traits::fungible::Inspect; - let dbg = T::NativeCurrency::balance(evaluator); T::NativeCurrency::hold(&HoldReason::Evaluation(project_id.into()).into(), evaluator, plmc_bond)?; } else { let (low_id, lowest_evaluation) = caller_existing_evaluations @@ -949,7 +948,7 @@ impl Pallet { } else { WeightInfoOf::::evaluation_over_limit() }; - + // Ok(PostDispatchInfo { actual_weight: Some(actual_weight), pays_fee: Pays::Yes }) } @@ -978,6 +977,7 @@ impl Pallet { let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; let plmc_usd_price = T::PriceProvider::get_price(PLMC_STATEMINT_ID).ok_or(Error::::PriceNotFound)?; let ct_deposit = T::ContributionTokenCurrency::deposit_required(project_id); + // benchmark variables // * Validity checks * ensure!(ct_amount > Zero::zero(), Error::::BidTooLow); @@ -1142,7 +1142,8 @@ impl Pallet { let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let ct_deposit = T::ContributionTokenCurrency::deposit_required(project_id); - + let caller_existing_contributions = + Contributions::::iter_prefix_values((project_id, contributor)).collect::>(); // * Validity checks * ensure!(project_metadata.participation_currencies == asset, Error::::FundingAssetNotAccepted); ensure!(contributor.clone() != project_details.issuer, Error::::ContributionToThemselves); @@ -1205,9 +1206,7 @@ impl Pallet { } // Try adding the new contribution to the system - let existing_contributions = - Contributions::::iter_prefix_values((project_id, contributor)).collect::>(); - if existing_contributions.len() < T::MaxContributionsPerUser::get() as usize { + if caller_existing_contributions.len() < T::MaxContributionsPerUser::get() as usize { Self::try_plmc_participation_lock(contributor, project_id, plmc_bond)?; Self::try_funding_asset_hold(contributor, project_id, funding_asset_amount, asset_id)?; } else { @@ -1267,6 +1266,7 @@ impl Pallet { // If no CTs remain, end the funding phase if remaining_cts_after_purchase.is_zero() { // TODO: return real weights + // remove the remainder transition or the funding failed transition let iterations = match Self::remove_from_update_store(&project_id) { Ok(iterations) => iterations, Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), From b3c3c547ed9649b0ef3166252b243e94b199cdef Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 24 Jan 2024 15:37:01 +0100 Subject: [PATCH 141/212] contribution logic split into separate functions Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 58 ++++++++++++++++++----------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 345a30132..0bb26df56 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -938,7 +938,13 @@ mod benchmarks { fn contribution_setup( x: u32, - ) -> (BenchInstantiator, ProjectId, UserToUSDBalance, BalanceOf, BalanceOf) { + ) -> (BenchInstantiator, ProjectId, UserToUSDBalance, BalanceOf, BalanceOf) + where + ::Balance: From, + ::Price: From, + T::Hash: From, + ::RuntimeEvent: From>, + { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 @@ -1003,47 +1009,55 @@ mod benchmarks { (inst, project_id, extrinsic_contribution, total_plmc_bonded, total_usdt_locked) } - fn contribution_verification() { + fn contribution_verification( + mut inst: BenchInstantiator, + project_id: ProjectId, + extrinsic_contribution: ContributionParams, + total_plmc_bonded: BalanceOf, + total_usdt_locked: BalanceOf, + ) where + ::Balance: From, + ::Price: From, + T::Hash: From, + ::RuntimeEvent: From>, + { // * validity checks * // Storage + let contributor = extrinsic_contribution.contributor.clone(); let stored_contribution = Contributions::::iter_prefix_values((project_id, contributor.clone())) .sorted_by(|a, b| a.id.cmp(&b.id)) .last() .unwrap(); - let contribution = ContributionInfoOf:: { - id: contribution_id, - project_id, - contributor: contributor.clone(), - ct_amount: contribution_params.amount, - usd_contribution_amount: necessary_usdt[0].asset_amount, - multiplier: contribution_params.multiplier, - funding_asset: contribution_params.asset, - funding_asset_amount: necessary_usdt[0].asset_amount, - plmc_bond: necessary_plmc[0].plmc_amount, - plmc_vesting_info: None, - funds_released: false, - ct_minted: false, - ct_migration_status: MigrationStatus::NotStarted, - }; - assert_eq!(stored_contribution, contribution); + match stored_contribution { + ContributionInfoOf:: { project_id, contributor, ct_amount, .. } + if project_id == project_id && + contributor == contributor && + ct_amount == extrinsic_contribution.amount => {}, + _ => assert!(false, "Contribution is not stored correctly"), + } let stored_project_details = ProjectsDetails::::get(project_id).unwrap(); assert_eq!( stored_project_details.remaining_contribution_tokens.1, - project_metadata.total_allocation_size.1.saturating_sub(contribution_params.amount) + project_metadata.total_allocation_size.1.saturating_sub(extrinsic_contribution.amount) ); // Balances let bonded_plmc = inst .get_reserved_plmc_balances_for(vec![contributor.clone()], HoldReason::Participation(project_id).into())[0] .plmc_amount; - assert_eq!(bonded_plmc, necessary_plmc[0].plmc_amount); + assert_eq!(bonded_plmc, total_plmc_bonded); let free_plmc = inst.get_free_plmc_balances_for(vec![contributor.clone()])[0].plmc_amount; assert_eq!(free_plmc, existential_deposits[0].plmc_amount); + let escrow_account = Pallet::::fund_account_id(project_id); + let locked_usdt = + inst.get_free_statemint_asset_balances_for(usdt_id(), vec![escrow_account.clone()])[0].asset_amount; + assert_eq!(locked_usdt, total_usdt_locked); + let free_usdt = inst.get_free_statemint_asset_balances_for(usdt_id(), vec![contributor.clone()])[0].asset_amount; assert_eq!(free_usdt, 0.into()); @@ -1053,8 +1067,8 @@ mod benchmarks { Event::Contribution { project_id, contributor, - amount: contribution_params.amount, - multiplier: contribution_params.multiplier, + amount: extrinsic_contribution.amount, + multiplier: extrinsic_contribution.multiplier, } .into(), ); From 4adf12464691b2455b095cce8ac8fc788dea3277 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 24 Jan 2024 16:26:10 +0100 Subject: [PATCH 142/212] all contribution bench branches coded. Missing single tests and using those weights in the contribute extrinsic Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 197 +++++++++++++++++++++++++--- pallets/funding/src/functions.rs | 2 +- 2 files changed, 180 insertions(+), 19 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 0bb26df56..bcec924e4 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -938,7 +938,8 @@ mod benchmarks { fn contribution_setup( x: u32, - ) -> (BenchInstantiator, ProjectId, UserToUSDBalance, BalanceOf, BalanceOf) + ends_round: bool, + ) -> (BenchInstantiator, ProjectId, ProjectMetadataOf, ContributionParams, BalanceOf, BalanceOf) where ::Balance: From, ::Price: From, @@ -965,10 +966,16 @@ mod benchmarks { let price = inst.get_project_details(project_id).weighted_average_price.unwrap(); + let existing_amount: BalanceOf = (50 * ASSET_UNIT).into(); + let extrinsic_amount: BalanceOf = if ends_round { + project_metadata.total_allocation_size.0 - existing_amount * (x as u128).into() + } else { + (100 * ASSET_UNIT).into() + }; let existing_contribution = - ContributionParams::new(contributor.clone(), (50 * ASSET_UNIT).into(), 1u8, AcceptedFundingAsset::USDT); + ContributionParams::new(contributor.clone(), existing_amount, 1u8, AcceptedFundingAsset::USDT); let extrinsic_contribution = - ContributionParams::new(contributor.clone(), (100 * ASSET_UNIT).into(), 1u8, AcceptedFundingAsset::USDT); + ContributionParams::new(contributor.clone(), extrinsic_amount, 1u8, AcceptedFundingAsset::USDT); let existing_contributions = vec![existing_contribution; x as usize]; let plmc_for_existing_contributions = @@ -995,23 +1002,24 @@ mod benchmarks { inst.mint_statemint_asset_to(usdt_for_extrinsic_contribution.clone()); // do "x" contributions for this user - inst.bond_for_users(project_id, existing_contributions).expect("All evaluations are accepted"); + inst.contribute_for_users(project_id, existing_contributions).expect("All evaluations are accepted"); let total_plmc_bonded = BenchInstantiator::::sum_balance_mappings(vec![ plmc_for_existing_contributions.clone(), plmc_for_extrinsic_contribution.clone(), ]); - let total_usdt_locked = BenchInstantiator::::sum_balance_mappings(vec![ + let total_usdt_locked = BenchInstantiator::::sum_statemint_mappings(vec![ usdt_for_existing_contributions.clone(), usdt_for_extrinsic_contribution.clone(), ]); - (inst, project_id, extrinsic_contribution, total_plmc_bonded, total_usdt_locked) + (inst, project_id, project_metadata, extrinsic_contribution, total_plmc_bonded, total_usdt_locked) } fn contribution_verification( mut inst: BenchInstantiator, project_id: ProjectId, + project_metadata: ProjectMetadataOf, extrinsic_contribution: ContributionParams, total_plmc_bonded: BalanceOf, total_usdt_locked: BalanceOf, @@ -1051,7 +1059,7 @@ mod benchmarks { assert_eq!(bonded_plmc, total_plmc_bonded); let free_plmc = inst.get_free_plmc_balances_for(vec![contributor.clone()])[0].plmc_amount; - assert_eq!(free_plmc, existential_deposits[0].plmc_amount); + assert_eq!(free_plmc, Zero::zero()); let escrow_account = Pallet::::fund_account_id(project_id); let locked_usdt = @@ -1060,7 +1068,7 @@ mod benchmarks { let free_usdt = inst.get_free_statemint_asset_balances_for(usdt_id(), vec![contributor.clone()])[0].asset_amount; - assert_eq!(free_usdt, 0.into()); + assert_eq!(free_usdt, Zero::zero()); // Events frame_system::Pallet::::assert_last_event( @@ -1074,26 +1082,179 @@ mod benchmarks { ); } - // branches: - // - ct account deposit - // - contribution over limit - // - if last ct sold, automatic transition to failed removed, and automatic transition to success inserted #[benchmark] - // assume for now community contribution - fn contribute( + fn first_contribution() { + // How many other contributions the user did for that same project + let x = 0; + let ends_round = false; + + let (inst, project_id, project_metadata, extrinsic_contribution, total_plmc_bonded, total_usdt_locked) = + contribution_setup::(x, ends_round); + + #[extrinsic_call] + contribute( + RawOrigin::Signed(extrinsic_contribution.contributor.clone()), + project_id, + extrinsic_contribution.amount, + extrinsic_contribution.multiplier, + extrinsic_contribution.asset, + ); + + contribution_verification::( + inst, + project_id, + project_metadata, + extrinsic_contribution, + total_plmc_bonded, + total_usdt_locked, + ); + } + #[benchmark] + fn first_contribution_ends_round() { + // How many other contributions the user did for that same project + let x = 0; + let ends_round = true; + let (inst, project_id, project_metadata, extrinsic_contribution, total_plmc_bonded, total_usdt_locked) = + contribution_setup::(x, ends_round); + + #[extrinsic_call] + contribute( + RawOrigin::Signed(extrinsic_contribution.contributor.clone()), + project_id, + extrinsic_contribution.amount, + extrinsic_contribution.multiplier, + extrinsic_contribution.asset, + ); + + contribution_verification::( + inst, + project_id, + project_metadata, + extrinsic_contribution, + total_plmc_bonded, + total_usdt_locked, + ); + } + + #[benchmark] + fn second_to_limit_contribution( // How many other contributions the user did for that same project x: Linear<1, { T::MaxContributionsPerUser::get() - 1 }>, ) { + let ends_round = false; + + let (inst, project_id, project_metadata, extrinsic_contribution, total_plmc_bonded, total_usdt_locked) = + contribution_setup::(x, ends_round); + #[extrinsic_call] contribute( - RawOrigin::Signed(contributor.clone()), + RawOrigin::Signed(extrinsic_contribution.contributor.clone()), + project_id, + extrinsic_contribution.amount, + extrinsic_contribution.multiplier, + extrinsic_contribution.asset, + ); + + contribution_verification::( + inst, + project_id, + project_metadata, + extrinsic_contribution, + total_plmc_bonded, + total_usdt_locked, + ); + } + + #[benchmark] + fn second_to_limit_contribution_ends_round( + // How many other contributions the user did for that same project + x: Linear<1, { T::MaxContributionsPerUser::get() - 1 }>, + ) { + let ends_round = true; + + let (inst, project_id, project_metadata, extrinsic_contribution, total_plmc_bonded, total_usdt_locked) = + contribution_setup::(x, ends_round); + + #[extrinsic_call] + contribute( + RawOrigin::Signed(extrinsic_contribution.contributor.clone()), + project_id, + extrinsic_contribution.amount, + extrinsic_contribution.multiplier, + extrinsic_contribution.asset, + ); + + contribution_verification::( + inst, + project_id, + project_metadata, + extrinsic_contribution, + total_plmc_bonded, + total_usdt_locked, + ); + } + + #[benchmark] + fn contribution_over_limit() { + // How many other contributions the user did for that same project + let x = ::MaxContributionsPerUser::get(); + let ends_round = false; + + let (inst, project_id, project_metadata, extrinsic_contribution, total_plmc_bonded, total_usdt_locked) = + contribution_setup::(x, ends_round); + + #[extrinsic_call] + contribute( + RawOrigin::Signed(extrinsic_contribution.contributor.clone()), project_id, - contribution_params.amount, - contribution_params.multiplier, - contribution_params.asset, + extrinsic_contribution.amount, + extrinsic_contribution.multiplier, + extrinsic_contribution.asset, + ); + + contribution_verification::( + inst, + project_id, + project_metadata, + extrinsic_contribution, + total_plmc_bonded, + total_usdt_locked, ); } + #[benchmark] + fn contribution_over_limit_ends_round() { + // How many other contributions the user did for that same project + let x = ::MaxContributionsPerUser::get(); + let ends_round = true; + + let (inst, project_id, project_metadata, extrinsic_contribution, total_plmc_bonded, total_usdt_locked) = + contribution_setup::(x, ends_round); + + #[extrinsic_call] + contribute( + RawOrigin::Signed(extrinsic_contribution.contributor.clone()), + project_id, + extrinsic_contribution.amount, + extrinsic_contribution.multiplier, + extrinsic_contribution.asset, + ); + + contribution_verification::( + inst, + project_id, + project_metadata, + extrinsic_contribution, + total_plmc_bonded, + total_usdt_locked, + ); + } + + // branches: + // - ct account deposit + // - contribution over limit + // - if last ct sold, automatic transition to failed removed, and automatic transition to success inserted + #[benchmark] fn evaluation_unbond_for(x: Linear<1, 20>) { // setup diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 19f0daa58..2fe38bcad 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -1210,7 +1210,7 @@ impl Pallet { Self::try_plmc_participation_lock(contributor, project_id, plmc_bond)?; Self::try_funding_asset_hold(contributor, project_id, funding_asset_amount, asset_id)?; } else { - let lowest_contribution = existing_contributions + let lowest_contribution = caller_existing_contributions .iter() .min_by_key(|contribution| contribution.plmc_bond) .ok_or(Error::::ImpossibleState)?; From c568fab56db5fbd0b0674ebee63152b306237c5b Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 25 Jan 2024 12:03:30 +0100 Subject: [PATCH 143/212] contribute benches tested and passing. Missing real benchmarking and adding the correct weights on the extrinsic Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 197 ++++++++++++++++++++++++---- 1 file changed, 175 insertions(+), 22 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index bcec924e4..0f3bcd23e 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -761,7 +761,7 @@ mod benchmarks { // - We know that it requires a ct deposit // - We know that it does not require to unbond the lowest evaluation #[benchmark] - fn first_evaluation() { + pub fn first_evaluation() { // How many other evaluations the user did for that same project let x = 0; let (inst, project_id, extrinsic_evaluation, extrinsic_plmc_bonded, total_expected_plmc_bonded) = @@ -939,7 +939,17 @@ mod benchmarks { fn contribution_setup( x: u32, ends_round: bool, - ) -> (BenchInstantiator, ProjectId, ProjectMetadataOf, ContributionParams, BalanceOf, BalanceOf) + ) -> ( + BenchInstantiator, + ProjectId, + ProjectMetadataOf, + ContributionParams, + BalanceOf, + BalanceOf, + BalanceOf, + BalanceOf, + BalanceOf, + ) where ::Balance: From, ::Price: From, @@ -978,6 +988,8 @@ mod benchmarks { ContributionParams::new(contributor.clone(), extrinsic_amount, 1u8, AcceptedFundingAsset::USDT); let existing_contributions = vec![existing_contribution; x as usize]; + let mut total_ct_sold: BalanceOf = existing_amount * (x as u128).into() + extrinsic_amount; + let plmc_for_existing_contributions = BenchInstantiator::::calculate_contributed_plmc_spent(existing_contributions.clone(), price); let plmc_for_extrinsic_contribution = @@ -994,6 +1006,10 @@ mod benchmarks { let ct_account_deposits: Vec> = plmc_for_extrinsic_contribution.accounts().ct_account_deposits(); + let escrow_account = Pallet::::fund_account_id(project_id); + let prev_total_usdt_locked = + inst.get_free_statemint_asset_balances_for(usdt_id(), vec![escrow_account.clone()]); + inst.mint_plmc_to(plmc_for_existing_contributions.clone()); inst.mint_plmc_to(plmc_for_extrinsic_contribution.clone()); inst.mint_plmc_to(existential_deposits.clone()); @@ -1004,16 +1020,43 @@ mod benchmarks { // do "x" contributions for this user inst.contribute_for_users(project_id, existing_contributions).expect("All evaluations are accepted"); - let total_plmc_bonded = BenchInstantiator::::sum_balance_mappings(vec![ + let mut total_plmc_bonded = BenchInstantiator::::sum_balance_mappings(vec![ plmc_for_existing_contributions.clone(), plmc_for_extrinsic_contribution.clone(), ]); - let total_usdt_locked = BenchInstantiator::::sum_statemint_mappings(vec![ + let mut total_usdt_locked = BenchInstantiator::::sum_statemint_mappings(vec![ + prev_total_usdt_locked, usdt_for_existing_contributions.clone(), usdt_for_extrinsic_contribution.clone(), ]); - (inst, project_id, project_metadata, extrinsic_contribution, total_plmc_bonded, total_usdt_locked) + let over_limit_count = x.saturating_sub(::MaxContributionsPerUser::get() - 1); + + let mut total_free_plmc = existential_deposits[0].plmc_amount; + let mut total_free_usdt = Zero::zero(); + + if x > 0 { + let plmc_returned = plmc_for_existing_contributions[0].plmc_amount * (over_limit_count as u128).into(); + total_plmc_bonded -= plmc_returned; + + let usdt_returned = usdt_for_existing_contributions[0].asset_amount * (over_limit_count as u128).into(); + total_usdt_locked -= usdt_returned; + total_ct_sold -= existing_amount * (over_limit_count as u128).into(); + total_free_plmc += plmc_returned; + total_free_usdt += usdt_returned; + } + + ( + inst, + project_id, + project_metadata, + extrinsic_contribution, + total_free_plmc, + total_plmc_bonded, + total_free_usdt, + total_usdt_locked, + total_ct_sold, + ) } fn contribution_verification( @@ -1021,8 +1064,11 @@ mod benchmarks { project_id: ProjectId, project_metadata: ProjectMetadataOf, extrinsic_contribution: ContributionParams, + total_free_plmc: BalanceOf, total_plmc_bonded: BalanceOf, + total_free_usdt: BalanceOf, total_usdt_locked: BalanceOf, + total_ct_sold: BalanceOf, ) where ::Balance: From, ::Price: From, @@ -1049,7 +1095,7 @@ mod benchmarks { assert_eq!( stored_project_details.remaining_contribution_tokens.1, - project_metadata.total_allocation_size.1.saturating_sub(extrinsic_contribution.amount) + project_metadata.total_allocation_size.1.saturating_sub(total_ct_sold) ); // Balances @@ -1059,7 +1105,7 @@ mod benchmarks { assert_eq!(bonded_plmc, total_plmc_bonded); let free_plmc = inst.get_free_plmc_balances_for(vec![contributor.clone()])[0].plmc_amount; - assert_eq!(free_plmc, Zero::zero()); + assert_eq!(free_plmc, total_free_plmc); let escrow_account = Pallet::::fund_account_id(project_id); let locked_usdt = @@ -1068,7 +1114,7 @@ mod benchmarks { let free_usdt = inst.get_free_statemint_asset_balances_for(usdt_id(), vec![contributor.clone()])[0].asset_amount; - assert_eq!(free_usdt, Zero::zero()); + assert_eq!(free_usdt, total_free_usdt); // Events frame_system::Pallet::::assert_last_event( @@ -1088,8 +1134,17 @@ mod benchmarks { let x = 0; let ends_round = false; - let (inst, project_id, project_metadata, extrinsic_contribution, total_plmc_bonded, total_usdt_locked) = - contribution_setup::(x, ends_round); + let ( + inst, + project_id, + project_metadata, + extrinsic_contribution, + total_free_plmc, + total_plmc_bonded, + total_free_usdt, + total_usdt_locked, + total_ct_sold, + ) = contribution_setup::(x, ends_round); #[extrinsic_call] contribute( @@ -1105,8 +1160,11 @@ mod benchmarks { project_id, project_metadata, extrinsic_contribution, + total_free_plmc, total_plmc_bonded, + total_free_usdt, total_usdt_locked, + total_ct_sold, ); } #[benchmark] @@ -1114,8 +1172,17 @@ mod benchmarks { // How many other contributions the user did for that same project let x = 0; let ends_round = true; - let (inst, project_id, project_metadata, extrinsic_contribution, total_plmc_bonded, total_usdt_locked) = - contribution_setup::(x, ends_round); + let ( + inst, + project_id, + project_metadata, + extrinsic_contribution, + total_free_plmc, + total_plmc_bonded, + total_free_usdt, + total_usdt_locked, + total_ct_sold, + ) = contribution_setup::(x, ends_round); #[extrinsic_call] contribute( @@ -1131,8 +1198,11 @@ mod benchmarks { project_id, project_metadata, extrinsic_contribution, + total_free_plmc, total_plmc_bonded, + total_free_usdt, total_usdt_locked, + total_ct_sold, ); } @@ -1143,8 +1213,17 @@ mod benchmarks { ) { let ends_round = false; - let (inst, project_id, project_metadata, extrinsic_contribution, total_plmc_bonded, total_usdt_locked) = - contribution_setup::(x, ends_round); + let ( + inst, + project_id, + project_metadata, + extrinsic_contribution, + total_free_plmc, + total_plmc_bonded, + total_free_usdt, + total_usdt_locked, + total_ct_sold, + ) = contribution_setup::(x, ends_round); #[extrinsic_call] contribute( @@ -1160,8 +1239,11 @@ mod benchmarks { project_id, project_metadata, extrinsic_contribution, + total_free_plmc, total_plmc_bonded, + total_free_usdt, total_usdt_locked, + total_ct_sold, ); } @@ -1172,8 +1254,17 @@ mod benchmarks { ) { let ends_round = true; - let (inst, project_id, project_metadata, extrinsic_contribution, total_plmc_bonded, total_usdt_locked) = - contribution_setup::(x, ends_round); + let ( + inst, + project_id, + project_metadata, + extrinsic_contribution, + total_free_plmc, + total_plmc_bonded, + total_free_usdt, + total_usdt_locked, + total_ct_sold, + ) = contribution_setup::(x, ends_round); #[extrinsic_call] contribute( @@ -1189,8 +1280,11 @@ mod benchmarks { project_id, project_metadata, extrinsic_contribution, + total_free_plmc, total_plmc_bonded, + total_free_usdt, total_usdt_locked, + total_ct_sold, ); } @@ -1200,8 +1294,17 @@ mod benchmarks { let x = ::MaxContributionsPerUser::get(); let ends_round = false; - let (inst, project_id, project_metadata, extrinsic_contribution, total_plmc_bonded, total_usdt_locked) = - contribution_setup::(x, ends_round); + let ( + inst, + project_id, + project_metadata, + extrinsic_contribution, + total_free_plmc, + total_plmc_bonded, + total_free_usdt, + total_usdt_locked, + total_ct_sold, + ) = contribution_setup::(x, ends_round); #[extrinsic_call] contribute( @@ -1217,8 +1320,11 @@ mod benchmarks { project_id, project_metadata, extrinsic_contribution, + total_free_plmc, total_plmc_bonded, + total_free_usdt, total_usdt_locked, + total_ct_sold, ); } @@ -1228,8 +1334,17 @@ mod benchmarks { let x = ::MaxContributionsPerUser::get(); let ends_round = true; - let (inst, project_id, project_metadata, extrinsic_contribution, total_plmc_bonded, total_usdt_locked) = - contribution_setup::(x, ends_round); + let ( + inst, + project_id, + project_metadata, + extrinsic_contribution, + total_free_plmc, + total_plmc_bonded, + total_free_usdt, + total_usdt_locked, + total_ct_sold, + ) = contribution_setup::(x, ends_round); #[extrinsic_call] contribute( @@ -1245,8 +1360,11 @@ mod benchmarks { project_id, project_metadata, extrinsic_contribution, + total_free_plmc, total_plmc_bonded, + total_free_usdt, total_usdt_locked, + total_ct_sold, ); } @@ -2336,9 +2454,44 @@ mod benchmarks { } #[test] - fn bench_contribute() { + fn bench_first_contribution() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_first_contribution()); + }); + } + + #[test] + fn bench_first_contribution_ends_round() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_first_contribution_ends_round()); + }); + } + + #[test] + fn bench_second_to_limit_contribution() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_second_to_limit_contribution()); + }); + } + + #[test] + fn bench_second_to_limit_contribution_ends_round() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_second_to_limit_contribution_ends_round()); + }); + } + + #[test] + fn bench_contribution_over_limit() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_contribution_over_limit()); + }); + } + + #[test] + fn bench_contribution_over_limit_ends_round() { new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_contribute()); + assert_ok!(PalletFunding::::test_contribution_over_limit_ends_round()); }); } From 24debe6ae9b6a3ea7d21d1e9a28d4dc481ad441a Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 26 Jan 2024 10:38:34 +0100 Subject: [PATCH 144/212] contribution_over_limit_ends_round removed since that case never happens Signed-off-by: Juan Ignacio Rios --- debug_weight_gen.rs | 199 ++++++++++++++++++++++------ pallets/funding/src/benchmarking.rs | 74 ++++------- 2 files changed, 183 insertions(+), 90 deletions(-) diff --git a/debug_weight_gen.rs b/debug_weight_gen.rs index 1af778286..2d9e7f52f 100644 --- a/debug_weight_gen.rs +++ b/debug_weight_gen.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `pallet_funding` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-01-23, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-01-25, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `Juans-MacBook-Pro.local`, CPU: `` //! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: 1024 @@ -15,7 +15,7 @@ // --steps=20 // --repeat=10 // --pallet=pallet_funding -// --extrinsic=first_evaluation,second_to_limit_evaluation,evaluation_over_limit +// --extrinsic=first_contribution, first_contribution_ends_round, second_to_limit_contribution, second_to_limit_contribution_ends_round, contribution_over_limit, contribution_over_limit_ends_round // --output // ./debug_weight_gen.rs @@ -30,69 +30,186 @@ use core::marker::PhantomData; /// Weight functions for `pallet_funding`. pub struct WeightInfo(PhantomData); impl pallet_funding::WeightInfo for WeightInfo { + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) - /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:1 w:0) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn first_contribution() -> Weight { + // Proof Size summary in bytes: + // Measured: `1996` + // Estimated: `6208` + // Minimum execution time: 2_110_000_000 picoseconds. + Weight::from_parts(2_217_000_000, 0) + .saturating_add(Weight::from_parts(0, 6208)) + .saturating_add(T::DbWeight::get().reads(11)) + .saturating_add(T::DbWeight::get().writes(7)) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Balances::Holds` (r:1 w:1) /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - fn first_evaluation() -> Weight { + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:3 w:2) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + fn first_contribution_ends_round() -> Weight { // Proof Size summary in bytes: - // Measured: `676` - // Estimated: `4614` - // Minimum execution time: 1_398_000_000 picoseconds. - Weight::from_parts(1_451_000_000, 0) - .saturating_add(Weight::from_parts(0, 4614)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) + // Measured: `2010` + // Estimated: `10281` + // Minimum execution time: 2_279_000_000 picoseconds. + Weight::from_parts(2_358_000_000, 0) + .saturating_add(Weight::from_parts(0, 10281)) + .saturating_add(T::DbWeight::get().reads(14)) + .saturating_add(T::DbWeight::get().writes(9)) } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) - /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:255 w:1) + /// Storage: `PolimecFunding::Contributions` (r:255 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:1 w:0) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 255]`. + fn second_to_limit_contribution(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2209 + x * (137 ±0)` + // Estimated: `6208 + x * (2839 ±0)` + // Minimum execution time: 1_801_000_000 picoseconds. + Weight::from_parts(1_517_808_385, 0) + .saturating_add(Weight::from_parts(0, 6208)) + // Standard Error: 299_619 + .saturating_add(Weight::from_parts(66_615_228, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(11)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(7)) + .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:255 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Balances::Holds` (r:1 w:1) /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:3 w:2) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 255]`. - fn second_to_limit_evaluation(x: u32, ) -> Weight { + fn second_to_limit_contribution_ends_round(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `889 + x * (137 ±0)` - // Estimated: `4614 + x * (2820 ±0)` - // Minimum execution time: 1_048_000_000 picoseconds. - Weight::from_parts(829_226_001, 0) - .saturating_add(Weight::from_parts(0, 4614)) - // Standard Error: 159_622 - .saturating_add(Weight::from_parts(63_317_508, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(5)) + // Measured: `2223 + x * (137 ±0)` + // Estimated: `10281 + x * (2839 ±0)` + // Minimum execution time: 1_883_000_000 picoseconds. + Weight::from_parts(1_704_088_160, 0) + .saturating_add(Weight::from_parts(0, 10281)) + // Standard Error: 216_861 + .saturating_add(Weight::from_parts(65_992_903, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(14)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(4)) - .saturating_add(Weight::from_parts(0, 2820).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().writes(9)) + .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) - /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:257 w:2) + /// Storage: `PolimecFunding::Contributions` (r:257 w:2) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:1 w:0) + fn contribution_over_limit() -> Weight { + // Proof Size summary in bytes: + // Measured: `37440` + // Estimated: `730613` + // Minimum execution time: 19_118_000_000 picoseconds. + Weight::from_parts(19_346_000_000, 0) + .saturating_add(Weight::from_parts(0, 730613)) + .saturating_add(T::DbWeight::get().reads(267)) + .saturating_add(T::DbWeight::get().writes(8)) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:257 w:2) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Balances::Holds` (r:1 w:1) /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - fn evaluation_over_limit() -> Weight { + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + fn contribution_over_limit_ends_round() -> Weight { // Proof Size summary in bytes: - // Measured: `36120` - // Estimated: `725730` - // Minimum execution time: 17_581_000_000 picoseconds. - Weight::from_parts(17_943_000_000, 0) - .saturating_add(Weight::from_parts(0, 725730)) - .saturating_add(T::DbWeight::get().reads(261)) - .saturating_add(T::DbWeight::get().writes(5)) + // Measured: `37440` + // Estimated: `730613` + // Minimum execution time: 19_344_000_000 picoseconds. + Weight::from_parts(19_637_000_000, 0) + .saturating_add(Weight::from_parts(0, 730613)) + .saturating_add(T::DbWeight::get().reads(267)) + .saturating_add(T::DbWeight::get().writes(8)) } } diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 0f3bcd23e..0eb3698e0 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -131,6 +131,24 @@ where ] } +pub fn full_bids() -> Vec> +where + ::Price: From, + ::Balance: From, + T::Hash: From, +{ + let default_project = default_project::(0, account::>("issuer", 0, 0)); + let total_ct_for_bids = default_project.total_allocation_size.0; + let total_usd_for_bids = default_project.minimum_price.checked_mul_int(total_ct_for_bids).unwrap(); + BenchInstantiator::::generate_bids_from_total_usd( + total_usd_for_bids, + default_project.minimum_price, + default_weights(), + default_bidders::(), + default_bidder_multipliers(), + ) +} + pub fn default_community_contributions() -> Vec> where ::Price: From, @@ -971,20 +989,21 @@ mod benchmarks { project_metadata.clone(), issuer, default_evaluations::(), - default_bids::(), + full_bids::(), ); let price = inst.get_project_details(project_id).weighted_average_price.unwrap(); let existing_amount: BalanceOf = (50 * ASSET_UNIT).into(); let extrinsic_amount: BalanceOf = if ends_round { - project_metadata.total_allocation_size.0 - existing_amount * (x as u128).into() + project_metadata.total_allocation_size.0 - + existing_amount * (x.min(::MaxContributionsPerUser::get() - 1) as u128).into() } else { (100 * ASSET_UNIT).into() }; let existing_contribution = ContributionParams::new(contributor.clone(), existing_amount, 1u8, AcceptedFundingAsset::USDT); - let extrinsic_contribution = + let mut extrinsic_contribution = ContributionParams::new(contributor.clone(), extrinsic_amount, 1u8, AcceptedFundingAsset::USDT); let existing_contributions = vec![existing_contribution; x as usize]; @@ -1088,7 +1107,9 @@ mod benchmarks { if project_id == project_id && contributor == contributor && ct_amount == extrinsic_contribution.amount => {}, - _ => assert!(false, "Contribution is not stored correctly"), + _ => { + assert!(false, "Contribution is not stored correctly") + }, } let stored_project_details = ProjectsDetails::::get(project_id).unwrap(); @@ -1328,51 +1349,6 @@ mod benchmarks { ); } - #[benchmark] - fn contribution_over_limit_ends_round() { - // How many other contributions the user did for that same project - let x = ::MaxContributionsPerUser::get(); - let ends_round = true; - - let ( - inst, - project_id, - project_metadata, - extrinsic_contribution, - total_free_plmc, - total_plmc_bonded, - total_free_usdt, - total_usdt_locked, - total_ct_sold, - ) = contribution_setup::(x, ends_round); - - #[extrinsic_call] - contribute( - RawOrigin::Signed(extrinsic_contribution.contributor.clone()), - project_id, - extrinsic_contribution.amount, - extrinsic_contribution.multiplier, - extrinsic_contribution.asset, - ); - - contribution_verification::( - inst, - project_id, - project_metadata, - extrinsic_contribution, - total_free_plmc, - total_plmc_bonded, - total_free_usdt, - total_usdt_locked, - total_ct_sold, - ); - } - - // branches: - // - ct account deposit - // - contribution over limit - // - if last ct sold, automatic transition to failed removed, and automatic transition to success inserted - #[benchmark] fn evaluation_unbond_for(x: Linear<1, 20>) { // setup From b6080097f6cdd9d545eff5fd4155a36d48e7576c Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 26 Jan 2024 11:29:37 +0100 Subject: [PATCH 145/212] abstracted away `ProjectsToUpdate` filling Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 114 ++++++++++++++++++---------- 1 file changed, 73 insertions(+), 41 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 0eb3698e0..3d4646a46 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -377,6 +377,42 @@ where // contributions // } +// IMPORTANT: make sure your project starts at (block 1 + `total_vecs_in_storage` - `fully_filled_vecs_from_insertion`) to always have room to insert new vecs +pub fn fill_projects_to_update( + fully_filled_vecs_from_insertion: u32, + mut expected_insertion_block: BlockNumberFor, + total_vecs_in_storage: u32, +) { + // fill the `ProjectsToUpdate` vectors from @ expected_insertion_block to @ expected_insertion_block+x, to benchmark all the failed insertion attempts + for _ in 0..fully_filled_vecs_from_insertion { + while ProjectsToUpdate::::try_append(expected_insertion_block, (&69u32, UpdateType::EvaluationEnd)).is_ok() { + continue + } + expected_insertion_block += 1u32.into(); + } + + // fill `ProjectsToUpdate` with `y` different BlockNumber->Vec items to benchmark deletion of our project from the map + // We keep in mind that we already filled `x` amount of vecs to max capacity + let remaining_vecs = total_vecs_in_storage.saturating_sub(fully_filled_vecs_from_insertion); + if remaining_vecs > 0 { + // we benchmarked this with different values, and it had no impact on the weight, so we use a low value to speed up the benchmark + let items_per_vec = 5u32; + let mut block_number: BlockNumberFor = Zero::zero(); + for _ in 0..remaining_vecs { + // To iterate over all expected items when looking to remove, we need to insert everything _before_ our already stored project's block_number + let mut vec: Vec<(ProjectId, UpdateType)> = ProjectsToUpdate::::get(block_number).to_vec(); + let items_to_fill = items_per_vec - vec.len() as u32; + for _ in 0..items_to_fill { + vec.push((69u32, UpdateType::EvaluationEnd)); + } + let bounded_vec: BoundedVec<(ProjectId, UpdateType), T::MaxProjectsToUpdatePerBlock> = + vec.try_into().unwrap(); + ProjectsToUpdate::::insert(block_number, bounded_vec); + block_number += 1u32.into(); + } + } +} + #[benchmarks( where T: Config + frame_system::Config::RuntimeEvent> + pallet_balances::Config>, @@ -956,7 +992,7 @@ mod benchmarks { fn contribution_setup( x: u32, - ends_round: bool, + ends_round: Option<(u32, u32)>, ) -> ( BenchInstantiator, ProjectId, @@ -976,8 +1012,14 @@ mod benchmarks { { // setup let mut inst = BenchInstantiator::::new(None); - // real benchmark starts at block 0, and we can't call `events()` at block 0 - inst.advance_time(1u32.into()).unwrap(); + + // We need to leave enough block numbers to fill `ProjectsToUpdate` before our project insertion + let mut time_advance: u32 = 1; + if let Some((y, z)) = ends_round { + let u32_remaining_vecs: u32 = z.saturating_sub(y).into(); + time_advance += u32_remaining_vecs + 1; + } + inst.advance_time(time_advance.into()).unwrap(); let issuer = account::>("issuer", 0, 0); let contributor = account::>("contributor", 0, 0); @@ -995,7 +1037,7 @@ mod benchmarks { let price = inst.get_project_details(project_id).weighted_average_price.unwrap(); let existing_amount: BalanceOf = (50 * ASSET_UNIT).into(); - let extrinsic_amount: BalanceOf = if ends_round { + let extrinsic_amount: BalanceOf = if let Some(_) = ends_round { project_metadata.total_allocation_size.0 - existing_amount * (x.min(::MaxContributionsPerUser::get() - 1) as u128).into() } else { @@ -1065,6 +1107,16 @@ mod benchmarks { total_free_usdt += usdt_returned; } + if let Some((fully_filled_vecs_from_insertion, total_vecs_in_storage)) = ends_round { + // if all CTs are sold, next round is scheduled for next block (either remainder or success) + let expected_insertion_block = inst.current_block() + One::one(); + fill_projects_to_update::( + fully_filled_vecs_from_insertion, + expected_insertion_block, + total_vecs_in_storage, + ); + } + ( inst, project_id, @@ -1153,7 +1205,7 @@ mod benchmarks { fn first_contribution() { // How many other contributions the user did for that same project let x = 0; - let ends_round = false; + let ends_round = None; let ( inst, @@ -1189,10 +1241,16 @@ mod benchmarks { ); } #[benchmark] - fn first_contribution_ends_round() { + fn first_contribution_ends_round( + // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the extrinsic pass + y: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, + // Total amount of storage items iterated through in `ProjectsToUpdate` when trying to remove our project in `remove_from_update_store`. + // Upper bound is assumed to be enough + z: Linear<1, 10_000>, + ) { // How many other contributions the user did for that same project let x = 0; - let ends_round = true; + let ends_round = Some((y, z)); let ( inst, project_id, @@ -1232,7 +1290,7 @@ mod benchmarks { // How many other contributions the user did for that same project x: Linear<1, { T::MaxContributionsPerUser::get() - 1 }>, ) { - let ends_round = false; + let ends_round = None; let ( inst, @@ -1272,8 +1330,13 @@ mod benchmarks { fn second_to_limit_contribution_ends_round( // How many other contributions the user did for that same project x: Linear<1, { T::MaxContributionsPerUser::get() - 1 }>, + // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the extrinsic pass + y: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, + // Total amount of storage items iterated through in `ProjectsToUpdate` when trying to remove our project in `remove_from_update_store`. + // Upper bound is assumed to be enough + z: Linear<1, 10_000>, ) { - let ends_round = true; + let ends_round = Some((y, z)); let ( inst, @@ -1313,7 +1376,7 @@ mod benchmarks { fn contribution_over_limit() { // How many other contributions the user did for that same project let x = ::MaxContributionsPerUser::get(); - let ends_round = false; + let ends_round = None; let ( inst, @@ -2316,30 +2379,6 @@ mod benchmarks { ); } - // #[benchmark] - // fn test(){ - // let mut inst = BenchInstantiator::::new(None); - // inst.advance_time(5u32.into()).unwrap(); - // let issuer = account::>("issuer", 0, 0); - // frame_system::Pallet::::remark_with_event(RawOrigin::Signed(issuer.clone()).into(), vec![1u8,2u8,3u8,4u8]); - // - // let debug_events = frame_system::Pallet::::events(); - // if debug_events.len() == 0 { - // panic!("events in store: {:?}", debug_events.len()); - // } - // - // #[block] - // { - // - // } - // - // let debug_events = frame_system::Pallet::::events(); - // log::info!( - // "frame system default events {:?}", - // debug_events - // ); - // } - #[macro_export] macro_rules! find_event { ($env: expr, $pattern:pat) => { @@ -2464,13 +2503,6 @@ mod benchmarks { }); } - #[test] - fn bench_contribution_over_limit_ends_round() { - new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_contribution_over_limit_ends_round()); - }); - } - #[test] fn bench_evaluation_unbond_for() { new_test_ext().execute_with(|| { From 0bf8c7aa92596a6b13445104c53791808e818735 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 26 Jan 2024 14:25:30 +0100 Subject: [PATCH 146/212] weight gen v2 Signed-off-by: Juan Ignacio Rios --- debug_weight_gen_v2.rs | 203 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 203 insertions(+) create mode 100644 debug_weight_gen_v2.rs diff --git a/debug_weight_gen_v2.rs b/debug_weight_gen_v2.rs new file mode 100644 index 000000000..1c3461ed0 --- /dev/null +++ b/debug_weight_gen_v2.rs @@ -0,0 +1,203 @@ + +//! Autogenerated weights for `pallet_funding` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2024-01-26, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `Juans-MBP.home`, CPU: `` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: 1024 + +// Executed Command: +// target/debug/polimec-parachain-node +// benchmark +// pallet +// --chain=polimec-rococo-local +// --steps=20 +// --repeat=10 +// --pallet=pallet_funding +// --extrinsic=first_contribution, first_contribution_ends_round, second_to_limit_contribution, second_to_limit_contribution_ends_round, contribution_over_limit +// --output +// ./debug_weight_gen_v2.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_funding`. +pub struct WeightInfo(PhantomData); +impl pallet_funding::WeightInfo for WeightInfo { + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn first_contribution() -> Weight { + // Proof Size summary in bytes: + // Measured: `1996` + // Estimated: `6208` + // Minimum execution time: 2_100_000_000 picoseconds. + Weight::from_parts(2_210_000_000, 0) + .saturating_add(Weight::from_parts(0, 6208)) + .saturating_add(T::DbWeight::get().reads(11)) + .saturating_add(T::DbWeight::get().writes(7)) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9832 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `y` is `[1, 99]`. + /// The range of component `z` is `[1, 10000]`. + fn first_contribution_ends_round(y: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + y * (909 ±0) + z * (41 ±0)` + // Estimated: `248750 + y * (17540 ±9_815) + z * (1383 ±97)` + // Minimum execution time: 7_079_000_000 picoseconds. + Weight::from_parts(7_117_000_000, 0) + .saturating_add(Weight::from_parts(0, 248750)) + // Standard Error: 226_579_186 + .saturating_add(Weight::from_parts(362_478_839, 0).saturating_mul(y.into())) + // Standard Error: 2_241_815 + .saturating_add(Weight::from_parts(32_034_853, 0).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(91)) + .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(y.into()))) + .saturating_add(T::DbWeight::get().writes(8)) + .saturating_add(Weight::from_parts(0, 17540).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 1383).saturating_mul(z.into())) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:255 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 255]`. + fn second_to_limit_contribution(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2209 + x * (137 ±0)` + // Estimated: `6208 + x * (2839 ±0)` + // Minimum execution time: 1_737_000_000 picoseconds. + Weight::from_parts(1_514_705_638, 0) + .saturating_add(Weight::from_parts(0, 6208)) + // Standard Error: 177_615 + .saturating_add(Weight::from_parts(64_011_655, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(11)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(7)) + .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:256 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9832 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 255]`. + /// The range of component `y` is `[1, 99]`. + /// The range of component `z` is `[1, 10000]`. + fn second_to_limit_contribution_ends_round(x: u32, y: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `37040 + x * (137 ±0) + y * (909 ±0) + z * (41 ±0)` + // Estimated: `2178320 + x * (2839 ±0) + y * (103665 ±16_527) + z * (2230 ±162)` + // Minimum execution time: 22_009_000_000 picoseconds. + Weight::from_parts(46_609_465_170, 0) + .saturating_add(Weight::from_parts(0, 2178320)) + // Standard Error: 379_495_438 + .saturating_add(Weight::from_parts(2_369_315_873, 0).saturating_mul(y.into())) + // Standard Error: 3_737_964 + .saturating_add(Weight::from_parts(51_569_812, 0).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(714)) + .saturating_add(T::DbWeight::get().reads((33_u64).saturating_mul(y.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(z.into()))) + .saturating_add(T::DbWeight::get().writes(8)) + .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 103665).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 2230).saturating_mul(z.into())) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:257 w:2) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + fn contribution_over_limit() -> Weight { + // Proof Size summary in bytes: + // Measured: `37440` + // Estimated: `730613` + // Minimum execution time: 17_812_000_000 picoseconds. + Weight::from_parts(18_304_000_000, 0) + .saturating_add(Weight::from_parts(0, 730613)) + .saturating_add(T::DbWeight::get().reads(267)) + .saturating_add(T::DbWeight::get().writes(8)) + } +} From 336bc3cf2b3e4eac135529d77442d34aa04631b1 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 26 Jan 2024 16:46:25 +0100 Subject: [PATCH 147/212] added weight returns on contribute() Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/functions.rs | 84 ++++++++++++++++++++++++++++---- pallets/funding/src/lib.rs | 13 +++-- pallets/funding/src/weights.rs | 11 ++++- 3 files changed, 94 insertions(+), 14 deletions(-) diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 2fe38bcad..9b7d0fe90 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -1144,6 +1144,28 @@ impl Pallet { let ct_deposit = T::ContributionTokenCurrency::deposit_required(project_id); let caller_existing_contributions = Contributions::::iter_prefix_values((project_id, contributor)).collect::>(); + + // Weight flags + enum WeightContributionFlag { + FirstContribution, + SecondToLimitContribution, + OverLimitContribution, + } + struct WeightRoundEndFlag { + fully_filled_vecs_from_insertion: u32, + total_vecs_in_storage: u32, + } + let mut weight_contribution_flag: WeightContributionFlag; + let mut weight_round_end_flag: Option = None; + + if caller_existing_contributions.len() == 0 { + weight_contribution_flag = WeightContributionFlag::FirstContribution; + } else if caller_existing_contributions.len() < T::MaxContributionsPerUser::get() as usize { + weight_contribution_flag = WeightContributionFlag::SecondToLimitContribution; + } else { + weight_contribution_flag = WeightContributionFlag::OverLimitContribution; + } + // * Validity checks * ensure!(project_metadata.participation_currencies == asset, Error::::FundingAssetNotAccepted); ensure!(contributor.clone() != project_details.issuer, Error::::ContributionToThemselves); @@ -1206,7 +1228,7 @@ impl Pallet { } // Try adding the new contribution to the system - if caller_existing_contributions.len() < T::MaxContributionsPerUser::get() as usize { + if matches!(weight_contribution_flag, Some(WeightContributionFlag::OverLimitContribution)).not() { Self::try_plmc_participation_lock(contributor, project_id, plmc_bond)?; Self::try_funding_asset_hold(contributor, project_id, funding_asset_amount, asset_id)?; } else { @@ -1264,17 +1286,21 @@ impl Pallet { project_details.funding_amount_reached.saturating_accrue(new_contribution.usd_contribution_amount); ProjectsDetails::::insert(project_id, project_details); // If no CTs remain, end the funding phase + if remaining_cts_after_purchase.is_zero() { - // TODO: return real weights // remove the remainder transition or the funding failed transition - let iterations = match Self::remove_from_update_store(&project_id) { - Ok(iterations) => iterations, - Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), - }; - let iterations = match Self::add_to_update_store(now + 1u32.into(), (&project_id, UpdateType::FundingEnd)) { + let total_vecs_in_storage = match Self::remove_from_update_store(&project_id) { Ok(iterations) => iterations, - Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + Err(_iterations) => return Err(Error::::TooManyInsertionAttempts.into()), }; + let fully_filled_vecs_from_insertion = + match Self::add_to_update_store(now + 1u32.into(), (&project_id, UpdateType::FundingEnd)) { + Ok(iterations) => iterations, + Err(_iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + }; + + weight_round_end_flag = + Some(WeightRoundEndFlag { fully_filled_vecs_from_insertion, total_vecs_in_storage }); } // * Emit events * @@ -1285,7 +1311,47 @@ impl Pallet { multiplier, }); - Ok(Pays::No.into()) + // return correct weight function + match (weight_contribution_flag, weight_round_end_flag) { + (WeightContributionFlag::FirstContribution, None) => Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::first_contribution()), + pays_fee: Pays::Yes, + }), + ( + WeightContributionFlag::FirstContribution, + Some(WeightRoundEndFlag { fully_filled_vecs_from_insertion, total_vecs_in_storage }), + ) => Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::first_contribution_ends_round( + fully_filled_vecs_from_insertion, + total_vecs_in_storage, + )), + pays_fee: Pays::Yes, + }), + + (WeightContributionFlag::SecondToLimitContribution, None) => Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::second_to_limit_contribution( + caller_existing_contributions.len() as u32, + )), + pays_fee: Pays::Yes, + }), + ( + WeightContributionFlag::SecondToLimitContribution, + Some(WeightRoundEndFlag { fully_filled_vecs_from_insertion, total_vecs_in_storage }), + ) => Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::second_to_limit_contribution_ends_round( + caller_existing_contributions.len() as u32, + fully_filled_vecs_from_insertion, + total_vecs_in_storage, + )), + pays_fee: Pays::Yes, + }), + + // a contribution over the limit means removing an existing contribution, therefore you cannot have a round end + (WeightContributionFlag::OverLimitContribution, _) => Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::contribution_over_limit()), + pays_fee: Pays::Yes, + }), + } } fn calculate_buyable_amount( diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 6949afa03..05e320eb3 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -963,7 +963,7 @@ pub mod pallet { /// Starts the evaluation round of a project. It needs to be called by the project issuer. #[pallet::call_index(2)] - #[pallet::weight(WeightInfoOf::::start_evaluation(::MaxProjectsToUpdateInsertionAttempts::get()))] + #[pallet::weight(WeightInfoOf::::start_evaluation(::MaxProjectsToUpdateInsertionAttempts::get() - 1))] pub fn start_evaluation(origin: OriginFor, project_id: ProjectId) -> DispatchResultWithPostInfo { let issuer = ensure_signed(origin)?; Self::do_start_evaluation(issuer, project_id) @@ -973,7 +973,7 @@ pub mod pallet { /// institutional user can set bids for a token_amount/token_price pair. /// Any bids from this point until the candle_auction starts, will be considered as valid. #[pallet::call_index(3)] - #[pallet::weight(WeightInfoOf::::start_auction_manually(::MaxProjectsToUpdateInsertionAttempts::get(), 10_000u32))] + #[pallet::weight(WeightInfoOf::::start_auction_manually(::MaxProjectsToUpdateInsertionAttempts::get() - 1, 10_000u32))] pub fn start_auction(origin: OriginFor, project_id: ProjectId) -> DispatchResultWithPostInfo { let issuer = ensure_signed(origin)?; Self::do_english_auction(issuer, project_id) @@ -1007,7 +1007,14 @@ pub mod pallet { /// Buy tokens in the Community or Remainder round at the price set in the Auction Round #[pallet::call_index(6)] - #[pallet::weight(WeightInfoOf::::contribute())] + #[pallet::weight(WeightInfoOf::::second_to_limit_contribution_ends_round( + // Last contribution possible before having to remove an old lower one + ::MaxContributionsPerUser::get() -1, + // Since we didn't remove any previous lower contribution, we can buy all remaining CTs and try to move to the next phase + ::MaxProjectsToUpdateInsertionAttempts::get() - 1, + // Assumed upper bound for deletion attempts for the previous scheduled transition + 10_000u32, + ))] pub fn contribute( origin: OriginFor, project_id: ProjectId, diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index a53b85ae5..49877a860 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -60,8 +60,15 @@ pub trait WeightInfo { fn second_to_limit_evaluation(x: u32) -> Weight; fn evaluation_over_limit() -> Weight; fn bid() -> Weight; - fn contribute() -> Weight; - fn evaluation_unbond_for() -> Weight; + + fn first_contribution() -> Weight; + fn first_contribution_ends_round(y: u32, z: u32, ) -> Weight; + fn second_to_limit_contribution(x: u32, ) -> Weight; + fn second_to_limit_contribution_ends_round(x: u32, y: u32, z: u32, ) -> Weight; + fn contribution_over_limit() -> Weight; + + + fn evaluation_unbond_for() -> Weight; fn evaluation_slash_for() -> Weight; fn evaluation_reward_payout_for() -> Weight; fn bid_ct_mint_for() -> Weight; From 3dd0467c8912717f6152e1b8f224709fe4a75814 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 26 Jan 2024 17:33:12 +0100 Subject: [PATCH 148/212] all tests for benches rewritten so far are passing Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 285 +++++++++++++--------------- pallets/funding/src/functions.rs | 8 +- pallets/funding/src/weights.rs | 36 +++- 3 files changed, 158 insertions(+), 171 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 3d4646a46..658c3b34d 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -381,7 +381,7 @@ where pub fn fill_projects_to_update( fully_filled_vecs_from_insertion: u32, mut expected_insertion_block: BlockNumberFor, - total_vecs_in_storage: u32, + maybe_total_vecs_in_storage: Option, ) { // fill the `ProjectsToUpdate` vectors from @ expected_insertion_block to @ expected_insertion_block+x, to benchmark all the failed insertion attempts for _ in 0..fully_filled_vecs_from_insertion { @@ -391,24 +391,27 @@ pub fn fill_projects_to_update( expected_insertion_block += 1u32.into(); } - // fill `ProjectsToUpdate` with `y` different BlockNumber->Vec items to benchmark deletion of our project from the map - // We keep in mind that we already filled `x` amount of vecs to max capacity - let remaining_vecs = total_vecs_in_storage.saturating_sub(fully_filled_vecs_from_insertion); - if remaining_vecs > 0 { - // we benchmarked this with different values, and it had no impact on the weight, so we use a low value to speed up the benchmark - let items_per_vec = 5u32; - let mut block_number: BlockNumberFor = Zero::zero(); - for _ in 0..remaining_vecs { - // To iterate over all expected items when looking to remove, we need to insert everything _before_ our already stored project's block_number - let mut vec: Vec<(ProjectId, UpdateType)> = ProjectsToUpdate::::get(block_number).to_vec(); - let items_to_fill = items_per_vec - vec.len() as u32; - for _ in 0..items_to_fill { - vec.push((69u32, UpdateType::EvaluationEnd)); + // sometimes we don't expect to remove anything from storage + if let Some(total_vecs_in_storage) = maybe_total_vecs_in_storage { + // fill `ProjectsToUpdate` with `y` different BlockNumber->Vec items to benchmark deletion of our project from the map + // We keep in mind that we already filled `x` amount of vecs to max capacity + let remaining_vecs = total_vecs_in_storage.saturating_sub(fully_filled_vecs_from_insertion); + if remaining_vecs > 0 { + // we benchmarked this with different values, and it had no impact on the weight, so we use a low value to speed up the benchmark + let items_per_vec = 5u32; + let mut block_number: BlockNumberFor = Zero::zero(); + for _ in 0..remaining_vecs { + // To iterate over all expected items when looking to remove, we need to insert everything _before_ our already stored project's block_number + let mut vec: Vec<(ProjectId, UpdateType)> = ProjectsToUpdate::::get(block_number).to_vec(); + let items_to_fill = items_per_vec - vec.len() as u32; + for _ in 0..items_to_fill { + vec.push((69u32, UpdateType::EvaluationEnd)); + } + let bounded_vec: BoundedVec<(ProjectId, UpdateType), T::MaxProjectsToUpdatePerBlock> = + vec.try_into().unwrap(); + ProjectsToUpdate::::insert(block_number, bounded_vec); + block_number += 1u32.into(); } - let bounded_vec: BoundedVec<(ProjectId, UpdateType), T::MaxProjectsToUpdatePerBlock> = - vec.try_into().unwrap(); - ProjectsToUpdate::::insert(block_number, bounded_vec); - block_number += 1u32.into(); } } } @@ -584,34 +587,7 @@ mod benchmarks { let insertion_block_number: BlockNumberFor = current_block + T::EnglishAuctionDuration::get() + One::one(); let mut block_number = insertion_block_number; - // fill the `ProjectsToUpdate` vectors from @ block_number to @ block_number+x, to benchmark all the failed insertion attempts - for _ in 0..x { - while ProjectsToUpdate::::try_append(block_number, (&69u32, UpdateType::EvaluationEnd)).is_ok() { - continue - } - block_number += 1u32.into(); - } - - // fill `ProjectsToUpdate` with `y` different BlockNumber->Vec items to benchmark deletion of our project from the map - // We keep in mind that we already filled `x` amount of vecs to max capacity - let remaining_vecs = y.saturating_sub(x); - if remaining_vecs > 0 { - // we benchmarked this with different values and it had no impact on the weight, so we use a low value to speed up the benchmark - let items_per_vec = 5u32; - let mut block_number = insertion_block_number - One::one(); - for _ in 0..remaining_vecs { - // To iterate over all expected items when looking to remove, we need to insert everything _before_ our project's block_number - let mut vec: Vec<(ProjectId, UpdateType)> = ProjectsToUpdate::::get(block_number).to_vec(); - let items_to_fill = items_per_vec - vec.len() as u32; - for _ in 0..items_to_fill { - vec.push((69u32, UpdateType::EvaluationEnd)); - } - let bounded_vec: BoundedVec<(ProjectId, UpdateType), T::MaxProjectsToUpdatePerBlock> = - vec.try_into().unwrap(); - ProjectsToUpdate::::insert(block_number, bounded_vec); - block_number -= One::one(); - } - } + fill_projects_to_update::(x, block_number, Some(y)); #[extrinsic_call] start_auction(RawOrigin::Signed(issuer), project_id); @@ -666,13 +642,7 @@ mod benchmarks { automatic_transition_block + T::EnglishAuctionDuration::get() + One::one(); let mut block_number = insertion_block_number; - // fill the `ProjectsToUpdate` vectors from @ block_number to @ block_number+x, to benchmark all the failed insertion attempts - for _ in 0..x { - while ProjectsToUpdate::::try_append(block_number, (&69u32, UpdateType::EvaluationEnd)).is_ok() { - continue - } - block_number += 1u32.into(); - } + fill_projects_to_update::(x, block_number, None); let now = inst.current_block(); inst.advance_time(automatic_transition_block - now - One::one()).unwrap(); @@ -1113,7 +1083,7 @@ mod benchmarks { fill_projects_to_update::( fully_filled_vecs_from_insertion, expected_insertion_block, - total_vecs_in_storage, + Some(total_vecs_in_storage), ); } @@ -2433,6 +2403,7 @@ mod benchmarks { assert_ok!(PalletFunding::::test_first_evaluation()); }); } + #[test] fn bench_second_to_limit_evaluation() { new_test_ext().execute_with(|| { @@ -2461,12 +2432,12 @@ mod benchmarks { }); } - #[test] - fn bench_bid() { - new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_bid()); - }); - } + // #[test] + // fn bench_bid() { + // new_test_ext().execute_with(|| { + // assert_ok!(PalletFunding::::test_bid()); + // }); + // } #[test] fn bench_first_contribution() { @@ -2503,102 +2474,102 @@ mod benchmarks { }); } - #[test] - fn bench_evaluation_unbond_for() { - new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_evaluation_unbond_for()); - }); - } - - #[test] - fn bench_evaluation_slash_for() { - new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_evaluation_slash_for()); - }); - } - - #[test] - fn bench_evaluation_reward_payout_for() { - new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_evaluation_reward_payout_for()); - }); - } - - #[test] - fn bench_bid_ct_mint_for() { - new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_bid_ct_mint_for()); - }); - } - - #[test] - fn bench_contribution_ct_mint_for() { - new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_contribution_ct_mint_for()); - }); - } - - #[test] - fn bench_start_bid_vesting_schedule_for() { - new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_start_bid_vesting_schedule_for()); - }); - } - - #[test] - fn bench_start_contribution_vesting_schedule_for() { - new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_start_contribution_vesting_schedule_for()); - }); - } - - #[test] - fn bench_payout_bid_funds_for() { - new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_payout_bid_funds_for()); - }); - } - - #[test] - fn bench_payout_contribution_funds_for() { - new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_payout_contribution_funds_for()); - }); - } - - #[test] - fn bench_decide_project_outcome() { - new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_decide_project_outcome()); - }); - } - - #[test] - fn bench_release_bid_funds_for() { - new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_release_bid_funds_for()); - }); - } - - #[test] - fn bench_release_contribution_funds_for() { - new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_release_contribution_funds_for()); - }); - } - - #[test] - fn bench_bid_unbond_for() { - new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_bid_unbond_for()); - }); - } - - #[test] - fn bench_contribution_unbond_for() { - new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_contribution_unbond_for()); - }); - } + // #[test] + // fn bench_evaluation_unbond_for() { + // new_test_ext().execute_with(|| { + // assert_ok!(PalletFunding::::test_evaluation_unbond_for()); + // }); + // } + // + // #[test] + // fn bench_evaluation_slash_for() { + // new_test_ext().execute_with(|| { + // assert_ok!(PalletFunding::::test_evaluation_slash_for()); + // }); + // } + // + // #[test] + // fn bench_evaluation_reward_payout_for() { + // new_test_ext().execute_with(|| { + // assert_ok!(PalletFunding::::test_evaluation_reward_payout_for()); + // }); + // } + // + // #[test] + // fn bench_bid_ct_mint_for() { + // new_test_ext().execute_with(|| { + // assert_ok!(PalletFunding::::test_bid_ct_mint_for()); + // }); + // } + // + // #[test] + // fn bench_contribution_ct_mint_for() { + // new_test_ext().execute_with(|| { + // assert_ok!(PalletFunding::::test_contribution_ct_mint_for()); + // }); + // } + // + // #[test] + // fn bench_start_bid_vesting_schedule_for() { + // new_test_ext().execute_with(|| { + // assert_ok!(PalletFunding::::test_start_bid_vesting_schedule_for()); + // }); + // } + // + // #[test] + // fn bench_start_contribution_vesting_schedule_for() { + // new_test_ext().execute_with(|| { + // assert_ok!(PalletFunding::::test_start_contribution_vesting_schedule_for()); + // }); + // } + // + // #[test] + // fn bench_payout_bid_funds_for() { + // new_test_ext().execute_with(|| { + // assert_ok!(PalletFunding::::test_payout_bid_funds_for()); + // }); + // } + // + // #[test] + // fn bench_payout_contribution_funds_for() { + // new_test_ext().execute_with(|| { + // assert_ok!(PalletFunding::::test_payout_contribution_funds_for()); + // }); + // } + // + // #[test] + // fn bench_decide_project_outcome() { + // new_test_ext().execute_with(|| { + // assert_ok!(PalletFunding::::test_decide_project_outcome()); + // }); + // } + // + // #[test] + // fn bench_release_bid_funds_for() { + // new_test_ext().execute_with(|| { + // assert_ok!(PalletFunding::::test_release_bid_funds_for()); + // }); + // } + // + // #[test] + // fn bench_release_contribution_funds_for() { + // new_test_ext().execute_with(|| { + // assert_ok!(PalletFunding::::test_release_contribution_funds_for()); + // }); + // } + // + // #[test] + // fn bench_bid_unbond_for() { + // new_test_ext().execute_with(|| { + // assert_ok!(PalletFunding::::test_bid_unbond_for()); + // }); + // } + // + // #[test] + // fn bench_contribution_unbond_for() { + // new_test_ext().execute_with(|| { + // assert_ok!(PalletFunding::::test_contribution_unbond_for()); + // }); + // } } } diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 9b7d0fe90..33d4d6c1e 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -18,10 +18,8 @@ //! Functions for the Funding pallet. -use frame_support::dispatch::{DispatchErrorWithPostInfo, DispatchResultWithPostInfo, PostDispatchInfo}; - use frame_support::{ - dispatch::DispatchResult, + dispatch::{DispatchErrorWithPostInfo, DispatchResult, DispatchResultWithPostInfo, PostDispatchInfo}, ensure, pallet_prelude::*, traits::{ @@ -38,7 +36,7 @@ use sp_arithmetic::{ Percent, Perquintill, }; use sp_runtime::traits::{Convert, ConvertBack}; -use sp_std::marker::PhantomData; +use sp_std::{marker::PhantomData, ops::Not}; use xcm::v3::MaxDispatchErrorLen; use crate::ProjectStatus::FundingSuccessful; @@ -1228,7 +1226,7 @@ impl Pallet { } // Try adding the new contribution to the system - if matches!(weight_contribution_flag, Some(WeightContributionFlag::OverLimitContribution)).not() { + if matches!(weight_contribution_flag, WeightContributionFlag::OverLimitContribution).not() { Self::try_plmc_participation_lock(contributor, project_id, plmc_bond)?; Self::try_funding_asset_hold(contributor, project_id, funding_asset_amount, asset_id)?; } else { diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index 49877a860..06ed6d33a 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -178,6 +178,32 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().reads(10_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } + + fn first_contribution() -> Weight { + Weight::from_parts(140_000_000, 6208) + + } + + fn first_contribution_ends_round(y: u32, z: u32) -> Weight { + Weight::from_parts(140_000_000, 6208) + + } + + fn second_to_limit_contribution(x: u32) -> Weight { + Weight::from_parts(140_000_000, 6208) + + } + + fn second_to_limit_contribution_ends_round(x: u32, y: u32, z: u32) -> Weight { + Weight::from_parts(140_000_000, 6208) + + } + + fn contribution_over_limit() -> Weight { + Weight::from_parts(140_000_000, 6208) + + } + /// Storage: PolimecFunding ProjectsMetadata (r:1 w:0) /// Proof Skipped: PolimecFunding ProjectsMetadata (max_values: None, max_size: None, mode: Measured) /// Storage: PolimecFunding ProjectsDetails (r:1 w:1) @@ -194,15 +220,7 @@ impl WeightInfo for SubstrateWeight { /// Proof: StatemintAssets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) /// Storage: StatemintAssets Account (r:2 w:2) /// Proof: StatemintAssets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) - fn contribute() -> Weight { - // Proof Size summary in bytes: - // Measured: `1682` - // Estimated: `6208` - // Minimum execution time: 122_000_000 picoseconds. - Weight::from_parts(131_000_000, 6208) - .saturating_add(T::DbWeight::get().reads(9_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) - } + /// Storage: PolimecFunding ProjectsDetails (r:1 w:0) /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) /// Storage: PolimecFunding Evaluations (r:1 w:1) From 524004139d0e9438e4c1f7660e3edeb6319b36ee Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 29 Jan 2024 11:31:01 +0100 Subject: [PATCH 149/212] added ct_deposit difference benchmarks for first contribution. Bench running atm. Onward to bids Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 121 +++++++++++++++++++- pallets/parachain-staking/src/benchmarks.rs | 7 +- 2 files changed, 121 insertions(+), 7 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 658c3b34d..5c94b4409 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -22,9 +22,16 @@ use sp_runtime::traits::TrailingZeroInput; use super::*; use crate::{instantiator::*, traits::SetPrices}; - use frame_benchmarking::v2::*; -use frame_support::{assert_ok, dispatch::RawOrigin, traits::OriginTrait, Parameter}; +use frame_support::{ + assert_ok, + dispatch::RawOrigin, + traits::{ + fungible::{InspectHold, Mutate, MutateHold}, + OriginTrait, + }, + Parameter, +}; #[allow(unused_imports)] use pallet::Pallet as PalletFunding; use parity_scale_codec::{Decode, Encode}; @@ -416,6 +423,15 @@ pub fn fill_projects_to_update( } } +// returns how much PLMC was minted and held to the user +pub fn make_ct_deposit_for(user: AccountIdOf, project_id: ProjectId) { + let ct_deposit = T::ContributionTokenCurrency::deposit_required(project_id); + // Reserve plmc deposit to create a contribution token account for this project + if T::NativeCurrency::balance_on_hold(&HoldReason::FutureDeposit(project_id).into(), &user) < ct_deposit { + T::NativeCurrency::hold(&HoldReason::FutureDeposit(project_id).into(), &user, ct_deposit).unwrap(); + } +} + #[benchmarks( where T: Config + frame_system::Config::RuntimeEvent> + pallet_balances::Config>, @@ -1171,8 +1187,56 @@ mod benchmarks { ); } + // - We know how many iterations it does in storage + // - We know it requires no CT deposit (remainder round only) + // - We know that it does not require to unbond the lowest contribution + // - We know it doesn't end the round + #[benchmark] + fn first_contribution_no_ct_deposit() { + // How many other contributions the user did for that same project + let x = 0; + let ends_round = None; + + let ( + inst, + project_id, + project_metadata, + extrinsic_contribution, + total_free_plmc, + total_plmc_bonded, + total_free_usdt, + total_usdt_locked, + total_ct_sold, + ) = contribution_setup::(x, ends_round); + + #[extrinsic_call] + contribute( + RawOrigin::Signed(extrinsic_contribution.contributor.clone()), + project_id, + extrinsic_contribution.amount, + extrinsic_contribution.multiplier, + extrinsic_contribution.asset, + ); + + contribution_verification::( + inst, + project_id, + project_metadata, + extrinsic_contribution, + total_free_plmc, + total_plmc_bonded, + total_free_usdt, + total_usdt_locked, + total_ct_sold, + ); + } + + // - We know how many iterations it does in storage + // - We know it requires a CT deposit + // - We know that it does not require to unbond the lowest contribution + // - We know it doesn't end the round #[benchmark] - fn first_contribution() { + fn first_contribution_with_ct_deposit() { // How many other contributions the user did for that same project let x = 0; let ends_round = None; @@ -1189,6 +1253,8 @@ mod benchmarks { total_ct_sold, ) = contribution_setup::(x, ends_round); + let _new_plmc_minted = make_ct_deposit_for::(extrinsic_contribution.contributor.clone(), project_id); + #[extrinsic_call] contribute( RawOrigin::Signed(extrinsic_contribution.contributor.clone()), @@ -1211,7 +1277,7 @@ mod benchmarks { ); } #[benchmark] - fn first_contribution_ends_round( + fn first_contribution_ends_round_no_ct_deposit( // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the extrinsic pass y: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, // Total amount of storage items iterated through in `ProjectsToUpdate` when trying to remove our project in `remove_from_update_store`. @@ -1255,6 +1321,53 @@ mod benchmarks { ); } + #[benchmark] + fn first_contribution_ends_round_with_ct_deposit( + // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the extrinsic pass + y: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, + // Total amount of storage items iterated through in `ProjectsToUpdate` when trying to remove our project in `remove_from_update_store`. + // Upper bound is assumed to be enough + z: Linear<1, 10_000>, + ) { + // How many other contributions the user did for that same project + let x = 0; + let ends_round = Some((y, z)); + let ( + inst, + project_id, + project_metadata, + extrinsic_contribution, + total_free_plmc, + total_plmc_bonded, + total_free_usdt, + total_usdt_locked, + total_ct_sold, + ) = contribution_setup::(x, ends_round); + + let _new_plmc_minter = make_ct_deposit_for::(extrinsic_contribution.contributor.clone(), project_id); + + #[extrinsic_call] + contribute( + RawOrigin::Signed(extrinsic_contribution.contributor.clone()), + project_id, + extrinsic_contribution.amount, + extrinsic_contribution.multiplier, + extrinsic_contribution.asset, + ); + + contribution_verification::( + inst, + project_id, + project_metadata, + extrinsic_contribution, + total_free_plmc, + total_plmc_bonded, + total_free_usdt, + total_usdt_locked, + total_ct_sold, + ); + } + #[benchmark] fn second_to_limit_contribution( // How many other contributions the user did for that same project diff --git a/pallets/parachain-staking/src/benchmarks.rs b/pallets/parachain-staking/src/benchmarks.rs index bef87e0bf..e05df27ca 100644 --- a/pallets/parachain-staking/src/benchmarks.rs +++ b/pallets/parachain-staking/src/benchmarks.rs @@ -21,10 +21,11 @@ use crate::{ AwardedPts, BalanceOf, Call, CandidateBondLessRequest, Config, DelegationAction, Pallet, ParachainBondConfig, ParachainBondInfo, Points, Range, RewardPayment, Round, ScheduledRequest, Staked, TopDelegations, }; -use frame_support::traits::fungible::{Inspect, Mutate}; - use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, vec}; -use frame_support::traits::{fungible::Balanced, Get, OnFinalize, OnInitialize}; +use frame_support::traits::{ + fungible::{Inspect, Mutate, MutateHold}, + Get, OnFinalize, OnInitialize, +}; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; #[cfg(feature = "std")] use sp_runtime::BuildStorage; From c5d4a17b064375fcc828c87921dcdd958702265d Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 29 Jan 2024 11:36:29 +0100 Subject: [PATCH 150/212] weight generated. Seems off Signed-off-by: Juan Ignacio Rios --- debug_weight_gen_v3.rs | 161 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 debug_weight_gen_v3.rs diff --git a/debug_weight_gen_v3.rs b/debug_weight_gen_v3.rs new file mode 100644 index 000000000..457468cbc --- /dev/null +++ b/debug_weight_gen_v3.rs @@ -0,0 +1,161 @@ + +//! Autogenerated weights for `pallet_funding` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2024-01-29, STEPS: `10`, REPEAT: `5`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `Juans-MBP.home`, CPU: `` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: 1024 + +// Executed Command: +// target/debug/polimec-parachain-node +// benchmark +// pallet +// --chain=polimec-rococo-local +// --steps=10 +// --repeat=5 +// --pallet=pallet_funding +// --extrinsic=first_contribution_no_ct_deposit,first_contribution_with_ct_deposit,first_contribution_ends_round_no_ct_deposit,first_contribution_ends_round_with_ct_deposit +// --output +// ./debug_weight_gen_v3.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_funding`. +pub struct WeightInfo(PhantomData); +impl pallet_funding::WeightInfo for WeightInfo { + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn first_contribution_no_ct_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `1996` + // Estimated: `6208` + // Minimum execution time: 2_129_000_000 picoseconds. + Weight::from_parts(2_151_000_000, 0) + .saturating_add(Weight::from_parts(0, 6208)) + .saturating_add(T::DbWeight::get().reads(11)) + .saturating_add(T::DbWeight::get().writes(7)) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn first_contribution_with_ct_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `2073` + // Estimated: `6208` + // Minimum execution time: 1_656_000_000 picoseconds. + Weight::from_parts(1_695_000_000, 0) + .saturating_add(Weight::from_parts(0, 6208)) + .saturating_add(T::DbWeight::get().reads(11)) + .saturating_add(T::DbWeight::get().writes(7)) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9832 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `y` is `[1, 99]`. + /// The range of component `z` is `[1, 10000]`. + fn first_contribution_ends_round_no_ct_deposit(_y: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `34332 + y * (1339 ±0) + z * (28 ±0)` + // Estimated: `248750 + z * (1752 ±198)` + // Minimum execution time: 6_878_000_000 picoseconds. + Weight::from_parts(7_162_000_000, 0) + .saturating_add(Weight::from_parts(0, 248750)) + // Standard Error: 4_575_505 + .saturating_add(Weight::from_parts(41_056_098, 0).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(91)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(z.into()))) + .saturating_add(T::DbWeight::get().writes(8)) + .saturating_add(Weight::from_parts(0, 1752).saturating_mul(z.into())) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9832 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `y` is `[1, 99]`. + /// The range of component `z` is `[1, 10000]`. + fn first_contribution_ends_round_with_ct_deposit(_y: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `34409 + y * (1339 ±0) + z * (28 ±0)` + // Estimated: `248750 + z * (1752 ±198)` + // Minimum execution time: 6_652_000_000 picoseconds. + Weight::from_parts(6_691_000_000, 0) + .saturating_add(Weight::from_parts(0, 248750)) + // Standard Error: 4_584_644 + .saturating_add(Weight::from_parts(40_419_101, 0).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(91)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(z.into()))) + .saturating_add(T::DbWeight::get().writes(8)) + .saturating_add(Weight::from_parts(0, 1752).saturating_mul(z.into())) + } +} From 87c731cfd1e7f80569bd4e9c58a07261845f1282 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 29 Jan 2024 11:53:04 +0100 Subject: [PATCH 151/212] rename benches Signed-off-by: Juan Ignacio Rios --- debug_weight_gen_v3.rs | 86 +++-------------------------- pallets/funding/src/benchmarking.rs | 30 +++++++--- 2 files changed, 29 insertions(+), 87 deletions(-) diff --git a/debug_weight_gen_v3.rs b/debug_weight_gen_v3.rs index 457468cbc..5d24aad8c 100644 --- a/debug_weight_gen_v3.rs +++ b/debug_weight_gen_v3.rs @@ -15,7 +15,7 @@ // --steps=10 // --repeat=5 // --pallet=pallet_funding -// --extrinsic=first_contribution_no_ct_deposit,first_contribution_with_ct_deposit,first_contribution_ends_round_no_ct_deposit,first_contribution_ends_round_with_ct_deposit +// --extrinsic=first_contribution_no_ct_deposit,first_contribution_with_ct_deposit, // --output // ./debug_weight_gen_v3.rs @@ -48,12 +48,12 @@ impl pallet_funding::WeightInfo for WeightInfo { /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) /// Storage: `StatemintAssets::Account` (r:2 w:2) /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - fn first_contribution_no_ct_deposit() -> Weight { + fn first_contribution_with_ct_deposit() -> Weight { // Proof Size summary in bytes: // Measured: `1996` // Estimated: `6208` - // Minimum execution time: 2_129_000_000 picoseconds. - Weight::from_parts(2_151_000_000, 0) + // Minimum execution time: 2_126_000_000 picoseconds. + Weight::from_parts(2_136_000_000, 0) .saturating_add(Weight::from_parts(0, 6208)) .saturating_add(T::DbWeight::get().reads(11)) .saturating_add(T::DbWeight::get().writes(7)) @@ -76,86 +76,14 @@ impl pallet_funding::WeightInfo for WeightInfo { /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) /// Storage: `StatemintAssets::Account` (r:2 w:2) /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - fn first_contribution_with_ct_deposit() -> Weight { + fn first_contribution_no_ct_deposit() -> Weight { // Proof Size summary in bytes: // Measured: `2073` // Estimated: `6208` - // Minimum execution time: 1_656_000_000 picoseconds. - Weight::from_parts(1_695_000_000, 0) + // Minimum execution time: 1_657_000_000 picoseconds. + Weight::from_parts(1_673_000_000, 0) .saturating_add(Weight::from_parts(0, 6208)) .saturating_add(T::DbWeight::get().reads(11)) .saturating_add(T::DbWeight::get().writes(7)) } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9832 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - /// The range of component `y` is `[1, 99]`. - /// The range of component `z` is `[1, 10000]`. - fn first_contribution_ends_round_no_ct_deposit(_y: u32, z: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `34332 + y * (1339 ±0) + z * (28 ±0)` - // Estimated: `248750 + z * (1752 ±198)` - // Minimum execution time: 6_878_000_000 picoseconds. - Weight::from_parts(7_162_000_000, 0) - .saturating_add(Weight::from_parts(0, 248750)) - // Standard Error: 4_575_505 - .saturating_add(Weight::from_parts(41_056_098, 0).saturating_mul(z.into())) - .saturating_add(T::DbWeight::get().reads(91)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(z.into()))) - .saturating_add(T::DbWeight::get().writes(8)) - .saturating_add(Weight::from_parts(0, 1752).saturating_mul(z.into())) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9832 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - /// The range of component `y` is `[1, 99]`. - /// The range of component `z` is `[1, 10000]`. - fn first_contribution_ends_round_with_ct_deposit(_y: u32, z: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `34409 + y * (1339 ±0) + z * (28 ±0)` - // Estimated: `248750 + z * (1752 ±198)` - // Minimum execution time: 6_652_000_000 picoseconds. - Weight::from_parts(6_691_000_000, 0) - .saturating_add(Weight::from_parts(0, 248750)) - // Standard Error: 4_584_644 - .saturating_add(Weight::from_parts(40_419_101, 0).saturating_mul(z.into())) - .saturating_add(T::DbWeight::get().reads(91)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(z.into()))) - .saturating_add(T::DbWeight::get().writes(8)) - .saturating_add(Weight::from_parts(0, 1752).saturating_mul(z.into())) - } } diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 5c94b4409..60cea2edd 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -1192,7 +1192,7 @@ mod benchmarks { // - We know that it does not require to unbond the lowest contribution // - We know it doesn't end the round #[benchmark] - fn first_contribution_no_ct_deposit() { + fn first_contribution_with_ct_deposit() { // How many other contributions the user did for that same project let x = 0; let ends_round = None; @@ -1236,7 +1236,7 @@ mod benchmarks { // - We know that it does not require to unbond the lowest contribution // - We know it doesn't end the round #[benchmark] - fn first_contribution_with_ct_deposit() { + fn first_contribution_no_ct_deposit() { // How many other contributions the user did for that same project let x = 0; let ends_round = None; @@ -1277,7 +1277,7 @@ mod benchmarks { ); } #[benchmark] - fn first_contribution_ends_round_no_ct_deposit( + fn first_contribution_ends_round_with_ct_deposit( // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the extrinsic pass y: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, // Total amount of storage items iterated through in `ProjectsToUpdate` when trying to remove our project in `remove_from_update_store`. @@ -1322,7 +1322,7 @@ mod benchmarks { } #[benchmark] - fn first_contribution_ends_round_with_ct_deposit( + fn first_contribution_ends_round_no_ct_deposit( // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the extrinsic pass y: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, // Total amount of storage items iterated through in `ProjectsToUpdate` when trying to remove our project in `remove_from_update_store`. @@ -2553,16 +2553,30 @@ mod benchmarks { // } #[test] - fn bench_first_contribution() { + fn bench_first_contribution_no_ct_deposit() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_first_contribution_no_ct_deposit()); + }); + } + + #[test] + fn bench_first_contribution_with_ct_deposit() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_first_contribution_with_ct_deposit()); + }); + } + + #[test] + fn bench_first_contribution_ends_round_no_ct_deposit() { new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_first_contribution()); + assert_ok!(PalletFunding::::test_first_contribution_ends_round_no_ct_deposit()); }); } #[test] - fn bench_first_contribution_ends_round() { + fn bench_first_contribution_ends_round_with_ct_deposit() { new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_first_contribution_ends_round()); + assert_ok!(PalletFunding::::test_first_contribution_ends_round_with_ct_deposit()); }); } From 10c02930f0863a08e889223cc3a5f0e0398ae14c Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 29 Jan 2024 12:10:19 +0100 Subject: [PATCH 152/212] modify contribution function to return new bench fns Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/functions.rs | 31 +++++++++++++++++++++++++------ pallets/funding/src/weights.rs | 20 ++++++++++++++++---- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 33d4d6c1e..3816ab14a 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -1155,6 +1155,7 @@ impl Pallet { } let mut weight_contribution_flag: WeightContributionFlag; let mut weight_round_end_flag: Option = None; + let mut weight_ct_account_deposit = false; if caller_existing_contributions.len() == 0 { weight_contribution_flag = WeightContributionFlag::FirstContribution; @@ -1222,6 +1223,7 @@ impl Pallet { // Reserve plmc deposit to create a contribution token account for this project if T::NativeCurrency::balance_on_hold(&HoldReason::FutureDeposit(project_id).into(), &contributor) < ct_deposit { + weight_ct_account_deposit = true; T::NativeCurrency::hold(&HoldReason::FutureDeposit(project_id).into(), &contributor, ct_deposit)?; } @@ -1310,23 +1312,39 @@ impl Pallet { }); // return correct weight function - match (weight_contribution_flag, weight_round_end_flag) { - (WeightContributionFlag::FirstContribution, None) => Ok(PostDispatchInfo { - actual_weight: Some(WeightInfoOf::::first_contribution()), + match (weight_contribution_flag, weight_round_end_flag, weight_ct_account_deposit) { + (WeightContributionFlag::FirstContribution, None, false) => Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::first_contribution_no_ct_deposit()), + pays_fee: Pays::Yes, + }), + (WeightContributionFlag::FirstContribution, None, true) => Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::first_contribution_with_ct_deposit()), + pays_fee: Pays::Yes, + }), + ( + WeightContributionFlag::FirstContribution, + Some(WeightRoundEndFlag { fully_filled_vecs_from_insertion, total_vecs_in_storage }), + false, + ) => Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::first_contribution_ends_round_no_ct_deposit( + fully_filled_vecs_from_insertion, + total_vecs_in_storage, + )), pays_fee: Pays::Yes, }), ( WeightContributionFlag::FirstContribution, Some(WeightRoundEndFlag { fully_filled_vecs_from_insertion, total_vecs_in_storage }), + true, ) => Ok(PostDispatchInfo { - actual_weight: Some(WeightInfoOf::::first_contribution_ends_round( + actual_weight: Some(WeightInfoOf::::first_contribution_ends_round_with_ct_deposit( fully_filled_vecs_from_insertion, total_vecs_in_storage, )), pays_fee: Pays::Yes, }), - (WeightContributionFlag::SecondToLimitContribution, None) => Ok(PostDispatchInfo { + (WeightContributionFlag::SecondToLimitContribution, None, _) => Ok(PostDispatchInfo { actual_weight: Some(WeightInfoOf::::second_to_limit_contribution( caller_existing_contributions.len() as u32, )), @@ -1335,6 +1353,7 @@ impl Pallet { ( WeightContributionFlag::SecondToLimitContribution, Some(WeightRoundEndFlag { fully_filled_vecs_from_insertion, total_vecs_in_storage }), + _, ) => Ok(PostDispatchInfo { actual_weight: Some(WeightInfoOf::::second_to_limit_contribution_ends_round( caller_existing_contributions.len() as u32, @@ -1345,7 +1364,7 @@ impl Pallet { }), // a contribution over the limit means removing an existing contribution, therefore you cannot have a round end - (WeightContributionFlag::OverLimitContribution, _) => Ok(PostDispatchInfo { + (WeightContributionFlag::OverLimitContribution, _, _) => Ok(PostDispatchInfo { actual_weight: Some(WeightInfoOf::::contribution_over_limit()), pays_fee: Pays::Yes, }), diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index 06ed6d33a..1fd06834e 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -61,8 +61,11 @@ pub trait WeightInfo { fn evaluation_over_limit() -> Weight; fn bid() -> Weight; - fn first_contribution() -> Weight; - fn first_contribution_ends_round(y: u32, z: u32, ) -> Weight; + fn first_contribution_with_ct_deposit() -> Weight; + fn first_contribution_no_ct_deposit() -> Weight; + + fn first_contribution_ends_round_with_ct_deposit(y: u32, z: u32, ) -> Weight; + fn first_contribution_ends_round_no_ct_deposit(y: u32, z: u32, ) -> Weight; fn second_to_limit_contribution(x: u32, ) -> Weight; fn second_to_limit_contribution_ends_round(x: u32, y: u32, z: u32, ) -> Weight; fn contribution_over_limit() -> Weight; @@ -179,14 +182,23 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().writes(7_u64)) } - fn first_contribution() -> Weight { + fn first_contribution_no_ct_deposit() -> Weight { Weight::from_parts(140_000_000, 6208) } - fn first_contribution_ends_round(y: u32, z: u32) -> Weight { + fn first_contribution_with_ct_deposit() -> Weight { + Weight::from_parts(140_000_000, 6208) + + } + + fn first_contribution_ends_round_no_ct_deposit(y: u32, z: u32) -> Weight { Weight::from_parts(140_000_000, 6208) + } + fn first_contribution_ends_round_with_ct_deposit(y: u32, z: u32) -> Weight { + Weight::from_parts(140_000_000, 6208) + } fn second_to_limit_contribution(x: u32) -> Weight { From 04b0befe5b977c5b981be720d7f5243b66ff68aa Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 29 Jan 2024 12:22:10 +0100 Subject: [PATCH 153/212] removed chance to bid over the limit by removing the lowest bid. Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 1 - pallets/funding/src/functions.rs | 27 +++------------------------ pallets/funding/src/lib.rs | 2 ++ 3 files changed, 5 insertions(+), 25 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 60cea2edd..c11bee6df 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -867,7 +867,6 @@ mod benchmarks { // branches: // - ct account deposit // - amount of times where `perform_bid` is called (i.e how many buckets) - // - reached max bids and needs to unbond one #[benchmark] fn bid(x: Linear<1, 20>) { // * setup * diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 3816ab14a..280fbf98b 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -975,6 +975,8 @@ impl Pallet { let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; let plmc_usd_price = T::PriceProvider::get_price(PLMC_STATEMINT_ID).ok_or(Error::::PriceNotFound)?; let ct_deposit = T::ContributionTokenCurrency::deposit_required(project_id); + let existing_bids = Bids::::iter_prefix_values((project_id, bidder)).collect::>(); + // benchmark variables // * Validity checks * @@ -984,6 +986,7 @@ impl Pallet { ensure!(funding_asset == project_metadata.participation_currencies, Error::::FundingAssetNotAccepted); // Note: We limit the CT Amount to the total allocation size, to avoid long running loops. ensure!(ct_amount <= project_metadata.total_allocation_size.0, Error::::NotAllowed); + ensure!(existing_bids.len() < T::MaxBidsPerUser::get() as usize, Error::::TooManyBids); // Reserve plmc deposit to create a contribution token account for this project if T::NativeCurrency::balance_on_hold(&HoldReason::FutureDeposit(project_id).into(), &bidder) < ct_deposit { @@ -1044,7 +1047,6 @@ impl Pallet { let ticket_size = ct_usd_price.checked_mul_int(ct_amount).ok_or(Error::::BadMath)?; let funding_asset_usd_price = T::PriceProvider::get_price(funding_asset.to_statemint_id()).ok_or(Error::::PriceNotFound)?; - let existing_bids = Bids::::iter_prefix_values((project_id, bidder)).collect::>(); if let Some(minimum_ticket_size) = project_ticket_size.minimum { // Make sure the bid amount is greater than the minimum specified by the issuer @@ -1082,29 +1084,6 @@ impl Pallet { ct_migration_status: MigrationStatus::NotStarted, }; - // * Update storage * - if existing_bids.len() >= T::MaxBidsPerUser::get() as usize { - let lowest_bid = existing_bids.iter().min_by_key(|bid| &bid.id).ok_or(Error::::ImpossibleState)?; - - // TODO: Check how to handle this - // ensure!(new_bid.plmc_bond > lowest_bid.plmc_bond, Error::::BidTooLow); - - T::NativeCurrency::release( - &HoldReason::Participation(project_id.into()).into(), - &lowest_bid.bidder, - lowest_bid.plmc_bond, - Precision::Exact, - )?; - T::FundingCurrency::transfer( - asset_id, - &Self::fund_account_id(project_id), - &lowest_bid.bidder, - lowest_bid.funding_asset_amount_locked, - Preservation::Expendable, - )?; - Bids::::remove((project_id, &lowest_bid.bidder, lowest_bid.id)); - } - Self::try_plmc_participation_lock(bidder, project_id, plmc_bond)?; Self::try_funding_asset_hold(bidder, project_id, funding_asset_amount_locked, asset_id)?; diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 05e320eb3..8b1e58f0f 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -936,6 +936,8 @@ pub mod pallet { NotEnoughFundsForEscrowCreation, /// Too many attempts to insert project in to ProjectsToUpdate storage TooManyInsertionAttempts, + /// Reached bid limit for this user on this project + TooManyBids, } #[pallet::call] From 83519f1d23b037ffab7adef7ba90bb7568dc4f11 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 29 Jan 2024 13:23:08 +0100 Subject: [PATCH 154/212] bid benchmark abstracted for future complexity parametrization Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 206 ++++++++++++++++++++-------- 1 file changed, 152 insertions(+), 54 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index c11bee6df..2f32fff6a 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -864,20 +864,31 @@ mod benchmarks { ); } - // branches: - // - ct account deposit - // - amount of times where `perform_bid` is called (i.e how many buckets) - #[benchmark] - fn bid(x: Linear<1, 20>) { + fn bid_setup( + x: u32, + ) -> ( + BenchInstantiator, + ProjectId, + ProjectMetadataOf, + BidParams, + Vec>, + BalanceOf, + BalanceOf, + BalanceOf, + BalanceOf, + ) + where + ::Balance: From, + ::Price: From, + T::Hash: From, + ::RuntimeEvent: From>, + { // * setup * let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - let issuer = account::>("issuer", 0, 0); let bidder = account::>("bidder", 0, 0); whitelist_account!(bidder); @@ -893,47 +904,88 @@ mod benchmarks { 1u8, AcceptedFundingAsset::USDT, ); - let bid_params = inst.simulate_bids_with_bucket(vec![bid_params], project_id)[0].clone(); + let original_extrinsic_bid = bid_params.clone(); + let extrinsic_bids_post_bucketing = inst.simulate_bids_with_bucket(vec![bid_params], project_id); let necessary_plmc: Vec> = - BenchInstantiator::::calculate_auction_plmc_spent(&vec![bid_params.clone()], None); + BenchInstantiator::::calculate_auction_plmc_spent(&extrinsic_bids_post_bucketing, None); let existential_deposits: Vec> = necessary_plmc.accounts().existential_deposits(); let ct_account_deposits = necessary_plmc.accounts().ct_account_deposits(); let necessary_usdt: Vec> = - BenchInstantiator::::calculate_auction_funding_asset_spent(&vec![bid_params.clone()], None); + BenchInstantiator::::calculate_auction_funding_asset_spent(&extrinsic_bids_post_bucketing, None); + let escrow_account = Pallet::::fund_account_id(project_id); + let prev_total_escrow_usdt_locked = + inst.get_free_statemint_asset_balances_for(usdt_id(), vec![escrow_account.clone()]); inst.mint_plmc_to(necessary_plmc.clone()); inst.mint_plmc_to(existential_deposits.clone()); inst.mint_plmc_to(ct_account_deposits.clone()); inst.mint_statemint_asset_to(necessary_usdt.clone()); - #[extrinsic_call] - bid(RawOrigin::Signed(bidder.clone()), project_id, bid_params.amount, bid_params.multiplier, bid_params.asset); + let mut total_free_plmc = existential_deposits[0].plmc_amount; + let total_plmc_participation_bonded = + BenchInstantiator::::sum_balance_mappings(vec![necessary_plmc.clone()]); + let mut total_free_usdt = Zero::zero(); + let total_escrow_usdt_locked = BenchInstantiator::::sum_statemint_mappings(vec![ + necessary_usdt.clone(), + prev_total_escrow_usdt_locked.clone(), + ]); + + ( + inst, + project_id, + project_metadata, + original_extrinsic_bid, + extrinsic_bids_post_bucketing, + total_free_plmc, + total_plmc_participation_bonded, + total_free_usdt, + total_escrow_usdt_locked, + ) + } + fn bid_verification( + mut inst: BenchInstantiator, + project_id: ProjectId, + project_metadata: ProjectMetadataOf, + extrinsic_bids_post_bucketing: Vec>, + total_free_plmc: BalanceOf, + total_plmc_bonded: BalanceOf, + total_free_usdt: BalanceOf, + total_usdt_locked: BalanceOf, + ) -> () + where + ::Balance: From, + ::Price: From, + T::Hash: From, + ::RuntimeEvent: From>, + { // * validity checks * + + let bidder = extrinsic_bids_post_bucketing[0].bidder.clone(); // Storage - let stored_bid = Bids::::iter_prefix_values((project_id, bidder.clone())) - .sorted_by(|a, b| a.id.cmp(&b.id)) - .last() - .unwrap(); - let bid_filter = BidInfoFilter:: { - id: None, - project_id: Some(project_id), - bidder: Some(bidder.clone()), - status: Some(BidStatus::YetUnknown), - original_ct_amount: Some(bid_params.amount), - original_ct_usd_price: Some(bid_params.price), - final_ct_amount: Some(bid_params.amount), - final_ct_usd_price: Some(bid_params.price), - funding_asset: Some(AcceptedFundingAsset::USDT), - funding_asset_amount_locked: Some(necessary_usdt[0].asset_amount), - multiplier: Some(bid_params.multiplier), - plmc_bond: Some(necessary_plmc[0].plmc_amount), - plmc_vesting_info: Some(None), - when: None, - funds_released: Some(false), - ct_minted: Some(false), - }; - assert!(bid_filter.matches_bid(&stored_bid)); + for bid_params in extrinsic_bids_post_bucketing.clone() { + let bid_filter = BidInfoFilter:: { + id: None, + project_id: Some(project_id), + bidder: Some(bidder.clone()), + status: Some(BidStatus::YetUnknown), + original_ct_amount: Some(bid_params.amount), + original_ct_usd_price: Some(bid_params.price), + final_ct_amount: Some(bid_params.amount), + final_ct_usd_price: Some(bid_params.price), + funding_asset: Some(AcceptedFundingAsset::USDT), + funding_asset_amount_locked: None, + multiplier: Some(bid_params.multiplier), + plmc_bond: None, + plmc_vesting_info: Some(None), + when: None, + funds_released: Some(false), + ct_minted: Some(false), + }; + Bids::::iter_prefix_values((project_id, bidder.clone())) + .find(|stored_bid| bid_filter.matches_bid(stored_bid)) + .expect("bid not found"); + } // Bucket Storage Check let bucket_delta_amount = Percent::from_percent(10) * project_metadata.total_allocation_size.0; @@ -946,7 +998,9 @@ mod benchmarks { bucket_delta_amount, ); - starting_bucket.update(bid_params.amount); + for bid_params in extrinsic_bids_post_bucketing.clone() { + starting_bucket.update(bid_params.amount); + } let current_bucket = Buckets::::get(project_id).unwrap(); assert_eq!(current_bucket, starting_bucket); @@ -955,23 +1009,67 @@ mod benchmarks { let bonded_plmc = inst .get_reserved_plmc_balances_for(vec![bidder.clone()], HoldReason::Participation(project_id).into())[0] .plmc_amount; - assert_eq!(bonded_plmc, necessary_plmc[0].plmc_amount); + assert_eq!(bonded_plmc, total_plmc_bonded); let free_plmc = inst.get_free_plmc_balances_for(vec![bidder.clone()])[0].plmc_amount; - assert_eq!(free_plmc, existential_deposits[0].plmc_amount); + assert_eq!(free_plmc, total_free_plmc); + + let escrow_account = Pallet::::fund_account_id(project_id); + let locked_usdt = + inst.get_free_statemint_asset_balances_for(usdt_id(), vec![escrow_account.clone()])[0].asset_amount; + assert_eq!(locked_usdt, total_usdt_locked); let free_usdt = inst.get_free_statemint_asset_balances_for(usdt_id(), vec![bidder])[0].asset_amount; - assert_eq!(free_usdt, 0.into()); + assert_eq!(free_usdt, total_free_usdt); // Events - frame_system::Pallet::::assert_last_event( - Event::Bid { - project_id, - amount: bid_params.amount, - price: bid_params.price, - multiplier: bid_params.multiplier, - } - .into(), + for bid_params in extrinsic_bids_post_bucketing { + frame_system::Pallet::::assert_last_event( + Event::Bid { + project_id, + amount: bid_params.amount, + price: bid_params.price, + multiplier: bid_params.multiplier, + } + .into(), + ); + } + } + // branches: + // - ct account deposit + // - amount of times where `perform_bid` is called (i.e how many buckets) + #[benchmark] + fn bid(x: Linear<1, 20>) { + let ( + mut inst, + project_id, + project_metadata, + original_extrinsic_bid, + extrinsic_bids_post_bucketing, + total_free_plmc, + total_plmc_bonded, + total_free_usdt, + total_usdt_locked, + ) = bid_setup::(x); + + #[extrinsic_call] + bid( + RawOrigin::Signed(original_extrinsic_bid.bidder.clone()), + project_id, + original_extrinsic_bid.amount, + original_extrinsic_bid.multiplier, + original_extrinsic_bid.asset, + ); + + bid_verification::( + inst, + project_id, + project_metadata, + extrinsic_bids_post_bucketing, + total_free_plmc, + total_plmc_bonded, + total_free_usdt, + total_usdt_locked, ); } @@ -2544,12 +2642,12 @@ mod benchmarks { }); } - // #[test] - // fn bench_bid() { - // new_test_ext().execute_with(|| { - // assert_ok!(PalletFunding::::test_bid()); - // }); - // } + #[test] + fn bench_bid() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_bid()); + }); + } #[test] fn bench_first_contribution_no_ct_deposit() { From 70126695221b04ce6cdd8f3f38fa935976f80634 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 29 Jan 2024 15:24:49 +0100 Subject: [PATCH 155/212] complexity parameter `x` working (existing bids). Missing `y` for times "perform_bid" is called Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 70 +++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 18 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 2f32fff6a..f442ea18e 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -872,6 +872,7 @@ mod benchmarks { ProjectMetadataOf, BidParams, Vec>, + Vec>, BalanceOf, BalanceOf, BalanceOf, @@ -897,37 +898,63 @@ mod benchmarks { let project_id = inst.create_auctioning_project(project_metadata.clone(), issuer, default_evaluations::()); - let bid_params = BidParams::new( + let existing_bid = BidParams::new( bidder.clone(), - (50000u128 * ASSET_UNIT).into(), + (100u128 * ASSET_UNIT).into(), 1_u128.into(), - 1u8, + 5u8, AcceptedFundingAsset::USDT, ); - let original_extrinsic_bid = bid_params.clone(); - let extrinsic_bids_post_bucketing = inst.simulate_bids_with_bucket(vec![bid_params], project_id); - let necessary_plmc: Vec> = - BenchInstantiator::::calculate_auction_plmc_spent(&extrinsic_bids_post_bucketing, None); - let existential_deposits: Vec> = necessary_plmc.accounts().existential_deposits(); - let ct_account_deposits = necessary_plmc.accounts().ct_account_deposits(); - let necessary_usdt: Vec> = - BenchInstantiator::::calculate_auction_funding_asset_spent(&extrinsic_bids_post_bucketing, None); + let existing_bids = vec![existing_bid; x as usize]; + let existing_bids_post_bucketing = inst.simulate_bids_with_bucket(existing_bids.clone(), project_id); + let plmc_for_existing_bids = + BenchInstantiator::::calculate_auction_plmc_spent(&existing_bids_post_bucketing, None); + + let existential_deposits: Vec> = vec![bidder.clone()].existential_deposits(); + let ct_account_deposits = vec![bidder.clone()].ct_account_deposits(); + + let usdt_for_existing_bids: Vec> = + BenchInstantiator::::calculate_auction_funding_asset_spent(&existing_bids_post_bucketing, None); let escrow_account = Pallet::::fund_account_id(project_id); let prev_total_escrow_usdt_locked = inst.get_free_statemint_asset_balances_for(usdt_id(), vec![escrow_account.clone()]); - inst.mint_plmc_to(necessary_plmc.clone()); + inst.mint_plmc_to(plmc_for_existing_bids.clone()); inst.mint_plmc_to(existential_deposits.clone()); inst.mint_plmc_to(ct_account_deposits.clone()); - inst.mint_statemint_asset_to(necessary_usdt.clone()); + inst.mint_statemint_asset_to(usdt_for_existing_bids.clone()); + + // do "x" contributions for this user + inst.bid_for_users(project_id, existing_bids_post_bucketing.clone()).expect("All bids are accepted"); + + let extrinsic_bid = BidParams::new( + bidder.clone(), + (1000u128 * ASSET_UNIT).into(), + 1_u128.into(), + 1u8, + AcceptedFundingAsset::USDT, + ); + let original_extrinsic_bid = extrinsic_bid.clone(); + // we need to call this after bidding `x` amount of times, to get the latest bucket from storage + let extrinsic_bids_post_bucketing = inst.simulate_bids_with_bucket(vec![extrinsic_bid], project_id); + + let plmc_for_extrinsic_bids: Vec> = + BenchInstantiator::::calculate_auction_plmc_spent(&extrinsic_bids_post_bucketing, None); + let usdt_for_extrinsic_bids: Vec> = + BenchInstantiator::::calculate_auction_funding_asset_spent(&extrinsic_bids_post_bucketing, None); + inst.mint_plmc_to(plmc_for_extrinsic_bids.clone()); + inst.mint_statemint_asset_to(usdt_for_extrinsic_bids.clone()); let mut total_free_plmc = existential_deposits[0].plmc_amount; - let total_plmc_participation_bonded = - BenchInstantiator::::sum_balance_mappings(vec![necessary_plmc.clone()]); + let total_plmc_participation_bonded = BenchInstantiator::::sum_balance_mappings(vec![ + plmc_for_extrinsic_bids.clone(), + plmc_for_existing_bids.clone(), + ]); let mut total_free_usdt = Zero::zero(); let total_escrow_usdt_locked = BenchInstantiator::::sum_statemint_mappings(vec![ - necessary_usdt.clone(), prev_total_escrow_usdt_locked.clone(), + usdt_for_extrinsic_bids.clone(), + usdt_for_existing_bids.clone(), ]); ( @@ -936,6 +963,7 @@ mod benchmarks { project_metadata, original_extrinsic_bid, extrinsic_bids_post_bucketing, + existing_bids_post_bucketing, total_free_plmc, total_plmc_participation_bonded, total_free_usdt, @@ -948,6 +976,7 @@ mod benchmarks { project_id: ProjectId, project_metadata: ProjectMetadataOf, extrinsic_bids_post_bucketing: Vec>, + existing_bids_post_bucketing: Vec>, total_free_plmc: BalanceOf, total_plmc_bonded: BalanceOf, total_free_usdt: BalanceOf, @@ -998,6 +1027,9 @@ mod benchmarks { bucket_delta_amount, ); + for bid_params in existing_bids_post_bucketing.clone() { + starting_bucket.update(bid_params.amount); + } for bid_params in extrinsic_bids_post_bucketing.clone() { starting_bucket.update(bid_params.amount); } @@ -1039,13 +1071,14 @@ mod benchmarks { // - ct account deposit // - amount of times where `perform_bid` is called (i.e how many buckets) #[benchmark] - fn bid(x: Linear<1, 20>) { + fn bid(x: Linear<0, { T::MaxBidsPerUser::get() - 1 }>) { let ( mut inst, project_id, project_metadata, original_extrinsic_bid, extrinsic_bids_post_bucketing, + existing_bids_post_bucketing, total_free_plmc, total_plmc_bonded, total_free_usdt, @@ -1066,6 +1099,7 @@ mod benchmarks { project_id, project_metadata, extrinsic_bids_post_bucketing, + existing_bids_post_bucketing, total_free_plmc, total_plmc_bonded, total_free_usdt, @@ -1162,7 +1196,7 @@ mod benchmarks { inst.mint_statemint_asset_to(usdt_for_extrinsic_contribution.clone()); // do "x" contributions for this user - inst.contribute_for_users(project_id, existing_contributions).expect("All evaluations are accepted"); + inst.contribute_for_users(project_id, existing_contributions).expect("All contributions are accepted"); let mut total_plmc_bonded = BenchInstantiator::::sum_balance_mappings(vec![ plmc_for_existing_contributions.clone(), From 22ea0037b160557afb3cae59bdd69d411c88677f Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 29 Jan 2024 17:58:07 +0100 Subject: [PATCH 156/212] new parameter "y" for amount of perform_bid calls on one extrinsic Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 72 +++++++++++++++++++++++------ pallets/funding/src/instantiator.rs | 17 +++++++ pallets/funding/src/tests.rs | 18 ++++++++ 3 files changed, 94 insertions(+), 13 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index f442ea18e..bdc4a3340 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -865,12 +865,14 @@ mod benchmarks { } fn bid_setup( - x: u32, + existing_bids_count: u32, + do_perform_bid_calls: u32, ) -> ( BenchInstantiator, ProjectId, ProjectMetadataOf, BidParams, + Option>, Vec>, Vec>, BalanceOf, @@ -905,7 +907,7 @@ mod benchmarks { 5u8, AcceptedFundingAsset::USDT, ); - let existing_bids = vec![existing_bid; x as usize]; + let existing_bids = vec![existing_bid; existing_bids_count as usize]; let existing_bids_post_bucketing = inst.simulate_bids_with_bucket(existing_bids.clone(), project_id); let plmc_for_existing_bids = BenchInstantiator::::calculate_auction_plmc_spent(&existing_bids_post_bucketing, None); @@ -927,17 +929,53 @@ mod benchmarks { // do "x" contributions for this user inst.bid_for_users(project_id, existing_bids_post_bucketing.clone()).expect("All bids are accepted"); - let extrinsic_bid = BidParams::new( - bidder.clone(), - (1000u128 * ASSET_UNIT).into(), - 1_u128.into(), - 1u8, - AcceptedFundingAsset::USDT, - ); + // to call do_perform_bid several times, we need the bucket to reach its limit. You can only bid over 10 buckets + // in a single bid, since the increase delta is 10% of the total allocation, and you cannot bid more than the allocation. + let mut ct_amount = (1000u128 * ASSET_UNIT).into(); + let mut maybe_filler_bid = None; + let new_bidder = account::>("new_bidder", 0, 0); + + let mut usdt_for_filler_bidder = vec![UserToStatemintAsset::::new( + new_bidder.clone(), + Zero::zero(), + AcceptedFundingAsset::USDT.to_statemint_id(), + )]; + if do_perform_bid_calls > 0 { + let current_bucket = Buckets::::get(project_id).unwrap(); + // first lets bring the bucket to almost its limit with another bidder: + assert!(new_bidder.clone() != bidder.clone()); + let mut bid_params = BidParams::new( + new_bidder, + current_bucket.amount_left, + // not used atm + 1_u128.into(), + 1u8, + AcceptedFundingAsset::USDT, + ); + maybe_filler_bid = Some(bid_params.clone()); + let plmc_for_new_bidder = + BenchInstantiator::::calculate_auction_plmc_spent(&vec![bid_params.clone()], None); + let plmc_ed = plmc_for_new_bidder.accounts().existential_deposits(); + let plmc_ct_deposit = plmc_for_new_bidder.accounts().ct_account_deposits(); + let usdt_for_new_bidder = + BenchInstantiator::::calculate_auction_funding_asset_spent(&vec![bid_params.clone()], None); + + inst.mint_plmc_to(plmc_for_new_bidder); + inst.mint_plmc_to(plmc_ed); + inst.mint_plmc_to(plmc_ct_deposit); + inst.mint_statemint_asset_to(usdt_for_new_bidder.clone()); + + inst.bid_for_users(project_id, vec![bid_params]).expect("new bidder can bid"); + + ct_amount = Percent::from_percent(10) * + (project_metadata.total_allocation_size.0 * (do_perform_bid_calls as u128).into()); + usdt_for_filler_bidder = usdt_for_new_bidder; + } + let extrinsic_bid = BidParams::new(bidder.clone(), ct_amount, 1_u128.into(), 1u8, AcceptedFundingAsset::USDT); let original_extrinsic_bid = extrinsic_bid.clone(); // we need to call this after bidding `x` amount of times, to get the latest bucket from storage let extrinsic_bids_post_bucketing = inst.simulate_bids_with_bucket(vec![extrinsic_bid], project_id); - + assert_eq!(extrinsic_bids_post_bucketing.len(), (do_perform_bid_calls as usize).max(1usize)); let plmc_for_extrinsic_bids: Vec> = BenchInstantiator::::calculate_auction_plmc_spent(&extrinsic_bids_post_bucketing, None); let usdt_for_extrinsic_bids: Vec> = @@ -955,6 +993,7 @@ mod benchmarks { prev_total_escrow_usdt_locked.clone(), usdt_for_extrinsic_bids.clone(), usdt_for_existing_bids.clone(), + usdt_for_filler_bidder.clone(), ]); ( @@ -962,6 +1001,7 @@ mod benchmarks { project_id, project_metadata, original_extrinsic_bid, + maybe_filler_bid, extrinsic_bids_post_bucketing, existing_bids_post_bucketing, total_free_plmc, @@ -975,6 +1015,7 @@ mod benchmarks { mut inst: BenchInstantiator, project_id: ProjectId, project_metadata: ProjectMetadataOf, + maybe_filler_bid: Option>, extrinsic_bids_post_bucketing: Vec>, existing_bids_post_bucketing: Vec>, total_free_plmc: BalanceOf, @@ -1030,6 +1071,9 @@ mod benchmarks { for bid_params in existing_bids_post_bucketing.clone() { starting_bucket.update(bid_params.amount); } + if let Some(bid_params) = maybe_filler_bid { + starting_bucket.update(bid_params.amount); + } for bid_params in extrinsic_bids_post_bucketing.clone() { starting_bucket.update(bid_params.amount); } @@ -1056,7 +1100,7 @@ mod benchmarks { // Events for bid_params in extrinsic_bids_post_bucketing { - frame_system::Pallet::::assert_last_event( + frame_system::Pallet::::assert_has_event( Event::Bid { project_id, amount: bid_params.amount, @@ -1071,19 +1115,20 @@ mod benchmarks { // - ct account deposit // - amount of times where `perform_bid` is called (i.e how many buckets) #[benchmark] - fn bid(x: Linear<0, { T::MaxBidsPerUser::get() - 1 }>) { + fn bid(x: Linear<0, { T::MaxBidsPerUser::get() - 1 }>, y: Linear<0, 10>) { let ( mut inst, project_id, project_metadata, original_extrinsic_bid, + maybe_filler_bid, extrinsic_bids_post_bucketing, existing_bids_post_bucketing, total_free_plmc, total_plmc_bonded, total_free_usdt, total_usdt_locked, - ) = bid_setup::(x); + ) = bid_setup::(x, y); #[extrinsic_call] bid( @@ -1098,6 +1143,7 @@ mod benchmarks { inst, project_id, project_metadata, + maybe_filler_bid, extrinsic_bids_post_bucketing, existing_bids_post_bucketing, total_free_plmc, diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 81e58e6a7..7e451310b 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -523,6 +523,23 @@ impl< output } + // Gives the ct_amount that would internally be split up in `desired_buckets` amount of bids. + // NOTE: buckets have increments of 10% of max allocation. And a bidder cannot bid for more CTs than the allocation size. + // This means that the amount of buckets in a single bid extrinsic is limited to 10. + pub fn reverse_simulate_bids_with_bucket(&mut self, project_id: ProjectId, desired_buckets: u32) -> BalanceOf { + let mut bucket: BucketOf = self.execute(|| Buckets::::get(project_id).unwrap()); + let mut amount = Zero::zero(); + let mut buckets_increased = 0; + + while buckets_increased < desired_buckets { + amount += bucket.amount_left; + bucket.update(bucket.amount_left); + buckets_increased += 1; + } + + amount + } + /// Filters the bids that would be rejected after the auction ends. pub fn filter_bids_after_auction(bids: Vec>, total_cts: BalanceOf) -> Vec> { let mut filtered_bids: Vec> = Vec::new(); diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 74cbc0837..ebca49ee1 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -5812,6 +5812,24 @@ mod test_helper_functions { assert_eq!(price_in_10_decimals, 16_3_333_333_333_u128); } + + #[test] + fn reverse_simulate_bids_with_bucket() { + let desired_buckets = 8; + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let project_metadata = default_project(inst.get_new_nonce(), ISSUER); + let project_id = inst.create_auctioning_project(project_metadata, ISSUER, default_evaluations()); + + let bucket = Buckets::::get(project_id).unwrap(); + // make sure base assumptions are valid: + assert_eq!(bucket.amount_left, 50_000 * ASSET_UNIT); + assert_eq!(bucket.current_price, 1u128.into()); + assert_eq!(bucket.delta_price, FixedU128::from_float(0.1)); + assert_eq!(bucket.delta_amount, 5_000 & ASSET_UNIT); + + let ct_amount = inst.reverse_simulate_bids_with_bucket(project_id, desired_buckets); + assert_eq!(ct_amount, 50_000 * ASSET_UNIT); + } } mod misc_features { From 20483f4435391d65fba86e619ce932fa6df97a0e Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 29 Jan 2024 17:58:28 +0100 Subject: [PATCH 157/212] remove unused bucket helper function Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/instantiator.rs | 17 ----------------- pallets/funding/src/tests.rs | 18 ------------------ 2 files changed, 35 deletions(-) diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 7e451310b..81e58e6a7 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -523,23 +523,6 @@ impl< output } - // Gives the ct_amount that would internally be split up in `desired_buckets` amount of bids. - // NOTE: buckets have increments of 10% of max allocation. And a bidder cannot bid for more CTs than the allocation size. - // This means that the amount of buckets in a single bid extrinsic is limited to 10. - pub fn reverse_simulate_bids_with_bucket(&mut self, project_id: ProjectId, desired_buckets: u32) -> BalanceOf { - let mut bucket: BucketOf = self.execute(|| Buckets::::get(project_id).unwrap()); - let mut amount = Zero::zero(); - let mut buckets_increased = 0; - - while buckets_increased < desired_buckets { - amount += bucket.amount_left; - bucket.update(bucket.amount_left); - buckets_increased += 1; - } - - amount - } - /// Filters the bids that would be rejected after the auction ends. pub fn filter_bids_after_auction(bids: Vec>, total_cts: BalanceOf) -> Vec> { let mut filtered_bids: Vec> = Vec::new(); diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index ebca49ee1..74cbc0837 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -5812,24 +5812,6 @@ mod test_helper_functions { assert_eq!(price_in_10_decimals, 16_3_333_333_333_u128); } - - #[test] - fn reverse_simulate_bids_with_bucket() { - let desired_buckets = 8; - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let project_metadata = default_project(inst.get_new_nonce(), ISSUER); - let project_id = inst.create_auctioning_project(project_metadata, ISSUER, default_evaluations()); - - let bucket = Buckets::::get(project_id).unwrap(); - // make sure base assumptions are valid: - assert_eq!(bucket.amount_left, 50_000 * ASSET_UNIT); - assert_eq!(bucket.current_price, 1u128.into()); - assert_eq!(bucket.delta_price, FixedU128::from_float(0.1)); - assert_eq!(bucket.delta_amount, 5_000 & ASSET_UNIT); - - let ct_amount = inst.reverse_simulate_bids_with_bucket(project_id, desired_buckets); - assert_eq!(ct_amount, 50_000 * ASSET_UNIT); - } } mod misc_features { From 4f634d61568f37b8b14fbc0f2961f46c80a3bdb9 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 30 Jan 2024 10:46:47 +0100 Subject: [PATCH 158/212] ct deposit bid benchmark difference Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 56 +++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index bdc4a3340..fe072c4af 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -1115,7 +1115,9 @@ mod benchmarks { // - ct account deposit // - amount of times where `perform_bid` is called (i.e how many buckets) #[benchmark] - fn bid(x: Linear<0, { T::MaxBidsPerUser::get() - 1 }>, y: Linear<0, 10>) { + fn bid_with_ct_deposit(y: Linear<0, 10>) { + // if x were > 0, then the ct deposit would already be paid + let x = 0; let ( mut inst, project_id, @@ -1153,6 +1155,47 @@ mod benchmarks { ); } + #[benchmark] + fn bid_no_ct_deposit(x: Linear<0, { T::MaxBidsPerUser::get() - 1 }>, y: Linear<0, 10>) { + let ( + mut inst, + project_id, + project_metadata, + original_extrinsic_bid, + maybe_filler_bid, + extrinsic_bids_post_bucketing, + existing_bids_post_bucketing, + total_free_plmc, + total_plmc_bonded, + total_free_usdt, + total_usdt_locked, + ) = bid_setup::(x, y); + + let _new_plmc_minted = make_ct_deposit_for::(original_extrinsic_bid.bidder.clone(), project_id); + + #[extrinsic_call] + bid( + RawOrigin::Signed(original_extrinsic_bid.bidder.clone()), + project_id, + original_extrinsic_bid.amount, + original_extrinsic_bid.multiplier, + original_extrinsic_bid.asset, + ); + + bid_verification::( + inst, + project_id, + project_metadata, + maybe_filler_bid, + extrinsic_bids_post_bucketing, + existing_bids_post_bucketing, + total_free_plmc, + total_plmc_bonded, + total_free_usdt, + total_usdt_locked, + ); + } + fn contribution_setup( x: u32, ends_round: Option<(u32, u32)>, @@ -2723,9 +2766,16 @@ mod benchmarks { } #[test] - fn bench_bid() { + fn bench_bid_with_ct_deposit() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_bid_with_ct_deposit()); + }); + } + + #[test] + fn bench_bid_no_ct_deposit() { new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_bid()); + assert_ok!(PalletFunding::::test_bid_no_ct_deposit()); }); } From 19d0998114668b6e49d11ac56c930d979bb28d1d Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 30 Jan 2024 14:18:30 +0100 Subject: [PATCH 159/212] real weight returns added for bid extrinsic. Trying to update now price calculation test Signed-off-by: Juan Ignacio Rios --- debug_weight_gen_v3.rs | 71 +++++++++++++++++---------- pallets/funding/src/benchmarking.rs | 4 +- pallets/funding/src/functions.rs | 22 ++++++++- pallets/funding/src/instantiator.rs | 12 ++--- pallets/funding/src/lib.rs | 10 +++- pallets/funding/src/tests.rs | 75 ++++++++++++++++++++--------- pallets/funding/src/weights.rs | 15 +++--- 7 files changed, 138 insertions(+), 71 deletions(-) diff --git a/debug_weight_gen_v3.rs b/debug_weight_gen_v3.rs index 5d24aad8c..2391aea31 100644 --- a/debug_weight_gen_v3.rs +++ b/debug_weight_gen_v3.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `pallet_funding` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-01-29, STEPS: `10`, REPEAT: `5`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-01-30, STEPS: `10`, REPEAT: `5`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `Juans-MBP.home`, CPU: `` //! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: 1024 @@ -15,7 +15,7 @@ // --steps=10 // --repeat=5 // --pallet=pallet_funding -// --extrinsic=first_contribution_no_ct_deposit,first_contribution_with_ct_deposit, +// --extrinsic=bid_no_ct_deposit,bid_with_ct_deposit // --output // ./debug_weight_gen_v3.rs @@ -30,60 +30,79 @@ use core::marker::PhantomData; /// Weight functions for `pallet_funding`. pub struct WeightInfo(PhantomData); impl pallet_funding::WeightInfo for WeightInfo { + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) /// Storage: `Oracle::Values` (r:2 w:0) /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:10) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) /// Storage: `Balances::Holds` (r:1 w:1) /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:1 w:1) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextBidId` (r:1 w:1) + /// Proof: `PolimecFunding::NextBidId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) /// Storage: `StatemintAssets::Asset` (r:1 w:1) /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) /// Storage: `StatemintAssets::Account` (r:2 w:2) /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - fn first_contribution_with_ct_deposit() -> Weight { + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// The range of component `y` is `[0, 10]`. + fn bid_with_ct_deposit(y: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1996` + // Measured: `2140` // Estimated: `6208` - // Minimum execution time: 2_126_000_000 picoseconds. - Weight::from_parts(2_136_000_000, 0) + // Minimum execution time: 2_186_000_000 picoseconds. + Weight::from_parts(1_479_823_232, 0) .saturating_add(Weight::from_parts(0, 6208)) - .saturating_add(T::DbWeight::get().reads(11)) + // Standard Error: 19_862_262 + .saturating_add(Weight::from_parts(1_083_494_949, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(12)) .saturating_add(T::DbWeight::get().writes(7)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) /// Storage: `Oracle::Values` (r:2 w:0) /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:256 w:10) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) /// Storage: `Balances::Holds` (r:1 w:1) /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:1 w:1) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextBidId` (r:1 w:1) + /// Proof: `PolimecFunding::NextBidId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) /// Storage: `StatemintAssets::Asset` (r:1 w:1) /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) /// Storage: `StatemintAssets::Account` (r:2 w:2) /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - fn first_contribution_no_ct_deposit() -> Weight { + /// The range of component `x` is `[0, 255]`. + /// The range of component `y` is `[0, 10]`. + fn bid_no_ct_deposit(x: u32, y: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2073` - // Estimated: `6208` - // Minimum execution time: 1_657_000_000 picoseconds. - Weight::from_parts(1_673_000_000, 0) + // Measured: `2218 + x * (164 ±0)` + // Estimated: `6208 + x * (2893 ±0)` + // Minimum execution time: 11_970_000_000 picoseconds. + Weight::from_parts(631_207_506, 0) .saturating_add(Weight::from_parts(0, 6208)) - .saturating_add(T::DbWeight::get().reads(11)) - .saturating_add(T::DbWeight::get().writes(7)) + // Standard Error: 510_923 + .saturating_add(Weight::from_parts(67_974_520, 0).saturating_mul(x.into())) + // Standard Error: 12_729_727 + .saturating_add(Weight::from_parts(1_143_574_647, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(12)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(6)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) + .saturating_add(Weight::from_parts(0, 2893).saturating_mul(x.into())) } } diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index fe072c4af..6736a5bc8 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -927,7 +927,7 @@ mod benchmarks { inst.mint_statemint_asset_to(usdt_for_existing_bids.clone()); // do "x" contributions for this user - inst.bid_for_users(project_id, existing_bids_post_bucketing.clone()).expect("All bids are accepted"); + inst.bid_for_users(project_id, existing_bids_post_bucketing.clone()); // to call do_perform_bid several times, we need the bucket to reach its limit. You can only bid over 10 buckets // in a single bid, since the increase delta is 10% of the total allocation, and you cannot bid more than the allocation. @@ -965,7 +965,7 @@ mod benchmarks { inst.mint_plmc_to(plmc_ct_deposit); inst.mint_statemint_asset_to(usdt_for_new_bidder.clone()); - inst.bid_for_users(project_id, vec![bid_params]).expect("new bidder can bid"); + inst.bid_for_users(project_id, vec![bid_params]); ct_amount = Percent::from_percent(10) * (project_metadata.total_allocation_size.0 * (do_perform_bid_calls as u128).into()); diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 280fbf98b..b20fa6354 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -969,7 +969,7 @@ impl Pallet { ct_amount: BalanceOf, multiplier: MultiplierOf, funding_asset: AcceptedFundingAsset, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; @@ -978,6 +978,9 @@ impl Pallet { let existing_bids = Bids::::iter_prefix_values((project_id, bidder)).collect::>(); // benchmark variables + let mut perform_bid_calls = 0; + let mut ct_deposit_required = false; + let existing_bids_amount = existing_bids.len() as u32; // * Validity checks * ensure!(ct_amount > Zero::zero(), Error::::BidTooLow); @@ -991,6 +994,7 @@ impl Pallet { // Reserve plmc deposit to create a contribution token account for this project if T::NativeCurrency::balance_on_hold(&HoldReason::FutureDeposit(project_id).into(), &bidder) < ct_deposit { T::NativeCurrency::hold(&HoldReason::FutureDeposit(project_id).into(), &bidder, ct_deposit)?; + ct_deposit_required = true } // Fetch current bucket details and other required info @@ -1021,6 +1025,9 @@ impl Pallet { now, plmc_usd_price, )?; + + perform_bid_calls += 1; + // Update current bucket, and reduce the amount to bid by the amount we just bid current_bucket.update(bid_amount); amount_to_bid.saturating_reduce(bid_amount); @@ -1029,7 +1036,18 @@ impl Pallet { // Note: If the bucket has been exhausted, the 'update' function has already made the 'current_bucket' point to the next one. Buckets::::insert(project_id, current_bucket); - Ok(()) + // if ct deposit was required, we already know it can only be the first bid, so existing_bids_amount == 0 + if ct_deposit_required { + Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::bid_with_ct_deposit(perform_bid_calls)), + pays_fee: Pays::Yes, + }) + } else { + Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::bid_no_ct_deposit(existing_bids_amount, perform_bid_calls)), + pays_fee: Pays::Yes, + }) + } } fn perform_do_bid( diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 81e58e6a7..897f7ea56 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -936,13 +936,11 @@ impl< project_id } - pub fn bid_for_users(&mut self, project_id: ProjectId, bids: Vec>) -> Result<(), DispatchError> { + pub fn bid_for_users(&mut self, project_id: ProjectId, bids: Vec>) { for bid in bids { - self.execute(|| { - crate::Pallet::::do_bid(&bid.bidder, project_id, bid.amount, bid.multiplier, bid.asset) - })?; + self.execute(|| crate::Pallet::::do_bid(&bid.bidder, project_id, bid.amount, bid.multiplier, bid.asset)) + .unwrap(); } - Ok(()) } pub fn start_community_funding(&mut self, project_id: ProjectId) -> Result<(), DispatchError> { @@ -1029,7 +1027,7 @@ impl< self.mint_plmc_to(plmc_ct_account_deposits.clone()); self.mint_statemint_asset_to(funding_asset_deposits.clone()); - self.bid_for_users(project_id, bids.clone()).expect("Bidding should work"); + self.bid_for_users(project_id, bids.clone()); self.do_reserved_plmc_assertions( total_plmc_participation_locked.merge_accounts(MergeOperation::Add), @@ -1755,7 +1753,7 @@ pub mod async_features { inst.mint_plmc_to(plmc_ct_account_deposits.clone()); inst.mint_statemint_asset_to(funding_asset_deposits.clone()); - inst.bid_for_users(project_id, bids.clone()).expect("Bidding should work"); + inst.bid_for_users(project_id, bids.clone()); inst.do_reserved_plmc_assertions( total_plmc_participation_locked.merge_accounts(MergeOperation::Add), diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 8b1e58f0f..c04cece99 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -995,14 +995,20 @@ pub mod pallet { /// Bid for a project in the Auction round #[pallet::call_index(5)] - #[pallet::weight(WeightInfoOf::::bid())] + #[pallet::weight(WeightInfoOf::::bid_no_ct_deposit( + // Last bid possible + ::MaxBidsPerUser::get() - 1, + // Assuming the current bucket is full, and has a price higher than the minimum. + // This user is buying 100% of the bid allocation, since each bucket has 10% of the allocation at a 10% increase + 10, + ))] pub fn bid( origin: OriginFor, project_id: ProjectId, #[pallet::compact] amount: BalanceOf, multiplier: T::Multiplier, asset: AcceptedFundingAsset, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { let bidder = ensure_signed(origin)?; Self::do_bid(&bidder, project_id, amount, multiplier, asset) } diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 74cbc0837..9050e7b27 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -748,9 +748,11 @@ mod auction_round_success { )]); inst.mint_statemint_asset_to(necessary_usdt_for_bid); - inst.bid_for_users(project_id, vec![evaluator_bid]).unwrap(); + inst.bid_for_users(project_id, vec![evaluator_bid]); } + // TODO: remove? + #[ignore] #[test] fn evaluation_bond_counts_towards_bid_vec_full() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); @@ -792,8 +794,8 @@ mod auction_round_success { inst.mint_statemint_asset_to(fill_necessary_usdt_for_bids); inst.mint_statemint_asset_to(bid_necessary_usdt); - inst.bid_for_users(project_id, bids).unwrap(); - inst.bid_for_users(project_id, vec![evaluator_bid]).unwrap(); + inst.bid_for_users(project_id, bids); + inst.bid_for_users(project_id, vec![evaluator_bid]); let evaluation_bonded = inst.execute(|| { ::NativeCurrency::balance_on_hold( @@ -829,21 +831,35 @@ mod auction_round_success { inst.mint_plmc_to(plmc_funding); inst.mint_statemint_asset_to(statemint_funding); - inst.bid_for_users(project_id, bids).unwrap(); + inst.bid_for_users(project_id, bids); inst.start_community_funding(project_id).unwrap(); - // let token_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); - - // let price_in_10_decimals = token_price.checked_mul_int(1_0_000_000_000_u128).unwrap(); - // let price_in_12_decimals = token_price.checked_mul_int(1_000_000_000_000_u128).unwrap(); - // assert_eq!(price_in_10_decimals, 16_3_333_333_333_u128); - // assert_eq!(price_in_12_decimals, 16_333_333_333_333_u128); } #[test] fn price_calculation_2() { // From the knowledge hub let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + // let bounded_name = BoundedVec::try_from("Contribution Token TEST".as_bytes().to_vec()).unwrap(); + // let bounded_symbol = BoundedVec::try_from("CTEST".as_bytes().to_vec()).unwrap(); + // let metadata_hash = hashed(format!("{}-{}", METADATA, inst.get_new_nonce())); + // let project_metadata = ProjectMetadata { + // token_information: CurrencyMetadata { + // name: bounded_name, + // symbol: bounded_symbol, + // decimals: ASSET_DECIMALS, + // }, + // mainnet_token_max_supply: 8_000_000 * ASSET_UNIT, + // total_allocation_size: (50_000 * ASSET_UNIT, 50_000 * ASSET_UNIT), + // minimum_price: PriceOf::::from_float(1.0), + // ticket_size: TicketSize { minimum: Some(1), maximum: None }, + // participants_size: ParticipantsSize { minimum: Some(2), maximum: None }, + // funding_thresholds: Default::default(), + // conversion_rate: 0, + // participation_currencies: AcceptedFundingAsset::USDT, + // funding_destination_account: ISSUER, + // offchain_information_hash: Some(metadata_hash), + // }; let project_metadata = default_project(inst.get_new_nonce(), ISSUER); let project_id = inst.create_auctioning_project(project_metadata, ISSUER, default_evaluations()); let bids = vec![ @@ -858,11 +874,13 @@ mod auction_round_success { let ct_account_deposits = plmc_funding.accounts().ct_account_deposits(); inst.mint_plmc_to(ed_funding); - inst.mint_plmc_to(plmc_funding); + inst.mint_plmc_to(plmc_funding.clone()); + inst.mint_plmc_to(plmc_funding.clone()); inst.mint_plmc_to(ct_account_deposits); - inst.mint_statemint_asset_to(statemint_funding); + inst.mint_statemint_asset_to(statemint_funding.clone()); + inst.mint_statemint_asset_to(statemint_funding.clone()); - inst.bid_for_users(project_id, bids).unwrap(); + inst.bid_for_users(project_id, bids); inst.start_community_funding(project_id).unwrap(); let token_price = inst.get_project_details(project_id).weighted_average_price.unwrap().to_float(); @@ -933,7 +951,7 @@ mod auction_round_success { multiplier: bid_info.multiplier, asset: bid_info.asset, }]; - inst.bid_for_users(project_id, bids.clone()).expect("Candle Bidding should not fail"); + inst.bid_for_users(project_id, bids.clone()); bids_made.push(bids[0].clone()); bidding_account += 1; @@ -1413,7 +1431,7 @@ mod auction_round_success { let bidders_funding_assets = MockInstantiator::calculate_auction_funding_asset_spent(&bids, None); inst.mint_statemint_asset_to(bidders_funding_assets); - inst.bid_for_users(project_id, bids).unwrap(); + inst.bid_for_users(project_id, bids); inst.start_community_funding(project_id).unwrap(); let final_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); @@ -1836,6 +1854,8 @@ mod auction_round_failure { }); } + // TODO: remove? + #[ignore] #[test] fn bids_overflow() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); @@ -1862,7 +1882,7 @@ mod auction_round_failure { // Fund enough for all bids inst.mint_statemint_asset_to(statemint_asset_fundings); - inst.bid_for_users(project_id, bids).expect("Bids should pass"); + inst.bid_for_users(project_id, bids); inst.execute(|| { let mut stored_bids = Bids::::iter_prefix_values((project_id, DAVE)).collect::>(); @@ -1879,11 +1899,18 @@ mod auction_round_failure { fn bid_with_asset_not_accepted() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let project_id = inst.create_auctioning_project(default_project(0, ISSUER), ISSUER, default_evaluations()); - let bids = vec![ - BidParams::new(BIDDER_1, 10_000, 2_u128.into(), 1u8, AcceptedFundingAsset::USDC), - BidParams::new(BIDDER_2, 13_000, 3_u128.into(), 2u8, AcceptedFundingAsset::USDC), - ]; - let outcome = inst.bid_for_users(project_id, bids); + let bids = + vec![BidParams::::new(BIDDER_1, 10_000, 2_u128.into(), 1u8, AcceptedFundingAsset::USDC)]; + + let outcome = inst.execute(|| { + Pallet::::do_bid( + &bids[0].bidder, + project_id, + bids[0].amount, + bids[0].multiplier, + bids[0].asset, + ) + }); frame_support::assert_err!(outcome, Error::::FundingAssetNotAccepted); } @@ -1941,7 +1968,7 @@ mod auction_round_failure { inst.mint_plmc_to(plmc_ct_account_deposits.clone()); inst.mint_statemint_asset_to(usdt_fundings.clone()); - inst.bid_for_users(project_id, vec![glutton_bid_1, rejected_bid, glutton_bid_2]).expect("Bids should pass"); + inst.bid_for_users(project_id, vec![glutton_bid_1, rejected_bid, glutton_bid_2]); inst.do_free_plmc_assertions(vec![ UserToPLMCBalance::new(BIDDER_1, MockInstantiator::get_ed()), @@ -2029,7 +2056,7 @@ mod auction_round_failure { inst.mint_plmc_to(plmc_ct_account_deposits.clone()); inst.mint_statemint_asset_to(usdt_fundings.clone()); - inst.bid_for_users(project_id, vec![bid_in]).expect("Bids should pass"); + inst.bid_for_users(project_id, vec![bid_in]); inst.advance_time( ::EnglishAuctionDuration::get() + ::CandleAuctionDuration::get() - @@ -2037,7 +2064,7 @@ mod auction_round_failure { ) .unwrap(); - inst.bid_for_users(project_id, vec![bid_out]).expect("Bids should pass"); + inst.bid_for_users(project_id, vec![bid_out]); inst.do_free_plmc_assertions(vec![ UserToPLMCBalance::new(BIDDER_1, MockInstantiator::get_ed()), diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index 1fd06834e..7dbb161c7 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -59,7 +59,8 @@ pub trait WeightInfo { fn first_evaluation() -> Weight; fn second_to_limit_evaluation(x: u32) -> Weight; fn evaluation_over_limit() -> Weight; - fn bid() -> Weight; + fn bid_with_ct_deposit(y: u32) -> Weight; + fn bid_no_ct_deposit(x: u32, y: u32) -> Weight; fn first_contribution_with_ct_deposit() -> Weight; fn first_contribution_no_ct_deposit() -> Weight; @@ -172,14 +173,12 @@ impl WeightInfo for SubstrateWeight { /// Proof: StatemintAssets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn bid() -> Weight { - // Proof Size summary in bytes: - // Measured: `1555` - // Estimated: `6208` - // Minimum execution time: 130_000_000 picoseconds. + fn bid_with_ct_deposit(y: u32) -> Weight { + Weight::from_parts(140_000_000, 6208) + } + + fn bid_no_ct_deposit(x: u32, y: u32) -> Weight { Weight::from_parts(140_000_000, 6208) - .saturating_add(T::DbWeight::get().reads(10_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) } fn first_contribution_no_ct_deposit() -> Weight { From b45d212040282ba5451abbbc113bee9b7cc829ef Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 30 Jan 2024 14:51:29 +0100 Subject: [PATCH 160/212] updated test, but still inaccurate. 11.1818 vs 11 Signed-off-by: Juan Ignacio Rios --- Cargo.lock | 1 + pallets/funding/Cargo.toml | 1 + pallets/funding/src/tests.rs | 79 +++++++++++++++++++----------------- 3 files changed, 43 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 924ea35d5..34ba306cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5719,6 +5719,7 @@ dependencies = [ "futures", "itertools 0.11.0", "log", + "macros", "pallet-assets", "pallet-balances", "pallet-insecure-randomness-collective-flip", diff --git a/pallets/funding/Cargo.toml b/pallets/funding/Cargo.toml index 71d52a362..bec0135b3 100644 --- a/pallets/funding/Cargo.toml +++ b/pallets/funding/Cargo.toml @@ -60,6 +60,7 @@ pallet-assets.workspace = true pallet-linear-release.workspace = true assert_matches2.workspace = true xcm-executor.workspace = true +macros.workspace = true [features] default = ["std"] diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 9050e7b27..e46fdd215 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -838,54 +838,57 @@ mod auction_round_success { #[test] fn price_calculation_2() { - // From the knowledge hub + // From the knowledge hub: https://hub.polimec.org/learn/calculation-example#auction-round-calculation-example let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - // let bounded_name = BoundedVec::try_from("Contribution Token TEST".as_bytes().to_vec()).unwrap(); - // let bounded_symbol = BoundedVec::try_from("CTEST".as_bytes().to_vec()).unwrap(); - // let metadata_hash = hashed(format!("{}-{}", METADATA, inst.get_new_nonce())); - // let project_metadata = ProjectMetadata { - // token_information: CurrencyMetadata { - // name: bounded_name, - // symbol: bounded_symbol, - // decimals: ASSET_DECIMALS, - // }, - // mainnet_token_max_supply: 8_000_000 * ASSET_UNIT, - // total_allocation_size: (50_000 * ASSET_UNIT, 50_000 * ASSET_UNIT), - // minimum_price: PriceOf::::from_float(1.0), - // ticket_size: TicketSize { minimum: Some(1), maximum: None }, - // participants_size: ParticipantsSize { minimum: Some(2), maximum: None }, - // funding_thresholds: Default::default(), - // conversion_rate: 0, - // participation_currencies: AcceptedFundingAsset::USDT, - // funding_destination_account: ISSUER, - // offchain_information_hash: Some(metadata_hash), - // }; + + const ADAM: u64 = 60; + const TOM: u64 = 61; + const SOFIA: u64 = 62; + const FRED: u64 = 63; + const ANNA: u64 = 64; + const DAMIAN: u64 = 65; + + let accounts = vec![ADAM, TOM, SOFIA, FRED, ANNA, DAMIAN]; + + // overfund with plmc + let plmc_fundings = accounts + .iter() + .map(|acc| UserToPLMCBalance { account: acc.clone(), plmc_amount: PLMC * 1_000_000 }) + .collect_vec(); + let usdt_fundings = accounts + .iter() + .map(|acc| UserToStatemintAsset { + account: acc.clone(), + asset_amount: US_DOLLAR * 1_000_000, + asset_id: AcceptedFundingAsset::USDT.to_statemint_id(), + }) + .collect_vec(); + inst.mint_plmc_to(plmc_fundings); + inst.mint_statemint_asset_to(usdt_fundings); + let project_metadata = default_project(inst.get_new_nonce(), ISSUER); let project_id = inst.create_auctioning_project(project_metadata, ISSUER, default_evaluations()); + let bids = vec![ - BidParams::new(BIDDER_1, 10_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), - BidParams::new(BIDDER_2, 40_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), - BidParams::new(BIDDER_3, 35_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), + BidParams::new(ADAM, 10_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), + BidParams::new(TOM, 20_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), + BidParams::new(SOFIA, 20_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), + BidParams::new(FRED, 10_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), + BidParams::new(ANNA, 5_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), + BidParams::new(DAMIAN, 5_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), ]; - let statemint_funding = MockInstantiator::calculate_auction_funding_asset_spent(&bids, None); - let plmc_funding = MockInstantiator::calculate_auction_plmc_spent(&bids, None); - let ed_funding = plmc_funding.accounts().existential_deposits(); - let ct_account_deposits = plmc_funding.accounts().ct_account_deposits(); - - inst.mint_plmc_to(ed_funding); - inst.mint_plmc_to(plmc_funding.clone()); - inst.mint_plmc_to(plmc_funding.clone()); - inst.mint_plmc_to(ct_account_deposits); - inst.mint_statemint_asset_to(statemint_funding.clone()); - inst.mint_statemint_asset_to(statemint_funding.clone()); - inst.bid_for_users(project_id, bids); inst.start_community_funding(project_id).unwrap(); - let token_price = inst.get_project_details(project_id).weighted_average_price.unwrap().to_float(); - assert_eq!(token_price, 1.283606557377049); + let bids = inst.execute(|| Bids::::iter_prefix_values((project_id,)).collect_vec()); + let token_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); + let token_price_as_usdt = token_price.saturating_mul_int(ASSET_UNIT); + + let current_bucket = inst.execute(|| Buckets::::get(project_id).unwrap()); + + assert_eq!(token_price_as_usdt, ASSET_UNIT * 11); } #[test] From da210f54079643431cc1b17ff26a24fc60b2653c Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 31 Jan 2024 08:58:40 +0100 Subject: [PATCH 161/212] evaluation_unbond_for does not need complexity parameters Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 6736a5bc8..616456dbe 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -1716,16 +1716,13 @@ mod benchmarks { } #[benchmark] - fn evaluation_unbond_for(x: Linear<1, 20>) { + fn evaluation_unbond_for() { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - let issuer = account::>("issuer", 0, 0); let evaluations = default_evaluations::(); let evaluator = evaluations[0].account.clone(); From dff3c612fb7b904b4f1477b70b3c0550ef38b6e6 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 31 Jan 2024 09:29:44 +0100 Subject: [PATCH 162/212] bug fixed in instantiator where multiple evaluations by same account didnt get the correct assertion. Bench written for reward to evaluators. Two branches: ct account created, and not Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 235 +++++++++++++++++++--------- pallets/funding/src/functions.rs | 1 + pallets/funding/src/instantiator.rs | 6 + 3 files changed, 172 insertions(+), 70 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 616456dbe..0015678b9 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -1785,54 +1785,42 @@ mod benchmarks { } #[benchmark] - fn evaluation_slash_for(x: Linear<1, 20>) { + fn evaluation_reward_payout_for_with_ct_account_creation() { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - let issuer = account::>("issuer", 0, 0); - let evaluations = default_evaluations::(); - let evaluator = evaluations[0].account.clone(); + let evaluations: Vec> = vec![ + UserToUSDBalance::new(account::>("evaluator_bench", 0, 0), (50_000 * US_DOLLAR).into()), + UserToUSDBalance::new(account::>("evaluator_bench", 0, 0), (25_000 * US_DOLLAR).into()), + UserToUSDBalance::new(account::>("evaluator_3", 0, 0), (32_000 * US_DOLLAR).into()), + ]; + let evaluator: AccountIdOf = evaluations[0].account.clone(); whitelist_account!(evaluator); - let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); - let target_funding_amount: BalanceOf = - project_metadata.minimum_price.saturating_mul_int(project_metadata.total_allocation_size.0); - - let bids = BenchInstantiator::generate_bids_from_total_usd( - Percent::from_percent(15) * target_funding_amount, - 10u128.into(), - default_weights(), - default_bidders::(), - default_bidder_multipliers(), - ); - let contributions = BenchInstantiator::generate_contributions_from_total_usd( - Percent::from_percent(10) * target_funding_amount, - BenchInstantiator::calculate_price_from_test_bids(bids.clone()), - default_weights(), - default_contributors::(), - default_community_contributor_multipliers(), + let project_id = inst.create_finished_project( + default_project::(inst.get_new_nonce(), issuer.clone()), + issuer, + evaluations, + default_bids::(), + default_community_contributions::(), + vec![], ); - let project_id = - inst.create_finished_project(project_metadata, issuer, evaluations, bids, contributions, vec![]); - - inst.advance_time(One::one()).unwrap(); + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); assert_eq!( inst.get_project_details(project_id).cleanup, - Cleaner::Failure(CleanerState::Initialized(PhantomData)) + Cleaner::Success(CleanerState::Initialized(PhantomData)) ); let evaluation_to_unbond = inst.execute(|| Evaluations::::iter_prefix_values((project_id, evaluator.clone())).next().unwrap()); #[extrinsic_call] - evaluation_slash_for( + evaluation_reward_payout_for( RawOrigin::Signed(evaluator.clone()), project_id, evaluator.clone(), @@ -1844,26 +1832,25 @@ mod benchmarks { let stored_evaluation = Evaluations::::get((project_id, evaluator.clone(), evaluation_to_unbond.id)).unwrap(); assert!(stored_evaluation.rewarded_or_slashed.is_some()); - let slashed_amount = T::EvaluatorSlash::get() * evaluation_to_unbond.original_plmc_bond; - let current_plmc_bond = evaluation_to_unbond.current_plmc_bond.saturating_sub(slashed_amount); - assert_eq!(stored_evaluation.current_plmc_bond, current_plmc_bond); - // Balance - let treasury_account = T::TreasuryAccount::get(); - let bonded_plmc = inst - .get_reserved_plmc_balances_for(vec![evaluator.clone()], HoldReason::Evaluation(project_id).into())[0] - .plmc_amount; - assert_eq!(bonded_plmc, stored_evaluation.current_plmc_bond); - let free_treasury_plmc = inst.get_free_plmc_balances_for(vec![treasury_account])[0].plmc_amount; - assert_eq!(free_treasury_plmc, slashed_amount); + // Balances + let project_details = ProjectsDetails::::get(project_id).unwrap(); + let reward_info = match project_details.evaluation_round_info.evaluators_outcome { + EvaluatorsOutcome::Rewarded(reward_info) => reward_info, + _ => panic!("EvaluatorsOutcome should be Rewarded"), + }; + let total_reward = + BenchInstantiator::::calculate_total_reward_for_evaluation(stored_evaluation.clone(), reward_info); + let ct_amount = inst.get_ct_asset_balances_for(project_id, vec![evaluator.clone()])[0]; + assert_eq!(ct_amount, total_reward); // Events frame_system::Pallet::::assert_last_event( - Event::EvaluationSlashed { + Event::EvaluationRewarded { project_id, evaluator: evaluator.clone(), id: stored_evaluation.id, - amount: slashed_amount, + amount: total_reward, caller: evaluator, } .into(), @@ -1871,19 +1858,20 @@ mod benchmarks { } #[benchmark] - fn evaluation_reward_payout_for(x: Linear<1, 20>) { + fn evaluation_reward_payout_for_no_ct_account_creation() { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - let issuer = account::>("issuer", 0, 0); - let evaluations = default_evaluations::(); - let evaluator = evaluations[0].account.clone(); + let evaluations: Vec> = vec![ + UserToUSDBalance::new(account::>("evaluator_1", 0, 0), (50_000 * US_DOLLAR).into()), + UserToUSDBalance::new(account::>("evaluator_1", 0, 0), (25_000 * US_DOLLAR).into()), + UserToUSDBalance::new(account::>("evaluator_3", 0, 0), (32_000 * US_DOLLAR).into()), + ]; + let evaluator: AccountIdOf = evaluations[0].account.clone(); whitelist_account!(evaluator); let project_id = inst.create_finished_project( @@ -1901,21 +1889,31 @@ mod benchmarks { Cleaner::Success(CleanerState::Initialized(PhantomData)) ); - let evaluation_to_unbond = - inst.execute(|| Evaluations::::iter_prefix_values((project_id, evaluator.clone())).next().unwrap()); + let mut evaluations_to_unbond = + inst.execute(|| Evaluations::::iter_prefix_values((project_id, evaluator.clone()))); + + let pre_evaluation = evaluations_to_unbond.next().unwrap(); + let bench_evaluation = evaluations_to_unbond.next().unwrap(); + + Pallet::::evaluation_reward_payout_for( + RawOrigin::Signed(evaluator.clone()).into(), + project_id, + evaluator.clone(), + pre_evaluation.id, + ) + .unwrap(); #[extrinsic_call] evaluation_reward_payout_for( RawOrigin::Signed(evaluator.clone()), project_id, evaluator.clone(), - evaluation_to_unbond.id, + bench_evaluation.id, ); // * validity checks * // Storage - let stored_evaluation = - Evaluations::::get((project_id, evaluator.clone(), evaluation_to_unbond.id)).unwrap(); + let stored_evaluation = Evaluations::::get((project_id, evaluator.clone(), bench_evaluation.id)).unwrap(); assert!(stored_evaluation.rewarded_or_slashed.is_some()); // Balances @@ -1924,10 +1922,13 @@ mod benchmarks { EvaluatorsOutcome::Rewarded(reward_info) => reward_info, _ => panic!("EvaluatorsOutcome should be Rewarded"), }; - let total_reward = - BenchInstantiator::::calculate_total_reward_for_evaluation(stored_evaluation.clone(), reward_info); + + let pre_reward = + BenchInstantiator::::calculate_total_reward_for_evaluation(pre_evaluation.clone(), reward_info.clone()); + let bench_reward = + BenchInstantiator::::calculate_total_reward_for_evaluation(bench_evaluation.clone(), reward_info); let ct_amount = inst.get_ct_asset_balances_for(project_id, vec![evaluator.clone()])[0]; - assert_eq!(ct_amount, total_reward); + assert_eq!(ct_amount, pre_reward + bench_reward); // Events frame_system::Pallet::::assert_last_event( @@ -1935,7 +1936,93 @@ mod benchmarks { project_id, evaluator: evaluator.clone(), id: stored_evaluation.id, - amount: total_reward, + amount: bench_reward, + caller: evaluator, + } + .into(), + ); + } + + #[benchmark] + fn evaluation_slash_for(x: Linear<1, 20>) { + // setup + let mut inst = BenchInstantiator::::new(None); + + // real benchmark starts at block 0, and we can't call `events()` at block 0 + inst.advance_time(1u32.into()).unwrap(); + + #[cfg(feature = "std")] + let mut inst = populate_with_projects(x, inst); + + let issuer = account::>("issuer", 0, 0); + let evaluations = default_evaluations::(); + let evaluator = evaluations[0].account.clone(); + whitelist_account!(evaluator); + + let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); + let target_funding_amount: BalanceOf = + project_metadata.minimum_price.saturating_mul_int(project_metadata.total_allocation_size.0); + + let bids = BenchInstantiator::generate_bids_from_total_usd( + Percent::from_percent(15) * target_funding_amount, + 10u128.into(), + default_weights(), + default_bidders::(), + default_bidder_multipliers(), + ); + let contributions = BenchInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(10) * target_funding_amount, + BenchInstantiator::calculate_price_from_test_bids(bids.clone()), + default_weights(), + default_contributors::(), + default_community_contributor_multipliers(), + ); + + let project_id = + inst.create_finished_project(project_metadata, issuer, evaluations, bids, contributions, vec![]); + + inst.advance_time(One::one()).unwrap(); + assert_eq!( + inst.get_project_details(project_id).cleanup, + Cleaner::Failure(CleanerState::Initialized(PhantomData)) + ); + + let evaluation_to_unbond = + inst.execute(|| Evaluations::::iter_prefix_values((project_id, evaluator.clone())).next().unwrap()); + + #[extrinsic_call] + evaluation_slash_for( + RawOrigin::Signed(evaluator.clone()), + project_id, + evaluator.clone(), + evaluation_to_unbond.id, + ); + + // * validity checks * + // Storage + let stored_evaluation = + Evaluations::::get((project_id, evaluator.clone(), evaluation_to_unbond.id)).unwrap(); + assert!(stored_evaluation.rewarded_or_slashed.is_some()); + let slashed_amount = T::EvaluatorSlash::get() * evaluation_to_unbond.original_plmc_bond; + let current_plmc_bond = evaluation_to_unbond.current_plmc_bond.saturating_sub(slashed_amount); + assert_eq!(stored_evaluation.current_plmc_bond, current_plmc_bond); + + // Balance + let treasury_account = T::TreasuryAccount::get(); + let bonded_plmc = inst + .get_reserved_plmc_balances_for(vec![evaluator.clone()], HoldReason::Evaluation(project_id).into())[0] + .plmc_amount; + assert_eq!(bonded_plmc, stored_evaluation.current_plmc_bond); + let free_treasury_plmc = inst.get_free_plmc_balances_for(vec![treasury_account])[0].plmc_amount; + assert_eq!(free_treasury_plmc, slashed_amount); + + // Events + frame_system::Pallet::::assert_last_event( + Event::EvaluationSlashed { + project_id, + evaluator: evaluator.clone(), + id: stored_evaluation.id, + amount: slashed_amount, caller: evaluator, } .into(), @@ -2825,13 +2912,27 @@ mod benchmarks { }); } - // #[test] - // fn bench_evaluation_unbond_for() { - // new_test_ext().execute_with(|| { - // assert_ok!(PalletFunding::::test_evaluation_unbond_for()); - // }); - // } - // + #[test] + fn bench_evaluation_unbond_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_evaluation_unbond_for()); + }); + } + + #[test] + fn bench_evaluation_reward_payout_for_with_ct_account_creation() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_evaluation_reward_payout_for_with_ct_account_creation()); + }); + } + + #[test] + fn bench_evaluation_reward_payout_for_no_ct_account_creation() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_evaluation_reward_payout_for_no_ct_account_creation()); + }); + } + // #[test] // fn bench_evaluation_slash_for() { // new_test_ext().execute_with(|| { @@ -2839,12 +2940,6 @@ mod benchmarks { // }); // } // - // #[test] - // fn bench_evaluation_reward_payout_for() { - // new_test_ext().execute_with(|| { - // assert_ok!(PalletFunding::::test_evaluation_reward_payout_for()); - // }); - // } // // #[test] // fn bench_bid_ct_mint_for() { diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index b20fa6354..54130e38e 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -1596,6 +1596,7 @@ impl Pallet { let early_evaluators_rewards = early_reward_weight * reward_info.early_evaluator_reward_pot; let normal_evaluators_rewards = normal_reward_weight * reward_info.normal_evaluator_reward_pot; let total_reward_amount = early_evaluators_rewards.saturating_add(normal_evaluators_rewards); + // * Update storage * if !T::ContributionTokenCurrency::contains(&project_id, &evaluation.evaluator) { T::NativeCurrency::release( diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 897f7ea56..7e38aca5e 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -385,6 +385,12 @@ impl< expected_reserved_plmc_balances: Vec>, total_plmc_supply: BalanceOf, ) { + // just in case we forgot to merge accounts: + let expected_free_plmc_balances = + Self::generic_map_operation(vec![expected_free_plmc_balances], MergeOperation::Add); + let expected_reserved_plmc_balances = + Self::generic_map_operation(vec![expected_reserved_plmc_balances], MergeOperation::Add); + let project_details = self.get_project_details(project_id); let accounts = expected_reserved_plmc_balances.accounts(); let expected_ct_account_deposits = accounts From 1ad6042a8f4278d5bea76ffcd98c0997090fc797 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 31 Jan 2024 10:05:34 +0100 Subject: [PATCH 163/212] real weight returns on evaluation reward payouts Signed-off-by: Juan Ignacio Rios --- debug_weight_gen_v4.rs | 71 ++++++++++++++ pallets/funding/src/functions.rs | 18 +++- pallets/funding/src/lib.rs | 2 +- pallets/funding/src/weights-old.rs | 145 ----------------------------- pallets/funding/src/weights.rs | 21 ++++- 5 files changed, 105 insertions(+), 152 deletions(-) create mode 100644 debug_weight_gen_v4.rs delete mode 100644 pallets/funding/src/weights-old.rs diff --git a/debug_weight_gen_v4.rs b/debug_weight_gen_v4.rs new file mode 100644 index 000000000..63202b6bc --- /dev/null +++ b/debug_weight_gen_v4.rs @@ -0,0 +1,71 @@ + +//! Autogenerated weights for `pallet_funding` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2024-01-31, STEPS: `10`, REPEAT: `5`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `Juans-MacBook-Pro.local`, CPU: `` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: 1024 + +// Executed Command: +// target/debug/polimec-parachain-node +// benchmark +// pallet +// --chain=polimec-rococo-local +// --steps=10 +// --repeat=5 +// --pallet=pallet_funding +// --extrinsic=evaluation_reward_payout_for_no_ct_account_creation, evaluation_reward_payout_for_with_ct_account_creation +// --output +// ./debug_weight_gen_v4.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_funding`. +pub struct WeightInfo(PhantomData); +impl pallet_funding::WeightInfo for WeightInfo { + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + fn evaluation_reward_payout_for_with_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1515` + // Estimated: `4614` + // Minimum execution time: 1_308_000_000 picoseconds. + Weight::from_parts(1_349_000_000, 0) + .saturating_add(Weight::from_parts(0, 4614)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + fn evaluation_reward_payout_for_no_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1219` + // Estimated: `3814` + // Minimum execution time: 629_000_000 picoseconds. + Weight::from_parts(650_000_000, 0) + .saturating_add(Weight::from_parts(0, 3814)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } +} diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 54130e38e..4e7b6c437 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -1567,7 +1567,7 @@ impl Pallet { project_id: ProjectId, evaluator: &AccountIdOf, evaluation_id: u32, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let reward_info = @@ -1579,6 +1579,9 @@ impl Pallet { let mut evaluation = Evaluations::::get((project_id, evaluator, evaluation_id)).ok_or(Error::::EvaluationNotFound)?; + // Benchmark variables + let mut ct_account_created = false; + // * Validity checks * ensure!( evaluation.rewarded_or_slashed.is_none() && @@ -1599,6 +1602,7 @@ impl Pallet { // * Update storage * if !T::ContributionTokenCurrency::contains(&project_id, &evaluation.evaluator) { + ct_account_created = true; T::NativeCurrency::release( &HoldReason::FutureDeposit(project_id).into(), &evaluation.evaluator, @@ -1624,7 +1628,17 @@ impl Pallet { caller: caller.clone(), }); - Ok(()) + Ok(if ct_account_created { + PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::evaluation_reward_payout_for_with_ct_account_creation()), + pays_fee: Pays::Yes, + } + } else { + PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::evaluation_reward_payout_for_no_ct_account_creation()), + pays_fee: Pays::Yes, + } + }) } pub fn do_evaluation_slash_for( diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index c04cece99..9b32393de 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1066,7 +1066,7 @@ pub mod pallet { project_id: ProjectId, evaluator: AccountIdOf, bond_id: u32, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { let caller = ensure_signed(origin)?; Self::do_evaluation_reward_payout_for(&caller, project_id, &evaluator, bond_id) } diff --git a/pallets/funding/src/weights-old.rs b/pallets/funding/src/weights-old.rs deleted file mode 100644 index 2eb1ccb1e..000000000 --- a/pallets/funding/src/weights-old.rs +++ /dev/null @@ -1,145 +0,0 @@ -// Polimec Blockchain – https://www.polimec.org/ -// Copyright (C) Polimec 2022. All rights reserved. - -// The Polimec Blockchain is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// The Polimec Blockchain is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -// If you feel like getting in touch with us, you can do so at info@polimec.org - - -//! Autogenerated weights for pallet_funding -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-03-20, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! HOSTNAME: `pop-os`, CPU: `13th Gen Intel(R) Core(TM) i9-13900K` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 - -// Executed Command: -// target/release/polimec-standalone-node -// benchmark -// pallet -// --chain=dev -// --steps=50 -// --repeat=20 -// --pallet=pallet_funding -// --extrinsic -// * -// --execution=wasm -// --heap-pages=4096 -// --output=pallets/funding/src/weights.rs -// --template=./.maintain/frame-weight-template.hbs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; - -/// Weight functions needed for pallet_funding. -pub trait WeightInfo { - fn create() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn edit_metadata() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn start_evaluation() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn start_auction() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn bond_evaluation() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn bid() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn contribute() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn evaluation_unbond_for() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn evaluation_slash_for() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn evaluation_reward_payout_for() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn bid_ct_mint_for() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn contribution_ct_mint_for() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn start_bid_vesting_schedule_for() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn start_contribution_vesting_schedule_for() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn payout_bid_funds_for() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn payout_contribution_funds_for() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn decide_project_outcome() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn release_bid_funds_for() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn bid_unbond_for() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn release_contribution_funds_for() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn contribution_unbond_for() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } - fn insert_cleaned_project() -> Weight { - // Minimum execution time: 5_745 nanoseconds. - Weight::from_parts(6_034_000, 0) - } -} - -/// Weights for pallet_funding using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight {} -// For backwards compatibility and tests -impl WeightInfo for () {} \ No newline at end of file diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index 7dbb161c7..0f8f7bf75 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -56,15 +56,16 @@ pub trait WeightInfo { fn start_evaluation(x: u32) -> Weight; fn start_auction_manually(x: u32, y: u32) -> Weight; fn start_auction_automatically() -> Weight; + fn first_evaluation() -> Weight; fn second_to_limit_evaluation(x: u32) -> Weight; fn evaluation_over_limit() -> Weight; + fn bid_with_ct_deposit(y: u32) -> Weight; fn bid_no_ct_deposit(x: u32, y: u32) -> Weight; fn first_contribution_with_ct_deposit() -> Weight; fn first_contribution_no_ct_deposit() -> Weight; - fn first_contribution_ends_round_with_ct_deposit(y: u32, z: u32, ) -> Weight; fn first_contribution_ends_round_no_ct_deposit(y: u32, z: u32, ) -> Weight; fn second_to_limit_contribution(x: u32, ) -> Weight; @@ -72,9 +73,12 @@ pub trait WeightInfo { fn contribution_over_limit() -> Weight; - fn evaluation_unbond_for() -> Weight; + fn evaluation_unbond_for() -> Weight; + + fn evaluation_reward_payout_for_with_ct_account_creation() -> Weight; + fn evaluation_reward_payout_for_no_ct_account_creation() -> Weight; + fn evaluation_slash_for() -> Weight; - fn evaluation_reward_payout_for() -> Weight; fn bid_ct_mint_for() -> Weight; fn contribution_ct_mint_for() -> Weight; fn start_bid_vesting_schedule_for() -> Weight; @@ -272,7 +276,16 @@ impl WeightInfo for SubstrateWeight { /// Proof: LocalAssets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) /// Storage: LocalAssets Account (r:1 w:1) /// Proof: LocalAssets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) - fn evaluation_reward_payout_for() -> Weight { + fn evaluation_reward_payout_for_with_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1245` + // Estimated: `4710` + // Minimum execution time: 63_000_000 picoseconds. + Weight::from_parts(71_000_000, 4710) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn evaluation_reward_payout_for_no_ct_account_creation() -> Weight { // Proof Size summary in bytes: // Measured: `1245` // Estimated: `4710` From 1cd30e4940d278d5a26fe97cabb7392fbf082142 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 31 Jan 2024 10:06:00 +0100 Subject: [PATCH 164/212] default weight on fn Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 9b32393de..06283e98a 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1060,7 +1060,7 @@ pub mod pallet { } #[pallet::call_index(9)] - #[pallet::weight(WeightInfoOf::::evaluation_reward_payout_for())] + #[pallet::weight(WeightInfoOf::::evaluation_reward_payout_for_with_ct_account_creation())] pub fn evaluation_reward_payout_for( origin: OriginFor, project_id: ProjectId, From cb6fd911c98bbf76c40f7d4c51ac2960d8b33536 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 31 Jan 2024 10:09:25 +0100 Subject: [PATCH 165/212] evaluation slash does not need complexity parameters or logic branches Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 0015678b9..2117f9684 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -1944,16 +1944,13 @@ mod benchmarks { } #[benchmark] - fn evaluation_slash_for(x: Linear<1, 20>) { + fn evaluation_slash_for() { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - let issuer = account::>("issuer", 0, 0); let evaluations = default_evaluations::(); let evaluator = evaluations[0].account.clone(); From 661e6844fccb6fdd988da99dfaf5cc28536ccb7c Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 31 Jan 2024 10:25:14 +0100 Subject: [PATCH 166/212] test for bench now passing. had to modify the state machine, but we will revise that code later Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 15 +++++----- pallets/funding/src/impls.rs | 45 +++++++++++++++++++++-------- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 2117f9684..b8d307df9 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -2930,14 +2930,13 @@ mod benchmarks { }); } - // #[test] - // fn bench_evaluation_slash_for() { - // new_test_ext().execute_with(|| { - // assert_ok!(PalletFunding::::test_evaluation_slash_for()); - // }); - // } - // - // + #[test] + fn bench_evaluation_slash_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_evaluation_slash_for()); + }); + } + // #[test] // fn bench_bid_ct_mint_for() { // new_test_ext().execute_with(|| { diff --git a/pallets/funding/src/impls.rs b/pallets/funding/src/impls.rs index da1a3f90b..f329b2fb5 100644 --- a/pallets/funding/src/impls.rs +++ b/pallets/funding/src/impls.rs @@ -1,4 +1,5 @@ use frame_support::{ + dispatch::{DispatchErrorWithPostInfo, GetDispatchInfo}, traits::{fungible::InspectHold, Get}, weights::Weight, }; @@ -56,7 +57,8 @@ impl DoRemainingOperation for CleanerState { *self = Self::EvaluationUnbonding(remaining_evaluations::(project_id), PhantomData); Ok(base_weight) } else { - let (consumed_weight, remaining_evaluations) = reward_or_slash_one_evaluation::(project_id)?; + let (consumed_weight, remaining_evaluations) = + reward_or_slash_one_evaluation::(project_id).map_err(|error_info| error_info.error)?; *self = CleanerState::EvaluationRewardOrSlash(remaining_evaluations, PhantomData); Ok(consumed_weight) }, @@ -175,7 +177,8 @@ impl DoRemainingOperation for CleanerState { ); Ok(base_weight) } else { - let (consumed_weight, remaining_evaluators) = reward_or_slash_one_evaluation::(project_id)?; + let (consumed_weight, remaining_evaluators) = + reward_or_slash_one_evaluation::(project_id).map_err(|error_info| error_info.error)?; *self = CleanerState::EvaluationRewardOrSlash(remaining_evaluators, PhantomData); Ok(consumed_weight) }, @@ -330,7 +333,9 @@ fn remaining_participants_with_future_ct_deposit(project_id: ProjectI .count() as u64 } -fn reward_or_slash_one_evaluation(project_id: ProjectId) -> Result<(Weight, u64), DispatchError> { +fn reward_or_slash_one_evaluation( + project_id: ProjectId, +) -> Result<(Weight, u64), DispatchErrorWithPostInfo> { let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectNotFound)?; let project_evaluations = Evaluations::::iter_prefix_values((project_id,)); let mut remaining_evaluations = project_evaluations.filter(|evaluation| evaluation.rewarded_or_slashed.is_none()); @@ -339,25 +344,41 @@ fn reward_or_slash_one_evaluation(project_id: ProjectId) -> Result<(W if let Some(evaluation) = remaining_evaluations.next() { // TODO: This base weight and the one in all other functions below should be calculated with a benchmark let remaining = remaining_evaluations.count() as u64; - match project_details.evaluation_round_info.evaluators_outcome { EvaluatorsOutcome::Rewarded(_) => { + let mut weight_consumed = crate::Call::::evaluation_reward_payout_for { + project_id: evaluation.project_id, + evaluator: evaluation.evaluator.clone(), + bond_id: evaluation.id, + } + .get_dispatch_info() + .weight; + match Pallet::::do_evaluation_reward_payout_for( &T::PalletId::get().into_account_truncating(), evaluation.project_id, &evaluation.evaluator, evaluation.id, ) { - Ok(_) => (), - Err(e) => Pallet::::deposit_event(Event::EvaluationRewardFailed { - project_id: evaluation.project_id, - evaluator: evaluation.evaluator.clone(), - id: evaluation.id, - error: e, - }), + Ok(result) => { + if let Some(weight) = result.actual_weight { + weight_consumed = weight + }; + }, + Err(e) => { + if let Some(weight) = e.post_info.actual_weight { + weight_consumed = weight + }; + Pallet::::deposit_event(Event::EvaluationRewardFailed { + project_id: evaluation.project_id, + evaluator: evaluation.evaluator.clone(), + id: evaluation.id, + error: e.error, + }) + }, }; - Ok((base_weight.saturating_add(WeightInfoOf::::evaluation_reward_payout_for()), remaining)) + Ok((base_weight.saturating_add(weight_consumed), remaining)) }, EvaluatorsOutcome::Slashed => { match Pallet::::do_evaluation_slash_for( From 37bb2adfb70eb2fedb6637bce17170c7603d14fd Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 31 Jan 2024 14:28:32 +0100 Subject: [PATCH 167/212] bid_ct_mint_for done Signed-off-by: Juan Ignacio Rios --- debug_weight_gen.rs | 215 ---------------------------- debug_weight_gen_v2.rs | 203 -------------------------- debug_weight_gen_v3.rs | 108 -------------- debug_weight_gen_v4.rs | 71 --------- pallets/funding/src/benchmarking.rs | 106 ++++++++++++-- pallets/funding/src/functions.rs | 15 +- pallets/funding/src/impls.rs | 7 +- pallets/funding/src/lib.rs | 4 +- pallets/funding/src/weights.rs | 17 ++- 9 files changed, 130 insertions(+), 616 deletions(-) delete mode 100644 debug_weight_gen.rs delete mode 100644 debug_weight_gen_v2.rs delete mode 100644 debug_weight_gen_v3.rs delete mode 100644 debug_weight_gen_v4.rs diff --git a/debug_weight_gen.rs b/debug_weight_gen.rs deleted file mode 100644 index 2d9e7f52f..000000000 --- a/debug_weight_gen.rs +++ /dev/null @@ -1,215 +0,0 @@ - -//! Autogenerated weights for `pallet_funding` -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-01-25, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `Juans-MacBook-Pro.local`, CPU: `` -//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: 1024 - -// Executed Command: -// target/debug/polimec-parachain-node -// benchmark -// pallet -// --chain=polimec-rococo-local -// --steps=20 -// --repeat=10 -// --pallet=pallet_funding -// --extrinsic=first_contribution, first_contribution_ends_round, second_to_limit_contribution, second_to_limit_contribution_ends_round, contribution_over_limit, contribution_over_limit_ends_round -// --output -// ./debug_weight_gen.rs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] -#![allow(missing_docs)] - -use frame_support::{traits::Get, weights::Weight}; -use core::marker::PhantomData; - -/// Weight functions for `pallet_funding`. -pub struct WeightInfo(PhantomData); -impl pallet_funding::WeightInfo for WeightInfo { - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - fn first_contribution() -> Weight { - // Proof Size summary in bytes: - // Measured: `1996` - // Estimated: `6208` - // Minimum execution time: 2_110_000_000 picoseconds. - Weight::from_parts(2_217_000_000, 0) - .saturating_add(Weight::from_parts(0, 6208)) - .saturating_add(T::DbWeight::get().reads(11)) - .saturating_add(T::DbWeight::get().writes(7)) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:3 w:2) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - fn first_contribution_ends_round() -> Weight { - // Proof Size summary in bytes: - // Measured: `2010` - // Estimated: `10281` - // Minimum execution time: 2_279_000_000 picoseconds. - Weight::from_parts(2_358_000_000, 0) - .saturating_add(Weight::from_parts(0, 10281)) - .saturating_add(T::DbWeight::get().reads(14)) - .saturating_add(T::DbWeight::get().writes(9)) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:255 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 255]`. - fn second_to_limit_contribution(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `2209 + x * (137 ±0)` - // Estimated: `6208 + x * (2839 ±0)` - // Minimum execution time: 1_801_000_000 picoseconds. - Weight::from_parts(1_517_808_385, 0) - .saturating_add(Weight::from_parts(0, 6208)) - // Standard Error: 299_619 - .saturating_add(Weight::from_parts(66_615_228, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(11)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(7)) - .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:255 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:3 w:2) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 255]`. - fn second_to_limit_contribution_ends_round(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `2223 + x * (137 ±0)` - // Estimated: `10281 + x * (2839 ±0)` - // Minimum execution time: 1_883_000_000 picoseconds. - Weight::from_parts(1_704_088_160, 0) - .saturating_add(Weight::from_parts(0, 10281)) - // Standard Error: 216_861 - .saturating_add(Weight::from_parts(65_992_903, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(14)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(9)) - .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:257 w:2) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - fn contribution_over_limit() -> Weight { - // Proof Size summary in bytes: - // Measured: `37440` - // Estimated: `730613` - // Minimum execution time: 19_118_000_000 picoseconds. - Weight::from_parts(19_346_000_000, 0) - .saturating_add(Weight::from_parts(0, 730613)) - .saturating_add(T::DbWeight::get().reads(267)) - .saturating_add(T::DbWeight::get().writes(8)) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:257 w:2) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - fn contribution_over_limit_ends_round() -> Weight { - // Proof Size summary in bytes: - // Measured: `37440` - // Estimated: `730613` - // Minimum execution time: 19_344_000_000 picoseconds. - Weight::from_parts(19_637_000_000, 0) - .saturating_add(Weight::from_parts(0, 730613)) - .saturating_add(T::DbWeight::get().reads(267)) - .saturating_add(T::DbWeight::get().writes(8)) - } -} diff --git a/debug_weight_gen_v2.rs b/debug_weight_gen_v2.rs deleted file mode 100644 index 1c3461ed0..000000000 --- a/debug_weight_gen_v2.rs +++ /dev/null @@ -1,203 +0,0 @@ - -//! Autogenerated weights for `pallet_funding` -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-01-26, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `Juans-MBP.home`, CPU: `` -//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: 1024 - -// Executed Command: -// target/debug/polimec-parachain-node -// benchmark -// pallet -// --chain=polimec-rococo-local -// --steps=20 -// --repeat=10 -// --pallet=pallet_funding -// --extrinsic=first_contribution, first_contribution_ends_round, second_to_limit_contribution, second_to_limit_contribution_ends_round, contribution_over_limit -// --output -// ./debug_weight_gen_v2.rs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] -#![allow(missing_docs)] - -use frame_support::{traits::Get, weights::Weight}; -use core::marker::PhantomData; - -/// Weight functions for `pallet_funding`. -pub struct WeightInfo(PhantomData); -impl pallet_funding::WeightInfo for WeightInfo { - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - fn first_contribution() -> Weight { - // Proof Size summary in bytes: - // Measured: `1996` - // Estimated: `6208` - // Minimum execution time: 2_100_000_000 picoseconds. - Weight::from_parts(2_210_000_000, 0) - .saturating_add(Weight::from_parts(0, 6208)) - .saturating_add(T::DbWeight::get().reads(11)) - .saturating_add(T::DbWeight::get().writes(7)) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9832 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - /// The range of component `y` is `[1, 99]`. - /// The range of component `z` is `[1, 10000]`. - fn first_contribution_ends_round(y: u32, z: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `0 + y * (909 ±0) + z * (41 ±0)` - // Estimated: `248750 + y * (17540 ±9_815) + z * (1383 ±97)` - // Minimum execution time: 7_079_000_000 picoseconds. - Weight::from_parts(7_117_000_000, 0) - .saturating_add(Weight::from_parts(0, 248750)) - // Standard Error: 226_579_186 - .saturating_add(Weight::from_parts(362_478_839, 0).saturating_mul(y.into())) - // Standard Error: 2_241_815 - .saturating_add(Weight::from_parts(32_034_853, 0).saturating_mul(z.into())) - .saturating_add(T::DbWeight::get().reads(91)) - .saturating_add(T::DbWeight::get().reads((6_u64).saturating_mul(y.into()))) - .saturating_add(T::DbWeight::get().writes(8)) - .saturating_add(Weight::from_parts(0, 17540).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 1383).saturating_mul(z.into())) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:255 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 255]`. - fn second_to_limit_contribution(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `2209 + x * (137 ±0)` - // Estimated: `6208 + x * (2839 ±0)` - // Minimum execution time: 1_737_000_000 picoseconds. - Weight::from_parts(1_514_705_638, 0) - .saturating_add(Weight::from_parts(0, 6208)) - // Standard Error: 177_615 - .saturating_add(Weight::from_parts(64_011_655, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(11)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(7)) - .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:256 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9832 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 255]`. - /// The range of component `y` is `[1, 99]`. - /// The range of component `z` is `[1, 10000]`. - fn second_to_limit_contribution_ends_round(x: u32, y: u32, z: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `37040 + x * (137 ±0) + y * (909 ±0) + z * (41 ±0)` - // Estimated: `2178320 + x * (2839 ±0) + y * (103665 ±16_527) + z * (2230 ±162)` - // Minimum execution time: 22_009_000_000 picoseconds. - Weight::from_parts(46_609_465_170, 0) - .saturating_add(Weight::from_parts(0, 2178320)) - // Standard Error: 379_495_438 - .saturating_add(Weight::from_parts(2_369_315_873, 0).saturating_mul(y.into())) - // Standard Error: 3_737_964 - .saturating_add(Weight::from_parts(51_569_812, 0).saturating_mul(z.into())) - .saturating_add(T::DbWeight::get().reads(714)) - .saturating_add(T::DbWeight::get().reads((33_u64).saturating_mul(y.into()))) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(z.into()))) - .saturating_add(T::DbWeight::get().writes(8)) - .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 103665).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 2230).saturating_mul(z.into())) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:257 w:2) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - fn contribution_over_limit() -> Weight { - // Proof Size summary in bytes: - // Measured: `37440` - // Estimated: `730613` - // Minimum execution time: 17_812_000_000 picoseconds. - Weight::from_parts(18_304_000_000, 0) - .saturating_add(Weight::from_parts(0, 730613)) - .saturating_add(T::DbWeight::get().reads(267)) - .saturating_add(T::DbWeight::get().writes(8)) - } -} diff --git a/debug_weight_gen_v3.rs b/debug_weight_gen_v3.rs deleted file mode 100644 index 2391aea31..000000000 --- a/debug_weight_gen_v3.rs +++ /dev/null @@ -1,108 +0,0 @@ - -//! Autogenerated weights for `pallet_funding` -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-01-30, STEPS: `10`, REPEAT: `5`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `Juans-MBP.home`, CPU: `` -//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: 1024 - -// Executed Command: -// target/debug/polimec-parachain-node -// benchmark -// pallet -// --chain=polimec-rococo-local -// --steps=10 -// --repeat=5 -// --pallet=pallet_funding -// --extrinsic=bid_no_ct_deposit,bid_with_ct_deposit -// --output -// ./debug_weight_gen_v3.rs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] -#![allow(missing_docs)] - -use frame_support::{traits::Get, weights::Weight}; -use core::marker::PhantomData; - -/// Weight functions for `pallet_funding`. -pub struct WeightInfo(PhantomData); -impl pallet_funding::WeightInfo for WeightInfo { - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:1 w:10) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Buckets` (r:1 w:1) - /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextBidId` (r:1 w:1) - /// Proof: `PolimecFunding::NextBidId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// The range of component `y` is `[0, 10]`. - fn bid_with_ct_deposit(y: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `2140` - // Estimated: `6208` - // Minimum execution time: 2_186_000_000 picoseconds. - Weight::from_parts(1_479_823_232, 0) - .saturating_add(Weight::from_parts(0, 6208)) - // Standard Error: 19_862_262 - .saturating_add(Weight::from_parts(1_083_494_949, 0).saturating_mul(y.into())) - .saturating_add(T::DbWeight::get().reads(12)) - .saturating_add(T::DbWeight::get().writes(7)) - .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:256 w:10) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Buckets` (r:1 w:1) - /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextBidId` (r:1 w:1) - /// Proof: `PolimecFunding::NextBidId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// The range of component `x` is `[0, 255]`. - /// The range of component `y` is `[0, 10]`. - fn bid_no_ct_deposit(x: u32, y: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `2218 + x * (164 ±0)` - // Estimated: `6208 + x * (2893 ±0)` - // Minimum execution time: 11_970_000_000 picoseconds. - Weight::from_parts(631_207_506, 0) - .saturating_add(Weight::from_parts(0, 6208)) - // Standard Error: 510_923 - .saturating_add(Weight::from_parts(67_974_520, 0).saturating_mul(x.into())) - // Standard Error: 12_729_727 - .saturating_add(Weight::from_parts(1_143_574_647, 0).saturating_mul(y.into())) - .saturating_add(T::DbWeight::get().reads(12)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(6)) - .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) - .saturating_add(Weight::from_parts(0, 2893).saturating_mul(x.into())) - } -} diff --git a/debug_weight_gen_v4.rs b/debug_weight_gen_v4.rs deleted file mode 100644 index 63202b6bc..000000000 --- a/debug_weight_gen_v4.rs +++ /dev/null @@ -1,71 +0,0 @@ - -//! Autogenerated weights for `pallet_funding` -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-01-31, STEPS: `10`, REPEAT: `5`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `Juans-MacBook-Pro.local`, CPU: `` -//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: 1024 - -// Executed Command: -// target/debug/polimec-parachain-node -// benchmark -// pallet -// --chain=polimec-rococo-local -// --steps=10 -// --repeat=5 -// --pallet=pallet_funding -// --extrinsic=evaluation_reward_payout_for_no_ct_account_creation, evaluation_reward_payout_for_with_ct_account_creation -// --output -// ./debug_weight_gen_v4.rs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] -#![allow(missing_docs)] - -use frame_support::{traits::Get, weights::Weight}; -use core::marker::PhantomData; - -/// Weight functions for `pallet_funding`. -pub struct WeightInfo(PhantomData); -impl pallet_funding::WeightInfo for WeightInfo { - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Account` (r:1 w:1) - /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Asset` (r:1 w:1) - /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - fn evaluation_reward_payout_for_with_ct_account_creation() -> Weight { - // Proof Size summary in bytes: - // Measured: `1515` - // Estimated: `4614` - // Minimum execution time: 1_308_000_000 picoseconds. - Weight::from_parts(1_349_000_000, 0) - .saturating_add(Weight::from_parts(0, 4614)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Account` (r:1 w:1) - /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Asset` (r:1 w:1) - /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - fn evaluation_reward_payout_for_no_ct_account_creation() -> Weight { - // Proof Size summary in bytes: - // Measured: `1219` - // Estimated: `3814` - // Minimum execution time: 629_000_000 picoseconds. - Weight::from_parts(650_000_000, 0) - .saturating_add(Weight::from_parts(0, 3814)) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().writes(3)) - } -} diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index b8d307df9..51af67756 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -2027,16 +2027,13 @@ mod benchmarks { } #[benchmark] - fn bid_ct_mint_for(x: Linear<1, 20>) { + fn bid_ct_mint_for_with_ct_account_creation() { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - let issuer = account::>("issuer", 0, 0); let bids = default_bids::(); let bidder = bids[0].bidder.clone(); @@ -2079,6 +2076,86 @@ mod benchmarks { ); } + #[benchmark] + fn bid_ct_mint_for_no_ct_account_creation() { + // setup + let mut inst = BenchInstantiator::::new(None); + + // real benchmark starts at block 0, and we can't call `events()` at block 0 + inst.advance_time(1u32.into()).unwrap(); + + let issuer = account::>("issuer", 0, 0); + let bids: Vec> = vec![ + BidParams::new( + account::>("bidder_1", 0, 0), + (40_000 * ASSET_UNIT).into(), + 1_u128.into(), + 1u8, + AcceptedFundingAsset::USDT, + ), + BidParams::new( + account::>("bidder_1", 0, 0), + (5_000 * ASSET_UNIT).into(), + 1_u128.into(), + 7u8, + AcceptedFundingAsset::USDT, + ), + ]; + let bidder = bids[0].bidder.clone(); + whitelist_account!(bidder); + + let project_id = inst.create_finished_project( + default_project::(inst.get_new_nonce(), issuer.clone()), + issuer, + default_evaluations::(), + bids, + default_community_contributions::(), + vec![], + ); + + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + assert_eq!( + inst.get_project_details(project_id).cleanup, + Cleaner::Success(CleanerState::Initialized(PhantomData)) + ); + + let mut bids_to_mint_ct = inst.execute(|| Bids::::iter_prefix_values((project_id, bidder.clone()))); + + let pre_bid_to_mint_ct = bids_to_mint_ct.next().unwrap(); + let bench_bid_to_mint_ct = bids_to_mint_ct.next().unwrap(); + + Pallet::::bid_ct_mint_for( + RawOrigin::Signed(bidder.clone()).into(), + project_id, + bidder.clone(), + pre_bid_to_mint_ct.id, + ) + .unwrap(); + + #[extrinsic_call] + bid_ct_mint_for(RawOrigin::Signed(bidder.clone()), project_id, bidder.clone(), bench_bid_to_mint_ct.id); + + // * validity checks * + // Storage + let stored_bid = Bids::::get((project_id, bidder.clone(), bench_bid_to_mint_ct.id)).unwrap(); + assert!(stored_bid.ct_minted); + + // Balances + let ct_amount = inst.get_ct_asset_balances_for(project_id, vec![bidder.clone()])[0]; + assert_eq!(ct_amount, pre_bid_to_mint_ct.final_ct_amount + stored_bid.final_ct_amount); + + // Events + frame_system::Pallet::::assert_last_event( + Event::ContributionTokenMinted { + releaser: bidder.clone(), + project_id, + claimer: bidder, + amount: bench_bid_to_mint_ct.final_ct_amount, + } + .into(), + ); + } + #[benchmark] fn contribution_ct_mint_for(x: Linear<1, 20>) { // setup @@ -2937,13 +3014,20 @@ mod benchmarks { }); } - // #[test] - // fn bench_bid_ct_mint_for() { - // new_test_ext().execute_with(|| { - // assert_ok!(PalletFunding::::test_bid_ct_mint_for()); - // }); - // } - // + #[test] + fn bench_bid_ct_mint_for_with_ct_account_creation() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_bid_ct_mint_for_with_ct_account_creation()); + }); + } + + #[test] + fn bench_bid_ct_mint_for_no_ct_account_creation() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_bid_ct_mint_for_no_ct_account_creation()); + }); + } + // #[test] // fn bench_contribution_ct_mint_for() { // new_test_ext().execute_with(|| { diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 4e7b6c437..d8f19503c 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -1427,12 +1427,15 @@ impl Pallet { project_id: ProjectId, bidder: &AccountIdOf, bid_id: u32, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { // * Get variables * let mut bid = Bids::::get((project_id, bidder, bid_id)).ok_or(Error::::BidNotFound)?; let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectNotFound)?; let ct_amount = bid.final_ct_amount; + // Benchmark variables + let mut ct_account_created = false; + // * Validity checks * ensure!(project_details.status == ProjectStatus::FundingSuccessful, Error::::NotAllowed); ensure!(!bid.ct_minted, Error::::NotAllowed); @@ -1444,6 +1447,7 @@ impl Pallet { // * Update storage * if !T::ContributionTokenCurrency::contains(&project_id, &bid.bidder) { + ct_account_created = true; T::NativeCurrency::release( &HoldReason::FutureDeposit(project_id).into(), &bid.bidder, @@ -1463,7 +1467,14 @@ impl Pallet { amount: ct_amount, }); - Ok(()) + Ok(PostDispatchInfo { + actual_weight: Some(if ct_account_created { + WeightInfoOf::::bid_ct_mint_for_with_ct_account_creation() + } else { + WeightInfoOf::::bid_ct_mint_for_no_ct_account_creation() + }), + pays_fee: Pays::Yes, + }) } pub fn do_contribution_ct_mint_for( diff --git a/pallets/funding/src/impls.rs b/pallets/funding/src/impls.rs index f329b2fb5..fa3f9ff17 100644 --- a/pallets/funding/src/impls.rs +++ b/pallets/funding/src/impls.rs @@ -676,10 +676,13 @@ fn mint_ct_for_one_bid(project_id: ProjectId) -> (Weight, u64) { project_id: bid.project_id, claimer: bid.bidder.clone(), id: bid.id, - error: e, + error: e.error, }), }; - (base_weight.saturating_add(WeightInfoOf::::bid_ct_mint_for()), remaining_bids.count() as u64) + ( + base_weight.saturating_add(WeightInfoOf::::bid_ct_mint_for_with_ct_account_creation()), + remaining_bids.count() as u64, + ) } else { (base_weight, 0u64) } diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 06283e98a..c54620744 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1072,13 +1072,13 @@ pub mod pallet { } #[pallet::call_index(10)] - #[pallet::weight(WeightInfoOf::::bid_ct_mint_for())] + #[pallet::weight(WeightInfoOf::::bid_ct_mint_for_with_ct_account_creation())] pub fn bid_ct_mint_for( origin: OriginFor, project_id: ProjectId, bidder: AccountIdOf, bid_id: u32, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { let caller = ensure_signed(origin)?; Self::do_bid_ct_mint_for(&caller, project_id, &bidder, bid_id) } diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index 0f8f7bf75..8adc34421 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -79,7 +79,10 @@ pub trait WeightInfo { fn evaluation_reward_payout_for_no_ct_account_creation() -> Weight; fn evaluation_slash_for() -> Weight; - fn bid_ct_mint_for() -> Weight; + fn bid_ct_mint_for_with_ct_account_creation() -> Weight; + fn bid_ct_mint_for_no_ct_account_creation() -> Weight; + + fn contribution_ct_mint_for() -> Weight; fn start_bid_vesting_schedule_for() -> Weight; fn start_contribution_vesting_schedule_for() -> Weight; @@ -302,7 +305,17 @@ impl WeightInfo for SubstrateWeight { /// Proof: LocalAssets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) /// Storage: LocalAssets Account (r:1 w:1) /// Proof: LocalAssets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) - fn bid_ct_mint_for() -> Weight { + fn bid_ct_mint_for_with_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1215` + // Estimated: `4680` + // Minimum execution time: 65_000_000 picoseconds. + Weight::from_parts(71_000_000, 4680) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + + fn bid_ct_mint_for_no_ct_account_creation() -> Weight { // Proof Size summary in bytes: // Measured: `1215` // Estimated: `4680` From 64eb4ec5d9fb389bdf0a81f2da9844975ed3f138 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 31 Jan 2024 16:03:50 +0100 Subject: [PATCH 168/212] contribution_ct_mint_for done Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 118 +++++++++++++++++++++++++--- pallets/funding/src/functions.rs | 4 + pallets/funding/src/instantiator.rs | 5 +- 3 files changed, 112 insertions(+), 15 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 51af67756..5040d318f 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -2157,16 +2157,13 @@ mod benchmarks { } #[benchmark] - fn contribution_ct_mint_for(x: Linear<1, 20>) { + fn contribution_ct_mint_for_with_ct_account_creation() { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - let issuer = account::>("issuer", 0, 0); let contributions = default_community_contributions::(); let contributor = contributions[0].contributor.clone(); @@ -2220,6 +2217,98 @@ mod benchmarks { ); } + #[benchmark] + fn contribution_ct_mint_for_no_ct_account_creation() { + // setup + let mut inst = BenchInstantiator::::new(None); + + // real benchmark starts at block 0, and we can't call `events()` at block 0 + inst.advance_time(1u32.into()).unwrap(); + + let issuer = account::>("issuer", 0, 0); + let contributions: Vec> = vec![ + ContributionParams::new( + account::>("contributor_1", 0, 0), + (10_000 * ASSET_UNIT).into(), + 1u8, + AcceptedFundingAsset::USDT, + ), + ContributionParams::new( + account::>("contributor_1", 0, 0), + (6_000 * ASSET_UNIT).into(), + 1u8, + AcceptedFundingAsset::USDT, + ), + ContributionParams::new( + account::>("contributor_3", 0, 0), + (30_000 * ASSET_UNIT).into(), + 1u8, + AcceptedFundingAsset::USDT, + ), + ]; + let contributor = contributions[0].contributor.clone(); + whitelist_account!(contributor); + + let project_id = inst.create_finished_project( + default_project::(inst.get_new_nonce(), issuer.clone()), + issuer, + default_evaluations::(), + default_bids::(), + contributions, + vec![], + ); + + inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + assert_eq!( + inst.get_project_details(project_id).cleanup, + Cleaner::Success(CleanerState::Initialized(PhantomData)) + ); + + let mut contributions_to_mint_ct = + inst.execute(|| Contributions::::iter_prefix_values((project_id, contributor.clone()))); + + let pre_contribution_to_mint_ct = contributions_to_mint_ct.next().unwrap(); + let bench_contribution_to_mint_ct = contributions_to_mint_ct.next().unwrap(); + + Pallet::::contribution_ct_mint_for( + RawOrigin::Signed(contributor.clone()).into(), + project_id, + contributor.clone(), + pre_contribution_to_mint_ct.id, + ) + .unwrap(); + + #[extrinsic_call] + contribution_ct_mint_for( + RawOrigin::Signed(contributor.clone()), + project_id, + contributor.clone(), + bench_contribution_to_mint_ct.id, + ); + + // * validity checks * + // Storage + let stored_contribution = + Contributions::::get((project_id, contributor.clone(), bench_contribution_to_mint_ct.id)).unwrap(); + assert!(stored_contribution.ct_minted); + + // Balances + let ct_amount = inst.get_ct_asset_balances_for(project_id, vec![contributor.clone()])[0]; + assert_eq!(ct_amount, pre_contribution_to_mint_ct.ct_amount + bench_contribution_to_mint_ct.ct_amount); + + // Events + frame_system::Pallet::::assert_last_event( + Event::ContributionTokenMinted { + releaser: contributor.clone(), + project_id, + claimer: contributor, + amount: bench_contribution_to_mint_ct.ct_amount, + } + .into(), + ); + } + + // remaining #[benchmark] fn start_bid_vesting_schedule_for(x: Linear<1, 20>) { // setup @@ -3028,13 +3117,20 @@ mod benchmarks { }); } - // #[test] - // fn bench_contribution_ct_mint_for() { - // new_test_ext().execute_with(|| { - // assert_ok!(PalletFunding::::test_contribution_ct_mint_for()); - // }); - // } - // + #[test] + fn bench_contribution_ct_mint_for_with_ct_account_creation() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_contribution_ct_mint_for_with_ct_account_creation()); + }); + } + + #[test] + fn bench_contribution_ct_mint_for_no_ct_account_creation() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_contribution_ct_mint_for_no_ct_account_creation()); + }); + } + // #[test] // fn bench_start_bid_vesting_schedule_for() { // new_test_ext().execute_with(|| { diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index d8f19503c..81701538d 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -1489,6 +1489,9 @@ impl Pallet { let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectNotFound)?; let ct_amount = contribution.ct_amount; + // Benchmark variables + let mut ct_account_created = false; + // * Validity checks * ensure!(project_details.status == ProjectStatus::FundingSuccessful, Error::::NotAllowed); ensure!(!contribution.ct_minted, Error::::NotAllowed); @@ -1499,6 +1502,7 @@ impl Pallet { // * Update storage * if !T::ContributionTokenCurrency::contains(&project_id, &contribution.contributor) { + ct_account_created = true; T::NativeCurrency::release( &HoldReason::FutureDeposit(project_id).into(), &contribution.contributor, diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 7e38aca5e..96d0de75e 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -1193,10 +1193,7 @@ impl< total_plmc_participation_locked.merge_accounts(MergeOperation::Add), HoldReason::Participation(project_id).into(), ); - self.do_contribution_transferred_statemint_asset_assertions( - funding_asset_deposits.merge_accounts(MergeOperation::Add), - project_id, - ); + self.do_contribution_transferred_statemint_asset_assertions(funding_asset_deposits, project_id); self.do_free_plmc_assertions(expected_free_plmc_balances.merge_accounts(MergeOperation::Add)); self.do_free_statemint_asset_assertions(prev_funding_asset_balances.merge_accounts(MergeOperation::Add)); assert_eq!(self.get_plmc_total_supply(), post_supply); From 625a82f90e8fe81ca5624fcd13785e71a459ffa8 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 31 Jan 2024 16:08:06 +0100 Subject: [PATCH 169/212] contribution_ct_mint_for done Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/functions.rs | 11 +++++++++-- pallets/funding/src/impls.rs | 4 ++-- pallets/funding/src/lib.rs | 4 ++-- pallets/funding/src/weights.rs | 30 ++++++++++++++++-------------- 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 81701538d..4bf5b8d76 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -1482,7 +1482,7 @@ impl Pallet { project_id: ProjectId, contributor: &AccountIdOf, contribution_id: u32, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { // * Get variables * let mut contribution = Contributions::::get((project_id, contributor, contribution_id)).ok_or(Error::::BidNotFound)?; @@ -1526,7 +1526,14 @@ impl Pallet { amount: ct_amount, }); - Ok(()) + Ok(PostDispatchInfo { + actual_weight: Some(if ct_account_created { + WeightInfoOf::::contribution_ct_mint_for_with_ct_account_creation() + } else { + WeightInfoOf::::contribution_ct_mint_for_no_ct_account_creation() + }), + pays_fee: Pays::Yes, + }) } pub fn do_evaluation_unbond_for( diff --git a/pallets/funding/src/impls.rs b/pallets/funding/src/impls.rs index fa3f9ff17..ddc1905ed 100644 --- a/pallets/funding/src/impls.rs +++ b/pallets/funding/src/impls.rs @@ -705,11 +705,11 @@ fn mint_ct_for_one_contribution(project_id: ProjectId) -> (Weight, u6 project_id: contribution.project_id, claimer: contribution.contributor.clone(), id: contribution.id, - error: e, + error: e.error, }), }; ( - base_weight.saturating_add(WeightInfoOf::::contribution_ct_mint_for()), + base_weight.saturating_add(WeightInfoOf::::contribution_ct_mint_for_with_ct_account_creation()), remaining_contributions.count() as u64, ) } else { diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index c54620744..13e0329f2 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1084,13 +1084,13 @@ pub mod pallet { } #[pallet::call_index(11)] - #[pallet::weight(WeightInfoOf::::contribution_ct_mint_for())] + #[pallet::weight(WeightInfoOf::::contribution_ct_mint_for_with_ct_account_creation())] pub fn contribution_ct_mint_for( origin: OriginFor, project_id: ProjectId, contributor: AccountIdOf, contribution_id: u32, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { let caller = ensure_signed(origin)?; Self::do_contribution_ct_mint_for(&caller, project_id, &contributor, contribution_id) } diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index 8adc34421..2010fe72f 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -83,7 +83,8 @@ pub trait WeightInfo { fn bid_ct_mint_for_no_ct_account_creation() -> Weight; - fn contribution_ct_mint_for() -> Weight; + fn contribution_ct_mint_for_with_ct_account_creation() -> Weight; + fn contribution_ct_mint_for_no_ct_account_creation() -> Weight; fn start_bid_vesting_schedule_for() -> Weight; fn start_contribution_vesting_schedule_for() -> Weight; fn payout_bid_funds_for() -> Weight; @@ -324,20 +325,21 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } - /// Storage: PolimecFunding Contributions (r:1 w:1) - /// Proof Skipped: PolimecFunding Contributions (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding ProjectsDetails (r:1 w:0) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) - /// Storage: LocalAssets Asset (r:1 w:1) - /// Proof: LocalAssets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) - /// Storage: LocalAssets Account (r:1 w:1) - /// Proof: LocalAssets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) - fn contribution_ct_mint_for() -> Weight { + fn contribution_ct_mint_for_with_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1215` + // Estimated: `4680` + // Minimum execution time: 65_000_000 picoseconds. + Weight::from_parts(71_000_000, 4680) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + fn contribution_ct_mint_for_no_ct_account_creation() -> Weight { // Proof Size summary in bytes: - // Measured: `1205` - // Estimated: `4670` - // Minimum execution time: 64_000_000 picoseconds. - Weight::from_parts(69_000_000, 4670) + // Measured: `1215` + // Estimated: `4680` + // Minimum execution time: 65_000_000 picoseconds. + Weight::from_parts(71_000_000, 4680) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } From d4ebc0c0f730b83fd7200daf65f6e508b33a93b3 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 31 Jan 2024 16:11:34 +0100 Subject: [PATCH 170/212] vesting schedule benchmarks (minimal changes) Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 54 +++++++++++++---------------- 1 file changed, 24 insertions(+), 30 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 5040d318f..72dda6202 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -2308,18 +2308,14 @@ mod benchmarks { ); } - // remaining #[benchmark] - fn start_bid_vesting_schedule_for(x: Linear<1, 20>) { + fn start_bid_vesting_schedule_for() { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - let issuer = account::>("issuer", 0, 0); let bids = default_bids::(); let bidder = bids[0].bidder.clone(); @@ -2368,16 +2364,13 @@ mod benchmarks { } #[benchmark] - fn start_contribution_vesting_schedule_for(x: Linear<1, 20>) { + fn start_contribution_vesting_schedule_for() { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - let issuer = account::>("issuer", 0, 0); let contributions = default_community_contributions::(); let contributor = contributions[0].contributor.clone(); @@ -2432,6 +2425,7 @@ mod benchmarks { ); } + // remaining #[benchmark] fn payout_bid_funds_for(x: Linear<1, 20>) { // setup @@ -3131,27 +3125,27 @@ mod benchmarks { }); } - // #[test] - // fn bench_start_bid_vesting_schedule_for() { - // new_test_ext().execute_with(|| { - // assert_ok!(PalletFunding::::test_start_bid_vesting_schedule_for()); - // }); - // } - // - // #[test] - // fn bench_start_contribution_vesting_schedule_for() { - // new_test_ext().execute_with(|| { - // assert_ok!(PalletFunding::::test_start_contribution_vesting_schedule_for()); - // }); - // } - // - // #[test] - // fn bench_payout_bid_funds_for() { - // new_test_ext().execute_with(|| { - // assert_ok!(PalletFunding::::test_payout_bid_funds_for()); - // }); - // } - // + #[test] + fn bench_start_bid_vesting_schedule_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_start_bid_vesting_schedule_for()); + }); + } + + #[test] + fn bench_start_contribution_vesting_schedule_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_start_contribution_vesting_schedule_for()); + }); + } + + #[test] + fn bench_payout_bid_funds_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_payout_bid_funds_for()); + }); + } + // #[test] // fn bench_payout_contribution_funds_for() { // new_test_ext().execute_with(|| { From 20240bad837ef30831449c46f490c9bf50c79e53 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 31 Jan 2024 16:14:05 +0100 Subject: [PATCH 171/212] payouts benchmarks (minimal changes) Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 72dda6202..a20aeeba4 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -2427,16 +2427,13 @@ mod benchmarks { // remaining #[benchmark] - fn payout_bid_funds_for(x: Linear<1, 20>) { + fn payout_bid_funds_for() { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - let issuer = account::>("issuer", 0, 0); let bids = default_bids::(); let bidder = bids[0].bidder.clone(); @@ -2483,16 +2480,13 @@ mod benchmarks { } #[benchmark] - fn payout_contribution_funds_for(x: Linear<1, 20>) { + fn payout_contribution_funds_for() { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - let issuer = account::>("issuer", 0, 0); let contributions = default_community_contributions::(); let contributor = contributions[0].contributor.clone(); @@ -3146,20 +3140,20 @@ mod benchmarks { }); } - // #[test] - // fn bench_payout_contribution_funds_for() { - // new_test_ext().execute_with(|| { - // assert_ok!(PalletFunding::::test_payout_contribution_funds_for()); - // }); - // } - // + #[test] + fn bench_payout_contribution_funds_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_payout_contribution_funds_for()); + }); + } + // #[test] // fn bench_decide_project_outcome() { // new_test_ext().execute_with(|| { // assert_ok!(PalletFunding::::test_decide_project_outcome()); // }); // } - // + // #[test] // fn bench_release_bid_funds_for() { // new_test_ext().execute_with(|| { From e5637eed997c25007eae5a3ff87c80ac2ab31e4e Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 31 Jan 2024 17:15:55 +0100 Subject: [PATCH 172/212] all benchmarks passing Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 114 ++++++++++++++-------------- pallets/funding/src/functions.rs | 40 +++++++--- pallets/funding/src/lib.rs | 7 +- pallets/funding/src/weights.rs | 4 +- 4 files changed, 91 insertions(+), 74 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index a20aeeba4..d7f9a6222 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -601,9 +601,8 @@ mod benchmarks { let current_block = inst.current_block(); // `do_english_auction` fn will try to add an automatic transition 1 block after the last english round block let insertion_block_number: BlockNumberFor = current_block + T::EnglishAuctionDuration::get() + One::one(); - let mut block_number = insertion_block_number; - fill_projects_to_update::(x, block_number, Some(y)); + fill_projects_to_update::(x, insertion_block_number, Some(y)); #[extrinsic_call] start_auction(RawOrigin::Signed(issuer), project_id); @@ -2425,7 +2424,6 @@ mod benchmarks { ); } - // remaining #[benchmark] fn payout_bid_funds_for() { // setup @@ -2545,15 +2543,20 @@ mod benchmarks { } #[benchmark] - fn decide_project_outcome(x: Linear<1, 20>) { + fn decide_project_outcome( + // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the extrinsic pass + x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, + // Total amount of storage items iterated through in `ProjectsToUpdate` when trying to remove our project in `remove_from_update_store`. + // Upper bound is assumed to be enough + y: Linear<1, 10_000>, + ) { // setup let mut inst = BenchInstantiator::::new(None); - // real benchmark starts at block 0, and we can't call `events()` at block 0 - inst.advance_time(1u32.into()).unwrap(); - - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); + // We need to leave enough block numbers to fill `ProjectsToUpdate` before our project insertion + let u32_remaining_vecs: u32 = y.saturating_sub(x).into(); + let time_advance: u32 = 1 + u32_remaining_vecs + 1; + inst.advance_time(time_advance.into()).unwrap(); let issuer = account::>("issuer", 0, 0); let evaluations = default_evaluations::(); @@ -2586,6 +2589,11 @@ mod benchmarks { inst.advance_time(One::one()).unwrap(); + let current_block = inst.current_block(); + let insertion_block_number: BlockNumberFor = current_block + One::one(); + + fill_projects_to_update::(x, insertion_block_number, Some(y)); + #[extrinsic_call] decide_project_outcome(RawOrigin::Signed(issuer), project_id, FundingOutcomeDecision::AcceptFunding); @@ -2602,16 +2610,13 @@ mod benchmarks { } #[benchmark] - fn release_bid_funds_for(x: Linear<1, 20>) { + fn release_bid_funds_for() { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - let issuer = account::>("issuer", 0, 0); let evaluations = default_evaluations::(); @@ -2676,16 +2681,13 @@ mod benchmarks { } #[benchmark] - fn release_contribution_funds_for(x: Linear<1, 20>) { + fn release_contribution_funds_for() { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - let issuer = account::>("issuer", 0, 0); let evaluations = default_evaluations::(); @@ -2757,16 +2759,13 @@ mod benchmarks { } #[benchmark] - fn bid_unbond_for(x: Linear<1, 20>) { + fn bid_unbond_for() { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - let issuer = account::>("issuer", 0, 0); let evaluations = default_evaluations::(); @@ -2832,16 +2831,13 @@ mod benchmarks { } #[benchmark] - fn contribution_unbond_for(x: Linear<1, 20>) { + fn contribution_unbond_for() { // setup let mut inst = BenchInstantiator::::new(None); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - #[cfg(feature = "std")] - let mut inst = populate_with_projects(x, inst); - let issuer = account::>("issuer", 0, 0); let evaluations = default_evaluations::(); @@ -3147,39 +3143,39 @@ mod benchmarks { }); } - // #[test] - // fn bench_decide_project_outcome() { - // new_test_ext().execute_with(|| { - // assert_ok!(PalletFunding::::test_decide_project_outcome()); - // }); - // } - - // #[test] - // fn bench_release_bid_funds_for() { - // new_test_ext().execute_with(|| { - // assert_ok!(PalletFunding::::test_release_bid_funds_for()); - // }); - // } - // - // #[test] - // fn bench_release_contribution_funds_for() { - // new_test_ext().execute_with(|| { - // assert_ok!(PalletFunding::::test_release_contribution_funds_for()); - // }); - // } - // - // #[test] - // fn bench_bid_unbond_for() { - // new_test_ext().execute_with(|| { - // assert_ok!(PalletFunding::::test_bid_unbond_for()); - // }); - // } - // - // #[test] - // fn bench_contribution_unbond_for() { - // new_test_ext().execute_with(|| { - // assert_ok!(PalletFunding::::test_contribution_unbond_for()); - // }); - // } + #[test] + fn bench_decide_project_outcome() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_decide_project_outcome()); + }); + } + + #[test] + fn bench_release_bid_funds_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_release_bid_funds_for()); + }); + } + + #[test] + fn bench_release_contribution_funds_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_release_contribution_funds_for()); + }); + } + + #[test] + fn bench_bid_unbond_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_bid_unbond_for()); + }); + } + + #[test] + fn bench_contribution_unbond_for() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_contribution_unbond_for()); + }); + } } } diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 4bf5b8d76..2250d7b66 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -1396,7 +1396,7 @@ impl Pallet { issuer: AccountIdOf, project_id: ProjectId, decision: FundingOutcomeDecision, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let now = >::block_number(); @@ -1406,20 +1406,38 @@ impl Pallet { ensure!(project_details.status == ProjectStatus::AwaitingProjectDecision, Error::::NotAllowed); // * Update storage * - // TODO: return real weights - let iterations = match Self::remove_from_update_store(&project_id) { - Ok(iterations) => iterations, - Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + let mut remove_attempts: u32 = 0u32; + let mut insertion_attempts: u32 = 0u32; + + match Self::remove_from_update_store(&project_id) { + Ok(iterations) => remove_attempts = iterations, + Err(iterations) => + return Err(DispatchErrorWithPostInfo { + post_info: PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::decide_project_outcome(insertion_attempts, iterations)), + pays_fee: Pays::Yes, + }, + error: Error::::TooManyInsertionAttempts.into(), + }), + }; + match Self::add_to_update_store(now + 1u32.into(), (&project_id, UpdateType::ProjectDecision(decision))) { + Ok(iterations) => insertion_attempts = iterations, + Err(iterations) => + return Err(DispatchErrorWithPostInfo { + post_info: PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::decide_project_outcome(iterations, remove_attempts)), + pays_fee: Pays::Yes, + }, + error: Error::::TooManyInsertionAttempts.into(), + }), }; - let iterations = - match Self::add_to_update_store(now + 1u32.into(), (&project_id, UpdateType::ProjectDecision(decision))) { - Ok(iterations) => iterations, - Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), - }; Self::deposit_event(Event::ProjectOutcomeDecided { project_id, decision }); - Ok(()) + Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::decide_project_outcome(insertion_attempts, remove_attempts)), + pays_fee: Pays::Yes, + }) } pub fn do_bid_ct_mint_for( diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 13e0329f2..098d10d14 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1144,12 +1144,15 @@ pub mod pallet { } #[pallet::call_index(16)] - #[pallet::weight(WeightInfoOf::::decide_project_outcome())] + #[pallet::weight(WeightInfoOf::::decide_project_outcome( + ::MaxProjectsToUpdateInsertionAttempts::get() - 1, + 10_000u32 + ))] pub fn decide_project_outcome( origin: OriginFor, project_id: ProjectId, outcome: FundingOutcomeDecision, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { let caller = ensure_signed(origin)?; Self::do_decide_project_outcome(caller, project_id, outcome) } diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index 2010fe72f..fd21ca2c1 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -89,7 +89,7 @@ pub trait WeightInfo { fn start_contribution_vesting_schedule_for() -> Weight; fn payout_bid_funds_for() -> Weight; fn payout_contribution_funds_for() -> Weight; - fn decide_project_outcome() -> Weight; + fn decide_project_outcome(x: u32, y:u32) -> Weight; fn release_bid_funds_for() -> Weight; fn bid_unbond_for() -> Weight; fn release_contribution_funds_for() -> Weight; @@ -415,7 +415,7 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) /// Storage: PolimecFunding ProjectsToUpdate (r:3 w:2) /// Proof Skipped: PolimecFunding ProjectsToUpdate (max_values: None, max_size: None, mode: Measured) - fn decide_project_outcome() -> Weight { + fn decide_project_outcome(x: u32, y: u32) -> Weight { // Proof Size summary in bytes: // Measured: `515` // Estimated: `8930` From 32c48a9fc7f864907d39468e690a49949a22e011 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 1 Feb 2024 13:43:46 +0100 Subject: [PATCH 173/212] price test was correct, fixed the expectation Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/instantiator.rs | 29 +++++++++++++++++++++++-- pallets/funding/src/tests.rs | 33 +++++++++++++++++++++++------ 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 96d0de75e..7d300dab0 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -2759,17 +2759,42 @@ impl Default for BidInfoFilter { pub mod testing_macros { #[macro_export] + /// Example: + /// ``` + /// use pallet_funding::assert_close_enough; + /// use sp_arithmetic::Perquintill; + /// + /// let real = 98u64; + /// let desired = 100u64; + /// assert_close_enough!(real, desired, Perquintill::from_float(0.02)); + /// // This would fail + /// // assert_close_enough!(real, desired, Perquintill::from_float(0.01)); + /// ``` + /// + /// - Use this macro when you deal with operations with lots of decimals, and you are ok with the real value being an approximation of the desired one. + /// - The max_approximation should be an upper bound such that 1-real/desired <= approximation in the case where the desired is smaller than the real, + /// and 1-desired/real <= approximation in the case where the real is bigger than the desired. + /// - You probably should define the max_approximation from a float number or a percentage, like in the example. macro_rules! assert_close_enough { // Match when a message is provided ($real:expr, $desired:expr, $max_approximation:expr, $msg:expr) => { - let real_parts = Perquintill::from_rational($real, $desired); + if $real <= $desired { + let real_parts = Perquintill::from_rational($real, $desired); + } else { + let real_parts = Perquintill::from_rational($desired, $real); + } let one = Perquintill::from_percent(100u64); let real_approximation = one - real_parts; assert!(real_approximation <= $max_approximation, $msg); }; // Match when no message is provided ($real:expr, $desired:expr, $max_approximation:expr) => { - let real_parts = Perquintill::from_rational($real, $desired); + let real_parts; + if $real <= $desired { + real_parts = Perquintill::from_rational($real, $desired); + } else { + real_parts = Perquintill::from_rational($desired, $real); + } let one = Perquintill::from_percent(100u64); let real_approximation = one - real_parts; assert!( diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index e46fdd215..c2b499562 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -850,6 +850,27 @@ mod auction_round_success { let accounts = vec![ADAM, TOM, SOFIA, FRED, ANNA, DAMIAN]; + let bounded_name = BoundedVec::try_from("Contribution Token TEST".as_bytes().to_vec()).unwrap(); + let bounded_symbol = BoundedVec::try_from("CTEST".as_bytes().to_vec()).unwrap(); + let metadata_hash = hashed(format!("{}-{}", METADATA, 0)); + let project_metadata = ProjectMetadata { + token_information: CurrencyMetadata { + name: bounded_name, + symbol: bounded_symbol, + decimals: ASSET_DECIMALS, + }, + mainnet_token_max_supply: 8_000_000 * ASSET_UNIT, + total_allocation_size: (50_000 * ASSET_UNIT, 50_000 * ASSET_UNIT), + minimum_price: PriceOf::::from_float(10.0), + ticket_size: TicketSize { minimum: Some(1), maximum: None }, + participants_size: ParticipantsSize { minimum: Some(2), maximum: None }, + funding_thresholds: Default::default(), + conversion_rate: 0, + participation_currencies: AcceptedFundingAsset::USDT, + funding_destination_account: ISSUER, + offchain_information_hash: Some(metadata_hash), + }; + // overfund with plmc let plmc_fundings = accounts .iter() @@ -866,7 +887,7 @@ mod auction_round_success { inst.mint_plmc_to(plmc_fundings); inst.mint_statemint_asset_to(usdt_fundings); - let project_metadata = default_project(inst.get_new_nonce(), ISSUER); + // let project_metadata = default_project(inst.get_new_nonce(), ISSUER); let project_id = inst.create_auctioning_project(project_metadata, ISSUER, default_evaluations()); let bids = vec![ @@ -882,13 +903,11 @@ mod auction_round_success { inst.start_community_funding(project_id).unwrap(); - let bids = inst.execute(|| Bids::::iter_prefix_values((project_id,)).collect_vec()); - let token_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); - let token_price_as_usdt = token_price.saturating_mul_int(ASSET_UNIT); - - let current_bucket = inst.execute(|| Buckets::::get(project_id).unwrap()); + let token_price = + inst.get_project_details(project_id).weighted_average_price.unwrap().saturating_mul_int(ASSET_UNIT); + let desired_price = PriceOf::::from_float(11.1818f64).saturating_mul_int(ASSET_UNIT); - assert_eq!(token_price_as_usdt, ASSET_UNIT * 11); + assert_close_enough!(token_price, desired_price, Perquintill::from_float(0.01)); } #[test] From b4c357eae7102735e51d7ec991cd2e620956ea34 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 1 Feb 2024 14:39:54 +0100 Subject: [PATCH 174/212] save Signed-off-by: Juan Ignacio Rios --- nodes/parachain/src/chain_spec/testnet.rs | 6 +-- pallets/funding/src/benchmarking.rs | 2 +- pallets/funding/src/functions.rs | 48 +++++++++++------------ pallets/funding/src/instantiator.rs | 3 -- pallets/funding/src/tests.rs | 4 +- pallets/funding/src/weights.rs | 20 +++++----- 6 files changed, 38 insertions(+), 45 deletions(-) diff --git a/nodes/parachain/src/chain_spec/testnet.rs b/nodes/parachain/src/chain_spec/testnet.rs index df4b09055..907fbacd9 100644 --- a/nodes/parachain/src/chain_spec/testnet.rs +++ b/nodes/parachain/src/chain_spec/testnet.rs @@ -271,18 +271,16 @@ fn testnet_genesis( } } -use pallet_funding::{instantiator::UserToUSDBalance, *}; -use sp_runtime::BoundedVec; - #[cfg(feature = "std")] mod testing_helpers { use super::*; use macros::generate_accounts; pub use pallet_funding::{instantiator::UserToUSDBalance, *}; + use pallet_funding::{instantiator::UserToUSDBalance, *}; use polimec_parachain_runtime::AccountId; use sp_core::H256; + use sp_runtime::BoundedVec; pub use sp_runtime::{traits::ConstU32, BoundedVec, FixedU128}; - pub const METADATA: &str = r#"METADATA { "whitepaper":"ipfs_url", diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index d7f9a6222..992670545 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -21,7 +21,7 @@ use sp_runtime::traits::TrailingZeroInput; use super::*; -use crate::{instantiator::*, traits::SetPrices}; +use crate::instantiator::*; use frame_benchmarking::v2::*; use frame_support::{ assert_ok, diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 2250d7b66..b186041e9 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -45,7 +45,6 @@ use polimec_common::ReleaseSchedule; use crate::traits::{BondingRequirementCalculation, ProvideStatemintPrice, VestingDurationCalculation}; use frame_support::traits::fungible::Mutate; use polimec_common::migration_types::{MigrationInfo, MigrationOrigin, Migrations, ParticipationType}; -use sp_runtime::DispatchResultWithInfo; use super::*; const POLIMEC_PARA_ID: u32 = 3344u32; @@ -283,12 +282,12 @@ impl Pallet { project_details.status = ProjectStatus::AuctionInitializePeriod; ProjectsDetails::::insert(project_id, project_details); // TODO: return real weights - let insertions_attempts = match Self::add_to_update_store( + let _insertions_attempts = match Self::add_to_update_store( auction_initialize_period_end_block + 1u32.into(), (&project_id, UpdateType::EnglishAuctionStart), ) { Ok(insertions) => insertions, - Err(insertions) => return Err(Error::::TooManyInsertionAttempts.into()), + Err(_insertions) => return Err(Error::::TooManyInsertionAttempts.into()), }; // * Emit events * @@ -384,7 +383,10 @@ impl Pallet { Err(iterations) => return Err(DispatchErrorWithPostInfo { post_info: PostDispatchInfo { - actual_weight: Some(WeightInfoOf::::start_auction_manually(0u32, iterations)), + actual_weight: Some(WeightInfoOf::::start_auction_manually( + insertion_attempts, + iterations, + )), pays_fee: Pays::Yes, }, error: Error::::ProjectNotInUpdateStore.into(), @@ -471,12 +473,12 @@ impl Pallet { ProjectsDetails::::insert(project_id, project_details); // Schedule for automatic check by on_initialize. Success depending on enough funding reached // TODO: return real weights - let iterations = match Self::add_to_update_store( + let _iterations = match Self::add_to_update_store( candle_end_block + 1u32.into(), (&project_id, UpdateType::CommunityFundingStart), ) { Ok(iterations) => iterations, - Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + Err(_iterations) => return Err(Error::::TooManyInsertionAttempts.into()), }; // * Emit events * @@ -538,12 +540,12 @@ impl Pallet { project_details.status = ProjectStatus::FundingFailed; ProjectsDetails::::insert(project_id, project_details); // TODO: return real weights - let iterations = match Self::add_to_update_store( + let _iterations = match Self::add_to_update_store( >::block_number() + 1u32.into(), (&project_id, UpdateType::FundingEnd), ) { Ok(iterations) => iterations, - Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + Err(_iterations) => return Err(Error::::TooManyInsertionAttempts.into()), }; // * Emit events * @@ -562,12 +564,12 @@ impl Pallet { project_details.status = ProjectStatus::CommunityRound; ProjectsDetails::::insert(project_id, project_details); // TODO: return real weights - let iterations = match Self::add_to_update_store( + let _iterations = match Self::add_to_update_store( community_end_block + 1u32.into(), (&project_id, UpdateType::RemainderFundingStart), ) { Ok(iterations) => iterations, - Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + Err(_iterations) => return Err(Error::::TooManyInsertionAttempts.into()), }; // * Emit events * @@ -623,10 +625,10 @@ impl Pallet { ProjectsDetails::::insert(project_id, project_details); // Schedule for automatic transition by `on_initialize` // TODO: return real weights - let iterations = + let _iterations = match Self::add_to_update_store(remainder_end_block + 1u32.into(), (&project_id, UpdateType::FundingEnd)) { Ok(iterations) => iterations, - Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + Err(_iterations) => return Err(Error::::TooManyInsertionAttempts.into()), }; // * Emit events * @@ -701,12 +703,12 @@ impl Pallet { project_details.evaluation_round_info.evaluators_outcome = EvaluatorsOutcome::Slashed; project_details.status = ProjectStatus::AwaitingProjectDecision; // TODO: return real weights - let iterations = match Self::add_to_update_store( + let _iterations = match Self::add_to_update_store( now + T::ManualAcceptanceDuration::get() + 1u32.into(), (&project_id, UpdateType::ProjectDecision(FundingOutcomeDecision::AcceptFunding)), ) { Ok(iterations) => iterations, - Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + Err(_iterations) => return Err(Error::::TooManyInsertionAttempts.into()), }; ProjectsDetails::::insert(project_id, project_details); Ok(()) @@ -714,12 +716,12 @@ impl Pallet { project_details.evaluation_round_info.evaluators_outcome = EvaluatorsOutcome::Unchanged; project_details.status = ProjectStatus::AwaitingProjectDecision; // TODO: return real weights - let iterations = match Self::add_to_update_store( + let _iterations = match Self::add_to_update_store( now + T::ManualAcceptanceDuration::get() + 1u32.into(), (&project_id, UpdateType::ProjectDecision(FundingOutcomeDecision::AcceptFunding)), ) { Ok(iterations) => iterations, - Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + Err(_iterations) => return Err(Error::::TooManyInsertionAttempts.into()), }; ProjectsDetails::::insert(project_id, project_details); Ok(()) @@ -902,8 +904,6 @@ impl Pallet { } if caller_existing_evaluations.len() < T::MaxEvaluationsPerUser::get() as usize { - use frame_support::traits::fungible::Inspect; - T::NativeCurrency::hold(&HoldReason::Evaluation(project_id.into()).into(), evaluator, plmc_bond)?; } else { let (low_id, lowest_evaluation) = caller_existing_evaluations @@ -1150,7 +1150,7 @@ impl Pallet { fully_filled_vecs_from_insertion: u32, total_vecs_in_storage: u32, } - let mut weight_contribution_flag: WeightContributionFlag; + let weight_contribution_flag: WeightContributionFlag; let mut weight_round_end_flag: Option = None; let mut weight_ct_account_deposit = false; @@ -1406,7 +1406,7 @@ impl Pallet { ensure!(project_details.status == ProjectStatus::AwaitingProjectDecision, Error::::NotAllowed); // * Update storage * - let mut remove_attempts: u32 = 0u32; + let remove_attempts: u32; let mut insertion_attempts: u32 = 0u32; match Self::remove_from_update_store(&project_id) { @@ -3089,10 +3089,10 @@ impl Pallet { ProjectsDetails::::insert(project_id, project_details); // TODO: add real weights - let iterations = + let _iterations = match Self::add_to_update_store(now + settlement_delta, (&project_id, UpdateType::StartSettlement)) { Ok(iterations) => iterations, - Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + Err(_iterations) => return Err(Error::::TooManyInsertionAttempts.into()), }; Self::deposit_event(Event::FundingEnded { project_id, outcome: FundingOutcome::Success(reason) }); @@ -3111,10 +3111,10 @@ impl Pallet { ProjectsDetails::::insert(project_id, project_details); // TODO: add real weights - let iterations = + let _iterations = match Self::add_to_update_store(now + settlement_delta, (&project_id, UpdateType::StartSettlement)) { Ok(iterations) => iterations, - Err(iterations) => return Err(Error::::TooManyInsertionAttempts.into()), + Err(_iterations) => return Err(Error::::TooManyInsertionAttempts.into()), }; Self::deposit_event(Event::FundingEnded { project_id, outcome: FundingOutcome::Failure(reason) }); Ok(()) diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 7d300dab0..0020a01ff 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -1493,9 +1493,6 @@ pub mod async_features { ) -> ProjectId { let mut inst = instantiator.lock().await; - let asset_account_deposit = - inst.execute(|| ::ContributionTokenCurrency::deposit_required(One::one())); - let ed = Instantiator::::get_ed(); let now = inst.current_block(); // One ED for the issuer, one for the escrow account inst.mint_plmc_to(vec![UserToPLMCBalance::new( diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index c2b499562..86d165164 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -437,8 +437,7 @@ mod evaluation_round_success { for (real, desired) in zip(actual_reward_balances.iter(), expected_ct_rewards.iter()) { assert_eq!(real.0, desired.0, "bad accounts order"); - // 0.01 parts of a Perbill - assert_close_enough!(real.1, desired.1, Perquintill::from_parts(10_000_000u64)); + assert_close_enough!(real.1, desired.1, Perquintill::from_float(0.001)); } } @@ -887,7 +886,6 @@ mod auction_round_success { inst.mint_plmc_to(plmc_fundings); inst.mint_statemint_asset_to(usdt_fundings); - // let project_metadata = default_project(inst.get_new_nonce(), ISSUER); let project_id = inst.create_auctioning_project(project_metadata, ISSUER, default_evaluations()); let bids = vec![ diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index fd21ca2c1..1e585fbab 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -137,7 +137,7 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) /// Storage: PolimecFunding ProjectsToUpdate (r:1 w:1) /// Proof Skipped: PolimecFunding ProjectsToUpdate (max_values: None, max_size: None, mode: Measured) - fn start_evaluation(x: u32) -> Weight { + fn start_evaluation(_x: u32) -> Weight { // Proof Size summary in bytes: // Measured: `467` // Estimated: `3932` @@ -146,7 +146,7 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } - fn start_auction_manually(x: u32, y: u32) -> Weight { + fn start_auction_manually(_x: u32, _y: u32) -> Weight { Zero::zero() } @@ -157,7 +157,7 @@ impl WeightInfo for SubstrateWeight { fn first_evaluation() -> Weight { Weight::from_parts(20_000_000, 3932) } - fn second_to_limit_evaluation(x: u32) -> Weight { + fn second_to_limit_evaluation(_x: u32) -> Weight { Weight::from_parts(20_000_000, 3932) } fn evaluation_over_limit() -> Weight { @@ -181,11 +181,11 @@ impl WeightInfo for SubstrateWeight { /// Proof: StatemintAssets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) /// Storage: System Account (r:1 w:1) /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn bid_with_ct_deposit(y: u32) -> Weight { + fn bid_with_ct_deposit(_y: u32) -> Weight { Weight::from_parts(140_000_000, 6208) } - fn bid_no_ct_deposit(x: u32, y: u32) -> Weight { + fn bid_no_ct_deposit(_x: u32, _y: u32) -> Weight { Weight::from_parts(140_000_000, 6208) } @@ -199,21 +199,21 @@ impl WeightInfo for SubstrateWeight { } - fn first_contribution_ends_round_no_ct_deposit(y: u32, z: u32) -> Weight { + fn first_contribution_ends_round_no_ct_deposit(_y: u32, _z: u32) -> Weight { Weight::from_parts(140_000_000, 6208) } - fn first_contribution_ends_round_with_ct_deposit(y: u32, z: u32) -> Weight { + fn first_contribution_ends_round_with_ct_deposit(_y: u32, _z: u32) -> Weight { Weight::from_parts(140_000_000, 6208) } - fn second_to_limit_contribution(x: u32) -> Weight { + fn second_to_limit_contribution(_x: u32) -> Weight { Weight::from_parts(140_000_000, 6208) } - fn second_to_limit_contribution_ends_round(x: u32, y: u32, z: u32) -> Weight { + fn second_to_limit_contribution_ends_round(_x: u32, _y: u32, _z: u32) -> Weight { Weight::from_parts(140_000_000, 6208) } @@ -415,7 +415,7 @@ impl WeightInfo for SubstrateWeight { /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) /// Storage: PolimecFunding ProjectsToUpdate (r:3 w:2) /// Proof Skipped: PolimecFunding ProjectsToUpdate (max_values: None, max_size: None, mode: Measured) - fn decide_project_outcome(x: u32, y: u32) -> Weight { + fn decide_project_outcome(_x: u32, _y: u32) -> Weight { // Proof Size summary in bytes: // Measured: `515` // Estimated: `8930` From 809fb958524a45a45b5e2fa9feb6e857e46917b9 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 1 Feb 2024 16:05:18 +0100 Subject: [PATCH 175/212] fix evaluator rewards test Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/tests.rs | 129 +++++++++++++++++++---------------- 1 file changed, 70 insertions(+), 59 deletions(-) diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 86d165164..4ec6c8ee5 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -107,6 +107,30 @@ pub mod defaults { } } + pub fn knowledge_hub_project(nonce: u64) -> ProjectMetadataOf { + let bounded_name = BoundedVec::try_from("Contribution Token TEST".as_bytes().to_vec()).unwrap(); + let bounded_symbol = BoundedVec::try_from("CTEST".as_bytes().to_vec()).unwrap(); + let metadata_hash = hashed(format!("{}-{}", METADATA, nonce)); + let project_metadata = ProjectMetadataOf:: { + token_information: CurrencyMetadata { + name: bounded_name, + symbol: bounded_symbol, + decimals: ASSET_DECIMALS, + }, + mainnet_token_max_supply: 8_000_000 * ASSET_UNIT, + total_allocation_size: (50_000 * ASSET_UNIT, 50_000 * ASSET_UNIT), + minimum_price: PriceOf::::from_float(10.0), + ticket_size: TicketSize { minimum: Some(1), maximum: None }, + participants_size: ParticipantsSize { minimum: Some(2), maximum: None }, + funding_thresholds: Default::default(), + conversion_rate: 0, + participation_currencies: AcceptedFundingAsset::USDT, + funding_destination_account: ISSUER, + offchain_information_hash: Some(metadata_hash), + }; + project_metadata + } + pub fn default_plmc_balances() -> Vec> { vec![ UserToPLMCBalance::new(ISSUER, 20_000 * PLMC), @@ -128,6 +152,14 @@ pub mod defaults { ] } + pub fn knowledge_hub_evaluations() -> Vec> { + vec![ + UserToUSDBalance::new(EVALUATOR_1, 75_000 * USDT_UNIT), + UserToUSDBalance::new(EVALUATOR_2, 65_000 * USDT_UNIT), + UserToUSDBalance::new(EVALUATOR_3, 60_000 * USDT_UNIT), + ] + } + pub fn default_failing_evaluations() -> Vec> { vec![UserToUSDBalance::new(EVALUATOR_1, 3_000 * PLMC), UserToUSDBalance::new(EVALUATOR_2, 1_000 * PLMC)] } @@ -140,6 +172,18 @@ pub mod defaults { ] } + pub fn knowledge_hub_bids() -> Vec> { + // This should reflect the bidding currency, which currently is USDT + vec![ + BidParams::new(BIDDER_1, 10_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), + BidParams::new(BIDDER_2, 20_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), + BidParams::new(BIDDER_3, 20_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), + BidParams::new(BIDDER_4, 10_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), + BidParams::new(BIDDER_5, 5_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), + BidParams::new(BIDDER_6, 5_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), + ] + } + pub fn default_community_buys() -> Vec> { vec![ ContributionParams::new(BUYER_1, 8_100 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), @@ -156,6 +200,18 @@ pub mod defaults { ] } + pub fn knowledge_hub_buys() -> Vec> { + vec![ + ContributionParams::new(BUYER_1, 4_000 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), + ContributionParams::new(BUYER_2, 2_000 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), + ContributionParams::new(BUYER_3, 2_000 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), + ContributionParams::new(BUYER_4, 5_000 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), + ContributionParams::new(BUYER_5, 30_000 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), + ContributionParams::new(BUYER_6, 5_000 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), + ContributionParams::new(BUYER_7, 2_000 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), + ] + } + pub fn default_weights() -> Vec { vec![20u8, 15u8, 10u8, 25u8, 30u8] } @@ -366,65 +422,17 @@ mod evaluation_round_success { fn rewards_are_paid_full_funding() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let bounded_name = BoundedVec::try_from("Contribution Token TEST".as_bytes().to_vec()).unwrap(); - let bounded_symbol = BoundedVec::try_from("CTEST".as_bytes().to_vec()).unwrap(); - let metadata_hash = hashed(format!("{}-{}", METADATA, 420)); - let project_metadata = ProjectMetadataOf:: { - token_information: CurrencyMetadata { - name: bounded_name, - symbol: bounded_symbol, - decimals: ASSET_DECIMALS, - }, - mainnet_token_max_supply: 8_000_000 * ASSET_UNIT, - total_allocation_size: (50_000 * ASSET_UNIT, 50_000 * ASSET_UNIT), - minimum_price: PriceOf::::from_float(1.0), - ticket_size: TicketSize { minimum: Some(1), maximum: None }, - participants_size: ParticipantsSize { minimum: Some(2), maximum: None }, - funding_thresholds: Default::default(), - conversion_rate: 0, - participation_currencies: AcceptedFundingAsset::USDT, - funding_destination_account: ISSUER, - offchain_information_hash: Some(metadata_hash), - }; - - // all values taken from the knowledge hub - let evaluations: Vec> = default_evaluations(); + let project_metadata = knowledge_hub_project(0); + let evaluations = knowledge_hub_evaluations(); + let bids = knowledge_hub_bids(); + let contributions = knowledge_hub_buys(); - let bids: Vec> = vec![ - BidParams::new(BIDDER_1, 10_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), - BidParams::new(BIDDER_2, 20_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), - BidParams::new(BIDDER_4, 20_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), - ]; - - let contributions: Vec> = vec![ - ContributionParams::new(BUYER_1, 4_000 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_2, 2_000 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_3, 2_000 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_4, 5_000 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_5, 30_000 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_6, 5_000 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), - ContributionParams::new(BUYER_7, 2_000 * ASSET_UNIT, 1u8, AcceptedFundingAsset::USDT), - ]; - - let (project_id, _) = inst.create_community_contributing_project(project_metadata, ISSUER, evaluations, bids); - let details = inst.get_project_details(project_id); - let ct_price = details.weighted_average_price.unwrap(); - let plmc_deposits = MockInstantiator::calculate_contributed_plmc_spent(contributions.clone(), ct_price); - let existential_deposits = plmc_deposits.accounts().existential_deposits(); - let ct_account_deposits = plmc_deposits.accounts().ct_account_deposits(); - let funding_deposits = - MockInstantiator::calculate_contributed_funding_asset_spent(contributions.clone(), ct_price); - - inst.mint_plmc_to(plmc_deposits); - inst.mint_plmc_to(existential_deposits); - inst.mint_plmc_to(ct_account_deposits); - inst.mint_statemint_asset_to(funding_deposits); + let project_id = + inst.create_finished_project(project_metadata, ISSUER, evaluations, bids, contributions, vec![]); - inst.contribute_for_users(project_id, contributions).unwrap(); - inst.finish_funding(project_id).unwrap(); inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); - inst.advance_time(10).unwrap(); + let actual_reward_balances = inst.execute(|| { vec![ (EVALUATOR_1, ::ContributionTokenCurrency::balance(project_id, EVALUATOR_1)), @@ -432,12 +440,15 @@ mod evaluation_round_success { (EVALUATOR_3, ::ContributionTokenCurrency::balance(project_id, EVALUATOR_3)), ] }); - let expected_ct_rewards = - vec![(EVALUATOR_1, 17214953271028), (EVALUATOR_2, 5607476635514), (EVALUATOR_3, 6_379_471_698_137)]; + let expected_ct_rewards = vec![ + (EVALUATOR_1, 1_332_4_500_000_000), + (EVALUATOR_2, 917_9_100_000_000), + (EVALUATOR_3, 710_6_400_000_000), + ]; for (real, desired) in zip(actual_reward_balances.iter(), expected_ct_rewards.iter()) { - assert_eq!(real.0, desired.0, "bad accounts order"); - assert_close_enough!(real.1, desired.1, Perquintill::from_float(0.001)); + // TODO: Check if either knowledge hub needs updating, or we need to update our weighted average price calculation + assert_close_enough!(real.1, desired.1, Perquintill::from_float(0.01)); } } From 4eba97de83b1a5d1f358d766cbb82e5729027382 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 1 Feb 2024 16:37:31 +0100 Subject: [PATCH 176/212] fmt, remove draft tests Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 22 ++++++++++----------- pallets/funding/src/tests.rs | 12 ----------- pallets/parachain-staking/src/benchmarks.rs | 4 ++-- 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 992670545..5aee12368 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -23,11 +23,12 @@ use sp_runtime::traits::TrailingZeroInput; use super::*; use crate::instantiator::*; use frame_benchmarking::v2::*; +#[cfg(test)] +use frame_support::assert_ok; use frame_support::{ - assert_ok, dispatch::RawOrigin, traits::{ - fungible::{InspectHold, Mutate, MutateHold}, + fungible::{InspectHold, MutateHold}, OriginTrait, }, Parameter, @@ -41,7 +42,6 @@ use sp_arithmetic::Percent; use sp_core::H256; use sp_io::hashing::blake2_256; use sp_runtime::traits::{BlakeTwo256, Get, Member}; -use sp_std::prelude::*; const METADATA: &str = r#" { @@ -455,8 +455,6 @@ mod benchmarks { // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); - let projects_details_count = ProjectsDetails::::iter().count(); - let ed = BenchInstantiator::::get_ed(); let issuer = account::>("issuer", 0, 0); @@ -655,7 +653,7 @@ mod benchmarks { current_block + ::AuctionInitializePeriodDuration::get() + One::one(); let insertion_block_number: BlockNumberFor = automatic_transition_block + T::EnglishAuctionDuration::get() + One::one(); - let mut block_number = insertion_block_number; + let block_number = insertion_block_number; fill_projects_to_update::(x, block_number, None); @@ -943,7 +941,7 @@ mod benchmarks { let current_bucket = Buckets::::get(project_id).unwrap(); // first lets bring the bucket to almost its limit with another bidder: assert!(new_bidder.clone() != bidder.clone()); - let mut bid_params = BidParams::new( + let bid_params = BidParams::new( new_bidder, current_bucket.amount_left, // not used atm @@ -982,12 +980,12 @@ mod benchmarks { inst.mint_plmc_to(plmc_for_extrinsic_bids.clone()); inst.mint_statemint_asset_to(usdt_for_extrinsic_bids.clone()); - let mut total_free_plmc = existential_deposits[0].plmc_amount; + let total_free_plmc = existential_deposits[0].plmc_amount; let total_plmc_participation_bonded = BenchInstantiator::::sum_balance_mappings(vec![ plmc_for_extrinsic_bids.clone(), plmc_for_existing_bids.clone(), ]); - let mut total_free_usdt = Zero::zero(); + let total_free_usdt = Zero::zero(); let total_escrow_usdt_locked = BenchInstantiator::::sum_statemint_mappings(vec![ prev_total_escrow_usdt_locked.clone(), usdt_for_extrinsic_bids.clone(), @@ -1118,7 +1116,7 @@ mod benchmarks { // if x were > 0, then the ct deposit would already be paid let x = 0; let ( - mut inst, + inst, project_id, project_metadata, original_extrinsic_bid, @@ -1157,7 +1155,7 @@ mod benchmarks { #[benchmark] fn bid_no_ct_deposit(x: Linear<0, { T::MaxBidsPerUser::get() - 1 }>, y: Linear<0, 10>) { let ( - mut inst, + inst, project_id, project_metadata, original_extrinsic_bid, @@ -1250,7 +1248,7 @@ mod benchmarks { }; let existing_contribution = ContributionParams::new(contributor.clone(), existing_amount, 1u8, AcceptedFundingAsset::USDT); - let mut extrinsic_contribution = + let extrinsic_contribution = ContributionParams::new(contributor.clone(), extrinsic_amount, 1u8, AcceptedFundingAsset::USDT); let existing_contributions = vec![existing_contribution; x as usize]; diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 4ec6c8ee5..38c417c29 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -6304,15 +6304,3 @@ mod async_tests { assert_eq!(inst.get_project_details(0).status, ProjectStatus::FundingSuccessful); } } - -mod draft_tests { - #[test] - fn transition_failed_too_many_insertion_tries() { - todo!() - } - - #[test] - fn transition_can_happen_after_too_many_insertions_error() { - todo!() - } -} diff --git a/pallets/parachain-staking/src/benchmarks.rs b/pallets/parachain-staking/src/benchmarks.rs index e05df27ca..e7410bf8d 100644 --- a/pallets/parachain-staking/src/benchmarks.rs +++ b/pallets/parachain-staking/src/benchmarks.rs @@ -23,11 +23,11 @@ use crate::{ }; use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, vec}; use frame_support::traits::{ - fungible::{Inspect, Mutate, MutateHold}, + fungible::{Inspect, Mutate}, Get, OnFinalize, OnInitialize, }; use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; -#[cfg(feature = "std")] +#[cfg(test)] use sp_runtime::BuildStorage; use sp_runtime::{Perbill, Percent}; use sp_std::{default::Default, vec::Vec}; From 96076c3cbf0227e9d6a7ef93dbd77d87306fbfaf Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 2 Feb 2024 10:30:02 +0100 Subject: [PATCH 177/212] remove unused tests. Add real weights on pallet-funding Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/tests.rs | 100 -- pallets/funding/src/weights.rs | 1742 ++++++++++++++++++++++++++------ 2 files changed, 1427 insertions(+), 415 deletions(-) diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 38c417c29..9993766ce 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -761,65 +761,6 @@ mod auction_round_success { inst.bid_for_users(project_id, vec![evaluator_bid]); } - // TODO: remove? - #[ignore] - #[test] - fn evaluation_bond_counts_towards_bid_vec_full() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let issuer = ISSUER; - let project = default_project(inst.get_new_nonce(), issuer); - let mut evaluations = default_evaluations(); - let evaluator_bidder = 69; - let evaluator_bid = - BidParams::new(evaluator_bidder, 600 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT); - - let mut bids = Vec::new(); - for _ in 0..::MaxBidsPerUser::get() { - bids.push(BidParams::new(evaluator_bidder, 100 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT)); - } - - let fill_necessary_plmc_for_bids = MockInstantiator::calculate_auction_plmc_spent(&bids.clone(), None); - let fill_necessary_usdt_for_bids = MockInstantiator::calculate_auction_funding_asset_spent(&bids, None); - - let bid_necessary_plmc = MockInstantiator::calculate_auction_plmc_spent(&vec![evaluator_bid.clone()], None); - let bid_necessary_usdt = - MockInstantiator::calculate_auction_funding_asset_spent(&vec![evaluator_bid.clone()], None); - - let evaluation_bond = - MockInstantiator::sum_balance_mappings(vec![fill_necessary_plmc_for_bids, bid_necessary_plmc]); - let plmc_available_for_participation = - evaluation_bond - ::EvaluatorSlash::get() * evaluation_bond; - - let evaluation_usd_amount = ::PriceProvider::get_price(PLMC_STATEMINT_ID) - .unwrap() - .saturating_mul_int(evaluation_bond); - evaluations.push(UserToUSDBalance::new(evaluator_bidder, evaluation_usd_amount)); - - let project_id = inst.create_auctioning_project(project, issuer, evaluations); - - inst.mint_plmc_to(vec![UserToPLMCBalance::new( - evaluator_bidder, - evaluation_bond - plmc_available_for_participation, - )]); - inst.mint_statemint_asset_to(fill_necessary_usdt_for_bids); - inst.mint_statemint_asset_to(bid_necessary_usdt); - - inst.bid_for_users(project_id, bids); - inst.bid_for_users(project_id, vec![evaluator_bid]); - - let evaluation_bonded = inst.execute(|| { - ::NativeCurrency::balance_on_hold( - &HoldReason::Evaluation(project_id.into()).into(), - &evaluator_bidder, - ) - }); - assert_close_enough!( - evaluation_bonded, - ::EvaluatorSlash::get() * evaluation_bond, - Perquintill::from_parts(1_000_000_000) - ); - } - #[test] fn price_calculation_1() { // TODO: Update this test to use the knowledge hub values (when they are available) @@ -1885,47 +1826,6 @@ mod auction_round_failure { }); } - // TODO: remove? - #[ignore] - #[test] - fn bids_overflow() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - let project_id = inst.create_auctioning_project(default_project(0, ISSUER), ISSUER, default_evaluations()); - const DAVE: AccountId = 42; - let bids: Vec> = vec![ - BidParams::new(DAVE, 10_000 * USDT_UNIT, 2_u128.into(), 1u8, AcceptedFundingAsset::USDT), // 20k - BidParams::new(DAVE, 12_000 * USDT_UNIT, 8_u128.into(), 1u8, AcceptedFundingAsset::USDT), // 96k - BidParams::new(DAVE, 15_000 * USDT_UNIT, 5_u128.into(), 1u8, AcceptedFundingAsset::USDT), // 75k - // Bid with lowest PLMC bonded gets dropped - BidParams::new(DAVE, 1_000 * USDT_UNIT, 7_u128.into(), 1u8, AcceptedFundingAsset::USDT), // 7k - BidParams::new(DAVE, 20_000 * USDT_UNIT, 5_u128.into(), 1u8, AcceptedFundingAsset::USDT), // 100k - ]; - - let mut plmc_fundings = MockInstantiator::calculate_auction_plmc_spent(&bids, None); - // Existential deposit on DAVE - plmc_fundings.push(UserToPLMCBalance::new(DAVE, MockInstantiator::get_ed())); - - let statemint_asset_fundings = MockInstantiator::calculate_auction_funding_asset_spent(&bids, None); - - // Fund enough for all PLMC bonds for the bids (multiplier of 1) - inst.mint_plmc_to(plmc_fundings); - - // Fund enough for all bids - inst.mint_statemint_asset_to(statemint_asset_fundings); - - inst.bid_for_users(project_id, bids); - - inst.execute(|| { - let mut stored_bids = Bids::::iter_prefix_values((project_id, DAVE)).collect::>(); - assert_eq!(stored_bids.len(), 4); - stored_bids.sort(); - assert_eq!(stored_bids[0].original_ct_usd_price.to_float(), 1.0); - assert_eq!(stored_bids[1].original_ct_usd_price.to_float(), 1.0); - assert_eq!(stored_bids[2].original_ct_usd_price.to_float(), 1.1); - assert_eq!(stored_bids[3].original_ct_usd_price.to_float(), 1.2); - }); - } - #[test] fn bid_with_asset_not_accepted() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index 1e585fbab..c7fa8edc2 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -17,13 +17,13 @@ // If you feel like getting in touch with us, you can do so at info@polimec.org -//! Autogenerated weights for pallet_funding +//! Autogenerated weights for `pallet_funding` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-09-15, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-02-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `Juans-MacBook-Pro.fritz.box`, CPU: `` -//! EXECUTION: `Some(Wasm)`, WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: `1024` +//! HOSTNAME: `Juans-MBP.home`, CPU: `` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: `1024` // Executed Command: // target/release/polimec-parachain-node @@ -35,7 +35,6 @@ // --pallet=pallet_funding // --extrinsic // * -// --execution=wasm // --heap-pages=4096 // --output=pallets/funding/src/weights-test.rs // --template=./.maintain/frame-weight-template.hbs @@ -45,25 +44,21 @@ #![allow(unused_imports)] #![allow(missing_docs)] -use sp_arithmetic::traits::Zero; use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use core::marker::PhantomData; -/// Weight functions needed for pallet_funding. +/// Weight functions needed for `pallet_funding`. pub trait WeightInfo { fn create() -> Weight; fn edit_metadata() -> Weight; - fn start_evaluation(x: u32) -> Weight; - fn start_auction_manually(x: u32, y: u32) -> Weight; - fn start_auction_automatically() -> Weight; - + fn start_evaluation(x: u32, ) -> Weight; + fn start_auction_manually(x: u32, y: u32, ) -> Weight; + fn start_auction_automatically(x: u32, ) -> Weight; fn first_evaluation() -> Weight; - fn second_to_limit_evaluation(x: u32) -> Weight; + fn second_to_limit_evaluation(x: u32, ) -> Weight; fn evaluation_over_limit() -> Weight; - - fn bid_with_ct_deposit(y: u32) -> Weight; - fn bid_no_ct_deposit(x: u32, y: u32) -> Weight; - + fn bid_with_ct_deposit(y: u32, ) -> Weight; + fn bid_no_ct_deposit(x: u32, y: u32, ) -> Weight; fn first_contribution_with_ct_deposit() -> Weight; fn first_contribution_no_ct_deposit() -> Weight; fn first_contribution_ends_round_with_ct_deposit(y: u32, z: u32, ) -> Weight; @@ -71,423 +66,1540 @@ pub trait WeightInfo { fn second_to_limit_contribution(x: u32, ) -> Weight; fn second_to_limit_contribution_ends_round(x: u32, y: u32, z: u32, ) -> Weight; fn contribution_over_limit() -> Weight; - - fn evaluation_unbond_for() -> Weight; - fn evaluation_reward_payout_for_with_ct_account_creation() -> Weight; fn evaluation_reward_payout_for_no_ct_account_creation() -> Weight; - fn evaluation_slash_for() -> Weight; fn bid_ct_mint_for_with_ct_account_creation() -> Weight; fn bid_ct_mint_for_no_ct_account_creation() -> Weight; - - fn contribution_ct_mint_for_with_ct_account_creation() -> Weight; fn contribution_ct_mint_for_no_ct_account_creation() -> Weight; fn start_bid_vesting_schedule_for() -> Weight; fn start_contribution_vesting_schedule_for() -> Weight; fn payout_bid_funds_for() -> Weight; fn payout_contribution_funds_for() -> Weight; - fn decide_project_outcome(x: u32, y:u32) -> Weight; + fn decide_project_outcome(x: u32, y: u32, ) -> Weight; fn release_bid_funds_for() -> Weight; - fn bid_unbond_for() -> Weight; fn release_contribution_funds_for() -> Weight; + fn bid_unbond_for() -> Weight; fn contribution_unbond_for() -> Weight; } -/// Weights for pallet_funding using the Substrate node and recommended hardware. +/// Weights for `pallet_funding` using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - /// Storage: PolimecFunding NextProjectId (r:1 w:1) - /// Proof Skipped: PolimecFunding NextProjectId (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: PolimecFunding Images (r:1 w:1) - /// Proof Skipped: PolimecFunding Images (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding ProjectsMetadata (r:0 w:1) - /// Proof Skipped: PolimecFunding ProjectsMetadata (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding ProjectsDetails (r:0 w:1) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) + /// Storage: `PolimecFunding::NextProjectId` (r:1 w:1) + /// Proof: `PolimecFunding::NextProjectId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Images` (r:1 w:1) + /// Proof: `PolimecFunding::Images` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:0 w:1) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:0 w:1) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:0 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) fn create() -> Weight { // Proof Size summary in bytes: - // Measured: `6` - // Estimated: `3471` - // Minimum execution time: 16_000_000 picoseconds. - Weight::from_parts(17_000_000, 3471) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) + // Measured: `161` + // Estimated: `3593` + // Minimum execution time: 60_000_000 picoseconds. + Weight::from_parts(62_000_000, 3593) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) } - /// Storage: PolimecFunding ProjectsMetadata (r:1 w:1) - /// Proof Skipped: PolimecFunding ProjectsMetadata (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding ProjectsDetails (r:1 w:0) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding Images (r:1 w:0) - /// Proof Skipped: PolimecFunding Images (max_values: None, max_size: None, mode: Measured) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Images` (r:1 w:0) + /// Proof: `PolimecFunding::Images` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) fn edit_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `536` - // Estimated: `4001` + // Measured: `609` + // Estimated: `3814` // Minimum execution time: 18_000_000 picoseconds. - Weight::from_parts(18_000_000, 4001) + Weight::from_parts(19_000_000, 3814) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } - /// Storage: PolimecFunding ProjectsMetadata (r:1 w:0) - /// Proof Skipped: PolimecFunding ProjectsMetadata (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding ProjectsDetails (r:1 w:1) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding ProjectsToUpdate (r:1 w:1) - /// Proof Skipped: PolimecFunding ProjectsToUpdate (max_values: None, max_size: None, mode: Measured) - fn start_evaluation(_x: u32) -> Weight { - // Proof Size summary in bytes: - // Measured: `467` - // Estimated: `3932` - // Minimum execution time: 19_000_000 picoseconds. - Weight::from_parts(20_000_000, 3932) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_evaluation(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `563 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 22_000_000 picoseconds. + Weight::from_parts(19_253_978, 4087) + // Standard Error: 15_066 + .saturating_add(Weight::from_parts(2_633_080, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) } - fn start_auction_manually(_x: u32, _y: u32) -> Weight { - Zero::zero() + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:4558 w:2) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + /// The range of component `y` is `[1, 10000]`. + fn start_auction_manually(x: u32, y: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + x * (1281 ±0) + y * (21 ±0)` + // Estimated: `268395 + x * (9966 ±8_383) + y * (1212 ±82)` + // Minimum execution time: 397_000_000 picoseconds. + Weight::from_parts(420_000_000, 268395) + // Standard Error: 4_704_303 + .saturating_add(Weight::from_parts(12_350_427, 0).saturating_mul(x.into())) + // Standard Error: 46_630 + .saturating_add(Weight::from_parts(1_402_043, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(87_u64)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_parts(0, 9966).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 1212).saturating_mul(y.into())) } - - fn start_auction_automatically() -> Weight { - Zero::zero() + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_auction_automatically(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `411 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 20_000_000 picoseconds. + Weight::from_parts(20_242_112, 4087) + // Standard Error: 18_140 + .saturating_add(Weight::from_parts(2_666_357, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) } - + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) + /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) fn first_evaluation() -> Weight { - Weight::from_parts(20_000_000, 3932) } - - fn second_to_limit_evaluation(_x: u32) -> Weight { - Weight::from_parts(20_000_000, 3932) } - + // Proof Size summary in bytes: + // Measured: `676` + // Estimated: `4614` + // Minimum execution time: 92_000_000 picoseconds. + Weight::from_parts(94_000_000, 4614) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) + /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:256 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 255]`. + fn second_to_limit_evaluation(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `893 + x * (137 ±0)` + // Estimated: `4614 + x * (2820 ±0)` + // Minimum execution time: 71_000_000 picoseconds. + Weight::from_parts(58_910_334, 4614) + // Standard Error: 11_575 + .saturating_add(Weight::from_parts(3_780_894, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(4_u64)) + .saturating_add(Weight::from_parts(0, 2820).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) + /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:257 w:2) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) fn evaluation_over_limit() -> Weight { - Weight::from_parts(20_000_000, 3932) } - - /// Storage: PolimecFunding ProjectsMetadata (r:1 w:0) - /// Proof Skipped: PolimecFunding ProjectsMetadata (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding ProjectsDetails (r:1 w:0) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding NextBidId (r:1 w:1) - /// Proof Skipped: PolimecFunding NextBidId (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: PolimecFunding Bids (r:1 w:1) - /// Proof Skipped: PolimecFunding Bids (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding Evaluations (r:1 w:0) - /// Proof Skipped: PolimecFunding Evaluations (max_values: None, max_size: None, mode: Measured) - /// Storage: Balances Holds (r:1 w:1) - /// Proof: Balances Holds (max_values: None, max_size: Some(1099), added: 3574, mode: MaxEncodedLen) - /// Storage: StatemintAssets Asset (r:1 w:1) - /// Proof: StatemintAssets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) - /// Storage: StatemintAssets Account (r:2 w:2) - /// Proof: StatemintAssets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn bid_with_ct_deposit(_y: u32) -> Weight { - Weight::from_parts(140_000_000, 6208) + // Proof Size summary in bytes: + // Measured: `36120` + // Estimated: `725730` + // Minimum execution time: 1_017_000_000 picoseconds. + Weight::from_parts(1_051_000_000, 725730) + .saturating_add(T::DbWeight::get().reads(261_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) } - - fn bid_no_ct_deposit(_x: u32, _y: u32) -> Weight { - Weight::from_parts(140_000_000, 6208) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:10) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:1 w:1) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextBidId` (r:1 w:1) + /// Proof: `PolimecFunding::NextBidId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// The range of component `y` is `[0, 10]`. + fn bid_with_ct_deposit(y: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2140` + // Estimated: `6208` + // Minimum execution time: 143_000_000 picoseconds. + Weight::from_parts(106_855_955, 6208) + // Standard Error: 319_819 + .saturating_add(Weight::from_parts(70_108_416, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(12_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) } - - fn first_contribution_no_ct_deposit() -> Weight { - Weight::from_parts(140_000_000, 6208) - + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:256 w:10) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:1 w:1) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextBidId` (r:1 w:1) + /// Proof: `PolimecFunding::NextBidId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// The range of component `x` is `[0, 255]`. + /// The range of component `y` is `[0, 10]`. + fn bid_no_ct_deposit(x: u32, y: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2227 + x * (164 ±0)` + // Estimated: `6208 + x * (2893 ±0)` + // Minimum execution time: 760_000_000 picoseconds. + Weight::from_parts(69_652_890, 6208) + // Standard Error: 11_684 + .saturating_add(Weight::from_parts(4_020_612, 0).saturating_mul(x.into())) + // Standard Error: 283_589 + .saturating_add(Weight::from_parts(72_460_034, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(12_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(6_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) + .saturating_add(Weight::from_parts(0, 2893).saturating_mul(x.into())) } - + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn first_contribution_with_ct_deposit() -> Weight { - Weight::from_parts(140_000_000, 6208) - + // Proof Size summary in bytes: + // Measured: `1996` + // Estimated: `6208` + // Minimum execution time: 147_000_000 picoseconds. + Weight::from_parts(155_000_000, 6208) + .saturating_add(T::DbWeight::get().reads(11_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) } - - fn first_contribution_ends_round_no_ct_deposit(_y: u32, _z: u32) -> Weight { - Weight::from_parts(140_000_000, 6208) - + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn first_contribution_no_ct_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `2073` + // Estimated: `6208` + // Minimum execution time: 119_000_000 picoseconds. + Weight::from_parts(126_000_000, 6208) + .saturating_add(T::DbWeight::get().reads(11_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) } - fn first_contribution_ends_round_with_ct_deposit(_y: u32, _z: u32) -> Weight { - Weight::from_parts(140_000_000, 6208) - + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9832 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `y` is `[1, 99]`. + /// The range of component `z` is `[1, 10000]`. + fn first_contribution_ends_round_with_ct_deposit(y: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + y * (443 ±0) + z * (37 ±0)` + // Estimated: `78415 + y * (14240 ±4_378) + z * (1371 ±43)` + // Minimum execution time: 264_000_000 picoseconds. + Weight::from_parts(268_000_000, 78415) + // Standard Error: 5_143_014 + .saturating_add(Weight::from_parts(16_318_492, 0).saturating_mul(y.into())) + // Standard Error: 50_979 + .saturating_add(Weight::from_parts(1_601_983, 0).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(36_u64)) + .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(y.into()))) + .saturating_add(T::DbWeight::get().writes(8_u64)) + .saturating_add(Weight::from_parts(0, 14240).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 1371).saturating_mul(z.into())) } - - fn second_to_limit_contribution(_x: u32) -> Weight { - Weight::from_parts(140_000_000, 6208) - + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9832 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `y` is `[1, 99]`. + /// The range of component `z` is `[1, 10000]`. + fn first_contribution_ends_round_no_ct_deposit(y: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + y * (443 ±0) + z * (37 ±0)` + // Estimated: `78415 + y * (14240 ±4_378) + z * (1371 ±43)` + // Minimum execution time: 226_000_000 picoseconds. + Weight::from_parts(239_000_000, 78415) + // Standard Error: 5_135_841 + .saturating_add(Weight::from_parts(15_722_813, 0).saturating_mul(y.into())) + // Standard Error: 50_908 + .saturating_add(Weight::from_parts(1_606_667, 0).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(36_u64)) + .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(y.into()))) + .saturating_add(T::DbWeight::get().writes(8_u64)) + .saturating_add(Weight::from_parts(0, 14240).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 1371).saturating_mul(z.into())) } - - fn second_to_limit_contribution_ends_round(_x: u32, _y: u32, _z: u32) -> Weight { - Weight::from_parts(140_000_000, 6208) - + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:256 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 255]`. + fn second_to_limit_contribution(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2213 + x * (137 ±0)` + // Estimated: `6208 + x * (2839 ±0)` + // Minimum execution time: 124_000_000 picoseconds. + Weight::from_parts(117_868_102, 6208) + // Standard Error: 10_026 + .saturating_add(Weight::from_parts(3_746_658, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(11_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(7_u64)) + .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) } - + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:256 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9832 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 255]`. + /// The range of component `y` is `[1, 99]`. + /// The range of component `z` is `[1, 10000]`. + fn second_to_limit_contribution_ends_round(x: u32, y: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `75282 + x * (137 ±0) + y * (723 ±0) + z * (39 ±0)` + // Estimated: `17232 + x * (2839 ±0) + y * (115061 ±7_565) + z * (2358 ±74)` + // Minimum execution time: 1_097_000_000 picoseconds. + Weight::from_parts(554_228_738, 17232) + // Standard Error: 8_861_727 + .saturating_add(Weight::from_parts(133_771_367, 0).saturating_mul(y.into())) + // Standard Error: 86_849 + .saturating_add(Weight::from_parts(2_763_795, 0).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(16_u64)) + .saturating_add(T::DbWeight::get().reads((37_u64).saturating_mul(y.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(z.into()))) + .saturating_add(T::DbWeight::get().writes(8_u64)) + .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 115061).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 2358).saturating_mul(z.into())) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:257 w:2) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) fn contribution_over_limit() -> Weight { - Weight::from_parts(140_000_000, 6208) - + // Proof Size summary in bytes: + // Measured: `37440` + // Estimated: `730613` + // Minimum execution time: 1_103_000_000 picoseconds. + Weight::from_parts(1_165_000_000, 730613) + .saturating_add(T::DbWeight::get().reads(267_u64)) + .saturating_add(T::DbWeight::get().writes(8_u64)) } - - /// Storage: PolimecFunding ProjectsMetadata (r:1 w:0) - /// Proof Skipped: PolimecFunding ProjectsMetadata (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding ProjectsDetails (r:1 w:1) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding NextContributionId (r:1 w:1) - /// Proof Skipped: PolimecFunding NextContributionId (max_values: Some(1), max_size: None, mode: Measured) - /// Storage: PolimecFunding Contributions (r:1 w:1) - /// Proof Skipped: PolimecFunding Contributions (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding Evaluations (r:1 w:0) - /// Proof Skipped: PolimecFunding Evaluations (max_values: None, max_size: None, mode: Measured) - /// Storage: Balances Holds (r:1 w:1) - /// Proof: Balances Holds (max_values: None, max_size: Some(1099), added: 3574, mode: MaxEncodedLen) - /// Storage: StatemintAssets Asset (r:1 w:1) - /// Proof: StatemintAssets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) - /// Storage: StatemintAssets Account (r:2 w:2) - /// Proof: StatemintAssets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) - - /// Storage: PolimecFunding ProjectsDetails (r:1 w:0) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding Evaluations (r:1 w:1) - /// Proof Skipped: PolimecFunding Evaluations (max_values: None, max_size: None, mode: Measured) - /// Storage: Balances Holds (r:1 w:1) - /// Proof: Balances Holds (max_values: None, max_size: Some(1099), added: 3574, mode: MaxEncodedLen) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) fn evaluation_unbond_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1303` - // Estimated: `4768` - // Minimum execution time: 60_000_000 picoseconds. - Weight::from_parts(65_000_000, 4768) + // Measured: `1411` + // Estimated: `4614` + // Minimum execution time: 55_000_000 picoseconds. + Weight::from_parts(60_000_000, 4614) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } - /// Storage: PolimecFunding ProjectsDetails (r:1 w:0) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding Evaluations (r:2 w:1) - /// Proof Skipped: PolimecFunding Evaluations (max_values: None, max_size: None, mode: Measured) - /// Storage: Balances Holds (r:1 w:1) - /// Proof: Balances Holds (max_values: None, max_size: Some(1099), added: 3574, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) - fn evaluation_slash_for() -> Weight { + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + fn evaluation_reward_payout_for_with_ct_account_creation() -> Weight { // Proof Size summary in bytes: - // Measured: `1338` - // Estimated: `7278` - // Minimum execution time: 84_000_000 picoseconds. - Weight::from_parts(94_000_000, 7278) + // Measured: `1515` + // Estimated: `4614` + // Minimum execution time: 92_000_000 picoseconds. + Weight::from_parts(102_000_000, 4614) .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } - /// Storage: PolimecFunding ProjectsDetails (r:1 w:0) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding Evaluations (r:1 w:1) - /// Proof Skipped: PolimecFunding Evaluations (max_values: None, max_size: None, mode: Measured) - /// Storage: LocalAssets Asset (r:1 w:1) - /// Proof: LocalAssets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) - /// Storage: LocalAssets Account (r:1 w:1) - /// Proof: LocalAssets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) - fn evaluation_reward_payout_for_with_ct_account_creation() -> Weight { + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + fn evaluation_reward_payout_for_no_ct_account_creation() -> Weight { // Proof Size summary in bytes: - // Measured: `1245` - // Estimated: `4710` - // Minimum execution time: 63_000_000 picoseconds. - Weight::from_parts(71_000_000, 4710) + // Measured: `1219` + // Estimated: `3814` + // Minimum execution time: 48_000_000 picoseconds. + Weight::from_parts(49_000_000, 3814) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } - fn evaluation_reward_payout_for_no_ct_account_creation() -> Weight { + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn evaluation_slash_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1245` - // Estimated: `4710` - // Minimum execution time: 63_000_000 picoseconds. - Weight::from_parts(71_000_000, 4710) + // Measured: `1419` + // Estimated: `4614` + // Minimum execution time: 68_000_000 picoseconds. + Weight::from_parts(71_000_000, 4614) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } - /// Storage: PolimecFunding Bids (r:1 w:1) - /// Proof Skipped: PolimecFunding Bids (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding ProjectsDetails (r:1 w:0) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) - /// Storage: LocalAssets Asset (r:1 w:1) - /// Proof: LocalAssets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) - /// Storage: LocalAssets Account (r:1 w:1) - /// Proof: LocalAssets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) fn bid_ct_mint_for_with_ct_account_creation() -> Weight { // Proof Size summary in bytes: - // Measured: `1215` - // Estimated: `4680` - // Minimum execution time: 65_000_000 picoseconds. - Weight::from_parts(71_000_000, 4680) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `1629` + // Estimated: `4614` + // Minimum execution time: 96_000_000 picoseconds. + Weight::from_parts(99_000_000, 4614) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } - + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn bid_ct_mint_for_no_ct_account_creation() -> Weight { // Proof Size summary in bytes: - // Measured: `1215` - // Estimated: `4680` - // Minimum execution time: 65_000_000 picoseconds. - Weight::from_parts(71_000_000, 4680) + // Measured: `1180` + // Estimated: `3883` + // Minimum execution time: 44_000_000 picoseconds. + Weight::from_parts(47_000_000, 3883) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) fn contribution_ct_mint_for_with_ct_account_creation() -> Weight { // Proof Size summary in bytes: - // Measured: `1215` - // Estimated: `4680` - // Minimum execution time: 65_000_000 picoseconds. - Weight::from_parts(71_000_000, 4680) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) + // Measured: `1545` + // Estimated: `4614` + // Minimum execution time: 91_000_000 picoseconds. + Weight::from_parts(98_000_000, 4614) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) } + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn contribution_ct_mint_for_no_ct_account_creation() -> Weight { // Proof Size summary in bytes: - // Measured: `1215` - // Estimated: `4680` - // Minimum execution time: 65_000_000 picoseconds. - Weight::from_parts(71_000_000, 4680) + // Measured: `1217` + // Estimated: `3829` + // Minimum execution time: 46_000_000 picoseconds. + Weight::from_parts(50_000_000, 3829) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } - /// Storage: PolimecFunding ProjectsDetails (r:1 w:0) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding Bids (r:1 w:1) - /// Proof Skipped: PolimecFunding Bids (max_values: None, max_size: None, mode: Measured) - /// Storage: Vesting Vesting (r:1 w:1) - /// Proof Skipped: Vesting Vesting (max_values: None, max_size: None, mode: Measured) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `LinearRelease::Vesting` (r:1 w:1) + /// Proof: `LinearRelease::Vesting` (`max_values`: None, `max_size`: None, mode: `Measured`) fn start_bid_vesting_schedule_for() -> Weight { // Proof Size summary in bytes: - // Measured: `870` - // Estimated: `4335` - // Minimum execution time: 44_000_000 picoseconds. - Weight::from_parts(47_000_000, 4335) + // Measured: `818` + // Estimated: `4283` + // Minimum execution time: 29_000_000 picoseconds. + Weight::from_parts(31_000_000, 4283) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } - /// Storage: PolimecFunding ProjectsDetails (r:1 w:0) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding Contributions (r:1 w:1) - /// Proof Skipped: PolimecFunding Contributions (max_values: None, max_size: None, mode: Measured) - /// Storage: Vesting Vesting (r:1 w:1) - /// Proof Skipped: Vesting Vesting (max_values: None, max_size: None, mode: Measured) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `LinearRelease::Vesting` (r:1 w:1) + /// Proof: `LinearRelease::Vesting` (`max_values`: None, `max_size`: None, mode: `Measured`) fn start_contribution_vesting_schedule_for() -> Weight { // Proof Size summary in bytes: - // Measured: `898` - // Estimated: `4363` - // Minimum execution time: 46_000_000 picoseconds. - Weight::from_parts(50_000_000, 4363) + // Measured: `847` + // Estimated: `4312` + // Minimum execution time: 30_000_000 picoseconds. + Weight::from_parts(32_000_000, 4312) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } - /// Storage: PolimecFunding ProjectsDetails (r:1 w:0) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding Bids (r:1 w:1) - /// Proof Skipped: PolimecFunding Bids (max_values: None, max_size: None, mode: Measured) - /// Storage: StatemintAssets Asset (r:1 w:1) - /// Proof: StatemintAssets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) - /// Storage: StatemintAssets Account (r:2 w:2) - /// Proof: StatemintAssets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) fn payout_bid_funds_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1392` + // Measured: `1372` // Estimated: `6208` - // Minimum execution time: 81_000_000 picoseconds. - Weight::from_parts(89_000_000, 6208) + // Minimum execution time: 64_000_000 picoseconds. + Weight::from_parts(69_000_000, 6208) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } - /// Storage: PolimecFunding ProjectsDetails (r:1 w:0) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding Contributions (r:1 w:1) - /// Proof Skipped: PolimecFunding Contributions (max_values: None, max_size: None, mode: Measured) - /// Storage: StatemintAssets Asset (r:1 w:1) - /// Proof: StatemintAssets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) - /// Storage: StatemintAssets Account (r:2 w:2) - /// Proof: StatemintAssets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) - /// Storage: System Account (r:1 w:1) - /// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) fn payout_contribution_funds_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1420` + // Measured: `1401` // Estimated: `6208` - // Minimum execution time: 81_000_000 picoseconds. - Weight::from_parts(89_000_000, 6208) + // Minimum execution time: 69_000_000 picoseconds. + Weight::from_parts(77_000_000, 6208) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } - /// Storage: PolimecFunding ProjectsDetails (r:1 w:0) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding ProjectsToUpdate (r:3 w:2) - /// Proof Skipped: PolimecFunding ProjectsToUpdate (max_values: None, max_size: None, mode: Measured) - fn decide_project_outcome(_x: u32, _y: u32) -> Weight { + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:2980 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + /// The range of component `y` is `[1, 10000]`. + fn decide_project_outcome(x: u32, y: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `515` - // Estimated: `8930` - // Minimum execution time: 27_000_000 picoseconds. - Weight::from_parts(31_000_000, 8930) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) + // Measured: `10254 + x * (419 ±0) + y * (20 ±0)` + // Estimated: `35057 + x * (4876 ±4_177) + y * (1437 ±41)` + // Minimum execution time: 64_000_000 picoseconds. + Weight::from_parts(68_000_000, 35057) + // Standard Error: 4_809_624 + .saturating_add(Weight::from_parts(5_610_465, 0).saturating_mul(x.into())) + // Standard Error: 47_674 + .saturating_add(Weight::from_parts(1_647_468, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(12_u64)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_parts(0, 4876).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 1437).saturating_mul(y.into())) } - /// Storage: PolimecFunding ProjectsDetails (r:1 w:0) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding Bids (r:1 w:1) - /// Proof Skipped: PolimecFunding Bids (max_values: None, max_size: None, mode: Measured) - /// Storage: StatemintAssets Asset (r:1 w:1) - /// Proof: StatemintAssets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) - /// Storage: StatemintAssets Account (r:2 w:2) - /// Proof: StatemintAssets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn release_bid_funds_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1461` + // Measured: `1481` // Estimated: `6208` - // Minimum execution time: 84_000_000 picoseconds. - Weight::from_parts(91_000_000, 6208) + // Minimum execution time: 64_000_000 picoseconds. + Weight::from_parts(71_000_000, 6208) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } - /// Storage: PolimecFunding ProjectsDetails (r:1 w:0) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding Bids (r:1 w:1) - /// Proof Skipped: PolimecFunding Bids (max_values: None, max_size: None, mode: Measured) - /// Storage: Balances Holds (r:1 w:1) - /// Proof: Balances Holds (max_values: None, max_size: Some(1099), added: 3574, mode: MaxEncodedLen) - fn bid_unbond_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `1406` - // Estimated: `4871` - // Minimum execution time: 61_000_000 picoseconds. - Weight::from_parts(68_000_000, 4871) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - } - /// Storage: PolimecFunding ProjectsDetails (r:1 w:0) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding Contributions (r:1 w:1) - /// Proof Skipped: PolimecFunding Contributions (max_values: None, max_size: None, mode: Measured) - /// Storage: StatemintAssets Asset (r:1 w:1) - /// Proof: StatemintAssets Asset (max_values: None, max_size: Some(210), added: 2685, mode: MaxEncodedLen) - /// Storage: StatemintAssets Account (r:2 w:2) - /// Proof: StatemintAssets Account (max_values: None, max_size: Some(134), added: 2609, mode: MaxEncodedLen) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn release_contribution_funds_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1453` + // Measured: `1474` // Estimated: `6208` - // Minimum execution time: 83_000_000 picoseconds. - Weight::from_parts(89_000_000, 6208) + // Minimum execution time: 64_000_000 picoseconds. + Weight::from_parts(70_000_000, 6208) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } - /// Storage: PolimecFunding ProjectsDetails (r:1 w:0) - /// Proof Skipped: PolimecFunding ProjectsDetails (max_values: None, max_size: None, mode: Measured) - /// Storage: PolimecFunding Contributions (r:1 w:1) - /// Proof Skipped: PolimecFunding Contributions (max_values: None, max_size: None, mode: Measured) - /// Storage: Balances Holds (r:1 w:1) - /// Proof: Balances Holds (max_values: None, max_size: Some(1099), added: 3574, mode: MaxEncodedLen) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn bid_unbond_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1486` + // Estimated: `4614` + // Minimum execution time: 52_000_000 picoseconds. + Weight::from_parts(57_000_000, 4614) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) fn contribution_unbond_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1397` - // Estimated: `4862` - // Minimum execution time: 60_000_000 picoseconds. - Weight::from_parts(66_000_000, 4862) + // Measured: `1441` + // Estimated: `4614` + // Minimum execution time: 52_000_000 picoseconds. + Weight::from_parts(57_000_000, 4614) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } +} - +// For backwards compatibility and tests. +impl WeightInfo for () { + /// Storage: `PolimecFunding::NextProjectId` (r:1 w:1) + /// Proof: `PolimecFunding::NextProjectId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Images` (r:1 w:1) + /// Proof: `PolimecFunding::Images` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:0 w:1) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:0 w:1) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:0 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + fn create() -> Weight { + // Proof Size summary in bytes: + // Measured: `161` + // Estimated: `3593` + // Minimum execution time: 60_000_000 picoseconds. + Weight::from_parts(62_000_000, 3593) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Images` (r:1 w:0) + /// Proof: `PolimecFunding::Images` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + fn edit_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `609` + // Estimated: `3814` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_000_000, 3814) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_evaluation(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `563 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 22_000_000 picoseconds. + Weight::from_parts(19_253_978, 4087) + // Standard Error: 15_066 + .saturating_add(Weight::from_parts(2_633_080, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:4558 w:2) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + /// The range of component `y` is `[1, 10000]`. + fn start_auction_manually(x: u32, y: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + x * (1281 ±0) + y * (21 ±0)` + // Estimated: `268395 + x * (9966 ±8_383) + y * (1212 ±82)` + // Minimum execution time: 397_000_000 picoseconds. + Weight::from_parts(420_000_000, 268395) + // Standard Error: 4_704_303 + .saturating_add(Weight::from_parts(12_350_427, 0).saturating_mul(x.into())) + // Standard Error: 46_630 + .saturating_add(Weight::from_parts(1_402_043, 0).saturating_mul(y.into())) + .saturating_add(RocksDbWeight::get().reads(87_u64)) + .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_parts(0, 9966).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 1212).saturating_mul(y.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_auction_automatically(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `411 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 20_000_000 picoseconds. + Weight::from_parts(20_242_112, 4087) + // Standard Error: 18_140 + .saturating_add(Weight::from_parts(2_666_357, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) + /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn first_evaluation() -> Weight { + // Proof Size summary in bytes: + // Measured: `676` + // Estimated: `4614` + // Minimum execution time: 92_000_000 picoseconds. + Weight::from_parts(94_000_000, 4614) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) + /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:256 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 255]`. + fn second_to_limit_evaluation(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `893 + x * (137 ±0)` + // Estimated: `4614 + x * (2820 ±0)` + // Minimum execution time: 71_000_000 picoseconds. + Weight::from_parts(58_910_334, 4614) + // Standard Error: 11_575 + .saturating_add(Weight::from_parts(3_780_894, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + .saturating_add(Weight::from_parts(0, 2820).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) + /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:257 w:2) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn evaluation_over_limit() -> Weight { + // Proof Size summary in bytes: + // Measured: `36120` + // Estimated: `725730` + // Minimum execution time: 1_017_000_000 picoseconds. + Weight::from_parts(1_051_000_000, 725730) + .saturating_add(RocksDbWeight::get().reads(261_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:10) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:1 w:1) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextBidId` (r:1 w:1) + /// Proof: `PolimecFunding::NextBidId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// The range of component `y` is `[0, 10]`. + fn bid_with_ct_deposit(y: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2140` + // Estimated: `6208` + // Minimum execution time: 143_000_000 picoseconds. + Weight::from_parts(106_855_955, 6208) + // Standard Error: 319_819 + .saturating_add(Weight::from_parts(70_108_416, 0).saturating_mul(y.into())) + .saturating_add(RocksDbWeight::get().reads(12_u64)) + .saturating_add(RocksDbWeight::get().writes(7_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(y.into()))) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:256 w:10) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:1 w:1) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextBidId` (r:1 w:1) + /// Proof: `PolimecFunding::NextBidId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// The range of component `x` is `[0, 255]`. + /// The range of component `y` is `[0, 10]`. + fn bid_no_ct_deposit(x: u32, y: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2227 + x * (164 ±0)` + // Estimated: `6208 + x * (2893 ±0)` + // Minimum execution time: 760_000_000 picoseconds. + Weight::from_parts(69_652_890, 6208) + // Standard Error: 11_684 + .saturating_add(Weight::from_parts(4_020_612, 0).saturating_mul(x.into())) + // Standard Error: 283_589 + .saturating_add(Weight::from_parts(72_460_034, 0).saturating_mul(y.into())) + .saturating_add(RocksDbWeight::get().reads(12_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(y.into()))) + .saturating_add(Weight::from_parts(0, 2893).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn first_contribution_with_ct_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `1996` + // Estimated: `6208` + // Minimum execution time: 147_000_000 picoseconds. + Weight::from_parts(155_000_000, 6208) + .saturating_add(RocksDbWeight::get().reads(11_u64)) + .saturating_add(RocksDbWeight::get().writes(7_u64)) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn first_contribution_no_ct_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `2073` + // Estimated: `6208` + // Minimum execution time: 119_000_000 picoseconds. + Weight::from_parts(126_000_000, 6208) + .saturating_add(RocksDbWeight::get().reads(11_u64)) + .saturating_add(RocksDbWeight::get().writes(7_u64)) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9832 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `y` is `[1, 99]`. + /// The range of component `z` is `[1, 10000]`. + fn first_contribution_ends_round_with_ct_deposit(y: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + y * (443 ±0) + z * (37 ±0)` + // Estimated: `78415 + y * (14240 ±4_378) + z * (1371 ±43)` + // Minimum execution time: 264_000_000 picoseconds. + Weight::from_parts(268_000_000, 78415) + // Standard Error: 5_143_014 + .saturating_add(Weight::from_parts(16_318_492, 0).saturating_mul(y.into())) + // Standard Error: 50_979 + .saturating_add(Weight::from_parts(1_601_983, 0).saturating_mul(z.into())) + .saturating_add(RocksDbWeight::get().reads(36_u64)) + .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(y.into()))) + .saturating_add(RocksDbWeight::get().writes(8_u64)) + .saturating_add(Weight::from_parts(0, 14240).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 1371).saturating_mul(z.into())) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9832 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `y` is `[1, 99]`. + /// The range of component `z` is `[1, 10000]`. + fn first_contribution_ends_round_no_ct_deposit(y: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + y * (443 ±0) + z * (37 ±0)` + // Estimated: `78415 + y * (14240 ±4_378) + z * (1371 ±43)` + // Minimum execution time: 226_000_000 picoseconds. + Weight::from_parts(239_000_000, 78415) + // Standard Error: 5_135_841 + .saturating_add(Weight::from_parts(15_722_813, 0).saturating_mul(y.into())) + // Standard Error: 50_908 + .saturating_add(Weight::from_parts(1_606_667, 0).saturating_mul(z.into())) + .saturating_add(RocksDbWeight::get().reads(36_u64)) + .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(y.into()))) + .saturating_add(RocksDbWeight::get().writes(8_u64)) + .saturating_add(Weight::from_parts(0, 14240).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 1371).saturating_mul(z.into())) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:256 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 255]`. + fn second_to_limit_contribution(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2213 + x * (137 ±0)` + // Estimated: `6208 + x * (2839 ±0)` + // Minimum execution time: 124_000_000 picoseconds. + Weight::from_parts(117_868_102, 6208) + // Standard Error: 10_026 + .saturating_add(Weight::from_parts(3_746_658, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(11_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(7_u64)) + .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:256 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9832 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 255]`. + /// The range of component `y` is `[1, 99]`. + /// The range of component `z` is `[1, 10000]`. + fn second_to_limit_contribution_ends_round(x: u32, y: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `75282 + x * (137 ±0) + y * (723 ±0) + z * (39 ±0)` + // Estimated: `17232 + x * (2839 ±0) + y * (115061 ±7_565) + z * (2358 ±74)` + // Minimum execution time: 1_097_000_000 picoseconds. + Weight::from_parts(554_228_738, 17232) + // Standard Error: 8_861_727 + .saturating_add(Weight::from_parts(133_771_367, 0).saturating_mul(y.into())) + // Standard Error: 86_849 + .saturating_add(Weight::from_parts(2_763_795, 0).saturating_mul(z.into())) + .saturating_add(RocksDbWeight::get().reads(16_u64)) + .saturating_add(RocksDbWeight::get().reads((37_u64).saturating_mul(y.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(z.into()))) + .saturating_add(RocksDbWeight::get().writes(8_u64)) + .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 115061).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 2358).saturating_mul(z.into())) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:257 w:2) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + fn contribution_over_limit() -> Weight { + // Proof Size summary in bytes: + // Measured: `37440` + // Estimated: `730613` + // Minimum execution time: 1_103_000_000 picoseconds. + Weight::from_parts(1_165_000_000, 730613) + .saturating_add(RocksDbWeight::get().reads(267_u64)) + .saturating_add(RocksDbWeight::get().writes(8_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn evaluation_unbond_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1411` + // Estimated: `4614` + // Minimum execution time: 55_000_000 picoseconds. + Weight::from_parts(60_000_000, 4614) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + fn evaluation_reward_payout_for_with_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1515` + // Estimated: `4614` + // Minimum execution time: 92_000_000 picoseconds. + Weight::from_parts(102_000_000, 4614) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + fn evaluation_reward_payout_for_no_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1219` + // Estimated: `3814` + // Minimum execution time: 48_000_000 picoseconds. + Weight::from_parts(49_000_000, 3814) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn evaluation_slash_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1419` + // Estimated: `4614` + // Minimum execution time: 68_000_000 picoseconds. + Weight::from_parts(71_000_000, 4614) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn bid_ct_mint_for_with_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1629` + // Estimated: `4614` + // Minimum execution time: 96_000_000 picoseconds. + Weight::from_parts(99_000_000, 4614) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn bid_ct_mint_for_no_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1180` + // Estimated: `3883` + // Minimum execution time: 44_000_000 picoseconds. + Weight::from_parts(47_000_000, 3883) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn contribution_ct_mint_for_with_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1545` + // Estimated: `4614` + // Minimum execution time: 91_000_000 picoseconds. + Weight::from_parts(98_000_000, 4614) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn contribution_ct_mint_for_no_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1217` + // Estimated: `3829` + // Minimum execution time: 46_000_000 picoseconds. + Weight::from_parts(50_000_000, 3829) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `LinearRelease::Vesting` (r:1 w:1) + /// Proof: `LinearRelease::Vesting` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn start_bid_vesting_schedule_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `818` + // Estimated: `4283` + // Minimum execution time: 29_000_000 picoseconds. + Weight::from_parts(31_000_000, 4283) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `LinearRelease::Vesting` (r:1 w:1) + /// Proof: `LinearRelease::Vesting` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn start_contribution_vesting_schedule_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `847` + // Estimated: `4312` + // Minimum execution time: 30_000_000 picoseconds. + Weight::from_parts(32_000_000, 4312) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn payout_bid_funds_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1372` + // Estimated: `6208` + // Minimum execution time: 64_000_000 picoseconds. + Weight::from_parts(69_000_000, 6208) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn payout_contribution_funds_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1401` + // Estimated: `6208` + // Minimum execution time: 69_000_000 picoseconds. + Weight::from_parts(77_000_000, 6208) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:2980 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + /// The range of component `y` is `[1, 10000]`. + fn decide_project_outcome(x: u32, y: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `10254 + x * (419 ±0) + y * (20 ±0)` + // Estimated: `35057 + x * (4876 ±4_177) + y * (1437 ±41)` + // Minimum execution time: 64_000_000 picoseconds. + Weight::from_parts(68_000_000, 35057) + // Standard Error: 4_809_624 + .saturating_add(Weight::from_parts(5_610_465, 0).saturating_mul(x.into())) + // Standard Error: 47_674 + .saturating_add(Weight::from_parts(1_647_468, 0).saturating_mul(y.into())) + .saturating_add(RocksDbWeight::get().reads(12_u64)) + .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_parts(0, 4876).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 1437).saturating_mul(y.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn release_bid_funds_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1481` + // Estimated: `6208` + // Minimum execution time: 64_000_000 picoseconds. + Weight::from_parts(71_000_000, 6208) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn release_contribution_funds_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1474` + // Estimated: `6208` + // Minimum execution time: 64_000_000 picoseconds. + Weight::from_parts(70_000_000, 6208) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn bid_unbond_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1486` + // Estimated: `4614` + // Minimum execution time: 52_000_000 picoseconds. + Weight::from_parts(57_000_000, 4614) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn contribution_unbond_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1441` + // Estimated: `4614` + // Minimum execution time: 52_000_000 picoseconds. + Weight::from_parts(57_000_000, 4614) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } } \ No newline at end of file From 21c8328ebbdb3571a2983ec6d9666956a333fbb0 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 2 Feb 2024 12:05:17 +0100 Subject: [PATCH 178/212] delete commented out code Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 106 ++++------------------------ 1 file changed, 15 insertions(+), 91 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 5aee12368..a520a54ac 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -302,88 +302,6 @@ where async_features::create_multiple_projects_at(inst, instantiation_details).1 } -// pub fn generate_evaluations(amount: u32) -> Vec> -// where -// ::Balance: From, -// { -// const TARGET_USD: u128 = 107_000u128 * US_DOLLAR; -// let amount_per_participant = TARGET_USD / amount as u128; -// let mut evaluations = Vec::new(); -// for i in 0..amount { -// let evaluator_name: String = format!("evaluator_{}", i); -// let evaluator = string_account::>(evaluator_name, 0, 0); -// evaluations.push(UserToUSDBalance::new(evaluator, (amount_per_participant).into())); -// } -// evaluations -// } -// -// pub fn generate_bids(amount: u32) -> Vec> -// where -// ::Price: From, -// ::Balance: From, -// { -// const TARGET_USD: u128 = 45_000 * US_DOLLAR; -// let amount_per_participant = TARGET_USD / amount as u128; -// let mut bids = Vec::new(); -// for i in 0..amount { -// let bidder_name: String = format!("bidder_{}", i); -// let bidder = string_account::>(bidder_name, 0, 0); -// bids.push(BidParams::new( -// bidder, -// (amount_per_participant).into(), -// 1_u128.into(), -// 1u8, -// AcceptedFundingAsset::USDT, -// )); -// } -// bids -// } -// -// pub fn generate_community_contributions(amount: u32) -> Vec> -// where -// ::Price: From, -// ::Balance: From, -// { -// const TARGET_USD: u128 = 46_000 * US_DOLLAR; -// let amount_per_participant = TARGET_USD / amount as u128; -// let mut contributions = Vec::new(); -// for i in 0..amount { -// let contributor_name: String = format!("contributor_{}", i); -// let contributor = string_account::>(contributor_name, 0, 0); -// contributions.push(ContributionParams::new( -// contributor, -// (amount_per_participant).into(), -// 1u8, -// AcceptedFundingAsset::USDT, -// )); -// } -// contributions -// } - -// pub fn generate_remainder_contributions(amount: u32) -> Vec> -// where -// ::Price: From, -// ::Balance: From, -// { -// const TARGET_USD: u128 = 100 * US_DOLLAR; -// let amount_per_participant = TARGET_USD / amount as u128; -// let mut contributions = Vec::new(); -// let mut user_kind = vec!["evaluator", "bidder", "contributor"].into_iter().cycle(); -// let mut counters = vec![0, 0, 0]; -// for i in 0..amount { -// let kind = user_kind.next().unwrap(); -// let contributor_name: String = match kind {}; -// let contributor = string_account::>(contributor_name, 0, 0); -// contributions.push(ContributionParams::new( -// contributor, -// (amount_per_participant).into(), -// 1u8, -// AcceptedFundingAsset::USDT, -// )); -// } -// contributions -// } - // IMPORTANT: make sure your project starts at (block 1 + `total_vecs_in_storage` - `fully_filled_vecs_from_insertion`) to always have room to insert new vecs pub fn fill_projects_to_update( fully_filled_vecs_from_insertion: u32, @@ -1108,13 +1026,14 @@ mod benchmarks { ); } } - // branches: - // - ct account deposit - // - amount of times where `perform_bid` is called (i.e how many buckets) + #[benchmark] - fn bid_with_ct_deposit(y: Linear<0, 10>) { - // if x were > 0, then the ct deposit would already be paid - let x = 0; + fn bid_no_ct_deposit( + // amount of already made bids by the same user + x: Linear<0, { T::MaxBidsPerUser::get() - 1 }>, + // amount of times where `perform_bid` is called (i.e how many buckets) + y: Linear<0, 10>, + ) { let ( inst, project_id, @@ -1129,6 +1048,8 @@ mod benchmarks { total_usdt_locked, ) = bid_setup::(x, y); + let _new_plmc_minted = make_ct_deposit_for::(original_extrinsic_bid.bidder.clone(), project_id); + #[extrinsic_call] bid( RawOrigin::Signed(original_extrinsic_bid.bidder.clone()), @@ -1153,7 +1074,12 @@ mod benchmarks { } #[benchmark] - fn bid_no_ct_deposit(x: Linear<0, { T::MaxBidsPerUser::get() - 1 }>, y: Linear<0, 10>) { + fn bid_with_ct_deposit( + // amount of times where `perform_bid` is called (i.e how many buckets) + y: Linear<0, 10>, + ) { + // if x were > 0, then the ct deposit would already be paid + let x = 0; let ( inst, project_id, @@ -1168,8 +1094,6 @@ mod benchmarks { total_usdt_locked, ) = bid_setup::(x, y); - let _new_plmc_minted = make_ct_deposit_for::(original_extrinsic_bid.bidder.clone(), project_id); - #[extrinsic_call] bid( RawOrigin::Signed(original_extrinsic_bid.bidder.clone()), From 04728d194d03cf94a9733f621ce9f3050baf68b0 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 2 Feb 2024 13:33:11 +0100 Subject: [PATCH 179/212] weight returns testing possible :) `start_evaluation` test done Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/functions.rs | 4 +-- pallets/funding/src/mock.rs | 5 ++-- pallets/funding/src/tests.rs | 44 ++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index b186041e9..b3cab44c7 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -403,7 +403,7 @@ impl Pallet { return Err(DispatchErrorWithPostInfo { post_info: PostDispatchInfo { actual_weight: if remove_attempts == 0u32 { - Some(WeightInfoOf::::start_auction_automatically()) + Some(WeightInfoOf::::start_auction_automatically(insertion_attempts)) } else { Some(WeightInfoOf::::start_auction_manually(insertion_attempts, remove_attempts)) }, @@ -418,7 +418,7 @@ impl Pallet { Ok(PostDispatchInfo { actual_weight: if remove_attempts == 0u32 { - Some(WeightInfoOf::::start_auction_automatically()) + Some(WeightInfoOf::::start_auction_automatically(insertion_attempts)) } else { Some(WeightInfoOf::::start_auction_manually(insertion_attempts, remove_attempts)) }, diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 6a2f4f712..3265e8608 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -350,14 +350,13 @@ impl Config for TestRuntime { type FeeBrackets = FeeBrackets; type FundingCurrency = StatemintAssets; type ManualAcceptanceDuration = ManualAcceptanceDuration; - // Low value to simplify the tests type MaxBidsPerUser = ConstU32<4>; type MaxCapacityThresholds = MaxCapacityThresholds; type MaxContributionsPerUser = ConstU32<4>; type MaxEvaluationsPerUser = ConstU32<4>; type MaxMessageSizeThresholds = MaxMessageSizeThresholds; - type MaxProjectsToUpdateInsertionAttempts = ConstU32<100>; - type MaxProjectsToUpdatePerBlock = ConstU32<100>; + type MaxProjectsToUpdateInsertionAttempts = ConstU32<10>; + type MaxProjectsToUpdatePerBlock = ConstU32<5>; type Multiplier = Multiplier; type NativeCurrency = Balances; type PalletId = FundingPalletId; diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 9993766ce..98388e3b0 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -6204,3 +6204,47 @@ mod async_tests { assert_eq!(inst.get_project_details(0).status, ProjectStatus::FundingSuccessful); } } + +// Want to make sure the correct weights are returned depending on the logic path and complexity params +// We only test extrinsics that return `DispatchResultWithPostInfo` +mod benchmark_tests { + use super::*; + + // test that it returns higher weight if it has to try more times to insert the project into the `ProjectsToUpdate` storage + #[test] + fn start_evaluation() { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + + let max_project_per_block: u32 = ::MaxProjectsToUpdatePerBlock::get(); + + let project_1 = inst.create_new_project(knowledge_hub_project(inst.get_new_nonce()), ISSUER); + let weight_1 = inst + .execute(|| { + crate::Pallet::::start_evaluation(RuntimeOrigin::signed(ISSUER), project_1).unwrap() + }) + .actual_weight + .unwrap(); + dbg!(weight_1); + + // fill the `ProjectsToUpdate` storage for this block + for _ in 0..max_project_per_block { + let project_id = inst.create_new_project(knowledge_hub_project(inst.get_new_nonce()), ISSUER); + inst.execute(|| { + crate::Pallet::::start_evaluation(RuntimeOrigin::signed(ISSUER), project_id).unwrap() + }); + } + + let project_2 = inst.create_new_project(knowledge_hub_project(inst.get_new_nonce()), ISSUER); + let weight_2 = inst + .execute(|| { + crate::Pallet::::start_evaluation(RuntimeOrigin::signed(ISSUER), project_2).unwrap() + }) + .actual_weight + .unwrap(); + dbg!(weight_2); + + assert!(weight_2.all_gt(weight_1)); + assert_eq!(weight_1, ::WeightInfo::start_evaluation(1)); + assert_eq!(weight_2, ::WeightInfo::start_evaluation(2)); + } +} From fc3042148bcbe38d23e16206bceb5cc7c61f5450 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 2 Feb 2024 15:07:26 +0100 Subject: [PATCH 180/212] removed benchmark tests. we think they are not necessary Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/tests.rs | 44 ------------------------------------ 1 file changed, 44 deletions(-) diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 98388e3b0..9993766ce 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -6204,47 +6204,3 @@ mod async_tests { assert_eq!(inst.get_project_details(0).status, ProjectStatus::FundingSuccessful); } } - -// Want to make sure the correct weights are returned depending on the logic path and complexity params -// We only test extrinsics that return `DispatchResultWithPostInfo` -mod benchmark_tests { - use super::*; - - // test that it returns higher weight if it has to try more times to insert the project into the `ProjectsToUpdate` storage - #[test] - fn start_evaluation() { - let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - - let max_project_per_block: u32 = ::MaxProjectsToUpdatePerBlock::get(); - - let project_1 = inst.create_new_project(knowledge_hub_project(inst.get_new_nonce()), ISSUER); - let weight_1 = inst - .execute(|| { - crate::Pallet::::start_evaluation(RuntimeOrigin::signed(ISSUER), project_1).unwrap() - }) - .actual_weight - .unwrap(); - dbg!(weight_1); - - // fill the `ProjectsToUpdate` storage for this block - for _ in 0..max_project_per_block { - let project_id = inst.create_new_project(knowledge_hub_project(inst.get_new_nonce()), ISSUER); - inst.execute(|| { - crate::Pallet::::start_evaluation(RuntimeOrigin::signed(ISSUER), project_id).unwrap() - }); - } - - let project_2 = inst.create_new_project(knowledge_hub_project(inst.get_new_nonce()), ISSUER); - let weight_2 = inst - .execute(|| { - crate::Pallet::::start_evaluation(RuntimeOrigin::signed(ISSUER), project_2).unwrap() - }) - .actual_weight - .unwrap(); - dbg!(weight_2); - - assert!(weight_2.all_gt(weight_1)); - assert_eq!(weight_1, ::WeightInfo::start_evaluation(1)); - assert_eq!(weight_2, ::WeightInfo::start_evaluation(2)); - } -} From 5c422cc2d01148f3b43ff023ee6b3f8b72bb5674 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 5 Feb 2024 10:50:57 +0100 Subject: [PATCH 181/212] evaluation end both logic paths written Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 309 ++++++++++++++++++++++------ 1 file changed, 243 insertions(+), 66 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index a520a54ac..c56c24d81 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -366,6 +366,9 @@ mod benchmarks { impl_benchmark_test_suite!(PalletFunding, crate::mock::new_test_ext(), crate::mock::TestRuntime); + // + // Extrinsics + // #[benchmark] fn create() { // * setup * @@ -534,69 +537,6 @@ mod benchmarks { ); } - #[benchmark] - fn start_auction_automatically( - // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the extrinsic pass - x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, - // No `y` param because we don't need to remove the automatic transition from storage - ) { - // * setup * - let mut inst = BenchInstantiator::::new(None); - - // real benchmark starts at block 0, and we can't call `events()` at block 0 - inst.advance_time(1u32.into()).unwrap(); - - let issuer = account::>("issuer", 0, 0); - whitelist_account!(issuer); - - let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); - let project_id = inst.create_evaluating_project(project_metadata, issuer.clone()); - - let evaluations = default_evaluations(); - let plmc_for_evaluating = BenchInstantiator::::calculate_evaluation_plmc_spent(evaluations.clone()); - let existential_plmc: Vec> = plmc_for_evaluating.accounts().existential_deposits(); - let ct_account_deposits: Vec> = plmc_for_evaluating.accounts().ct_account_deposits(); - - inst.mint_plmc_to(existential_plmc); - inst.mint_plmc_to(ct_account_deposits); - inst.mint_plmc_to(plmc_for_evaluating); - - inst.advance_time(One::one()).unwrap(); - inst.bond_for_users(project_id, evaluations).expect("All evaluations are accepted"); - - inst.advance_time(::EvaluationDuration::get() + One::one()).unwrap(); - - let current_block = inst.current_block(); - let automatic_transition_block = - current_block + ::AuctionInitializePeriodDuration::get() + One::one(); - let insertion_block_number: BlockNumberFor = - automatic_transition_block + T::EnglishAuctionDuration::get() + One::one(); - let block_number = insertion_block_number; - - fill_projects_to_update::(x, block_number, None); - - let now = inst.current_block(); - inst.advance_time(automatic_transition_block - now - One::one()).unwrap(); - let now = inst.current_block(); - // we don't use advance time to avoid triggering on_initialize. This benchmark should only measure the extrinsic - // weight and not the whole on_initialize call weight - frame_system::Pallet::::set_block_number(now + One::one()); - - #[extrinsic_call] - start_auction(RawOrigin::Signed(issuer), project_id); - - // * validity checks * - // Storage - let stored_details = ProjectsDetails::::get(project_id).unwrap(); - assert_eq!(stored_details.status, ProjectStatus::AuctionRound(AuctionPhase::English)); - - // Events - let current_block = inst.current_block(); - frame_system::Pallet::::assert_last_event( - Event::::EnglishAuctionStarted { project_id, when: current_block.into() }.into(), - ); - } - // possible branches: // - pays ct account deposit // - we know this happens only if param x = 0, but we cannot fit it in the linear regression @@ -2465,7 +2405,7 @@ mod benchmarks { } #[benchmark] - fn decide_project_outcome( + fn decide_project_outcome_manually( // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the extrinsic pass x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, // Total amount of storage items iterated through in `ProjectsToUpdate` when trying to remove our project in `remove_from_update_store`. @@ -2835,6 +2775,228 @@ mod benchmarks { ); } + // + // on_initialize + // + + //do_evaluation_end + #[benchmark] + fn end_evaluation_success( + // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the fn succeed + x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, + ) { + // * setup * + let mut inst = BenchInstantiator::::new(None); + + // real benchmark starts at block 0, and we can't call `events()` at block 0 + inst.advance_time(1u32.into()).unwrap(); + + let issuer = account::>("issuer", 0, 0); + whitelist_account!(issuer); + + let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); + let project_id = inst.create_evaluating_project(project_metadata, issuer.clone()); + + let evaluations = default_evaluations(); + let plmc_for_evaluating = BenchInstantiator::::calculate_evaluation_plmc_spent(evaluations.clone()); + let existential_plmc: Vec> = plmc_for_evaluating.accounts().existential_deposits(); + let ct_account_deposits: Vec> = plmc_for_evaluating.accounts().ct_account_deposits(); + + inst.mint_plmc_to(existential_plmc); + inst.mint_plmc_to(ct_account_deposits); + inst.mint_plmc_to(plmc_for_evaluating); + + inst.advance_time(One::one()).unwrap(); + inst.bond_for_users(project_id, evaluations).expect("All evaluations are accepted"); + + let evaluation_end_block = + inst.get_project_details(project_id).phase_transition_points.evaluation.end().unwrap(); + // move block manually without calling any hooks, to avoid triggering the transition outside the benchmarking context + frame_system::Pallet::::set_block_number(evaluation_end_block + One::one()); + + let insertion_block_number = + inst.current_block() + One::one() + ::AuctionInitializePeriodDuration::get(); + fill_projects_to_update::(x, insertion_block_number, None); + + // Instead of advancing in time for the automatic `do_evaluation_end` call in on_initialize, we call it directly to benchmark it + #[block] + { + Pallet::::do_evaluation_end(project_id); + } + + // * validity checks * + let project_details = inst.get_project_details(project_id); + assert_eq!(project_details.status, ProjectStatus::AuctionInitializePeriod); + } + + #[benchmark] + fn end_evaluation_failure() { + // * setup * + let mut inst = BenchInstantiator::::new(None); + + // real benchmark starts at block 0, and we can't call `events()` at block 0 + inst.advance_time(1u32.into()).unwrap(); + + let issuer = account::>("issuer", 0, 0); + whitelist_account!(issuer); + + let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); + let project_id = inst.create_evaluating_project(project_metadata, issuer.clone()); + let project_details = inst.get_project_details(project_id); + + let evaluation_usd_target = + ::EvaluationSuccessThreshold::get() * project_details.fundraising_target; + // we only fund 50% of the minimum threshold for the evaluation round, since we want it to fail + let evaluations = vec![ + UserToUSDBalance::new( + account::>("evaluator_1", 0, 0), + (Percent::from_percent(5) * evaluation_usd_target).into(), + ), + UserToUSDBalance::new( + account::>("evaluator_2", 0, 0), + (Percent::from_percent(20) * evaluation_usd_target).into(), + ), + UserToUSDBalance::new( + account::>("evaluator_3", 0, 0), + (Percent::from_percent(25) * evaluation_usd_target).into(), + ), + ]; + let plmc_for_evaluating = BenchInstantiator::::calculate_evaluation_plmc_spent(evaluations.clone()); + let existential_plmc: Vec> = plmc_for_evaluating.accounts().existential_deposits(); + let ct_account_deposits: Vec> = plmc_for_evaluating.accounts().ct_account_deposits(); + + inst.mint_plmc_to(existential_plmc); + inst.mint_plmc_to(ct_account_deposits); + inst.mint_plmc_to(plmc_for_evaluating); + + inst.advance_time(One::one()).unwrap(); + inst.bond_for_users(project_id, evaluations).expect("All evaluations are accepted"); + + let evaluation_end_block = + inst.get_project_details(project_id).phase_transition_points.evaluation.end().unwrap(); + // move block manually without calling any hooks, to avoid triggering the transition outside the benchmarking context + frame_system::Pallet::::set_block_number(evaluation_end_block + One::one()); + + let insertion_block_number = + inst.current_block() + One::one() + ::AuctionInitializePeriodDuration::get(); + + // Instead of advancing in time for the automatic `do_evaluation_end` call in on_initialize, we call it directly to benchmark it + #[block] + { + Pallet::::do_evaluation_end(project_id); + } + + // * validity checks * + let project_details = inst.get_project_details(project_id); + assert_eq!(project_details.status, ProjectStatus::EvaluationFailed); + } + + //do_english_auction + #[benchmark] + fn start_auction_automatically( + // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the extrinsic pass + x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, + // No `y` param because we don't need to remove the automatic transition from storage + ) { + // * setup * + let mut inst = BenchInstantiator::::new(None); + + // real benchmark starts at block 0, and we can't call `events()` at block 0 + inst.advance_time(1u32.into()).unwrap(); + + let issuer = account::>("issuer", 0, 0); + whitelist_account!(issuer); + + let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); + let project_id = inst.create_evaluating_project(project_metadata, issuer.clone()); + + let evaluations = default_evaluations(); + let plmc_for_evaluating = BenchInstantiator::::calculate_evaluation_plmc_spent(evaluations.clone()); + let existential_plmc: Vec> = plmc_for_evaluating.accounts().existential_deposits(); + let ct_account_deposits: Vec> = plmc_for_evaluating.accounts().ct_account_deposits(); + + inst.mint_plmc_to(existential_plmc); + inst.mint_plmc_to(ct_account_deposits); + inst.mint_plmc_to(plmc_for_evaluating); + + inst.advance_time(One::one()).unwrap(); + inst.bond_for_users(project_id, evaluations).expect("All evaluations are accepted"); + + inst.advance_time(::EvaluationDuration::get() + One::one()).unwrap(); + + let current_block = inst.current_block(); + let automatic_transition_block = + current_block + ::AuctionInitializePeriodDuration::get() + One::one(); + let insertion_block_number: BlockNumberFor = + automatic_transition_block + T::EnglishAuctionDuration::get() + One::one(); + let block_number = insertion_block_number; + + fill_projects_to_update::(x, block_number, None); + + let now = inst.current_block(); + inst.advance_time(automatic_transition_block - now - One::one()).unwrap(); + let now = inst.current_block(); + // we don't use advance time to avoid triggering on_initialize. This benchmark should only measure the extrinsic + // weight and not the whole on_initialize call weight + frame_system::Pallet::::set_block_number(now + One::one()); + + #[extrinsic_call] + start_auction(RawOrigin::Signed(issuer), project_id); + + // * validity checks * + // Storage + let stored_details = ProjectsDetails::::get(project_id).unwrap(); + assert_eq!(stored_details.status, ProjectStatus::AuctionRound(AuctionPhase::English)); + + // Events + let current_block = inst.current_block(); + frame_system::Pallet::::assert_last_event( + Event::::EnglishAuctionStarted { project_id, when: current_block.into() }.into(), + ); + } + + // do_candle_auction + #[benchmark] + fn start_candle_phase() { + #[block] + {} + } + + // do_community_funding + #[benchmark] + fn start_community_funding() { + #[block] + {} + } + + // do_remainder_funding + #[benchmark] + fn start_remainder_funding() { + #[block] + {} + } + + // do_end_funding + #[benchmark] + fn end_funding() { + #[block] + {} + } + + // do_project_decision + #[benchmark] + fn decide_project_outcome_automatically() { + #[block] + {} + } + + // do_start_settlement + #[benchmark] + fn start_settlement() { + #[block] + {} + } + #[macro_export] macro_rules! find_event { ($env: expr, $pattern:pat) => { @@ -3066,9 +3228,9 @@ mod benchmarks { } #[test] - fn bench_decide_project_outcome() { + fn bench_decide_project_outcome_manually() { new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_decide_project_outcome()); + assert_ok!(PalletFunding::::test_decide_project_outcome_manually()); }); } @@ -3099,5 +3261,20 @@ mod benchmarks { assert_ok!(PalletFunding::::test_contribution_unbond_for()); }); } + + // on_initialize benches + #[test] + fn bench_end_evaluation_success() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_end_evaluation_success()); + }); + } + + #[test] + fn bench_end_evaluation_failure() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_end_evaluation_failure()); + }); + } } } From 19c8b4f5b1302ce3ea1bb58254ed9d70e9711f70 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 5 Feb 2024 10:52:08 +0100 Subject: [PATCH 182/212] unused var Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index c56c24d81..b17fbe6e8 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -2877,9 +2877,6 @@ mod benchmarks { // move block manually without calling any hooks, to avoid triggering the transition outside the benchmarking context frame_system::Pallet::::set_block_number(evaluation_end_block + One::one()); - let insertion_block_number = - inst.current_block() + One::one() + ::AuctionInitializePeriodDuration::get(); - // Instead of advancing in time for the automatic `do_evaluation_end` call in on_initialize, we call it directly to benchmark it #[block] { From 258e4509a3f0bcc7458176b2dfd3c30968e92a87 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 5 Feb 2024 10:58:51 +0100 Subject: [PATCH 183/212] weight generated look ok Signed-off-by: Juan Ignacio Rios --- nodes/parachain/src/chain_spec/testnet.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/nodes/parachain/src/chain_spec/testnet.rs b/nodes/parachain/src/chain_spec/testnet.rs index 907fbacd9..ddd8b185d 100644 --- a/nodes/parachain/src/chain_spec/testnet.rs +++ b/nodes/parachain/src/chain_spec/testnet.rs @@ -276,10 +276,8 @@ mod testing_helpers { use super::*; use macros::generate_accounts; pub use pallet_funding::{instantiator::UserToUSDBalance, *}; - use pallet_funding::{instantiator::UserToUSDBalance, *}; use polimec_parachain_runtime::AccountId; use sp_core::H256; - use sp_runtime::BoundedVec; pub use sp_runtime::{traits::ConstU32, BoundedVec, FixedU128}; pub const METADATA: &str = r#"METADATA { From 33d13bb2d7b1f663e562a415dccf2026e2277dad Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 5 Feb 2024 11:47:17 +0100 Subject: [PATCH 184/212] candle phase done Signed-off-by: Juan Ignacio Rios --- debug_weight_gen.rs | 52 ++++++++++++ pallets/funding/src/benchmarking.rs | 48 ++++++++++- pallets/funding/src/functions.rs | 25 ++++-- pallets/funding/src/lib.rs | 6 +- pallets/funding/src/weights.rs | 126 ++++++++++++++++++++++++++++ 5 files changed, 246 insertions(+), 11 deletions(-) create mode 100644 debug_weight_gen.rs diff --git a/debug_weight_gen.rs b/debug_weight_gen.rs new file mode 100644 index 000000000..3a6b41c30 --- /dev/null +++ b/debug_weight_gen.rs @@ -0,0 +1,52 @@ + +//! Autogenerated weights for `pallet_funding` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2024-02-05, STEPS: `10`, REPEAT: `5`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `Juans-MBP.home`, CPU: `` +//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: 1024 + +// Executed Command: +// target/debug/polimec-parachain-node +// benchmark +// pallet +// --chain=polimec-rococo-local +// --steps=10 +// --repeat=5 +// --pallet=pallet_funding +// --extrinsic=start_candle_phase +// --output +// ./debug_weight_gen.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::Weight}; +use core::marker::PhantomData; + +/// Weight functions for `pallet_funding`. +pub struct WeightInfo(PhantomData); +impl pallet_funding::WeightInfo for WeightInfo { + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_candle_phase(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `445 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 241_000_000 picoseconds. + Weight::from_parts(229_863_239, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 186_038 + .saturating_add(Weight::from_parts(36_067_945, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + } +} diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index b17fbe6e8..f7b85aa9e 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -2954,9 +2954,46 @@ mod benchmarks { // do_candle_auction #[benchmark] - fn start_candle_phase() { + fn start_candle_phase( + // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the fn succeed + x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, + ) { + // * setup * + let mut inst = BenchInstantiator::::new(None); + + // real benchmark starts at block 0, and we can't call `events()` at block 0 + inst.advance_time(1u32.into()).unwrap(); + + let issuer = account::>("issuer", 0, 0); + whitelist_account!(issuer); + + let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); + let project_id = inst.create_auctioning_project(project_metadata, issuer.clone(), default_evaluations()); + + let english_end_block = + inst.get_project_details(project_id).phase_transition_points.english_auction.end().unwrap(); + // we don't use advance time to avoid triggering on_initialize. This benchmark should only measure the extrinsic + // weight and not the whole on_initialize call weight + frame_system::Pallet::::set_block_number(english_end_block + One::one()); + + let insertion_block_number = inst.current_block() + T::CandleAuctionDuration::get() + One::one(); + + fill_projects_to_update::(x, insertion_block_number, None); + #[block] - {} + { + Pallet::::do_candle_auction(project_id); + } + // * validity checks * + // Storage + let stored_details = ProjectsDetails::::get(project_id).unwrap(); + assert_eq!(stored_details.status, ProjectStatus::AuctionRound(AuctionPhase::Candle)); + + // Events + let current_block = inst.current_block(); + frame_system::Pallet::::assert_last_event( + Event::::CandleAuctionStarted { project_id, when: current_block.into() }.into(), + ); } // do_community_funding @@ -3273,5 +3310,12 @@ mod benchmarks { assert_ok!(PalletFunding::::test_end_evaluation_failure()); }); } + + #[test] + fn bench_start_candle_phase() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_start_candle_phase()); + }); + } } } diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index b3cab44c7..c7729c771 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -238,7 +238,7 @@ impl Pallet { /// /// * Bonding failed - `on_idle` at some point checks for failed evaluation projects, and /// unbonds the evaluators funds. - pub fn do_evaluation_end(project_id: ProjectId) -> DispatchResult { + pub fn do_evaluation_end(project_id: ProjectId) -> DispatchResultWithPostInfo { // * Get variables * let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let now = >::block_number(); @@ -282,7 +282,7 @@ impl Pallet { project_details.status = ProjectStatus::AuctionInitializePeriod; ProjectsDetails::::insert(project_id, project_details); // TODO: return real weights - let _insertions_attempts = match Self::add_to_update_store( + let insertion_attempts = match Self::add_to_update_store( auction_initialize_period_end_block + 1u32.into(), (&project_id, UpdateType::EnglishAuctionStart), ) { @@ -297,6 +297,11 @@ impl Pallet { end_block: auction_initialize_period_end_block, }); + return Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::end_evaluation_success(insertion_attempts)), + pays_fee: Pays::Yes, + }) + // Unsuccessful path } else { // * Update storage * @@ -306,9 +311,11 @@ impl Pallet { // * Emit events * Self::deposit_event(Event::EvaluationFailed { project_id }); + return Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::end_evaluation_failure()), + pays_fee: Pays::Yes, + }) } - - Ok(()) } /// Called by user extrinsic @@ -449,7 +456,7 @@ impl Pallet { /// but now their bids are not guaranteed. /// Later on, `on_initialize` ends the candle auction round and starts the community round, /// by calling [`do_community_funding`](Self::do_community_funding). - pub fn do_candle_auction(project_id: ProjectId) -> DispatchResult { + pub fn do_candle_auction(project_id: ProjectId) -> DispatchResultWithPostInfo { // * Get variables * let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let now = >::block_number(); @@ -472,8 +479,7 @@ impl Pallet { project_details.status = ProjectStatus::AuctionRound(AuctionPhase::Candle); ProjectsDetails::::insert(project_id, project_details); // Schedule for automatic check by on_initialize. Success depending on enough funding reached - // TODO: return real weights - let _iterations = match Self::add_to_update_store( + let insertion_iterations = match Self::add_to_update_store( candle_end_block + 1u32.into(), (&project_id, UpdateType::CommunityFundingStart), ) { @@ -484,7 +490,10 @@ impl Pallet { // * Emit events * Self::deposit_event(Event::CandleAuctionStarted { project_id, when: now }); - Ok(()) + Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::start_candle_phase(insertion_iterations)), + pays_fee: Pays::Yes, + }) } /// Called automatically by on_initialize diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 098d10d14..678ec89a3 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1267,7 +1267,11 @@ pub mod pallet { match update_type { // EvaluationRound -> AuctionInitializePeriod | EvaluationFailed UpdateType::EvaluationEnd => { - unwrap_result_or_skip!(Self::do_evaluation_end(project_id), project_id, |e| e); + unwrap_result_or_skip!( + Self::do_evaluation_end(project_id), + project_id, + |e: DispatchErrorWithPostInfo| { e.error } + ); }, // AuctionInitializePeriod -> AuctionRound(AuctionPhase::English) diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index c7fa8edc2..9dfda2b7a 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -83,6 +83,10 @@ pub trait WeightInfo { fn release_contribution_funds_for() -> Weight; fn bid_unbond_for() -> Weight; fn contribution_unbond_for() -> Weight; + + fn end_evaluation_success(x: u32, ) -> Weight; + fn end_evaluation_failure() -> Weight; + fn start_candle_phase(x: u32, ) -> Weight; } /// Weights for `pallet_funding` using the Substrate node and recommended hardware. @@ -843,6 +847,65 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:4 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:99 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn end_evaluation_success(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `680 + x * (529 ±0)` + // Estimated: `12270 + x * (3097 ±0)` + // Minimum execution time: 526_000_000 picoseconds. + Weight::from_parts(542_694_602, 0) + .saturating_add(Weight::from_parts(0, 12270)) + // Standard Error: 319_361 + .saturating_add(Weight::from_parts(37_635_189, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:4 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + fn end_evaluation_failure() -> Weight { + // Proof Size summary in bytes: + // Measured: `1148` + // Estimated: `12270` + // Minimum execution time: 478_000_000 picoseconds. + Weight::from_parts(553_000_000, 0) + .saturating_add(Weight::from_parts(0, 12270)) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(1)) + } + + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_candle_phase(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `445 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 241_000_000 picoseconds. + Weight::from_parts(229_863_239, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 186_038 + .saturating_add(Weight::from_parts(36_067_945, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + } } // For backwards compatibility and tests. @@ -1602,4 +1665,67 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } + + + + + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:4 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:99 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn end_evaluation_success(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `680 + x * (529 ±0)` + // Estimated: `12270 + x * (3097 ±0)` + // Minimum execution time: 526_000_000 picoseconds. + Weight::from_parts(542_694_602, 0) + .saturating_add(Weight::from_parts(0, 12270)) + // Standard Error: 319_361 + .saturating_add(Weight::from_parts(37_635_189, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(6)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:4 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + fn end_evaluation_failure() -> Weight { + // Proof Size summary in bytes: + // Measured: `1148` + // Estimated: `12270` + // Minimum execution time: 478_000_000 picoseconds. + Weight::from_parts(553_000_000, 0) + .saturating_add(Weight::from_parts(0, 12270)) + .saturating_add(RocksDbWeight::get().reads(6)) + .saturating_add(RocksDbWeight::get().writes(1)) + } + + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_candle_phase(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `445 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 241_000_000 picoseconds. + Weight::from_parts(229_863_239, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 186_038 + .saturating_add(Weight::from_parts(36_067_945, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + } } \ No newline at end of file From fb82fc49ca76630d318e5f4af80de68b7b8efba8 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 5 Feb 2024 13:46:21 +0100 Subject: [PATCH 185/212] trying to make community Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 64 ++++++++++++++++++++++++++++- pallets/funding/src/functions.rs | 3 +- pallets/funding/src/lib.rs | 6 ++- 3 files changed, 68 insertions(+), 5 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index f7b85aa9e..2814bfb8e 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -2997,10 +2997,63 @@ mod benchmarks { } // do_community_funding + // Should be complex due to calling `calculate_weighted_average_price` #[benchmark] - fn start_community_funding() { + fn start_community_funding_success( + // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the fn succeed + x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, + ) { + // * setup * + let mut inst = BenchInstantiator::::new(None); + + // real benchmark starts at block 0, and we can't call `events()` at block 0 + inst.advance_time(1u32.into()).unwrap(); + + let issuer = account::>("issuer", 0, 0); + whitelist_account!(issuer); + + let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); + let project_id = inst.create_auctioning_project(project_metadata, issuer.clone(), default_evaluations()); + + let bids = default_bids::(); + let plmc_needed_for_bids = BenchInstantiator::::calculate_auction_plmc_spent(&bids, None); + let plmc_ed = bids.accounts().existential_deposits(); + let plmc_ct_account_deposit = bids.accounts().ct_account_deposits(); + let funding_asset_needed_for_bids = BenchInstantiator::::calculate_auction_funding_asset_spent(&bids, None); + + inst.mint_plmc_to(plmc_needed_for_bids); + inst.mint_plmc_to(plmc_ed); + inst.mint_plmc_to(plmc_ct_account_deposit); + inst.mint_statemint_asset_to(funding_asset_needed_for_bids); + + inst.bid_for_users(project_id, bids); + + inst.advance_time(::EnglishAuctionDuration::get() + One::one()).unwrap(); + + let auction_candle_end_block = + inst.get_project_details(project_id).phase_transition_points.candle_auction.end().unwrap(); + // we don't use advance time to avoid triggering on_initialize. This benchmark should only measure the fn + // weight and not the whole on_initialize call weight + frame_system::Pallet::::set_block_number(auction_candle_end_block + One::one()); + let now = inst.current_block(); + + let community_end_block = now + T::CommunityFundingDuration::get(); + + let insertion_block_number = community_end_block + One::one(); + fill_projects_to_update::(x, insertion_block_number, None); + #[block] - {} + { + Pallet::::do_community_funding(project_id); + } + + // * validity checks * + // Storage + let stored_details = ProjectsDetails::::get(project_id).unwrap(); + assert_eq!(stored_details.status, ProjectStatus::CommunityRound); + + // Events + frame_system::Pallet::::assert_last_event(Event::::CommunityFundingStarted { project_id }.into()); } // do_remainder_funding @@ -3317,5 +3370,12 @@ mod benchmarks { assert_ok!(PalletFunding::::test_start_candle_phase()); }); } + + #[test] + fn bench_start_community_funding_success() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_start_community_funding_success()); + }); + } } } diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index c7729c771..e21f715f0 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -548,8 +548,7 @@ impl Pallet { Err(pallet_error) if pallet_error == Error::::NoBidsFound.into() => { project_details.status = ProjectStatus::FundingFailed; ProjectsDetails::::insert(project_id, project_details); - // TODO: return real weights - let _iterations = match Self::add_to_update_store( + let insertion_iterations = match Self::add_to_update_store( >::block_number() + 1u32.into(), (&project_id, UpdateType::FundingEnd), ) { diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 678ec89a3..4e3c1b3e2 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1286,7 +1286,11 @@ pub mod pallet { // AuctionRound(AuctionPhase::English) -> AuctionRound(AuctionPhase::Candle) UpdateType::CandleAuctionStart => { - unwrap_result_or_skip!(Self::do_candle_auction(project_id), project_id, |e| e); + unwrap_result_or_skip!( + Self::do_candle_auction(project_id), + project_id, + |e: DispatchErrorWithPostInfo| { e.error } + ); }, // AuctionRound(AuctionPhase::Candle) -> CommunityRound From 46efb8cf1ceadbad4c47605b883427e9a45dcd54 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 5 Feb 2024 14:42:35 +0100 Subject: [PATCH 186/212] remove refund bid on bad math. we now use saturating_mul_int Signed-off-by: Juan Ignacio Rios --- debug_weight_gen.rs | 36 ++++--- pallets/funding/src/benchmarking.rs | 58 +++++++++++ pallets/funding/src/functions.rs | 29 +++--- pallets/funding/src/lib.rs | 6 +- pallets/funding/src/tests.rs | 1 + pallets/funding/src/weights.rs | 144 ++++++++++++++++++++++++++++ 6 files changed, 246 insertions(+), 28 deletions(-) diff --git a/debug_weight_gen.rs b/debug_weight_gen.rs index 3a6b41c30..86f9e215c 100644 --- a/debug_weight_gen.rs +++ b/debug_weight_gen.rs @@ -15,7 +15,7 @@ // --steps=10 // --repeat=5 // --pallet=pallet_funding -// --extrinsic=start_candle_phase +// --extrinsic=start_community_funding_failure // --output // ./debug_weight_gen.rs @@ -32,21 +32,31 @@ pub struct WeightInfo(PhantomData); impl pallet_funding::WeightInfo for WeightInfo { /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Nonce` (r:1 w:1) + /// Proof: `PolimecFunding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Random::RandomMaterial` (r:1 w:0) + /// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:0) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:1 w:0) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. - fn start_candle_phase(x: u32, ) -> Weight { + fn start_community_funding_failure(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `445 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 241_000_000 picoseconds. - Weight::from_parts(229_863_239, 0) + // Measured: `2654 + x * (4 ±0)` + // Estimated: `4087` + // Minimum execution time: 1_453_000_000 picoseconds. + Weight::from_parts(1_487_504_532, 0) .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 186_038 - .saturating_add(Weight::from_parts(36_067_945, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + // Standard Error: 177_339 + .saturating_add(Weight::from_parts(731_091, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) } } diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 2814bfb8e..023da0266 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -3002,6 +3002,10 @@ mod benchmarks { fn start_community_funding_success( // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the fn succeed x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, + // Total bids made + y: Linear<1, 100_000>, + // Refunded bids (i.e failed bids) + z: Linear<1, 100_000>, ) { // * setup * let mut inst = BenchInstantiator::::new(None); @@ -3056,6 +3060,53 @@ mod benchmarks { frame_system::Pallet::::assert_last_event(Event::::CommunityFundingStarted { project_id }.into()); } + #[benchmark] + fn start_community_funding_failure( + // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the fn succeed + x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, + ) { + // * setup * + let mut inst = BenchInstantiator::::new(None); + + // real benchmark starts at block 0, and we can't call `events()` at block 0 + inst.advance_time(1u32.into()).unwrap(); + + let issuer = account::>("issuer", 0, 0); + whitelist_account!(issuer); + + let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); + let project_id = inst.create_auctioning_project(project_metadata, issuer.clone(), default_evaluations()); + + // no bids are made, so the project fails + + inst.advance_time(::EnglishAuctionDuration::get() + One::one()).unwrap(); + + let auction_candle_end_block = + inst.get_project_details(project_id).phase_transition_points.candle_auction.end().unwrap(); + // we don't use advance time to avoid triggering on_initialize. This benchmark should only measure the fn + // weight and not the whole on_initialize call weight + frame_system::Pallet::::set_block_number(auction_candle_end_block + One::one()); + let now = inst.current_block(); + + let community_end_block = now + T::CommunityFundingDuration::get(); + + let insertion_block_number = community_end_block + One::one(); + fill_projects_to_update::(x, insertion_block_number, None); + + #[block] + { + Pallet::::do_community_funding(project_id); + } + + // * validity checks * + // Storage + let stored_details = ProjectsDetails::::get(project_id).unwrap(); + assert_eq!(stored_details.status, ProjectStatus::FundingFailed); + + // Events + frame_system::Pallet::::assert_last_event(Event::::AuctionFailed { project_id }.into()); + } + // do_remainder_funding #[benchmark] fn start_remainder_funding() { @@ -3377,5 +3428,12 @@ mod benchmarks { assert_ok!(PalletFunding::::test_start_community_funding_success()); }); } + + #[test] + fn bench_start_community_funding_failure() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_start_community_funding_success()); + }); + } } } diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index e21f715f0..1d31159c6 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -518,7 +518,7 @@ impl Pallet { /// Retail users buy tokens at the price set on the auction round. /// Later on, `on_initialize` ends the community round by calling [`do_remainder_funding`](Self::do_remainder_funding) and /// starts the remainder round, where anyone can buy at that price point. - pub fn do_community_funding(project_id: ProjectId) -> DispatchResult { + pub fn do_community_funding(project_id: ProjectId) -> DispatchResultWithPostInfo { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; @@ -559,9 +559,12 @@ impl Pallet { // * Emit events * Self::deposit_event(Event::AuctionFailed { project_id }); - Ok(()) + Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::start_community_funding_failure(insertion_iterations)), + pays_fee: Pays::Yes, + }) }, - e @ Err(_) => e, + Err(e) => return Err(DispatchErrorWithPostInfo { post_info: ().into(), error: e }), Ok(()) => { // Get info again after updating it with new price. project_details.phase_transition_points.random_candle_ending = Some(end_block); @@ -572,7 +575,7 @@ impl Pallet { project_details.status = ProjectStatus::CommunityRound; ProjectsDetails::::insert(project_id, project_details); // TODO: return real weights - let _iterations = match Self::add_to_update_store( + let insertion_iterations = match Self::add_to_update_store( community_end_block + 1u32.into(), (&project_id, UpdateType::RemainderFundingStart), ) { @@ -583,7 +586,10 @@ impl Pallet { // * Emit events * Self::deposit_event(Event::CommunityFundingStarted { project_id }); - Ok(()) + Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::start_community_funding_success(insertion_iterations)), + pays_fee: Pays::Yes, + }) }, } } @@ -2705,15 +2711,10 @@ impl Pallet { return Self::refund_bid(&mut bid, project_id, &project_account, RejectionReason::NoTokensLeft) .and(Ok(bid)) } else if bid.original_ct_amount <= buyable_amount { - let maybe_ticket_size = bid.original_ct_usd_price.checked_mul_int(bid.original_ct_amount); - if let Some(ticket_size) = maybe_ticket_size { - bid_token_amount_sum.saturating_accrue(bid.original_ct_amount); - bid_usd_value_sum.saturating_accrue(ticket_size); - bid.status = BidStatus::Accepted; - } else { - return Self::refund_bid(&mut bid, project_id, &project_account, RejectionReason::BadMath) - .and(Ok(bid)) - } + let ticket_size = bid.original_ct_usd_price.saturating_mul_int(bid.original_ct_amount); + bid_token_amount_sum.saturating_accrue(bid.original_ct_amount); + bid_usd_value_sum.saturating_accrue(ticket_size); + bid.status = BidStatus::Accepted; } else { let maybe_ticket_size = bid.original_ct_usd_price.checked_mul_int(buyable_amount); if let Some(ticket_size) = maybe_ticket_size { diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 4e3c1b3e2..5ea9130db 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1295,7 +1295,11 @@ pub mod pallet { // AuctionRound(AuctionPhase::Candle) -> CommunityRound UpdateType::CommunityFundingStart => { - unwrap_result_or_skip!(Self::do_community_funding(project_id), project_id, |e| e); + unwrap_result_or_skip!( + Self::do_community_funding(project_id), + project_id, + |e: DispatchErrorWithPostInfo| { e.error } + ); }, // CommunityRound -> RemainderRound diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 9993766ce..867883120 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -298,6 +298,7 @@ mod creation_round_success { for _ in 0..512 { let project = default_project(inst.get_new_nonce(), issuer); inst.create_evaluating_project(project, issuer); + inst.advance_time(1u64).unwrap(); } } diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index 9dfda2b7a..6cb67c9cc 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -87,6 +87,26 @@ pub trait WeightInfo { fn end_evaluation_success(x: u32, ) -> Weight; fn end_evaluation_failure() -> Weight; fn start_candle_phase(x: u32, ) -> Weight; + + fn start_community_funding_success(x: u32, ) -> Weight; + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Nonce` (r:1 w:1) + /// Proof: `PolimecFunding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Random::RandomMaterial` (r:1 w:0) + /// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:0) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:1 w:0) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_community_funding_failure(x: u32, ) -> Weight; } /// Weights for `pallet_funding` using the Substrate node and recommended hardware. @@ -906,6 +926,68 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) } + + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Nonce` (r:1 w:1) + /// Proof: `PolimecFunding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Random::RandomMaterial` (r:1 w:0) + /// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:3 w:2) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:1 w:0) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_community_funding_success(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2882 + x * (529 ±0)` + // Estimated: `9669 + x * (3097 ±0)` + // Minimum execution time: 1_763_000_000 picoseconds. + Weight::from_parts(1_776_970_836, 0) + .saturating_add(Weight::from_parts(0, 9669)) + // Standard Error: 483_296 + .saturating_add(Weight::from_parts(38_180_695, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + } + + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Nonce` (r:1 w:1) + /// Proof: `PolimecFunding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Random::RandomMaterial` (r:1 w:0) + /// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:0) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:1 w:0) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_community_funding_failure(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2654 + x * (4 ±0)` + // Estimated: `4087` + // Minimum execution time: 1_453_000_000 picoseconds. + Weight::from_parts(1_487_504_532, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 177_339 + .saturating_add(Weight::from_parts(731_091, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(8)) + .saturating_add(T::DbWeight::get().writes(3)) + } } // For backwards compatibility and tests. @@ -1728,4 +1810,66 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) } + + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Nonce` (r:1 w:1) + /// Proof: `PolimecFunding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Random::RandomMaterial` (r:1 w:0) + /// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:3 w:2) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:1 w:0) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_community_funding_success(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2882 + x * (529 ±0)` + // Estimated: `9669 + x * (3097 ±0)` + // Minimum execution time: 1_763_000_000 picoseconds. + Weight::from_parts(1_776_970_836, 0) + .saturating_add(Weight::from_parts(0, 9669)) + // Standard Error: 483_296 + .saturating_add(Weight::from_parts(38_180_695, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(10)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(5)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + } + + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Nonce` (r:1 w:1) + /// Proof: `PolimecFunding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Random::RandomMaterial` (r:1 w:0) + /// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:0) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:1 w:0) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_community_funding_failure(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2654 + x * (4 ±0)` + // Estimated: `4087` + // Minimum execution time: 1_453_000_000 picoseconds. + Weight::from_parts(1_487_504_532, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 177_339 + .saturating_add(Weight::from_parts(731_091, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(8)) + .saturating_add(RocksDbWeight::get().writes(3)) + } } \ No newline at end of file From bc500593c1f788d649e3e81a0d1a254bae95ba2c Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 5 Feb 2024 15:53:33 +0100 Subject: [PATCH 187/212] trying to add complexity params to community round transition Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 106 ++++++++++++++++++++++++---- pallets/funding/src/functions.rs | 86 +++++++++++----------- pallets/funding/src/lib.rs | 5 ++ pallets/funding/src/mock.rs | 1 + pallets/funding/src/tests.rs | 5 ++ runtimes/testnet/src/lib.rs | 1 + 6 files changed, 146 insertions(+), 58 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 023da0266..c0d15e754 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -3002,10 +3002,10 @@ mod benchmarks { fn start_community_funding_success( // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the fn succeed x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, - // Total bids made - y: Linear<1, 100_000>, - // Refunded bids (i.e failed bids) - z: Linear<1, 100_000>, + // Accepted Bids + y: Linear<1, { ::MaxBidsPerProject::get() / 2 }>, + // Failed Bids + z: Linear<0, { ::MaxBidsPerProject::get() / 2 }>, ) { // * setup * let mut inst = BenchInstantiator::::new(None); @@ -3015,25 +3015,96 @@ mod benchmarks { let issuer = account::>("issuer", 0, 0); whitelist_account!(issuer); + let bounded_name = BoundedVec::try_from("Contribution Token TEST".as_bytes().to_vec()).unwrap(); + let bounded_symbol = BoundedVec::try_from("CTEST".as_bytes().to_vec()).unwrap(); + let metadata_hash = hashed(format!("{}-{}", METADATA, 69)); + // default has 50k allocated for bidding, so we cannot test the cap of bidding (100k bids) with it, since the ticket size is 1. + let project_metadata = ProjectMetadata { + token_information: CurrencyMetadata { + name: bounded_name, + symbol: bounded_symbol, + decimals: ASSET_DECIMALS, + }, + mainnet_token_max_supply: BalanceOf::::try_from(8_000_000_0_000_000_000u128) + .unwrap_or_else(|_| panic!("Failed to create BalanceOf")), + total_allocation_size: ( + BalanceOf::::try_from((10 * (y + z) + 1) as u128 * ASSET_UNIT) + .unwrap_or_else(|_| panic!("Failed to create BalanceOf")), + BalanceOf::::try_from(50_000u128 * ASSET_UNIT) + .unwrap_or_else(|_| panic!("Failed to create BalanceOf")), + ), + minimum_price: 1u128.into(), + ticket_size: TicketSize { + minimum: Some(1u128.try_into().unwrap_or_else(|_| panic!("Failed to create BalanceOf"))), + maximum: None, + }, + participants_size: ParticipantsSize { minimum: Some(2), maximum: None }, + funding_thresholds: Default::default(), + conversion_rate: 0, + participation_currencies: AcceptedFundingAsset::USDT, + funding_destination_account: issuer.clone(), + offchain_information_hash: Some(metadata_hash.into()), + }; + let project_id = + inst.create_auctioning_project(project_metadata.clone(), issuer.clone(), default_evaluations()); + + let accepted_bids = (0..y) + .map(|i| { + BidParams::::new( + account::>("bidder", 0, i), + (10u128 * ASSET_UNIT).into(), + project_metadata.minimum_price, + 1u8, + AcceptedFundingAsset::USDT, + ) + }) + .collect_vec(); - let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); - let project_id = inst.create_auctioning_project(project_metadata, issuer.clone(), default_evaluations()); - - let bids = default_bids::(); - let plmc_needed_for_bids = BenchInstantiator::::calculate_auction_plmc_spent(&bids, None); - let plmc_ed = bids.accounts().existential_deposits(); - let plmc_ct_account_deposit = bids.accounts().ct_account_deposits(); - let funding_asset_needed_for_bids = BenchInstantiator::::calculate_auction_funding_asset_spent(&bids, None); + let plmc_needed_for_bids = BenchInstantiator::::calculate_auction_plmc_spent(&accepted_bids, None); + let plmc_ed = accepted_bids.accounts().existential_deposits(); + let plmc_ct_account_deposit = accepted_bids.accounts().ct_account_deposits(); + let funding_asset_needed_for_bids = + BenchInstantiator::::calculate_auction_funding_asset_spent(&accepted_bids, None); inst.mint_plmc_to(plmc_needed_for_bids); inst.mint_plmc_to(plmc_ed); inst.mint_plmc_to(plmc_ct_account_deposit); inst.mint_statemint_asset_to(funding_asset_needed_for_bids); - inst.bid_for_users(project_id, bids); + inst.bid_for_users(project_id, accepted_bids); inst.advance_time(::EnglishAuctionDuration::get() + One::one()).unwrap(); + // testing always produced this random ending + let random_ending: BlockNumberFor = 9176u32.into(); + let now = inst.current_block(); + inst.advance_time(random_ending - now + 2u32.into()).unwrap(); + + let rejected_bids = (0..y) + .map(|i| { + BidParams::::new( + account::>("bidder", 0, i), + (10u128 * ASSET_UNIT).into(), + project_metadata.minimum_price, + 1u8, + AcceptedFundingAsset::USDT, + ) + }) + .collect_vec(); + + let plmc_needed_for_bids = BenchInstantiator::::calculate_auction_plmc_spent(&rejected_bids, None); + let plmc_ed = rejected_bids.accounts().existential_deposits(); + let plmc_ct_account_deposit = rejected_bids.accounts().ct_account_deposits(); + let funding_asset_needed_for_bids = + BenchInstantiator::::calculate_auction_funding_asset_spent(&rejected_bids, None); + + inst.mint_plmc_to(plmc_needed_for_bids); + inst.mint_plmc_to(plmc_ed); + inst.mint_plmc_to(plmc_ct_account_deposit); + inst.mint_statemint_asset_to(funding_asset_needed_for_bids); + + inst.bid_for_users(project_id, rejected_bids); + let auction_candle_end_block = inst.get_project_details(project_id).phase_transition_points.candle_auction.end().unwrap(); // we don't use advance time to avoid triggering on_initialize. This benchmark should only measure the fn @@ -3048,7 +3119,7 @@ mod benchmarks { #[block] { - Pallet::::do_community_funding(project_id); + Pallet::::do_community_funding(project_id).unwrap(); } // * validity checks * @@ -3056,6 +3127,13 @@ mod benchmarks { let stored_details = ProjectsDetails::::get(project_id).unwrap(); assert_eq!(stored_details.status, ProjectStatus::CommunityRound); + let accepted_bids_count = + Bids::::iter_prefix_values((project_id,)).filter(|b| matches!(b.status, BidStatus::Accepted)).count(); + let rejected_bids_count = + Bids::::iter_prefix_values((project_id,)).filter(|b| matches!(b.status, BidStatus::Rejected(_))).count(); + assert_eq!(rejected_bids_count, z as usize); + assert_eq!(accepted_bids_count, y as usize); + // Events frame_system::Pallet::::assert_last_event(Event::::CommunityFundingStarted { project_id }.into()); } diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 1d31159c6..f3d64f70e 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -990,6 +990,7 @@ impl Pallet { let plmc_usd_price = T::PriceProvider::get_price(PLMC_STATEMINT_ID).ok_or(Error::::PriceNotFound)?; let ct_deposit = T::ContributionTokenCurrency::deposit_required(project_id); let existing_bids = Bids::::iter_prefix_values((project_id, bidder)).collect::>(); + let bid_count = BidCounts::::get(project_id); // benchmark variables let mut perform_bid_calls = 0; @@ -998,6 +999,7 @@ impl Pallet { // * Validity checks * ensure!(ct_amount > Zero::zero(), Error::::BidTooLow); + ensure!(bid_count < T::MaxBidsPerProject::get(), Error::::TooManyBids); ensure!(bidder.clone() != project_details.issuer, Error::::ContributionToThemselves); ensure!(matches!(project_details.status, ProjectStatus::AuctionRound(_)), Error::::AuctionNotStarted); ensure!(funding_asset == project_metadata.participation_currencies, Error::::FundingAssetNotAccepted); @@ -1121,6 +1123,7 @@ impl Pallet { Bids::::insert((project_id, bidder, bid_id), &new_bid); NextBidId::::set(bid_id.saturating_add(One::one())); + BidCounts::::mutate(project_id, |c| *c += 1); Self::deposit_event(Event::Bid { project_id, amount: ct_amount, price: ct_usd_price, multiplier }); @@ -2716,50 +2719,45 @@ impl Pallet { bid_usd_value_sum.saturating_accrue(ticket_size); bid.status = BidStatus::Accepted; } else { - let maybe_ticket_size = bid.original_ct_usd_price.checked_mul_int(buyable_amount); - if let Some(ticket_size) = maybe_ticket_size { - bid_usd_value_sum.saturating_accrue(ticket_size); - bid_token_amount_sum.saturating_accrue(buyable_amount); - bid.status = BidStatus::PartiallyAccepted(buyable_amount, RejectionReason::NoTokensLeft); - bid.final_ct_amount = buyable_amount; - - let funding_asset_price = T::PriceProvider::get_price(bid.funding_asset.to_statemint_id()) - .ok_or(Error::::PriceNotFound)?; - let funding_asset_amount_needed = funding_asset_price - .reciprocal() - .ok_or(Error::::BadMath)? - .checked_mul_int(ticket_size) - .ok_or(Error::::BadMath)?; - T::FundingCurrency::transfer( - bid.funding_asset.to_statemint_id(), - &project_account, - &bid.bidder, - bid.funding_asset_amount_locked.saturating_sub(funding_asset_amount_needed), - Preservation::Preserve, - )?; - - let usd_bond_needed = bid - .multiplier - .calculate_bonding_requirement::(ticket_size) - .map_err(|_| Error::::BadMath)?; - let plmc_bond_needed = plmc_price - .reciprocal() - .ok_or(Error::::BadMath)? - .checked_mul_int(usd_bond_needed) - .ok_or(Error::::BadMath)?; - T::NativeCurrency::release( - &HoldReason::Participation(project_id.into()).into(), - &bid.bidder, - bid.plmc_bond.saturating_sub(plmc_bond_needed), - Precision::Exact, - )?; - - bid.funding_asset_amount_locked = funding_asset_amount_needed; - bid.plmc_bond = plmc_bond_needed; - } else { - return Self::refund_bid(&mut bid, project_id, &project_account, RejectionReason::BadMath) - .and(Ok(bid)) - } + let ticket_size = bid.original_ct_usd_price.saturating_mul_int(buyable_amount); + bid_usd_value_sum.saturating_accrue(ticket_size); + bid_token_amount_sum.saturating_accrue(buyable_amount); + bid.status = BidStatus::PartiallyAccepted(buyable_amount, RejectionReason::NoTokensLeft); + bid.final_ct_amount = buyable_amount; + + let funding_asset_price = T::PriceProvider::get_price(bid.funding_asset.to_statemint_id()) + .ok_or(Error::::PriceNotFound)?; + let funding_asset_amount_needed = funding_asset_price + .reciprocal() + .ok_or(Error::::BadMath)? + .checked_mul_int(ticket_size) + .ok_or(Error::::BadMath)?; + T::FundingCurrency::transfer( + bid.funding_asset.to_statemint_id(), + &project_account, + &bid.bidder, + bid.funding_asset_amount_locked.saturating_sub(funding_asset_amount_needed), + Preservation::Preserve, + )?; + + let usd_bond_needed = bid + .multiplier + .calculate_bonding_requirement::(ticket_size) + .map_err(|_| Error::::BadMath)?; + let plmc_bond_needed = plmc_price + .reciprocal() + .ok_or(Error::::BadMath)? + .checked_mul_int(usd_bond_needed) + .ok_or(Error::::BadMath)?; + T::NativeCurrency::release( + &HoldReason::Participation(project_id.into()).into(), + &bid.bidder, + bid.plmc_bond.saturating_sub(plmc_bond_needed), + Precision::Exact, + )?; + + bid.funding_asset_amount_locked = funding_asset_amount_needed; + bid.plmc_bond = plmc_bond_needed; } Ok(bid) diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 5ea9130db..b874435cf 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -442,6 +442,8 @@ pub mod pallet { type RequiredMaxMessageSize: Get; /// max iterations for trying to insert a project on the projects_to_update storage type MaxProjectsToUpdateInsertionAttempts: Get; + /// max individual bids per project. Used to estimate worst case weight for price calculation + type MaxBidsPerProject: Get; } #[pallet::storage] @@ -462,6 +464,9 @@ pub mod pallet { #[pallet::getter(fn next_contribution_id)] pub type NextContributionId = StorageValue<_, u32, ValueQuery>; + #[pallet::storage] + pub type BidCounts = StorageMap<_, Blake2_128Concat, ProjectId, u32, ValueQuery>; + #[pallet::storage] #[pallet::getter(fn nonce)] /// A global counter used in the randomness generation diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 3265e8608..4822d53cc 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -350,6 +350,7 @@ impl Config for TestRuntime { type FeeBrackets = FeeBrackets; type FundingCurrency = StatemintAssets; type ManualAcceptanceDuration = ManualAcceptanceDuration; + type MaxBidsPerProject = ConstU32<20>; type MaxBidsPerUser = ConstU32<4>; type MaxCapacityThresholds = MaxCapacityThresholds; type MaxContributionsPerUser = ConstU32<4>; diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 867883120..ccb514992 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -1774,6 +1774,11 @@ mod auction_round_success { assert_eq!(delta_bidders_plmc_balances, plmc_locked_for_bids); } + + #[test] + pub fn cannot_bid_more_than_project_limit_count() { + todo!() + } } mod auction_round_failure { diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 14c232539..d4fce9086 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -570,6 +570,7 @@ impl pallet_funding::Config for Runtime { type FeeBrackets = FeeBrackets; type FundingCurrency = StatemintAssets; type ManualAcceptanceDuration = ManualAcceptanceDuration; + type MaxBidsPerProject = ConstU32<100_000>; type MaxBidsPerUser = ConstU32<256>; type MaxCapacityThresholds = MaxCapacityThresholds; type MaxContributionsPerUser = ConstU32<256>; From d58a932b2f1b895df6c51db393fa6df420d7efb4 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Mon, 5 Feb 2024 18:08:02 +0100 Subject: [PATCH 188/212] weird allocation bug when running new params bench Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 2 +- runtimes/testnet/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index c0d15e754..ff438e933 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -3080,7 +3080,7 @@ mod benchmarks { let now = inst.current_block(); inst.advance_time(random_ending - now + 2u32.into()).unwrap(); - let rejected_bids = (0..y) + let rejected_bids = (0..z) .map(|i| { BidParams::::new( account::>("bidder", 0, i), diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index d4fce9086..39fea29cd 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -570,7 +570,7 @@ impl pallet_funding::Config for Runtime { type FeeBrackets = FeeBrackets; type FundingCurrency = StatemintAssets; type ManualAcceptanceDuration = ManualAcceptanceDuration; - type MaxBidsPerProject = ConstU32<100_000>; + type MaxBidsPerProject = ConstU32<20_000>; type MaxBidsPerUser = ConstU32<256>; type MaxCapacityThresholds = MaxCapacityThresholds; type MaxContributionsPerUser = ConstU32<256>; From c919475b554e079375bf0f74ff7cd7a58e10bf26 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 6 Feb 2024 10:34:59 +0100 Subject: [PATCH 189/212] benchmark taking forever when adding 50k bids. Maybe I should replace the storage directly.. Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 5 ++++- pallets/funding/src/mock.rs | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index ff438e933..9771bd3ed 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -3009,7 +3009,10 @@ mod benchmarks { ) { // * setup * let mut inst = BenchInstantiator::::new(None); - + dbg!(x); + dbg!(y); + dbg!(z); + println!("\n--------"); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 4822d53cc..8ed830537 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -350,13 +350,13 @@ impl Config for TestRuntime { type FeeBrackets = FeeBrackets; type FundingCurrency = StatemintAssets; type ManualAcceptanceDuration = ManualAcceptanceDuration; - type MaxBidsPerProject = ConstU32<20>; + type MaxBidsPerProject = ConstU32<100_000>; type MaxBidsPerUser = ConstU32<4>; type MaxCapacityThresholds = MaxCapacityThresholds; type MaxContributionsPerUser = ConstU32<4>; type MaxEvaluationsPerUser = ConstU32<4>; type MaxMessageSizeThresholds = MaxMessageSizeThresholds; - type MaxProjectsToUpdateInsertionAttempts = ConstU32<10>; + type MaxProjectsToUpdateInsertionAttempts = ConstU32<100>; type MaxProjectsToUpdatePerBlock = ConstU32<5>; type Multiplier = Multiplier; type NativeCurrency = Balances; From 49ebe10a2784f31d8dff9dfc82b9682e277f1cf5 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 6 Feb 2024 13:46:03 +0100 Subject: [PATCH 190/212] weight generated for new community funding success Signed-off-by: Juan Ignacio Rios --- debug_weight_gen.rs | 50 ++++++++++++++++++++--------- pallets/funding/src/benchmarking.rs | 12 +++---- pallets/funding/src/functions.rs | 1 - pallets/funding/src/mock.rs | 2 +- runtimes/testnet/src/lib.rs | 4 +-- 5 files changed, 43 insertions(+), 26 deletions(-) diff --git a/debug_weight_gen.rs b/debug_weight_gen.rs index 86f9e215c..5f747bcd9 100644 --- a/debug_weight_gen.rs +++ b/debug_weight_gen.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `pallet_funding` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-02-05, STEPS: `10`, REPEAT: `5`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-02-06, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `Juans-MBP.home`, CPU: `` //! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: 1024 @@ -12,10 +12,10 @@ // benchmark // pallet // --chain=polimec-rococo-local -// --steps=10 -// --repeat=5 +// --steps=20 +// --repeat=10 // --pallet=pallet_funding -// --extrinsic=start_community_funding_failure +// --extrinsic=start_community_funding_success // --output // ./debug_weight_gen.rs @@ -38,25 +38,45 @@ impl pallet_funding::WeightInfo for WeightInfo { /// Proof: `PolimecFunding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Random::RandomMaterial` (r:1 w:0) /// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:1 w:0) + /// Storage: `PolimecFunding::Bids` (r:2049 w:2048) /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) /// Storage: `Oracle::Values` (r:1 w:0) /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:1025 w:1025) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1024 w:1024) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1024 w:1024) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::Buckets` (r:1 w:0) /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. - fn start_community_funding_failure(x: u32, ) -> Weight { + /// The range of component `y` is `[1, 1024]`. + /// The range of component `z` is `[0, 1024]`. + fn start_community_funding_success(x: u32, y: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2654 + x * (4 ±0)` - // Estimated: `4087` - // Minimum execution time: 1_453_000_000 picoseconds. - Weight::from_parts(1_487_504_532, 0) + // Measured: `91678 + x * (529 ±0) + y * (167 ±0) + z * (364 ±0)` + // Estimated: `4087 + x * (3097 ±0) + y * (2893 ±0) + z * (3624 ±0)` + // Minimum execution time: 139_251_000_000 picoseconds. + Weight::from_parts(6_810_381_680, 0) .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 177_339 - .saturating_add(Weight::from_parts(731_091, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(3)) + // Standard Error: 2_917_537 + .saturating_add(Weight::from_parts(143_813_813, 0).saturating_mul(y.into())) + // Standard Error: 2_914_495 + .saturating_add(Weight::from_parts(1_093_099_600, 0).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into()))) + .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(z.into()))) + .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) + .saturating_add(T::DbWeight::get().writes((4_u64).saturating_mul(z.into()))) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 2893).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 3624).saturating_mul(z.into())) } } diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 9771bd3ed..172b35505 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -3009,10 +3009,6 @@ mod benchmarks { ) { // * setup * let mut inst = BenchInstantiator::::new(None); - dbg!(x); - dbg!(y); - dbg!(z); - println!("\n--------"); // real benchmark starts at block 0, and we can't call `events()` at block 0 inst.advance_time(1u32.into()).unwrap(); @@ -3076,12 +3072,14 @@ mod benchmarks { inst.bid_for_users(project_id, accepted_bids); - inst.advance_time(::EnglishAuctionDuration::get() + One::one()).unwrap(); + let now = inst.current_block(); + frame_system::Pallet::::set_block_number(now + ::EnglishAuctionDuration::get()); + // automatic transition to candle + inst.advance_time(1u32.into()).unwrap(); // testing always produced this random ending let random_ending: BlockNumberFor = 9176u32.into(); - let now = inst.current_block(); - inst.advance_time(random_ending - now + 2u32.into()).unwrap(); + frame_system::Pallet::::set_block_number(random_ending + 2u32.into()); let rejected_bids = (0..z) .map(|i| { diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index f3d64f70e..43b76b2c9 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -991,7 +991,6 @@ impl Pallet { let ct_deposit = T::ContributionTokenCurrency::deposit_required(project_id); let existing_bids = Bids::::iter_prefix_values((project_id, bidder)).collect::>(); let bid_count = BidCounts::::get(project_id); - // benchmark variables let mut perform_bid_calls = 0; let mut ct_deposit_required = false; diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 8ed830537..4546a7e0a 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -350,7 +350,7 @@ impl Config for TestRuntime { type FeeBrackets = FeeBrackets; type FundingCurrency = StatemintAssets; type ManualAcceptanceDuration = ManualAcceptanceDuration; - type MaxBidsPerProject = ConstU32<100_000>; + type MaxBidsPerProject = ConstU32<2048>; type MaxBidsPerUser = ConstU32<4>; type MaxCapacityThresholds = MaxCapacityThresholds; type MaxContributionsPerUser = ConstU32<4>; diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 39fea29cd..d580d7b68 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -570,8 +570,8 @@ impl pallet_funding::Config for Runtime { type FeeBrackets = FeeBrackets; type FundingCurrency = StatemintAssets; type ManualAcceptanceDuration = ManualAcceptanceDuration; - type MaxBidsPerProject = ConstU32<20_000>; - type MaxBidsPerUser = ConstU32<256>; + type MaxBidsPerProject = ConstU32<2048>; + type MaxBidsPerUser = ConstU32<128>; type MaxCapacityThresholds = MaxCapacityThresholds; type MaxContributionsPerUser = ConstU32<256>; type MaxEvaluationsPerUser = ConstU32<256>; From 0e30a5b2042df3288acf5af3dd4f7cd9c6364de1 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 6 Feb 2024 13:56:54 +0100 Subject: [PATCH 191/212] added generated weight to pallet weight file Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/weights.rs | 78 +++++++++++++++++++++++++--------- 1 file changed, 57 insertions(+), 21 deletions(-) diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index 6cb67c9cc..3313c7a0d 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -88,7 +88,7 @@ pub trait WeightInfo { fn end_evaluation_failure() -> Weight; fn start_candle_phase(x: u32, ) -> Weight; - fn start_community_funding_success(x: u32, ) -> Weight; + fn start_community_funding_success(x: u32, y: u32, z: u32) -> Weight; /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) @@ -935,28 +935,46 @@ impl WeightInfo for SubstrateWeight { /// Proof: `PolimecFunding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Random::RandomMaterial` (r:1 w:0) /// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:3 w:2) + /// Storage: `PolimecFunding::Bids` (r:2049 w:2048) /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) /// Storage: `Oracle::Values` (r:1 w:0) /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:1025 w:1025) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1024 w:1024) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1024 w:1024) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::Buckets` (r:1 w:0) /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. - fn start_community_funding_success(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `2882 + x * (529 ±0)` - // Estimated: `9669 + x * (3097 ±0)` - // Minimum execution time: 1_763_000_000 picoseconds. - Weight::from_parts(1_776_970_836, 0) - .saturating_add(Weight::from_parts(0, 9669)) - // Standard Error: 483_296 - .saturating_add(Weight::from_parts(38_180_695, 0).saturating_mul(x.into())) + /// The range of component `y` is `[1, 1024]`. + /// The range of component `z` is `[0, 1024]`. + fn start_community_funding_success(x: u32, y: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `91678 + x * (529 ±0) + y * (167 ±0) + z * (364 ±0)` + // Estimated: `4087 + x * (3097 ±0) + y * (2893 ±0) + z * (3624 ±0)` + // Minimum execution time: 139_251_000_000 picoseconds. + Weight::from_parts(6_810_381_680, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 2_917_537 + .saturating_add(Weight::from_parts(143_813_813, 0).saturating_mul(y.into())) + // Standard Error: 2_914_495 + .saturating_add(Weight::from_parts(1_093_099_600, 0).saturating_mul(z.into())) .saturating_add(T::DbWeight::get().reads(10)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into()))) + .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(z.into()))) .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) + .saturating_add(T::DbWeight::get().writes((4_u64).saturating_mul(z.into()))) .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 2893).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 3624).saturating_mul(z.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) @@ -1819,28 +1837,46 @@ impl WeightInfo for () { /// Proof: `PolimecFunding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Random::RandomMaterial` (r:1 w:0) /// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:3 w:2) + /// Storage: `PolimecFunding::Bids` (r:2049 w:2048) /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) /// Storage: `Oracle::Values` (r:1 w:0) /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:1025 w:1025) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1024 w:1024) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1024 w:1024) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::Buckets` (r:1 w:0) /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. - fn start_community_funding_success(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `2882 + x * (529 ±0)` - // Estimated: `9669 + x * (3097 ±0)` - // Minimum execution time: 1_763_000_000 picoseconds. - Weight::from_parts(1_776_970_836, 0) - .saturating_add(Weight::from_parts(0, 9669)) - // Standard Error: 483_296 - .saturating_add(Weight::from_parts(38_180_695, 0).saturating_mul(x.into())) + /// The range of component `y` is `[1, 1024]`. + /// The range of component `z` is `[0, 1024]`. + fn start_community_funding_success(x: u32, y: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `91678 + x * (529 ±0) + y * (167 ±0) + z * (364 ±0)` + // Estimated: `4087 + x * (3097 ±0) + y * (2893 ±0) + z * (3624 ±0)` + // Minimum execution time: 139_251_000_000 picoseconds. + Weight::from_parts(6_810_381_680, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 2_917_537 + .saturating_add(Weight::from_parts(143_813_813, 0).saturating_mul(y.into())) + // Standard Error: 2_914_495 + .saturating_add(Weight::from_parts(1_093_099_600, 0).saturating_mul(z.into())) .saturating_add(RocksDbWeight::get().reads(10)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(y.into()))) + .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(z.into()))) .saturating_add(RocksDbWeight::get().writes(5)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(y.into()))) + .saturating_add(RocksDbWeight::get().writes((4_u64).saturating_mul(z.into()))) .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 2893).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 3624).saturating_mul(z.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) From 2ffe5848ab36e2b4a2e082e2104c4dee73b4ea9e Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 6 Feb 2024 16:02:46 +0100 Subject: [PATCH 192/212] weight generated on remainder Signed-off-by: Juan Ignacio Rios --- debug_weight_gen.rs | 50 ++++++-------------------- pallets/funding/src/benchmarking.rs | 54 +++++++++++++++++++++++++++-- pallets/funding/src/functions.rs | 27 +++++++++++---- 3 files changed, 83 insertions(+), 48 deletions(-) diff --git a/debug_weight_gen.rs b/debug_weight_gen.rs index 5f747bcd9..75807b6cc 100644 --- a/debug_weight_gen.rs +++ b/debug_weight_gen.rs @@ -15,7 +15,7 @@ // --steps=20 // --repeat=10 // --pallet=pallet_funding -// --extrinsic=start_community_funding_success +// --extrinsic=start_remainder_funding // --output // ./debug_weight_gen.rs @@ -32,51 +32,21 @@ pub struct WeightInfo(PhantomData); impl pallet_funding::WeightInfo for WeightInfo { /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Nonce` (r:1 w:1) - /// Proof: `PolimecFunding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Random::RandomMaterial` (r:1 w:0) - /// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:2049 w:2048) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:1 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:1025 w:1025) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1024 w:1024) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1024 w:1024) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Buckets` (r:1 w:0) - /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. - /// The range of component `y` is `[1, 1024]`. - /// The range of component `z` is `[0, 1024]`. - fn start_community_funding_success(x: u32, y: u32, z: u32, ) -> Weight { + fn start_remainder_funding(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `91678 + x * (529 ±0) + y * (167 ±0) + z * (364 ±0)` - // Estimated: `4087 + x * (3097 ±0) + y * (2893 ±0) + z * (3624 ±0)` - // Minimum execution time: 139_251_000_000 picoseconds. - Weight::from_parts(6_810_381_680, 0) + // Measured: `510 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 242_000_000 picoseconds. + Weight::from_parts(227_535_753, 0) .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 2_917_537 - .saturating_add(Weight::from_parts(143_813_813, 0).saturating_mul(y.into())) - // Standard Error: 2_914_495 - .saturating_add(Weight::from_parts(1_093_099_600, 0).saturating_mul(z.into())) - .saturating_add(T::DbWeight::get().reads(10)) + // Standard Error: 174_777 + .saturating_add(Weight::from_parts(37_767_357, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into()))) - .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(z.into()))) - .saturating_add(T::DbWeight::get().writes(5)) - .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) - .saturating_add(T::DbWeight::get().writes((4_u64).saturating_mul(z.into()))) + .saturating_add(T::DbWeight::get().writes(2)) .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 2893).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 3624).saturating_mul(z.into())) } } diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 172b35505..417b821e6 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -3188,9 +3188,52 @@ mod benchmarks { // do_remainder_funding #[benchmark] - fn start_remainder_funding() { + fn start_remainder_funding( + // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the fn succeed + x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, + ) { + // * setup * + let mut inst = BenchInstantiator::::new(None); + + // real benchmark starts at block 0, and we can't call `events()` at block 0 + inst.advance_time(1u32.into()).unwrap(); + + let issuer = account::>("issuer", 0, 0); + whitelist_account!(issuer); + + let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); + let (project_id, _) = inst.create_community_contributing_project( + project_metadata, + issuer.clone(), + default_evaluations(), + default_bids(), + ); + + let community_end_block = inst.get_project_details(project_id).phase_transition_points.community.end().unwrap(); + + // we don't use advance time to avoid triggering on_initialize. This benchmark should only measure the fn + // weight and not the whole on_initialize call weight + frame_system::Pallet::::set_block_number(community_end_block + One::one()); + + let now = inst.current_block(); + let remainder_end_block = now + T::RemainderFundingDuration::get(); + let insertion_block_number = remainder_end_block + 1u32.into(); + + fill_projects_to_update::(x, insertion_block_number, None); + #[block] - {} + { + Pallet::::do_remainder_funding(project_id).unwrap() + } + + // * validity checks * + // Storage + let stored_details = ProjectsDetails::::get(project_id).unwrap(); + assert_eq!(stored_details.status, ProjectStatus::RemainderRound); + + // Events + let current_block = inst.current_block(); + frame_system::Pallet::::assert_last_event(Event::::RemainderFundingStarted { project_id }.into()); } // do_end_funding @@ -3514,5 +3557,12 @@ mod benchmarks { assert_ok!(PalletFunding::::test_start_community_funding_success()); }); } + + #[test] + fn bench_start_remainder_funding() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_start_remainder_funding()); + }); + } } } diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 43b76b2c9..4c7d1646a 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -565,7 +565,7 @@ impl Pallet { }) }, Err(e) => return Err(DispatchErrorWithPostInfo { post_info: ().into(), error: e }), - Ok(()) => { + Ok((accepted_bids_count, rejected_bids_count)) => { // Get info again after updating it with new price. project_details.phase_transition_points.random_candle_ending = Some(end_block); project_details @@ -587,7 +587,11 @@ impl Pallet { Self::deposit_event(Event::CommunityFundingStarted { project_id }); Ok(PostDispatchInfo { - actual_weight: Some(WeightInfoOf::::start_community_funding_success(insertion_iterations)), + actual_weight: Some(WeightInfoOf::::start_community_funding_success( + insertion_iterations, + accepted_bids_count, + rejected_bids_count, + )), pays_fee: Pays::Yes, }) }, @@ -638,8 +642,7 @@ impl Pallet { project_details.status = ProjectStatus::RemainderRound; ProjectsDetails::::insert(project_id, project_details); // Schedule for automatic transition by `on_initialize` - // TODO: return real weights - let _iterations = + let insertion_iterations = match Self::add_to_update_store(remainder_end_block + 1u32.into(), (&project_id, UpdateType::FundingEnd)) { Ok(iterations) => iterations, Err(_iterations) => return Err(Error::::TooManyInsertionAttempts.into()), @@ -2689,15 +2692,21 @@ impl Pallet { project_id: ProjectId, end_block: BlockNumberFor, total_allocation_size: BalanceOf, - ) -> DispatchResult { + ) -> Result<(u32, u32), DispatchError> { // Get all the bids that were made before the end of the candle let mut bids = Bids::::iter_prefix_values((project_id,)).collect::>(); + let debug_total_bids = bids.len() as u32; // temp variable to store the sum of the bids let mut bid_token_amount_sum = Zero::zero(); // temp variable to store the total value of the bids (i.e price * amount = Cumulative Ticket Size) let mut bid_usd_value_sum = BalanceOf::::zero(); let project_account = Self::fund_account_id(project_id); let plmc_price = T::PriceProvider::get_price(PLMC_STATEMINT_ID).ok_or(Error::::PLMCPriceNotAvailable)?; + + // Weight calculation variables + let mut accepted_bids_count = 0u32; + let mut rejected_bids_count = 0u32; + // sort bids by price, and equal prices sorted by id bids.sort_by(|a, b| b.cmp(a)); // accept only bids that were made before `end_block` i.e end of candle auction @@ -2705,19 +2714,23 @@ impl Pallet { .into_iter() .map(|mut bid| { if bid.when > end_block { + rejected_bids_count += 1; return Self::refund_bid(&mut bid, project_id, &project_account, RejectionReason::AfterCandleEnd) .and(Ok(bid)) } let buyable_amount = total_allocation_size.saturating_sub(bid_token_amount_sum); if buyable_amount.is_zero() { + rejected_bids_count += 1; return Self::refund_bid(&mut bid, project_id, &project_account, RejectionReason::NoTokensLeft) .and(Ok(bid)) } else if bid.original_ct_amount <= buyable_amount { + accepted_bids_count += 1; let ticket_size = bid.original_ct_usd_price.saturating_mul_int(bid.original_ct_amount); bid_token_amount_sum.saturating_accrue(bid.original_ct_amount); bid_usd_value_sum.saturating_accrue(ticket_size); bid.status = BidStatus::Accepted; } else { + accepted_bids_count += 1; let ticket_size = bid.original_ct_usd_price.saturating_mul_int(buyable_amount); bid_usd_value_sum.saturating_accrue(ticket_size); bid_token_amount_sum.saturating_accrue(buyable_amount); @@ -2867,7 +2880,9 @@ impl Pallet { } })?; - Ok(()) + #[cfg(test)] + assert_eq!(accepted_bids_count + rejected_bids_count, debug_total_bids); + Ok((accepted_bids_count, rejected_bids_count)) } /// Refund a bid because of `reason`. From 1825e0827204545a56ec40b02b6ec76ad0eb2c81 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 6 Feb 2024 17:08:03 +0100 Subject: [PATCH 193/212] project decision weights generated Signed-off-by: Juan Ignacio Rios --- debug_weight_gen.rs | 33 +++-- pallets/funding/src/benchmarking.rs | 210 ++++++++++++++++++++++++++-- pallets/funding/src/functions.rs | 57 ++++++-- pallets/funding/src/lib.rs | 24 +++- pallets/funding/src/weights.rs | 168 ++++++++++++++++++++++ 5 files changed, 451 insertions(+), 41 deletions(-) diff --git a/debug_weight_gen.rs b/debug_weight_gen.rs index 75807b6cc..ee03b16d2 100644 --- a/debug_weight_gen.rs +++ b/debug_weight_gen.rs @@ -15,7 +15,7 @@ // --steps=20 // --repeat=10 // --pallet=pallet_funding -// --extrinsic=start_remainder_funding +// --extrinsic=project_decision_reject_funding, project_decision_accept_funding // --output // ./debug_weight_gen.rs @@ -32,21 +32,30 @@ pub struct WeightInfo(PhantomData); impl pallet_funding::WeightInfo for WeightInfo { /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn start_remainder_funding(x: u32, ) -> Weight { + fn project_decision_accept_funding() -> Weight { // Proof Size summary in bytes: - // Measured: `510 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 242_000_000 picoseconds. - Weight::from_parts(227_535_753, 0) + // Measured: `535` + // Estimated: `4087` + // Minimum execution time: 200_000_000 picoseconds. + Weight::from_parts(207_000_000, 0) + .saturating_add(Weight::from_parts(0, 4087)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + fn project_decision_reject_funding() -> Weight { + // Proof Size summary in bytes: + // Measured: `535` + // Estimated: `4087` + // Minimum execution time: 200_000_000 picoseconds. + Weight::from_parts(203_000_000, 0) .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 174_777 - .saturating_add(Weight::from_parts(37_767_357, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) } } diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 417b821e6..baafd48a7 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -2405,7 +2405,7 @@ mod benchmarks { } #[benchmark] - fn decide_project_outcome_manually( + fn decide_project_outcome( // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the extrinsic pass x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, // Total amount of storage items iterated through in `ProjectsToUpdate` when trying to remove our project in `remove_from_update_store`. @@ -2421,14 +2421,13 @@ mod benchmarks { inst.advance_time(time_advance.into()).unwrap(); let issuer = account::>("issuer", 0, 0); - let evaluations = default_evaluations::(); - let evaluator = evaluations[0].account.clone(); - whitelist_account!(evaluator); + whitelist_account!(issuer); let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); let target_funding_amount: BalanceOf = project_metadata.minimum_price.saturating_mul_int(project_metadata.total_allocation_size.0); + let evaluations = default_evaluations::(); let bids = BenchInstantiator::generate_bids_from_total_usd( Percent::from_percent(40) * target_funding_amount, 1u128.into(), @@ -3223,7 +3222,7 @@ mod benchmarks { #[block] { - Pallet::::do_remainder_funding(project_id).unwrap() + Pallet::::do_remainder_funding(project_id).unwrap(); } // * validity checks * @@ -3245,16 +3244,177 @@ mod benchmarks { // do_project_decision #[benchmark] - fn decide_project_outcome_automatically() { + fn project_decision_accept_funding() { + // setup + let mut inst = BenchInstantiator::::new(None); + + let issuer = account::>("issuer", 0, 0); + + let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); + let target_funding_amount: BalanceOf = project_metadata + .minimum_price + .saturating_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1); + let manual_outcome_threshold = Percent::from_percent(50); + + let bids: Vec> = BenchInstantiator::generate_bids_from_total_usd( + (manual_outcome_threshold * target_funding_amount) / 2.into(), + project_metadata.minimum_price, + default_weights(), + default_bidders::(), + default_bidder_multipliers(), + ); + let contributions = BenchInstantiator::generate_contributions_from_total_usd( + (manual_outcome_threshold * target_funding_amount) / 2.into(), + BenchInstantiator::calculate_price_from_test_bids(bids.clone()), + default_weights(), + default_contributors::(), + default_community_contributor_multipliers(), + ); + + let project_id = inst.create_finished_project( + project_metadata, + issuer.clone(), + default_evaluations::(), + bids, + contributions, + vec![], + ); + + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AwaitingProjectDecision); + #[block] - {} + { + Pallet::::do_project_decision(project_id, FundingOutcomeDecision::AcceptFunding); + } + + // * validity checks * + let project_details = inst.get_project_details(project_id); + assert_eq!(project_details.status, ProjectStatus::FundingSuccessful); + } + + #[benchmark] + fn project_decision_reject_funding() { + // setup + let mut inst = BenchInstantiator::::new(None); + + let issuer = account::>("issuer", 0, 0); + + let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); + let target_funding_amount: BalanceOf = project_metadata + .minimum_price + .saturating_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1); + let manual_outcome_threshold = Percent::from_percent(50); + + let bids: Vec> = BenchInstantiator::generate_bids_from_total_usd( + (manual_outcome_threshold * target_funding_amount) / 2.into(), + project_metadata.minimum_price, + default_weights(), + default_bidders::(), + default_bidder_multipliers(), + ); + let contributions = BenchInstantiator::generate_contributions_from_total_usd( + (manual_outcome_threshold * target_funding_amount) / 2.into(), + BenchInstantiator::calculate_price_from_test_bids(bids.clone()), + default_weights(), + default_contributors::(), + default_community_contributor_multipliers(), + ); + + let project_id = inst.create_finished_project( + project_metadata, + issuer.clone(), + default_evaluations::(), + bids, + contributions, + vec![], + ); + + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AwaitingProjectDecision); + + #[block] + { + Pallet::::do_project_decision(project_id, FundingOutcomeDecision::RejectFunding); + } + + // * validity checks * + let project_details = inst.get_project_details(project_id); + assert_eq!(project_details.status, ProjectStatus::FundingFailed); } // do_start_settlement #[benchmark] - fn start_settlement() { + fn start_settlement_funding_success() { + // setup + let mut inst = BenchInstantiator::::new(None); + + let issuer = account::>("issuer", 0, 0); + + let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); + let project_id = inst.create_finished_project( + project_metadata, + issuer.clone(), + default_evaluations::(), + default_bids::(), + default_community_contributions::(), + vec![], + ); + + #[block] + { + Pallet::::do_start_settlement(project_id); + } + + // * validity checks * + let project_details = inst.get_project_details(project_id); + assert_eq!(project_details.cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData))); + } + + #[benchmark] + fn start_settlement_funding_failure() { + // setup + let mut inst = BenchInstantiator::::new(None); + + let issuer = account::>("issuer", 0, 0); + + let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); + let target_funding_amount: BalanceOf = project_metadata + .minimum_price + .saturating_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1); + + let bids: Vec> = BenchInstantiator::generate_bids_from_total_usd( + Percent::from_percent(15) * target_funding_amount, + 10u128.into(), + default_weights(), + default_bidders::(), + default_bidder_multipliers(), + ); + let contributions = BenchInstantiator::generate_contributions_from_total_usd( + Percent::from_percent(10) * target_funding_amount, + BenchInstantiator::calculate_price_from_test_bids(bids.clone()), + default_weights(), + default_contributors::(), + default_community_contributor_multipliers(), + ); + + let project_id = inst.create_finished_project( + project_metadata, + issuer.clone(), + default_evaluations::(), + bids, + contributions, + vec![], + ); + + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingFailed); + #[block] - {} + { + Pallet::::do_start_settlement(project_id); + } + + // * validity checks * + let project_details = inst.get_project_details(project_id); + assert_eq!(project_details.cleanup, Cleaner::Failure(CleanerState::Initialized(PhantomData))); } #[macro_export] @@ -3488,9 +3648,9 @@ mod benchmarks { } #[test] - fn bench_decide_project_outcome_manually() { + fn bench_decide_project_outcome() { new_test_ext().execute_with(|| { - assert_ok!(PalletFunding::::test_decide_project_outcome_manually()); + assert_ok!(PalletFunding::::test_decide_project_outcome()); }); } @@ -3564,5 +3724,33 @@ mod benchmarks { assert_ok!(PalletFunding::::test_start_remainder_funding()); }); } + + #[test] + fn bench_start_settlement_funding_success() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_start_settlement_funding_success()); + }); + } + + #[test] + fn bench_start_settlement_funding_failure() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_start_settlement_funding_failure()); + }); + } + + #[test] + fn bench_project_decision_accept_funding() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_project_decision_accept_funding()); + }); + } + + #[test] + fn bench_project_decision_reject_funding() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_project_decision_reject_funding()); + }); + } } } diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 4c7d1646a..5924e3a9d 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -619,7 +619,7 @@ impl Pallet { /// Any users can now buy tokens at the price set on the auction round. /// Later on, `on_initialize` ends the remainder round, and finalizes the project funding, by calling /// [`do_end_funding`](Self::do_end_funding). - pub fn do_remainder_funding(project_id: ProjectId) -> DispatchResult { + pub fn do_remainder_funding(project_id: ProjectId) -> DispatchResultWithPostInfo { // * Get variables * let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let now = >::block_number(); @@ -651,7 +651,10 @@ impl Pallet { // * Emit events * Self::deposit_event(Event::RemainderFundingStarted { project_id }); - Ok(()) + Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::start_remainder_funding(insertion_iterations)), + pays_fee: Pays::Yes, + }) } /// Called automatically by on_initialize @@ -683,7 +686,7 @@ impl Pallet { /// * Bonded plmc with [`vested_plmc_purchase_unbond_for`](Self::vested_plmc_purchase_unbond_for) /// /// If **unsuccessful**, users every user should have their PLMC vesting unbonded. - pub fn do_end_funding(project_id: ProjectId) -> DispatchResult { + pub fn do_end_funding(project_id: ProjectId) -> DispatchResultWithPostInfo { // * Get variables * let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; @@ -715,7 +718,16 @@ impl Pallet { // * Update Storage * if funding_ratio <= Perquintill::from_percent(33u64) { project_details.evaluation_round_info.evaluators_outcome = EvaluatorsOutcome::Slashed; - Self::make_project_funding_fail(project_id, project_details, FailureReason::TargetNotReached, 1u32.into()) + let result = Self::make_project_funding_fail( + project_id, + project_details, + FailureReason::TargetNotReached, + 1u32.into(), + ); + return Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::end_funding_failure()), + pays_fee: Pays::Yes, + }) } else if funding_ratio <= Perquintill::from_percent(75u64) { project_details.evaluation_round_info.evaluators_outcome = EvaluatorsOutcome::Slashed; project_details.status = ProjectStatus::AwaitingProjectDecision; @@ -728,7 +740,10 @@ impl Pallet { Err(_iterations) => return Err(Error::::TooManyInsertionAttempts.into()), }; ProjectsDetails::::insert(project_id, project_details); - Ok(()) + Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::end_funding_awaiting_decision()), + pays_fee: Pays::Yes, + }) } else if funding_ratio < Perquintill::from_percent(90u64) { project_details.evaluation_round_info.evaluators_outcome = EvaluatorsOutcome::Unchanged; project_details.status = ProjectStatus::AwaitingProjectDecision; @@ -741,20 +756,27 @@ impl Pallet { Err(_iterations) => return Err(Error::::TooManyInsertionAttempts.into()), }; ProjectsDetails::::insert(project_id, project_details); - Ok(()) + Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::end_funding_awaiting_decision()), + pays_fee: Pays::Yes, + }) } else { let reward_info = Self::generate_evaluator_rewards_info(project_id)?; project_details.evaluation_round_info.evaluators_outcome = EvaluatorsOutcome::Rewarded(reward_info); - Self::make_project_funding_successful( + let result = Self::make_project_funding_successful( project_id, project_details, SuccessReason::ReachedTarget, T::SuccessToSettlementTime::get(), - ) + ); + return Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::end_funding_success()), + pays_fee: Pays::Yes, + }) } } - pub fn do_project_decision(project_id: ProjectId, decision: FundingOutcomeDecision) -> DispatchResult { + pub fn do_project_decision(project_id: ProjectId, decision: FundingOutcomeDecision) -> DispatchResultWithPostInfo { // * Get variables * let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; @@ -778,10 +800,10 @@ impl Pallet { }, } - Ok(()) + Ok(PostDispatchInfo { actual_weight: Some(WeightInfoOf::::project_decision()), pays_fee: Pays::Yes }) } - pub fn do_start_settlement(project_id: ProjectId) -> DispatchResult { + pub fn do_start_settlement(project_id: ProjectId) -> DispatchResultWithPostInfo { // * Get variables * let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let token_information = @@ -801,7 +823,6 @@ impl Pallet { project_details.funding_end_block = Some(now); // * Update storage * - ProjectsDetails::::insert(project_id, &project_details); if project_details.status == ProjectStatus::FundingSuccessful { @@ -813,9 +834,17 @@ impl Pallet { token_information.symbol.into(), token_information.decimals, )?; - } - Ok(()) + Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::start_settlement_funding_success()), + pays_fee: Pays::Yes, + }) + } else { + Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::start_settlement_funding_failure()), + pays_fee: Pays::Yes, + }) + } } } diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index b874435cf..9b20e96f2 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1309,20 +1309,36 @@ pub mod pallet { // CommunityRound -> RemainderRound UpdateType::RemainderFundingStart => { - unwrap_result_or_skip!(Self::do_remainder_funding(project_id), project_id, |e| e) + unwrap_result_or_skip!( + Self::do_remainder_funding(project_id), + project_id, + |e: DispatchErrorWithPostInfo| { e.error } + ); }, // CommunityRound || RemainderRound -> FundingEnded UpdateType::FundingEnd => { - unwrap_result_or_skip!(Self::do_end_funding(project_id), project_id, |e| e) + unwrap_result_or_skip!( + Self::do_end_funding(project_id), + project_id, + |e: DispatchErrorWithPostInfo| { e.error } + ); }, UpdateType::ProjectDecision(decision) => { - unwrap_result_or_skip!(Self::do_project_decision(project_id, decision), project_id, |e| e) + unwrap_result_or_skip!( + Self::do_project_decision(project_id, decision), + project_id, + |e: DispatchErrorWithPostInfo| { e.error } + ); }, UpdateType::StartSettlement => { - unwrap_result_or_skip!(Self::do_start_settlement(project_id), project_id, |e| e) + unwrap_result_or_skip!( + Self::do_start_settlement(project_id), + project_id, + |e: DispatchErrorWithPostInfo| { e.error } + ); }, } } diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index 3313c7a0d..34f073504 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -107,6 +107,32 @@ pub trait WeightInfo { /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. fn start_community_funding_failure(x: u32, ) -> Weight; + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_remainder_funding(x: u32, ) -> Weight; + fn end_funding_success() -> Weight; + fn end_funding_failure() -> Weight; + fn end_funding_awaiting_decision() -> Weight; + fn project_decision() -> Weight; + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Metadata` (r:1 w:0) + /// Proof: `LocalAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn start_settlement_funding_success() -> Weight; + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + fn start_settlement_funding_failure() -> Weight; } /// Weights for `pallet_funding` using the Substrate node and recommended hardware. @@ -1006,6 +1032,77 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(3)) } + + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_remainder_funding(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `510 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 242_000_000 picoseconds. + Weight::from_parts(227_535_753, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 174_777 + .saturating_add(Weight::from_parts(37_767_357, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + } + + fn end_funding_success() -> Weight { + Weight::from_parts(227_535_753, 0) + } + + fn end_funding_failure() -> Weight { + Weight::from_parts(227_535_753, 0) + } + + fn end_funding_awaiting_decision() -> Weight { + Weight::from_parts(227_535_753, 0) + } + + fn project_decision() -> Weight { + Weight::from_parts(227_535_753, 0) + } + + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Metadata` (r:1 w:0) + /// Proof: `LocalAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn start_settlement_funding_success() -> Weight { + // Proof Size summary in bytes: + // Measured: `933` + // Estimated: `3814` + // Minimum execution time: 447_000_000 picoseconds. + Weight::from_parts(457_000_000, 0) + .saturating_add(Weight::from_parts(0, 3814)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + fn start_settlement_funding_failure() -> Weight { + // Proof Size summary in bytes: + // Measured: `760` + // Estimated: `3814` + // Minimum execution time: 130_000_000 picoseconds. + Weight::from_parts(136_000_000, 0) + .saturating_add(Weight::from_parts(0, 3814)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } } // For backwards compatibility and tests. @@ -1908,4 +2005,75 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(8)) .saturating_add(RocksDbWeight::get().writes(3)) } + + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_remainder_funding(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `510 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 242_000_000 picoseconds. + Weight::from_parts(227_535_753, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 174_777 + .saturating_add(Weight::from_parts(37_767_357, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + } + + fn end_funding_success() -> Weight { + Weight::from_parts(227_535_753, 0) + } + + fn end_funding_failure() -> Weight { + Weight::from_parts(227_535_753, 0) + } + + fn end_funding_awaiting_decision() -> Weight { + Weight::from_parts(227_535_753, 0) + } + + fn project_decision() -> Weight { + Weight::from_parts(227_535_753, 0) + } + + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Metadata` (r:1 w:0) + /// Proof: `LocalAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn start_settlement_funding_success() -> Weight { + // Proof Size summary in bytes: + // Measured: `933` + // Estimated: `3814` + // Minimum execution time: 447_000_000 picoseconds. + Weight::from_parts(457_000_000, 0) + .saturating_add(Weight::from_parts(0, 3814)) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(3)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + fn start_settlement_funding_failure() -> Weight { + // Proof Size summary in bytes: + // Measured: `760` + // Estimated: `3814` + // Minimum execution time: 130_000_000 picoseconds. + Weight::from_parts(136_000_000, 0) + .saturating_add(Weight::from_parts(0, 3814)) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(1)) + } } \ No newline at end of file From 2ed5f598713bd6b6891cd8304a57a90b19f1da4c Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 6 Feb 2024 17:30:22 +0100 Subject: [PATCH 194/212] end_funding benches written. Missing complexity parameters Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 239 +++++++++++++++++++++++++++- pallets/funding/src/functions.rs | 10 +- pallets/funding/src/weights.rs | 73 ++++++++- 3 files changed, 310 insertions(+), 12 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index baafd48a7..5539c1468 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -3237,9 +3237,214 @@ mod benchmarks { // do_end_funding #[benchmark] - fn end_funding() { + fn end_funding_automatically_rejected_evaluators_slashed() { + // setup + let mut inst = BenchInstantiator::::new(None); + + let issuer = account::>("issuer", 0, 0); + + let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); + let target_funding_amount: BalanceOf = project_metadata + .minimum_price + .saturating_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1); + + let automatically_rejected_threshold = Percent::from_percent(33); + + let bids: Vec> = BenchInstantiator::generate_bids_from_total_usd( + (automatically_rejected_threshold * target_funding_amount) / 2.into(), + project_metadata.minimum_price, + default_weights(), + default_bidders::(), + default_bidder_multipliers(), + ); + let contributions = BenchInstantiator::generate_contributions_from_total_usd( + (automatically_rejected_threshold * target_funding_amount) / 2.into(), + BenchInstantiator::calculate_price_from_test_bids(bids.clone()), + default_weights(), + default_contributors::(), + default_community_contributor_multipliers(), + ); + + let (project_id, _) = inst.create_remainder_contributing_project( + project_metadata, + issuer.clone(), + default_evaluations::(), + bids, + contributions, + ); + + let project_details = inst.get_project_details(project_id); + assert_eq!(project_details.status, ProjectStatus::RemainderRound); + let last_funding_block = project_details.phase_transition_points.remainder.end().unwrap(); + + frame_system::Pallet::::set_block_number(last_funding_block + 1u32.into()); + #[block] - {} + { + Pallet::::do_end_funding(project_id).unwrap(); + } + + // * validity checks * + let project_details = inst.get_project_details(project_id); + assert_eq!(project_details.status, ProjectStatus::FundingFailed); + } + #[benchmark] + fn end_funding_awaiting_decision_evaluators_slashed() { + // setup + let mut inst = BenchInstantiator::::new(None); + + let issuer = account::>("issuer", 0, 0); + + let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); + let target_funding_amount: BalanceOf = project_metadata + .minimum_price + .saturating_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1); + + let automatically_rejected_threshold = Percent::from_percent(75); + + let bids: Vec> = BenchInstantiator::generate_bids_from_total_usd( + (automatically_rejected_threshold * target_funding_amount) / 2.into(), + project_metadata.minimum_price, + default_weights(), + default_bidders::(), + default_bidder_multipliers(), + ); + let contributions = BenchInstantiator::generate_contributions_from_total_usd( + (automatically_rejected_threshold * target_funding_amount) / 2.into(), + BenchInstantiator::calculate_price_from_test_bids(bids.clone()), + default_weights(), + default_contributors::(), + default_community_contributor_multipliers(), + ); + + let (project_id, _) = inst.create_remainder_contributing_project( + project_metadata, + issuer.clone(), + default_evaluations::(), + bids, + contributions, + ); + + let project_details = inst.get_project_details(project_id); + assert_eq!(project_details.status, ProjectStatus::RemainderRound); + let last_funding_block = project_details.phase_transition_points.remainder.end().unwrap(); + + frame_system::Pallet::::set_block_number(last_funding_block + 1u32.into()); + + #[block] + { + Pallet::::do_end_funding(project_id).unwrap(); + } + + // * validity checks * + let project_details = inst.get_project_details(project_id); + assert_eq!(project_details.status, ProjectStatus::AwaitingProjectDecision); + assert_eq!(project_details.evaluation_round_info.evaluators_outcome, EvaluatorsOutcome::Slashed) + } + #[benchmark] + fn end_funding_awaiting_decision_evaluators_unchanged() { + // setup + let mut inst = BenchInstantiator::::new(None); + + let issuer = account::>("issuer", 0, 0); + + let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); + let target_funding_amount: BalanceOf = project_metadata + .minimum_price + .saturating_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1); + + let automatically_rejected_threshold = Percent::from_percent(89); + + let bids: Vec> = BenchInstantiator::generate_bids_from_total_usd( + (automatically_rejected_threshold * target_funding_amount) / 2.into(), + project_metadata.minimum_price, + default_weights(), + default_bidders::(), + default_bidder_multipliers(), + ); + let contributions = BenchInstantiator::generate_contributions_from_total_usd( + (automatically_rejected_threshold * target_funding_amount) / 2.into(), + BenchInstantiator::calculate_price_from_test_bids(bids.clone()), + default_weights(), + default_contributors::(), + default_community_contributor_multipliers(), + ); + + let (project_id, _) = inst.create_remainder_contributing_project( + project_metadata, + issuer.clone(), + default_evaluations::(), + bids, + contributions, + ); + + let project_details = inst.get_project_details(project_id); + assert_eq!(project_details.status, ProjectStatus::RemainderRound); + let last_funding_block = project_details.phase_transition_points.remainder.end().unwrap(); + + frame_system::Pallet::::set_block_number(last_funding_block + 1u32.into()); + + #[block] + { + Pallet::::do_end_funding(project_id).unwrap(); + } + + // * validity checks * + let project_details = inst.get_project_details(project_id); + assert_eq!(project_details.status, ProjectStatus::AwaitingProjectDecision); + assert_eq!(project_details.evaluation_round_info.evaluators_outcome, EvaluatorsOutcome::Unchanged) + } + #[benchmark] + fn end_funding_automatically_accepted_evaluators_rewarded() { + // setup + let mut inst = BenchInstantiator::::new(None); + + let issuer = account::>("issuer", 0, 0); + + let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); + let target_funding_amount: BalanceOf = project_metadata + .minimum_price + .saturating_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1); + + let automatically_rejected_threshold = Percent::from_percent(91); + + let bids: Vec> = BenchInstantiator::generate_bids_from_total_usd( + (automatically_rejected_threshold * target_funding_amount) / 2.into(), + project_metadata.minimum_price, + default_weights(), + default_bidders::(), + default_bidder_multipliers(), + ); + let contributions = BenchInstantiator::generate_contributions_from_total_usd( + (automatically_rejected_threshold * target_funding_amount) / 2.into(), + BenchInstantiator::calculate_price_from_test_bids(bids.clone()), + default_weights(), + default_contributors::(), + default_community_contributor_multipliers(), + ); + + let (project_id, _) = inst.create_remainder_contributing_project( + project_metadata, + issuer.clone(), + default_evaluations::(), + bids, + contributions, + ); + + let project_details = inst.get_project_details(project_id); + assert_eq!(project_details.status, ProjectStatus::RemainderRound); + let last_funding_block = project_details.phase_transition_points.remainder.end().unwrap(); + + frame_system::Pallet::::set_block_number(last_funding_block + 1u32.into()); + + #[block] + { + Pallet::::do_end_funding(project_id).unwrap(); + } + + // * validity checks * + let project_details = inst.get_project_details(project_id); + assert_eq!(project_details.status, ProjectStatus::FundingSuccessful); } // do_project_decision @@ -3383,7 +3588,7 @@ mod benchmarks { let bids: Vec> = BenchInstantiator::generate_bids_from_total_usd( Percent::from_percent(15) * target_funding_amount, - 10u128.into(), + 1u128.into(), default_weights(), default_bidders::(), default_bidder_multipliers(), @@ -3752,5 +3957,33 @@ mod benchmarks { assert_ok!(PalletFunding::::test_project_decision_reject_funding()); }); } + + #[test] + fn bench_end_funding_automatically_rejected_evaluators_slashed() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_end_funding_automatically_rejected_evaluators_slashed()); + }); + } + + #[test] + fn bench_end_funding_automatically_accepted_evaluators_rewarded() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_end_funding_automatically_accepted_evaluators_rewarded()); + }); + } + + #[test] + fn bench_end_funding_awaiting_decision_evaluators_unchanged() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_end_funding_awaiting_decision_evaluators_unchanged()); + }); + } + + #[test] + fn bench_end_funding_awaiting_decision_evaluators_slashed() { + new_test_ext().execute_with(|| { + assert_ok!(PalletFunding::::test_end_funding_awaiting_decision_evaluators_slashed()); + }); + } } } diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 5924e3a9d..46a21464d 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -789,6 +789,10 @@ impl Pallet { SuccessReason::ProjectDecision, T::SuccessToSettlementTime::get(), )?; + Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::project_decision_accept_funding()), + pays_fee: Pays::Yes, + }) }, FundingOutcomeDecision::RejectFunding => { Self::make_project_funding_fail( @@ -797,10 +801,12 @@ impl Pallet { FailureReason::ProjectDecision, T::SuccessToSettlementTime::get(), )?; + Ok(PostDispatchInfo { + actual_weight: Some(WeightInfoOf::::project_decision_reject_funding()), + pays_fee: Pays::Yes, + }) }, } - - Ok(PostDispatchInfo { actual_weight: Some(WeightInfoOf::::project_decision()), pays_fee: Pays::Yes }) } pub fn do_start_settlement(project_id: ProjectId) -> DispatchResultWithPostInfo { diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index 34f073504..0498f84bf 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -116,7 +116,6 @@ pub trait WeightInfo { fn end_funding_success() -> Weight; fn end_funding_failure() -> Weight; fn end_funding_awaiting_decision() -> Weight; - fn project_decision() -> Weight; /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) @@ -133,6 +132,16 @@ pub trait WeightInfo { /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) fn start_settlement_funding_failure() -> Weight; + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + fn project_decision_accept_funding() -> Weight; + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + fn project_decision_reject_funding() -> Weight; } /// Weights for `pallet_funding` using the Substrate node and recommended hardware. @@ -1065,9 +1074,6 @@ impl WeightInfo for SubstrateWeight { Weight::from_parts(227_535_753, 0) } - fn project_decision() -> Weight { - Weight::from_parts(227_535_753, 0) - } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) @@ -1103,6 +1109,34 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + fn project_decision_accept_funding() -> Weight { + // Proof Size summary in bytes: + // Measured: `535` + // Estimated: `4087` + // Minimum execution time: 200_000_000 picoseconds. + Weight::from_parts(207_000_000, 0) + .saturating_add(Weight::from_parts(0, 4087)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + fn project_decision_reject_funding() -> Weight { + // Proof Size summary in bytes: + // Measured: `535` + // Estimated: `4087` + // Minimum execution time: 200_000_000 picoseconds. + Weight::from_parts(203_000_000, 0) + .saturating_add(Weight::from_parts(0, 4087)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } } // For backwards compatibility and tests. @@ -2038,9 +2072,6 @@ impl WeightInfo for () { Weight::from_parts(227_535_753, 0) } - fn project_decision() -> Weight { - Weight::from_parts(227_535_753, 0) - } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) @@ -2076,4 +2107,32 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(1)) } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + fn project_decision_accept_funding() -> Weight { + // Proof Size summary in bytes: + // Measured: `535` + // Estimated: `4087` + // Minimum execution time: 200_000_000 picoseconds. + Weight::from_parts(207_000_000, 0) + .saturating_add(Weight::from_parts(0, 4087)) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + fn project_decision_reject_funding() -> Weight { + // Proof Size summary in bytes: + // Measured: `535` + // Estimated: `4087` + // Minimum execution time: 200_000_000 picoseconds. + Weight::from_parts(203_000_000, 0) + .saturating_add(Weight::from_parts(0, 4087)) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) + } } \ No newline at end of file From 8aa8cb94e80298e6254c61d54100f4451641c1c0 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 7 Feb 2024 11:55:45 +0100 Subject: [PATCH 195/212] complexity params for funding end written. Advancing blocks taking forever when having lots of evaluations. trying to find out why Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 56 +++++++++++++++++++++--- pallets/funding/src/functions.rs | 65 +++++++++++++++++----------- pallets/funding/src/instantiator.rs | 7 +++ pallets/funding/src/lib.rs | 10 ++++- pallets/funding/src/mock.rs | 1 + pallets/funding/src/tests.rs | 5 +++ pallets/funding/src/weights.rs | 67 ++++++++++++++++------------- runtimes/testnet/src/lib.rs | 1 + 8 files changed, 151 insertions(+), 61 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 5539c1468..38a6288d2 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -3237,7 +3237,10 @@ mod benchmarks { // do_end_funding #[benchmark] - fn end_funding_automatically_rejected_evaluators_slashed() { + fn end_funding_automatically_rejected_evaluators_slashed( + // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the fn succeed + x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, + ) { // setup let mut inst = BenchInstantiator::::new(None); @@ -3279,6 +3282,9 @@ mod benchmarks { frame_system::Pallet::::set_block_number(last_funding_block + 1u32.into()); + let insertion_block_number = inst.current_block() + 1u32.into(); + fill_projects_to_update::(x, insertion_block_number, None); + #[block] { Pallet::::do_end_funding(project_id).unwrap(); @@ -3289,7 +3295,10 @@ mod benchmarks { assert_eq!(project_details.status, ProjectStatus::FundingFailed); } #[benchmark] - fn end_funding_awaiting_decision_evaluators_slashed() { + fn end_funding_awaiting_decision_evaluators_slashed( + // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the fn succeed + x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, + ) { // setup let mut inst = BenchInstantiator::::new(None); @@ -3331,6 +3340,9 @@ mod benchmarks { frame_system::Pallet::::set_block_number(last_funding_block + 1u32.into()); + let insertion_block_number = inst.current_block() + T::ManualAcceptanceDuration::get().into() + 1u32.into(); + fill_projects_to_update::(x, insertion_block_number, None); + #[block] { Pallet::::do_end_funding(project_id).unwrap(); @@ -3342,7 +3354,10 @@ mod benchmarks { assert_eq!(project_details.evaluation_round_info.evaluators_outcome, EvaluatorsOutcome::Slashed) } #[benchmark] - fn end_funding_awaiting_decision_evaluators_unchanged() { + fn end_funding_awaiting_decision_evaluators_unchanged( + // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the fn succeed + x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, + ) { // setup let mut inst = BenchInstantiator::::new(None); @@ -3384,6 +3399,9 @@ mod benchmarks { frame_system::Pallet::::set_block_number(last_funding_block + 1u32.into()); + let insertion_block_number = inst.current_block() + T::ManualAcceptanceDuration::get().into() + 1u32.into(); + fill_projects_to_update::(x, insertion_block_number, None); + #[block] { Pallet::::do_end_funding(project_id).unwrap(); @@ -3395,9 +3413,14 @@ mod benchmarks { assert_eq!(project_details.evaluation_round_info.evaluators_outcome, EvaluatorsOutcome::Unchanged) } #[benchmark] - fn end_funding_automatically_accepted_evaluators_rewarded() { + fn end_funding_automatically_accepted_evaluators_rewarded( + // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the fn succeed + x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, + y: Linear<1, { ::MaxEvaluationsPerProject::get() }>, + ) { // setup let mut inst = BenchInstantiator::::new(None); + println!("here"); let issuer = account::>("issuer", 0, 0); @@ -3408,6 +3431,26 @@ mod benchmarks { let automatically_rejected_threshold = Percent::from_percent(91); + let mut evaluations = (0..y.saturating_sub(1)) + .map(|i| { + UserToUSDBalance::::new(account::>("evaluator", 0, i), (10u128 * ASSET_UNIT).into()) + }) + .collect_vec(); + + let evaluation_target_usd = ::EvaluationSuccessThreshold::get() * target_funding_amount; + evaluations.push(UserToUSDBalance::::new( + account::>("evaluator_success", 0, 69420), + evaluation_target_usd, + )); + + let plmc_needed_for_evaluating = BenchInstantiator::::calculate_evaluation_plmc_spent(evaluations.clone()); + let plmc_ed = evaluations.accounts().existential_deposits(); + let plmc_ct_account_deposit = evaluations.accounts().ct_account_deposits(); + + inst.mint_plmc_to(plmc_needed_for_evaluating); + inst.mint_plmc_to(plmc_ed); + inst.mint_plmc_to(plmc_ct_account_deposit); + let bids: Vec> = BenchInstantiator::generate_bids_from_total_usd( (automatically_rejected_threshold * target_funding_amount) / 2.into(), project_metadata.minimum_price, @@ -3426,7 +3469,7 @@ mod benchmarks { let (project_id, _) = inst.create_remainder_contributing_project( project_metadata, issuer.clone(), - default_evaluations::(), + evaluations, bids, contributions, ); @@ -3437,6 +3480,9 @@ mod benchmarks { frame_system::Pallet::::set_block_number(last_funding_block + 1u32.into()); + let insertion_block_number = inst.current_block() + T::SuccessToSettlementTime::get().into(); + fill_projects_to_update::(x, insertion_block_number, None); + #[block] { Pallet::::do_end_funding(project_id).unwrap(); diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 46a21464d..299633bb9 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -718,21 +718,22 @@ impl Pallet { // * Update Storage * if funding_ratio <= Perquintill::from_percent(33u64) { project_details.evaluation_round_info.evaluators_outcome = EvaluatorsOutcome::Slashed; - let result = Self::make_project_funding_fail( + let insertion_iterations = Self::make_project_funding_fail( project_id, project_details, FailureReason::TargetNotReached, 1u32.into(), - ); + )?; return Ok(PostDispatchInfo { - actual_weight: Some(WeightInfoOf::::end_funding_failure()), + actual_weight: Some(WeightInfoOf::::end_funding_automatically_rejected_evaluators_slashed( + insertion_iterations, + )), pays_fee: Pays::Yes, }) } else if funding_ratio <= Perquintill::from_percent(75u64) { project_details.evaluation_round_info.evaluators_outcome = EvaluatorsOutcome::Slashed; project_details.status = ProjectStatus::AwaitingProjectDecision; - // TODO: return real weights - let _iterations = match Self::add_to_update_store( + let insertion_iterations = match Self::add_to_update_store( now + T::ManualAcceptanceDuration::get() + 1u32.into(), (&project_id, UpdateType::ProjectDecision(FundingOutcomeDecision::AcceptFunding)), ) { @@ -741,14 +742,15 @@ impl Pallet { }; ProjectsDetails::::insert(project_id, project_details); Ok(PostDispatchInfo { - actual_weight: Some(WeightInfoOf::::end_funding_awaiting_decision()), + actual_weight: Some(WeightInfoOf::::end_funding_awaiting_decision_evaluators_slashed( + insertion_iterations, + )), pays_fee: Pays::Yes, }) } else if funding_ratio < Perquintill::from_percent(90u64) { project_details.evaluation_round_info.evaluators_outcome = EvaluatorsOutcome::Unchanged; project_details.status = ProjectStatus::AwaitingProjectDecision; - // TODO: return real weights - let _iterations = match Self::add_to_update_store( + let insertion_iterations = match Self::add_to_update_store( now + T::ManualAcceptanceDuration::get() + 1u32.into(), (&project_id, UpdateType::ProjectDecision(FundingOutcomeDecision::AcceptFunding)), ) { @@ -757,20 +759,25 @@ impl Pallet { }; ProjectsDetails::::insert(project_id, project_details); Ok(PostDispatchInfo { - actual_weight: Some(WeightInfoOf::::end_funding_awaiting_decision()), + actual_weight: Some(WeightInfoOf::::end_funding_awaiting_decision_evaluators_unchanged( + insertion_iterations, + )), pays_fee: Pays::Yes, }) } else { - let reward_info = Self::generate_evaluator_rewards_info(project_id)?; + let (reward_info, evaluations_count) = Self::generate_evaluator_rewards_info(project_id)?; project_details.evaluation_round_info.evaluators_outcome = EvaluatorsOutcome::Rewarded(reward_info); - let result = Self::make_project_funding_successful( + let insertion_iterations = Self::make_project_funding_successful( project_id, project_details, SuccessReason::ReachedTarget, T::SuccessToSettlementTime::get(), - ); + )?; return Ok(PostDispatchInfo { - actual_weight: Some(WeightInfoOf::::end_funding_success()), + actual_weight: Some(WeightInfoOf::::end_funding_automatically_accepted_evaluators_rewarded( + insertion_iterations, + evaluations_count, + )), pays_fee: Pays::Yes, }) } @@ -894,13 +901,14 @@ impl Pallet { Ok(()) } - // Note: usd_amount needs to have the same amount of decimals as PLMC,, so when multiplied by the plmc-usd price, it gives us the PLMC amount with the decimals we wanted. + // Note: usd_amount needs to have the same amount of decimals as PLMC, so when multiplied by the plmc-usd price, it gives us the PLMC amount with the decimals we wanted. pub fn do_evaluate( evaluator: &AccountIdOf, project_id: ProjectId, usd_amount: BalanceOf, ) -> DispatchResultWithPostInfo { // * Get variables * + println!("do_evaluate {}", evaluator); let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let now = >::block_number(); let evaluation_id = Self::next_evaluation_id(); @@ -911,10 +919,12 @@ impl Pallet { T::EvaluationSuccessThreshold::get() * project_details.fundraising_target; let evaluation_round_info = &mut project_details.evaluation_round_info; let ct_deposit = T::ContributionTokenCurrency::deposit_required(project_id); + let evaluations_count = EvaluationCounts::::get(project_id); // * Validity Checks * ensure!(evaluator.clone() != project_details.issuer, Error::::ContributionToThemselves); ensure!(project_details.status == ProjectStatus::EvaluationRound, Error::::EvaluationNotStarted); + ensure!(evaluations_count < T::MaxBidsPerProject::get(), Error::::TooManyEvaluationsForProject); // * Calculate new variables * let plmc_bond = plmc_usd_price @@ -979,6 +989,7 @@ impl Pallet { T::NativeCurrency::hold(&HoldReason::Evaluation(project_id.into()).into(), evaluator, plmc_bond)?; Evaluations::::remove((project_id, evaluator, low_id)); + EvaluationCounts::::mutate(project_id, |c| *c -= 1); } Evaluations::::insert((project_id, evaluator, evaluation_id), new_evaluation); @@ -986,6 +997,7 @@ impl Pallet { evaluation_round_info.total_bonded_usd += usd_amount; evaluation_round_info.total_bonded_plmc += plmc_bond; ProjectsDetails::::insert(project_id, project_details); + EvaluationCounts::::mutate(project_id, |c| *c += 1); // * Emit events * Self::deposit_event(Event::FundsBonded { project_id, amount: plmc_bond, bonder: evaluator.clone() }); @@ -998,7 +1010,7 @@ impl Pallet { } else { WeightInfoOf::::evaluation_over_limit() }; - // + Ok(PostDispatchInfo { actual_weight: Some(actual_weight), pays_fee: Pays::Yes }) } @@ -1036,13 +1048,13 @@ impl Pallet { // * Validity checks * ensure!(ct_amount > Zero::zero(), Error::::BidTooLow); - ensure!(bid_count < T::MaxBidsPerProject::get(), Error::::TooManyBids); + ensure!(bid_count < T::MaxBidsPerProject::get(), Error::::TooManyBidsForProject); ensure!(bidder.clone() != project_details.issuer, Error::::ContributionToThemselves); ensure!(matches!(project_details.status, ProjectStatus::AuctionRound(_)), Error::::AuctionNotStarted); ensure!(funding_asset == project_metadata.participation_currencies, Error::::FundingAssetNotAccepted); // Note: We limit the CT Amount to the total allocation size, to avoid long running loops. ensure!(ct_amount <= project_metadata.total_allocation_size.0, Error::::NotAllowed); - ensure!(existing_bids.len() < T::MaxBidsPerUser::get() as usize, Error::::TooManyBids); + ensure!(existing_bids.len() < T::MaxBidsPerUser::get() as usize, Error::::TooManyBidsForUser); // Reserve plmc deposit to create a contribution token account for this project if T::NativeCurrency::balance_on_hold(&HoldReason::FutureDeposit(project_id).into(), &bidder) < ct_deposit { @@ -3072,11 +3084,13 @@ impl Pallet { /// /// Note: Consider refactoring the `RewardInfo` struct to make it more generic and /// reusable, not just for evaluator rewards. - pub fn generate_evaluator_rewards_info(project_id: ProjectId) -> Result, DispatchError> { + pub fn generate_evaluator_rewards_info(project_id: ProjectId) -> Result<(RewardInfoOf, u32), DispatchError> { // Fetching the necessary data for a specific project. let project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectNotFound)?; let project_metadata = ProjectsMetadata::::get(project_id).ok_or(Error::::ProjectNotFound)?; let evaluations = Evaluations::::iter_prefix((project_id,)).collect::>(); + // used for weight calculation + let evaluations_count = evaluations.len() as u32; // Determine how much funding has been achieved. let funding_amount_reached = project_details.funding_amount_reached; @@ -3131,7 +3145,7 @@ impl Pallet { normal_evaluator_total_bonded_usd, }; - Ok(reward_info) + Ok((reward_info, evaluations_count)) } pub fn make_project_funding_successful( @@ -3139,13 +3153,13 @@ impl Pallet { mut project_details: ProjectDetailsOf, reason: SuccessReason, settlement_delta: BlockNumberFor, - ) -> DispatchResult { + ) -> Result { let now = >::block_number(); project_details.status = ProjectStatus::FundingSuccessful; ProjectsDetails::::insert(project_id, project_details); // TODO: add real weights - let _iterations = + let insertion_iterations = match Self::add_to_update_store(now + settlement_delta, (&project_id, UpdateType::StartSettlement)) { Ok(iterations) => iterations, Err(_iterations) => return Err(Error::::TooManyInsertionAttempts.into()), @@ -3153,7 +3167,7 @@ impl Pallet { Self::deposit_event(Event::FundingEnded { project_id, outcome: FundingOutcome::Success(reason) }); - Ok(()) + Ok(insertion_iterations) } pub fn make_project_funding_fail( @@ -3161,19 +3175,18 @@ impl Pallet { mut project_details: ProjectDetailsOf, reason: FailureReason, settlement_delta: BlockNumberFor, - ) -> DispatchResult { + ) -> Result { let now = >::block_number(); project_details.status = ProjectStatus::FundingFailed; ProjectsDetails::::insert(project_id, project_details); - // TODO: add real weights - let _iterations = + let insertion_iterations = match Self::add_to_update_store(now + settlement_delta, (&project_id, UpdateType::StartSettlement)) { Ok(iterations) => iterations, Err(_iterations) => return Err(Error::::TooManyInsertionAttempts.into()), }; Self::deposit_event(Event::FundingEnded { project_id, outcome: FundingOutcome::Failure(reason) }); - Ok(()) + Ok(insertion_iterations) } pub fn migrations_per_xcm_message_allowed() -> u32 { diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 0020a01ff..a02e95a3e 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -223,7 +223,11 @@ impl< pub fn advance_time(&mut self, amount: BlockNumberFor) -> Result<(), DispatchError> { self.execute(|| { + // time performance + use std::time::Instant; + let now = Instant::now(); for _block in 0u32..amount.saturated_into() { + println!("advancing block {}/{}", _block, amount); let mut current_block = frame_system::Pallet::::block_number(); >>::on_finalize(current_block); @@ -245,6 +249,9 @@ impl< Self::err_if_on_initialize_failed(post_events)?; } } + println!("advancing {amount} blocks took {:?}", now.elapsed()); + // time per block + println!("time per block: {:?}", now.elapsed() / amount.saturated_into()); Ok(()) }) } diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 9b20e96f2..d5ad31a36 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -444,6 +444,7 @@ pub mod pallet { type MaxProjectsToUpdateInsertionAttempts: Get; /// max individual bids per project. Used to estimate worst case weight for price calculation type MaxBidsPerProject: Get; + type MaxEvaluationsPerProject: Get; } #[pallet::storage] @@ -467,6 +468,9 @@ pub mod pallet { #[pallet::storage] pub type BidCounts = StorageMap<_, Blake2_128Concat, ProjectId, u32, ValueQuery>; + #[pallet::storage] + pub type EvaluationCounts = StorageMap<_, Blake2_128Concat, ProjectId, u32, ValueQuery>; + #[pallet::storage] #[pallet::getter(fn nonce)] /// A global counter used in the randomness generation @@ -942,7 +946,11 @@ pub mod pallet { /// Too many attempts to insert project in to ProjectsToUpdate storage TooManyInsertionAttempts, /// Reached bid limit for this user on this project - TooManyBids, + TooManyBidsForUser, + /// Reached bid limit for this project + TooManyBidsForProject, + /// Reached evaluation limit for this project + TooManyEvaluationsForProject, } #[pallet::call] diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 4546a7e0a..2cef32109 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -354,6 +354,7 @@ impl Config for TestRuntime { type MaxBidsPerUser = ConstU32<4>; type MaxCapacityThresholds = MaxCapacityThresholds; type MaxContributionsPerUser = ConstU32<4>; + type MaxEvaluationsPerProject = ConstU32<2048>; type MaxEvaluationsPerUser = ConstU32<4>; type MaxMessageSizeThresholds = MaxMessageSizeThresholds; type MaxProjectsToUpdateInsertionAttempts = ConstU32<100>; diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index ccb514992..b455e00e7 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -695,6 +695,11 @@ mod evaluation_round_failure { HoldReason::FutureDeposit(project_id).into(), ); } + + #[test] + fn cannot_evaluate_more_than_project_limit() { + todo!() + } } mod auction_round_success { diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index 0498f84bf..748cca149 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -113,9 +113,12 @@ pub trait WeightInfo { /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. fn start_remainder_funding(x: u32, ) -> Weight; - fn end_funding_success() -> Weight; - fn end_funding_failure() -> Weight; - fn end_funding_awaiting_decision() -> Weight; + fn end_funding_automatically_rejected_evaluators_slashed(x: u32) -> Weight; + fn end_funding_awaiting_decision_evaluators_slashed(x: u32) -> Weight; + fn end_funding_awaiting_decision_evaluators_unchanged(x: u32) -> Weight; + fn end_funding_automatically_accepted_evaluators_rewarded(x: u32, y: u32) -> Weight; + + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) @@ -1062,19 +1065,6 @@ impl WeightInfo for SubstrateWeight { .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) } - fn end_funding_success() -> Weight { - Weight::from_parts(227_535_753, 0) - } - - fn end_funding_failure() -> Weight { - Weight::from_parts(227_535_753, 0) - } - - fn end_funding_awaiting_decision() -> Weight { - Weight::from_parts(227_535_753, 0) - } - - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) @@ -1137,6 +1127,22 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().reads(2)) .saturating_add(T::DbWeight::get().writes(2)) } + + fn end_funding_automatically_rejected_evaluators_slashed(x: u32) -> Weight { + Weight::from_parts(203_000_000, 0) + } + + fn end_funding_awaiting_decision_evaluators_slashed(x: u32) -> Weight { + Weight::from_parts(203_000_000, 0) + } + + fn end_funding_awaiting_decision_evaluators_unchanged(x: u32) -> Weight { + Weight::from_parts(203_000_000, 0) + } + + fn end_funding_automatically_accepted_evaluators_rewarded(x: u32, y: u32) -> Weight { + Weight::from_parts(203_000_000, 0) + } } // For backwards compatibility and tests. @@ -2060,19 +2066,6 @@ impl WeightInfo for () { .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) } - fn end_funding_success() -> Weight { - Weight::from_parts(227_535_753, 0) - } - - fn end_funding_failure() -> Weight { - Weight::from_parts(227_535_753, 0) - } - - fn end_funding_awaiting_decision() -> Weight { - Weight::from_parts(227_535_753, 0) - } - - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) @@ -2135,4 +2128,20 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(2)) } + + fn end_funding_automatically_rejected_evaluators_slashed(x: u32) -> Weight { + Weight::from_parts(203_000_000, 0) + } + + fn end_funding_awaiting_decision_evaluators_slashed(x: u32) -> Weight { + Weight::from_parts(203_000_000, 0) + } + + fn end_funding_awaiting_decision_evaluators_unchanged(x: u32) -> Weight { + Weight::from_parts(203_000_000, 0) + } + + fn end_funding_automatically_accepted_evaluators_rewarded(x: u32, y: u32) -> Weight { + Weight::from_parts(203_000_000, 0) + } } \ No newline at end of file diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index d580d7b68..0b249ed6d 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -574,6 +574,7 @@ impl pallet_funding::Config for Runtime { type MaxBidsPerUser = ConstU32<128>; type MaxCapacityThresholds = MaxCapacityThresholds; type MaxContributionsPerUser = ConstU32<256>; + type MaxEvaluationsPerProject = ConstU32<2048>; type MaxEvaluationsPerUser = ConstU32<256>; type MaxMessageSizeThresholds = MaxMessageSizeThresholds; type MaxProjectsToUpdateInsertionAttempts = ConstU32<100>; From 5528f29abd7be679853ca6174693eeb0df5a54a4 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 7 Feb 2024 13:36:29 +0100 Subject: [PATCH 196/212] save trying to debug time increase Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 4 ++++ pallets/funding/src/functions.rs | 3 +-- pallets/funding/src/instantiator.rs | 23 +++++++++++++++++++---- pallets/funding/src/lib.rs | 9 +++++++++ pallets/funding/src/mock.rs | 2 +- 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 38a6288d2..827bf2639 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -3416,6 +3416,7 @@ mod benchmarks { fn end_funding_automatically_accepted_evaluators_rewarded( // Insertion attempts in add_to_update_store. Total amount of storage items iterated through in `ProjectsToUpdate`. Leave one free to make the fn succeed x: Linear<1, { ::MaxProjectsToUpdateInsertionAttempts::get() - 1 }>, + // How many evaluations have been made. Used when calculating evaluator rewards y: Linear<1, { ::MaxEvaluationsPerProject::get() }>, ) { // setup @@ -3443,6 +3444,9 @@ mod benchmarks { evaluation_target_usd, )); + dbg!(y); + dbg!(evaluations.len()); + let plmc_needed_for_evaluating = BenchInstantiator::::calculate_evaluation_plmc_spent(evaluations.clone()); let plmc_ed = evaluations.accounts().existential_deposits(); let plmc_ct_account_deposit = evaluations.accounts().ct_account_deposits(); diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 299633bb9..06b9f1719 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -908,7 +908,6 @@ impl Pallet { usd_amount: BalanceOf, ) -> DispatchResultWithPostInfo { // * Get variables * - println!("do_evaluate {}", evaluator); let mut project_details = ProjectsDetails::::get(project_id).ok_or(Error::::ProjectDetailsNotFound)?; let now = >::block_number(); let evaluation_id = Self::next_evaluation_id(); @@ -924,7 +923,7 @@ impl Pallet { // * Validity Checks * ensure!(evaluator.clone() != project_details.issuer, Error::::ContributionToThemselves); ensure!(project_details.status == ProjectStatus::EvaluationRound, Error::::EvaluationNotStarted); - ensure!(evaluations_count < T::MaxBidsPerProject::get(), Error::::TooManyEvaluationsForProject); + ensure!(evaluations_count < T::MaxEvaluationsPerProject::get(), Error::::TooManyEvaluationsForProject); // * Calculate new variables * let plmc_bond = plmc_usd_price diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index a02e95a3e..cbaaef878 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -225,33 +225,48 @@ impl< self.execute(|| { // time performance use std::time::Instant; - let now = Instant::now(); + let outer_now = Instant::now(); + println!("advancing {amount} blocks"); for _block in 0u32..amount.saturated_into() { - println!("advancing block {}/{}", _block, amount); let mut current_block = frame_system::Pallet::::block_number(); + let now = Instant::now(); >>::on_finalize(current_block); + println!("AllPalletsWithoutSystem OnFinalize took {:?}", now.elapsed()); + + let now = Instant::now(); as OnFinalize>>::on_finalize(current_block); + println!("system OnFinalize took {:?}", now.elapsed()); + let now = Instant::now(); >>::on_idle(current_block, Weight::MAX); + println!("AllPalletsWithoutSystem OnIdle took {:?}", now.elapsed()); + + let now = Instant::now(); as OnIdle>>::on_idle(current_block, Weight::MAX); + println!("system OnIdle took {:?}", now.elapsed()); current_block += One::one(); frame_system::Pallet::::set_block_number(current_block); let pre_events = frame_system::Pallet::::events(); + let now = Instant::now(); as OnInitialize>>::on_initialize(current_block); + println!("system OnInitialize took {:?}", now.elapsed()); + + let now = Instant::now(); >>::on_initialize(current_block); + println!("AllPalletsWithoutSystem OnInitialize took {:?}", now.elapsed()); let post_events = frame_system::Pallet::::events(); if post_events.len() > pre_events.len() { Self::err_if_on_initialize_failed(post_events)?; } } - println!("advancing {amount} blocks took {:?}", now.elapsed()); + println!("advancing {amount} blocks took {:?}", outer_now.elapsed()); // time per block - println!("time per block: {:?}", now.elapsed() / amount.saturated_into()); + println!("time per block: {:?}", outer_now.elapsed() / amount.saturated_into()); Ok(()) }) } diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index d5ad31a36..5f27a9520 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1276,7 +1276,10 @@ pub mod pallet { impl Hooks> for Pallet { fn on_initialize(now: BlockNumberFor) -> Weight { // Get the projects that need to be updated on this block and update them + use std::time::Instant; + let time_now = Instant::now(); for (project_id, update_type) in ProjectsToUpdate::::take(now) { + println!("took something"); match update_type { // EvaluationRound -> AuctionInitializePeriod | EvaluationFailed UpdateType::EvaluationEnd => { @@ -1350,11 +1353,15 @@ pub mod pallet { }, } } + let elapsed = time_now.elapsed(); + println!("Funding on_initialize elapsed: {:?}", elapsed); // TODO: PLMC-127. Set a proper weight Weight::from_parts(0, 0) } fn on_idle(_now: BlockNumberFor, max_weight: Weight) -> Weight { + use std::time::Instant; + let now = Instant::now(); let mut remaining_weight = max_weight; let projects_needing_cleanup = ProjectsDetails::::iter() @@ -1398,6 +1405,8 @@ pub mod pallet { } } + let elapsed = now.elapsed(); + println!("Funding on_idle elapsed: {:?}", elapsed); max_weight.saturating_sub(remaining_weight) } } diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 2cef32109..c51c10187 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -354,7 +354,7 @@ impl Config for TestRuntime { type MaxBidsPerUser = ConstU32<4>; type MaxCapacityThresholds = MaxCapacityThresholds; type MaxContributionsPerUser = ConstU32<4>; - type MaxEvaluationsPerProject = ConstU32<2048>; + type MaxEvaluationsPerProject = ConstU32<4096>; type MaxEvaluationsPerUser = ConstU32<4>; type MaxMessageSizeThresholds = MaxMessageSizeThresholds; type MaxProjectsToUpdateInsertionAttempts = ConstU32<100>; From 96917b30b4e6327a06ff316528ca9273c4f00b49 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 7 Feb 2024 14:51:54 +0100 Subject: [PATCH 197/212] =?UTF-8?q?all=20benches=20passing=20and=20BLAZING?= =?UTF-8?q?=20FAST=20=F0=9F=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 72 ++++++++++++++++++++--------- pallets/funding/src/instantiator.rs | 34 ++++++++------ pallets/funding/src/lib.rs | 18 ++++---- pallets/funding/src/mock.rs | 2 +- runtimes/testnet/src/lib.rs | 2 +- 5 files changed, 80 insertions(+), 48 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 827bf2639..61809cec7 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -495,7 +495,7 @@ mod benchmarks { // We need to leave enough block numbers to fill `ProjectsToUpdate` before our project insertion let u32_remaining_vecs: u32 = y.saturating_sub(x).into(); let time_advance: u32 = 1 + u32_remaining_vecs + 1; - inst.advance_time(time_advance.into()).unwrap(); + frame_system::Pallet::::set_block_number(time_advance.into()); let issuer = account::>("issuer", 0, 0); whitelist_account!(issuer); @@ -515,7 +515,11 @@ mod benchmarks { inst.advance_time(One::one()).unwrap(); inst.bond_for_users(project_id, evaluations).expect("All evaluations are accepted"); - inst.advance_time(::EvaluationDuration::get() + One::one()).unwrap(); + let (evaluation_end_block, _) = inst.get_update_pair(project_id); + frame_system::Pallet::::set_block_number(evaluation_end_block - 1u32.into()); + inst.advance_time(2u32.into()).unwrap(); + + assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::AuctionInitializePeriod); let current_block = inst.current_block(); // `do_english_auction` fn will try to add an automatic transition 1 block after the last english round block @@ -1086,7 +1090,7 @@ mod benchmarks { let u32_remaining_vecs: u32 = z.saturating_sub(y).into(); time_advance += u32_remaining_vecs + 1; } - inst.advance_time(time_advance.into()).unwrap(); + frame_system::Pallet::::set_block_number(time_advance.into()); let issuer = account::>("issuer", 0, 0); let contributor = account::>("contributor", 0, 0); @@ -1598,7 +1602,9 @@ mod benchmarks { vec![], ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + let (settlement_block, _) = inst.get_update_pair(project_id); + frame_system::Pallet::::set_block_number(settlement_block - 1u32.into()); + inst.advance_time(1u32.into()).unwrap(); assert_eq!(inst.get_project_details(project_id).status, ProjectStatus::FundingSuccessful); assert_eq!( inst.get_project_details(project_id).cleanup, @@ -1671,7 +1677,9 @@ mod benchmarks { vec![], ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + let (update_block, _) = inst.get_update_pair(project_id); + frame_system::Pallet::::set_block_number(update_block - 1u32.into()); + inst.advance_time(One::one()).unwrap(); assert_eq!( inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData)) @@ -1744,7 +1752,9 @@ mod benchmarks { vec![], ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + let (update_block, _) = inst.get_update_pair(project_id); + frame_system::Pallet::::set_block_number(update_block - 1u32.into()); + inst.advance_time(One::one()).unwrap(); assert_eq!( inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData)) @@ -1909,7 +1919,9 @@ mod benchmarks { vec![], ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + let (update_block, _) = inst.get_update_pair(project_id); + frame_system::Pallet::::set_block_number(update_block - 1u32.into()); + inst.advance_time(One::one()).unwrap(); assert_eq!( inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData)) @@ -1974,7 +1986,9 @@ mod benchmarks { vec![], ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + let (update_block, _) = inst.get_update_pair(project_id); + frame_system::Pallet::::set_block_number(update_block - 1u32.into()); + inst.advance_time(One::one()).unwrap(); assert_eq!( inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData)) @@ -2039,7 +2053,9 @@ mod benchmarks { vec![], ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + let (update_block, _) = inst.get_update_pair(project_id); + frame_system::Pallet::::set_block_number(update_block - 1u32.into()); + inst.advance_time(One::one()).unwrap(); assert_eq!( inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData)) @@ -2119,7 +2135,9 @@ mod benchmarks { vec![], ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + let (update_block, _) = inst.get_update_pair(project_id); + frame_system::Pallet::::set_block_number(update_block - 1u32.into()); + inst.advance_time(One::one()).unwrap(); assert_eq!( inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData)) @@ -2191,7 +2209,9 @@ mod benchmarks { vec![], ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + let (update_block, _) = inst.get_update_pair(project_id); + frame_system::Pallet::::set_block_number(update_block - 1u32.into()); + inst.advance_time(One::one()).unwrap(); assert_eq!( inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData)) @@ -2246,7 +2266,9 @@ mod benchmarks { vec![], ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + let (update_block, _) = inst.get_update_pair(project_id); + frame_system::Pallet::::set_block_number(update_block - 1u32.into()); + inst.advance_time(One::one()).unwrap(); assert_eq!( inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData)) @@ -2308,7 +2330,9 @@ mod benchmarks { vec![], ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + let (update_block, _) = inst.get_update_pair(project_id); + frame_system::Pallet::::set_block_number(update_block - 1u32.into()); + inst.advance_time(One::one()).unwrap(); assert_eq!( inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData)) @@ -2361,7 +2385,9 @@ mod benchmarks { vec![], ); - inst.advance_time(::SuccessToSettlementTime::get()).unwrap(); + let (update_block, _) = inst.get_update_pair(project_id); + frame_system::Pallet::::set_block_number(update_block - 1u32.into()); + inst.advance_time(One::one()).unwrap(); assert_eq!( inst.get_project_details(project_id).cleanup, Cleaner::Success(CleanerState::Initialized(PhantomData)) @@ -2418,7 +2444,7 @@ mod benchmarks { // We need to leave enough block numbers to fill `ProjectsToUpdate` before our project insertion let u32_remaining_vecs: u32 = y.saturating_sub(x).into(); let time_advance: u32 = 1 + u32_remaining_vecs + 1; - inst.advance_time(time_advance.into()).unwrap(); + frame_system::Pallet::::set_block_number(time_advance.into()); let issuer = account::>("issuer", 0, 0); whitelist_account!(issuer); @@ -2918,7 +2944,9 @@ mod benchmarks { inst.advance_time(One::one()).unwrap(); inst.bond_for_users(project_id, evaluations).expect("All evaluations are accepted"); - inst.advance_time(::EvaluationDuration::get() + One::one()).unwrap(); + let (evaluation_end_block, _) = inst.get_update_pair(project_id); + frame_system::Pallet::::set_block_number(evaluation_end_block - 1u32.into()); + inst.advance_time(One::one()).unwrap(); let current_block = inst.current_block(); let automatic_transition_block = @@ -2929,12 +2957,11 @@ mod benchmarks { fill_projects_to_update::(x, block_number, None); - let now = inst.current_block(); - inst.advance_time(automatic_transition_block - now - One::one()).unwrap(); - let now = inst.current_block(); // we don't use advance time to avoid triggering on_initialize. This benchmark should only measure the extrinsic // weight and not the whole on_initialize call weight - frame_system::Pallet::::set_block_number(now + One::one()); + frame_system::Pallet::::set_block_number(automatic_transition_block); + + dbg!(inst.get_project_details(project_id).status); #[extrinsic_call] start_auction(RawOrigin::Signed(issuer), project_id); @@ -3156,8 +3183,9 @@ mod benchmarks { let project_id = inst.create_auctioning_project(project_metadata, issuer.clone(), default_evaluations()); // no bids are made, so the project fails - - inst.advance_time(::EnglishAuctionDuration::get() + One::one()).unwrap(); + let (update_block, _) = inst.get_update_pair(project_id); + frame_system::Pallet::::set_block_number(update_block - 1u32.into()); + inst.advance_time(One::one()).unwrap(); let auction_candle_end_block = inst.get_project_details(project_id).phase_transition_points.candle_auction.end().unwrap(); diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index cbaaef878..0edb1034b 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -909,9 +909,12 @@ impl< if project_details.status == ProjectStatus::EvaluationRound { let evaluation_end = project_details.phase_transition_points.evaluation.end().unwrap(); - let auction_start = evaluation_end.saturating_add(2u32.into()); - let blocks_to_start = auction_start.saturating_sub(self.current_block()); - self.advance_time(blocks_to_start).unwrap(); + frame_system::Pallet::::set_block_number(evaluation_end); + // run on_initialize for evaluation end + self.advance_time(1u32.into()).unwrap(); + let auction_initialize_period_start = + self.get_project_details(project_id).phase_transition_points.auction_initialize_period.start().unwrap(); + frame_system::Pallet::::set_block_number(auction_initialize_period_start); }; assert_eq!(self.get_project_details(project_id).status, ProjectStatus::AuctionInitializePeriod); @@ -979,9 +982,10 @@ impl< .end() .expect("English end point should exist"); - let candle_start = english_end + 2u32.into(); - let current_block = self.current_block(); - self.advance_time(candle_start.saturating_sub(current_block)).unwrap(); + frame_system::Pallet::::set_block_number(english_end); + // run on_initialize + self.advance_time(1u32.into()).unwrap(); + let candle_end = self .get_project_details(project_id) .phase_transition_points @@ -989,10 +993,9 @@ impl< .end() .expect("Candle end point should exist"); - let community_start = candle_end + 2u32.into(); - - let current_block = self.current_block(); - self.advance_time(community_start.saturating_sub(current_block)).unwrap(); + frame_system::Pallet::::set_block_number(candle_end); + // run on_initialize + self.advance_time(1u32.into()).unwrap(); assert_eq!(self.get_project_details(project_id).status, ProjectStatus::CommunityRound); @@ -1119,7 +1122,8 @@ impl< .expect("Community funding end point should exist"); let remainder_start = community_funding_end + 1u32.into(); let current_block = self.current_block(); - self.advance_time(remainder_start.saturating_sub(current_block)).unwrap(); + frame_system::Pallet::::set_block_number(remainder_start - One::one()); + self.advance_time(1u32.into()).unwrap(); match self.get_project_details(project_id).status { ProjectStatus::RemainderRound | ProjectStatus::FundingSuccessful => Ok(()), _ => panic!("Bad state"), @@ -1128,12 +1132,12 @@ impl< pub fn finish_funding(&mut self, project_id: ProjectId) -> Result<(), DispatchError> { let (update_block, _) = self.get_update_pair(project_id); - let current_block = self.current_block(); - self.advance_time(update_block.saturating_sub(current_block)).unwrap(); + frame_system::Pallet::::set_block_number(update_block - One::one()); + self.advance_time(1u32.into()).unwrap(); if self.get_project_details(project_id).status == ProjectStatus::RemainderRound { let (end_block, _) = self.get_update_pair(project_id); - let current_block = self.current_block(); - self.advance_time(end_block.saturating_sub(current_block)).unwrap(); + frame_system::Pallet::::set_block_number(end_block - 1u32.into()); + self.advance_time(1u32.into()).unwrap(); } let project_details = self.get_project_details(project_id); assert!( diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 5f27a9520..37c8bc258 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1276,10 +1276,10 @@ pub mod pallet { impl Hooks> for Pallet { fn on_initialize(now: BlockNumberFor) -> Weight { // Get the projects that need to be updated on this block and update them - use std::time::Instant; - let time_now = Instant::now(); + // use std::time::Instant; + // let time_now = Instant::now(); for (project_id, update_type) in ProjectsToUpdate::::take(now) { - println!("took something"); + // println!("took something"); match update_type { // EvaluationRound -> AuctionInitializePeriod | EvaluationFailed UpdateType::EvaluationEnd => { @@ -1353,15 +1353,15 @@ pub mod pallet { }, } } - let elapsed = time_now.elapsed(); - println!("Funding on_initialize elapsed: {:?}", elapsed); + // let elapsed = time_now.elapsed(); + // println!("Funding on_initialize elapsed: {:?}", elapsed); // TODO: PLMC-127. Set a proper weight Weight::from_parts(0, 0) } fn on_idle(_now: BlockNumberFor, max_weight: Weight) -> Weight { - use std::time::Instant; - let now = Instant::now(); + // use std::time::Instant; + // let now = Instant::now(); let mut remaining_weight = max_weight; let projects_needing_cleanup = ProjectsDetails::::iter() @@ -1405,8 +1405,8 @@ pub mod pallet { } } - let elapsed = now.elapsed(); - println!("Funding on_idle elapsed: {:?}", elapsed); + // let elapsed = now.elapsed(); + // println!("Funding on_idle elapsed: {:?}", elapsed); max_weight.saturating_sub(remaining_weight) } } diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index c51c10187..2cef32109 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -354,7 +354,7 @@ impl Config for TestRuntime { type MaxBidsPerUser = ConstU32<4>; type MaxCapacityThresholds = MaxCapacityThresholds; type MaxContributionsPerUser = ConstU32<4>; - type MaxEvaluationsPerProject = ConstU32<4096>; + type MaxEvaluationsPerProject = ConstU32<2048>; type MaxEvaluationsPerUser = ConstU32<4>; type MaxMessageSizeThresholds = MaxMessageSizeThresholds; type MaxProjectsToUpdateInsertionAttempts = ConstU32<100>; diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index 0b249ed6d..e72e782ca 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -575,7 +575,7 @@ impl pallet_funding::Config for Runtime { type MaxCapacityThresholds = MaxCapacityThresholds; type MaxContributionsPerUser = ConstU32<256>; type MaxEvaluationsPerProject = ConstU32<2048>; - type MaxEvaluationsPerUser = ConstU32<256>; + type MaxEvaluationsPerUser = ConstU32<16>; type MaxMessageSizeThresholds = MaxMessageSizeThresholds; type MaxProjectsToUpdateInsertionAttempts = ConstU32<100>; type MaxProjectsToUpdatePerBlock = ConstU32<100>; From b5879f1badf779c3355d39a73302261ea423ad3d Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 7 Feb 2024 15:41:20 +0100 Subject: [PATCH 198/212] comment out debug lines Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 6 ----- pallets/funding/src/instantiator.rs | 34 ++++++++++++++--------------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 61809cec7..f5946aede 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -2961,8 +2961,6 @@ mod benchmarks { // weight and not the whole on_initialize call weight frame_system::Pallet::::set_block_number(automatic_transition_block); - dbg!(inst.get_project_details(project_id).status); - #[extrinsic_call] start_auction(RawOrigin::Signed(issuer), project_id); @@ -3449,7 +3447,6 @@ mod benchmarks { ) { // setup let mut inst = BenchInstantiator::::new(None); - println!("here"); let issuer = account::>("issuer", 0, 0); @@ -3472,9 +3469,6 @@ mod benchmarks { evaluation_target_usd, )); - dbg!(y); - dbg!(evaluations.len()); - let plmc_needed_for_evaluating = BenchInstantiator::::calculate_evaluation_plmc_spent(evaluations.clone()); let plmc_ed = evaluations.accounts().existential_deposits(); let plmc_ct_account_deposit = evaluations.accounts().ct_account_deposits(); diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 0edb1034b..13cfb640c 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -224,49 +224,49 @@ impl< pub fn advance_time(&mut self, amount: BlockNumberFor) -> Result<(), DispatchError> { self.execute(|| { // time performance - use std::time::Instant; - let outer_now = Instant::now(); - println!("advancing {amount} blocks"); + // use std::time::Instant; + // let outer_now = Instant::now(); + // println!("advancing {amount} blocks"); for _block in 0u32..amount.saturated_into() { let mut current_block = frame_system::Pallet::::block_number(); - let now = Instant::now(); + // let now = Instant::now(); >>::on_finalize(current_block); - println!("AllPalletsWithoutSystem OnFinalize took {:?}", now.elapsed()); + // println!("AllPalletsWithoutSystem OnFinalize took {:?}", now.elapsed()); - let now = Instant::now(); + // let now = Instant::now(); as OnFinalize>>::on_finalize(current_block); - println!("system OnFinalize took {:?}", now.elapsed()); + // println!("system OnFinalize took {:?}", now.elapsed()); - let now = Instant::now(); + // let now = Instant::now(); >>::on_idle(current_block, Weight::MAX); - println!("AllPalletsWithoutSystem OnIdle took {:?}", now.elapsed()); + // println!("AllPalletsWithoutSystem OnIdle took {:?}", now.elapsed()); - let now = Instant::now(); + // let now = Instant::now(); as OnIdle>>::on_idle(current_block, Weight::MAX); - println!("system OnIdle took {:?}", now.elapsed()); + // println!("system OnIdle took {:?}", now.elapsed()); current_block += One::one(); frame_system::Pallet::::set_block_number(current_block); let pre_events = frame_system::Pallet::::events(); - let now = Instant::now(); + // let now = Instant::now(); as OnInitialize>>::on_initialize(current_block); - println!("system OnInitialize took {:?}", now.elapsed()); + // println!("system OnInitialize took {:?}", now.elapsed()); - let now = Instant::now(); + // let now = Instant::now(); >>::on_initialize(current_block); - println!("AllPalletsWithoutSystem OnInitialize took {:?}", now.elapsed()); + // println!("AllPalletsWithoutSystem OnInitialize took {:?}", now.elapsed()); let post_events = frame_system::Pallet::::events(); if post_events.len() > pre_events.len() { Self::err_if_on_initialize_failed(post_events)?; } } - println!("advancing {amount} blocks took {:?}", outer_now.elapsed()); + // println!("advancing {amount} blocks took {:?}", outer_now.elapsed()); // time per block - println!("time per block: {:?}", outer_now.elapsed() / amount.saturated_into()); + // println!("time per block: {:?}", outer_now.elapsed() / amount.saturated_into()); Ok(()) }) } From 3393fe3d3c12ca871bdaf6ab6d5feb8067e002ec Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 7 Feb 2024 16:25:52 +0100 Subject: [PATCH 199/212] debug weight generated for end_funding benchmarks .max() added for worst case charging on weight annotation in extrinsics Signed-off-by: Juan Ignacio Rios --- debug_weight_gen.rs | 97 ++++++++++++++++++++----- pallets/funding/src/benchmarking.rs | 17 +++-- pallets/funding/src/functions.rs | 3 - pallets/funding/src/instantiator.rs | 1 - pallets/funding/src/lib.rs | 105 +++++++++++++++++++--------- 5 files changed, 160 insertions(+), 63 deletions(-) diff --git a/debug_weight_gen.rs b/debug_weight_gen.rs index ee03b16d2..866759d41 100644 --- a/debug_weight_gen.rs +++ b/debug_weight_gen.rs @@ -2,9 +2,9 @@ //! Autogenerated weights for `pallet_funding` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-02-06, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-02-07, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `Juans-MBP.home`, CPU: `` +//! HOSTNAME: `Juans-MacBook-Pro.local`, CPU: `` //! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: 1024 // Executed Command: @@ -15,7 +15,7 @@ // --steps=20 // --repeat=10 // --pallet=pallet_funding -// --extrinsic=project_decision_reject_funding, project_decision_accept_funding +// --extrinsic=end_funding_automatically_rejected_evaluators_slashed, end_funding_awaiting_decision_evaluators_slashed, end_funding_awaiting_decision_evaluators_unchanged, end_funding_automatically_accepted_evaluators_rewarded // --output // ./debug_weight_gen.rs @@ -32,30 +32,93 @@ pub struct WeightInfo(PhantomData); impl pallet_funding::WeightInfo for WeightInfo { /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - fn project_decision_accept_funding() -> Weight { + /// The range of component `x` is `[1, 99]`. + fn end_funding_automatically_rejected_evaluators_slashed(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `535` - // Estimated: `4087` - // Minimum execution time: 200_000_000 picoseconds. - Weight::from_parts(207_000_000, 0) + // Measured: `822 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 296_000_000 picoseconds. + Weight::from_parts(284_006_640, 0) .saturating_add(Weight::from_parts(0, 4087)) - .saturating_add(T::DbWeight::get().reads(2)) + // Standard Error: 85_755 + .saturating_add(Weight::from_parts(36_442_516, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - fn project_decision_reject_funding() -> Weight { + /// The range of component `x` is `[1, 99]`. + fn end_funding_awaiting_decision_evaluators_slashed(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `535` - // Estimated: `4087` - // Minimum execution time: 200_000_000 picoseconds. - Weight::from_parts(203_000_000, 0) + // Measured: `822 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 233_000_000 picoseconds. + Weight::from_parts(213_045_370, 0) .saturating_add(Weight::from_parts(0, 4087)) - .saturating_add(T::DbWeight::get().reads(2)) + // Standard Error: 117_943 + .saturating_add(Weight::from_parts(36_217_046, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn end_funding_awaiting_decision_evaluators_unchanged(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `822 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 236_000_000 picoseconds. + Weight::from_parts(245_084_435, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 136_756 + .saturating_add(Weight::from_parts(35_663_280, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:2049 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + /// The range of component `y` is `[1, 2048]`. + fn end_funding_automatically_accepted_evaluators_rewarded(x: u32, y: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1199 + x * (529 ±0) + y * (187 ±0)` + // Estimated: `4087 + x * (3097 ±0) + y * (2820 ±0)` + // Minimum execution time: 4_119_000_000 picoseconds. + Weight::from_parts(4_122_000_000, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 13_179_751 + .saturating_add(Weight::from_parts(37_293_090, 0).saturating_mul(x.into())) + // Standard Error: 636_741 + .saturating_add(Weight::from_parts(74_778_225, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 2820).saturating_mul(y.into())) } } diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index f5946aede..9023169d6 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -2846,7 +2846,7 @@ mod benchmarks { // Instead of advancing in time for the automatic `do_evaluation_end` call in on_initialize, we call it directly to benchmark it #[block] { - Pallet::::do_evaluation_end(project_id); + Pallet::::do_evaluation_end(project_id).unwrap(); } // * validity checks * @@ -2905,7 +2905,7 @@ mod benchmarks { // Instead of advancing in time for the automatic `do_evaluation_end` call in on_initialize, we call it directly to benchmark it #[block] { - Pallet::::do_evaluation_end(project_id); + Pallet::::do_evaluation_end(project_id).unwrap(); } // * validity checks * @@ -3006,7 +3006,7 @@ mod benchmarks { #[block] { - Pallet::::do_candle_auction(project_id); + Pallet::::do_candle_auction(project_id).unwrap(); } // * validity checks * // Storage @@ -3199,7 +3199,7 @@ mod benchmarks { #[block] { - Pallet::::do_community_funding(project_id); + Pallet::::do_community_funding(project_id).unwrap(); } // * validity checks * @@ -3257,7 +3257,6 @@ mod benchmarks { assert_eq!(stored_details.status, ProjectStatus::RemainderRound); // Events - let current_block = inst.current_block(); frame_system::Pallet::::assert_last_event(Event::::RemainderFundingStarted { project_id }.into()); } @@ -3561,7 +3560,7 @@ mod benchmarks { #[block] { - Pallet::::do_project_decision(project_id, FundingOutcomeDecision::AcceptFunding); + Pallet::::do_project_decision(project_id, FundingOutcomeDecision::AcceptFunding).unwrap(); } // * validity checks * @@ -3610,7 +3609,7 @@ mod benchmarks { #[block] { - Pallet::::do_project_decision(project_id, FundingOutcomeDecision::RejectFunding); + Pallet::::do_project_decision(project_id, FundingOutcomeDecision::RejectFunding).unwrap(); } // * validity checks * @@ -3638,7 +3637,7 @@ mod benchmarks { #[block] { - Pallet::::do_start_settlement(project_id); + Pallet::::do_start_settlement(project_id).unwrap(); } // * validity checks * @@ -3686,7 +3685,7 @@ mod benchmarks { #[block] { - Pallet::::do_start_settlement(project_id); + Pallet::::do_start_settlement(project_id).unwrap(); } // * validity checks * diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 06b9f1719..f653f1c83 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -2741,7 +2741,6 @@ impl Pallet { ) -> Result<(u32, u32), DispatchError> { // Get all the bids that were made before the end of the candle let mut bids = Bids::::iter_prefix_values((project_id,)).collect::>(); - let debug_total_bids = bids.len() as u32; // temp variable to store the sum of the bids let mut bid_token_amount_sum = Zero::zero(); // temp variable to store the total value of the bids (i.e price * amount = Cumulative Ticket Size) @@ -2926,8 +2925,6 @@ impl Pallet { } })?; - #[cfg(test)] - assert_eq!(accepted_bids_count + rejected_bids_count, debug_total_bids); Ok((accepted_bids_count, rejected_bids_count)) } diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 13cfb640c..00f28756a 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -1121,7 +1121,6 @@ impl< .end() .expect("Community funding end point should exist"); let remainder_start = community_funding_end + 1u32.into(); - let current_block = self.current_block(); frame_system::Pallet::::set_block_number(remainder_start - One::one()); self.advance_time(1u32.into()).unwrap(); match self.get_project_details(project_id).status { diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 37c8bc258..8eda5fdc8 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -996,7 +996,11 @@ pub mod pallet { /// Bond PLMC for a project in the evaluation stage #[pallet::call_index(4)] - #[pallet::weight(WeightInfoOf::::evaluation_over_limit())] + #[pallet::weight( + WeightInfoOf::::first_evaluation() + .max(WeightInfoOf::::second_to_limit_evaluation(T::MaxEvaluationsPerUser::get() - 1)) + .max(WeightInfoOf::::evaluation_over_limit()) + )] pub fn evaluate( origin: OriginFor, project_id: ProjectId, @@ -1008,13 +1012,15 @@ pub mod pallet { /// Bid for a project in the Auction round #[pallet::call_index(5)] - #[pallet::weight(WeightInfoOf::::bid_no_ct_deposit( - // Last bid possible - ::MaxBidsPerUser::get() - 1, - // Assuming the current bucket is full, and has a price higher than the minimum. - // This user is buying 100% of the bid allocation, since each bucket has 10% of the allocation at a 10% increase - 10, - ))] + #[pallet::weight( + WeightInfoOf::::bid_no_ct_deposit( + ::MaxBidsPerUser::get() - 1, + // Assuming the current bucket is full, and has a price higher than the minimum. + // This user is buying 100% of the bid allocation. + // Since each bucket has 10% of the allocation, one bid can be split into a max of 10 + 10 + ) + .max(WeightInfoOf::::bid_with_ct_deposit(10)))] pub fn bid( origin: OriginFor, project_id: ProjectId, @@ -1028,14 +1034,22 @@ pub mod pallet { /// Buy tokens in the Community or Remainder round at the price set in the Auction Round #[pallet::call_index(6)] - #[pallet::weight(WeightInfoOf::::second_to_limit_contribution_ends_round( + #[pallet::weight( + WeightInfoOf::::first_contribution_with_ct_deposit() + .max(WeightInfoOf::::first_contribution_no_ct_deposit()) + .max(WeightInfoOf::::first_contribution_ends_round_with_ct_deposit(::MaxProjectsToUpdateInsertionAttempts::get() - 1, 10_000)) + .max(WeightInfoOf::::first_contribution_ends_round_no_ct_deposit(::MaxProjectsToUpdateInsertionAttempts::get() - 1, 10_000)) + .max(WeightInfoOf::::second_to_limit_contribution(T::MaxContributionsPerUser::get() - 1)) + .max(WeightInfoOf::::second_to_limit_contribution_ends_round( // Last contribution possible before having to remove an old lower one ::MaxContributionsPerUser::get() -1, // Since we didn't remove any previous lower contribution, we can buy all remaining CTs and try to move to the next phase ::MaxProjectsToUpdateInsertionAttempts::get() - 1, // Assumed upper bound for deletion attempts for the previous scheduled transition 10_000u32, - ))] + )) + .max(WeightInfoOf::::contribution_over_limit()) + )] pub fn contribute( origin: OriginFor, project_id: ProjectId, @@ -1073,7 +1087,10 @@ pub mod pallet { } #[pallet::call_index(9)] - #[pallet::weight(WeightInfoOf::::evaluation_reward_payout_for_with_ct_account_creation())] + #[pallet::weight( + WeightInfoOf::::evaluation_reward_payout_for_with_ct_account_creation() + .max(WeightInfoOf::::evaluation_reward_payout_for_no_ct_account_creation()) + )] pub fn evaluation_reward_payout_for( origin: OriginFor, project_id: ProjectId, @@ -1085,7 +1102,10 @@ pub mod pallet { } #[pallet::call_index(10)] - #[pallet::weight(WeightInfoOf::::bid_ct_mint_for_with_ct_account_creation())] + #[pallet::weight( + WeightInfoOf::::bid_ct_mint_for_with_ct_account_creation() + .max(WeightInfoOf::::bid_ct_mint_for_no_ct_account_creation()) + )] pub fn bid_ct_mint_for( origin: OriginFor, project_id: ProjectId, @@ -1097,7 +1117,10 @@ pub mod pallet { } #[pallet::call_index(11)] - #[pallet::weight(WeightInfoOf::::contribution_ct_mint_for_with_ct_account_creation())] + #[pallet::weight( + WeightInfoOf::::contribution_ct_mint_for_with_ct_account_creation() + .max(WeightInfoOf::::contribution_ct_mint_for_no_ct_account_creation()) + )] pub fn contribution_ct_mint_for( origin: OriginFor, project_id: ProjectId, @@ -1278,52 +1301,68 @@ pub mod pallet { // Get the projects that need to be updated on this block and update them // use std::time::Instant; // let time_now = Instant::now(); + let mut used_weight = Weight::from_parts(0, 0); for (project_id, update_type) in ProjectsToUpdate::::take(now) { // println!("took something"); match update_type { // EvaluationRound -> AuctionInitializePeriod | EvaluationFailed UpdateType::EvaluationEnd => { - unwrap_result_or_skip!( - Self::do_evaluation_end(project_id), - project_id, - |e: DispatchErrorWithPostInfo| { e.error } + used_weight.saturating_add( + unwrap_result_or_skip!( + Self::do_evaluation_end(project_id), + project_id, + |e: DispatchErrorWithPostInfo| { e.error } + ) + .calc_actual_weight(), ); }, // AuctionInitializePeriod -> AuctionRound(AuctionPhase::English) // Only if it wasn't first handled by user extrinsic UpdateType::EnglishAuctionStart => { - unwrap_result_or_skip!( - Self::do_english_auction(T::PalletId::get().into_account_truncating(), project_id), - project_id, - |e: DispatchErrorWithPostInfo| { e.error } + used_weight.saturating_add( + unwrap_result_or_skip!( + Self::do_english_auction(T::PalletId::get().into_account_truncating(), project_id), + project_id, + |e: DispatchErrorWithPostInfo| { e.error } + ) + .calc_actual_weight(), ); }, // AuctionRound(AuctionPhase::English) -> AuctionRound(AuctionPhase::Candle) UpdateType::CandleAuctionStart => { - unwrap_result_or_skip!( - Self::do_candle_auction(project_id), - project_id, - |e: DispatchErrorWithPostInfo| { e.error } + used_weight.saturating_add( + unwrap_result_or_skip!( + Self::do_candle_auction(project_id), + project_id, + |e: DispatchErrorWithPostInfo| { e.error } + ) + .calc_actual_weight(), ); }, // AuctionRound(AuctionPhase::Candle) -> CommunityRound UpdateType::CommunityFundingStart => { - unwrap_result_or_skip!( - Self::do_community_funding(project_id), - project_id, - |e: DispatchErrorWithPostInfo| { e.error } + used_weight.saturating_add( + unwrap_result_or_skip!( + Self::do_community_funding(project_id), + project_id, + |e: DispatchErrorWithPostInfo| { e.error } + ) + .calc_actual_weight(), ); }, // CommunityRound -> RemainderRound UpdateType::RemainderFundingStart => { - unwrap_result_or_skip!( - Self::do_remainder_funding(project_id), - project_id, - |e: DispatchErrorWithPostInfo| { e.error } + used_weight.saturating_add( + unwrap_result_or_skip!( + Self::do_remainder_funding(project_id), + project_id, + |e: DispatchErrorWithPostInfo| { e.error } + ) + .calc_actual_weight(), ); }, From 08ce8efedd650be058d3baa0e49349de490774f1 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 8 Feb 2024 14:55:36 +0100 Subject: [PATCH 200/212] BUGFIX: we now charge the issuer on project creation for the CT metadata storage. Signed-off-by: Juan Ignacio Rios --- Cargo.lock | 108 +++++----- Cargo.toml | 1 + debug_weight_gen.rs | 103 ++------- pallets/funding/src/benchmarking.rs | 13 +- pallets/funding/src/functions.rs | 29 ++- pallets/funding/src/instantiator.rs | 56 ++--- pallets/funding/src/lib.rs | 77 ++++--- pallets/funding/src/tests.rs | 255 ++++++++--------------- pallets/funding/src/weights.rs | 197 +++++++++++++++-- runtimes/shared-configuration/Cargo.toml | 1 + runtimes/testnet/Cargo.toml | 3 + runtimes/testnet/src/lib.rs | 2 +- 12 files changed, 441 insertions(+), 404 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 34ba306cb..26a9bcfdd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -330,7 +330,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -341,7 +341,7 @@ checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -473,7 +473,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -872,7 +872,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -1550,7 +1550,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -1863,7 +1863,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -1890,7 +1890,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -1907,7 +1907,7 @@ checksum = "587663dd5fb3d10932c8aecfe7c844db1bcf0aee93eeab08fac13dc1212c2e7f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -2089,7 +2089,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -2113,7 +2113,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.39", + "syn 2.0.48", "termcolor", "walkdir", ] @@ -2291,7 +2291,7 @@ checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -2302,7 +2302,7 @@ checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -2423,7 +2423,7 @@ dependencies = [ "fs-err", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -2680,7 +2680,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -2799,7 +2799,7 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -2811,7 +2811,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -2821,7 +2821,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948 dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -2981,7 +2981,7 @@ checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -4643,7 +4643,7 @@ dependencies = [ "macro_magic_core", "macro_magic_macros", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -4657,7 +4657,7 @@ dependencies = [ "macro_magic_core_macros", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -4668,7 +4668,7 @@ checksum = "d710e1214dffbab3b5dacb21475dde7d6ed84c69ff722b3a47a782668d44fbac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -4679,7 +4679,7 @@ checksum = "b8fb85ec1620619edf2984a7693497d4ec88a9665d8b87e942856884c92dbf2a" dependencies = [ "macro_magic_core", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -4689,7 +4689,7 @@ dependencies = [ "proc-macro2", "quote", "sp-core", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -6292,7 +6292,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -6767,7 +6767,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -6808,7 +6808,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -8411,7 +8411,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -8495,14 +8495,14 @@ checksum = "3d1eaa7fa0aa1929ffdf7eeb6eac234dde6268914a14ad44d23521ab6a9b258e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] name = "proc-macro2" -version = "1.0.70" +version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] @@ -8541,7 +8541,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -8666,9 +8666,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -8856,7 +8856,7 @@ checksum = "7f7473c2cfcf90008193dd0e3e16599455cb601a9fce322b5bb55de799664925" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -9392,7 +9392,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -10315,7 +10315,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -10585,7 +10585,7 @@ checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -10900,7 +10900,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -11137,7 +11137,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948 dependencies = [ "quote", "sp-core-hashing", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -11156,7 +11156,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948 dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -11363,7 +11363,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -11548,7 +11548,7 @@ dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -11714,7 +11714,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -11854,9 +11854,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.39" +version = "2.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" dependencies = [ "proc-macro2", "quote", @@ -11953,7 +11953,7 @@ checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -12114,7 +12114,7 @@ checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -12280,7 +12280,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -12323,7 +12323,7 @@ dependencies = [ "proc-macro-crate 1.3.1", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -12688,7 +12688,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", "wasm-bindgen-shared", ] @@ -12722,7 +12722,7 @@ checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -13543,7 +13543,7 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -13586,7 +13586,7 @@ checksum = "86cd5ca076997b97ef09d3ad65efe811fa68c9e874cb636ccb211223a813b0c2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] @@ -13606,7 +13606,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.39", + "syn 2.0.48", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index c4d6a365b..b56a9782d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -103,6 +103,7 @@ frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate" frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } frame-try-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } +sp-debug-derive = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } sp-staking = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" } diff --git a/debug_weight_gen.rs b/debug_weight_gen.rs index 866759d41..4f6c94870 100644 --- a/debug_weight_gen.rs +++ b/debug_weight_gen.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `pallet_funding` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-02-07, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-02-08, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `Juans-MacBook-Pro.local`, CPU: `` //! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: 1024 @@ -15,7 +15,7 @@ // --steps=20 // --repeat=10 // --pallet=pallet_funding -// --extrinsic=end_funding_automatically_rejected_evaluators_slashed, end_funding_awaiting_decision_evaluators_slashed, end_funding_awaiting_decision_evaluators_unchanged, end_funding_automatically_accepted_evaluators_rewarded +// --extrinsic=start_settlement_funding_success, // --output // ./debug_weight_gen.rs @@ -34,91 +34,20 @@ impl pallet_funding::WeightInfo for WeightInfo { /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn end_funding_automatically_rejected_evaluators_slashed(x: u32, ) -> Weight { + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Metadata` (r:1 w:1) + /// Proof: `LocalAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn start_settlement_funding_success() -> Weight { // Proof Size summary in bytes: - // Measured: `822 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 296_000_000 picoseconds. - Weight::from_parts(284_006_640, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 85_755 - .saturating_add(Weight::from_parts(36_442_516, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn end_funding_awaiting_decision_evaluators_slashed(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `822 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 233_000_000 picoseconds. - Weight::from_parts(213_045_370, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 117_943 - .saturating_add(Weight::from_parts(36_217_046, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn end_funding_awaiting_decision_evaluators_unchanged(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `822 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 236_000_000 picoseconds. - Weight::from_parts(245_084_435, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 136_756 - .saturating_add(Weight::from_parts(35_663_280, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(3)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:2049 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - /// The range of component `y` is `[1, 2048]`. - fn end_funding_automatically_accepted_evaluators_rewarded(x: u32, y: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1199 + x * (529 ±0) + y * (187 ±0)` - // Estimated: `4087 + x * (3097 ±0) + y * (2820 ±0)` - // Minimum execution time: 4_119_000_000 picoseconds. - Weight::from_parts(4_122_000_000, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 13_179_751 - .saturating_add(Weight::from_parts(37_293_090, 0).saturating_mul(x.into())) - // Standard Error: 636_741 - .saturating_add(Weight::from_parts(74_778_225, 0).saturating_mul(y.into())) - .saturating_add(T::DbWeight::get().reads(4)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into()))) - .saturating_add(T::DbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 2820).saturating_mul(y.into())) + // Measured: `970` + // Estimated: `3814` + // Minimum execution time: 542_000_000 picoseconds. + Weight::from_parts(549_000_000, 0) + .saturating_add(Weight::from_parts(0, 3814)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) } } diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 9023169d6..530a866f4 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -786,7 +786,7 @@ mod benchmarks { inst.mint_statemint_asset_to(usdt_for_existing_bids.clone()); // do "x" contributions for this user - inst.bid_for_users(project_id, existing_bids_post_bucketing.clone()); + inst.bid_for_users(project_id, existing_bids_post_bucketing.clone()).unwrap(); // to call do_perform_bid several times, we need the bucket to reach its limit. You can only bid over 10 buckets // in a single bid, since the increase delta is 10% of the total allocation, and you cannot bid more than the allocation. @@ -824,7 +824,7 @@ mod benchmarks { inst.mint_plmc_to(plmc_ct_deposit); inst.mint_statemint_asset_to(usdt_for_new_bidder.clone()); - inst.bid_for_users(project_id, vec![bid_params]); + inst.bid_for_users(project_id, vec![bid_params]).unwrap(); ct_amount = Percent::from_percent(10) * (project_metadata.total_allocation_size.0 * (do_perform_bid_calls as u128).into()); @@ -3094,7 +3094,7 @@ mod benchmarks { inst.mint_plmc_to(plmc_ct_account_deposit); inst.mint_statemint_asset_to(funding_asset_needed_for_bids); - inst.bid_for_users(project_id, accepted_bids); + inst.bid_for_users(project_id, accepted_bids).unwrap(); let now = inst.current_block(); frame_system::Pallet::::set_block_number(now + ::EnglishAuctionDuration::get()); @@ -3128,7 +3128,7 @@ mod benchmarks { inst.mint_plmc_to(plmc_ct_account_deposit); inst.mint_statemint_asset_to(funding_asset_needed_for_bids); - inst.bid_for_users(project_id, rejected_bids); + inst.bid_for_users(project_id, rejected_bids).unwrap(); let auction_candle_end_block = inst.get_project_details(project_id).phase_transition_points.candle_auction.end().unwrap(); @@ -3635,9 +3635,12 @@ mod benchmarks { vec![], ); + // let issuer_mint = UserToPLMCBalance::::new(issuer.clone(), (100 * ASSET_UNIT).into()); + // inst.mint_plmc_to(vec![issuer_mint]); + #[block] { - Pallet::::do_start_settlement(project_id).unwrap(); + let result = Pallet::::do_start_settlement(project_id).unwrap(); } // * validity checks * diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index f653f1c83..3f6ae6964 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -17,20 +17,24 @@ // If you feel like getting in touch with us, you can do so at info@polimec.org //! Functions for the Funding pallet. - +use crate::ProjectStatus::FundingSuccessful; use frame_support::{ dispatch::{DispatchErrorWithPostInfo, DispatchResult, DispatchResultWithPostInfo, PostDispatchInfo}, ensure, pallet_prelude::*, traits::{ - fungible::{InspectHold, MutateHold as FungibleMutateHold}, - fungibles::{metadata::Mutate as MetadataMutate, Create, Inspect, Mutate as FungiblesMutate}, + fungible::{InspectHold, Mutate, MutateHold as FungibleMutateHold}, + fungibles::{ + metadata::{MetadataDeposit, Mutate as MetadataMutate}, + Create, Inspect, Mutate as FungiblesMutate, + }, tokens::{Fortitude, Precision, Preservation, Restriction}, Get, }, }; use frame_system::pallet_prelude::BlockNumberFor; use itertools::Itertools; +use polimec_common::ReleaseSchedule; use sp_arithmetic::{ traits::{CheckedDiv, CheckedSub, Zero}, Percent, Perquintill, @@ -39,11 +43,7 @@ use sp_runtime::traits::{Convert, ConvertBack}; use sp_std::{marker::PhantomData, ops::Not}; use xcm::v3::MaxDispatchErrorLen; -use crate::ProjectStatus::FundingSuccessful; -use polimec_common::ReleaseSchedule; - use crate::traits::{BondingRequirementCalculation, ProvideStatemintPrice, VestingDurationCalculation}; -use frame_support::traits::fungible::Mutate; use polimec_common::migration_types::{MigrationInfo, MigrationOrigin, Migrations, ParticipationType}; use super::*; @@ -133,6 +133,16 @@ impl Pallet { ) .map_err(|_| Error::::NotEnoughFundsForEscrowCreation)?; + // Each project needs a new token type to be created (i.e contribution token). + // This creation is done automatically in the project transition on success, but someone needs to pay for the storage + // of the metadata associated with it. + let metadata_deposit = T::ContributionTokenCurrency::calc_metadata_deposit( + initial_metadata.token_information.name.as_slice(), + initial_metadata.token_information.symbol.as_slice(), + ); + T::NativeCurrency::transfer(&issuer, &escrow_account, metadata_deposit, Preservation::Preserve) + .map_err(|_| Error::::NotEnoughFundsForCTMetadata)?; + // * Update storage * ProjectsMetadata::::insert(project_id, &initial_metadata); ProjectsDetails::::insert(project_id, project_details); @@ -838,11 +848,12 @@ impl Pallet { // * Update storage * ProjectsDetails::::insert(project_id, &project_details); + let escrow_account = Self::fund_account_id(project_id); if project_details.status == ProjectStatus::FundingSuccessful { - T::ContributionTokenCurrency::create(project_id, project_details.issuer.clone(), false, 1_u32.into())?; + T::ContributionTokenCurrency::create(project_id, escrow_account.clone(), false, 1_u32.into())?; T::ContributionTokenCurrency::set( project_id, - &project_details.issuer, + &escrow_account.clone(), token_information.name.into(), token_information.symbol.into(), token_information.decimals, diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 00f28756a..540fc22f5 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -5,10 +5,11 @@ use crate::{ use frame_support::{ pallet_prelude::*, traits::{ - fungible::{Inspect as FungibleInspect, InspectHold as FungibleInspectHold, Mutate as FungibleMutate}, + fungible::{Inspect as FungibleInspect, InspectHold as FungibleInspectHold, Mutate as FungibleMutate, Mutate}, fungibles::{ - metadata::Inspect as MetadataInspect, roles::Inspect as RolesInspect, Inspect as FungiblesInspect, - Mutate as FungiblesMutate, + metadata::{Inspect as MetadataInspect, MetadataDeposit}, + roles::Inspect as RolesInspect, + Inspect as FungiblesInspect, Mutate as FungiblesMutate, }, AccountTouch, Get, OnFinalize, OnIdle, OnInitialize, }, @@ -863,7 +864,15 @@ impl< pub fn create_new_project(&mut self, project_metadata: ProjectMetadataOf, issuer: AccountIdOf) -> ProjectId { let now = self.current_block(); // one ED for the issuer, one ED for the escrow account - self.mint_plmc_to(vec![UserToPLMCBalance::new(issuer.clone(), Self::get_ed() * 2u64.into())]); + let metadata_deposit = T::ContributionTokenCurrency::calc_metadata_deposit( + project_metadata.token_information.name.as_slice(), + project_metadata.token_information.symbol.as_slice(), + ); + self.mint_plmc_to(vec![UserToPLMCBalance::new( + issuer.clone(), + Self::get_ed() * 2u64.into() + metadata_deposit, + )]); + self.execute(|| { crate::Pallet::::do_create(&issuer, project_metadata.clone()).unwrap(); let last_project_metadata = ProjectsMetadata::::iter().last().unwrap(); @@ -909,12 +918,12 @@ impl< if project_details.status == ProjectStatus::EvaluationRound { let evaluation_end = project_details.phase_transition_points.evaluation.end().unwrap(); - frame_system::Pallet::::set_block_number(evaluation_end); + self.execute(|| frame_system::Pallet::::set_block_number(evaluation_end)); // run on_initialize for evaluation end self.advance_time(1u32.into()).unwrap(); let auction_initialize_period_start = self.get_project_details(project_id).phase_transition_points.auction_initialize_period.start().unwrap(); - frame_system::Pallet::::set_block_number(auction_initialize_period_start); + self.execute(|| frame_system::Pallet::::set_block_number(auction_initialize_period_start)); }; assert_eq!(self.get_project_details(project_id).status, ProjectStatus::AuctionInitializePeriod); @@ -967,11 +976,13 @@ impl< project_id } - pub fn bid_for_users(&mut self, project_id: ProjectId, bids: Vec>) { + pub fn bid_for_users(&mut self, project_id: ProjectId, bids: Vec>) -> DispatchResultWithPostInfo { for bid in bids { - self.execute(|| crate::Pallet::::do_bid(&bid.bidder, project_id, bid.amount, bid.multiplier, bid.asset)) - .unwrap(); + self.execute(|| { + crate::Pallet::::do_bid(&bid.bidder, project_id, bid.amount, bid.multiplier, bid.asset) + })?; } + Ok(().into()) } pub fn start_community_funding(&mut self, project_id: ProjectId) -> Result<(), DispatchError> { @@ -982,7 +993,7 @@ impl< .end() .expect("English end point should exist"); - frame_system::Pallet::::set_block_number(english_end); + self.execute(|| frame_system::Pallet::::set_block_number(english_end)); // run on_initialize self.advance_time(1u32.into()).unwrap(); @@ -993,7 +1004,7 @@ impl< .end() .expect("Candle end point should exist"); - frame_system::Pallet::::set_block_number(candle_end); + self.execute(|| frame_system::Pallet::::set_block_number(candle_end)); // run on_initialize self.advance_time(1u32.into()).unwrap(); @@ -1058,7 +1069,7 @@ impl< self.mint_plmc_to(plmc_ct_account_deposits.clone()); self.mint_statemint_asset_to(funding_asset_deposits.clone()); - self.bid_for_users(project_id, bids.clone()); + self.bid_for_users(project_id, bids.clone()).unwrap(); self.do_reserved_plmc_assertions( total_plmc_participation_locked.merge_accounts(MergeOperation::Add), @@ -1114,14 +1125,8 @@ impl< pub fn start_remainder_or_end_funding(&mut self, project_id: ProjectId) -> Result<(), DispatchError> { assert_eq!(self.get_project_details(project_id).status, ProjectStatus::CommunityRound); - let community_funding_end = self - .get_project_details(project_id) - .phase_transition_points - .community - .end() - .expect("Community funding end point should exist"); - let remainder_start = community_funding_end + 1u32.into(); - frame_system::Pallet::::set_block_number(remainder_start - One::one()); + let (transition_block, _) = self.get_update_pair(project_id); + self.execute(|| frame_system::Pallet::::set_block_number(transition_block - One::one())); self.advance_time(1u32.into()).unwrap(); match self.get_project_details(project_id).status { ProjectStatus::RemainderRound | ProjectStatus::FundingSuccessful => Ok(()), @@ -1131,11 +1136,11 @@ impl< pub fn finish_funding(&mut self, project_id: ProjectId) -> Result<(), DispatchError> { let (update_block, _) = self.get_update_pair(project_id); - frame_system::Pallet::::set_block_number(update_block - One::one()); + self.execute(|| frame_system::Pallet::::set_block_number(update_block - One::one())); self.advance_time(1u32.into()).unwrap(); if self.get_project_details(project_id).status == ProjectStatus::RemainderRound { let (end_block, _) = self.get_update_pair(project_id); - frame_system::Pallet::::set_block_number(end_block - 1u32.into()); + self.execute(|| frame_system::Pallet::::set_block_number(end_block - 1u32.into())); self.advance_time(1u32.into()).unwrap(); } let project_details = self.get_project_details(project_id); @@ -1778,7 +1783,7 @@ pub mod async_features { inst.mint_plmc_to(plmc_ct_account_deposits.clone()); inst.mint_statemint_asset_to(funding_asset_deposits.clone()); - inst.bid_for_users(project_id, bids.clone()); + inst.bid_for_users(project_id, bids.clone()).unwrap(); inst.do_reserved_plmc_assertions( total_plmc_participation_locked.merge_accounts(MergeOperation::Add), @@ -2800,10 +2805,11 @@ pub mod testing_macros { macro_rules! assert_close_enough { // Match when a message is provided ($real:expr, $desired:expr, $max_approximation:expr, $msg:expr) => { + let real_parts; if $real <= $desired { - let real_parts = Perquintill::from_rational($real, $desired); + real_parts = Perquintill::from_rational($real, $desired); } else { - let real_parts = Perquintill::from_rational($desired, $real); + real_parts = Perquintill::from_rational($desired, $real); } let one = Perquintill::from_percent(100u64); let real_approximation = one - real_parts; diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 8eda5fdc8..56ef19fff 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -337,6 +337,7 @@ pub mod pallet { + fungibles::InspectEnumerable, Balance = BalanceOf> + fungibles::metadata::Inspect> + fungibles::metadata::Mutate> + + fungibles::metadata::MetadataDeposit> + fungibles::Mutate, Balance = BalanceOf> + fungibles::roles::Inspect> + AccountTouch, Balance = BalanceOf> @@ -943,6 +944,8 @@ pub mod pallet { NoFutureDepositHeld, /// The issuer doesn't have enough funds (ExistentialDeposit), to create the escrow account NotEnoughFundsForEscrowCreation, + /// The issuer doesn't have enough funds to pay for the metadata of their contribution token + NotEnoughFundsForCTMetadata, /// Too many attempts to insert project in to ProjectsToUpdate storage TooManyInsertionAttempts, /// Reached bid limit for this user on this project @@ -1299,108 +1302,118 @@ pub mod pallet { impl Hooks> for Pallet { fn on_initialize(now: BlockNumberFor) -> Weight { // Get the projects that need to be updated on this block and update them - // use std::time::Instant; - // let time_now = Instant::now(); let mut used_weight = Weight::from_parts(0, 0); for (project_id, update_type) in ProjectsToUpdate::::take(now) { - // println!("took something"); match update_type { // EvaluationRound -> AuctionInitializePeriod | EvaluationFailed UpdateType::EvaluationEnd => { - used_weight.saturating_add( + used_weight = used_weight.saturating_add( unwrap_result_or_skip!( Self::do_evaluation_end(project_id), project_id, |e: DispatchErrorWithPostInfo| { e.error } ) - .calc_actual_weight(), + .actual_weight + .unwrap_or_default(), ); }, // AuctionInitializePeriod -> AuctionRound(AuctionPhase::English) // Only if it wasn't first handled by user extrinsic UpdateType::EnglishAuctionStart => { - used_weight.saturating_add( + used_weight = used_weight.saturating_add( unwrap_result_or_skip!( Self::do_english_auction(T::PalletId::get().into_account_truncating(), project_id), project_id, |e: DispatchErrorWithPostInfo| { e.error } ) - .calc_actual_weight(), + .actual_weight + .unwrap_or_default(), ); }, // AuctionRound(AuctionPhase::English) -> AuctionRound(AuctionPhase::Candle) UpdateType::CandleAuctionStart => { - used_weight.saturating_add( + used_weight = used_weight.saturating_add( unwrap_result_or_skip!( Self::do_candle_auction(project_id), project_id, |e: DispatchErrorWithPostInfo| { e.error } ) - .calc_actual_weight(), + .actual_weight + .unwrap_or_default(), ); }, // AuctionRound(AuctionPhase::Candle) -> CommunityRound UpdateType::CommunityFundingStart => { - used_weight.saturating_add( + used_weight = used_weight.saturating_add( unwrap_result_or_skip!( Self::do_community_funding(project_id), project_id, |e: DispatchErrorWithPostInfo| { e.error } ) - .calc_actual_weight(), + .actual_weight + .unwrap_or_default(), ); }, // CommunityRound -> RemainderRound UpdateType::RemainderFundingStart => { - used_weight.saturating_add( + used_weight = used_weight.saturating_add( unwrap_result_or_skip!( Self::do_remainder_funding(project_id), project_id, |e: DispatchErrorWithPostInfo| { e.error } ) - .calc_actual_weight(), + .actual_weight + .unwrap_or_default(), ); }, // CommunityRound || RemainderRound -> FundingEnded UpdateType::FundingEnd => { - unwrap_result_or_skip!( - Self::do_end_funding(project_id), - project_id, - |e: DispatchErrorWithPostInfo| { e.error } + used_weight = used_weight.saturating_add( + unwrap_result_or_skip!( + Self::do_end_funding(project_id), + project_id, + |e: DispatchErrorWithPostInfo| { e.error } + ) + .actual_weight + .unwrap_or_default(), ); }, UpdateType::ProjectDecision(decision) => { - unwrap_result_or_skip!( - Self::do_project_decision(project_id, decision), - project_id, - |e: DispatchErrorWithPostInfo| { e.error } + used_weight = used_weight.saturating_add( + unwrap_result_or_skip!( + Self::do_project_decision(project_id, decision), + project_id, + |e: DispatchErrorWithPostInfo| { e.error } + ) + .actual_weight + .unwrap_or_default(), ); }, UpdateType::StartSettlement => { - unwrap_result_or_skip!( - Self::do_start_settlement(project_id), - project_id, - |e: DispatchErrorWithPostInfo| { e.error } + used_weight = used_weight.saturating_add( + unwrap_result_or_skip!( + Self::do_start_settlement(project_id), + project_id, + |e: DispatchErrorWithPostInfo| { e.error } + ) + .actual_weight + .unwrap_or_default(), ); }, } } - // let elapsed = time_now.elapsed(); - // println!("Funding on_initialize elapsed: {:?}", elapsed); - // TODO: PLMC-127. Set a proper weight - Weight::from_parts(0, 0) + + used_weight } fn on_idle(_now: BlockNumberFor, max_weight: Weight) -> Weight { - // use std::time::Instant; - // let now = Instant::now(); let mut remaining_weight = max_weight; let projects_needing_cleanup = ProjectsDetails::::iter() @@ -1444,8 +1457,6 @@ pub mod pallet { } } - // let elapsed = now.elapsed(); - // println!("Funding on_idle elapsed: {:?}", elapsed); max_weight.saturating_sub(remaining_weight) } } diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index b455e00e7..c85603cd1 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -18,8 +18,9 @@ //! Tests for Funding pallet. use assert_matches2::assert_matches; +use defaults::*; use frame_support::{ - assert_noop, assert_ok, + assert_err, assert_noop, assert_ok, traits::{ fungible::{Inspect as FungibleInspect, InspectHold as FungibleInspectHold}, Get, @@ -27,14 +28,12 @@ use frame_support::{ }; use itertools::Itertools; use parachains_common::DAYS; +use polimec_common::ReleaseSchedule; use sp_arithmetic::{traits::Zero, Percent, Perquintill}; use sp_runtime::BuildStorage; use sp_std::{cell::RefCell, marker::PhantomData}; use std::{cmp::min, iter::zip}; -use defaults::*; -use polimec_common::ReleaseSchedule; - use super::*; use crate::{ instantiator::*, @@ -698,7 +697,38 @@ mod evaluation_round_failure { #[test] fn cannot_evaluate_more_than_project_limit() { - todo!() + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let project_metadata = default_project(0, ISSUER); + let evaluations = (0u32..::MaxEvaluationsPerProject::get()) + .map(|i| UserToUSDBalance::::new(i as u64 + 420u64, (10u128 * ASSET_UNIT).into())) + .collect_vec(); + let failing_evaluation = UserToUSDBalance::new(EVALUATOR_1, 1000 * ASSET_UNIT); + + let project_id = inst.create_evaluating_project(project_metadata.clone(), ISSUER); + + let plmc_for_evaluating = MockInstantiator::calculate_evaluation_plmc_spent(evaluations.clone()); + let plmc_existential_deposits = evaluations.accounts().existential_deposits(); + let plmc_ct_account_deposits = evaluations.accounts().ct_account_deposits(); + + inst.mint_plmc_to(plmc_for_evaluating.clone()); + inst.mint_plmc_to(plmc_existential_deposits.clone()); + inst.mint_plmc_to(plmc_ct_account_deposits.clone()); + + inst.bond_for_users(project_id, evaluations.clone()).unwrap(); + + let plmc_for_failing_evaluating = + MockInstantiator::calculate_evaluation_plmc_spent(vec![failing_evaluation.clone()]); + let plmc_existential_deposits = plmc_for_failing_evaluating.accounts().existential_deposits(); + let plmc_ct_account_deposits = plmc_for_failing_evaluating.accounts().ct_account_deposits(); + + inst.mint_plmc_to(plmc_for_failing_evaluating.clone()); + inst.mint_plmc_to(plmc_existential_deposits.clone()); + inst.mint_plmc_to(plmc_ct_account_deposits.clone()); + + assert_err!( + inst.bond_for_users(project_id, vec![failing_evaluation]), + Error::::TooManyEvaluationsForProject + ); } } @@ -764,7 +794,7 @@ mod auction_round_success { )]); inst.mint_statemint_asset_to(necessary_usdt_for_bid); - inst.bid_for_users(project_id, vec![evaluator_bid]); + inst.bid_for_users(project_id, vec![evaluator_bid]).unwrap(); } #[test] @@ -855,7 +885,7 @@ mod auction_round_success { BidParams::new(DAMIAN, 5_000 * ASSET_UNIT, 1.into(), 1u8, AcceptedFundingAsset::USDT), ]; - inst.bid_for_users(project_id, bids); + inst.bid_for_users(project_id, bids).unwrap(); inst.start_community_funding(project_id).unwrap(); @@ -929,7 +959,7 @@ mod auction_round_success { multiplier: bid_info.multiplier, asset: bid_info.asset, }]; - inst.bid_for_users(project_id, bids.clone()); + inst.bid_for_users(project_id, bids.clone()).unwrap(); bids_made.push(bids[0].clone()); bidding_account += 1; @@ -1409,7 +1439,7 @@ mod auction_round_success { let bidders_funding_assets = MockInstantiator::calculate_auction_funding_asset_spent(&bids, None); inst.mint_statemint_asset_to(bidders_funding_assets); - inst.bid_for_users(project_id, bids); + inst.bid_for_users(project_id, bids).unwrap(); inst.start_community_funding(project_id).unwrap(); let final_price = inst.get_project_details(project_id).weighted_average_price.unwrap(); @@ -1779,11 +1809,6 @@ mod auction_round_success { assert_eq!(delta_bidders_plmc_balances, plmc_locked_for_bids); } - - #[test] - pub fn cannot_bid_more_than_project_limit_count() { - todo!() - } } mod auction_round_failure { @@ -1819,6 +1844,52 @@ mod auction_round_failure { }); } + #[test] + pub fn cannot_bid_more_than_project_limit_count() { + let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); + let project_metadata = default_project(0, ISSUER); + let bids = (0u32..::MaxBidsPerProject::get()) + .map(|i| { + BidParams::::new( + i as u64 + 420u64, + 10 * ASSET_UNIT, + 1_u128.into(), + 1u8, + AcceptedFundingAsset::USDT, + ) + }) + .collect_vec(); + let failing_bid = + BidParams::::new(BIDDER_1, 10 * ASSET_UNIT, 1_u128.into(), 1u8, AcceptedFundingAsset::USDT); + + let project_id = inst.create_auctioning_project(project_metadata.clone(), ISSUER, default_evaluations()); + + let plmc_for_bidding = MockInstantiator::calculate_auction_plmc_spent(&bids.clone(), None); + let plmc_existential_deposits = bids.accounts().existential_deposits(); + let plmc_ct_account_deposits = bids.accounts().ct_account_deposits(); + let usdt_for_bidding = MockInstantiator::calculate_auction_funding_asset_spent(&bids.clone(), None); + + inst.mint_plmc_to(plmc_for_bidding.clone()); + inst.mint_plmc_to(plmc_existential_deposits.clone()); + inst.mint_plmc_to(plmc_ct_account_deposits.clone()); + inst.mint_statemint_asset_to(usdt_for_bidding.clone()); + + inst.bid_for_users(project_id, bids.clone()).unwrap(); + + let plmc_for_failing_bid = MockInstantiator::calculate_auction_plmc_spent(&vec![failing_bid.clone()], None); + let plmc_existential_deposits = plmc_for_failing_bid.accounts().existential_deposits(); + let plmc_ct_account_deposits = plmc_for_failing_bid.accounts().ct_account_deposits(); + let usdt_for_bidding = + MockInstantiator::calculate_auction_funding_asset_spent(&vec![failing_bid.clone()], None); + + inst.mint_plmc_to(plmc_for_failing_bid.clone()); + inst.mint_plmc_to(plmc_existential_deposits.clone()); + inst.mint_plmc_to(plmc_ct_account_deposits.clone()); + inst.mint_statemint_asset_to(usdt_for_bidding.clone()); + + assert_err!(inst.bid_for_users(project_id, vec![failing_bid]), Error::::TooManyBidsForProject); + } + #[test] fn contribute_does_not_work() { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); @@ -1910,7 +1981,7 @@ mod auction_round_failure { inst.mint_plmc_to(plmc_ct_account_deposits.clone()); inst.mint_statemint_asset_to(usdt_fundings.clone()); - inst.bid_for_users(project_id, vec![glutton_bid_1, rejected_bid, glutton_bid_2]); + inst.bid_for_users(project_id, vec![glutton_bid_1, rejected_bid, glutton_bid_2]).unwrap(); inst.do_free_plmc_assertions(vec![ UserToPLMCBalance::new(BIDDER_1, MockInstantiator::get_ed()), @@ -1998,7 +2069,7 @@ mod auction_round_failure { inst.mint_plmc_to(plmc_ct_account_deposits.clone()); inst.mint_statemint_asset_to(usdt_fundings.clone()); - inst.bid_for_users(project_id, vec![bid_in]); + inst.bid_for_users(project_id, vec![bid_in]).unwrap(); inst.advance_time( ::EnglishAuctionDuration::get() + ::CandleAuctionDuration::get() - @@ -2006,7 +2077,7 @@ mod auction_round_failure { ) .unwrap(); - inst.bid_for_users(project_id, vec![bid_out]); + inst.bid_for_users(project_id, vec![bid_out]).unwrap(); inst.do_free_plmc_assertions(vec![ UserToPLMCBalance::new(BIDDER_1, MockInstantiator::get_ed()), @@ -5850,157 +5921,7 @@ mod misc_features { mod async_tests { use super::*; - use core::sync::atomic::Ordering; - use futures::FutureExt; use instantiator::async_features::*; - use sp_std::sync::Arc; - use tokio::{runtime::Runtime, sync::Mutex}; - - #[test] - fn prototype_1() { - let tokio_runtime = Runtime::new().unwrap(); - let inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); - - let _inst = tokio_runtime.block_on(async { - let block_orchestrator = Arc::new(BlockOrchestrator::new()); - let mutex_inst = Arc::new(Mutex::new(inst)); - - let controller_handle = tokio::spawn(block_controller(block_orchestrator.clone(), mutex_inst.clone())); - - let project_creations = vec![ - async_create_new_project(mutex_inst.clone(), default_project(0, ISSUER), ISSUER).boxed(), - async_create_evaluating_project(mutex_inst.clone(), default_project(1, ISSUER), ISSUER).boxed(), - async_create_auctioning_project( - mutex_inst.clone(), - block_orchestrator.clone(), - default_project(2, ISSUER), - ISSUER, - default_evaluations(), - ) - .boxed(), - async_create_community_contributing_project( - mutex_inst.clone(), - block_orchestrator.clone(), - default_project(3, ISSUER), - ISSUER, - default_evaluations(), - default_bids(), - ) - .map(|(project_id, _)| project_id) - .boxed(), - async_create_community_contributing_project( - mutex_inst.clone(), - block_orchestrator.clone(), - default_project(4, ISSUER), - ISSUER, - default_evaluations(), - default_bids(), - ) - .map(|(project_id, _)| project_id) - .boxed(), - async_create_community_contributing_project( - mutex_inst.clone(), - block_orchestrator.clone(), - default_project(5, ISSUER), - ISSUER, - default_evaluations(), - default_bids(), - ) - .map(|(project_id, _)| project_id) - .boxed(), - async_create_remainder_contributing_project( - mutex_inst.clone(), - block_orchestrator.clone(), - default_project(6, ISSUER), - ISSUER, - default_evaluations(), - default_bids(), - default_community_buys(), - ) - .map(|(project_id, _)| project_id) - .boxed(), - async_create_remainder_contributing_project( - mutex_inst.clone(), - block_orchestrator.clone(), - default_project(7, ISSUER), - ISSUER, - default_evaluations(), - default_bids(), - default_community_buys(), - ) - .map(|(project_id, _)| project_id) - .boxed(), - async_create_remainder_contributing_project( - mutex_inst.clone(), - block_orchestrator.clone(), - default_project(8, ISSUER), - ISSUER, - default_evaluations(), - default_bids(), - default_community_buys(), - ) - .map(|(project_id, _)| project_id) - .boxed(), - async_create_finished_project( - mutex_inst.clone(), - block_orchestrator.clone(), - default_project(9, ISSUER), - ISSUER, - default_evaluations(), - default_bids(), - default_community_buys(), - default_remainder_buys(), - ) - .boxed(), - async_create_finished_project( - mutex_inst.clone(), - block_orchestrator.clone(), - default_project(10, ISSUER), - ISSUER, - default_evaluations(), - default_bids(), - default_community_buys(), - default_remainder_buys(), - ) - .boxed(), - async_create_finished_project( - mutex_inst.clone(), - block_orchestrator.clone(), - default_project(11, ISSUER), - ISSUER, - default_evaluations(), - default_bids(), - default_community_buys(), - default_remainder_buys(), - ) - .boxed(), - ]; - // Wait for all project creation tasks to complete - futures::future::join_all(project_creations).await; - - // Now that all projects have been set up, signal the block_controller to stop - block_orchestrator.should_continue.store(false, Ordering::SeqCst); - - // Wait for the block controller to finish - controller_handle.await.unwrap(); - - let mut inst = mutex_inst.lock().await; - let events = inst.execute(|| frame_system::Pallet::::events()); - dbg!(events); - dbg!(inst.get_project_details(0).status); - dbg!(inst.get_project_details(1).status); - dbg!(inst.get_project_details(2).status); - dbg!(inst.get_project_details(3).status); - dbg!(inst.get_project_details(4).status); - dbg!(inst.get_project_details(5).status); - dbg!(inst.get_project_details(6).status); - dbg!(inst.get_project_details(7).status); - dbg!(inst.get_project_details(8).status); - dbg!(inst.get_project_details(9).status); - dbg!(inst.get_project_details(10).status); - dbg!(inst.get_project_details(11).status); - }); - } #[test] fn prototype_2() { diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index 748cca149..66326479b 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -1128,20 +1128,96 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().writes(2)) } - fn end_funding_automatically_rejected_evaluators_slashed(x: u32) -> Weight { - Weight::from_parts(203_000_000, 0) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn end_funding_automatically_rejected_evaluators_slashed(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `822 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 296_000_000 picoseconds. + Weight::from_parts(284_006_640, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 85_755 + .saturating_add(Weight::from_parts(36_442_516, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) } - - fn end_funding_awaiting_decision_evaluators_slashed(x: u32) -> Weight { - Weight::from_parts(203_000_000, 0) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn end_funding_awaiting_decision_evaluators_slashed(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `822 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 233_000_000 picoseconds. + Weight::from_parts(213_045_370, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 117_943 + .saturating_add(Weight::from_parts(36_217_046, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) } - - fn end_funding_awaiting_decision_evaluators_unchanged(x: u32) -> Weight { - Weight::from_parts(203_000_000, 0) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn end_funding_awaiting_decision_evaluators_unchanged(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `822 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 236_000_000 picoseconds. + Weight::from_parts(245_084_435, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 136_756 + .saturating_add(Weight::from_parts(35_663_280, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) } - - fn end_funding_automatically_accepted_evaluators_rewarded(x: u32, y: u32) -> Weight { - Weight::from_parts(203_000_000, 0) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:2049 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + /// The range of component `y` is `[1, 2048]`. + fn end_funding_automatically_accepted_evaluators_rewarded(x: u32, y: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1199 + x * (529 ±0) + y * (187 ±0)` + // Estimated: `4087 + x * (3097 ±0) + y * (2820 ±0)` + // Minimum execution time: 4_119_000_000 picoseconds. + Weight::from_parts(4_122_000_000, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 13_179_751 + .saturating_add(Weight::from_parts(37_293_090, 0).saturating_mul(x.into())) + // Standard Error: 636_741 + .saturating_add(Weight::from_parts(74_778_225, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into()))) + .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 2820).saturating_mul(y.into())) } } @@ -2128,20 +2204,95 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(2)) .saturating_add(RocksDbWeight::get().writes(2)) } - - fn end_funding_automatically_rejected_evaluators_slashed(x: u32) -> Weight { - Weight::from_parts(203_000_000, 0) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn end_funding_automatically_rejected_evaluators_slashed(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `822 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 296_000_000 picoseconds. + Weight::from_parts(284_006_640, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 85_755 + .saturating_add(Weight::from_parts(36_442_516, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) } - - fn end_funding_awaiting_decision_evaluators_slashed(x: u32) -> Weight { - Weight::from_parts(203_000_000, 0) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn end_funding_awaiting_decision_evaluators_slashed(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `822 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 233_000_000 picoseconds. + Weight::from_parts(213_045_370, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 117_943 + .saturating_add(Weight::from_parts(36_217_046, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) } - - fn end_funding_awaiting_decision_evaluators_unchanged(x: u32) -> Weight { - Weight::from_parts(203_000_000, 0) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn end_funding_awaiting_decision_evaluators_unchanged(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `822 + x * (529 ±0)` + // Estimated: `4087 + x * (3097 ±0)` + // Minimum execution time: 236_000_000 picoseconds. + Weight::from_parts(245_084_435, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 136_756 + .saturating_add(Weight::from_parts(35_663_280, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) } - - fn end_funding_automatically_accepted_evaluators_rewarded(x: u32, y: u32) -> Weight { - Weight::from_parts(203_000_000, 0) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:2049 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + /// The range of component `y` is `[1, 2048]`. + fn end_funding_automatically_accepted_evaluators_rewarded(x: u32, y: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1199 + x * (529 ±0) + y * (187 ±0)` + // Estimated: `4087 + x * (3097 ±0) + y * (2820 ±0)` + // Minimum execution time: 4_119_000_000 picoseconds. + Weight::from_parts(4_122_000_000, 0) + .saturating_add(Weight::from_parts(0, 4087)) + // Standard Error: 13_179_751 + .saturating_add(Weight::from_parts(37_293_090, 0).saturating_mul(x.into())) + // Standard Error: 636_741 + .saturating_add(Weight::from_parts(74_778_225, 0).saturating_mul(y.into())) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(y.into()))) + .saturating_add(RocksDbWeight::get().writes(2)) + .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 2820).saturating_mul(y.into())) } } \ No newline at end of file diff --git a/runtimes/shared-configuration/Cargo.toml b/runtimes/shared-configuration/Cargo.toml index b98ef0ffa..ae474d955 100644 --- a/runtimes/shared-configuration/Cargo.toml +++ b/runtimes/shared-configuration/Cargo.toml @@ -34,6 +34,7 @@ pallet-balances.workspace = true pallet-authorship.workspace = true pallet-parachain-staking.workspace = true + [features] default = [ "std" ] fast-gov = [] diff --git a/runtimes/testnet/Cargo.toml b/runtimes/testnet/Cargo.toml index 8de1dac1b..409b22440 100644 --- a/runtimes/testnet/Cargo.toml +++ b/runtimes/testnet/Cargo.toml @@ -21,6 +21,9 @@ hex-literal = { workspace = true, optional = true } serde = { workspace = true, features = ["derive"] } smallvec.workspace = true +# Uncomment this to see variables instead of in the console output +#sp-debug-derive = { workspace = true, features = ["force-debug"]} + # Polimec specific pallet-funding.workspace = true pallet-oracle-ocw.workspace = true diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index e72e782ca..6221feb8a 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -578,7 +578,7 @@ impl pallet_funding::Config for Runtime { type MaxEvaluationsPerUser = ConstU32<16>; type MaxMessageSizeThresholds = MaxMessageSizeThresholds; type MaxProjectsToUpdateInsertionAttempts = ConstU32<100>; - type MaxProjectsToUpdatePerBlock = ConstU32<100>; + type MaxProjectsToUpdatePerBlock = ConstU32<1>; type Multiplier = pallet_funding::types::Multiplier; type NativeCurrency = Balances; type PalletId = FundingPalletId; From 06a89941eb18574b8077a2ef457571719d7f63ae Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 8 Feb 2024 14:59:51 +0100 Subject: [PATCH 201/212] fix warnings Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 2 +- pallets/funding/src/instantiator.rs | 2 +- pallets/funding/src/tests.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 530a866f4..c17fbc5f4 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -3640,7 +3640,7 @@ mod benchmarks { #[block] { - let result = Pallet::::do_start_settlement(project_id).unwrap(); + Pallet::::do_start_settlement(project_id).unwrap(); } // * validity checks * diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 540fc22f5..01fc73644 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -5,7 +5,7 @@ use crate::{ use frame_support::{ pallet_prelude::*, traits::{ - fungible::{Inspect as FungibleInspect, InspectHold as FungibleInspectHold, Mutate as FungibleMutate, Mutate}, + fungible::{Inspect as FungibleInspect, InspectHold as FungibleInspectHold, Mutate as FungibleMutate}, fungibles::{ metadata::{Inspect as MetadataInspect, MetadataDeposit}, roles::Inspect as RolesInspect, diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index c85603cd1..2313a8901 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -818,7 +818,7 @@ mod auction_round_success { inst.mint_plmc_to(plmc_funding); inst.mint_statemint_asset_to(statemint_funding); - inst.bid_for_users(project_id, bids); + inst.bid_for_users(project_id, bids).unwrap(); inst.start_community_funding(project_id).unwrap(); } From 08697675c8fe21181282f5378abbd32416f3f35d Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 8 Feb 2024 15:54:01 +0100 Subject: [PATCH 202/212] fix tests Signed-off-by: Juan Ignacio Rios --- Cargo.lock | 751 ++++++++++++++++++++++++++++ Cargo.toml | 4 +- pallets/funding/src/benchmarking.rs | 13 +- pallets/funding/src/instantiator.rs | 7 +- pallets/funding/src/lib.rs | 23 + 5 files changed, 788 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 26a9bcfdd..3c7db03a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -125,6 +125,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + [[package]] name = "ansi_term" version = "0.12.1" @@ -272,6 +278,98 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15832d94c458da98cac0ffa6eca52cc19c2a3c6c951058500a5ae8f01f0fdf56" +[[package]] +name = "asset-hub-polkadot-runtime" +version = "0.9.420" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "assets-common", + "cumulus-pallet-aura-ext", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-session-benchmarking", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-timestamp", + "cumulus-primitives-utility", + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal 0.4.1", + "log", + "pallet-asset-tx-payment", + "pallet-assets", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-multisig", + "pallet-nfts", + "pallet-nfts-runtime-api", + "pallet-proxy", + "pallet-session", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-uniques", + "pallet-utility", + "pallet-xcm", + "pallet-xcm-benchmarks", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-runtime-common", + "polkadot-runtime-constants", + "scale-info", + "smallvec", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "sp-weights", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "assets-common" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "cumulus-primitives-core", + "frame-support", + "log", + "pallet-asset-conversion", + "pallet-asset-tx-payment", + "pallet-xcm", + "parachains-common", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-runtime", + "sp-std", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + [[package]] name = "async-channel" version = "1.9.0" @@ -719,6 +817,21 @@ dependencies = [ "thiserror", ] +[[package]] +name = "casey" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "614586263949597dcc18675da12ef9b429135e13628d92eb8b8c6fa50ca5656b" +dependencies = [ + "syn 1.0.109", +] + +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + [[package]] name = "cc" version = "1.0.83" @@ -797,6 +910,33 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "ciborium" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" + +[[package]] +name = "ciborium-ll" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" +dependencies = [ + "ciborium-io", + "half", +] + [[package]] name = "cid" version = "0.9.0" @@ -1167,6 +1307,44 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "criterion" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" +dependencies = [ + "anes", + "cast", + "ciborium", + "clap", + "criterion-plot", + "futures", + "is-terminal", + "itertools 0.10.5", + "num-traits", + "once_cell", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_derive", + "serde_json", + "tinytemplate", + "tokio", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" +dependencies = [ + "cast", + "itertools 0.10.5", +] + [[package]] name = "critical-section" version = "1.1.2" @@ -1398,6 +1576,29 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cumulus-client-consensus-relay-chain" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "async-trait", + "cumulus-client-consensus-common", + "cumulus-primitives-core", + "cumulus-relay-chain-interface", + "futures", + "parking_lot 0.12.1", + "sc-consensus", + "sp-api", + "sp-block-builder", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-inherents", + "sp-runtime", + "substrate-prometheus-endpoint", + "tracing", +] + [[package]] name = "cumulus-client-network" version = "0.1.0" @@ -1812,6 +2013,119 @@ dependencies = [ "sp-std", ] +[[package]] +name = "cumulus-test-relay-validation-worker-provider" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "polkadot-node-core-pvf", + "toml 0.7.8", +] + +[[package]] +name = "cumulus-test-runtime" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "cumulus-pallet-parachain-system", + "cumulus-primitives-core", + "cumulus-primitives-timestamp", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "pallet-balances", + "pallet-glutton", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-block-builder", + "sp-core", + "sp-inherents", + "sp-io", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", +] + +[[package]] +name = "cumulus-test-service" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "async-trait", + "clap", + "criterion", + "cumulus-client-cli", + "cumulus-client-consensus-common", + "cumulus-client-consensus-relay-chain", + "cumulus-client-pov-recovery", + "cumulus-client-service", + "cumulus-pallet-parachain-system", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-relay-chain-inprocess-interface", + "cumulus-relay-chain-interface", + "cumulus-relay-chain-minimal-node", + "cumulus-test-relay-sproof-builder", + "cumulus-test-relay-validation-worker-provider", + "cumulus-test-runtime", + "frame-system", + "frame-system-rpc-runtime-api", + "jsonrpsee", + "pallet-timestamp", + "pallet-transaction-payment", + "parachains-common", + "parity-scale-codec", + "polkadot-cli", + "polkadot-node-subsystem", + "polkadot-overseer", + "polkadot-primitives", + "polkadot-service", + "polkadot-test-service", + "rand 0.8.5", + "sc-basic-authorship", + "sc-block-builder", + "sc-chain-spec", + "sc-cli", + "sc-client-api", + "sc-consensus", + "sc-executor", + "sc-executor-common", + "sc-executor-wasmtime", + "sc-network", + "sc-service", + "sc-telemetry", + "sc-tracing", + "sc-transaction-pool", + "sc-transaction-pool-api", + "serde", + "sp-api", + "sp-arithmetic", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-io", + "sp-keyring", + "sp-runtime", + "sp-state-machine", + "sp-timestamp", + "sp-tracing", + "sp-trie", + "substrate-test-client", + "tempfile", + "tokio", + "tracing", + "url", +] + [[package]] name = "curve25519-dalek" version = "2.1.3" @@ -3168,6 +3482,16 @@ dependencies = [ "tracing", ] +[[package]] +name = "half" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc52e53916c08643f1b56ec082790d1e86a32e58dc5268f897f313fbae7b4872" +dependencies = [ + "cfg-if", + "crunchy", +] + [[package]] name = "handlebars" version = "4.5.0" @@ -3599,6 +3923,61 @@ dependencies = [ "num-traits", ] +[[package]] +name = "integration-tests" +version = "0.4.0" +dependencies = [ + "asset-hub-polkadot-runtime", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "frame-support", + "frame-system", + "itertools 0.11.0", + "macros", + "orml-oracle", + "pallet-assets", + "pallet-balances", + "pallet-funding", + "pallet-im-online", + "pallet-linear-release", + "pallet-membership", + "pallet-message-queue", + "pallet-parachain-staking", + "pallet-staking", + "pallet-vesting", + "pallet-xcm", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "penpal-runtime", + "polimec-base-runtime", + "polimec-common", + "polimec-parachain-runtime", + "polimec-receiver", + "polkadot-core-primitives", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime", + "polkadot-runtime-constants", + "polkadot-runtime-parachains", + "polkadot-service", + "sc-consensus-grandpa", + "scale-info", + "sp-arithmetic", + "sp-authority-discovery", + "sp-consensus-babe", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-emulator", + "xcm-executor", +] + [[package]] name = "io-lifetimes" version = "1.0.11" @@ -5233,6 +5612,12 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +[[package]] +name = "oorandom" +version = "11.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" + [[package]] name = "opaque-debug" version = "0.2.3" @@ -5345,6 +5730,24 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-asset-conversion" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-asset-tx-payment" version = "4.0.0-dev" @@ -5747,6 +6150,24 @@ dependencies = [ "xcm-executor", ] +[[package]] +name = "pallet-glutton" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "blake2", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-grandpa" version = "4.0.0-dev" @@ -5926,6 +6347,35 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-nfts" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "enumflags2", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "pallet-nfts-runtime-api" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "frame-support", + "pallet-nfts", + "parity-scale-codec", + "sp-api", +] + [[package]] name = "pallet-nis" version = "4.0.0-dev" @@ -6443,6 +6893,21 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-uniques" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "parity-scale-codec", + "scale-info", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-utility" version = "4.0.0-dev" @@ -6730,6 +7195,69 @@ dependencies = [ "base64 0.13.1", ] +[[package]] +name = "penpal-runtime" +version = "0.9.27" +dependencies = [ + "cumulus-pallet-aura-ext", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-session-benchmarking", + "cumulus-pallet-xcm", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-timestamp", + "cumulus-primitives-utility", + "frame-benchmarking", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-benchmarking", + "frame-system-rpc-runtime-api", + "frame-try-runtime", + "hex-literal 0.4.1", + "log", + "pallet-asset-tx-payment", + "pallet-assets", + "pallet-aura", + "pallet-authorship", + "pallet-balances", + "pallet-collator-selection", + "pallet-session", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-vesting", + "pallet-xcm", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "polimec-common", + "polimec-receiver", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "scale-info", + "smallvec", + "sp-api", + "sp-block-builder", + "sp-consensus-aura", + "sp-core", + "sp-inherents", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", + "xcm", + "xcm-builder", + "xcm-executor", +] + [[package]] name = "percent-encoding" version = "2.3.1" @@ -6851,6 +7379,34 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" +[[package]] +name = "plotters" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" + +[[package]] +name = "plotters-svg" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +dependencies = [ + "plotters-backend", +] + [[package]] name = "polimec-base-runtime" version = "0.4.0" @@ -8309,6 +8865,118 @@ dependencies = [ "sp-core", ] +[[package]] +name = "polkadot-test-runtime" +version = "1.0.0" +source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" +dependencies = [ + "bitvec", + "frame-election-provider-support", + "frame-executive", + "frame-support", + "frame-system", + "frame-system-rpc-runtime-api", + "log", + "pallet-authority-discovery", + "pallet-authorship", + "pallet-babe", + "pallet-balances", + "pallet-grandpa", + "pallet-indices", + "pallet-offences", + "pallet-session", + "pallet-staking", + "pallet-staking-reward-curve", + "pallet-sudo", + "pallet-timestamp", + "pallet-transaction-payment", + "pallet-transaction-payment-rpc-runtime-api", + "pallet-vesting", + "pallet-xcm", + "parity-scale-codec", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "rustc-hex", + "scale-info", + "serde", + "serde_derive", + "smallvec", + "sp-api", + "sp-authority-discovery", + "sp-block-builder", + "sp-consensus-babe", + "sp-consensus-beefy", + "sp-core", + "sp-inherents", + "sp-io", + "sp-mmr-primitives", + "sp-offchain", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-std", + "sp-transaction-pool", + "sp-version", + "substrate-wasm-builder", + "test-runtime-constants", + "xcm", + "xcm-builder", + "xcm-executor", +] + +[[package]] +name = "polkadot-test-service" +version = "1.0.0" +source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" +dependencies = [ + "frame-system", + "futures", + "hex", + "pallet-balances", + "pallet-staking", + "pallet-transaction-payment", + "polkadot-node-primitives", + "polkadot-node-subsystem", + "polkadot-overseer", + "polkadot-parachain", + "polkadot-primitives", + "polkadot-rpc", + "polkadot-runtime-common", + "polkadot-runtime-parachains", + "polkadot-service", + "polkadot-test-runtime", + "rand 0.8.5", + "sc-authority-discovery", + "sc-chain-spec", + "sc-cli", + "sc-client-api", + "sc-consensus", + "sc-consensus-babe", + "sc-consensus-grandpa", + "sc-network", + "sc-service", + "sc-tracing", + "sc-transaction-pool", + "sp-arithmetic", + "sp-authority-discovery", + "sp-blockchain", + "sp-consensus", + "sp-consensus-babe", + "sp-consensus-grandpa", + "sp-core", + "sp-inherents", + "sp-keyring", + "sp-runtime", + "sp-state-machine", + "substrate-test-client", + "tempfile", + "test-runtime-constants", + "tokio", + "tracing-gum", +] + [[package]] name = "polling" version = "3.3.1" @@ -11807,6 +12475,32 @@ dependencies = [ "trie-db", ] +[[package]] +name = "substrate-test-client" +version = "2.0.1" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "array-bytes", + "async-trait", + "futures", + "parity-scale-codec", + "sc-client-api", + "sc-client-db", + "sc-consensus", + "sc-executor", + "sc-offchain", + "sc-service", + "serde", + "serde_json", + "sp-blockchain", + "sp-consensus", + "sp-core", + "sp-keyring", + "sp-keystore", + "sp-runtime", + "sp-state-machine", +] + [[package]] name = "substrate-typenum" version = "1.16.0" @@ -11936,6 +12630,20 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" +[[package]] +name = "test-runtime-constants" +version = "1.0.0" +source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" +dependencies = [ + "frame-support", + "polkadot-primitives", + "polkadot-runtime-common", + "smallvec", + "sp-core", + "sp-runtime", + "sp-weights", +] + [[package]] name = "thiserror" version = "1.0.50" @@ -12072,6 +12780,16 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "tinyvec" version = "1.6.0" @@ -13515,6 +14233,39 @@ dependencies = [ "xcm-executor", ] +[[package]] +name = "xcm-emulator" +version = "0.1.0" +source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" +dependencies = [ + "casey", + "cumulus-pallet-dmp-queue", + "cumulus-pallet-parachain-system", + "cumulus-pallet-xcmp-queue", + "cumulus-primitives-core", + "cumulus-primitives-parachain-inherent", + "cumulus-test-relay-sproof-builder", + "cumulus-test-service", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "pallet-message-queue", + "parachain-info", + "parachains-common", + "parity-scale-codec", + "paste", + "polkadot-primitives", + "polkadot-runtime-parachains", + "quote", + "sp-arithmetic", + "sp-core", + "sp-io", + "sp-std", + "sp-trie", + "xcm", +] + [[package]] name = "xcm-executor" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index b56a9782d..4f1606094 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,8 +3,8 @@ members = [ "nodes/*", "runtimes/*", "pallets/*", -# "integration-tests", -# "integration-tests/penpal", + "integration-tests", + "integration-tests/penpal", "macros", "macros/tests", "polimec-common", diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index c17fbc5f4..670dc5b27 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -18,8 +18,6 @@ //! Benchmarking setup for Funding pallet -use sp_runtime::traits::TrailingZeroInput; - use super::*; use crate::instantiator::*; use frame_benchmarking::v2::*; @@ -29,6 +27,7 @@ use frame_support::{ dispatch::RawOrigin, traits::{ fungible::{InspectHold, MutateHold}, + fungibles::metadata::MetadataDeposit, OriginTrait, }, Parameter, @@ -41,7 +40,7 @@ use scale_info::prelude::format; use sp_arithmetic::Percent; use sp_core::H256; use sp_io::hashing::blake2_256; -use sp_runtime::traits::{BlakeTwo256, Get, Member}; +use sp_runtime::traits::{BlakeTwo256, Get, Member, TrailingZeroInput}; const METADATA: &str = r#" { @@ -380,10 +379,14 @@ mod benchmarks { let issuer = account::>("issuer", 0, 0); whitelist_account!(issuer); - inst.mint_plmc_to(vec![UserToPLMCBalance::new(issuer.clone(), ed * 2u64.into())]); - let project_metadata = default_project::(inst.get_new_nonce(), issuer.clone()); + let metadata_deposit = T::ContributionTokenCurrency::calc_metadata_deposit( + project_metadata.token_information.name.as_slice(), + project_metadata.token_information.symbol.as_slice(), + ); + inst.mint_plmc_to(vec![UserToPLMCBalance::new(issuer.clone(), ed * 2u64.into() + metadata_deposit)]); + #[extrinsic_call] create(RawOrigin::Signed(issuer.clone()), project_metadata.clone()); diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 01fc73644..ce48c784f 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -337,12 +337,13 @@ impl< pub fn test_ct_created_for(&mut self, project_id: ProjectId) { self.execute(|| { let metadata = ProjectsMetadata::::get(project_id).unwrap(); - let details = ProjectsDetails::::get(project_id).unwrap(); assert_eq!( ::ContributionTokenCurrency::name(project_id), metadata.token_information.name.to_vec() ); - assert_eq!(::ContributionTokenCurrency::admin(project_id).unwrap(), details.issuer); + let escrow_account = Pallet::::fund_account_id(project_id); + + assert_eq!(::ContributionTokenCurrency::admin(project_id).unwrap(), escrow_account); assert_eq!( ::ContributionTokenCurrency::total_issuance(project_id), 0u32.into(), @@ -863,11 +864,11 @@ impl< pub fn create_new_project(&mut self, project_metadata: ProjectMetadataOf, issuer: AccountIdOf) -> ProjectId { let now = self.current_block(); - // one ED for the issuer, one ED for the escrow account let metadata_deposit = T::ContributionTokenCurrency::calc_metadata_deposit( project_metadata.token_information.name.as_slice(), project_metadata.token_information.symbol.as_slice(), ); + // one ED for the issuer, one ED for the escrow account self.mint_plmc_to(vec![UserToPLMCBalance::new( issuer.clone(), Self::get_ed() * 2u64.into() + metadata_deposit, diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 56ef19fff..1b7c7f267 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -390,6 +390,7 @@ pub mod pallet { type MaxProjectsToUpdatePerBlock: Get; /// How many distinct evaluations per user per project + #[pallet::constant] type MaxEvaluationsPerUser: Get; /// The maximum number of bids per user per project @@ -407,8 +408,10 @@ pub mod pallet { /// Weight information for extrinsics in this pallet. type WeightInfo: weights::WeightInfo; + #[pallet::constant] type FeeBrackets: Get::Balance)>>; + #[pallet::constant] type EvaluationSuccessThreshold: Get; type Vesting: polimec_common::ReleaseSchedule< @@ -417,13 +420,19 @@ pub mod pallet { Currency = Self::NativeCurrency, Moment = BlockNumberFor, >; + /// For now we expect 3 days until the project is automatically accepted. Timeline decided by MiCA regulations. + #[pallet::constant] type ManualAcceptanceDuration: Get>; + /// For now we expect 4 days from acceptance to settlement due to MiCA regulations. + #[pallet::constant] type SuccessToSettlementTime: Get>; + #[pallet::constant] type EvaluatorSlash: Get; + #[pallet::constant] type TreasuryAccount: Get>; /// Convert 24 hours as FixedU128, to the corresponding amount of blocks in the same type as frame_system @@ -431,20 +440,34 @@ pub mod pallet { type BlockNumberToBalance: Convert, BalanceOf>; + #[pallet::constant] type PolimecReceiverInfo: Get; /// Range of max_message_size values for the hrmp config where we accept the incoming channel request + #[pallet::constant] type MaxMessageSizeThresholds: Get<(u32, u32)>; + /// Range of max_capacity_thresholds values for the hrmp config where we accept the incoming channel request + #[pallet::constant] type MaxCapacityThresholds: Get<(u32, u32)>; + /// max_capacity config required for the channel from polimec to the project + #[pallet::constant] type RequiredMaxCapacity: Get; + /// max_message_size config required for the channel from polimec to the project + #[pallet::constant] type RequiredMaxMessageSize: Get; + /// max iterations for trying to insert a project on the projects_to_update storage + #[pallet::constant] type MaxProjectsToUpdateInsertionAttempts: Get; + /// max individual bids per project. Used to estimate worst case weight for price calculation + #[pallet::constant] type MaxBidsPerProject: Get; + + #[pallet::constant] type MaxEvaluationsPerProject: Get; } From b8756949c1521a7545e8d54b193c41e0d946749f Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Thu, 8 Feb 2024 16:10:05 +0100 Subject: [PATCH 203/212] fix benchmark Signed-off-by: Juan Ignacio Rios --- Cargo.lock | 870 ++-------------------------- Cargo.toml | 4 +- pallets/funding/src/benchmarking.rs | 3 +- runtimes/testnet/Cargo.toml | 2 +- 4 files changed, 64 insertions(+), 815 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3c7db03a9..563899308 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -125,12 +125,6 @@ dependencies = [ "libc", ] -[[package]] -name = "anes" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" - [[package]] name = "ansi_term" version = "0.12.1" @@ -278,98 +272,6 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15832d94c458da98cac0ffa6eca52cc19c2a3c6c951058500a5ae8f01f0fdf56" -[[package]] -name = "asset-hub-polkadot-runtime" -version = "0.9.420" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "assets-common", - "cumulus-pallet-aura-ext", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-session-benchmarking", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "cumulus-primitives-timestamp", - "cumulus-primitives-utility", - "frame-benchmarking", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal 0.4.1", - "log", - "pallet-asset-tx-payment", - "pallet-assets", - "pallet-aura", - "pallet-authorship", - "pallet-balances", - "pallet-collator-selection", - "pallet-multisig", - "pallet-nfts", - "pallet-nfts-runtime-api", - "pallet-proxy", - "pallet-session", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-uniques", - "pallet-utility", - "pallet-xcm", - "pallet-xcm-benchmarks", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "polkadot-core-primitives", - "polkadot-parachain", - "polkadot-runtime-common", - "polkadot-runtime-constants", - "scale-info", - "smallvec", - "sp-api", - "sp-block-builder", - "sp-consensus-aura", - "sp-core", - "sp-inherents", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "sp-weights", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "assets-common" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "cumulus-primitives-core", - "frame-support", - "log", - "pallet-asset-conversion", - "pallet-asset-tx-payment", - "pallet-xcm", - "parachains-common", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-runtime", - "sp-std", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", -] - [[package]] name = "async-channel" version = "1.9.0" @@ -817,21 +719,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "casey" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614586263949597dcc18675da12ef9b429135e13628d92eb8b8c6fa50ca5656b" -dependencies = [ - "syn 1.0.109", -] - -[[package]] -name = "cast" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" - [[package]] name = "cc" version = "1.0.83" @@ -910,33 +797,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "ciborium" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" -dependencies = [ - "ciborium-io", - "ciborium-ll", - "serde", -] - -[[package]] -name = "ciborium-io" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" - -[[package]] -name = "ciborium-ll" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" -dependencies = [ - "ciborium-io", - "half", -] - [[package]] name = "cid" version = "0.9.0" @@ -1307,44 +1167,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "criterion" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2b12d017a929603d80db1831cd3a24082f8137ce19c69e6447f54f5fc8d692f" -dependencies = [ - "anes", - "cast", - "ciborium", - "clap", - "criterion-plot", - "futures", - "is-terminal", - "itertools 0.10.5", - "num-traits", - "once_cell", - "oorandom", - "plotters", - "rayon", - "regex", - "serde", - "serde_derive", - "serde_json", - "tinytemplate", - "tokio", - "walkdir", -] - -[[package]] -name = "criterion-plot" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b50826342786a51a89e2da3a28f1c32b06e387201bc2d19791f622c673706b1" -dependencies = [ - "cast", - "itertools 0.10.5", -] - [[package]] name = "critical-section" version = "1.1.2" @@ -1576,29 +1398,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "cumulus-client-consensus-relay-chain" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "async-trait", - "cumulus-client-consensus-common", - "cumulus-primitives-core", - "cumulus-relay-chain-interface", - "futures", - "parking_lot 0.12.1", - "sc-consensus", - "sp-api", - "sp-block-builder", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-inherents", - "sp-runtime", - "substrate-prometheus-endpoint", - "tracing", -] - [[package]] name = "cumulus-client-network" version = "0.1.0" @@ -2006,124 +1805,11 @@ version = "0.1.0" source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" dependencies = [ "cumulus-primitives-core", - "parity-scale-codec", - "polkadot-primitives", - "sp-runtime", - "sp-state-machine", - "sp-std", -] - -[[package]] -name = "cumulus-test-relay-validation-worker-provider" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "polkadot-node-core-pvf", - "toml 0.7.8", -] - -[[package]] -name = "cumulus-test-runtime" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "cumulus-pallet-parachain-system", - "cumulus-primitives-core", - "cumulus-primitives-timestamp", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-rpc-runtime-api", - "pallet-balances", - "pallet-glutton", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-block-builder", - "sp-core", - "sp-inherents", - "sp-io", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", -] - -[[package]] -name = "cumulus-test-service" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "async-trait", - "clap", - "criterion", - "cumulus-client-cli", - "cumulus-client-consensus-common", - "cumulus-client-consensus-relay-chain", - "cumulus-client-pov-recovery", - "cumulus-client-service", - "cumulus-pallet-parachain-system", - "cumulus-primitives-core", - "cumulus-primitives-parachain-inherent", - "cumulus-relay-chain-inprocess-interface", - "cumulus-relay-chain-interface", - "cumulus-relay-chain-minimal-node", - "cumulus-test-relay-sproof-builder", - "cumulus-test-relay-validation-worker-provider", - "cumulus-test-runtime", - "frame-system", - "frame-system-rpc-runtime-api", - "jsonrpsee", - "pallet-timestamp", - "pallet-transaction-payment", - "parachains-common", - "parity-scale-codec", - "polkadot-cli", - "polkadot-node-subsystem", - "polkadot-overseer", - "polkadot-primitives", - "polkadot-service", - "polkadot-test-service", - "rand 0.8.5", - "sc-basic-authorship", - "sc-block-builder", - "sc-chain-spec", - "sc-cli", - "sc-client-api", - "sc-consensus", - "sc-executor", - "sc-executor-common", - "sc-executor-wasmtime", - "sc-network", - "sc-service", - "sc-telemetry", - "sc-tracing", - "sc-transaction-pool", - "sc-transaction-pool-api", - "serde", - "sp-api", - "sp-arithmetic", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-io", - "sp-keyring", - "sp-runtime", - "sp-state-machine", - "sp-timestamp", - "sp-tracing", - "sp-trie", - "substrate-test-client", - "tempfile", - "tokio", - "tracing", - "url", + "parity-scale-codec", + "polkadot-primitives", + "sp-runtime", + "sp-state-machine", + "sp-std", ] [[package]] @@ -3482,16 +3168,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "half" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc52e53916c08643f1b56ec082790d1e86a32e58dc5268f897f313fbae7b4872" -dependencies = [ - "cfg-if", - "crunchy", -] - [[package]] name = "handlebars" version = "4.5.0" @@ -3923,61 +3599,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "integration-tests" -version = "0.4.0" -dependencies = [ - "asset-hub-polkadot-runtime", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "frame-support", - "frame-system", - "itertools 0.11.0", - "macros", - "orml-oracle", - "pallet-assets", - "pallet-balances", - "pallet-funding", - "pallet-im-online", - "pallet-linear-release", - "pallet-membership", - "pallet-message-queue", - "pallet-parachain-staking", - "pallet-staking", - "pallet-vesting", - "pallet-xcm", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "penpal-runtime", - "polimec-base-runtime", - "polimec-common", - "polimec-parachain-runtime", - "polimec-receiver", - "polkadot-core-primitives", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime", - "polkadot-runtime-constants", - "polkadot-runtime-parachains", - "polkadot-service", - "sc-consensus-grandpa", - "scale-info", - "sp-arithmetic", - "sp-authority-discovery", - "sp-consensus-babe", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-emulator", - "xcm-executor", -] - [[package]] name = "io-lifetimes" version = "1.0.11" @@ -5612,12 +5233,6 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" -[[package]] -name = "oorandom" -version = "11.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" - [[package]] name = "opaque-debug" version = "0.2.3" @@ -5730,24 +5345,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-asset-conversion" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-api", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-asset-tx-payment" version = "4.0.0-dev" @@ -6150,24 +5747,6 @@ dependencies = [ "xcm-executor", ] -[[package]] -name = "pallet-glutton" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "blake2", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-grandpa" version = "4.0.0-dev" @@ -6347,35 +5926,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-nfts" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "enumflags2", - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-io", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "pallet-nfts-runtime-api" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "frame-support", - "pallet-nfts", - "parity-scale-codec", - "sp-api", -] - [[package]] name = "pallet-nis" version = "4.0.0-dev" @@ -6893,21 +6443,6 @@ dependencies = [ "sp-std", ] -[[package]] -name = "pallet-uniques" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "log", - "parity-scale-codec", - "scale-info", - "sp-runtime", - "sp-std", -] - [[package]] name = "pallet-utility" version = "4.0.0-dev" @@ -7139,123 +6674,60 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall 0.4.1", - "smallvec", - "windows-targets 0.48.5", -] - -[[package]] -name = "partial_sort" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" - -[[package]] -name = "paste" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" - -[[package]] -name = "pbkdf2" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" -dependencies = [ - "crypto-mac 0.11.1", -] - -[[package]] -name = "pbkdf2" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" -dependencies = [ - "digest 0.10.7", -] - -[[package]] -name = "peeking_take_while" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" - -[[package]] -name = "pem" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" -dependencies = [ - "base64 0.13.1", -] - -[[package]] -name = "penpal-runtime" -version = "0.9.27" -dependencies = [ - "cumulus-pallet-aura-ext", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-session-benchmarking", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "cumulus-primitives-timestamp", - "cumulus-primitives-utility", - "frame-benchmarking", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-benchmarking", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex-literal 0.4.1", - "log", - "pallet-asset-tx-payment", - "pallet-assets", - "pallet-aura", - "pallet-authorship", - "pallet-balances", - "pallet-collator-selection", - "pallet-session", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-vesting", - "pallet-xcm", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "polimec-common", - "polimec-receiver", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "scale-info", - "smallvec", - "sp-api", - "sp-block-builder", - "sp-consensus-aura", - "sp-core", - "sp-inherents", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", - "xcm", - "xcm-builder", - "xcm-executor", +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.4.1", + "smallvec", + "windows-targets 0.48.5", +] + +[[package]] +name = "partial_sort" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7924d1d0ad836f665c9065e26d016c673ece3993f30d340068b16f282afc1156" + +[[package]] +name = "paste" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" + +[[package]] +name = "pbkdf2" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d95f5254224e617595d2cc3cc73ff0a5eaf2637519e25f03388154e9378b6ffa" +dependencies = [ + "crypto-mac 0.11.1", +] + +[[package]] +name = "pbkdf2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" +dependencies = [ + "digest 0.10.7", +] + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "pem" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8835c273a76a90455d7344889b0964598e3316e2a79ede8e36f16bdcf2228b8" +dependencies = [ + "base64 0.13.1", ] [[package]] @@ -7379,34 +6851,6 @@ version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" -[[package]] -name = "plotters" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" -dependencies = [ - "num-traits", - "plotters-backend", - "plotters-svg", - "wasm-bindgen", - "web-sys", -] - -[[package]] -name = "plotters-backend" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" - -[[package]] -name = "plotters-svg" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" -dependencies = [ - "plotters-backend", -] - [[package]] name = "polimec-base-runtime" version = "0.4.0" @@ -7626,6 +7070,7 @@ dependencies = [ "sp-block-builder", "sp-consensus-aura", "sp-core", + "sp-debug-derive", "sp-inherents", "sp-io", "sp-offchain", @@ -8865,118 +8310,6 @@ dependencies = [ "sp-core", ] -[[package]] -name = "polkadot-test-runtime" -version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" -dependencies = [ - "bitvec", - "frame-election-provider-support", - "frame-executive", - "frame-support", - "frame-system", - "frame-system-rpc-runtime-api", - "log", - "pallet-authority-discovery", - "pallet-authorship", - "pallet-babe", - "pallet-balances", - "pallet-grandpa", - "pallet-indices", - "pallet-offences", - "pallet-session", - "pallet-staking", - "pallet-staking-reward-curve", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-vesting", - "pallet-xcm", - "parity-scale-codec", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "rustc-hex", - "scale-info", - "serde", - "serde_derive", - "smallvec", - "sp-api", - "sp-authority-discovery", - "sp-block-builder", - "sp-consensus-babe", - "sp-consensus-beefy", - "sp-core", - "sp-inherents", - "sp-io", - "sp-mmr-primitives", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-staking", - "sp-std", - "sp-transaction-pool", - "sp-version", - "substrate-wasm-builder", - "test-runtime-constants", - "xcm", - "xcm-builder", - "xcm-executor", -] - -[[package]] -name = "polkadot-test-service" -version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" -dependencies = [ - "frame-system", - "futures", - "hex", - "pallet-balances", - "pallet-staking", - "pallet-transaction-payment", - "polkadot-node-primitives", - "polkadot-node-subsystem", - "polkadot-overseer", - "polkadot-parachain", - "polkadot-primitives", - "polkadot-rpc", - "polkadot-runtime-common", - "polkadot-runtime-parachains", - "polkadot-service", - "polkadot-test-runtime", - "rand 0.8.5", - "sc-authority-discovery", - "sc-chain-spec", - "sc-cli", - "sc-client-api", - "sc-consensus", - "sc-consensus-babe", - "sc-consensus-grandpa", - "sc-network", - "sc-service", - "sc-tracing", - "sc-transaction-pool", - "sp-arithmetic", - "sp-authority-discovery", - "sp-blockchain", - "sp-consensus", - "sp-consensus-babe", - "sp-consensus-grandpa", - "sp-core", - "sp-inherents", - "sp-keyring", - "sp-runtime", - "sp-state-machine", - "substrate-test-client", - "tempfile", - "test-runtime-constants", - "tokio", - "tracing-gum", -] - [[package]] name = "polling" version = "3.3.1" @@ -12475,32 +11808,6 @@ dependencies = [ "trie-db", ] -[[package]] -name = "substrate-test-client" -version = "2.0.1" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" -dependencies = [ - "array-bytes", - "async-trait", - "futures", - "parity-scale-codec", - "sc-client-api", - "sc-client-db", - "sc-consensus", - "sc-executor", - "sc-offchain", - "sc-service", - "serde", - "serde_json", - "sp-blockchain", - "sp-consensus", - "sp-core", - "sp-keyring", - "sp-keystore", - "sp-runtime", - "sp-state-machine", -] - [[package]] name = "substrate-typenum" version = "1.16.0" @@ -12630,20 +11937,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" -[[package]] -name = "test-runtime-constants" -version = "1.0.0" -source = "git+https://github.com/paritytech/polkadot?branch=release-v1.0.0#c9ec8c5a15959ce711bb60aa79add58f560d61e9" -dependencies = [ - "frame-support", - "polkadot-primitives", - "polkadot-runtime-common", - "smallvec", - "sp-core", - "sp-runtime", - "sp-weights", -] - [[package]] name = "thiserror" version = "1.0.50" @@ -12780,16 +12073,6 @@ dependencies = [ "crunchy", ] -[[package]] -name = "tinytemplate" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" -dependencies = [ - "serde", - "serde_json", -] - [[package]] name = "tinyvec" version = "1.6.0" @@ -14233,39 +13516,6 @@ dependencies = [ "xcm-executor", ] -[[package]] -name = "xcm-emulator" -version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=release-v1.0.0#7935c251f42a41a3e3f61db101af623027676b49" -dependencies = [ - "casey", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-core", - "cumulus-primitives-parachain-inherent", - "cumulus-test-relay-sproof-builder", - "cumulus-test-service", - "frame-support", - "frame-system", - "log", - "pallet-balances", - "pallet-message-queue", - "parachain-info", - "parachains-common", - "parity-scale-codec", - "paste", - "polkadot-primitives", - "polkadot-runtime-parachains", - "quote", - "sp-arithmetic", - "sp-core", - "sp-io", - "sp-std", - "sp-trie", - "xcm", -] - [[package]] name = "xcm-executor" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index 4f1606094..b56a9782d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,8 +3,8 @@ members = [ "nodes/*", "runtimes/*", "pallets/*", - "integration-tests", - "integration-tests/penpal", +# "integration-tests", +# "integration-tests/penpal", "macros", "macros/tests", "polimec-common", diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 670dc5b27..4d8e85882 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -321,8 +321,7 @@ pub fn fill_projects_to_update( // We keep in mind that we already filled `x` amount of vecs to max capacity let remaining_vecs = total_vecs_in_storage.saturating_sub(fully_filled_vecs_from_insertion); if remaining_vecs > 0 { - // we benchmarked this with different values, and it had no impact on the weight, so we use a low value to speed up the benchmark - let items_per_vec = 5u32; + let items_per_vec = T::MaxProjectsToUpdatePerBlock::get(); let mut block_number: BlockNumberFor = Zero::zero(); for _ in 0..remaining_vecs { // To iterate over all expected items when looking to remove, we need to insert everything _before_ our already stored project's block_number diff --git a/runtimes/testnet/Cargo.toml b/runtimes/testnet/Cargo.toml index 409b22440..81997e1e0 100644 --- a/runtimes/testnet/Cargo.toml +++ b/runtimes/testnet/Cargo.toml @@ -22,7 +22,7 @@ serde = { workspace = true, features = ["derive"] } smallvec.workspace = true # Uncomment this to see variables instead of in the console output -#sp-debug-derive = { workspace = true, features = ["force-debug"]} +sp-debug-derive = { workspace = true, features = ["force-debug"]} # Polimec specific pallet-funding.workspace = true From edb763fbe37913f0d9e33b596103edde61c61656 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 9 Feb 2024 09:57:37 +0100 Subject: [PATCH 204/212] final weights generated Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/weights-test.rs | 2227 +++++++++++++++++++++++++++ 1 file changed, 2227 insertions(+) create mode 100644 pallets/funding/src/weights-test.rs diff --git a/pallets/funding/src/weights-test.rs b/pallets/funding/src/weights-test.rs new file mode 100644 index 000000000..78226edc1 --- /dev/null +++ b/pallets/funding/src/weights-test.rs @@ -0,0 +1,2227 @@ +// Polimec Blockchain – https://www.polimec.org/ +// Copyright (C) Polimec 2022. All rights reserved. + +// The Polimec Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Polimec Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@polimec.org + + +//! Autogenerated weights for `pallet_funding` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2024-02-09, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `Juans-MBP.home`, CPU: `` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: `1024` + +// Executed Command: +// target/release/polimec-parachain-node +// benchmark +// pallet +// --chain=polimec-rococo-local +// --steps=50 +// --repeat=20 +// --pallet=pallet_funding +// --extrinsic +// * +// --heap-pages=4096 +// --output=pallets/funding/src/weights-test.rs +// --template=./.maintain/frame-weight-template.hbs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use core::marker::PhantomData; + +/// Weight functions needed for `pallet_funding`. +pub trait WeightInfo { + fn create() -> Weight; + fn edit_metadata() -> Weight; + fn start_evaluation(x: u32, ) -> Weight; + fn start_auction_manually(x: u32, y: u32, ) -> Weight; + fn first_evaluation() -> Weight; + fn second_to_limit_evaluation(x: u32, ) -> Weight; + fn evaluation_over_limit() -> Weight; + fn bid_no_ct_deposit(x: u32, y: u32, ) -> Weight; + fn bid_with_ct_deposit(y: u32, ) -> Weight; + fn first_contribution_with_ct_deposit() -> Weight; + fn first_contribution_no_ct_deposit() -> Weight; + fn first_contribution_ends_round_with_ct_deposit(y: u32, z: u32, ) -> Weight; + fn first_contribution_ends_round_no_ct_deposit(y: u32, z: u32, ) -> Weight; + fn second_to_limit_contribution(x: u32, ) -> Weight; + fn second_to_limit_contribution_ends_round(x: u32, y: u32, z: u32, ) -> Weight; + fn contribution_over_limit() -> Weight; + fn evaluation_unbond_for() -> Weight; + fn evaluation_reward_payout_for_with_ct_account_creation() -> Weight; + fn evaluation_reward_payout_for_no_ct_account_creation() -> Weight; + fn evaluation_slash_for() -> Weight; + fn bid_ct_mint_for_with_ct_account_creation() -> Weight; + fn bid_ct_mint_for_no_ct_account_creation() -> Weight; + fn contribution_ct_mint_for_with_ct_account_creation() -> Weight; + fn contribution_ct_mint_for_no_ct_account_creation() -> Weight; + fn start_bid_vesting_schedule_for() -> Weight; + fn start_contribution_vesting_schedule_for() -> Weight; + fn payout_bid_funds_for() -> Weight; + fn payout_contribution_funds_for() -> Weight; + fn decide_project_outcome(x: u32, y: u32, ) -> Weight; + fn release_bid_funds_for() -> Weight; + fn release_contribution_funds_for() -> Weight; + fn bid_unbond_for() -> Weight; + fn contribution_unbond_for() -> Weight; + fn end_evaluation_success(x: u32, ) -> Weight; + fn end_evaluation_failure() -> Weight; + fn start_auction_automatically(x: u32, ) -> Weight; + fn start_candle_phase(x: u32, ) -> Weight; + fn start_community_funding_success(x: u32, y: u32, z: u32, ) -> Weight; + fn start_community_funding_failure(x: u32, ) -> Weight; + fn start_remainder_funding(x: u32, ) -> Weight; + fn end_funding_automatically_rejected_evaluators_slashed(x: u32, ) -> Weight; + fn end_funding_awaiting_decision_evaluators_slashed(x: u32, ) -> Weight; + fn end_funding_awaiting_decision_evaluators_unchanged(x: u32, ) -> Weight; + fn end_funding_automatically_accepted_evaluators_rewarded(x: u32, y: u32, ) -> Weight; + fn project_decision_accept_funding() -> Weight; + fn project_decision_reject_funding() -> Weight; + fn start_settlement_funding_success() -> Weight; + fn start_settlement_funding_failure() -> Weight; +} + +/// Weights for `pallet_funding` using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: `PolimecFunding::NextProjectId` (r:1 w:1) + /// Proof: `PolimecFunding::NextProjectId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Images` (r:1 w:1) + /// Proof: `PolimecFunding::Images` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:0 w:1) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:0 w:1) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:0 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + fn create() -> Weight { + // Proof Size summary in bytes: + // Measured: `161` + // Estimated: `3593` + // Minimum execution time: 92_000_000 picoseconds. + Weight::from_parts(94_000_000, 3593) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Images` (r:1 w:0) + /// Proof: `PolimecFunding::Images` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + fn edit_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `609` + // Estimated: `3814` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_000_000, 3814) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_evaluation(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `562 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 23_000_000 picoseconds. + Weight::from_parts(21_490_523, 3814) + // Standard Error: 5_416 + .saturating_add(Weight::from_parts(2_287_829, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:4558 w:2) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + /// The range of component `y` is `[1, 10000]`. + fn start_auction_manually(x: u32, y: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + x * (539 ±0) + y * (13 ±0)` + // Estimated: `217021 + x * (8051 ±6_772) + y * (979 ±66)` + // Minimum execution time: 321_000_000 picoseconds. + Weight::from_parts(325_000_000, 217021) + // Standard Error: 3_856_088 + .saturating_add(Weight::from_parts(10_425_661, 0).saturating_mul(x.into())) + // Standard Error: 38_223 + .saturating_add(Weight::from_parts(1_158_523, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(87_u64)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_parts(0, 8051).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 979).saturating_mul(y.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) + /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::EvaluationCounts` (r:1 w:1) + /// Proof: `PolimecFunding::EvaluationCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn first_evaluation() -> Weight { + // Proof Size summary in bytes: + // Measured: `745` + // Estimated: `4614` + // Minimum execution time: 90_000_000 picoseconds. + Weight::from_parts(97_000_000, 4614) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) + /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:16 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::EvaluationCounts` (r:1 w:1) + /// Proof: `PolimecFunding::EvaluationCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 15]`. + fn second_to_limit_evaluation(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `941 + x * (137 ±0)` + // Estimated: `4614 + x * (2820 ±0)` + // Minimum execution time: 70_000_000 picoseconds. + Weight::from_parts(73_938_801, 4614) + // Standard Error: 20_740 + .saturating_add(Weight::from_parts(3_615_461, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(5_u64)) + .saturating_add(Weight::from_parts(0, 2820).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) + /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:17 w:2) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::EvaluationCounts` (r:1 w:1) + /// Proof: `PolimecFunding::EvaluationCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn evaluation_over_limit() -> Weight { + // Proof Size summary in bytes: + // Measured: `3148` + // Estimated: `48930` + // Minimum execution time: 152_000_000 picoseconds. + Weight::from_parts(158_000_000, 48930) + .saturating_add(T::DbWeight::get().reads(22_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:128 w:10) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::BidCounts` (r:1 w:1) + /// Proof: `PolimecFunding::BidCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:1 w:1) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextBidId` (r:1 w:1) + /// Proof: `PolimecFunding::NextBidId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// The range of component `x` is `[0, 127]`. + /// The range of component `y` is `[0, 10]`. + fn bid_no_ct_deposit(x: u32, y: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2278 + x * (164 ±0)` + // Estimated: `6208 + x * (2893 ±0)` + // Minimum execution time: 539_000_000 picoseconds. + Weight::from_parts(84_439_405, 6208) + // Standard Error: 20_670 + .saturating_add(Weight::from_parts(3_779_627, 0).saturating_mul(x.into())) + // Standard Error: 250_512 + .saturating_add(Weight::from_parts(73_255_675, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(13_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(7_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) + .saturating_add(Weight::from_parts(0, 2893).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:10) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::BidCounts` (r:1 w:1) + /// Proof: `PolimecFunding::BidCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:1 w:1) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextBidId` (r:1 w:1) + /// Proof: `PolimecFunding::NextBidId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// The range of component `y` is `[0, 10]`. + fn bid_with_ct_deposit(y: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2184` + // Estimated: `6208` + // Minimum execution time: 143_000_000 picoseconds. + Weight::from_parts(110_639_424, 6208) + // Standard Error: 314_196 + .saturating_add(Weight::from_parts(70_855_879, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(13_u64)) + .saturating_add(T::DbWeight::get().writes(8_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn first_contribution_with_ct_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `2029` + // Estimated: `6208` + // Minimum execution time: 146_000_000 picoseconds. + Weight::from_parts(151_000_000, 6208) + .saturating_add(T::DbWeight::get().reads(11_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn first_contribution_no_ct_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `2106` + // Estimated: `6208` + // Minimum execution time: 118_000_000 picoseconds. + Weight::from_parts(120_000_000, 6208) + .saturating_add(T::DbWeight::get().reads(11_u64)) + .saturating_add(T::DbWeight::get().writes(7_u64)) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9833 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `y` is `[1, 99]`. + /// The range of component `z` is `[1, 10000]`. + fn first_contribution_ends_round_with_ct_deposit(y: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + y * (140 ±0) + z * (20 ±0)` + // Estimated: `66042 + y * (11508 ±3_537) + z * (1108 ±35)` + // Minimum execution time: 232_000_000 picoseconds. + Weight::from_parts(246_000_000, 66042) + // Standard Error: 4_200_086 + .saturating_add(Weight::from_parts(12_470_526, 0).saturating_mul(y.into())) + // Standard Error: 41_632 + .saturating_add(Weight::from_parts(1_318_329, 0).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(37_u64)) + .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(y.into()))) + .saturating_add(T::DbWeight::get().writes(8_u64)) + .saturating_add(Weight::from_parts(0, 11508).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 1108).saturating_mul(z.into())) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9833 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `y` is `[1, 99]`. + /// The range of component `z` is `[1, 10000]`. + fn first_contribution_ends_round_no_ct_deposit(y: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + y * (140 ±0) + z * (20 ±0)` + // Estimated: `66042 + y * (11508 ±3_537) + z * (1108 ±35)` + // Minimum execution time: 212_000_000 picoseconds. + Weight::from_parts(223_000_000, 66042) + // Standard Error: 4_200_933 + .saturating_add(Weight::from_parts(12_638_804, 0).saturating_mul(y.into())) + // Standard Error: 41_641 + .saturating_add(Weight::from_parts(1_313_036, 0).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(37_u64)) + .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(y.into()))) + .saturating_add(T::DbWeight::get().writes(8_u64)) + .saturating_add(Weight::from_parts(0, 11508).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 1108).saturating_mul(z.into())) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:256 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 255]`. + fn second_to_limit_contribution(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2246 + x * (137 ±0)` + // Estimated: `6208 + x * (2839 ±0)` + // Minimum execution time: 124_000_000 picoseconds. + Weight::from_parts(128_568_935, 6208) + // Standard Error: 11_772 + .saturating_add(Weight::from_parts(3_704_148, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(11_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(7_u64)) + .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:256 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9833 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 255]`. + /// The range of component `y` is `[1, 99]`. + /// The range of component `z` is `[1, 10000]`. + fn second_to_limit_contribution_ends_round(x: u32, y: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `44564 + x * (137 ±0) + y * (254 ±0) + z * (21 ±0)` + // Estimated: `15401 + x * (2839 ±0) + y * (92965 ±6_111) + z * (1905 ±59)` + // Minimum execution time: 1_120_000_000 picoseconds. + Weight::from_parts(55_806_166, 15401) + // Standard Error: 7_331_488 + .saturating_add(Weight::from_parts(111_668_126, 0).saturating_mul(y.into())) + // Standard Error: 71_852 + .saturating_add(Weight::from_parts(2_292_683, 0).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(17_u64)) + .saturating_add(T::DbWeight::get().reads((37_u64).saturating_mul(y.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(z.into()))) + .saturating_add(T::DbWeight::get().writes(8_u64)) + .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 92965).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 1905).saturating_mul(z.into())) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:257 w:2) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + fn contribution_over_limit() -> Weight { + // Proof Size summary in bytes: + // Measured: `37473` + // Estimated: `730613` + // Minimum execution time: 1_082_000_000 picoseconds. + Weight::from_parts(1_150_000_000, 730613) + .saturating_add(T::DbWeight::get().reads(267_u64)) + .saturating_add(T::DbWeight::get().writes(8_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn evaluation_unbond_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1477` + // Estimated: `4614` + // Minimum execution time: 54_000_000 picoseconds. + Weight::from_parts(57_000_000, 4614) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + fn evaluation_reward_payout_for_with_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1654` + // Estimated: `4614` + // Minimum execution time: 94_000_000 picoseconds. + Weight::from_parts(98_000_000, 4614) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + fn evaluation_reward_payout_for_no_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1322` + // Estimated: `3814` + // Minimum execution time: 48_000_000 picoseconds. + Weight::from_parts(50_000_000, 3814) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn evaluation_slash_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1485` + // Estimated: `4614` + // Minimum execution time: 67_000_000 picoseconds. + Weight::from_parts(69_000_000, 4614) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn bid_ct_mint_for_with_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1735` + // Estimated: `4614` + // Minimum execution time: 99_000_000 picoseconds. + Weight::from_parts(103_000_000, 4614) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn bid_ct_mint_for_no_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1250` + // Estimated: `3883` + // Minimum execution time: 46_000_000 picoseconds. + Weight::from_parts(50_000_000, 3883) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn contribution_ct_mint_for_with_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1651` + // Estimated: `4614` + // Minimum execution time: 94_000_000 picoseconds. + Weight::from_parts(100_000_000, 4614) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn contribution_ct_mint_for_no_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1287` + // Estimated: `3829` + // Minimum execution time: 47_000_000 picoseconds. + Weight::from_parts(50_000_000, 3829) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `LinearRelease::Vesting` (r:1 w:1) + /// Proof: `LinearRelease::Vesting` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn start_bid_vesting_schedule_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `851` + // Estimated: `4316` + // Minimum execution time: 29_000_000 picoseconds. + Weight::from_parts(31_000_000, 4316) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `LinearRelease::Vesting` (r:1 w:1) + /// Proof: `LinearRelease::Vesting` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn start_contribution_vesting_schedule_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `880` + // Estimated: `4345` + // Minimum execution time: 30_000_000 picoseconds. + Weight::from_parts(31_000_000, 4345) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn payout_bid_funds_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1405` + // Estimated: `6208` + // Minimum execution time: 67_000_000 picoseconds. + Weight::from_parts(68_000_000, 6208) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn payout_contribution_funds_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1434` + // Estimated: `6208` + // Minimum execution time: 66_000_000 picoseconds. + Weight::from_parts(69_000_000, 6208) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:2980 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + /// The range of component `y` is `[1, 10000]`. + fn decide_project_outcome(x: u32, y: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `4454 + x * (93 ±0) + y * (11 ±0)` + // Estimated: `28512 + x * (3946 ±3_374) + y * (1161 ±33)` + // Minimum execution time: 58_000_000 picoseconds. + Weight::from_parts(59_000_000, 28512) + // Standard Error: 3_928_236 + .saturating_add(Weight::from_parts(3_329_337, 0).saturating_mul(x.into())) + // Standard Error: 38_938 + .saturating_add(Weight::from_parts(1_351_270, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(12_u64)) + .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_parts(0, 3946).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 1161).saturating_mul(y.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn release_bid_funds_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1514` + // Estimated: `6208` + // Minimum execution time: 65_000_000 picoseconds. + Weight::from_parts(70_000_000, 6208) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn release_contribution_funds_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1507` + // Estimated: `6208` + // Minimum execution time: 63_000_000 picoseconds. + Weight::from_parts(69_000_000, 6208) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn bid_unbond_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1519` + // Estimated: `4614` + // Minimum execution time: 54_000_000 picoseconds. + Weight::from_parts(56_000_000, 4614) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn contribution_unbond_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1474` + // Estimated: `4614` + // Minimum execution time: 54_000_000 picoseconds. + Weight::from_parts(57_000_000, 4614) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:4 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:99 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn end_evaluation_success(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1174 + x * (29 ±0)` + // Estimated: `12270 + x * (2502 ±0)` + // Minimum execution time: 38_000_000 picoseconds. + Weight::from_parts(36_057_447, 12270) + // Standard Error: 5_687 + .saturating_add(Weight::from_parts(2_349_611, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:4 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + fn end_evaluation_failure() -> Weight { + // Proof Size summary in bytes: + // Measured: `1148` + // Estimated: `12270` + // Minimum execution time: 33_000_000 picoseconds. + Weight::from_parts(35_000_000, 12270) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:102 w:2) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_auction_automatically(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `413 + x * (29 ±0)` + // Estimated: `8496 + x * (2502 ±0)` + // Minimum execution time: 26_000_000 picoseconds. + Weight::from_parts(28_124_881, 8496) + // Standard Error: 5_442 + .saturating_add(Weight::from_parts(2_521_942, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_candle_phase(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `446 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 17_000_000 picoseconds. + Weight::from_parts(17_987_956, 3814) + // Standard Error: 5_995 + .saturating_add(Weight::from_parts(2_286_160, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Nonce` (r:1 w:1) + /// Proof: `PolimecFunding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Random::RandomMaterial` (r:1 w:0) + /// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:2049 w:2048) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:1025 w:1025) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1024 w:1024) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1024 w:1024) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:1 w:0) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + /// The range of component `y` is `[1, 1024]`. + /// The range of component `z` is `[0, 1024]`. + fn start_community_funding_success(x: u32, y: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `86802 + x * (29 ±0) + y * (167 ±0) + z * (367 ±0)` + // Estimated: `4079 + x * (2502 ±0) + y * (2893 ±0) + z * (3624 ±0)` + // Minimum execution time: 8_733_000_000 picoseconds. + Weight::from_parts(8_889_000_000, 4079) + // Standard Error: 235_341 + .saturating_add(Weight::from_parts(6_457_226, 0).saturating_mul(y.into())) + // Standard Error: 235_237 + .saturating_add(Weight::from_parts(70_277_060, 0).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(10_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into()))) + .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(z.into()))) + .saturating_add(T::DbWeight::get().writes(5_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) + .saturating_add(T::DbWeight::get().writes((4_u64).saturating_mul(z.into()))) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 2893).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 3624).saturating_mul(z.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Nonce` (r:1 w:1) + /// Proof: `PolimecFunding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Random::RandomMaterial` (r:1 w:0) + /// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:0) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:1 w:0) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_community_funding_failure(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1418 + x * (3 ±0)` + // Estimated: `4079` + // Minimum execution time: 87_000_000 picoseconds. + Weight::from_parts(97_589_188, 4079) + // Standard Error: 3_828 + .saturating_add(Weight::from_parts(26_576, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(8_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_remainder_funding(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `536 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(18_694_146, 3814) + // Standard Error: 5_669 + .saturating_add(Weight::from_parts(2_256_677, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn end_funding_automatically_rejected_evaluators_slashed(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `824 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 24_000_000 picoseconds. + Weight::from_parts(23_753_565, 3814) + // Standard Error: 4_976 + .saturating_add(Weight::from_parts(2_285_728, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn end_funding_awaiting_decision_evaluators_slashed(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `823 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_149_882, 3814) + // Standard Error: 4_893 + .saturating_add(Weight::from_parts(2_241_882, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn end_funding_awaiting_decision_evaluators_unchanged(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `823 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(18_735_663, 3814) + // Standard Error: 5_515 + .saturating_add(Weight::from_parts(2_252_806, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:2048 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + /// The range of component `y` is `[1, 2048]`. + fn end_funding_automatically_accepted_evaluators_rewarded(x: u32, y: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1184 + x * (29 ±0) + y * (187 ±0)` + // Estimated: `3814 + x * (2502 ±0) + y * (2820 ±0)` + // Minimum execution time: 257_000_000 picoseconds. + Weight::from_parts(260_000_000, 3814) + // Standard Error: 52_986 + .saturating_add(Weight::from_parts(476_614, 0).saturating_mul(x.into())) + // Standard Error: 2_564 + .saturating_add(Weight::from_parts(4_091_225, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into()))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 2820).saturating_mul(y.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:2 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + fn project_decision_accept_funding() -> Weight { + // Proof Size summary in bytes: + // Measured: `563` + // Estimated: `5994` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_000_000, 5994) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:2 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + fn project_decision_reject_funding() -> Weight { + // Proof Size summary in bytes: + // Measured: `563` + // Estimated: `5994` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_000_000, 5994) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Metadata` (r:1 w:1) + /// Proof: `LocalAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn start_settlement_funding_success() -> Weight { + // Proof Size summary in bytes: + // Measured: `970` + // Estimated: `3814` + // Minimum execution time: 41_000_000 picoseconds. + Weight::from_parts(43_000_000, 3814) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + fn start_settlement_funding_failure() -> Weight { + // Proof Size summary in bytes: + // Measured: `760` + // Estimated: `3814` + // Minimum execution time: 11_000_000 picoseconds. + Weight::from_parts(12_000_000, 3814) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } +} + +// For backwards compatibility and tests. +impl WeightInfo for () { + /// Storage: `PolimecFunding::NextProjectId` (r:1 w:1) + /// Proof: `PolimecFunding::NextProjectId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Images` (r:1 w:1) + /// Proof: `PolimecFunding::Images` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:0 w:1) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:0 w:1) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:0 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + fn create() -> Weight { + // Proof Size summary in bytes: + // Measured: `161` + // Estimated: `3593` + // Minimum execution time: 92_000_000 picoseconds. + Weight::from_parts(94_000_000, 3593) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Images` (r:1 w:0) + /// Proof: `PolimecFunding::Images` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + fn edit_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `609` + // Estimated: `3814` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_000_000, 3814) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_evaluation(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `562 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 23_000_000 picoseconds. + Weight::from_parts(21_490_523, 3814) + // Standard Error: 5_416 + .saturating_add(Weight::from_parts(2_287_829, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:4558 w:2) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + /// The range of component `y` is `[1, 10000]`. + fn start_auction_manually(x: u32, y: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + x * (539 ±0) + y * (13 ±0)` + // Estimated: `217021 + x * (8051 ±6_772) + y * (979 ±66)` + // Minimum execution time: 321_000_000 picoseconds. + Weight::from_parts(325_000_000, 217021) + // Standard Error: 3_856_088 + .saturating_add(Weight::from_parts(10_425_661, 0).saturating_mul(x.into())) + // Standard Error: 38_223 + .saturating_add(Weight::from_parts(1_158_523, 0).saturating_mul(y.into())) + .saturating_add(RocksDbWeight::get().reads(87_u64)) + .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_parts(0, 8051).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 979).saturating_mul(y.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) + /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::EvaluationCounts` (r:1 w:1) + /// Proof: `PolimecFunding::EvaluationCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn first_evaluation() -> Weight { + // Proof Size summary in bytes: + // Measured: `745` + // Estimated: `4614` + // Minimum execution time: 90_000_000 picoseconds. + Weight::from_parts(97_000_000, 4614) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) + /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:16 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::EvaluationCounts` (r:1 w:1) + /// Proof: `PolimecFunding::EvaluationCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 15]`. + fn second_to_limit_evaluation(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `941 + x * (137 ±0)` + // Estimated: `4614 + x * (2820 ±0)` + // Minimum execution time: 70_000_000 picoseconds. + Weight::from_parts(73_938_801, 4614) + // Standard Error: 20_740 + .saturating_add(Weight::from_parts(3_615_461, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + .saturating_add(Weight::from_parts(0, 2820).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) + /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:17 w:2) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::EvaluationCounts` (r:1 w:1) + /// Proof: `PolimecFunding::EvaluationCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn evaluation_over_limit() -> Weight { + // Proof Size summary in bytes: + // Measured: `3148` + // Estimated: `48930` + // Minimum execution time: 152_000_000 picoseconds. + Weight::from_parts(158_000_000, 48930) + .saturating_add(RocksDbWeight::get().reads(22_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:128 w:10) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::BidCounts` (r:1 w:1) + /// Proof: `PolimecFunding::BidCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:1 w:1) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextBidId` (r:1 w:1) + /// Proof: `PolimecFunding::NextBidId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// The range of component `x` is `[0, 127]`. + /// The range of component `y` is `[0, 10]`. + fn bid_no_ct_deposit(x: u32, y: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2278 + x * (164 ±0)` + // Estimated: `6208 + x * (2893 ±0)` + // Minimum execution time: 539_000_000 picoseconds. + Weight::from_parts(84_439_405, 6208) + // Standard Error: 20_670 + .saturating_add(Weight::from_parts(3_779_627, 0).saturating_mul(x.into())) + // Standard Error: 250_512 + .saturating_add(Weight::from_parts(73_255_675, 0).saturating_mul(y.into())) + .saturating_add(RocksDbWeight::get().reads(13_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(7_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(y.into()))) + .saturating_add(Weight::from_parts(0, 2893).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:10) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::BidCounts` (r:1 w:1) + /// Proof: `PolimecFunding::BidCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:1 w:1) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextBidId` (r:1 w:1) + /// Proof: `PolimecFunding::NextBidId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// The range of component `y` is `[0, 10]`. + fn bid_with_ct_deposit(y: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2184` + // Estimated: `6208` + // Minimum execution time: 143_000_000 picoseconds. + Weight::from_parts(110_639_424, 6208) + // Standard Error: 314_196 + .saturating_add(Weight::from_parts(70_855_879, 0).saturating_mul(y.into())) + .saturating_add(RocksDbWeight::get().reads(13_u64)) + .saturating_add(RocksDbWeight::get().writes(8_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(y.into()))) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn first_contribution_with_ct_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `2029` + // Estimated: `6208` + // Minimum execution time: 146_000_000 picoseconds. + Weight::from_parts(151_000_000, 6208) + .saturating_add(RocksDbWeight::get().reads(11_u64)) + .saturating_add(RocksDbWeight::get().writes(7_u64)) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn first_contribution_no_ct_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `2106` + // Estimated: `6208` + // Minimum execution time: 118_000_000 picoseconds. + Weight::from_parts(120_000_000, 6208) + .saturating_add(RocksDbWeight::get().reads(11_u64)) + .saturating_add(RocksDbWeight::get().writes(7_u64)) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9833 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `y` is `[1, 99]`. + /// The range of component `z` is `[1, 10000]`. + fn first_contribution_ends_round_with_ct_deposit(y: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + y * (140 ±0) + z * (20 ±0)` + // Estimated: `66042 + y * (11508 ±3_537) + z * (1108 ±35)` + // Minimum execution time: 232_000_000 picoseconds. + Weight::from_parts(246_000_000, 66042) + // Standard Error: 4_200_086 + .saturating_add(Weight::from_parts(12_470_526, 0).saturating_mul(y.into())) + // Standard Error: 41_632 + .saturating_add(Weight::from_parts(1_318_329, 0).saturating_mul(z.into())) + .saturating_add(RocksDbWeight::get().reads(37_u64)) + .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(y.into()))) + .saturating_add(RocksDbWeight::get().writes(8_u64)) + .saturating_add(Weight::from_parts(0, 11508).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 1108).saturating_mul(z.into())) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9833 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `y` is `[1, 99]`. + /// The range of component `z` is `[1, 10000]`. + fn first_contribution_ends_round_no_ct_deposit(y: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0 + y * (140 ±0) + z * (20 ±0)` + // Estimated: `66042 + y * (11508 ±3_537) + z * (1108 ±35)` + // Minimum execution time: 212_000_000 picoseconds. + Weight::from_parts(223_000_000, 66042) + // Standard Error: 4_200_933 + .saturating_add(Weight::from_parts(12_638_804, 0).saturating_mul(y.into())) + // Standard Error: 41_641 + .saturating_add(Weight::from_parts(1_313_036, 0).saturating_mul(z.into())) + .saturating_add(RocksDbWeight::get().reads(37_u64)) + .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(y.into()))) + .saturating_add(RocksDbWeight::get().writes(8_u64)) + .saturating_add(Weight::from_parts(0, 11508).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 1108).saturating_mul(z.into())) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:256 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 255]`. + fn second_to_limit_contribution(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2246 + x * (137 ±0)` + // Estimated: `6208 + x * (2839 ±0)` + // Minimum execution time: 124_000_000 picoseconds. + Weight::from_parts(128_568_935, 6208) + // Standard Error: 11_772 + .saturating_add(Weight::from_parts(3_704_148, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(11_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(7_u64)) + .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:256 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9833 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 255]`. + /// The range of component `y` is `[1, 99]`. + /// The range of component `z` is `[1, 10000]`. + fn second_to_limit_contribution_ends_round(x: u32, y: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `44564 + x * (137 ±0) + y * (254 ±0) + z * (21 ±0)` + // Estimated: `15401 + x * (2839 ±0) + y * (92965 ±6_111) + z * (1905 ±59)` + // Minimum execution time: 1_120_000_000 picoseconds. + Weight::from_parts(55_806_166, 15401) + // Standard Error: 7_331_488 + .saturating_add(Weight::from_parts(111_668_126, 0).saturating_mul(y.into())) + // Standard Error: 71_852 + .saturating_add(Weight::from_parts(2_292_683, 0).saturating_mul(z.into())) + .saturating_add(RocksDbWeight::get().reads(17_u64)) + .saturating_add(RocksDbWeight::get().reads((37_u64).saturating_mul(y.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(z.into()))) + .saturating_add(RocksDbWeight::get().writes(8_u64)) + .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 92965).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 1905).saturating_mul(z.into())) + } + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:257 w:2) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:2 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) + /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + fn contribution_over_limit() -> Weight { + // Proof Size summary in bytes: + // Measured: `37473` + // Estimated: `730613` + // Minimum execution time: 1_082_000_000 picoseconds. + Weight::from_parts(1_150_000_000, 730613) + .saturating_add(RocksDbWeight::get().reads(267_u64)) + .saturating_add(RocksDbWeight::get().writes(8_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn evaluation_unbond_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1477` + // Estimated: `4614` + // Minimum execution time: 54_000_000 picoseconds. + Weight::from_parts(57_000_000, 4614) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + fn evaluation_reward_payout_for_with_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1654` + // Estimated: `4614` + // Minimum execution time: 94_000_000 picoseconds. + Weight::from_parts(98_000_000, 4614) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + fn evaluation_reward_payout_for_no_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1322` + // Estimated: `3814` + // Minimum execution time: 48_000_000 picoseconds. + Weight::from_parts(50_000_000, 3814) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn evaluation_slash_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1485` + // Estimated: `4614` + // Minimum execution time: 67_000_000 picoseconds. + Weight::from_parts(69_000_000, 4614) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn bid_ct_mint_for_with_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1735` + // Estimated: `4614` + // Minimum execution time: 99_000_000 picoseconds. + Weight::from_parts(103_000_000, 4614) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn bid_ct_mint_for_no_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1250` + // Estimated: `3883` + // Minimum execution time: 46_000_000 picoseconds. + Weight::from_parts(50_000_000, 3883) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn contribution_ct_mint_for_with_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1651` + // Estimated: `4614` + // Minimum execution time: 94_000_000 picoseconds. + Weight::from_parts(100_000_000, 4614) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Account` (r:1 w:1) + /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn contribution_ct_mint_for_no_ct_account_creation() -> Weight { + // Proof Size summary in bytes: + // Measured: `1287` + // Estimated: `3829` + // Minimum execution time: 47_000_000 picoseconds. + Weight::from_parts(50_000_000, 3829) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `LinearRelease::Vesting` (r:1 w:1) + /// Proof: `LinearRelease::Vesting` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn start_bid_vesting_schedule_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `851` + // Estimated: `4316` + // Minimum execution time: 29_000_000 picoseconds. + Weight::from_parts(31_000_000, 4316) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `LinearRelease::Vesting` (r:1 w:1) + /// Proof: `LinearRelease::Vesting` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn start_contribution_vesting_schedule_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `880` + // Estimated: `4345` + // Minimum execution time: 30_000_000 picoseconds. + Weight::from_parts(31_000_000, 4345) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn payout_bid_funds_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1405` + // Estimated: `6208` + // Minimum execution time: 67_000_000 picoseconds. + Weight::from_parts(68_000_000, 6208) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn payout_contribution_funds_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1434` + // Estimated: `6208` + // Minimum execution time: 66_000_000 picoseconds. + Weight::from_parts(69_000_000, 6208) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:2980 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + /// The range of component `y` is `[1, 10000]`. + fn decide_project_outcome(x: u32, y: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `4454 + x * (93 ±0) + y * (11 ±0)` + // Estimated: `28512 + x * (3946 ±3_374) + y * (1161 ±33)` + // Minimum execution time: 58_000_000 picoseconds. + Weight::from_parts(59_000_000, 28512) + // Standard Error: 3_928_236 + .saturating_add(Weight::from_parts(3_329_337, 0).saturating_mul(x.into())) + // Standard Error: 38_938 + .saturating_add(Weight::from_parts(1_351_270, 0).saturating_mul(y.into())) + .saturating_add(RocksDbWeight::get().reads(12_u64)) + .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(Weight::from_parts(0, 3946).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 1161).saturating_mul(y.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn release_bid_funds_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1514` + // Estimated: `6208` + // Minimum execution time: 65_000_000 picoseconds. + Weight::from_parts(70_000_000, 6208) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:2 w:2) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + fn release_contribution_funds_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1507` + // Estimated: `6208` + // Minimum execution time: 63_000_000 picoseconds. + Weight::from_parts(69_000_000, 6208) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:1) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn bid_unbond_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1519` + // Estimated: `4614` + // Minimum execution time: 54_000_000 picoseconds. + Weight::from_parts(56_000_000, 4614) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Contributions` (r:1 w:1) + /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + fn contribution_unbond_for() -> Weight { + // Proof Size summary in bytes: + // Measured: `1474` + // Estimated: `4614` + // Minimum execution time: 54_000_000 picoseconds. + Weight::from_parts(57_000_000, 4614) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:4 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:99 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn end_evaluation_success(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1174 + x * (29 ±0)` + // Estimated: `12270 + x * (2502 ±0)` + // Minimum execution time: 38_000_000 picoseconds. + Weight::from_parts(36_057_447, 12270) + // Standard Error: 5_687 + .saturating_add(Weight::from_parts(2_349_611, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:4 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + fn end_evaluation_failure() -> Weight { + // Proof Size summary in bytes: + // Measured: `1148` + // Estimated: `12270` + // Minimum execution time: 33_000_000 picoseconds. + Weight::from_parts(35_000_000, 12270) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:102 w:2) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_auction_automatically(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `413 + x * (29 ±0)` + // Estimated: `8496 + x * (2502 ±0)` + // Minimum execution time: 26_000_000 picoseconds. + Weight::from_parts(28_124_881, 8496) + // Standard Error: 5_442 + .saturating_add(Weight::from_parts(2_521_942, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_candle_phase(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `446 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 17_000_000 picoseconds. + Weight::from_parts(17_987_956, 3814) + // Standard Error: 5_995 + .saturating_add(Weight::from_parts(2_286_160, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Nonce` (r:1 w:1) + /// Proof: `PolimecFunding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Random::RandomMaterial` (r:1 w:0) + /// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:2049 w:2048) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Asset` (r:1 w:1) + /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `StatemintAssets::Account` (r:1025 w:1025) + /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1024 w:1024) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1024 w:1024) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:1 w:0) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + /// The range of component `y` is `[1, 1024]`. + /// The range of component `z` is `[0, 1024]`. + fn start_community_funding_success(x: u32, y: u32, z: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `86802 + x * (29 ±0) + y * (167 ±0) + z * (367 ±0)` + // Estimated: `4079 + x * (2502 ±0) + y * (2893 ±0) + z * (3624 ±0)` + // Minimum execution time: 8_733_000_000 picoseconds. + Weight::from_parts(8_889_000_000, 4079) + // Standard Error: 235_341 + .saturating_add(Weight::from_parts(6_457_226, 0).saturating_mul(y.into())) + // Standard Error: 235_237 + .saturating_add(Weight::from_parts(70_277_060, 0).saturating_mul(z.into())) + .saturating_add(RocksDbWeight::get().reads(10_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(y.into()))) + .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(z.into()))) + .saturating_add(RocksDbWeight::get().writes(5_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(y.into()))) + .saturating_add(RocksDbWeight::get().writes((4_u64).saturating_mul(z.into()))) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 2893).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 3624).saturating_mul(z.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Nonce` (r:1 w:1) + /// Proof: `PolimecFunding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + /// Storage: `Random::RandomMaterial` (r:1 w:0) + /// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Bids` (r:1 w:0) + /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `Oracle::Values` (r:1 w:0) + /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Buckets` (r:1 w:0) + /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_community_funding_failure(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1418 + x * (3 ±0)` + // Estimated: `4079` + // Minimum execution time: 87_000_000 picoseconds. + Weight::from_parts(97_589_188, 4079) + // Standard Error: 3_828 + .saturating_add(Weight::from_parts(26_576, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(8_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_remainder_funding(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `536 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(18_694_146, 3814) + // Standard Error: 5_669 + .saturating_add(Weight::from_parts(2_256_677, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn end_funding_automatically_rejected_evaluators_slashed(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `824 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 24_000_000 picoseconds. + Weight::from_parts(23_753_565, 3814) + // Standard Error: 4_976 + .saturating_add(Weight::from_parts(2_285_728, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn end_funding_awaiting_decision_evaluators_slashed(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `823 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_149_882, 3814) + // Standard Error: 4_893 + .saturating_add(Weight::from_parts(2_241_882, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn end_funding_awaiting_decision_evaluators_unchanged(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `823 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(18_735_663, 3814) + // Standard Error: 5_515 + .saturating_add(Weight::from_parts(2_252_806, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::Evaluations` (r:2048 w:0) + /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + /// The range of component `y` is `[1, 2048]`. + fn end_funding_automatically_accepted_evaluators_rewarded(x: u32, y: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1184 + x * (29 ±0) + y * (187 ±0)` + // Estimated: `3814 + x * (2502 ±0) + y * (2820 ±0)` + // Minimum execution time: 257_000_000 picoseconds. + Weight::from_parts(260_000_000, 3814) + // Standard Error: 52_986 + .saturating_add(Weight::from_parts(476_614, 0).saturating_mul(x.into())) + // Standard Error: 2_564 + .saturating_add(Weight::from_parts(4_091_225, 0).saturating_mul(y.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(y.into()))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 2820).saturating_mul(y.into())) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:2 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + fn project_decision_accept_funding() -> Weight { + // Proof Size summary in bytes: + // Measured: `563` + // Estimated: `5994` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_000_000, 5994) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:2 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + fn project_decision_reject_funding() -> Weight { + // Proof Size summary in bytes: + // Measured: `563` + // Estimated: `5994` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_000_000, 5994) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Metadata` (r:1 w:1) + /// Proof: `LocalAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn start_settlement_funding_success() -> Weight { + // Proof Size summary in bytes: + // Measured: `970` + // Estimated: `3814` + // Minimum execution time: 41_000_000 picoseconds. + Weight::from_parts(43_000_000, 3814) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + fn start_settlement_funding_failure() -> Weight { + // Proof Size summary in bytes: + // Measured: `760` + // Estimated: `3814` + // Minimum execution time: 11_000_000 picoseconds. + Weight::from_parts(12_000_000, 3814) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } +} \ No newline at end of file From 37e7848fbabd64c0494957e74968ff7c256b4e6c Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 9 Feb 2024 10:01:14 +0100 Subject: [PATCH 205/212] replace weights.rs file Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/weights-test.rs | 2227 --------------------------- pallets/funding/src/weights.rs | 1531 +++++++++--------- 2 files changed, 730 insertions(+), 3028 deletions(-) delete mode 100644 pallets/funding/src/weights-test.rs diff --git a/pallets/funding/src/weights-test.rs b/pallets/funding/src/weights-test.rs deleted file mode 100644 index 78226edc1..000000000 --- a/pallets/funding/src/weights-test.rs +++ /dev/null @@ -1,2227 +0,0 @@ -// Polimec Blockchain – https://www.polimec.org/ -// Copyright (C) Polimec 2022. All rights reserved. - -// The Polimec Blockchain is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// The Polimec Blockchain is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -// If you feel like getting in touch with us, you can do so at info@polimec.org - - -//! Autogenerated weights for `pallet_funding` -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-02-09, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `Juans-MBP.home`, CPU: `` -//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: `1024` - -// Executed Command: -// target/release/polimec-parachain-node -// benchmark -// pallet -// --chain=polimec-rococo-local -// --steps=50 -// --repeat=20 -// --pallet=pallet_funding -// --extrinsic -// * -// --heap-pages=4096 -// --output=pallets/funding/src/weights-test.rs -// --template=./.maintain/frame-weight-template.hbs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] -#![allow(missing_docs)] - -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use core::marker::PhantomData; - -/// Weight functions needed for `pallet_funding`. -pub trait WeightInfo { - fn create() -> Weight; - fn edit_metadata() -> Weight; - fn start_evaluation(x: u32, ) -> Weight; - fn start_auction_manually(x: u32, y: u32, ) -> Weight; - fn first_evaluation() -> Weight; - fn second_to_limit_evaluation(x: u32, ) -> Weight; - fn evaluation_over_limit() -> Weight; - fn bid_no_ct_deposit(x: u32, y: u32, ) -> Weight; - fn bid_with_ct_deposit(y: u32, ) -> Weight; - fn first_contribution_with_ct_deposit() -> Weight; - fn first_contribution_no_ct_deposit() -> Weight; - fn first_contribution_ends_round_with_ct_deposit(y: u32, z: u32, ) -> Weight; - fn first_contribution_ends_round_no_ct_deposit(y: u32, z: u32, ) -> Weight; - fn second_to_limit_contribution(x: u32, ) -> Weight; - fn second_to_limit_contribution_ends_round(x: u32, y: u32, z: u32, ) -> Weight; - fn contribution_over_limit() -> Weight; - fn evaluation_unbond_for() -> Weight; - fn evaluation_reward_payout_for_with_ct_account_creation() -> Weight; - fn evaluation_reward_payout_for_no_ct_account_creation() -> Weight; - fn evaluation_slash_for() -> Weight; - fn bid_ct_mint_for_with_ct_account_creation() -> Weight; - fn bid_ct_mint_for_no_ct_account_creation() -> Weight; - fn contribution_ct_mint_for_with_ct_account_creation() -> Weight; - fn contribution_ct_mint_for_no_ct_account_creation() -> Weight; - fn start_bid_vesting_schedule_for() -> Weight; - fn start_contribution_vesting_schedule_for() -> Weight; - fn payout_bid_funds_for() -> Weight; - fn payout_contribution_funds_for() -> Weight; - fn decide_project_outcome(x: u32, y: u32, ) -> Weight; - fn release_bid_funds_for() -> Weight; - fn release_contribution_funds_for() -> Weight; - fn bid_unbond_for() -> Weight; - fn contribution_unbond_for() -> Weight; - fn end_evaluation_success(x: u32, ) -> Weight; - fn end_evaluation_failure() -> Weight; - fn start_auction_automatically(x: u32, ) -> Weight; - fn start_candle_phase(x: u32, ) -> Weight; - fn start_community_funding_success(x: u32, y: u32, z: u32, ) -> Weight; - fn start_community_funding_failure(x: u32, ) -> Weight; - fn start_remainder_funding(x: u32, ) -> Weight; - fn end_funding_automatically_rejected_evaluators_slashed(x: u32, ) -> Weight; - fn end_funding_awaiting_decision_evaluators_slashed(x: u32, ) -> Weight; - fn end_funding_awaiting_decision_evaluators_unchanged(x: u32, ) -> Weight; - fn end_funding_automatically_accepted_evaluators_rewarded(x: u32, y: u32, ) -> Weight; - fn project_decision_accept_funding() -> Weight; - fn project_decision_reject_funding() -> Weight; - fn start_settlement_funding_success() -> Weight; - fn start_settlement_funding_failure() -> Weight; -} - -/// Weights for `pallet_funding` using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight { - /// Storage: `PolimecFunding::NextProjectId` (r:1 w:1) - /// Proof: `PolimecFunding::NextProjectId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Images` (r:1 w:1) - /// Proof: `PolimecFunding::Images` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Buckets` (r:0 w:1) - /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:0 w:1) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:0 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - fn create() -> Weight { - // Proof Size summary in bytes: - // Measured: `161` - // Estimated: `3593` - // Minimum execution time: 92_000_000 picoseconds. - Weight::from_parts(94_000_000, 3593) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(6_u64)) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Images` (r:1 w:0) - /// Proof: `PolimecFunding::Images` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) - fn edit_metadata() -> Weight { - // Proof Size summary in bytes: - // Measured: `609` - // Estimated: `3814` - // Minimum execution time: 18_000_000 picoseconds. - Weight::from_parts(19_000_000, 3814) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn start_evaluation(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `562 + x * (29 ±0)` - // Estimated: `3814 + x * (2502 ±0)` - // Minimum execution time: 23_000_000 picoseconds. - Weight::from_parts(21_490_523, 3814) - // Standard Error: 5_416 - .saturating_add(Weight::from_parts(2_287_829, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:4558 w:2) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - /// The range of component `y` is `[1, 10000]`. - fn start_auction_manually(x: u32, y: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `0 + x * (539 ±0) + y * (13 ±0)` - // Estimated: `217021 + x * (8051 ±6_772) + y * (979 ±66)` - // Minimum execution time: 321_000_000 picoseconds. - Weight::from_parts(325_000_000, 217021) - // Standard Error: 3_856_088 - .saturating_add(Weight::from_parts(10_425_661, 0).saturating_mul(x.into())) - // Standard Error: 38_223 - .saturating_add(Weight::from_parts(1_158_523, 0).saturating_mul(y.into())) - .saturating_add(T::DbWeight::get().reads(87_u64)) - .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 8051).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 979).saturating_mul(y.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) - /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:1 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::EvaluationCounts` (r:1 w:1) - /// Proof: `PolimecFunding::EvaluationCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - fn first_evaluation() -> Weight { - // Proof Size summary in bytes: - // Measured: `745` - // Estimated: `4614` - // Minimum execution time: 90_000_000 picoseconds. - Weight::from_parts(97_000_000, 4614) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(5_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) - /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:16 w:1) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:1 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::EvaluationCounts` (r:1 w:1) - /// Proof: `PolimecFunding::EvaluationCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 15]`. - fn second_to_limit_evaluation(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `941 + x * (137 ±0)` - // Estimated: `4614 + x * (2820 ±0)` - // Minimum execution time: 70_000_000 picoseconds. - Weight::from_parts(73_938_801, 4614) - // Standard Error: 20_740 - .saturating_add(Weight::from_parts(3_615_461, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(5_u64)) - .saturating_add(Weight::from_parts(0, 2820).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) - /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:17 w:2) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:1 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::EvaluationCounts` (r:1 w:1) - /// Proof: `PolimecFunding::EvaluationCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - fn evaluation_over_limit() -> Weight { - // Proof Size summary in bytes: - // Measured: `3148` - // Estimated: `48930` - // Minimum execution time: 152_000_000 picoseconds. - Weight::from_parts(158_000_000, 48930) - .saturating_add(T::DbWeight::get().reads(22_u64)) - .saturating_add(T::DbWeight::get().writes(6_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:128 w:10) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::BidCounts` (r:1 w:1) - /// Proof: `PolimecFunding::BidCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Buckets` (r:1 w:1) - /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextBidId` (r:1 w:1) - /// Proof: `PolimecFunding::NextBidId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// The range of component `x` is `[0, 127]`. - /// The range of component `y` is `[0, 10]`. - fn bid_no_ct_deposit(x: u32, y: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `2278 + x * (164 ±0)` - // Estimated: `6208 + x * (2893 ±0)` - // Minimum execution time: 539_000_000 picoseconds. - Weight::from_parts(84_439_405, 6208) - // Standard Error: 20_670 - .saturating_add(Weight::from_parts(3_779_627, 0).saturating_mul(x.into())) - // Standard Error: 250_512 - .saturating_add(Weight::from_parts(73_255_675, 0).saturating_mul(y.into())) - .saturating_add(T::DbWeight::get().reads(13_u64)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(7_u64)) - .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) - .saturating_add(Weight::from_parts(0, 2893).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:1 w:10) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::BidCounts` (r:1 w:1) - /// Proof: `PolimecFunding::BidCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Buckets` (r:1 w:1) - /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextBidId` (r:1 w:1) - /// Proof: `PolimecFunding::NextBidId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// The range of component `y` is `[0, 10]`. - fn bid_with_ct_deposit(y: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `2184` - // Estimated: `6208` - // Minimum execution time: 143_000_000 picoseconds. - Weight::from_parts(110_639_424, 6208) - // Standard Error: 314_196 - .saturating_add(Weight::from_parts(70_855_879, 0).saturating_mul(y.into())) - .saturating_add(T::DbWeight::get().reads(13_u64)) - .saturating_add(T::DbWeight::get().writes(8_u64)) - .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - fn first_contribution_with_ct_deposit() -> Weight { - // Proof Size summary in bytes: - // Measured: `2029` - // Estimated: `6208` - // Minimum execution time: 146_000_000 picoseconds. - Weight::from_parts(151_000_000, 6208) - .saturating_add(T::DbWeight::get().reads(11_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - fn first_contribution_no_ct_deposit() -> Weight { - // Proof Size summary in bytes: - // Measured: `2106` - // Estimated: `6208` - // Minimum execution time: 118_000_000 picoseconds. - Weight::from_parts(120_000_000, 6208) - .saturating_add(T::DbWeight::get().reads(11_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9833 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `y` is `[1, 99]`. - /// The range of component `z` is `[1, 10000]`. - fn first_contribution_ends_round_with_ct_deposit(y: u32, z: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `0 + y * (140 ±0) + z * (20 ±0)` - // Estimated: `66042 + y * (11508 ±3_537) + z * (1108 ±35)` - // Minimum execution time: 232_000_000 picoseconds. - Weight::from_parts(246_000_000, 66042) - // Standard Error: 4_200_086 - .saturating_add(Weight::from_parts(12_470_526, 0).saturating_mul(y.into())) - // Standard Error: 41_632 - .saturating_add(Weight::from_parts(1_318_329, 0).saturating_mul(z.into())) - .saturating_add(T::DbWeight::get().reads(37_u64)) - .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(y.into()))) - .saturating_add(T::DbWeight::get().writes(8_u64)) - .saturating_add(Weight::from_parts(0, 11508).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 1108).saturating_mul(z.into())) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9833 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `y` is `[1, 99]`. - /// The range of component `z` is `[1, 10000]`. - fn first_contribution_ends_round_no_ct_deposit(y: u32, z: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `0 + y * (140 ±0) + z * (20 ±0)` - // Estimated: `66042 + y * (11508 ±3_537) + z * (1108 ±35)` - // Minimum execution time: 212_000_000 picoseconds. - Weight::from_parts(223_000_000, 66042) - // Standard Error: 4_200_933 - .saturating_add(Weight::from_parts(12_638_804, 0).saturating_mul(y.into())) - // Standard Error: 41_641 - .saturating_add(Weight::from_parts(1_313_036, 0).saturating_mul(z.into())) - .saturating_add(T::DbWeight::get().reads(37_u64)) - .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(y.into()))) - .saturating_add(T::DbWeight::get().writes(8_u64)) - .saturating_add(Weight::from_parts(0, 11508).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 1108).saturating_mul(z.into())) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:256 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 255]`. - fn second_to_limit_contribution(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `2246 + x * (137 ±0)` - // Estimated: `6208 + x * (2839 ±0)` - // Minimum execution time: 124_000_000 picoseconds. - Weight::from_parts(128_568_935, 6208) - // Standard Error: 11_772 - .saturating_add(Weight::from_parts(3_704_148, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(11_u64)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(7_u64)) - .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:256 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9833 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 255]`. - /// The range of component `y` is `[1, 99]`. - /// The range of component `z` is `[1, 10000]`. - fn second_to_limit_contribution_ends_round(x: u32, y: u32, z: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `44564 + x * (137 ±0) + y * (254 ±0) + z * (21 ±0)` - // Estimated: `15401 + x * (2839 ±0) + y * (92965 ±6_111) + z * (1905 ±59)` - // Minimum execution time: 1_120_000_000 picoseconds. - Weight::from_parts(55_806_166, 15401) - // Standard Error: 7_331_488 - .saturating_add(Weight::from_parts(111_668_126, 0).saturating_mul(y.into())) - // Standard Error: 71_852 - .saturating_add(Weight::from_parts(2_292_683, 0).saturating_mul(z.into())) - .saturating_add(T::DbWeight::get().reads(17_u64)) - .saturating_add(T::DbWeight::get().reads((37_u64).saturating_mul(y.into()))) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(z.into()))) - .saturating_add(T::DbWeight::get().writes(8_u64)) - .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 92965).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 1905).saturating_mul(z.into())) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:257 w:2) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - fn contribution_over_limit() -> Weight { - // Proof Size summary in bytes: - // Measured: `37473` - // Estimated: `730613` - // Minimum execution time: 1_082_000_000 picoseconds. - Weight::from_parts(1_150_000_000, 730613) - .saturating_add(T::DbWeight::get().reads(267_u64)) - .saturating_add(T::DbWeight::get().writes(8_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - fn evaluation_unbond_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `1477` - // Estimated: `4614` - // Minimum execution time: 54_000_000 picoseconds. - Weight::from_parts(57_000_000, 4614) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Account` (r:1 w:1) - /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Asset` (r:1 w:1) - /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - fn evaluation_reward_payout_for_with_ct_account_creation() -> Weight { - // Proof Size summary in bytes: - // Measured: `1654` - // Estimated: `4614` - // Minimum execution time: 94_000_000 picoseconds. - Weight::from_parts(98_000_000, 4614) - .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Account` (r:1 w:1) - /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Asset` (r:1 w:1) - /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - fn evaluation_reward_payout_for_no_ct_account_creation() -> Weight { - // Proof Size summary in bytes: - // Measured: `1322` - // Estimated: `3814` - // Minimum execution time: 48_000_000 picoseconds. - Weight::from_parts(50_000_000, 3814) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - fn evaluation_slash_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `1485` - // Estimated: `4614` - // Minimum execution time: 67_000_000 picoseconds. - Weight::from_parts(69_000_000, 4614) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) - } - /// Storage: `PolimecFunding::Bids` (r:1 w:1) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Asset` (r:1 w:1) - /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Account` (r:1 w:1) - /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - fn bid_ct_mint_for_with_ct_account_creation() -> Weight { - // Proof Size summary in bytes: - // Measured: `1735` - // Estimated: `4614` - // Minimum execution time: 99_000_000 picoseconds. - Weight::from_parts(103_000_000, 4614) - .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) - } - /// Storage: `PolimecFunding::Bids` (r:1 w:1) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Asset` (r:1 w:1) - /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Account` (r:1 w:1) - /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - fn bid_ct_mint_for_no_ct_account_creation() -> Weight { - // Proof Size summary in bytes: - // Measured: `1250` - // Estimated: `3883` - // Minimum execution time: 46_000_000 picoseconds. - Weight::from_parts(50_000_000, 3883) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) - } - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Asset` (r:1 w:1) - /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Account` (r:1 w:1) - /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - fn contribution_ct_mint_for_with_ct_account_creation() -> Weight { - // Proof Size summary in bytes: - // Measured: `1651` - // Estimated: `4614` - // Minimum execution time: 94_000_000 picoseconds. - Weight::from_parts(100_000_000, 4614) - .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) - } - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Asset` (r:1 w:1) - /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Account` (r:1 w:1) - /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - fn contribution_ct_mint_for_no_ct_account_creation() -> Weight { - // Proof Size summary in bytes: - // Measured: `1287` - // Estimated: `3829` - // Minimum execution time: 47_000_000 picoseconds. - Weight::from_parts(50_000_000, 3829) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:1 w:1) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `LinearRelease::Vesting` (r:1 w:1) - /// Proof: `LinearRelease::Vesting` (`max_values`: None, `max_size`: None, mode: `Measured`) - fn start_bid_vesting_schedule_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `851` - // Estimated: `4316` - // Minimum execution time: 29_000_000 picoseconds. - Weight::from_parts(31_000_000, 4316) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `LinearRelease::Vesting` (r:1 w:1) - /// Proof: `LinearRelease::Vesting` (`max_values`: None, `max_size`: None, mode: `Measured`) - fn start_contribution_vesting_schedule_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `880` - // Estimated: `4345` - // Minimum execution time: 30_000_000 picoseconds. - Weight::from_parts(31_000_000, 4345) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:1 w:1) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - fn payout_bid_funds_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `1405` - // Estimated: `6208` - // Minimum execution time: 67_000_000 picoseconds. - Weight::from_parts(68_000_000, 6208) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(5_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - fn payout_contribution_funds_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `1434` - // Estimated: `6208` - // Minimum execution time: 66_000_000 picoseconds. - Weight::from_parts(69_000_000, 6208) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(5_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:2980 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - /// The range of component `y` is `[1, 10000]`. - fn decide_project_outcome(x: u32, y: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `4454 + x * (93 ±0) + y * (11 ±0)` - // Estimated: `28512 + x * (3946 ±3_374) + y * (1161 ±33)` - // Minimum execution time: 58_000_000 picoseconds. - Weight::from_parts(59_000_000, 28512) - // Standard Error: 3_928_236 - .saturating_add(Weight::from_parts(3_329_337, 0).saturating_mul(x.into())) - // Standard Error: 38_938 - .saturating_add(Weight::from_parts(1_351_270, 0).saturating_mul(y.into())) - .saturating_add(T::DbWeight::get().reads(12_u64)) - .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(1_u64)) - .saturating_add(Weight::from_parts(0, 3946).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 1161).saturating_mul(y.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:1 w:1) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - fn release_bid_funds_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `1514` - // Estimated: `6208` - // Minimum execution time: 65_000_000 picoseconds. - Weight::from_parts(70_000_000, 6208) - .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - fn release_contribution_funds_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `1507` - // Estimated: `6208` - // Minimum execution time: 63_000_000 picoseconds. - Weight::from_parts(69_000_000, 6208) - .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:1 w:1) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - fn bid_unbond_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `1519` - // Estimated: `4614` - // Minimum execution time: 54_000_000 picoseconds. - Weight::from_parts(56_000_000, 4614) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - fn contribution_unbond_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `1474` - // Estimated: `4614` - // Minimum execution time: 54_000_000 picoseconds. - Weight::from_parts(57_000_000, 4614) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:1 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:4 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:99 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn end_evaluation_success(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1174 + x * (29 ±0)` - // Estimated: `12270 + x * (2502 ±0)` - // Minimum execution time: 38_000_000 picoseconds. - Weight::from_parts(36_057_447, 12270) - // Standard Error: 5_687 - .saturating_add(Weight::from_parts(2_349_611, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:1 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:4 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - fn end_evaluation_failure() -> Weight { - // Proof Size summary in bytes: - // Measured: `1148` - // Estimated: `12270` - // Minimum execution time: 33_000_000 picoseconds. - Weight::from_parts(35_000_000, 12270) - .saturating_add(T::DbWeight::get().reads(6_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:102 w:2) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn start_auction_automatically(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `413 + x * (29 ±0)` - // Estimated: `8496 + x * (2502 ±0)` - // Minimum execution time: 26_000_000 picoseconds. - Weight::from_parts(28_124_881, 8496) - // Standard Error: 5_442 - .saturating_add(Weight::from_parts(2_521_942, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn start_candle_phase(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `446 + x * (29 ±0)` - // Estimated: `3814 + x * (2502 ±0)` - // Minimum execution time: 17_000_000 picoseconds. - Weight::from_parts(17_987_956, 3814) - // Standard Error: 5_995 - .saturating_add(Weight::from_parts(2_286_160, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Nonce` (r:1 w:1) - /// Proof: `PolimecFunding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Random::RandomMaterial` (r:1 w:0) - /// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:2049 w:2048) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:1 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:1025 w:1025) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1024 w:1024) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1024 w:1024) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Buckets` (r:1 w:0) - /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - /// The range of component `y` is `[1, 1024]`. - /// The range of component `z` is `[0, 1024]`. - fn start_community_funding_success(x: u32, y: u32, z: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `86802 + x * (29 ±0) + y * (167 ±0) + z * (367 ±0)` - // Estimated: `4079 + x * (2502 ±0) + y * (2893 ±0) + z * (3624 ±0)` - // Minimum execution time: 8_733_000_000 picoseconds. - Weight::from_parts(8_889_000_000, 4079) - // Standard Error: 235_341 - .saturating_add(Weight::from_parts(6_457_226, 0).saturating_mul(y.into())) - // Standard Error: 235_237 - .saturating_add(Weight::from_parts(70_277_060, 0).saturating_mul(z.into())) - .saturating_add(T::DbWeight::get().reads(10_u64)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into()))) - .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(z.into()))) - .saturating_add(T::DbWeight::get().writes(5_u64)) - .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) - .saturating_add(T::DbWeight::get().writes((4_u64).saturating_mul(z.into()))) - .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 2893).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 3624).saturating_mul(z.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Nonce` (r:1 w:1) - /// Proof: `PolimecFunding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Random::RandomMaterial` (r:1 w:0) - /// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:1 w:0) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:1 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Buckets` (r:1 w:0) - /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn start_community_funding_failure(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1418 + x * (3 ±0)` - // Estimated: `4079` - // Minimum execution time: 87_000_000 picoseconds. - Weight::from_parts(97_589_188, 4079) - // Standard Error: 3_828 - .saturating_add(Weight::from_parts(26_576, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(3_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn start_remainder_funding(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `536 + x * (29 ±0)` - // Estimated: `3814 + x * (2502 ±0)` - // Minimum execution time: 18_000_000 picoseconds. - Weight::from_parts(18_694_146, 3814) - // Standard Error: 5_669 - .saturating_add(Weight::from_parts(2_256_677, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn end_funding_automatically_rejected_evaluators_slashed(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `824 + x * (29 ±0)` - // Estimated: `3814 + x * (2502 ±0)` - // Minimum execution time: 24_000_000 picoseconds. - Weight::from_parts(23_753_565, 3814) - // Standard Error: 4_976 - .saturating_add(Weight::from_parts(2_285_728, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn end_funding_awaiting_decision_evaluators_slashed(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `823 + x * (29 ±0)` - // Estimated: `3814 + x * (2502 ±0)` - // Minimum execution time: 18_000_000 picoseconds. - Weight::from_parts(19_149_882, 3814) - // Standard Error: 4_893 - .saturating_add(Weight::from_parts(2_241_882, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn end_funding_awaiting_decision_evaluators_unchanged(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `823 + x * (29 ±0)` - // Estimated: `3814 + x * (2502 ±0)` - // Minimum execution time: 18_000_000 picoseconds. - Weight::from_parts(18_735_663, 3814) - // Standard Error: 5_515 - .saturating_add(Weight::from_parts(2_252_806, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:2048 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - /// The range of component `y` is `[1, 2048]`. - fn end_funding_automatically_accepted_evaluators_rewarded(x: u32, y: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1184 + x * (29 ±0) + y * (187 ±0)` - // Estimated: `3814 + x * (2502 ±0) + y * (2820 ±0)` - // Minimum execution time: 257_000_000 picoseconds. - Weight::from_parts(260_000_000, 3814) - // Standard Error: 52_986 - .saturating_add(Weight::from_parts(476_614, 0).saturating_mul(x.into())) - // Standard Error: 2_564 - .saturating_add(Weight::from_parts(4_091_225, 0).saturating_mul(y.into())) - .saturating_add(T::DbWeight::get().reads(4_u64)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into()))) - .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 2820).saturating_mul(y.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:2 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - fn project_decision_accept_funding() -> Weight { - // Proof Size summary in bytes: - // Measured: `563` - // Estimated: `5994` - // Minimum execution time: 18_000_000 picoseconds. - Weight::from_parts(19_000_000, 5994) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:2 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - fn project_decision_reject_funding() -> Weight { - // Proof Size summary in bytes: - // Measured: `563` - // Estimated: `5994` - // Minimum execution time: 18_000_000 picoseconds. - Weight::from_parts(19_000_000, 5994) - .saturating_add(T::DbWeight::get().reads(3_u64)) - .saturating_add(T::DbWeight::get().writes(2_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Asset` (r:1 w:1) - /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Metadata` (r:1 w:1) - /// Proof: `LocalAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - fn start_settlement_funding_success() -> Weight { - // Proof Size summary in bytes: - // Measured: `970` - // Estimated: `3814` - // Minimum execution time: 41_000_000 picoseconds. - Weight::from_parts(43_000_000, 3814) - .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - fn start_settlement_funding_failure() -> Weight { - // Proof Size summary in bytes: - // Measured: `760` - // Estimated: `3814` - // Minimum execution time: 11_000_000 picoseconds. - Weight::from_parts(12_000_000, 3814) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) - } -} - -// For backwards compatibility and tests. -impl WeightInfo for () { - /// Storage: `PolimecFunding::NextProjectId` (r:1 w:1) - /// Proof: `PolimecFunding::NextProjectId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Images` (r:1 w:1) - /// Proof: `PolimecFunding::Images` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Buckets` (r:0 w:1) - /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:0 w:1) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:0 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - fn create() -> Weight { - // Proof Size summary in bytes: - // Measured: `161` - // Estimated: `3593` - // Minimum execution time: 92_000_000 picoseconds. - Weight::from_parts(94_000_000, 3593) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(6_u64)) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Images` (r:1 w:0) - /// Proof: `PolimecFunding::Images` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) - fn edit_metadata() -> Weight { - // Proof Size summary in bytes: - // Measured: `609` - // Estimated: `3814` - // Minimum execution time: 18_000_000 picoseconds. - Weight::from_parts(19_000_000, 3814) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn start_evaluation(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `562 + x * (29 ±0)` - // Estimated: `3814 + x * (2502 ±0)` - // Minimum execution time: 23_000_000 picoseconds. - Weight::from_parts(21_490_523, 3814) - // Standard Error: 5_416 - .saturating_add(Weight::from_parts(2_287_829, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:4558 w:2) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - /// The range of component `y` is `[1, 10000]`. - fn start_auction_manually(x: u32, y: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `0 + x * (539 ±0) + y * (13 ±0)` - // Estimated: `217021 + x * (8051 ±6_772) + y * (979 ±66)` - // Minimum execution time: 321_000_000 picoseconds. - Weight::from_parts(325_000_000, 217021) - // Standard Error: 3_856_088 - .saturating_add(Weight::from_parts(10_425_661, 0).saturating_mul(x.into())) - // Standard Error: 38_223 - .saturating_add(Weight::from_parts(1_158_523, 0).saturating_mul(y.into())) - .saturating_add(RocksDbWeight::get().reads(87_u64)) - .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 8051).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 979).saturating_mul(y.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) - /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:1 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::EvaluationCounts` (r:1 w:1) - /// Proof: `PolimecFunding::EvaluationCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - fn first_evaluation() -> Weight { - // Proof Size summary in bytes: - // Measured: `745` - // Estimated: `4614` - // Minimum execution time: 90_000_000 picoseconds. - Weight::from_parts(97_000_000, 4614) - .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().writes(5_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) - /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:16 w:1) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:1 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::EvaluationCounts` (r:1 w:1) - /// Proof: `PolimecFunding::EvaluationCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 15]`. - fn second_to_limit_evaluation(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `941 + x * (137 ±0)` - // Estimated: `4614 + x * (2820 ±0)` - // Minimum execution time: 70_000_000 picoseconds. - Weight::from_parts(73_938_801, 4614) - // Standard Error: 20_740 - .saturating_add(Weight::from_parts(3_615_461, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(5_u64)) - .saturating_add(Weight::from_parts(0, 2820).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) - /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:17 w:2) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:1 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::EvaluationCounts` (r:1 w:1) - /// Proof: `PolimecFunding::EvaluationCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - fn evaluation_over_limit() -> Weight { - // Proof Size summary in bytes: - // Measured: `3148` - // Estimated: `48930` - // Minimum execution time: 152_000_000 picoseconds. - Weight::from_parts(158_000_000, 48930) - .saturating_add(RocksDbWeight::get().reads(22_u64)) - .saturating_add(RocksDbWeight::get().writes(6_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:128 w:10) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::BidCounts` (r:1 w:1) - /// Proof: `PolimecFunding::BidCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Buckets` (r:1 w:1) - /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextBidId` (r:1 w:1) - /// Proof: `PolimecFunding::NextBidId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// The range of component `x` is `[0, 127]`. - /// The range of component `y` is `[0, 10]`. - fn bid_no_ct_deposit(x: u32, y: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `2278 + x * (164 ±0)` - // Estimated: `6208 + x * (2893 ±0)` - // Minimum execution time: 539_000_000 picoseconds. - Weight::from_parts(84_439_405, 6208) - // Standard Error: 20_670 - .saturating_add(Weight::from_parts(3_779_627, 0).saturating_mul(x.into())) - // Standard Error: 250_512 - .saturating_add(Weight::from_parts(73_255_675, 0).saturating_mul(y.into())) - .saturating_add(RocksDbWeight::get().reads(13_u64)) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(7_u64)) - .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(y.into()))) - .saturating_add(Weight::from_parts(0, 2893).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:1 w:10) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::BidCounts` (r:1 w:1) - /// Proof: `PolimecFunding::BidCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Buckets` (r:1 w:1) - /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextBidId` (r:1 w:1) - /// Proof: `PolimecFunding::NextBidId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// The range of component `y` is `[0, 10]`. - fn bid_with_ct_deposit(y: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `2184` - // Estimated: `6208` - // Minimum execution time: 143_000_000 picoseconds. - Weight::from_parts(110_639_424, 6208) - // Standard Error: 314_196 - .saturating_add(Weight::from_parts(70_855_879, 0).saturating_mul(y.into())) - .saturating_add(RocksDbWeight::get().reads(13_u64)) - .saturating_add(RocksDbWeight::get().writes(8_u64)) - .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(y.into()))) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - fn first_contribution_with_ct_deposit() -> Weight { - // Proof Size summary in bytes: - // Measured: `2029` - // Estimated: `6208` - // Minimum execution time: 146_000_000 picoseconds. - Weight::from_parts(151_000_000, 6208) - .saturating_add(RocksDbWeight::get().reads(11_u64)) - .saturating_add(RocksDbWeight::get().writes(7_u64)) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - fn first_contribution_no_ct_deposit() -> Weight { - // Proof Size summary in bytes: - // Measured: `2106` - // Estimated: `6208` - // Minimum execution time: 118_000_000 picoseconds. - Weight::from_parts(120_000_000, 6208) - .saturating_add(RocksDbWeight::get().reads(11_u64)) - .saturating_add(RocksDbWeight::get().writes(7_u64)) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9833 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `y` is `[1, 99]`. - /// The range of component `z` is `[1, 10000]`. - fn first_contribution_ends_round_with_ct_deposit(y: u32, z: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `0 + y * (140 ±0) + z * (20 ±0)` - // Estimated: `66042 + y * (11508 ±3_537) + z * (1108 ±35)` - // Minimum execution time: 232_000_000 picoseconds. - Weight::from_parts(246_000_000, 66042) - // Standard Error: 4_200_086 - .saturating_add(Weight::from_parts(12_470_526, 0).saturating_mul(y.into())) - // Standard Error: 41_632 - .saturating_add(Weight::from_parts(1_318_329, 0).saturating_mul(z.into())) - .saturating_add(RocksDbWeight::get().reads(37_u64)) - .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(y.into()))) - .saturating_add(RocksDbWeight::get().writes(8_u64)) - .saturating_add(Weight::from_parts(0, 11508).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 1108).saturating_mul(z.into())) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9833 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `y` is `[1, 99]`. - /// The range of component `z` is `[1, 10000]`. - fn first_contribution_ends_round_no_ct_deposit(y: u32, z: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `0 + y * (140 ±0) + z * (20 ±0)` - // Estimated: `66042 + y * (11508 ±3_537) + z * (1108 ±35)` - // Minimum execution time: 212_000_000 picoseconds. - Weight::from_parts(223_000_000, 66042) - // Standard Error: 4_200_933 - .saturating_add(Weight::from_parts(12_638_804, 0).saturating_mul(y.into())) - // Standard Error: 41_641 - .saturating_add(Weight::from_parts(1_313_036, 0).saturating_mul(z.into())) - .saturating_add(RocksDbWeight::get().reads(37_u64)) - .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(y.into()))) - .saturating_add(RocksDbWeight::get().writes(8_u64)) - .saturating_add(Weight::from_parts(0, 11508).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 1108).saturating_mul(z.into())) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:256 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 255]`. - fn second_to_limit_contribution(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `2246 + x * (137 ±0)` - // Estimated: `6208 + x * (2839 ±0)` - // Minimum execution time: 124_000_000 picoseconds. - Weight::from_parts(128_568_935, 6208) - // Standard Error: 11_772 - .saturating_add(Weight::from_parts(3_704_148, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(11_u64)) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(7_u64)) - .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:256 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9833 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 255]`. - /// The range of component `y` is `[1, 99]`. - /// The range of component `z` is `[1, 10000]`. - fn second_to_limit_contribution_ends_round(x: u32, y: u32, z: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `44564 + x * (137 ±0) + y * (254 ±0) + z * (21 ±0)` - // Estimated: `15401 + x * (2839 ±0) + y * (92965 ±6_111) + z * (1905 ±59)` - // Minimum execution time: 1_120_000_000 picoseconds. - Weight::from_parts(55_806_166, 15401) - // Standard Error: 7_331_488 - .saturating_add(Weight::from_parts(111_668_126, 0).saturating_mul(y.into())) - // Standard Error: 71_852 - .saturating_add(Weight::from_parts(2_292_683, 0).saturating_mul(z.into())) - .saturating_add(RocksDbWeight::get().reads(17_u64)) - .saturating_add(RocksDbWeight::get().reads((37_u64).saturating_mul(y.into()))) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(z.into()))) - .saturating_add(RocksDbWeight::get().writes(8_u64)) - .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 92965).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 1905).saturating_mul(z.into())) - } - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:257 w:2) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:2 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::NextContributionId` (r:1 w:1) - /// Proof: `PolimecFunding::NextContributionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - fn contribution_over_limit() -> Weight { - // Proof Size summary in bytes: - // Measured: `37473` - // Estimated: `730613` - // Minimum execution time: 1_082_000_000 picoseconds. - Weight::from_parts(1_150_000_000, 730613) - .saturating_add(RocksDbWeight::get().reads(267_u64)) - .saturating_add(RocksDbWeight::get().writes(8_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - fn evaluation_unbond_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `1477` - // Estimated: `4614` - // Minimum execution time: 54_000_000 picoseconds. - Weight::from_parts(57_000_000, 4614) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Account` (r:1 w:1) - /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Asset` (r:1 w:1) - /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - fn evaluation_reward_payout_for_with_ct_account_creation() -> Weight { - // Proof Size summary in bytes: - // Measured: `1654` - // Estimated: `4614` - // Minimum execution time: 94_000_000 picoseconds. - Weight::from_parts(98_000_000, 4614) - .saturating_add(RocksDbWeight::get().reads(5_u64)) - .saturating_add(RocksDbWeight::get().writes(4_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Account` (r:1 w:1) - /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Asset` (r:1 w:1) - /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - fn evaluation_reward_payout_for_no_ct_account_creation() -> Weight { - // Proof Size summary in bytes: - // Measured: `1322` - // Estimated: `3814` - // Minimum execution time: 48_000_000 picoseconds. - Weight::from_parts(50_000_000, 3814) - .saturating_add(RocksDbWeight::get().reads(4_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:1 w:1) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - fn evaluation_slash_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `1485` - // Estimated: `4614` - // Minimum execution time: 67_000_000 picoseconds. - Weight::from_parts(69_000_000, 4614) - .saturating_add(RocksDbWeight::get().reads(4_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - } - /// Storage: `PolimecFunding::Bids` (r:1 w:1) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Asset` (r:1 w:1) - /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Account` (r:1 w:1) - /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - fn bid_ct_mint_for_with_ct_account_creation() -> Weight { - // Proof Size summary in bytes: - // Measured: `1735` - // Estimated: `4614` - // Minimum execution time: 99_000_000 picoseconds. - Weight::from_parts(103_000_000, 4614) - .saturating_add(RocksDbWeight::get().reads(5_u64)) - .saturating_add(RocksDbWeight::get().writes(4_u64)) - } - /// Storage: `PolimecFunding::Bids` (r:1 w:1) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Asset` (r:1 w:1) - /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Account` (r:1 w:1) - /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - fn bid_ct_mint_for_no_ct_account_creation() -> Weight { - // Proof Size summary in bytes: - // Measured: `1250` - // Estimated: `3883` - // Minimum execution time: 46_000_000 picoseconds. - Weight::from_parts(50_000_000, 3883) - .saturating_add(RocksDbWeight::get().reads(4_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - } - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Asset` (r:1 w:1) - /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Account` (r:1 w:1) - /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - fn contribution_ct_mint_for_with_ct_account_creation() -> Weight { - // Proof Size summary in bytes: - // Measured: `1651` - // Estimated: `4614` - // Minimum execution time: 94_000_000 picoseconds. - Weight::from_parts(100_000_000, 4614) - .saturating_add(RocksDbWeight::get().reads(5_u64)) - .saturating_add(RocksDbWeight::get().writes(4_u64)) - } - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Asset` (r:1 w:1) - /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Account` (r:1 w:1) - /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - fn contribution_ct_mint_for_no_ct_account_creation() -> Weight { - // Proof Size summary in bytes: - // Measured: `1287` - // Estimated: `3829` - // Minimum execution time: 47_000_000 picoseconds. - Weight::from_parts(50_000_000, 3829) - .saturating_add(RocksDbWeight::get().reads(4_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:1 w:1) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `LinearRelease::Vesting` (r:1 w:1) - /// Proof: `LinearRelease::Vesting` (`max_values`: None, `max_size`: None, mode: `Measured`) - fn start_bid_vesting_schedule_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `851` - // Estimated: `4316` - // Minimum execution time: 29_000_000 picoseconds. - Weight::from_parts(31_000_000, 4316) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `LinearRelease::Vesting` (r:1 w:1) - /// Proof: `LinearRelease::Vesting` (`max_values`: None, `max_size`: None, mode: `Measured`) - fn start_contribution_vesting_schedule_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `880` - // Estimated: `4345` - // Minimum execution time: 30_000_000 picoseconds. - Weight::from_parts(31_000_000, 4345) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:1 w:1) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - fn payout_bid_funds_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `1405` - // Estimated: `6208` - // Minimum execution time: 67_000_000 picoseconds. - Weight::from_parts(68_000_000, 6208) - .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().writes(5_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - fn payout_contribution_funds_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `1434` - // Estimated: `6208` - // Minimum execution time: 66_000_000 picoseconds. - Weight::from_parts(69_000_000, 6208) - .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().writes(5_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:2980 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - /// The range of component `y` is `[1, 10000]`. - fn decide_project_outcome(x: u32, y: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `4454 + x * (93 ±0) + y * (11 ±0)` - // Estimated: `28512 + x * (3946 ±3_374) + y * (1161 ±33)` - // Minimum execution time: 58_000_000 picoseconds. - Weight::from_parts(59_000_000, 28512) - // Standard Error: 3_928_236 - .saturating_add(Weight::from_parts(3_329_337, 0).saturating_mul(x.into())) - // Standard Error: 38_938 - .saturating_add(Weight::from_parts(1_351_270, 0).saturating_mul(y.into())) - .saturating_add(RocksDbWeight::get().reads(12_u64)) - .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - .saturating_add(Weight::from_parts(0, 3946).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 1161).saturating_mul(y.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:1 w:1) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - fn release_bid_funds_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `1514` - // Estimated: `6208` - // Minimum execution time: 65_000_000 picoseconds. - Weight::from_parts(70_000_000, 6208) - .saturating_add(RocksDbWeight::get().reads(5_u64)) - .saturating_add(RocksDbWeight::get().writes(4_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:2 w:2) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - fn release_contribution_funds_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `1507` - // Estimated: `6208` - // Minimum execution time: 63_000_000 picoseconds. - Weight::from_parts(69_000_000, 6208) - .saturating_add(RocksDbWeight::get().reads(5_u64)) - .saturating_add(RocksDbWeight::get().writes(4_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:1 w:1) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - fn bid_unbond_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `1519` - // Estimated: `4614` - // Minimum execution time: 54_000_000 picoseconds. - Weight::from_parts(56_000_000, 4614) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Contributions` (r:1 w:1) - /// Proof: `PolimecFunding::Contributions` (`max_values`: None, `max_size`: Some(364), added: 2839, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1 w:1) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - fn contribution_unbond_for() -> Weight { - // Proof Size summary in bytes: - // Measured: `1474` - // Estimated: `4614` - // Minimum execution time: 54_000_000 picoseconds. - Weight::from_parts(57_000_000, 4614) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:1 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:4 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:99 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn end_evaluation_success(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1174 + x * (29 ±0)` - // Estimated: `12270 + x * (2502 ±0)` - // Minimum execution time: 38_000_000 picoseconds. - Weight::from_parts(36_057_447, 12270) - // Standard Error: 5_687 - .saturating_add(Weight::from_parts(2_349_611, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:1 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:4 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - fn end_evaluation_failure() -> Weight { - // Proof Size summary in bytes: - // Measured: `1148` - // Estimated: `12270` - // Minimum execution time: 33_000_000 picoseconds. - Weight::from_parts(35_000_000, 12270) - .saturating_add(RocksDbWeight::get().reads(6_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:102 w:2) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn start_auction_automatically(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `413 + x * (29 ±0)` - // Estimated: `8496 + x * (2502 ±0)` - // Minimum execution time: 26_000_000 picoseconds. - Weight::from_parts(28_124_881, 8496) - // Standard Error: 5_442 - .saturating_add(Weight::from_parts(2_521_942, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(4_u64)) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn start_candle_phase(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `446 + x * (29 ±0)` - // Estimated: `3814 + x * (2502 ±0)` - // Minimum execution time: 17_000_000 picoseconds. - Weight::from_parts(17_987_956, 3814) - // Standard Error: 5_995 - .saturating_add(Weight::from_parts(2_286_160, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Nonce` (r:1 w:1) - /// Proof: `PolimecFunding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Random::RandomMaterial` (r:1 w:0) - /// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:2049 w:2048) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:1 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Asset` (r:1 w:1) - /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `StatemintAssets::Account` (r:1025 w:1025) - /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1024 w:1024) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - /// Storage: `Balances::Holds` (r:1024 w:1024) - /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Buckets` (r:1 w:0) - /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - /// The range of component `y` is `[1, 1024]`. - /// The range of component `z` is `[0, 1024]`. - fn start_community_funding_success(x: u32, y: u32, z: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `86802 + x * (29 ±0) + y * (167 ±0) + z * (367 ±0)` - // Estimated: `4079 + x * (2502 ±0) + y * (2893 ±0) + z * (3624 ±0)` - // Minimum execution time: 8_733_000_000 picoseconds. - Weight::from_parts(8_889_000_000, 4079) - // Standard Error: 235_341 - .saturating_add(Weight::from_parts(6_457_226, 0).saturating_mul(y.into())) - // Standard Error: 235_237 - .saturating_add(Weight::from_parts(70_277_060, 0).saturating_mul(z.into())) - .saturating_add(RocksDbWeight::get().reads(10_u64)) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(y.into()))) - .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(z.into()))) - .saturating_add(RocksDbWeight::get().writes(5_u64)) - .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(y.into()))) - .saturating_add(RocksDbWeight::get().writes((4_u64).saturating_mul(z.into()))) - .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 2893).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 3624).saturating_mul(z.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Nonce` (r:1 w:1) - /// Proof: `PolimecFunding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Random::RandomMaterial` (r:1 w:0) - /// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:1 w:0) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:1 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Buckets` (r:1 w:0) - /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn start_community_funding_failure(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1418 + x * (3 ±0)` - // Estimated: `4079` - // Minimum execution time: 87_000_000 picoseconds. - Weight::from_parts(97_589_188, 4079) - // Standard Error: 3_828 - .saturating_add(Weight::from_parts(26_576, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(8_u64)) - .saturating_add(RocksDbWeight::get().writes(3_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn start_remainder_funding(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `536 + x * (29 ±0)` - // Estimated: `3814 + x * (2502 ±0)` - // Minimum execution time: 18_000_000 picoseconds. - Weight::from_parts(18_694_146, 3814) - // Standard Error: 5_669 - .saturating_add(Weight::from_parts(2_256_677, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn end_funding_automatically_rejected_evaluators_slashed(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `824 + x * (29 ±0)` - // Estimated: `3814 + x * (2502 ±0)` - // Minimum execution time: 24_000_000 picoseconds. - Weight::from_parts(23_753_565, 3814) - // Standard Error: 4_976 - .saturating_add(Weight::from_parts(2_285_728, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn end_funding_awaiting_decision_evaluators_slashed(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `823 + x * (29 ±0)` - // Estimated: `3814 + x * (2502 ±0)` - // Minimum execution time: 18_000_000 picoseconds. - Weight::from_parts(19_149_882, 3814) - // Standard Error: 4_893 - .saturating_add(Weight::from_parts(2_241_882, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn end_funding_awaiting_decision_evaluators_unchanged(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `823 + x * (29 ±0)` - // Estimated: `3814 + x * (2502 ±0)` - // Minimum execution time: 18_000_000 picoseconds. - Weight::from_parts(18_735_663, 3814) - // Standard Error: 5_515 - .saturating_add(Weight::from_parts(2_252_806, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:2048 w:0) - /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - /// The range of component `y` is `[1, 2048]`. - fn end_funding_automatically_accepted_evaluators_rewarded(x: u32, y: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `1184 + x * (29 ±0) + y * (187 ±0)` - // Estimated: `3814 + x * (2502 ±0) + y * (2820 ±0)` - // Minimum execution time: 257_000_000 picoseconds. - Weight::from_parts(260_000_000, 3814) - // Standard Error: 52_986 - .saturating_add(Weight::from_parts(476_614, 0).saturating_mul(x.into())) - // Standard Error: 2_564 - .saturating_add(Weight::from_parts(4_091_225, 0).saturating_mul(y.into())) - .saturating_add(RocksDbWeight::get().reads(4_u64)) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(y.into()))) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 2820).saturating_mul(y.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:2 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - fn project_decision_accept_funding() -> Weight { - // Proof Size summary in bytes: - // Measured: `563` - // Estimated: `5994` - // Minimum execution time: 18_000_000 picoseconds. - Weight::from_parts(19_000_000, 5994) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:2 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) - fn project_decision_reject_funding() -> Weight { - // Proof Size summary in bytes: - // Measured: `563` - // Estimated: `5994` - // Minimum execution time: 18_000_000 picoseconds. - Weight::from_parts(19_000_000, 5994) - .saturating_add(RocksDbWeight::get().reads(3_u64)) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Asset` (r:1 w:1) - /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Metadata` (r:1 w:1) - /// Proof: `LocalAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - fn start_settlement_funding_success() -> Weight { - // Proof Size summary in bytes: - // Measured: `970` - // Estimated: `3814` - // Minimum execution time: 41_000_000 picoseconds. - Weight::from_parts(43_000_000, 3814) - .saturating_add(RocksDbWeight::get().reads(5_u64)) - .saturating_add(RocksDbWeight::get().writes(4_u64)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - fn start_settlement_funding_failure() -> Weight { - // Proof Size summary in bytes: - // Measured: `760` - // Estimated: `3814` - // Minimum execution time: 11_000_000 picoseconds. - Weight::from_parts(12_000_000, 3814) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) - } -} \ No newline at end of file diff --git a/pallets/funding/src/weights.rs b/pallets/funding/src/weights.rs index 66326479b..78226edc1 100644 --- a/pallets/funding/src/weights.rs +++ b/pallets/funding/src/weights.rs @@ -20,7 +20,7 @@ //! Autogenerated weights for `pallet_funding` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-02-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-02-09, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `Juans-MBP.home`, CPU: `` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: `1024` @@ -53,12 +53,11 @@ pub trait WeightInfo { fn edit_metadata() -> Weight; fn start_evaluation(x: u32, ) -> Weight; fn start_auction_manually(x: u32, y: u32, ) -> Weight; - fn start_auction_automatically(x: u32, ) -> Weight; fn first_evaluation() -> Weight; fn second_to_limit_evaluation(x: u32, ) -> Weight; fn evaluation_over_limit() -> Weight; - fn bid_with_ct_deposit(y: u32, ) -> Weight; fn bid_no_ct_deposit(x: u32, y: u32, ) -> Weight; + fn bid_with_ct_deposit(y: u32, ) -> Weight; fn first_contribution_with_ct_deposit() -> Weight; fn first_contribution_no_ct_deposit() -> Weight; fn first_contribution_ends_round_with_ct_deposit(y: u32, z: u32, ) -> Weight; @@ -83,68 +82,21 @@ pub trait WeightInfo { fn release_contribution_funds_for() -> Weight; fn bid_unbond_for() -> Weight; fn contribution_unbond_for() -> Weight; - fn end_evaluation_success(x: u32, ) -> Weight; fn end_evaluation_failure() -> Weight; + fn start_auction_automatically(x: u32, ) -> Weight; fn start_candle_phase(x: u32, ) -> Weight; - - fn start_community_funding_success(x: u32, y: u32, z: u32) -> Weight; - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Nonce` (r:1 w:1) - /// Proof: `PolimecFunding::Nonce` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `Random::RandomMaterial` (r:1 w:0) - /// Proof: `Random::RandomMaterial` (`max_values`: Some(1), `max_size`: Some(2594), added: 3089, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:1 w:0) - /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) - /// Storage: `Oracle::Values` (r:1 w:0) - /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Buckets` (r:1 w:0) - /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. + fn start_community_funding_success(x: u32, y: u32, z: u32, ) -> Weight; fn start_community_funding_failure(x: u32, ) -> Weight; - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. fn start_remainder_funding(x: u32, ) -> Weight; - fn end_funding_automatically_rejected_evaluators_slashed(x: u32) -> Weight; - fn end_funding_awaiting_decision_evaluators_slashed(x: u32) -> Weight; - fn end_funding_awaiting_decision_evaluators_unchanged(x: u32) -> Weight; - fn end_funding_automatically_accepted_evaluators_rewarded(x: u32, y: u32) -> Weight; - - - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Asset` (r:1 w:1) - /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Metadata` (r:1 w:0) - /// Proof: `LocalAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - fn start_settlement_funding_success() -> Weight; - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - fn start_settlement_funding_failure() -> Weight; - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + fn end_funding_automatically_rejected_evaluators_slashed(x: u32, ) -> Weight; + fn end_funding_awaiting_decision_evaluators_slashed(x: u32, ) -> Weight; + fn end_funding_awaiting_decision_evaluators_unchanged(x: u32, ) -> Weight; + fn end_funding_automatically_accepted_evaluators_rewarded(x: u32, y: u32, ) -> Weight; fn project_decision_accept_funding() -> Weight; - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) fn project_decision_reject_funding() -> Weight; + fn start_settlement_funding_success() -> Weight; + fn start_settlement_funding_failure() -> Weight; } /// Weights for `pallet_funding` using the Substrate node and recommended hardware. @@ -166,8 +118,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `161` // Estimated: `3593` - // Minimum execution time: 60_000_000 picoseconds. - Weight::from_parts(62_000_000, 3593) + // Minimum execution time: 92_000_000 picoseconds. + Weight::from_parts(94_000_000, 3593) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(6_u64)) } @@ -191,60 +143,42 @@ impl WeightInfo for SubstrateWeight { /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. fn start_evaluation(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `563 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 22_000_000 picoseconds. - Weight::from_parts(19_253_978, 4087) - // Standard Error: 15_066 - .saturating_add(Weight::from_parts(2_633_080, 0).saturating_mul(x.into())) + // Measured: `562 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 23_000_000 picoseconds. + Weight::from_parts(21_490_523, 3814) + // Standard Error: 5_416 + .saturating_add(Weight::from_parts(2_287_829, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:4558 w:2) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. /// The range of component `y` is `[1, 10000]`. fn start_auction_manually(x: u32, y: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + x * (1281 ±0) + y * (21 ±0)` - // Estimated: `268395 + x * (9966 ±8_383) + y * (1212 ±82)` - // Minimum execution time: 397_000_000 picoseconds. - Weight::from_parts(420_000_000, 268395) - // Standard Error: 4_704_303 - .saturating_add(Weight::from_parts(12_350_427, 0).saturating_mul(x.into())) - // Standard Error: 46_630 - .saturating_add(Weight::from_parts(1_402_043, 0).saturating_mul(y.into())) + // Measured: `0 + x * (539 ±0) + y * (13 ±0)` + // Estimated: `217021 + x * (8051 ±6_772) + y * (979 ±66)` + // Minimum execution time: 321_000_000 picoseconds. + Weight::from_parts(325_000_000, 217021) + // Standard Error: 3_856_088 + .saturating_add(Weight::from_parts(10_425_661, 0).saturating_mul(x.into())) + // Standard Error: 38_223 + .saturating_add(Weight::from_parts(1_158_523, 0).saturating_mul(y.into())) .saturating_add(T::DbWeight::get().reads(87_u64)) .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 9966).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 1212).saturating_mul(y.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn start_auction_automatically(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `411 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 20_000_000 picoseconds. - Weight::from_parts(20_242_112, 4087) - // Standard Error: 18_140 - .saturating_add(Weight::from_parts(2_666_357, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 8051).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 979).saturating_mul(y.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) @@ -254,59 +188,65 @@ impl WeightInfo for SubstrateWeight { /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) /// Storage: `Oracle::Values` (r:1 w:0) /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::EvaluationCounts` (r:1 w:1) + /// Proof: `PolimecFunding::EvaluationCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) /// Storage: `Balances::Holds` (r:1 w:1) /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) fn first_evaluation() -> Weight { // Proof Size summary in bytes: - // Measured: `676` + // Measured: `745` // Estimated: `4614` - // Minimum execution time: 92_000_000 picoseconds. - Weight::from_parts(94_000_000, 4614) - .saturating_add(T::DbWeight::get().reads(5_u64)) - .saturating_add(T::DbWeight::get().writes(4_u64)) + // Minimum execution time: 90_000_000 picoseconds. + Weight::from_parts(97_000_000, 4614) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:256 w:1) + /// Storage: `PolimecFunding::Evaluations` (r:16 w:1) /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) /// Storage: `Oracle::Values` (r:1 w:0) /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::EvaluationCounts` (r:1 w:1) + /// Proof: `PolimecFunding::EvaluationCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) /// Storage: `Balances::Holds` (r:1 w:1) /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 255]`. + /// The range of component `x` is `[1, 15]`. fn second_to_limit_evaluation(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `893 + x * (137 ±0)` + // Measured: `941 + x * (137 ±0)` // Estimated: `4614 + x * (2820 ±0)` - // Minimum execution time: 71_000_000 picoseconds. - Weight::from_parts(58_910_334, 4614) - // Standard Error: 11_575 - .saturating_add(Weight::from_parts(3_780_894, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(5_u64)) + // Minimum execution time: 70_000_000 picoseconds. + Weight::from_parts(73_938_801, 4614) + // Standard Error: 20_740 + .saturating_add(Weight::from_parts(3_615_461, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(4_u64)) + .saturating_add(T::DbWeight::get().writes(5_u64)) .saturating_add(Weight::from_parts(0, 2820).saturating_mul(x.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:257 w:2) + /// Storage: `PolimecFunding::Evaluations` (r:17 w:2) /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) /// Storage: `Oracle::Values` (r:1 w:0) /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::EvaluationCounts` (r:1 w:1) + /// Proof: `PolimecFunding::EvaluationCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) /// Storage: `Balances::Holds` (r:1 w:1) /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) fn evaluation_over_limit() -> Weight { // Proof Size summary in bytes: - // Measured: `36120` - // Estimated: `725730` - // Minimum execution time: 1_017_000_000 picoseconds. - Weight::from_parts(1_051_000_000, 725730) - .saturating_add(T::DbWeight::get().reads(261_u64)) - .saturating_add(T::DbWeight::get().writes(5_u64)) + // Measured: `3148` + // Estimated: `48930` + // Minimum execution time: 152_000_000 picoseconds. + Weight::from_parts(158_000_000, 48930) + .saturating_add(T::DbWeight::get().reads(22_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) @@ -314,8 +254,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) /// Storage: `Oracle::Values` (r:2 w:0) /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:1 w:10) + /// Storage: `PolimecFunding::Bids` (r:128 w:10) /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::BidCounts` (r:1 w:1) + /// Proof: `PolimecFunding::BidCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) /// Storage: `Balances::Holds` (r:1 w:1) /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::Buckets` (r:1 w:1) @@ -328,20 +270,23 @@ impl WeightInfo for SubstrateWeight { /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) /// Storage: `StatemintAssets::Account` (r:2 w:2) /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// The range of component `x` is `[0, 127]`. /// The range of component `y` is `[0, 10]`. - fn bid_with_ct_deposit(y: u32, ) -> Weight { + fn bid_no_ct_deposit(x: u32, y: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2140` - // Estimated: `6208` - // Minimum execution time: 143_000_000 picoseconds. - Weight::from_parts(106_855_955, 6208) - // Standard Error: 319_819 - .saturating_add(Weight::from_parts(70_108_416, 0).saturating_mul(y.into())) - .saturating_add(T::DbWeight::get().reads(12_u64)) + // Measured: `2278 + x * (164 ±0)` + // Estimated: `6208 + x * (2893 ±0)` + // Minimum execution time: 539_000_000 picoseconds. + Weight::from_parts(84_439_405, 6208) + // Standard Error: 20_670 + .saturating_add(Weight::from_parts(3_779_627, 0).saturating_mul(x.into())) + // Standard Error: 250_512 + .saturating_add(Weight::from_parts(73_255_675, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(13_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().writes(7_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) + .saturating_add(Weight::from_parts(0, 2893).saturating_mul(x.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) @@ -349,8 +294,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) /// Storage: `Oracle::Values` (r:2 w:0) /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:256 w:10) + /// Storage: `PolimecFunding::Bids` (r:1 w:10) /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::BidCounts` (r:1 w:1) + /// Proof: `PolimecFunding::BidCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) /// Storage: `Balances::Holds` (r:1 w:1) /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::Buckets` (r:1 w:1) @@ -363,23 +310,20 @@ impl WeightInfo for SubstrateWeight { /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) /// Storage: `StatemintAssets::Account` (r:2 w:2) /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// The range of component `x` is `[0, 255]`. + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// The range of component `y` is `[0, 10]`. - fn bid_no_ct_deposit(x: u32, y: u32, ) -> Weight { + fn bid_with_ct_deposit(y: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2227 + x * (164 ±0)` - // Estimated: `6208 + x * (2893 ±0)` - // Minimum execution time: 760_000_000 picoseconds. - Weight::from_parts(69_652_890, 6208) - // Standard Error: 11_684 - .saturating_add(Weight::from_parts(4_020_612, 0).saturating_mul(x.into())) - // Standard Error: 283_589 - .saturating_add(Weight::from_parts(72_460_034, 0).saturating_mul(y.into())) - .saturating_add(T::DbWeight::get().reads(12_u64)) - .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(6_u64)) + // Measured: `2184` + // Estimated: `6208` + // Minimum execution time: 143_000_000 picoseconds. + Weight::from_parts(110_639_424, 6208) + // Standard Error: 314_196 + .saturating_add(Weight::from_parts(70_855_879, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(13_u64)) + .saturating_add(T::DbWeight::get().writes(8_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) - .saturating_add(Weight::from_parts(0, 2893).saturating_mul(x.into())) } /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) @@ -401,10 +345,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn first_contribution_with_ct_deposit() -> Weight { // Proof Size summary in bytes: - // Measured: `1996` + // Measured: `2029` // Estimated: `6208` - // Minimum execution time: 147_000_000 picoseconds. - Weight::from_parts(155_000_000, 6208) + // Minimum execution time: 146_000_000 picoseconds. + Weight::from_parts(151_000_000, 6208) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -428,10 +372,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn first_contribution_no_ct_deposit() -> Weight { // Proof Size summary in bytes: - // Measured: `2073` + // Measured: `2106` // Estimated: `6208` - // Minimum execution time: 119_000_000 picoseconds. - Weight::from_parts(126_000_000, 6208) + // Minimum execution time: 118_000_000 picoseconds. + Weight::from_parts(120_000_000, 6208) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().writes(7_u64)) } @@ -453,25 +397,25 @@ impl WeightInfo for SubstrateWeight { /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) /// Storage: `StatemintAssets::Account` (r:2 w:2) /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9832 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9833 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `y` is `[1, 99]`. /// The range of component `z` is `[1, 10000]`. fn first_contribution_ends_round_with_ct_deposit(y: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + y * (443 ±0) + z * (37 ±0)` - // Estimated: `78415 + y * (14240 ±4_378) + z * (1371 ±43)` - // Minimum execution time: 264_000_000 picoseconds. - Weight::from_parts(268_000_000, 78415) - // Standard Error: 5_143_014 - .saturating_add(Weight::from_parts(16_318_492, 0).saturating_mul(y.into())) - // Standard Error: 50_979 - .saturating_add(Weight::from_parts(1_601_983, 0).saturating_mul(z.into())) - .saturating_add(T::DbWeight::get().reads(36_u64)) + // Measured: `0 + y * (140 ±0) + z * (20 ±0)` + // Estimated: `66042 + y * (11508 ±3_537) + z * (1108 ±35)` + // Minimum execution time: 232_000_000 picoseconds. + Weight::from_parts(246_000_000, 66042) + // Standard Error: 4_200_086 + .saturating_add(Weight::from_parts(12_470_526, 0).saturating_mul(y.into())) + // Standard Error: 41_632 + .saturating_add(Weight::from_parts(1_318_329, 0).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(37_u64)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(y.into()))) .saturating_add(T::DbWeight::get().writes(8_u64)) - .saturating_add(Weight::from_parts(0, 14240).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 1371).saturating_mul(z.into())) + .saturating_add(Weight::from_parts(0, 11508).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 1108).saturating_mul(z.into())) } /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) @@ -491,25 +435,25 @@ impl WeightInfo for SubstrateWeight { /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) /// Storage: `StatemintAssets::Account` (r:2 w:2) /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9832 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9833 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `y` is `[1, 99]`. /// The range of component `z` is `[1, 10000]`. fn first_contribution_ends_round_no_ct_deposit(y: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + y * (443 ±0) + z * (37 ±0)` - // Estimated: `78415 + y * (14240 ±4_378) + z * (1371 ±43)` - // Minimum execution time: 226_000_000 picoseconds. - Weight::from_parts(239_000_000, 78415) - // Standard Error: 5_135_841 - .saturating_add(Weight::from_parts(15_722_813, 0).saturating_mul(y.into())) - // Standard Error: 50_908 - .saturating_add(Weight::from_parts(1_606_667, 0).saturating_mul(z.into())) - .saturating_add(T::DbWeight::get().reads(36_u64)) + // Measured: `0 + y * (140 ±0) + z * (20 ±0)` + // Estimated: `66042 + y * (11508 ±3_537) + z * (1108 ±35)` + // Minimum execution time: 212_000_000 picoseconds. + Weight::from_parts(223_000_000, 66042) + // Standard Error: 4_200_933 + .saturating_add(Weight::from_parts(12_638_804, 0).saturating_mul(y.into())) + // Standard Error: 41_641 + .saturating_add(Weight::from_parts(1_313_036, 0).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(37_u64)) .saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(y.into()))) .saturating_add(T::DbWeight::get().writes(8_u64)) - .saturating_add(Weight::from_parts(0, 14240).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 1371).saturating_mul(z.into())) + .saturating_add(Weight::from_parts(0, 11508).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 1108).saturating_mul(z.into())) } /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) @@ -532,12 +476,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `x` is `[1, 255]`. fn second_to_limit_contribution(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2213 + x * (137 ±0)` + // Measured: `2246 + x * (137 ±0)` // Estimated: `6208 + x * (2839 ±0)` // Minimum execution time: 124_000_000 picoseconds. - Weight::from_parts(117_868_102, 6208) - // Standard Error: 10_026 - .saturating_add(Weight::from_parts(3_746_658, 0).saturating_mul(x.into())) + Weight::from_parts(128_568_935, 6208) + // Standard Error: 11_772 + .saturating_add(Weight::from_parts(3_704_148, 0).saturating_mul(x.into())) .saturating_add(T::DbWeight::get().reads(11_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().writes(7_u64)) @@ -561,28 +505,28 @@ impl WeightInfo for SubstrateWeight { /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) /// Storage: `StatemintAssets::Account` (r:2 w:2) /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9832 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9833 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 255]`. /// The range of component `y` is `[1, 99]`. /// The range of component `z` is `[1, 10000]`. fn second_to_limit_contribution_ends_round(x: u32, y: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `75282 + x * (137 ±0) + y * (723 ±0) + z * (39 ±0)` - // Estimated: `17232 + x * (2839 ±0) + y * (115061 ±7_565) + z * (2358 ±74)` - // Minimum execution time: 1_097_000_000 picoseconds. - Weight::from_parts(554_228_738, 17232) - // Standard Error: 8_861_727 - .saturating_add(Weight::from_parts(133_771_367, 0).saturating_mul(y.into())) - // Standard Error: 86_849 - .saturating_add(Weight::from_parts(2_763_795, 0).saturating_mul(z.into())) - .saturating_add(T::DbWeight::get().reads(16_u64)) + // Measured: `44564 + x * (137 ±0) + y * (254 ±0) + z * (21 ±0)` + // Estimated: `15401 + x * (2839 ±0) + y * (92965 ±6_111) + z * (1905 ±59)` + // Minimum execution time: 1_120_000_000 picoseconds. + Weight::from_parts(55_806_166, 15401) + // Standard Error: 7_331_488 + .saturating_add(Weight::from_parts(111_668_126, 0).saturating_mul(y.into())) + // Standard Error: 71_852 + .saturating_add(Weight::from_parts(2_292_683, 0).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(17_u64)) .saturating_add(T::DbWeight::get().reads((37_u64).saturating_mul(y.into()))) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(z.into()))) .saturating_add(T::DbWeight::get().writes(8_u64)) .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 115061).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 2358).saturating_mul(z.into())) + .saturating_add(Weight::from_parts(0, 92965).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 1905).saturating_mul(z.into())) } /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) @@ -604,10 +548,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) fn contribution_over_limit() -> Weight { // Proof Size summary in bytes: - // Measured: `37440` + // Measured: `37473` // Estimated: `730613` - // Minimum execution time: 1_103_000_000 picoseconds. - Weight::from_parts(1_165_000_000, 730613) + // Minimum execution time: 1_082_000_000 picoseconds. + Weight::from_parts(1_150_000_000, 730613) .saturating_add(T::DbWeight::get().reads(267_u64)) .saturating_add(T::DbWeight::get().writes(8_u64)) } @@ -619,10 +563,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) fn evaluation_unbond_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1411` + // Measured: `1477` // Estimated: `4614` - // Minimum execution time: 55_000_000 picoseconds. - Weight::from_parts(60_000_000, 4614) + // Minimum execution time: 54_000_000 picoseconds. + Weight::from_parts(57_000_000, 4614) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -638,10 +582,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) fn evaluation_reward_payout_for_with_ct_account_creation() -> Weight { // Proof Size summary in bytes: - // Measured: `1515` + // Measured: `1654` // Estimated: `4614` - // Minimum execution time: 92_000_000 picoseconds. - Weight::from_parts(102_000_000, 4614) + // Minimum execution time: 94_000_000 picoseconds. + Weight::from_parts(98_000_000, 4614) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -655,10 +599,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) fn evaluation_reward_payout_for_no_ct_account_creation() -> Weight { // Proof Size summary in bytes: - // Measured: `1219` + // Measured: `1322` // Estimated: `3814` // Minimum execution time: 48_000_000 picoseconds. - Weight::from_parts(49_000_000, 3814) + Weight::from_parts(50_000_000, 3814) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -672,10 +616,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) fn evaluation_slash_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1419` + // Measured: `1485` // Estimated: `4614` - // Minimum execution time: 68_000_000 picoseconds. - Weight::from_parts(71_000_000, 4614) + // Minimum execution time: 67_000_000 picoseconds. + Weight::from_parts(69_000_000, 4614) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -691,10 +635,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) fn bid_ct_mint_for_with_ct_account_creation() -> Weight { // Proof Size summary in bytes: - // Measured: `1629` + // Measured: `1735` // Estimated: `4614` - // Minimum execution time: 96_000_000 picoseconds. - Weight::from_parts(99_000_000, 4614) + // Minimum execution time: 99_000_000 picoseconds. + Weight::from_parts(103_000_000, 4614) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -708,10 +652,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn bid_ct_mint_for_no_ct_account_creation() -> Weight { // Proof Size summary in bytes: - // Measured: `1180` + // Measured: `1250` // Estimated: `3883` - // Minimum execution time: 44_000_000 picoseconds. - Weight::from_parts(47_000_000, 3883) + // Minimum execution time: 46_000_000 picoseconds. + Weight::from_parts(50_000_000, 3883) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -727,10 +671,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) fn contribution_ct_mint_for_with_ct_account_creation() -> Weight { // Proof Size summary in bytes: - // Measured: `1545` + // Measured: `1651` // Estimated: `4614` - // Minimum execution time: 91_000_000 picoseconds. - Weight::from_parts(98_000_000, 4614) + // Minimum execution time: 94_000_000 picoseconds. + Weight::from_parts(100_000_000, 4614) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -744,9 +688,9 @@ impl WeightInfo for SubstrateWeight { /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn contribution_ct_mint_for_no_ct_account_creation() -> Weight { // Proof Size summary in bytes: - // Measured: `1217` + // Measured: `1287` // Estimated: `3829` - // Minimum execution time: 46_000_000 picoseconds. + // Minimum execution time: 47_000_000 picoseconds. Weight::from_parts(50_000_000, 3829) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) @@ -759,10 +703,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `LinearRelease::Vesting` (`max_values`: None, `max_size`: None, mode: `Measured`) fn start_bid_vesting_schedule_for() -> Weight { // Proof Size summary in bytes: - // Measured: `818` - // Estimated: `4283` + // Measured: `851` + // Estimated: `4316` // Minimum execution time: 29_000_000 picoseconds. - Weight::from_parts(31_000_000, 4283) + Weight::from_parts(31_000_000, 4316) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -774,10 +718,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `LinearRelease::Vesting` (`max_values`: None, `max_size`: None, mode: `Measured`) fn start_contribution_vesting_schedule_for() -> Weight { // Proof Size summary in bytes: - // Measured: `847` - // Estimated: `4312` + // Measured: `880` + // Estimated: `4345` // Minimum execution time: 30_000_000 picoseconds. - Weight::from_parts(32_000_000, 4312) + Weight::from_parts(31_000_000, 4345) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -793,10 +737,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) fn payout_bid_funds_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1372` + // Measured: `1405` // Estimated: `6208` - // Minimum execution time: 64_000_000 picoseconds. - Weight::from_parts(69_000_000, 6208) + // Minimum execution time: 67_000_000 picoseconds. + Weight::from_parts(68_000_000, 6208) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -812,34 +756,34 @@ impl WeightInfo for SubstrateWeight { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) fn payout_contribution_funds_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1401` + // Measured: `1434` // Estimated: `6208` - // Minimum execution time: 69_000_000 picoseconds. - Weight::from_parts(77_000_000, 6208) + // Minimum execution time: 66_000_000 picoseconds. + Weight::from_parts(69_000_000, 6208) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:2980 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. /// The range of component `y` is `[1, 10000]`. fn decide_project_outcome(x: u32, y: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `10254 + x * (419 ±0) + y * (20 ±0)` - // Estimated: `35057 + x * (4876 ±4_177) + y * (1437 ±41)` - // Minimum execution time: 64_000_000 picoseconds. - Weight::from_parts(68_000_000, 35057) - // Standard Error: 4_809_624 - .saturating_add(Weight::from_parts(5_610_465, 0).saturating_mul(x.into())) - // Standard Error: 47_674 - .saturating_add(Weight::from_parts(1_647_468, 0).saturating_mul(y.into())) + // Measured: `4454 + x * (93 ±0) + y * (11 ±0)` + // Estimated: `28512 + x * (3946 ±3_374) + y * (1161 ±33)` + // Minimum execution time: 58_000_000 picoseconds. + Weight::from_parts(59_000_000, 28512) + // Standard Error: 3_928_236 + .saturating_add(Weight::from_parts(3_329_337, 0).saturating_mul(x.into())) + // Standard Error: 38_938 + .saturating_add(Weight::from_parts(1_351_270, 0).saturating_mul(y.into())) .saturating_add(T::DbWeight::get().reads(12_u64)) .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().writes(1_u64)) - .saturating_add(Weight::from_parts(0, 4876).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 1437).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 3946).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 1161).saturating_mul(y.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) @@ -851,10 +795,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn release_bid_funds_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1481` + // Measured: `1514` // Estimated: `6208` - // Minimum execution time: 64_000_000 picoseconds. - Weight::from_parts(71_000_000, 6208) + // Minimum execution time: 65_000_000 picoseconds. + Weight::from_parts(70_000_000, 6208) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -868,10 +812,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn release_contribution_funds_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1474` + // Measured: `1507` // Estimated: `6208` - // Minimum execution time: 64_000_000 picoseconds. - Weight::from_parts(70_000_000, 6208) + // Minimum execution time: 63_000_000 picoseconds. + Weight::from_parts(69_000_000, 6208) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(4_u64)) } @@ -883,10 +827,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) fn bid_unbond_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1486` + // Measured: `1519` // Estimated: `4614` - // Minimum execution time: 52_000_000 picoseconds. - Weight::from_parts(57_000_000, 4614) + // Minimum execution time: 54_000_000 picoseconds. + Weight::from_parts(56_000_000, 4614) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -898,9 +842,9 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) fn contribution_unbond_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1441` + // Measured: `1474` // Estimated: `4614` - // Minimum execution time: 52_000_000 picoseconds. + // Minimum execution time: 54_000_000 picoseconds. Weight::from_parts(57_000_000, 4614) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -912,21 +856,20 @@ impl WeightInfo for SubstrateWeight { /// Storage: `PolimecFunding::Evaluations` (r:4 w:0) /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:99 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. fn end_evaluation_success(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `680 + x * (529 ±0)` - // Estimated: `12270 + x * (3097 ±0)` - // Minimum execution time: 526_000_000 picoseconds. - Weight::from_parts(542_694_602, 0) - .saturating_add(Weight::from_parts(0, 12270)) - // Standard Error: 319_361 - .saturating_add(Weight::from_parts(37_635_189, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(6)) + // Measured: `1174 + x * (29 ±0)` + // Estimated: `12270 + x * (2502 ±0)` + // Minimum execution time: 38_000_000 picoseconds. + Weight::from_parts(36_057_447, 12270) + // Standard Error: 5_687 + .saturating_add(Weight::from_parts(2_349_611, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) @@ -938,33 +881,47 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `1148` // Estimated: `12270` - // Minimum execution time: 478_000_000 picoseconds. - Weight::from_parts(553_000_000, 0) - .saturating_add(Weight::from_parts(0, 12270)) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(1)) + // Minimum execution time: 33_000_000 picoseconds. + Weight::from_parts(35_000_000, 12270) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:102 w:2) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_auction_automatically(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `413 + x * (29 ±0)` + // Estimated: `8496 + x * (2502 ±0)` + // Minimum execution time: 26_000_000 picoseconds. + Weight::from_parts(28_124_881, 8496) + // Standard Error: 5_442 + .saturating_add(Weight::from_parts(2_521_942, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. fn start_candle_phase(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `445 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 241_000_000 picoseconds. - Weight::from_parts(229_863_239, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 186_038 - .saturating_add(Weight::from_parts(36_067_945, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(2)) + // Measured: `446 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 17_000_000 picoseconds. + Weight::from_parts(17_987_956, 3814) + // Standard Error: 5_995 + .saturating_add(Weight::from_parts(2_286_160, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) @@ -988,33 +945,31 @@ impl WeightInfo for SubstrateWeight { /// Storage: `PolimecFunding::Buckets` (r:1 w:0) /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. /// The range of component `y` is `[1, 1024]`. /// The range of component `z` is `[0, 1024]`. fn start_community_funding_success(x: u32, y: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `91678 + x * (529 ±0) + y * (167 ±0) + z * (364 ±0)` - // Estimated: `4087 + x * (3097 ±0) + y * (2893 ±0) + z * (3624 ±0)` - // Minimum execution time: 139_251_000_000 picoseconds. - Weight::from_parts(6_810_381_680, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 2_917_537 - .saturating_add(Weight::from_parts(143_813_813, 0).saturating_mul(y.into())) - // Standard Error: 2_914_495 - .saturating_add(Weight::from_parts(1_093_099_600, 0).saturating_mul(z.into())) - .saturating_add(T::DbWeight::get().reads(10)) + // Measured: `86802 + x * (29 ±0) + y * (167 ±0) + z * (367 ±0)` + // Estimated: `4079 + x * (2502 ±0) + y * (2893 ±0) + z * (3624 ±0)` + // Minimum execution time: 8_733_000_000 picoseconds. + Weight::from_parts(8_889_000_000, 4079) + // Standard Error: 235_341 + .saturating_add(Weight::from_parts(6_457_226, 0).saturating_mul(y.into())) + // Standard Error: 235_237 + .saturating_add(Weight::from_parts(70_277_060, 0).saturating_mul(z.into())) + .saturating_add(T::DbWeight::get().reads(10_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into()))) .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(z.into()))) - .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(T::DbWeight::get().writes(5_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(y.into()))) .saturating_add(T::DbWeight::get().writes((4_u64).saturating_mul(z.into()))) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) .saturating_add(Weight::from_parts(0, 2893).saturating_mul(y.into())) .saturating_add(Weight::from_parts(0, 3624).saturating_mul(z.into())) } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) @@ -1030,195 +985,182 @@ impl WeightInfo for SubstrateWeight { /// Storage: `PolimecFunding::Buckets` (r:1 w:0) /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. fn start_community_funding_failure(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2654 + x * (4 ±0)` - // Estimated: `4087` - // Minimum execution time: 1_453_000_000 picoseconds. - Weight::from_parts(1_487_504_532, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 177_339 - .saturating_add(Weight::from_parts(731_091, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(8)) - .saturating_add(T::DbWeight::get().writes(3)) + // Measured: `1418 + x * (3 ±0)` + // Estimated: `4079` + // Minimum execution time: 87_000_000 picoseconds. + Weight::from_parts(97_589_188, 4079) + // Standard Error: 3_828 + .saturating_add(Weight::from_parts(26_576, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(8_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. fn start_remainder_funding(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `510 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 242_000_000 picoseconds. - Weight::from_parts(227_535_753, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 174_777 - .saturating_add(Weight::from_parts(37_767_357, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(2)) + // Measured: `536 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(18_694_146, 3814) + // Standard Error: 5_669 + .saturating_add(Weight::from_parts(2_256_677, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) - } - - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Asset` (r:1 w:1) - /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Metadata` (r:1 w:0) - /// Proof: `LocalAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - fn start_settlement_funding_success() -> Weight { - // Proof Size summary in bytes: - // Measured: `933` - // Estimated: `3814` - // Minimum execution time: 447_000_000 picoseconds. - Weight::from_parts(457_000_000, 0) - .saturating_add(Weight::from_parts(0, 3814)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(3)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - fn start_settlement_funding_failure() -> Weight { - // Proof Size summary in bytes: - // Measured: `760` - // Estimated: `3814` - // Minimum execution time: 130_000_000 picoseconds. - Weight::from_parts(136_000_000, 0) - .saturating_add(Weight::from_parts(0, 3814)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - fn project_decision_accept_funding() -> Weight { - // Proof Size summary in bytes: - // Measured: `535` - // Estimated: `4087` - // Minimum execution time: 200_000_000 picoseconds. - Weight::from_parts(207_000_000, 0) - .saturating_add(Weight::from_parts(0, 4087)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - fn project_decision_reject_funding() -> Weight { - // Proof Size summary in bytes: - // Measured: `535` - // Estimated: `4087` - // Minimum execution time: 200_000_000 picoseconds. - Weight::from_parts(203_000_000, 0) - .saturating_add(Weight::from_parts(0, 4087)) - .saturating_add(T::DbWeight::get().reads(2)) - .saturating_add(T::DbWeight::get().writes(2)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. fn end_funding_automatically_rejected_evaluators_slashed(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `822 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 296_000_000 picoseconds. - Weight::from_parts(284_006_640, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 85_755 - .saturating_add(Weight::from_parts(36_442_516, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(3)) + // Measured: `824 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 24_000_000 picoseconds. + Weight::from_parts(23_753_565, 3814) + // Standard Error: 4_976 + .saturating_add(Weight::from_parts(2_285_728, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. fn end_funding_awaiting_decision_evaluators_slashed(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `822 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 233_000_000 picoseconds. - Weight::from_parts(213_045_370, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 117_943 - .saturating_add(Weight::from_parts(36_217_046, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(3)) + // Measured: `823 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_149_882, 3814) + // Standard Error: 4_893 + .saturating_add(Weight::from_parts(2_241_882, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. fn end_funding_awaiting_decision_evaluators_unchanged(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `822 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 236_000_000 picoseconds. - Weight::from_parts(245_084_435, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 136_756 - .saturating_add(Weight::from_parts(35_663_280, 0).saturating_mul(x.into())) - .saturating_add(T::DbWeight::get().reads(3)) + // Measured: `823 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(18_735_663, 3814) + // Standard Error: 5_515 + .saturating_add(Weight::from_parts(2_252_806, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(T::DbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:2049 w:0) + /// Storage: `PolimecFunding::Evaluations` (r:2048 w:0) /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. /// The range of component `y` is `[1, 2048]`. fn end_funding_automatically_accepted_evaluators_rewarded(x: u32, y: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1199 + x * (529 ±0) + y * (187 ±0)` - // Estimated: `4087 + x * (3097 ±0) + y * (2820 ±0)` - // Minimum execution time: 4_119_000_000 picoseconds. - Weight::from_parts(4_122_000_000, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 13_179_751 - .saturating_add(Weight::from_parts(37_293_090, 0).saturating_mul(x.into())) - // Standard Error: 636_741 - .saturating_add(Weight::from_parts(74_778_225, 0).saturating_mul(y.into())) - .saturating_add(T::DbWeight::get().reads(4)) + // Measured: `1184 + x * (29 ±0) + y * (187 ±0)` + // Estimated: `3814 + x * (2502 ±0) + y * (2820 ±0)` + // Minimum execution time: 257_000_000 picoseconds. + Weight::from_parts(260_000_000, 3814) + // Standard Error: 52_986 + .saturating_add(Weight::from_parts(476_614, 0).saturating_mul(x.into())) + // Standard Error: 2_564 + .saturating_add(Weight::from_parts(4_091_225, 0).saturating_mul(y.into())) + .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(y.into()))) - .saturating_add(T::DbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) .saturating_add(Weight::from_parts(0, 2820).saturating_mul(y.into())) } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:2 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + fn project_decision_accept_funding() -> Weight { + // Proof Size summary in bytes: + // Measured: `563` + // Estimated: `5994` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_000_000, 5994) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:2 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + fn project_decision_reject_funding() -> Weight { + // Proof Size summary in bytes: + // Measured: `563` + // Estimated: `5994` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_000_000, 5994) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Metadata` (r:1 w:1) + /// Proof: `LocalAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn start_settlement_funding_success() -> Weight { + // Proof Size summary in bytes: + // Measured: `970` + // Estimated: `3814` + // Minimum execution time: 41_000_000 picoseconds. + Weight::from_parts(43_000_000, 3814) + .saturating_add(T::DbWeight::get().reads(5_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + fn start_settlement_funding_failure() -> Weight { + // Proof Size summary in bytes: + // Measured: `760` + // Estimated: `3814` + // Minimum execution time: 11_000_000 picoseconds. + Weight::from_parts(12_000_000, 3814) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } } // For backwards compatibility and tests. @@ -1239,8 +1181,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `161` // Estimated: `3593` - // Minimum execution time: 60_000_000 picoseconds. - Weight::from_parts(62_000_000, 3593) + // Minimum execution time: 92_000_000 picoseconds. + Weight::from_parts(94_000_000, 3593) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(6_u64)) } @@ -1264,60 +1206,42 @@ impl WeightInfo for () { /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. fn start_evaluation(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `563 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 22_000_000 picoseconds. - Weight::from_parts(19_253_978, 4087) - // Standard Error: 15_066 - .saturating_add(Weight::from_parts(2_633_080, 0).saturating_mul(x.into())) + // Measured: `562 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 23_000_000 picoseconds. + Weight::from_parts(21_490_523, 3814) + // Standard Error: 5_416 + .saturating_add(Weight::from_parts(2_287_829, 0).saturating_mul(x.into())) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:4558 w:2) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. /// The range of component `y` is `[1, 10000]`. fn start_auction_manually(x: u32, y: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + x * (1281 ±0) + y * (21 ±0)` - // Estimated: `268395 + x * (9966 ±8_383) + y * (1212 ±82)` - // Minimum execution time: 397_000_000 picoseconds. - Weight::from_parts(420_000_000, 268395) - // Standard Error: 4_704_303 - .saturating_add(Weight::from_parts(12_350_427, 0).saturating_mul(x.into())) - // Standard Error: 46_630 - .saturating_add(Weight::from_parts(1_402_043, 0).saturating_mul(y.into())) + // Measured: `0 + x * (539 ±0) + y * (13 ±0)` + // Estimated: `217021 + x * (8051 ±6_772) + y * (979 ±66)` + // Minimum execution time: 321_000_000 picoseconds. + Weight::from_parts(325_000_000, 217021) + // Standard Error: 3_856_088 + .saturating_add(Weight::from_parts(10_425_661, 0).saturating_mul(x.into())) + // Standard Error: 38_223 + .saturating_add(Weight::from_parts(1_158_523, 0).saturating_mul(y.into())) .saturating_add(RocksDbWeight::get().reads(87_u64)) .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(x.into()))) .saturating_add(RocksDbWeight::get().writes(3_u64)) - .saturating_add(Weight::from_parts(0, 9966).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 1212).saturating_mul(y.into())) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 99]`. - fn start_auction_automatically(x: u32, ) -> Weight { - // Proof Size summary in bytes: - // Measured: `411 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 20_000_000 picoseconds. - Weight::from_parts(20_242_112, 4087) - // Standard Error: 18_140 - .saturating_add(Weight::from_parts(2_666_357, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(2_u64)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 8051).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 979).saturating_mul(y.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) @@ -1327,59 +1251,65 @@ impl WeightInfo for () { /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) /// Storage: `Oracle::Values` (r:1 w:0) /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::EvaluationCounts` (r:1 w:1) + /// Proof: `PolimecFunding::EvaluationCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) /// Storage: `Balances::Holds` (r:1 w:1) /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) fn first_evaluation() -> Weight { // Proof Size summary in bytes: - // Measured: `676` + // Measured: `745` // Estimated: `4614` - // Minimum execution time: 92_000_000 picoseconds. - Weight::from_parts(94_000_000, 4614) - .saturating_add(RocksDbWeight::get().reads(5_u64)) - .saturating_add(RocksDbWeight::get().writes(4_u64)) + // Minimum execution time: 90_000_000 picoseconds. + Weight::from_parts(97_000_000, 4614) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:256 w:1) + /// Storage: `PolimecFunding::Evaluations` (r:16 w:1) /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) /// Storage: `Oracle::Values` (r:1 w:0) /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::EvaluationCounts` (r:1 w:1) + /// Proof: `PolimecFunding::EvaluationCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) /// Storage: `Balances::Holds` (r:1 w:1) /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) - /// The range of component `x` is `[1, 255]`. + /// The range of component `x` is `[1, 15]`. fn second_to_limit_evaluation(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `893 + x * (137 ±0)` + // Measured: `941 + x * (137 ±0)` // Estimated: `4614 + x * (2820 ±0)` - // Minimum execution time: 71_000_000 picoseconds. - Weight::from_parts(58_910_334, 4614) - // Standard Error: 11_575 - .saturating_add(Weight::from_parts(3_780_894, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(5_u64)) + // Minimum execution time: 70_000_000 picoseconds. + Weight::from_parts(73_938_801, 4614) + // Standard Error: 20_740 + .saturating_add(Weight::from_parts(3_615_461, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(4_u64)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) .saturating_add(Weight::from_parts(0, 2820).saturating_mul(x.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::NextEvaluationId` (r:1 w:1) /// Proof: `PolimecFunding::NextEvaluationId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:257 w:2) + /// Storage: `PolimecFunding::Evaluations` (r:17 w:2) /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) /// Storage: `Oracle::Values` (r:1 w:0) /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::EvaluationCounts` (r:1 w:1) + /// Proof: `PolimecFunding::EvaluationCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) /// Storage: `Balances::Holds` (r:1 w:1) /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) fn evaluation_over_limit() -> Weight { // Proof Size summary in bytes: - // Measured: `36120` - // Estimated: `725730` - // Minimum execution time: 1_017_000_000 picoseconds. - Weight::from_parts(1_051_000_000, 725730) - .saturating_add(RocksDbWeight::get().reads(261_u64)) - .saturating_add(RocksDbWeight::get().writes(5_u64)) + // Measured: `3148` + // Estimated: `48930` + // Minimum execution time: 152_000_000 picoseconds. + Weight::from_parts(158_000_000, 48930) + .saturating_add(RocksDbWeight::get().reads(22_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) @@ -1387,8 +1317,10 @@ impl WeightInfo for () { /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) /// Storage: `Oracle::Values` (r:2 w:0) /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:1 w:10) + /// Storage: `PolimecFunding::Bids` (r:128 w:10) /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::BidCounts` (r:1 w:1) + /// Proof: `PolimecFunding::BidCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) /// Storage: `Balances::Holds` (r:1 w:1) /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::Buckets` (r:1 w:1) @@ -1401,20 +1333,23 @@ impl WeightInfo for () { /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) /// Storage: `StatemintAssets::Account` (r:2 w:2) /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// The range of component `x` is `[0, 127]`. /// The range of component `y` is `[0, 10]`. - fn bid_with_ct_deposit(y: u32, ) -> Weight { + fn bid_no_ct_deposit(x: u32, y: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2140` - // Estimated: `6208` - // Minimum execution time: 143_000_000 picoseconds. - Weight::from_parts(106_855_955, 6208) - // Standard Error: 319_819 - .saturating_add(Weight::from_parts(70_108_416, 0).saturating_mul(y.into())) - .saturating_add(RocksDbWeight::get().reads(12_u64)) + // Measured: `2278 + x * (164 ±0)` + // Estimated: `6208 + x * (2893 ±0)` + // Minimum execution time: 539_000_000 picoseconds. + Weight::from_parts(84_439_405, 6208) + // Standard Error: 20_670 + .saturating_add(Weight::from_parts(3_779_627, 0).saturating_mul(x.into())) + // Standard Error: 250_512 + .saturating_add(Weight::from_parts(73_255_675, 0).saturating_mul(y.into())) + .saturating_add(RocksDbWeight::get().reads(13_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(RocksDbWeight::get().writes(7_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(y.into()))) + .saturating_add(Weight::from_parts(0, 2893).saturating_mul(x.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) @@ -1422,8 +1357,10 @@ impl WeightInfo for () { /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) /// Storage: `Oracle::Values` (r:2 w:0) /// Proof: `Oracle::Values` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Bids` (r:256 w:10) + /// Storage: `PolimecFunding::Bids` (r:1 w:10) /// Proof: `PolimecFunding::Bids` (`max_values`: None, `max_size`: Some(418), added: 2893, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::BidCounts` (r:1 w:1) + /// Proof: `PolimecFunding::BidCounts` (`max_values`: None, `max_size`: Some(24), added: 2499, mode: `MaxEncodedLen`) /// Storage: `Balances::Holds` (r:1 w:1) /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::Buckets` (r:1 w:1) @@ -1436,23 +1373,20 @@ impl WeightInfo for () { /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) /// Storage: `StatemintAssets::Account` (r:2 w:2) /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// The range of component `x` is `[0, 255]`. + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// The range of component `y` is `[0, 10]`. - fn bid_no_ct_deposit(x: u32, y: u32, ) -> Weight { + fn bid_with_ct_deposit(y: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2227 + x * (164 ±0)` - // Estimated: `6208 + x * (2893 ±0)` - // Minimum execution time: 760_000_000 picoseconds. - Weight::from_parts(69_652_890, 6208) - // Standard Error: 11_684 - .saturating_add(Weight::from_parts(4_020_612, 0).saturating_mul(x.into())) - // Standard Error: 283_589 - .saturating_add(Weight::from_parts(72_460_034, 0).saturating_mul(y.into())) - .saturating_add(RocksDbWeight::get().reads(12_u64)) - .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(6_u64)) + // Measured: `2184` + // Estimated: `6208` + // Minimum execution time: 143_000_000 picoseconds. + Weight::from_parts(110_639_424, 6208) + // Standard Error: 314_196 + .saturating_add(Weight::from_parts(70_855_879, 0).saturating_mul(y.into())) + .saturating_add(RocksDbWeight::get().reads(13_u64)) + .saturating_add(RocksDbWeight::get().writes(8_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(y.into()))) - .saturating_add(Weight::from_parts(0, 2893).saturating_mul(x.into())) } /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) @@ -1474,10 +1408,10 @@ impl WeightInfo for () { /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn first_contribution_with_ct_deposit() -> Weight { // Proof Size summary in bytes: - // Measured: `1996` + // Measured: `2029` // Estimated: `6208` - // Minimum execution time: 147_000_000 picoseconds. - Weight::from_parts(155_000_000, 6208) + // Minimum execution time: 146_000_000 picoseconds. + Weight::from_parts(151_000_000, 6208) .saturating_add(RocksDbWeight::get().reads(11_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -1501,10 +1435,10 @@ impl WeightInfo for () { /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn first_contribution_no_ct_deposit() -> Weight { // Proof Size summary in bytes: - // Measured: `2073` + // Measured: `2106` // Estimated: `6208` - // Minimum execution time: 119_000_000 picoseconds. - Weight::from_parts(126_000_000, 6208) + // Minimum execution time: 118_000_000 picoseconds. + Weight::from_parts(120_000_000, 6208) .saturating_add(RocksDbWeight::get().reads(11_u64)) .saturating_add(RocksDbWeight::get().writes(7_u64)) } @@ -1526,25 +1460,25 @@ impl WeightInfo for () { /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) /// Storage: `StatemintAssets::Account` (r:2 w:2) /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9832 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9833 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `y` is `[1, 99]`. /// The range of component `z` is `[1, 10000]`. fn first_contribution_ends_round_with_ct_deposit(y: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + y * (443 ±0) + z * (37 ±0)` - // Estimated: `78415 + y * (14240 ±4_378) + z * (1371 ±43)` - // Minimum execution time: 264_000_000 picoseconds. - Weight::from_parts(268_000_000, 78415) - // Standard Error: 5_143_014 - .saturating_add(Weight::from_parts(16_318_492, 0).saturating_mul(y.into())) - // Standard Error: 50_979 - .saturating_add(Weight::from_parts(1_601_983, 0).saturating_mul(z.into())) - .saturating_add(RocksDbWeight::get().reads(36_u64)) + // Measured: `0 + y * (140 ±0) + z * (20 ±0)` + // Estimated: `66042 + y * (11508 ±3_537) + z * (1108 ±35)` + // Minimum execution time: 232_000_000 picoseconds. + Weight::from_parts(246_000_000, 66042) + // Standard Error: 4_200_086 + .saturating_add(Weight::from_parts(12_470_526, 0).saturating_mul(y.into())) + // Standard Error: 41_632 + .saturating_add(Weight::from_parts(1_318_329, 0).saturating_mul(z.into())) + .saturating_add(RocksDbWeight::get().reads(37_u64)) .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(y.into()))) .saturating_add(RocksDbWeight::get().writes(8_u64)) - .saturating_add(Weight::from_parts(0, 14240).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 1371).saturating_mul(z.into())) + .saturating_add(Weight::from_parts(0, 11508).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 1108).saturating_mul(z.into())) } /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) @@ -1564,25 +1498,25 @@ impl WeightInfo for () { /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) /// Storage: `StatemintAssets::Account` (r:2 w:2) /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9832 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9833 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `y` is `[1, 99]`. /// The range of component `z` is `[1, 10000]`. fn first_contribution_ends_round_no_ct_deposit(y: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `0 + y * (443 ±0) + z * (37 ±0)` - // Estimated: `78415 + y * (14240 ±4_378) + z * (1371 ±43)` - // Minimum execution time: 226_000_000 picoseconds. - Weight::from_parts(239_000_000, 78415) - // Standard Error: 5_135_841 - .saturating_add(Weight::from_parts(15_722_813, 0).saturating_mul(y.into())) - // Standard Error: 50_908 - .saturating_add(Weight::from_parts(1_606_667, 0).saturating_mul(z.into())) - .saturating_add(RocksDbWeight::get().reads(36_u64)) + // Measured: `0 + y * (140 ±0) + z * (20 ±0)` + // Estimated: `66042 + y * (11508 ±3_537) + z * (1108 ±35)` + // Minimum execution time: 212_000_000 picoseconds. + Weight::from_parts(223_000_000, 66042) + // Standard Error: 4_200_933 + .saturating_add(Weight::from_parts(12_638_804, 0).saturating_mul(y.into())) + // Standard Error: 41_641 + .saturating_add(Weight::from_parts(1_313_036, 0).saturating_mul(z.into())) + .saturating_add(RocksDbWeight::get().reads(37_u64)) .saturating_add(RocksDbWeight::get().reads((5_u64).saturating_mul(y.into()))) .saturating_add(RocksDbWeight::get().writes(8_u64)) - .saturating_add(Weight::from_parts(0, 14240).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 1371).saturating_mul(z.into())) + .saturating_add(Weight::from_parts(0, 11508).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 1108).saturating_mul(z.into())) } /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) @@ -1605,12 +1539,12 @@ impl WeightInfo for () { /// The range of component `x` is `[1, 255]`. fn second_to_limit_contribution(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2213 + x * (137 ±0)` + // Measured: `2246 + x * (137 ±0)` // Estimated: `6208 + x * (2839 ±0)` // Minimum execution time: 124_000_000 picoseconds. - Weight::from_parts(117_868_102, 6208) - // Standard Error: 10_026 - .saturating_add(Weight::from_parts(3_746_658, 0).saturating_mul(x.into())) + Weight::from_parts(128_568_935, 6208) + // Standard Error: 11_772 + .saturating_add(Weight::from_parts(3_704_148, 0).saturating_mul(x.into())) .saturating_add(RocksDbWeight::get().reads(11_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(RocksDbWeight::get().writes(7_u64)) @@ -1634,28 +1568,28 @@ impl WeightInfo for () { /// Proof: `StatemintAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) /// Storage: `StatemintAssets::Account` (r:2 w:2) /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9832 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:9833 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 255]`. /// The range of component `y` is `[1, 99]`. /// The range of component `z` is `[1, 10000]`. fn second_to_limit_contribution_ends_round(x: u32, y: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `75282 + x * (137 ±0) + y * (723 ±0) + z * (39 ±0)` - // Estimated: `17232 + x * (2839 ±0) + y * (115061 ±7_565) + z * (2358 ±74)` - // Minimum execution time: 1_097_000_000 picoseconds. - Weight::from_parts(554_228_738, 17232) - // Standard Error: 8_861_727 - .saturating_add(Weight::from_parts(133_771_367, 0).saturating_mul(y.into())) - // Standard Error: 86_849 - .saturating_add(Weight::from_parts(2_763_795, 0).saturating_mul(z.into())) - .saturating_add(RocksDbWeight::get().reads(16_u64)) + // Measured: `44564 + x * (137 ±0) + y * (254 ±0) + z * (21 ±0)` + // Estimated: `15401 + x * (2839 ±0) + y * (92965 ±6_111) + z * (1905 ±59)` + // Minimum execution time: 1_120_000_000 picoseconds. + Weight::from_parts(55_806_166, 15401) + // Standard Error: 7_331_488 + .saturating_add(Weight::from_parts(111_668_126, 0).saturating_mul(y.into())) + // Standard Error: 71_852 + .saturating_add(Weight::from_parts(2_292_683, 0).saturating_mul(z.into())) + .saturating_add(RocksDbWeight::get().reads(17_u64)) .saturating_add(RocksDbWeight::get().reads((37_u64).saturating_mul(y.into()))) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(z.into()))) .saturating_add(RocksDbWeight::get().writes(8_u64)) .saturating_add(Weight::from_parts(0, 2839).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 115061).saturating_mul(y.into())) - .saturating_add(Weight::from_parts(0, 2358).saturating_mul(z.into())) + .saturating_add(Weight::from_parts(0, 92965).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 1905).saturating_mul(z.into())) } /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) @@ -1677,10 +1611,10 @@ impl WeightInfo for () { /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) fn contribution_over_limit() -> Weight { // Proof Size summary in bytes: - // Measured: `37440` + // Measured: `37473` // Estimated: `730613` - // Minimum execution time: 1_103_000_000 picoseconds. - Weight::from_parts(1_165_000_000, 730613) + // Minimum execution time: 1_082_000_000 picoseconds. + Weight::from_parts(1_150_000_000, 730613) .saturating_add(RocksDbWeight::get().reads(267_u64)) .saturating_add(RocksDbWeight::get().writes(8_u64)) } @@ -1692,10 +1626,10 @@ impl WeightInfo for () { /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) fn evaluation_unbond_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1411` + // Measured: `1477` // Estimated: `4614` - // Minimum execution time: 55_000_000 picoseconds. - Weight::from_parts(60_000_000, 4614) + // Minimum execution time: 54_000_000 picoseconds. + Weight::from_parts(57_000_000, 4614) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1711,10 +1645,10 @@ impl WeightInfo for () { /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) fn evaluation_reward_payout_for_with_ct_account_creation() -> Weight { // Proof Size summary in bytes: - // Measured: `1515` + // Measured: `1654` // Estimated: `4614` - // Minimum execution time: 92_000_000 picoseconds. - Weight::from_parts(102_000_000, 4614) + // Minimum execution time: 94_000_000 picoseconds. + Weight::from_parts(98_000_000, 4614) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -1728,10 +1662,10 @@ impl WeightInfo for () { /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) fn evaluation_reward_payout_for_no_ct_account_creation() -> Weight { // Proof Size summary in bytes: - // Measured: `1219` + // Measured: `1322` // Estimated: `3814` // Minimum execution time: 48_000_000 picoseconds. - Weight::from_parts(49_000_000, 3814) + Weight::from_parts(50_000_000, 3814) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -1745,10 +1679,10 @@ impl WeightInfo for () { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) fn evaluation_slash_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1419` + // Measured: `1485` // Estimated: `4614` - // Minimum execution time: 68_000_000 picoseconds. - Weight::from_parts(71_000_000, 4614) + // Minimum execution time: 67_000_000 picoseconds. + Weight::from_parts(69_000_000, 4614) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -1764,10 +1698,10 @@ impl WeightInfo for () { /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) fn bid_ct_mint_for_with_ct_account_creation() -> Weight { // Proof Size summary in bytes: - // Measured: `1629` + // Measured: `1735` // Estimated: `4614` - // Minimum execution time: 96_000_000 picoseconds. - Weight::from_parts(99_000_000, 4614) + // Minimum execution time: 99_000_000 picoseconds. + Weight::from_parts(103_000_000, 4614) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -1781,10 +1715,10 @@ impl WeightInfo for () { /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn bid_ct_mint_for_no_ct_account_creation() -> Weight { // Proof Size summary in bytes: - // Measured: `1180` + // Measured: `1250` // Estimated: `3883` - // Minimum execution time: 44_000_000 picoseconds. - Weight::from_parts(47_000_000, 3883) + // Minimum execution time: 46_000_000 picoseconds. + Weight::from_parts(50_000_000, 3883) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -1800,10 +1734,10 @@ impl WeightInfo for () { /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) fn contribution_ct_mint_for_with_ct_account_creation() -> Weight { // Proof Size summary in bytes: - // Measured: `1545` + // Measured: `1651` // Estimated: `4614` - // Minimum execution time: 91_000_000 picoseconds. - Weight::from_parts(98_000_000, 4614) + // Minimum execution time: 94_000_000 picoseconds. + Weight::from_parts(100_000_000, 4614) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -1817,9 +1751,9 @@ impl WeightInfo for () { /// Proof: `LocalAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn contribution_ct_mint_for_no_ct_account_creation() -> Weight { // Proof Size summary in bytes: - // Measured: `1217` + // Measured: `1287` // Estimated: `3829` - // Minimum execution time: 46_000_000 picoseconds. + // Minimum execution time: 47_000_000 picoseconds. Weight::from_parts(50_000_000, 3829) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) @@ -1832,10 +1766,10 @@ impl WeightInfo for () { /// Proof: `LinearRelease::Vesting` (`max_values`: None, `max_size`: None, mode: `Measured`) fn start_bid_vesting_schedule_for() -> Weight { // Proof Size summary in bytes: - // Measured: `818` - // Estimated: `4283` + // Measured: `851` + // Estimated: `4316` // Minimum execution time: 29_000_000 picoseconds. - Weight::from_parts(31_000_000, 4283) + Weight::from_parts(31_000_000, 4316) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1847,10 +1781,10 @@ impl WeightInfo for () { /// Proof: `LinearRelease::Vesting` (`max_values`: None, `max_size`: None, mode: `Measured`) fn start_contribution_vesting_schedule_for() -> Weight { // Proof Size summary in bytes: - // Measured: `847` - // Estimated: `4312` + // Measured: `880` + // Estimated: `4345` // Minimum execution time: 30_000_000 picoseconds. - Weight::from_parts(32_000_000, 4312) + Weight::from_parts(31_000_000, 4345) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1866,10 +1800,10 @@ impl WeightInfo for () { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) fn payout_bid_funds_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1372` + // Measured: `1405` // Estimated: `6208` - // Minimum execution time: 64_000_000 picoseconds. - Weight::from_parts(69_000_000, 6208) + // Minimum execution time: 67_000_000 picoseconds. + Weight::from_parts(68_000_000, 6208) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -1885,34 +1819,34 @@ impl WeightInfo for () { /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) fn payout_contribution_funds_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1401` + // Measured: `1434` // Estimated: `6208` - // Minimum execution time: 69_000_000 picoseconds. - Weight::from_parts(77_000_000, 6208) + // Minimum execution time: 66_000_000 picoseconds. + Weight::from_parts(69_000_000, 6208) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:2980 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. /// The range of component `y` is `[1, 10000]`. fn decide_project_outcome(x: u32, y: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `10254 + x * (419 ±0) + y * (20 ±0)` - // Estimated: `35057 + x * (4876 ±4_177) + y * (1437 ±41)` - // Minimum execution time: 64_000_000 picoseconds. - Weight::from_parts(68_000_000, 35057) - // Standard Error: 4_809_624 - .saturating_add(Weight::from_parts(5_610_465, 0).saturating_mul(x.into())) - // Standard Error: 47_674 - .saturating_add(Weight::from_parts(1_647_468, 0).saturating_mul(y.into())) + // Measured: `4454 + x * (93 ±0) + y * (11 ±0)` + // Estimated: `28512 + x * (3946 ±3_374) + y * (1161 ±33)` + // Minimum execution time: 58_000_000 picoseconds. + Weight::from_parts(59_000_000, 28512) + // Standard Error: 3_928_236 + .saturating_add(Weight::from_parts(3_329_337, 0).saturating_mul(x.into())) + // Standard Error: 38_938 + .saturating_add(Weight::from_parts(1_351_270, 0).saturating_mul(y.into())) .saturating_add(RocksDbWeight::get().reads(12_u64)) .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(x.into()))) .saturating_add(RocksDbWeight::get().writes(1_u64)) - .saturating_add(Weight::from_parts(0, 4876).saturating_mul(x.into())) - .saturating_add(Weight::from_parts(0, 1437).saturating_mul(y.into())) + .saturating_add(Weight::from_parts(0, 3946).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 1161).saturating_mul(y.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) @@ -1924,10 +1858,10 @@ impl WeightInfo for () { /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn release_bid_funds_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1481` + // Measured: `1514` // Estimated: `6208` - // Minimum execution time: 64_000_000 picoseconds. - Weight::from_parts(71_000_000, 6208) + // Minimum execution time: 65_000_000 picoseconds. + Weight::from_parts(70_000_000, 6208) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -1941,10 +1875,10 @@ impl WeightInfo for () { /// Proof: `StatemintAssets::Account` (`max_values`: None, `max_size`: Some(134), added: 2609, mode: `MaxEncodedLen`) fn release_contribution_funds_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1474` + // Measured: `1507` // Estimated: `6208` - // Minimum execution time: 64_000_000 picoseconds. - Weight::from_parts(70_000_000, 6208) + // Minimum execution time: 63_000_000 picoseconds. + Weight::from_parts(69_000_000, 6208) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(4_u64)) } @@ -1956,10 +1890,10 @@ impl WeightInfo for () { /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) fn bid_unbond_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1486` + // Measured: `1519` // Estimated: `4614` - // Minimum execution time: 52_000_000 picoseconds. - Weight::from_parts(57_000_000, 4614) + // Minimum execution time: 54_000_000 picoseconds. + Weight::from_parts(56_000_000, 4614) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1971,17 +1905,13 @@ impl WeightInfo for () { /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(1149), added: 3624, mode: `MaxEncodedLen`) fn contribution_unbond_for() -> Weight { // Proof Size summary in bytes: - // Measured: `1441` + // Measured: `1474` // Estimated: `4614` - // Minimum execution time: 52_000_000 picoseconds. + // Minimum execution time: 54_000_000 picoseconds. Weight::from_parts(57_000_000, 4614) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } - - - - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `Oracle::Values` (r:1 w:0) @@ -1989,21 +1919,20 @@ impl WeightInfo for () { /// Storage: `PolimecFunding::Evaluations` (r:4 w:0) /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:99 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. fn end_evaluation_success(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `680 + x * (529 ±0)` - // Estimated: `12270 + x * (3097 ±0)` - // Minimum execution time: 526_000_000 picoseconds. - Weight::from_parts(542_694_602, 0) - .saturating_add(Weight::from_parts(0, 12270)) - // Standard Error: 319_361 - .saturating_add(Weight::from_parts(37_635_189, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(6)) + // Measured: `1174 + x * (29 ±0)` + // Estimated: `12270 + x * (2502 ±0)` + // Minimum execution time: 38_000_000 picoseconds. + Weight::from_parts(36_057_447, 12270) + // Standard Error: 5_687 + .saturating_add(Weight::from_parts(2_349_611, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) @@ -2015,33 +1944,47 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `1148` // Estimated: `12270` - // Minimum execution time: 478_000_000 picoseconds. - Weight::from_parts(553_000_000, 0) - .saturating_add(Weight::from_parts(0, 12270)) - .saturating_add(RocksDbWeight::get().reads(6)) - .saturating_add(RocksDbWeight::get().writes(1)) + // Minimum execution time: 33_000_000 picoseconds. + Weight::from_parts(35_000_000, 12270) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:102 w:2) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 99]`. + fn start_auction_automatically(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `413 + x * (29 ±0)` + // Estimated: `8496 + x * (2502 ±0)` + // Minimum execution time: 26_000_000 picoseconds. + Weight::from_parts(28_124_881, 8496) + // Standard Error: 5_442 + .saturating_add(Weight::from_parts(2_521_942, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. fn start_candle_phase(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `445 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 241_000_000 picoseconds. - Weight::from_parts(229_863_239, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 186_038 - .saturating_add(Weight::from_parts(36_067_945, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(2)) + // Measured: `446 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 17_000_000 picoseconds. + Weight::from_parts(17_987_956, 3814) + // Standard Error: 5_995 + .saturating_add(Weight::from_parts(2_286_160, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) @@ -2065,33 +2008,31 @@ impl WeightInfo for () { /// Storage: `PolimecFunding::Buckets` (r:1 w:0) /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. /// The range of component `y` is `[1, 1024]`. /// The range of component `z` is `[0, 1024]`. fn start_community_funding_success(x: u32, y: u32, z: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `91678 + x * (529 ±0) + y * (167 ±0) + z * (364 ±0)` - // Estimated: `4087 + x * (3097 ±0) + y * (2893 ±0) + z * (3624 ±0)` - // Minimum execution time: 139_251_000_000 picoseconds. - Weight::from_parts(6_810_381_680, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 2_917_537 - .saturating_add(Weight::from_parts(143_813_813, 0).saturating_mul(y.into())) - // Standard Error: 2_914_495 - .saturating_add(Weight::from_parts(1_093_099_600, 0).saturating_mul(z.into())) - .saturating_add(RocksDbWeight::get().reads(10)) + // Measured: `86802 + x * (29 ±0) + y * (167 ±0) + z * (367 ±0)` + // Estimated: `4079 + x * (2502 ±0) + y * (2893 ±0) + z * (3624 ±0)` + // Minimum execution time: 8_733_000_000 picoseconds. + Weight::from_parts(8_889_000_000, 4079) + // Standard Error: 235_341 + .saturating_add(Weight::from_parts(6_457_226, 0).saturating_mul(y.into())) + // Standard Error: 235_237 + .saturating_add(Weight::from_parts(70_277_060, 0).saturating_mul(z.into())) + .saturating_add(RocksDbWeight::get().reads(10_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(y.into()))) .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(z.into()))) - .saturating_add(RocksDbWeight::get().writes(5)) + .saturating_add(RocksDbWeight::get().writes(5_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(y.into()))) .saturating_add(RocksDbWeight::get().writes((4_u64).saturating_mul(z.into()))) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) .saturating_add(Weight::from_parts(0, 2893).saturating_mul(y.into())) .saturating_add(Weight::from_parts(0, 3624).saturating_mul(z.into())) } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) @@ -2107,192 +2048,180 @@ impl WeightInfo for () { /// Storage: `PolimecFunding::Buckets` (r:1 w:0) /// Proof: `PolimecFunding::Buckets` (`max_values`: None, `max_size`: Some(100), added: 2575, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. fn start_community_funding_failure(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `2654 + x * (4 ±0)` - // Estimated: `4087` - // Minimum execution time: 1_453_000_000 picoseconds. - Weight::from_parts(1_487_504_532, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 177_339 - .saturating_add(Weight::from_parts(731_091, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(8)) - .saturating_add(RocksDbWeight::get().writes(3)) + // Measured: `1418 + x * (3 ±0)` + // Estimated: `4079` + // Minimum execution time: 87_000_000 picoseconds. + Weight::from_parts(97_589_188, 4079) + // Standard Error: 3_828 + .saturating_add(Weight::from_parts(26_576, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(8_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. fn start_remainder_funding(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `510 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 242_000_000 picoseconds. - Weight::from_parts(227_535_753, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 174_777 - .saturating_add(Weight::from_parts(37_767_357, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(2)) + // Measured: `536 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(18_694_146, 3814) + // Standard Error: 5_669 + .saturating_add(Weight::from_parts(2_256_677, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) - } - - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Asset` (r:1 w:1) - /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Metadata` (r:1 w:0) - /// Proof: `LocalAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - fn start_settlement_funding_success() -> Weight { - // Proof Size summary in bytes: - // Measured: `933` - // Estimated: `3814` - // Minimum execution time: 447_000_000 picoseconds. - Weight::from_parts(457_000_000, 0) - .saturating_add(Weight::from_parts(0, 3814)) - .saturating_add(RocksDbWeight::get().reads(5)) - .saturating_add(RocksDbWeight::get().writes(3)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - fn start_settlement_funding_failure() -> Weight { - // Proof Size summary in bytes: - // Measured: `760` - // Estimated: `3814` - // Minimum execution time: 130_000_000 picoseconds. - Weight::from_parts(136_000_000, 0) - .saturating_add(Weight::from_parts(0, 3814)) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(1)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - fn project_decision_accept_funding() -> Weight { - // Proof Size summary in bytes: - // Measured: `535` - // Estimated: `4087` - // Minimum execution time: 200_000_000 picoseconds. - Weight::from_parts(207_000_000, 0) - .saturating_add(Weight::from_parts(0, 4087)) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) - } - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsToUpdate` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) - fn project_decision_reject_funding() -> Weight { - // Proof Size summary in bytes: - // Measured: `535` - // Estimated: `4087` - // Minimum execution time: 200_000_000 picoseconds. - Weight::from_parts(203_000_000, 0) - .saturating_add(Weight::from_parts(0, 4087)) - .saturating_add(RocksDbWeight::get().reads(2)) - .saturating_add(RocksDbWeight::get().writes(2)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. fn end_funding_automatically_rejected_evaluators_slashed(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `822 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 296_000_000 picoseconds. - Weight::from_parts(284_006_640, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 85_755 - .saturating_add(Weight::from_parts(36_442_516, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(3)) + // Measured: `824 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 24_000_000 picoseconds. + Weight::from_parts(23_753_565, 3814) + // Standard Error: 4_976 + .saturating_add(Weight::from_parts(2_285_728, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. fn end_funding_awaiting_decision_evaluators_slashed(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `822 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 233_000_000 picoseconds. - Weight::from_parts(213_045_370, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 117_943 - .saturating_add(Weight::from_parts(36_217_046, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(3)) + // Measured: `823 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_149_882, 3814) + // Standard Error: 4_893 + .saturating_add(Weight::from_parts(2_241_882, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. fn end_funding_awaiting_decision_evaluators_unchanged(x: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `822 + x * (529 ±0)` - // Estimated: `4087 + x * (3097 ±0)` - // Minimum execution time: 236_000_000 picoseconds. - Weight::from_parts(245_084_435, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 136_756 - .saturating_add(Weight::from_parts(35_663_280, 0).saturating_mul(x.into())) - .saturating_add(RocksDbWeight::get().reads(3)) + // Measured: `823 + x * (29 ±0)` + // Estimated: `3814 + x * (2502 ±0)` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(18_735_663, 3814) + // Standard Error: 5_515 + .saturating_add(Weight::from_parts(2_252_806, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) - .saturating_add(RocksDbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) } /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::Evaluations` (r:2049 w:0) + /// Storage: `PolimecFunding::Evaluations` (r:2048 w:0) /// Proof: `PolimecFunding::Evaluations` (`max_values`: None, `max_size`: Some(345), added: 2820, mode: `MaxEncodedLen`) /// Storage: `PolimecFunding::ProjectsToUpdate` (r:100 w:1) - /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(622), added: 3097, mode: `MaxEncodedLen`) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) /// The range of component `x` is `[1, 99]`. /// The range of component `y` is `[1, 2048]`. fn end_funding_automatically_accepted_evaluators_rewarded(x: u32, y: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `1199 + x * (529 ±0) + y * (187 ±0)` - // Estimated: `4087 + x * (3097 ±0) + y * (2820 ±0)` - // Minimum execution time: 4_119_000_000 picoseconds. - Weight::from_parts(4_122_000_000, 0) - .saturating_add(Weight::from_parts(0, 4087)) - // Standard Error: 13_179_751 - .saturating_add(Weight::from_parts(37_293_090, 0).saturating_mul(x.into())) - // Standard Error: 636_741 - .saturating_add(Weight::from_parts(74_778_225, 0).saturating_mul(y.into())) - .saturating_add(RocksDbWeight::get().reads(4)) + // Measured: `1184 + x * (29 ±0) + y * (187 ±0)` + // Estimated: `3814 + x * (2502 ±0) + y * (2820 ±0)` + // Minimum execution time: 257_000_000 picoseconds. + Weight::from_parts(260_000_000, 3814) + // Standard Error: 52_986 + .saturating_add(Weight::from_parts(476_614, 0).saturating_mul(x.into())) + // Standard Error: 2_564 + .saturating_add(Weight::from_parts(4_091_225, 0).saturating_mul(y.into())) + .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(x.into()))) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(y.into()))) - .saturating_add(RocksDbWeight::get().writes(2)) - .saturating_add(Weight::from_parts(0, 3097).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2502).saturating_mul(x.into())) .saturating_add(Weight::from_parts(0, 2820).saturating_mul(y.into())) } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:2 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + fn project_decision_accept_funding() -> Weight { + // Proof Size summary in bytes: + // Measured: `563` + // Estimated: `5994` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_000_000, 5994) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsToUpdate` (r:2 w:1) + /// Proof: `PolimecFunding::ProjectsToUpdate` (`max_values`: None, `max_size`: Some(27), added: 2502, mode: `MaxEncodedLen`) + fn project_decision_reject_funding() -> Weight { + // Proof Size summary in bytes: + // Measured: `563` + // Estimated: `5994` + // Minimum execution time: 18_000_000 picoseconds. + Weight::from_parts(19_000_000, 5994) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Asset` (r:1 w:1) + /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) + /// Storage: `LocalAssets::Metadata` (r:1 w:1) + /// Proof: `LocalAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn start_settlement_funding_success() -> Weight { + // Proof Size summary in bytes: + // Measured: `970` + // Estimated: `3814` + // Minimum execution time: 41_000_000 picoseconds. + Weight::from_parts(43_000_000, 3814) + .saturating_add(RocksDbWeight::get().reads(5_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) + /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) + /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) + /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) + fn start_settlement_funding_failure() -> Weight { + // Proof Size summary in bytes: + // Measured: `760` + // Estimated: `3814` + // Minimum execution time: 11_000_000 picoseconds. + Weight::from_parts(12_000_000, 3814) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } } \ No newline at end of file From b4bd740d06564a0ada242e15b6b06d12daa1fe52 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Fri, 9 Feb 2024 18:25:01 +0100 Subject: [PATCH 206/212] fmt Signed-off-by: Juan Ignacio Rios --- Cargo.lock | 92 ++++++++++++++++--- nodes/parachain/src/chain_spec/testnet.rs | 4 +- nodes/parachain/src/command.rs | 10 +- pallets/democracy/src/lib.rs | 14 +-- pallets/democracy/src/traits.rs | 12 +-- pallets/democracy/src/vote.rs | 10 +- pallets/democracy/src/vote_threshold.rs | 20 ++-- pallets/elections-phragmen/src/lib.rs | 12 +-- pallets/funding/src/benchmarking.rs | 32 +++---- pallets/funding/src/functions.rs | 76 ++++++--------- pallets/funding/src/instantiator.rs | 6 +- pallets/funding/src/lib.rs | 13 +-- pallets/funding/src/mock.rs | 5 +- pallets/funding/src/tests.rs | 82 ++++++++--------- pallets/funding/src/types.rs | 31 ++++--- pallets/linear-release/src/impls.rs | 12 +-- pallets/linear-release/src/lib.rs | 2 +- pallets/linear-release/src/types.rs | 4 +- pallets/oracle-ocw/src/lib.rs | 20 ++-- pallets/oracle-ocw/src/tests.rs | 5 +- pallets/oracle-ocw/src/traits.rs | 12 +-- pallets/oracle-ocw/src/types.rs | 16 ++-- .../parachain-staking/src/auto_compound.rs | 5 +- .../src/delegation_requests.rs | 8 +- pallets/parachain-staking/src/lib.rs | 18 ++-- pallets/parachain-staking/src/tests.rs | 8 +- pallets/parachain-staking/src/types.rs | 48 +++++----- pallets/polimec-receiver/src/lib.rs | 2 +- pallets/xcm-executor/src/lib.rs | 11 ++- runtimes/base/src/lib.rs | 11 ++- runtimes/shared-configuration/src/fee.rs | 4 +- .../shared-configuration/src/governance.rs | 6 +- runtimes/testnet/src/lib.rs | 8 +- runtimes/testnet/src/xcm_config.rs | 17 ++-- 34 files changed, 352 insertions(+), 284 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 563899308..a57e9e105 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3879,10 +3879,10 @@ dependencies = [ "pallet-child-bounties", "pallet-collective", "pallet-conviction-voting", - "pallet-democracy", + "pallet-democracy 4.0.0-dev", "pallet-election-provider-multi-phase", "pallet-election-provider-support-benchmarking", - "pallet-elections-phragmen", + "pallet-elections-phragmen 5.0.0-dev", "pallet-fast-unstake", "pallet-grandpa", "pallet-identity", @@ -5616,6 +5616,26 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-democracy" +version = "0.4.0" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "pallet-preimage", + "pallet-scheduler", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-democracy" version = "4.0.0-dev" @@ -5670,6 +5690,27 @@ dependencies = [ "sp-runtime", ] +[[package]] +name = "pallet-elections-phragmen" +version = "0.4.0" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-balances", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-npos-elections", + "sp-runtime", + "sp-staking", + "sp-std", + "sp-tracing", + "substrate-test-utils", +] + [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" @@ -5710,7 +5751,7 @@ dependencies = [ [[package]] name = "pallet-funding" -version = "0.1.0" +version = "0.4.0" dependencies = [ "assert_matches2", "frame-benchmarking", @@ -5839,7 +5880,7 @@ dependencies = [ [[package]] name = "pallet-linear-release" -version = "4.0.0-dev" +version = "0.4.0" dependencies = [ "frame-benchmarking", "frame-support", @@ -6033,7 +6074,7 @@ dependencies = [ [[package]] name = "pallet-oracle-ocw" -version = "0.1.0" +version = "0.4.0" dependencies = [ "frame-support", "frame-system", @@ -6877,11 +6918,16 @@ dependencies = [ "pallet-aura", "pallet-authorship", "pallet-balances", + "pallet-collective", + "pallet-democracy 0.4.0", + "pallet-elections-phragmen 0.4.0", "pallet-membership", "pallet-multisig", "pallet-oracle-ocw", "pallet-parachain-staking", + "pallet-preimage", "pallet-proxy", + "pallet-scheduler", "pallet-session", "pallet-sudo", "pallet-timestamp", @@ -7035,7 +7081,8 @@ dependencies = [ "pallet-authorship", "pallet-balances", "pallet-collective", - "pallet-democracy", + "pallet-democracy 0.4.0", + "pallet-elections-phragmen 0.4.0", "pallet-funding", "pallet-insecure-randomness-collective-flip", "pallet-linear-release", @@ -7974,10 +8021,10 @@ dependencies = [ "pallet-child-bounties", "pallet-collective", "pallet-conviction-voting", - "pallet-democracy", + "pallet-democracy 4.0.0-dev", "pallet-election-provider-multi-phase", "pallet-election-provider-support-benchmarking", - "pallet-elections-phragmen", + "pallet-elections-phragmen 5.0.0-dev", "pallet-fast-unstake", "pallet-grandpa", "pallet-identity", @@ -8999,8 +9046,8 @@ dependencies = [ "pallet-bounties", "pallet-child-bounties", "pallet-collective", - "pallet-democracy", - "pallet-elections-phragmen", + "pallet-democracy 4.0.0-dev", + "pallet-elections-phragmen 5.0.0-dev", "pallet-grandpa", "pallet-identity", "pallet-im-online", @@ -11808,6 +11855,27 @@ dependencies = [ "trie-db", ] +[[package]] +name = "substrate-test-utils" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "futures", + "substrate-test-utils-derive", + "tokio", +] + +[[package]] +name = "substrate-test-utils-derive" +version = "0.10.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" +dependencies = [ + "proc-macro-crate 1.3.1", + "proc-macro2", + "quote", + "syn 2.0.48", +] + [[package]] name = "substrate-typenum" version = "1.16.0" @@ -13060,10 +13128,10 @@ dependencies = [ "pallet-bags-list", "pallet-balances", "pallet-collective", - "pallet-democracy", + "pallet-democracy 4.0.0-dev", "pallet-election-provider-multi-phase", "pallet-election-provider-support-benchmarking", - "pallet-elections-phragmen", + "pallet-elections-phragmen 5.0.0-dev", "pallet-fast-unstake", "pallet-grandpa", "pallet-identity", diff --git a/nodes/parachain/src/chain_spec/testnet.rs b/nodes/parachain/src/chain_spec/testnet.rs index 3cf3949df..744fa7eb4 100644 --- a/nodes/parachain/src/chain_spec/testnet.rs +++ b/nodes/parachain/src/chain_spec/testnet.rs @@ -389,8 +389,8 @@ fn testing_genesis( let funding_percent = 93u64; let project_metadata = default_project(ISSUER.into(), 0u32); let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) * - (project_metadata + let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) + * (project_metadata .minimum_price .checked_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1) .unwrap()); diff --git a/nodes/parachain/src/command.rs b/nodes/parachain/src/command.rs index 03dda0d7f..fcd9cd03e 100644 --- a/nodes/parachain/src/command.rs +++ b/nodes/parachain/src/command.rs @@ -262,14 +262,15 @@ pub fn run() -> Result<()> { let runner = cli.create_runner(cmd)?; // Switch on the concrete benchmark sub-command- match cmd { - BenchmarkCmd::Pallet(cmd) => + BenchmarkCmd::Pallet(cmd) => { if cfg!(feature = "runtime-benchmarks") { runner.sync_run(|config| cmd.run::(config)) } else { Err("Benchmarking wasn't enabled when building the node. \ You can enable it with `--features runtime-benchmarks`." .into()) - }, + } + }, BenchmarkCmd::Block(cmd) => runner.sync_run(|config| { let partials = new_partial(&config)?; cmd.run(partials.client) @@ -287,8 +288,9 @@ pub fn run() -> Result<()> { let storage = partials.backend.expose_storage(); cmd.run(config, partials.client.clone(), db, storage) }), - BenchmarkCmd::Machine(cmd) => - runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())), + BenchmarkCmd::Machine(cmd) => { + runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())) + }, // NOTE: this allows the Client to leniently implement // new benchmark commands without requiring a companion MR. #[allow(unreachable_patterns)] diff --git a/pallets/democracy/src/lib.rs b/pallets/democracy/src/lib.rs index 0bc6be020..b17c7a295 100644 --- a/pallets/democracy/src/lib.rs +++ b/pallets/democracy/src/lib.rs @@ -168,17 +168,17 @@ use sp_runtime::{ use sp_std::prelude::*; mod conviction; -mod types; mod traits; +mod types; mod vote; mod vote_threshold; pub mod weights; pub use conviction::Conviction; pub use pallet::*; +pub use traits::GetElectorate; pub use types::{ Delegations, MetadataOwner, PropIndex, ReferendumIndex, ReferendumInfo, ReferendumStatus, Tally, UnvoteScope, }; -pub use traits::GetElectorate; pub use vote::{AccountVote, Vote, Voting}; pub use vote_threshold::{Approved, VoteThreshold}; pub use weights::WeightInfo; @@ -813,7 +813,7 @@ pub mod pallet { if let Some((ext_proposal, _)) = NextExternal::::get() { ensure!(proposal_hash == ext_proposal.hash(), Error::::ProposalMissing); } else { - return Err(Error::::NoProposal.into()) + return Err(Error::::NoProposal.into()); } let mut existing_vetoers = >::get(&proposal_hash).map(|pair| pair.1).unwrap_or_default(); @@ -1482,7 +1482,7 @@ impl Pallet { Self::transfer_metadata(MetadataOwner::External, MetadataOwner::Referendum(ref_index)); Ok(()) } else { - return Err(Error::::NoneWaiting.into()) + return Err(Error::::NoneWaiting.into()); } } @@ -1512,7 +1512,7 @@ impl Pallet { } Ok(()) } else { - return Err(Error::::NoneWaiting.into()) + return Err(Error::::NoneWaiting.into()); } } @@ -1591,8 +1591,8 @@ impl Pallet { // of unbaked referendum is bounded by this number. In case those number have changed in a // runtime upgrade the formula should be adjusted but the bound should still be sensible. >::mutate(|ref_index| { - while *ref_index < last && - Self::referendum_info(*ref_index) + while *ref_index < last + && Self::referendum_info(*ref_index) .map_or(true, |info| matches!(info, ReferendumInfo::Finished { .. })) { *ref_index += 1 diff --git a/pallets/democracy/src/traits.rs b/pallets/democracy/src/traits.rs index 5183f8479..71eeaab8d 100644 --- a/pallets/democracy/src/traits.rs +++ b/pallets/democracy/src/traits.rs @@ -10,9 +10,9 @@ // whichever suits your needs. pub trait GetElectorate { - /// Calculate the total size of the electorate (tokens in circulation that might be used - /// for voting) in terms of total Balance. - /// Used for the referendum approval threshold calculation. - /// Example: Total number of tokens in the system - total number of tokens in the treasury. - fn get_electorate() -> Balance; -} \ No newline at end of file + /// Calculate the total size of the electorate (tokens in circulation that might be used + /// for voting) in terms of total Balance. + /// Used for the referendum approval threshold calculation. + /// Example: Total number of tokens in the system - total number of tokens in the treasury. + fn get_electorate() -> Balance; +} diff --git a/pallets/democracy/src/vote.rs b/pallets/democracy/src/vote.rs index f7413a2b1..acb204e82 100644 --- a/pallets/democracy/src/vote.rs +++ b/pallets/democracy/src/vote.rs @@ -80,8 +80,9 @@ impl AccountVote { pub fn locked_if(self, approved: bool) -> Option<(u32, Balance)> { // winning side: can only be removed after the lock period ends. match self { - AccountVote::Standard { vote, balance } if vote.aye == approved => - Some((vote.conviction.lock_periods(), balance)), + AccountVote::Standard { vote, balance } if vote.aye == approved => { + Some((vote.conviction.lock_periods(), balance)) + }, _ => None, } } @@ -182,8 +183,9 @@ impl Balance { match self { - Voting::Direct { votes, prior, .. } => - votes.iter().map(|i| i.1.balance()).fold(prior.locked(), |a, i| a.max(i)), + Voting::Direct { votes, prior, .. } => { + votes.iter().map(|i| i.1.balance()).fold(prior.locked(), |a, i| a.max(i)) + }, Voting::Delegating { balance, prior, .. } => *balance.max(&prior.locked()), } } diff --git a/pallets/democracy/src/vote_threshold.rs b/pallets/democracy/src/vote_threshold.rs index fccfc35a8..fc94cbcd6 100644 --- a/pallets/democracy/src/vote_threshold.rs +++ b/pallets/democracy/src/vote_threshold.rs @@ -50,18 +50,18 @@ fn compare_rationals + Div + Rem - compare_rationals(tally.nays, sqrt_voters, tally.ayes, sqrt_electorate), - VoteThreshold::SuperMajorityAgainst => - compare_rationals(tally.nays, sqrt_electorate, tally.ayes, sqrt_voters), + VoteThreshold::SuperMajorityApprove => { + compare_rationals(tally.nays, sqrt_voters, tally.ayes, sqrt_electorate) + }, + VoteThreshold::SuperMajorityAgainst => { + compare_rationals(tally.nays, sqrt_electorate, tally.ayes, sqrt_voters) + }, VoteThreshold::SimpleMajority => tally.ayes > tally.nays, } } diff --git a/pallets/elections-phragmen/src/lib.rs b/pallets/elections-phragmen/src/lib.rs index 3a6a38f10..9cd96be9c 100644 --- a/pallets/elections-phragmen/src/lib.rs +++ b/pallets/elections-phragmen/src/lib.rs @@ -890,7 +890,7 @@ impl Pallet { if candidates_and_deposit.len().is_zero() { Self::deposit_event(Event::EmptyTerm); - return T::DbWeight::get().reads(3) + return T::DbWeight::get().reads(3); } // All of the new winners that come out of phragmen will thus have a deposit recorded. @@ -921,7 +921,7 @@ impl Pallet { "Failed to run election. Number of voters exceeded", ); Self::deposit_event(Event::ElectionError); - return T::DbWeight::get().reads(3 + max_voters as u64) + return T::DbWeight::get().reads(3 + max_voters as u64); }, } @@ -1007,8 +1007,8 @@ impl Pallet { // All candidates/members/runners-up who are no longer retaining a position as a // seat holder will lose their bond. candidates_and_deposit.iter().for_each(|(c, d)| { - if new_members_ids_sorted.binary_search(c).is_err() && - new_runners_up_ids_sorted.binary_search(c).is_err() + if new_members_ids_sorted.binary_search(c).is_err() + && new_runners_up_ids_sorted.binary_search(c).is_err() { let (imbalance, _) = T::Currency::slash(&HoldReason::Candidacy.into(), c, *d); T::LoserCandidate::on_unbalanced(imbalance); @@ -1165,8 +1165,8 @@ impl Pallet { // - Members and candidates sets are disjoint; // - Members and runners-ups sets are disjoint. fn try_state_members_disjoint() -> Result<(), TryRuntimeError> { - match Self::intersects(&Pallet::::members_ids(), &Self::candidates_ids()) && - Self::intersects(&Pallet::::members_ids(), &Self::runners_up_ids()) + match Self::intersects(&Pallet::::members_ids(), &Self::candidates_ids()) + && Self::intersects(&Pallet::::members_ids(), &Self::runners_up_ids()) { true => Err("Members set should be disjoint from candidates and runners-up sets".into()), false => Ok(()), diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 817760cde..e34ad6da2 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -310,7 +310,7 @@ pub fn fill_projects_to_update( // fill the `ProjectsToUpdate` vectors from @ expected_insertion_block to @ expected_insertion_block+x, to benchmark all the failed insertion attempts for _ in 0..fully_filled_vecs_from_insertion { while ProjectsToUpdate::::try_append(expected_insertion_block, (&69u32, UpdateType::EvaluationEnd)).is_ok() { - continue + continue; } expected_insertion_block += 1u32.into(); } @@ -455,7 +455,7 @@ mod benchmarks { // fill the `ProjectsToUpdate` vectors from @ block_number to @ block_number+x, to benchmark all the failed insertion attempts for _ in 0..x { while ProjectsToUpdate::::try_append(block_number, (&69u32, UpdateType::EvaluationEnd)).is_ok() { - continue + continue; } block_number += 1u32.into(); } @@ -602,8 +602,8 @@ mod benchmarks { // if we are going to unbond evaluations due to being over the limit per user, then deduct them from the total expected plmc bond if x >= ::MaxEvaluationsPerUser::get() { - total_expected_plmc_bonded -= plmc_for_existing_evaluations[0].plmc_amount * - (x as u128 - ::MaxEvaluationsPerUser::get() as u128 + 1u128).into(); + total_expected_plmc_bonded -= plmc_for_existing_evaluations[0].plmc_amount + * (x as u128 - ::MaxEvaluationsPerUser::get() as u128 + 1u128).into(); } (inst, test_project_id, extrinsic_evaluation, extrinsic_plmc_bonded, total_expected_plmc_bonded) @@ -635,11 +635,11 @@ mod benchmarks { current_plmc_bond, rewarded_or_slashed, .. - } if project_id == project_id && - evaluator == evaluation.account.clone() && - original_plmc_bond == extrinsic_plmc_bonded && - current_plmc_bond == extrinsic_plmc_bonded && - rewarded_or_slashed.is_none() => {}, + } if project_id == project_id + && evaluator == evaluation.account.clone() + && original_plmc_bond == extrinsic_plmc_bonded + && current_plmc_bond == extrinsic_plmc_bonded + && rewarded_or_slashed.is_none() => {}, _ => assert!(false, "Evaluation is not stored correctly"), } @@ -828,8 +828,8 @@ mod benchmarks { inst.bid_for_users(project_id, vec![bid_params]).unwrap(); - ct_amount = Percent::from_percent(10) * - (project_metadata.total_allocation_size.0 * (do_perform_bid_calls as u128).into()); + ct_amount = Percent::from_percent(10) + * (project_metadata.total_allocation_size.0 * (do_perform_bid_calls as u128).into()); usdt_for_filler_bidder = usdt_for_new_bidder; } let extrinsic_bid = BidParams::new(bidder.clone(), ct_amount, 1_u128.into(), 1u8, AcceptedFundingAsset::USDT); @@ -1111,8 +1111,8 @@ mod benchmarks { let existing_amount: BalanceOf = (50 * ASSET_UNIT).into(); let extrinsic_amount: BalanceOf = if let Some(_) = ends_round { - project_metadata.total_allocation_size.0 - - existing_amount * (x.min(::MaxContributionsPerUser::get() - 1) as u128).into() + project_metadata.total_allocation_size.0 + - existing_amount * (x.min(::MaxContributionsPerUser::get() - 1) as u128).into() } else { (100 * ASSET_UNIT).into() }; @@ -1229,9 +1229,9 @@ mod benchmarks { match stored_contribution { ContributionInfoOf:: { project_id, contributor, ct_amount, .. } - if project_id == project_id && - contributor == contributor && - ct_amount == extrinsic_contribution.amount => {}, + if project_id == project_id + && contributor == contributor + && ct_amount == extrinsic_contribution.amount => {}, _ => { assert!(false, "Contribution is not stored correctly") }, diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 79756d3cc..dce5b18d2 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -201,14 +201,15 @@ impl Pallet { (&project_id, UpdateType::EvaluationEnd), ) { Ok(insertions) => insertions, - Err(insertions) => + Err(insertions) => { return Err(DispatchErrorWithPostInfo { post_info: PostDispatchInfo { actual_weight: Some(WeightInfoOf::::start_evaluation(insertions)), pays_fee: Pays::Yes, }, error: Error::::TooManyInsertionAttempts.into(), - }), + }) + }, }; // * Emit events * @@ -310,7 +311,7 @@ impl Pallet { return Ok(PostDispatchInfo { actual_weight: Some(WeightInfoOf::::end_evaluation_success(insertion_attempts)), pays_fee: Pays::Yes, - }) + }); // Unsuccessful path } else { @@ -324,7 +325,7 @@ impl Pallet { return Ok(PostDispatchInfo { actual_weight: Some(WeightInfoOf::::end_evaluation_failure()), pays_fee: Pays::Yes, - }) + }); } } @@ -397,7 +398,7 @@ impl Pallet { Ok(iterations) => { remove_attempts = iterations; }, - Err(iterations) => + Err(iterations) => { return Err(DispatchErrorWithPostInfo { post_info: PostDispatchInfo { actual_weight: Some(WeightInfoOf::::start_auction_manually( @@ -407,7 +408,8 @@ impl Pallet { pays_fee: Pays::Yes, }, error: Error::::ProjectNotInUpdateStore.into(), - }), + }) + }, } } // Schedule for automatic transition to candle auction round @@ -416,7 +418,7 @@ impl Pallet { Ok(iterations) => { insertion_attempts = iterations; }, - Err(insertion_attempts) => + Err(insertion_attempts) => { return Err(DispatchErrorWithPostInfo { post_info: PostDispatchInfo { actual_weight: if remove_attempts == 0u32 { @@ -427,7 +429,8 @@ impl Pallet { pays_fee: Pays::Yes, }, error: Error::::TooManyInsertionAttempts.into(), - }), + }) + }, }; // * Emit events * @@ -709,9 +712,9 @@ impl Pallet { // * Validity checks * ensure!( - remaining_cts == Zero::zero() || - project_details.status == ProjectStatus::FundingFailed || - matches!(remainder_end_block, Some(end_block) if now > end_block), + remaining_cts == Zero::zero() + || project_details.status == ProjectStatus::FundingFailed + || matches!(remainder_end_block, Some(end_block) if now > end_block), Error::::TooEarlyForFundingEnd ); @@ -739,7 +742,7 @@ impl Pallet { insertion_iterations, )), pays_fee: Pays::Yes, - }) + }); } else if funding_ratio <= Perquintill::from_percent(75u64) { project_details.evaluation_round_info.evaluators_outcome = EvaluatorsOutcome::Slashed; project_details.status = ProjectStatus::AwaitingProjectDecision; @@ -789,7 +792,7 @@ impl Pallet { evaluations_count, )), pays_fee: Pays::Yes, - }) + }); } } @@ -835,8 +838,8 @@ impl Pallet { // * Validity checks * ensure!( - project_details.status == ProjectStatus::FundingSuccessful || - project_details.status == ProjectStatus::FundingFailed, + project_details.status == ProjectStatus::FundingSuccessful + || project_details.status == ProjectStatus::FundingFailed, Error::::NotAllowed ); @@ -1216,30 +1219,6 @@ impl Pallet { let caller_existing_contributions = Contributions::::iter_prefix_values((project_id, contributor)).collect::>(); - // Weight flags - enum WeightContributionFlag { - FirstContribution, - SecondToLimitContribution, - OverLimitContribution, - } - struct WeightRoundEndFlag { - fully_filled_vecs_from_insertion: u32, - total_vecs_in_storage: u32, - } - let weight_contribution_flag: WeightContributionFlag; - let mut weight_round_end_flag: Option = None; - let mut weight_ct_account_deposit = false; - - if caller_existing_contributions.len() == 0 { - weight_contribution_flag = WeightContributionFlag::FirstContribution; - } else if caller_existing_contributions.len() < T::MaxContributionsPerUser::get() as usize { - weight_contribution_flag = WeightContributionFlag::SecondToLimitContribution; - } else { - weight_contribution_flag = WeightContributionFlag::OverLimitContribution; - } - let caller_existing_contributions = - Contributions::::iter_prefix_values((project_id, contributor)).collect::>(); - // Weight flags enum WeightContributionFlag { First, @@ -1322,13 +1301,13 @@ impl Pallet { { weight_ct_account_deposit = true; T::NativeCurrency::hold(&HoldReason::FutureDeposit(project_id).into(), &contributor, ct_deposit)?; + } if T::NativeCurrency::balance_on_hold(&HoldReason::FutureDeposit(project_id).into(), contributor) < ct_deposit { weight_ct_account_deposit = true; T::NativeCurrency::hold(&HoldReason::FutureDeposit(project_id).into(), contributor, ct_deposit)?; } // Try adding the new contribution to the system - if matches!(weight_contribution_flag, WeightContributionFlag::OverLimitContribution).not() { if matches!(weight_contribution_flag, WeightContributionFlag::OverLimit).not() { Self::try_plmc_participation_lock(contributor, project_id, plmc_bond)?; Self::try_funding_asset_hold(contributor, project_id, funding_asset_amount, asset_id)?; @@ -1412,7 +1391,7 @@ impl Pallet { multiplier, }); - // return correct weight function + // return correct weight function match (weight_contribution_flag, weight_round_end_flag, weight_ct_account_deposit) { (WeightContributionFlag::First, None, false) => Ok(PostDispatchInfo { actual_weight: Some(WeightInfoOf::::first_contribution_no_ct_deposit()), @@ -1470,6 +1449,7 @@ impl Pallet { pays_fee: Pays::Yes, }), } + } fn calculate_buyable_amount( status: &ProjectStatus, @@ -1515,25 +1495,27 @@ impl Pallet { match Self::remove_from_update_store(&project_id) { Ok(iterations) => remove_attempts = iterations, - Err(iterations) => + Err(iterations) => { return Err(DispatchErrorWithPostInfo { post_info: PostDispatchInfo { actual_weight: Some(WeightInfoOf::::decide_project_outcome(insertion_attempts, iterations)), pays_fee: Pays::Yes, }, error: Error::::TooManyInsertionAttempts.into(), - }), + }) + }, }; match Self::add_to_update_store(now + 1u32.into(), (&project_id, UpdateType::ProjectDecision(decision))) { Ok(iterations) => insertion_attempts = iterations, - Err(iterations) => + Err(iterations) => { return Err(DispatchErrorWithPostInfo { post_info: PostDispatchInfo { actual_weight: Some(WeightInfoOf::::decide_project_outcome(iterations, remove_attempts)), pays_fee: Pays::Yes, }, error: Error::::TooManyInsertionAttempts.into(), - }), + }) + }, }; Self::deposit_event(Event::ProjectOutcomeDecided { project_id, decision }); @@ -2703,10 +2685,10 @@ impl Pallet { if ProjectsToUpdate::::try_append(block_number, store.clone()).is_err() { block_number += 1u32.into(); } else { - return Ok(i) + return Ok(i); } } - return Err(T::MaxProjectsToUpdateInsertionAttempts::get()) + return Err(T::MaxProjectsToUpdateInsertionAttempts::get()); } // returns the actual iterations for weight calculation either as an Err type or Ok type so the caller can add that diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index b3c99346d..1563a4b07 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -1161,9 +1161,9 @@ impl< assert!( matches!( project_details.status, - ProjectStatus::FundingSuccessful | - ProjectStatus::FundingFailed | - ProjectStatus::AwaitingProjectDecision + ProjectStatus::FundingSuccessful + | ProjectStatus::FundingFailed + | ProjectStatus::AwaitingProjectDecision ), "Project should be in Finished status" ); diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 45c0c9588..d32f64321 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1441,15 +1441,16 @@ pub mod pallet { let projects_needing_cleanup = ProjectsDetails::::iter() .filter_map(|(project_id, info)| match info.cleanup { - cleaner if >::has_remaining_operations(&cleaner) => - Some((project_id, cleaner)), + cleaner if >::has_remaining_operations(&cleaner) => { + Some((project_id, cleaner)) + }, _ => None, }) .collect::>(); let projects_amount = projects_needing_cleanup.len() as u64; if projects_amount == 0 { - return max_weight + return max_weight; } let mut max_weight_per_project = remaining_weight.saturating_div(projects_amount); @@ -1465,7 +1466,7 @@ pub mod pallet { { consumed_weight.saturating_accrue(weight); } else { - break + break; } } @@ -1569,7 +1570,7 @@ pub mod local_macros { project_id: $project_id, error: Error::::FieldIsNone.into(), }); - continue + continue; }, } }; @@ -1583,7 +1584,7 @@ pub mod local_macros { Ok(val) => val, Err(err) => { Self::deposit_event(Event::TransitionError { project_id: $project_id, error: $error_handler(err) }); - continue + continue; }, } }; diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 2cef32109..2b9b4772f 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -81,8 +81,9 @@ where { fn try_convert(o: RuntimeOrigin) -> Result { o.try_with_caller(|caller| match caller.try_into() { - Ok(SystemRawOrigin::Signed(who)) => - Ok(Junction::AccountIndex64 { network: Network::get(), index: who.into() }.into()), + Ok(SystemRawOrigin::Signed(who)) => { + Ok(Junction::AccountIndex64 { network: Network::get(), index: who.into() }.into()) + }, Ok(other) => Err(other.into()), Err(other) => Err(other), }) diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index 2313a8901..88ba37662 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -242,8 +242,8 @@ pub mod defaults { pub fn project_from_funding_reached(instantiator: &mut MockInstantiator, percent: u64) -> ProjectId { let project_metadata = default_project(instantiator.get_new_nonce(), ISSUER); let min_price = project_metadata.minimum_price; - let usd_to_reach = Perquintill::from_percent(percent) * - (project_metadata + let usd_to_reach = Perquintill::from_percent(percent) + * (project_metadata .minimum_price .checked_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1) .unwrap()); @@ -622,8 +622,8 @@ mod evaluation_round_failure { let project_metadata = default_project(0, ISSUER); let project_id = inst.create_evaluating_project(project_metadata.clone(), ISSUER); let evaluation_success_threshold = ::EvaluationSuccessThreshold::get(); - let evaluation_min_success_amount = evaluation_success_threshold * - project_metadata.minimum_price.saturating_mul_int( + let evaluation_min_success_amount = evaluation_success_threshold + * project_metadata.minimum_price.saturating_mul_int( project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1, ); let evaluation_fail_amount = evaluation_min_success_amount - 100 * ASSET_UNIT; @@ -2071,9 +2071,9 @@ mod auction_round_failure { inst.bid_for_users(project_id, vec![bid_in]).unwrap(); inst.advance_time( - ::EnglishAuctionDuration::get() + - ::CandleAuctionDuration::get() - - 1, + ::EnglishAuctionDuration::get() + + ::CandleAuctionDuration::get() + - 1, ) .unwrap(); @@ -2518,15 +2518,15 @@ mod community_round_success { assert_eq!( new_plmc_bond_stored, - plmc_bond_stored + MockInstantiator::sum_balance_mappings(vec![new_plmc_funding]) - - plmc_funding[0].plmc_amount + plmc_bond_stored + MockInstantiator::sum_balance_mappings(vec![new_plmc_funding]) + - plmc_funding[0].plmc_amount ); assert_eq!( new_statemint_asset_contributions_stored, - statemint_asset_contributions_stored + - MockInstantiator::sum_statemint_mappings(vec![new_statemint_funding]) - - statemint_funding[0].asset_amount + statemint_asset_contributions_stored + + MockInstantiator::sum_statemint_mappings(vec![new_statemint_funding]) + - statemint_funding[0].asset_amount ); } @@ -2634,15 +2634,15 @@ mod community_round_success { assert_eq!( new_plmc_bond_stored, - plmc_bond_stored + MockInstantiator::sum_balance_mappings(vec![new_plmc_funding]) - - plmc_funding[0].plmc_amount + plmc_bond_stored + MockInstantiator::sum_balance_mappings(vec![new_plmc_funding]) + - plmc_funding[0].plmc_amount ); assert_eq!( new_statemint_asset_contributions_stored, - statemint_asset_contributions_stored + - MockInstantiator::sum_statemint_mappings(vec![new_statemint_funding]) - - statemint_funding[0].asset_amount + statemint_asset_contributions_stored + + MockInstantiator::sum_statemint_mappings(vec![new_statemint_funding]) + - statemint_funding[0].asset_amount ); } @@ -2772,8 +2772,8 @@ mod community_round_success { let plmc_available_for_participating = plmc_evaluation_amount - ::EvaluatorSlash::get() * plmc_evaluation_amount; assert!( - necessary_plmc_for_contribution > plmc_available_for_participating && - necessary_plmc_for_contribution < plmc_evaluation_amount + necessary_plmc_for_contribution > plmc_available_for_participating + && necessary_plmc_for_contribution < plmc_evaluation_amount ); println!( "Plmc contr: {:?}, plmc eval: {:?}, plmc avail: {:?}", @@ -2813,8 +2813,8 @@ mod community_round_success { let plmc_available_for_participating = plmc_evaluation_amount - ::EvaluatorSlash::get() * plmc_evaluation_amount; assert!( - necessary_plmc_for_contribution > plmc_available_for_participating && - necessary_plmc_for_contribution < plmc_evaluation_amount + necessary_plmc_for_contribution > plmc_available_for_participating + && necessary_plmc_for_contribution < plmc_evaluation_amount ); let necessary_usdt_for_contribution = MockInstantiator::calculate_contributed_funding_asset_spent(vec![contribution.clone()], ct_price); @@ -3383,8 +3383,8 @@ mod remainder_round_success { // Check remaining CTs is 0 assert_eq!( - inst.get_project_details(project_id).remaining_contribution_tokens.0 + - inst.get_project_details(project_id).remaining_contribution_tokens.1, + inst.get_project_details(project_id).remaining_contribution_tokens.0 + + inst.get_project_details(project_id).remaining_contribution_tokens.1, 0, "There are still remaining CTs" ); @@ -3414,8 +3414,8 @@ mod remainder_round_success { ); const BOB: AccountId = 808; - let remaining_ct = inst.get_project_details(project_id).remaining_contribution_tokens.0 + - inst.get_project_details(project_id).remaining_contribution_tokens.1; + let remaining_ct = inst.get_project_details(project_id).remaining_contribution_tokens.0 + + inst.get_project_details(project_id).remaining_contribution_tokens.1; let ct_price = inst.get_project_details(project_id).weighted_average_price.expect("CT Price should exist"); @@ -3438,8 +3438,8 @@ mod remainder_round_success { // Check remaining CTs is 0 assert_eq!( - inst.get_project_details(project_id).remaining_contribution_tokens.0 + - inst.get_project_details(project_id).remaining_contribution_tokens.1, + inst.get_project_details(project_id).remaining_contribution_tokens.0 + + inst.get_project_details(project_id).remaining_contribution_tokens.1, 0, "There are still remaining CTs" ); @@ -3826,8 +3826,8 @@ mod funding_end { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let project_metadata = default_project(inst.get_new_nonce(), ISSUER); let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) * - (project_metadata.minimum_price.checked_mul_int(project_metadata.total_allocation_size.0).unwrap()); + let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) + * (project_metadata.minimum_price.checked_mul_int(project_metadata.total_allocation_size.0).unwrap()); let evaluations = default_evaluations(); let bids = MockInstantiator::generate_bids_from_total_usd( Percent::from_percent(50u8) * twenty_percent_funding_usd, @@ -3855,8 +3855,8 @@ mod funding_end { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let project_metadata = default_project(inst.get_new_nonce(), ISSUER); let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) * - (project_metadata + let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) + * (project_metadata .minimum_price .checked_mul_int( project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1, @@ -3889,8 +3889,8 @@ mod funding_end { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let project_metadata = default_project(inst.get_new_nonce(), ISSUER); let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) * - (project_metadata + let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) + * (project_metadata .minimum_price .checked_mul_int( project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1, @@ -3922,8 +3922,8 @@ mod funding_end { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let project_metadata = default_project(inst.get_new_nonce(), ISSUER); let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(55) * - (project_metadata + let twenty_percent_funding_usd = Perquintill::from_percent(55) + * (project_metadata .minimum_price .checked_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1) .unwrap()); @@ -3971,8 +3971,8 @@ mod funding_end { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let project_metadata = default_project(inst.get_new_nonce(), ISSUER); let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(55) * - (project_metadata + let twenty_percent_funding_usd = Perquintill::from_percent(55) + * (project_metadata .minimum_price .checked_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1) .unwrap()); @@ -4024,8 +4024,8 @@ mod funding_end { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let project_metadata = default_project(inst.get_new_nonce(), ISSUER); let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(55) * - (project_metadata + let twenty_percent_funding_usd = Perquintill::from_percent(55) + * (project_metadata .minimum_price .checked_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1) .unwrap()); @@ -6009,8 +6009,8 @@ mod async_tests { let funding_percent = 93u64; let project_metadata = default_project(0u64, ISSUER.into()); let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) * - (project_metadata + let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) + * (project_metadata .minimum_price .checked_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1) .unwrap()); diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index e5f195c1f..0851adb2b 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -194,7 +194,7 @@ pub mod storage_types { // TODO: PLMC-162. Perform a REAL validity check pub fn validity_check(&self) -> Result<(), ValidityError> { if self.minimum_price == Price::zero() { - return Err(ValidityError::PriceTooLow) + return Err(ValidityError::PriceTooLow); } self.ticket_size.is_valid()?; self.participants_size.is_valid()?; @@ -411,10 +411,10 @@ pub mod inner_types { impl TicketSize { pub(crate) fn is_valid(&self) -> Result<(), ValidityError> { if self.minimum.is_some() && self.maximum.is_some() { - return if self.minimum < self.maximum { Ok(()) } else { Err(ValidityError::TicketSizeError) } + return if self.minimum < self.maximum { Ok(()) } else { Err(ValidityError::TicketSizeError) }; } if self.minimum.is_some() || self.maximum.is_some() { - return Ok(()) + return Ok(()); } Err(ValidityError::TicketSizeError) @@ -430,18 +430,20 @@ pub mod inner_types { impl ParticipantsSize { pub(crate) const fn is_valid(&self) -> Result<(), ValidityError> { match (self.minimum, self.maximum) { - (Some(min), Some(max)) => + (Some(min), Some(max)) => { if min < max && min > 0 && max > 0 { Ok(()) } else { Err(ValidityError::ParticipantsSizeError) - }, - (Some(elem), None) | (None, Some(elem)) => + } + }, + (Some(elem), None) | (None, Some(elem)) => { if elem > 0 { Ok(()) } else { Err(ValidityError::ParticipantsSizeError) - }, + } + }, (None, None) => Err(ValidityError::ParticipantsSizeError), } } @@ -666,8 +668,9 @@ pub mod inner_types { fn try_from(value: ProjectStatus) -> Result { match value { ProjectStatus::FundingSuccessful => Ok(Cleaner::Success(CleanerState::Initialized(PhantomData))), - ProjectStatus::FundingFailed | ProjectStatus::EvaluationFailed => - Ok(Cleaner::Failure(CleanerState::Initialized(PhantomData))), + ProjectStatus::FundingFailed | ProjectStatus::EvaluationFailed => { + Ok(Cleaner::Failure(CleanerState::Initialized(PhantomData))) + }, _ => Err(()), } } @@ -771,7 +774,7 @@ pub struct MigrationGenerator(PhantomData); impl MigrationGenerator { pub fn evaluation_migration(evaluation: EvaluationInfoOf) -> Option { if matches!(evaluation.ct_migration_status, MigrationStatus::Confirmed | MigrationStatus::Sent(_)) { - return None + return None; } if let Some(RewardOrSlash::Reward(ct_amount)) = evaluation.rewarded_or_slashed { let multiplier = MultiplierOf::::try_from(1u8).ok()?; @@ -790,10 +793,10 @@ impl MigrationGenerator { } pub fn bid_migration(bid: BidInfoOf) -> Option { - if bid.final_ct_amount == Zero::zero() || - matches!(bid.ct_migration_status, MigrationStatus::Confirmed | MigrationStatus::Sent(_)) + if bid.final_ct_amount == Zero::zero() + || matches!(bid.ct_migration_status, MigrationStatus::Confirmed | MigrationStatus::Sent(_)) { - return None + return None; } let vesting_duration = bid.multiplier.calculate_vesting_duration::(); let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); @@ -808,7 +811,7 @@ impl MigrationGenerator { pub fn contribution_migration(contribution: ContributionInfoOf) -> Option { if matches!(contribution.ct_migration_status, MigrationStatus::Confirmed | MigrationStatus::Sent(_)) { - return None + return None; } let vesting_duration = contribution.multiplier.calculate_vesting_duration::(); let vesting_duration_local_type = ::BlockNumber::from(vesting_duration); diff --git a/pallets/linear-release/src/impls.rs b/pallets/linear-release/src/impls.rs index fb95385cb..6ad347ac0 100644 --- a/pallets/linear-release/src/impls.rs +++ b/pallets/linear-release/src/impls.rs @@ -72,7 +72,7 @@ impl Pallet { // Validate user inputs. ensure!(schedule.locked() >= T::MinVestedTransfer::get(), Error::::AmountLow); if !schedule.is_valid() { - return Err(Error::::InvalidScheduleParams.into()) + return Err(Error::::InvalidScheduleParams.into()); }; // Check we can add to this account prior to any storage writes. @@ -272,13 +272,13 @@ impl ReleaseSchedule, ReasonOf> for Pallet { reason: ReasonOf, ) -> DispatchResult { if locked.is_zero() { - return Ok(()) + return Ok(()); } let vesting_schedule = VestingInfo::new(locked, per_block, starting_block); // Check for `per_block` or `locked` of 0. if !vesting_schedule.is_valid() { - return Err(Error::::InvalidScheduleParams.into()) + return Err(Error::::InvalidScheduleParams.into()); }; let mut schedules = Self::vesting(who, reason).unwrap_or_default(); @@ -313,13 +313,13 @@ impl ReleaseSchedule, ReasonOf> for Pallet { reason: ReasonOf, ) -> DispatchResult { if locked.is_zero() { - return Ok(()) + return Ok(()); } let vesting_schedule = VestingInfo::new(locked, per_block, starting_block); // Check for `per_block` or `locked` of 0. if !vesting_schedule.is_valid() { - return Err(Error::::InvalidScheduleParams.into()) + return Err(Error::::InvalidScheduleParams.into()); }; let mut schedules = Self::vesting(who, reason).unwrap_or_default(); @@ -346,7 +346,7 @@ impl ReleaseSchedule, ReasonOf> for Pallet { ) -> DispatchResult { // Check for `per_block` or `locked` of 0. if !VestingInfo::new(locked, per_block, starting_block).is_valid() { - return Err(Error::::InvalidScheduleParams.into()) + return Err(Error::::InvalidScheduleParams.into()); } ensure!( diff --git a/pallets/linear-release/src/lib.rs b/pallets/linear-release/src/lib.rs index 6d6c0daf0..d34db5b4d 100644 --- a/pallets/linear-release/src/lib.rs +++ b/pallets/linear-release/src/lib.rs @@ -371,7 +371,7 @@ pub mod pallet { ) -> DispatchResult { let who = ensure_signed(origin)?; if schedule1_index == schedule2_index { - return Ok(()) + return Ok(()); }; let schedule1_index = schedule1_index as usize; let schedule2_index = schedule2_index as usize; diff --git a/pallets/linear-release/src/types.rs b/pallets/linear-release/src/types.rs index afdb779bc..6a422c6a3 100644 --- a/pallets/linear-release/src/types.rs +++ b/pallets/linear-release/src/types.rs @@ -103,8 +103,8 @@ where // the block after starting. One::one() } else { - self.locked / self.per_block() + - if (self.locked % self.per_block()).is_zero() { + self.locked / self.per_block() + + if (self.locked % self.per_block()).is_zero() { Zero::zero() } else { // `per_block` does not perfectly divide `locked`, so we need an extra block to diff --git a/pallets/oracle-ocw/src/lib.rs b/pallets/oracle-ocw/src/lib.rs index fb9535e97..dd08d25ac 100644 --- a/pallets/oracle-ocw/src/lib.rs +++ b/pallets/oracle-ocw/src/lib.rs @@ -121,7 +121,7 @@ pub mod pallet { let account = public.clone().into_account(); if ::Members::contains(&account) { if let Ok(generic_public) = TryInto::>::try_into(public) { - return Some(generic_public.into()) + return Some(generic_public.into()); } } None @@ -154,24 +154,24 @@ pub mod pallet { .filter_map(|(asset_name, last_send)| { let window = T::FetchWindow::get(); let remainder = block_number.rem(T::FetchInterval::get()); - if remainder >= BlockNumberFor::::zero() && - remainder < window && last_send < &block_number.saturating_sub(window) + if remainder >= BlockNumberFor::::zero() + && remainder < window && last_send < &block_number.saturating_sub(window) { - return Some(*asset_name) + return Some(*asset_name); } None }) .collect::>(); if assets.is_empty() { - return + return; } log::trace!(target: LOG_TARGET, "Transaction grace period reached for assets {:?} in block {:?}", assets, block_number); let prices = Self::fetch_prices(assets); if prices.is_empty() { - return + return; } for (asset_name, price) in prices.clone() { @@ -220,14 +220,14 @@ pub mod pallet { .into_iter() .filter_map(|(key, price_list)| { if price_list.is_empty() { - return None + return None; } let combined_prices = price_list.into_iter().fold((FixedU128::zero(), FixedU128::zero()), |acc, (price, volume)| { (acc.0 + price, acc.1 + volume) }); if combined_prices.1.is_zero() { - return None + return None; } Some((key, combined_prices.0.div(combined_prices.1))) }) @@ -246,11 +246,11 @@ pub mod pallet { match result { Some((_, Ok(_))) => { log::trace!(target: LOG_TARGET, "offchain tx sent successfully"); - return Ok(()) + return Ok(()); }, _ => { log::trace!(target: LOG_TARGET, "failure: offchain_signed_tx"); - return Err(()) + return Err(()); }, } } diff --git a/pallets/oracle-ocw/src/tests.rs b/pallets/oracle-ocw/src/tests.rs index da1a1b2fd..da891ee14 100644 --- a/pallets/oracle-ocw/src/tests.rs +++ b/pallets/oracle-ocw/src/tests.rs @@ -36,7 +36,7 @@ fn call_offchain_worker() { assert_eq!(tx.signature.unwrap().0, 0); match tx.call { - RuntimeCall::Oracle(orml_oracle::Call::feed_values { values }) => + RuntimeCall::Oracle(orml_oracle::Call::feed_values { values }) => { for (asset, price) in values { match asset { 0 => assert_close_enough(price, FixedU128::from_float(6.138485575453039783)), @@ -44,7 +44,8 @@ fn call_offchain_worker() { 420 => assert_close_enough(price, FixedU128::from_float(1.000093378020633965)), _ => panic!("Unexpected asset"), } - }, + } + }, _ => panic!("Unexpected call"), } }); diff --git a/pallets/oracle-ocw/src/traits.rs b/pallets/oracle-ocw/src/traits.rs index e785748b6..708d3b19e 100644 --- a/pallets/oracle-ocw/src/traits.rs +++ b/pallets/oracle-ocw/src/traits.rs @@ -31,12 +31,12 @@ pub(crate) trait FetchPrice { .filter_map(|asset| { let url = Self::get_url(asset); if url.is_empty() { - return None + return None; } let request = http::Request::get(url); if let Ok(req) = request.deadline(deadline).send() { - return Some(AssetRequest { asset, id: req.id }) + return Some(AssetRequest { asset, id: req.id }); } None }) @@ -51,9 +51,9 @@ pub(crate) trait FetchPrice { .filter_map(|(maybe_response, asset)| { if let Ok(Ok(response)) = maybe_response { if response.code != 200 { - return None + return None; } - return Some((asset, response)) + return Some((asset, response)); } None }) @@ -61,7 +61,7 @@ pub(crate) trait FetchPrice { let body = response.body().collect::>(); if let Ok(body_str) = sp_std::str::from_utf8(&body) { if let Some(ocv_data) = Self::parse_body(body_str) { - return Some((asset, ocv_data)) + return Some((asset, ocv_data)); } } None @@ -72,7 +72,7 @@ pub(crate) trait FetchPrice { (w_price_sum + ocv.vwp(), vol_sum.saturating_add(ocv.volume)) }); if total_vol.is_zero() { - return None + return None; } Some((asset, w_price_sum, total_vol)) }) diff --git a/pallets/oracle-ocw/src/types.rs b/pallets/oracle-ocw/src/types.rs index 6c2babcaf..443e5498a 100644 --- a/pallets/oracle-ocw/src/types.rs +++ b/pallets/oracle-ocw/src/types.rs @@ -119,7 +119,7 @@ impl FetchPrice for KrakenFetcher { let maybe_response = serde_json_core::from_str::(body); if let Err(e) = maybe_response { log::error!(target: LOG_TARGET, "Error parsing response for Kraken: {:?}", e); - return None + return None; } let response = maybe_response.ok()?; Some(response.0.result.data.into_iter().rev().take(NUMBER_OF_CANDLES).collect()) @@ -141,14 +141,14 @@ impl FetchPrice for BitFinexFetcher { let maybe_response = serde_json_core::from_str::>(body); if let Err(e) = maybe_response { log::error!(target: LOG_TARGET, "Error parsing response for BitFinex: {:?}", e); - return None + return None; } let response = maybe_response.ok()?; let data: Vec = response.0.into_iter().filter_map(|r| OpenCloseVolume::from_f64(r.3, r.4, r.2, r.5).ok()).collect(); if data.len() < NUMBER_OF_CANDLES { - return None + return None; } Some(data) } @@ -175,7 +175,7 @@ where let volume_str = "volume"; for row in data.into_iter() { if !row.contains_key(&high_str) && !row.contains_key(&close_str) && !row.contains_key(&volume_str) { - return Err(serde::de::Error::custom("Row does not contain required data")) + return Err(serde::de::Error::custom("Row does not contain required data")); } let high = *row.get(&high_str).ok_or(serde::de::Error::custom("Could not parse value to str"))?; let low = *row.get(&low_str).ok_or(serde::de::Error::custom("Could not parse value to str"))?; @@ -208,11 +208,11 @@ impl FetchPrice for BitStampFetcher { let maybe_response = serde_json_core::from_str::(body); if let Err(e) = maybe_response { log::error!(target: LOG_TARGET, "Error parsing response for Bitstamp: {:?}", e); - return None + return None; } let response = maybe_response.ok()?; if response.0.data.ohlc.len() < NUMBER_OF_CANDLES { - return None + return None; } Some(response.0.data.ohlc.into_iter().rev().collect()) @@ -234,7 +234,7 @@ impl FetchPrice for CoinbaseFetcher { let maybe_response = serde_json_core::from_str::>(body); if let Err(e) = maybe_response { log::error!(target: LOG_TARGET, "Error parsing response for Coinbase: {:?}", e); - return None + return None; } let response = maybe_response.ok()?; @@ -245,7 +245,7 @@ impl FetchPrice for CoinbaseFetcher { .filter_map(|r| OpenCloseVolume::from_f64(r.2, r.1, r.4, r.5).ok()) .collect(); if data.len() < NUMBER_OF_CANDLES { - return None + return None; } Some(data) } diff --git a/pallets/parachain-staking/src/auto_compound.rs b/pallets/parachain-staking/src/auto_compound.rs index 8bb04ca8c..b030e74ee 100644 --- a/pallets/parachain-staking/src/auto_compound.rs +++ b/pallets/parachain-staking/src/auto_compound.rs @@ -86,13 +86,14 @@ where /// vector for binary_search to work. pub fn set_for_delegator(&mut self, delegator: T::AccountId, value: Percent) -> Result> { match self.0.binary_search_by(|d| d.delegator.cmp(&delegator)) { - Ok(index) => + Ok(index) => { if self.0[index].value == value { Ok(false) } else { self.0[index].value = value; Ok(true) - }, + } + }, Err(index) => { self.0 .try_insert(index, AutoCompoundConfig { delegator, value }) diff --git a/pallets/parachain-staking/src/delegation_requests.rs b/pallets/parachain-staking/src/delegation_requests.rs index 971d5bdc6..5ee672e2f 100644 --- a/pallets/parachain-staking/src/delegation_requests.rs +++ b/pallets/parachain-staking/src/delegation_requests.rs @@ -287,7 +287,7 @@ impl Pallet { } else { // must rm entire delegation if bond.amount <= less or cancel request Err(>::DelegationBelowMin.into()) - } + }; } } Err(>::DelegationDNE.into()) @@ -338,7 +338,7 @@ impl Pallet { } if existing_revoke_count == state.delegations.0.len() { - return Err(>::DelegatorAlreadyLeaving.into()) + return Err(>::DelegatorAlreadyLeaving.into()); } updated_scheduled_requests.into_iter().for_each(|(collator, scheduled_requests)| { @@ -363,7 +363,7 @@ impl Pallet { state.status = DelegatorStatus::Active; >::insert(delegator.clone(), state.clone()); Self::deposit_event(Event::DelegatorExitCancelled { delegator }); - return Ok(().into()) + return Ok(().into()); } // pre-validate that all delegations have a Revoke request. @@ -424,7 +424,7 @@ impl Pallet { } >::remove(&delegator); Self::deposit_event(Event::DelegatorLeft { delegator, unstaked_amount: state.total }); - return Ok(().into()) + return Ok(().into()); } let mut validated_scheduled_requests = vec![]; diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index 2eec4fe0c..8535de394 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -1454,12 +1454,12 @@ pub mod pallet { // payout is now - delay rounds ago => now - delay > 0 else return early let delay = T::RewardPaymentDelay::get(); if now <= delay { - return Weight::zero() + return Weight::zero(); } let round_to_payout = now.saturating_sub(delay); let total_points = >::get(round_to_payout); if total_points.is_zero() { - return Weight::zero() + return Weight::zero(); } let total_staked = >::take(round_to_payout); let total_issuance = Self::compute_issuance(total_staked); @@ -1501,7 +1501,7 @@ pub mod pallet { // don't underflow uint if now < delay { - return Weight::from_parts(0u64, 0) + return Weight::from_parts(0u64, 0); } let paid_for_round = now.saturating_sub(delay); @@ -1544,7 +1544,7 @@ pub mod pallet { // 2. we called pay_one_collator_reward when we were actually done with deferred // payouts log::warn!("pay_one_collator_reward called with no > for the round!"); - return (RewardPayment::Finished, early_weight) + return (RewardPayment::Finished, early_weight); } let collator_fee = payout_info.collator_commission; @@ -1559,7 +1559,7 @@ pub mod pallet { // read and kill AwardedPts early_weight = early_weight.saturating_add(T::DbWeight::get().reads_writes(1, 1)); if pts == 0 { - return (RewardPayment::Skipped, early_weight) + return (RewardPayment::Skipped, early_weight); } // 'extra_weight' tracks weight returned from fns that we delegate to which can't be @@ -1631,7 +1631,7 @@ pub mod pallet { pub fn compute_top_candidates() -> Vec { let top_n = >::get() as usize; if top_n == 0 { - return vec![] + return vec![]; } let mut candidates = >::get().0; @@ -1690,7 +1690,7 @@ pub mod pallet { }) } let weight = T::WeightInfo::select_top_candidates(0, 0); - return (weight, collator_count, delegation_count, total) + return (weight, collator_count, delegation_count, total); } // snapshot exposure for round for weighting reward distribution @@ -1834,7 +1834,7 @@ pub mod pallet { let compound_amount = compound_percent.mul_ceil(amount_transferred); if compound_amount.is_zero() { - return weight + return weight; } if let Err(err) = @@ -1846,7 +1846,7 @@ pub mod pallet { delegator, err ); - return weight + return weight; }; weight = weight.saturating_add(T::WeightInfo::delegator_bond_more()); diff --git a/pallets/parachain-staking/src/tests.rs b/pallets/parachain-staking/src/tests.rs index f3302b60e..baf309459 100644 --- a/pallets/parachain-staking/src/tests.rs +++ b/pallets/parachain-staking/src/tests.rs @@ -2516,7 +2516,7 @@ fn execute_delegator_bond_less_updates_just_bottom_delegations() { if &owner == post_owner { if &amount != post_amount { not_equal = true; - break + break; } } } @@ -2528,7 +2528,7 @@ fn execute_delegator_bond_less_updates_just_bottom_delegations() { if &owner == post_owner { if &amount != post_amount { equal = false; - break + break; } } } @@ -2563,7 +2563,7 @@ fn execute_delegator_bond_less_does_not_delete_bottom_delegations() { if &owner == post_owner { if &amount != post_amount { equal = false; - break + break; } } } @@ -2575,7 +2575,7 @@ fn execute_delegator_bond_less_does_not_delete_bottom_delegations() { if &owner == post_owner { if &amount != post_amount { not_equal = true; - break + break; } } } diff --git a/pallets/parachain-staking/src/types.rs b/pallets/parachain-staking/src/types.rs index 0bde3605a..3e962f733 100644 --- a/pallets/parachain-staking/src/types.rs +++ b/pallets/parachain-staking/src/types.rs @@ -134,7 +134,7 @@ impl PartialEq for CollatorSnapshot { fn eq(&self, other: &Self) -> bool { let must_be_true = self.bond == other.bond && self.total == other.total; if !must_be_true { - return false + return false; } for ( BondWithAutoCompound { owner: o1, amount: a1, auto_compound: c1 }, @@ -142,7 +142,7 @@ impl PartialEq for CollatorSnapshot { ) in self.delegations.iter().zip(other.delegations.iter()) { if o1 != o2 || a1 != a2 || c1 != c2 { - return false + return false; } } true @@ -264,7 +264,7 @@ impl PartialEq for CollatorCandidate { fn eq(&self, other: &Self) -> bool { - let must_be_true = self.id == other.id && - self.bond == other.bond && - self.total_counted == other.total_counted && - self.total_backing == other.total_backing && - self.request == other.request && - self.state == other.state; + let must_be_true = self.id == other.id + && self.bond == other.bond + && self.total_counted == other.total_counted + && self.total_backing == other.total_backing + && self.request == other.request + && self.state == other.state; if !must_be_true { - return false + return false; } for (x, y) in self.delegators.0.iter().zip(other.delegators.0.iter()) { if x != y { - return false + return false; } } for (Bond { owner: o1, amount: a1 }, Bond { owner: o2, amount: a2 }) in self.top_delegations.iter().zip(other.top_delegations.iter()) { if o1 != o2 || a1 != a2 { - return false + return false; } } for (Bond { owner: o1, amount: a1 }, Bond { owner: o2, amount: a2 }) in self.bottom_delegations.iter().zip(other.bottom_delegations.iter()) { if o1 != o2 || a1 != a2 { - return false + return false; } } true @@ -1161,18 +1161,18 @@ pub struct Delegator { // Temporary manual implementation for migration testing purposes impl PartialEq for Delegator { fn eq(&self, other: &Self) -> bool { - let must_be_true = self.id == other.id && - self.total == other.total && - self.less_total == other.less_total && - self.status == other.status; + let must_be_true = self.id == other.id + && self.total == other.total + && self.less_total == other.less_total + && self.status == other.status; if !must_be_true { - return false + return false; } for (Bond { owner: o1, amount: a1 }, Bond { owner: o2, amount: a2 }) in self.delegations.0.iter().zip(other.delegations.0.iter()) { if o1 != o2 || a1 != a2 { - return false + return false; } } true @@ -1337,7 +1337,7 @@ impl< >::put(new_total_staked); let nom_st: Delegator> = self.clone().into(); >::insert(&delegator_id, nom_st); - return Ok(in_top) + return Ok(in_top); } } Err(Error::::DelegationDNE.into()) @@ -1366,7 +1366,7 @@ impl< // additional sanity check: shouldn't ever want to lock more than total if amount > self.total { log::warn!("LOGIC ERROR: request to reserve more than bond total"); - return Err(DispatchError::Other("Invalid additional_required_balance")) + return Err(DispatchError::Other("Invalid additional_required_balance")); } }, BondAdjust::Decrease => (), // do nothing on decrease @@ -1496,13 +1496,13 @@ pub mod deprecated { fn eq(&self, other: &Self) -> bool { let must_be_true = self.bond == other.bond && self.total == other.total; if !must_be_true { - return false + return false; } for (Bond { owner: o1, amount: a1 }, Bond { owner: o2, amount: a2 }) in self.delegations.iter().zip(other.delegations.iter()) { if o1 != o2 || a1 != a2 { - return false + return false; } } true diff --git a/pallets/polimec-receiver/src/lib.rs b/pallets/polimec-receiver/src/lib.rs index 1929f4045..e41692fc0 100644 --- a/pallets/polimec-receiver/src/lib.rs +++ b/pallets/polimec-receiver/src/lib.rs @@ -112,7 +112,7 @@ pub mod pallet { let already_executed = ExecutedMigrations::::get((user, participation_type, id)); if already_executed { Self::deposit_event(Event::DuplicatedMigrationSkipped { migration }); - continue + continue; } T::Balances::transfer( &polimec_soverign_account, diff --git a/pallets/xcm-executor/src/lib.rs b/pallets/xcm-executor/src/lib.rs index ed7791baa..951a0202f 100644 --- a/pallets/xcm-executor/src/lib.rs +++ b/pallets/xcm-executor/src/lib.rs @@ -246,7 +246,7 @@ impl ExecuteXcm for XcmExecutor XcmExecutor { let inst_res = recursion_count::using_once(&mut 1, || { recursion_count::with(|count| { if *count > RECURSION_LIMIT { - return Err(XcmError::ExceedsStackLimit) + return Err(XcmError::ExceedsStackLimit); } *count = count.saturating_add(1); Ok(()) @@ -364,10 +364,11 @@ impl XcmExecutor { *r = Err(ExecutorError { index: i as u32, xcm_error: e, weight: Weight::zero() }); } }, - Err(ref mut error) => + Err(ref mut error) => { if let Ok(x) = Config::Weigher::instr_weight(&instr) { error.weight.saturating_accrue(x) - }, + } + }, } } result @@ -895,7 +896,7 @@ impl XcmExecutor { fn take_fee(&mut self, fee: MultiAssets, reason: FeeReason) -> XcmResult { if Config::FeeManager::is_waived(self.origin_ref(), reason) { - return Ok(()) + return Ok(()); } let paid = if self.fees_mode.jit_withdraw { let origin = self.origin_ref().ok_or(XcmError::BadOrigin)?; diff --git a/runtimes/base/src/lib.rs b/runtimes/base/src/lib.rs index a28127d84..ef34cd7f9 100644 --- a/runtimes/base/src/lib.rs +++ b/runtimes/base/src/lib.rs @@ -24,7 +24,10 @@ extern crate frame_benchmarking; use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use frame_support::{ construct_runtime, parameter_types, - traits::{fungible::{Credit, Inspect}, tokens, ConstU32, Contains, EitherOfDiverse, InstanceFilter, PrivilegeCmp}, + traits::{ + fungible::{Credit, Inspect}, + tokens, ConstU32, Contains, EitherOfDiverse, InstanceFilter, PrivilegeCmp, + }, weights::{ConstantMultiplier, Weight}, }; use frame_system::{EnsureRoot, EnsureSigned}; @@ -550,7 +553,7 @@ pub struct EqualOrGreatestRootCmp; impl PrivilegeCmp for EqualOrGreatestRootCmp { fn cmp_privilege(left: &OriginCaller, right: &OriginCaller) -> Option { if left == right { - return Some(Ordering::Equal) + return Some(Ordering::Equal); } match (left, right) { // Root is greater than anything. @@ -832,11 +835,11 @@ mod benches { // Monetary stuff. [pallet_balances, Balances] [pallet_vesting, Vesting] - + // Collator support. [pallet_session, SessionBench::] [pallet_parachain_staking, ParachainStaking] - + // XCM helpers. [cumulus_pallet_xcmp_queue, XcmpQueue] [pallet_xcm, PolkadotXcm] diff --git a/runtimes/shared-configuration/src/fee.rs b/runtimes/shared-configuration/src/fee.rs index 61af74604..42efa3029 100644 --- a/runtimes/shared-configuration/src/fee.rs +++ b/runtimes/shared-configuration/src/fee.rs @@ -138,7 +138,7 @@ where _tip: Self::Balance, ) -> Result { if fee.is_zero() { - return Ok(None) + return Ok(None); } // TODO: This is a temporary workaround. @@ -146,7 +146,7 @@ where // This will probably be included in v1.6 or 1.7. // src: https://github.com/paritytech/polkadot-sdk/pull/2823 if F::can_withdraw(who, fee) != frame_support::traits::tokens::WithdrawConsequence::Success { - return Err(InvalidTransaction::Payment.into()) + return Err(InvalidTransaction::Payment.into()); }; match F::withdraw( diff --git a/runtimes/shared-configuration/src/governance.rs b/runtimes/shared-configuration/src/governance.rs index 39b19e33e..94ca28bbd 100644 --- a/runtimes/shared-configuration/src/governance.rs +++ b/runtimes/shared-configuration/src/governance.rs @@ -109,19 +109,19 @@ parameter_types! { pub const CouncilMotionDuration: BlockNumber = COUNCIL_MOTION_DURATION; pub const CouncilMaxProposals: u32 = 7; pub const CouncilMaxMembers: u32 = 20; - + // Technical Committee pub const TechnicalMotionDuration: BlockNumber = TECHNICAL_MOTION_DURATION; pub const TechnicalMaxProposals: u32 = 7; pub const TechnicalMaxMembers: u32 = 5; - + // Extras pub const PreimageBaseDeposit: Balance = deposit(2, 64); pub const MaxProposals: u32 = 10; pub const MaxVotes: u32 = 100; pub const MaxBlacklisted: u32 = 100; pub const MaxDeposits: u32 = 100; - + //Treasury pub const ProposalBond: Permill = Permill::from_percent(5); pub const ProposalBondMinimum: Balance = 50 * PLMC; diff --git a/runtimes/testnet/src/lib.rs b/runtimes/testnet/src/lib.rs index df46c318b..32497a4b3 100644 --- a/runtimes/testnet/src/lib.rs +++ b/runtimes/testnet/src/lib.rs @@ -25,8 +25,8 @@ use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; use frame_support::{ construct_runtime, ord_parameter_types, parameter_types, traits::{ - fungible::{Credit, Inspect}, tokens, AsEnsureOriginWithArg, ConstU32, Currency, EitherOfDiverse, Everything, PrivilegeCmp, - WithdrawReasons, + fungible::{Credit, Inspect}, + tokens, AsEnsureOriginWithArg, ConstU32, Currency, EitherOfDiverse, Everything, PrivilegeCmp, WithdrawReasons, }, weights::{ConstantMultiplier, Weight}, }; @@ -54,8 +54,8 @@ use sp_runtime::{ ApplyExtrinsicResult, FixedU128, MultiAddress, SaturatedConversion, }; -use pallet_oracle_ocw::types::AssetName; use pallet_democracy::GetElectorate; +use pallet_oracle_ocw::types::AssetName; use sp_std::{cmp::Ordering, prelude::*}; #[cfg(feature = "std")] use sp_version::NativeVersion; @@ -499,7 +499,7 @@ pub struct EqualOrGreatestRootCmp; impl PrivilegeCmp for EqualOrGreatestRootCmp { fn cmp_privilege(left: &OriginCaller, right: &OriginCaller) -> Option { if left == right { - return Some(Ordering::Equal) + return Some(Ordering::Equal); } match (left, right) { // Root is greater than anything. diff --git a/runtimes/testnet/src/xcm_config.rs b/runtimes/testnet/src/xcm_config.rs index ea7e543b0..b8ad26498 100644 --- a/runtimes/testnet/src/xcm_config.rs +++ b/runtimes/testnet/src/xcm_config.rs @@ -129,15 +129,16 @@ pub struct NativeToFungible; impl MaybeEquivalence for NativeToFungible { fn convert(asset: &MultiLocation) -> Option { match asset { - MultiLocation { parents: 1, interior: Here } => - Some(pallet_funding::types::AcceptedFundingAsset::DOT.to_statemint_id()), + MultiLocation { parents: 1, interior: Here } => { + Some(pallet_funding::types::AcceptedFundingAsset::DOT.to_statemint_id()) + }, _ => None, } } fn convert_back(value: &AssetIdPalletAssets) -> Option { if value.is_zero() { - return Some(MultiLocation { parents: 1, interior: Here }) + return Some(MultiLocation { parents: 1, interior: Here }); } None } @@ -259,8 +260,8 @@ impl ContainsPair for StatemintAssetsFilter { // location must be the statemint parachain let loc = MultiLocation::new(1, X1(Parachain(1000))); // asset must be either a fungible asset from `pallet_assets` or the native token of the relay chain - &loc == origin && - match asset { + &loc == origin + && match asset { MultiAsset { id: Concrete(MultiLocation { @@ -279,8 +280,8 @@ impl ContainsPair for StatemintAssetsFilter { impl> ContainsPair for AssetsFrom { fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { let loc = T::get(); - &loc == origin && - matches!(asset, MultiAsset { id: AssetId::Concrete(asset_loc), fun: Fungible(_a) } + &loc == origin + && matches!(asset, MultiAsset { id: AssetId::Concrete(asset_loc), fun: Fungible(_a) } if asset_loc.match_and_split(&loc).is_some()) } } @@ -344,7 +345,7 @@ impl ContainsPair for MultiNativeAsset { fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool { if let Some(ref reserve) = asset.reserve() { if reserve == origin { - return true + return true; } } false From a4a56c8eac8b7f7de2f87fdba61bfb552a491944 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 13 Feb 2024 15:28:33 +0100 Subject: [PATCH 207/212] nightly fmt Signed-off-by: Juan Ignacio Rios --- nodes/parachain/src/chain_spec/testnet.rs | 4 +- nodes/parachain/src/command.rs | 10 +- pallets/democracy/src/lib.rs | 4 +- pallets/democracy/src/vote.rs | 10 +- pallets/democracy/src/vote_threshold.rs | 10 +- pallets/elections-phragmen/src/lib.rs | 8 +- pallets/funding/src/benchmarking.rs | 28 +++--- pallets/funding/src/functions.rs | 99 +++++++++---------- pallets/funding/src/lib.rs | 5 +- pallets/funding/src/mock.rs | 5 +- pallets/funding/src/tests.rs | 84 ++++++++-------- pallets/funding/src/types.rs | 19 ++-- pallets/linear-release/src/types.rs | 4 +- pallets/oracle-ocw/src/lib.rs | 4 +- pallets/oracle-ocw/src/tests.rs | 5 +- .../parachain-staking/src/auto_compound.rs | 5 +- pallets/parachain-staking/src/types.rs | 20 ++-- pallets/xcm-executor/src/lib.rs | 5 +- 18 files changed, 153 insertions(+), 176 deletions(-) diff --git a/nodes/parachain/src/chain_spec/testnet.rs b/nodes/parachain/src/chain_spec/testnet.rs index 935494721..3abca9e79 100644 --- a/nodes/parachain/src/chain_spec/testnet.rs +++ b/nodes/parachain/src/chain_spec/testnet.rs @@ -388,8 +388,8 @@ fn testing_genesis( let funding_percent = 93u64; let project_metadata = default_project(ISSUER.into(), 0u32); let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) - * (project_metadata + let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) * + (project_metadata .minimum_price .checked_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1) .unwrap()); diff --git a/nodes/parachain/src/command.rs b/nodes/parachain/src/command.rs index fcd9cd03e..03dda0d7f 100644 --- a/nodes/parachain/src/command.rs +++ b/nodes/parachain/src/command.rs @@ -262,15 +262,14 @@ pub fn run() -> Result<()> { let runner = cli.create_runner(cmd)?; // Switch on the concrete benchmark sub-command- match cmd { - BenchmarkCmd::Pallet(cmd) => { + BenchmarkCmd::Pallet(cmd) => if cfg!(feature = "runtime-benchmarks") { runner.sync_run(|config| cmd.run::(config)) } else { Err("Benchmarking wasn't enabled when building the node. \ You can enable it with `--features runtime-benchmarks`." .into()) - } - }, + }, BenchmarkCmd::Block(cmd) => runner.sync_run(|config| { let partials = new_partial(&config)?; cmd.run(partials.client) @@ -288,9 +287,8 @@ pub fn run() -> Result<()> { let storage = partials.backend.expose_storage(); cmd.run(config, partials.client.clone(), db, storage) }), - BenchmarkCmd::Machine(cmd) => { - runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())) - }, + BenchmarkCmd::Machine(cmd) => + runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())), // NOTE: this allows the Client to leniently implement // new benchmark commands without requiring a companion MR. #[allow(unreachable_patterns)] diff --git a/pallets/democracy/src/lib.rs b/pallets/democracy/src/lib.rs index b17c7a295..b57ef1eaa 100644 --- a/pallets/democracy/src/lib.rs +++ b/pallets/democracy/src/lib.rs @@ -1591,8 +1591,8 @@ impl Pallet { // of unbaked referendum is bounded by this number. In case those number have changed in a // runtime upgrade the formula should be adjusted but the bound should still be sensible. >::mutate(|ref_index| { - while *ref_index < last - && Self::referendum_info(*ref_index) + while *ref_index < last && + Self::referendum_info(*ref_index) .map_or(true, |info| matches!(info, ReferendumInfo::Finished { .. })) { *ref_index += 1 diff --git a/pallets/democracy/src/vote.rs b/pallets/democracy/src/vote.rs index acb204e82..f7413a2b1 100644 --- a/pallets/democracy/src/vote.rs +++ b/pallets/democracy/src/vote.rs @@ -80,9 +80,8 @@ impl AccountVote { pub fn locked_if(self, approved: bool) -> Option<(u32, Balance)> { // winning side: can only be removed after the lock period ends. match self { - AccountVote::Standard { vote, balance } if vote.aye == approved => { - Some((vote.conviction.lock_periods(), balance)) - }, + AccountVote::Standard { vote, balance } if vote.aye == approved => + Some((vote.conviction.lock_periods(), balance)), _ => None, } } @@ -183,9 +182,8 @@ impl Balance { match self { - Voting::Direct { votes, prior, .. } => { - votes.iter().map(|i| i.1.balance()).fold(prior.locked(), |a, i| a.max(i)) - }, + Voting::Direct { votes, prior, .. } => + votes.iter().map(|i| i.1.balance()).fold(prior.locked(), |a, i| a.max(i)), Voting::Delegating { balance, prior, .. } => *balance.max(&prior.locked()), } } diff --git a/pallets/democracy/src/vote_threshold.rs b/pallets/democracy/src/vote_threshold.rs index fc94cbcd6..0c4081e93 100644 --- a/pallets/democracy/src/vote_threshold.rs +++ b/pallets/democracy/src/vote_threshold.rs @@ -88,12 +88,10 @@ impl< return false; } match *self { - VoteThreshold::SuperMajorityApprove => { - compare_rationals(tally.nays, sqrt_voters, tally.ayes, sqrt_electorate) - }, - VoteThreshold::SuperMajorityAgainst => { - compare_rationals(tally.nays, sqrt_electorate, tally.ayes, sqrt_voters) - }, + VoteThreshold::SuperMajorityApprove => + compare_rationals(tally.nays, sqrt_voters, tally.ayes, sqrt_electorate), + VoteThreshold::SuperMajorityAgainst => + compare_rationals(tally.nays, sqrt_electorate, tally.ayes, sqrt_voters), VoteThreshold::SimpleMajority => tally.ayes > tally.nays, } } diff --git a/pallets/elections-phragmen/src/lib.rs b/pallets/elections-phragmen/src/lib.rs index 9cd96be9c..dd8fec21e 100644 --- a/pallets/elections-phragmen/src/lib.rs +++ b/pallets/elections-phragmen/src/lib.rs @@ -1007,8 +1007,8 @@ impl Pallet { // All candidates/members/runners-up who are no longer retaining a position as a // seat holder will lose their bond. candidates_and_deposit.iter().for_each(|(c, d)| { - if new_members_ids_sorted.binary_search(c).is_err() - && new_runners_up_ids_sorted.binary_search(c).is_err() + if new_members_ids_sorted.binary_search(c).is_err() && + new_runners_up_ids_sorted.binary_search(c).is_err() { let (imbalance, _) = T::Currency::slash(&HoldReason::Candidacy.into(), c, *d); T::LoserCandidate::on_unbalanced(imbalance); @@ -1165,8 +1165,8 @@ impl Pallet { // - Members and candidates sets are disjoint; // - Members and runners-ups sets are disjoint. fn try_state_members_disjoint() -> Result<(), TryRuntimeError> { - match Self::intersects(&Pallet::::members_ids(), &Self::candidates_ids()) - && Self::intersects(&Pallet::::members_ids(), &Self::runners_up_ids()) + match Self::intersects(&Pallet::::members_ids(), &Self::candidates_ids()) && + Self::intersects(&Pallet::::members_ids(), &Self::runners_up_ids()) { true => Err("Members set should be disjoint from candidates and runners-up sets".into()), false => Ok(()), diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index cbdd6cb16..9450890e0 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -602,8 +602,8 @@ mod benchmarks { // if we are going to unbond evaluations due to being over the limit per user, then deduct them from the total expected plmc bond if x >= ::MaxEvaluationsPerUser::get() { - total_expected_plmc_bonded -= plmc_for_existing_evaluations[0].plmc_amount - * (x as u128 - ::MaxEvaluationsPerUser::get() as u128 + 1u128).into(); + total_expected_plmc_bonded -= plmc_for_existing_evaluations[0].plmc_amount * + (x as u128 - ::MaxEvaluationsPerUser::get() as u128 + 1u128).into(); } (inst, test_project_id, extrinsic_evaluation, extrinsic_plmc_bonded, total_expected_plmc_bonded) @@ -635,11 +635,11 @@ mod benchmarks { current_plmc_bond, rewarded_or_slashed, .. - } if project_id == project_id - && evaluator == evaluation.account.clone() - && original_plmc_bond == extrinsic_plmc_bonded - && current_plmc_bond == extrinsic_plmc_bonded - && rewarded_or_slashed.is_none() => {}, + } if project_id == project_id && + evaluator == evaluation.account.clone() && + original_plmc_bond == extrinsic_plmc_bonded && + current_plmc_bond == extrinsic_plmc_bonded && + rewarded_or_slashed.is_none() => {}, _ => assert!(false, "Evaluation is not stored correctly"), } @@ -829,8 +829,8 @@ mod benchmarks { inst.bid_for_users(project_id, vec![bid_params]).unwrap(); - ct_amount = Percent::from_percent(10) - * (project_metadata.total_allocation_size.0 * (do_perform_bid_calls as u128).into()); + ct_amount = Percent::from_percent(10) * + (project_metadata.total_allocation_size.0 * (do_perform_bid_calls as u128).into()); usdt_for_filler_bidder = usdt_for_new_bidder; } let extrinsic_bid = BidParams::new(bidder.clone(), ct_amount, 1_u128.into(), 1u8, AcceptedFundingAsset::USDT); @@ -1112,8 +1112,8 @@ mod benchmarks { let existing_amount: BalanceOf = (50 * ASSET_UNIT).into(); let extrinsic_amount: BalanceOf = if ends_round.is_some() { - project_metadata.total_allocation_size.0 - - existing_amount * (x.min(::MaxContributionsPerUser::get() - 1) as u128).into() + project_metadata.total_allocation_size.0 - + existing_amount * (x.min(::MaxContributionsPerUser::get() - 1) as u128).into() } else { (100 * ASSET_UNIT).into() }; @@ -1230,9 +1230,9 @@ mod benchmarks { match stored_contribution { ContributionInfoOf:: { project_id, contributor, ct_amount, .. } - if project_id == project_id - && contributor == contributor - && ct_amount == extrinsic_contribution.amount => {}, + if project_id == project_id && + contributor == contributor && + ct_amount == extrinsic_contribution.amount => {}, _ => { assert!(false, "Contribution is not stored correctly") }, diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index a3fbf0605..628b81be3 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -205,15 +205,14 @@ impl Pallet { (&project_id, UpdateType::EvaluationEnd), ) { Ok(insertions) => insertions, - Err(insertions) => { + Err(insertions) => return Err(DispatchErrorWithPostInfo { post_info: PostDispatchInfo { actual_weight: Some(WeightInfoOf::::start_evaluation(insertions)), pays_fee: Pays::Yes, }, error: Error::::TooManyInsertionAttempts.into(), - }) - }, + }), }; // * Emit events * @@ -402,7 +401,7 @@ impl Pallet { Ok(iterations) => { remove_attempts = iterations; }, - Err(iterations) => { + Err(iterations) => return Err(DispatchErrorWithPostInfo { post_info: PostDispatchInfo { actual_weight: Some(WeightInfoOf::::start_auction_manually( @@ -412,8 +411,7 @@ impl Pallet { pays_fee: Pays::Yes, }, error: Error::::ProjectNotInUpdateStore.into(), - }) - }, + }), } } // Schedule for automatic transition to candle auction round @@ -422,7 +420,7 @@ impl Pallet { Ok(iterations) => { insertion_attempts = iterations; }, - Err(insertion_attempts) => { + Err(insertion_attempts) => return Err(DispatchErrorWithPostInfo { post_info: PostDispatchInfo { actual_weight: if remove_attempts == 0u32 { @@ -433,8 +431,7 @@ impl Pallet { pays_fee: Pays::Yes, }, error: Error::::TooManyInsertionAttempts.into(), - }) - }, + }), }; // * Emit events * @@ -716,9 +713,9 @@ impl Pallet { // * Validity checks * ensure!( - remaining_cts == Zero::zero() - || project_details.status == ProjectStatus::FundingFailed - || matches!(remainder_end_block, Some(end_block) if now > end_block), + remaining_cts == Zero::zero() || + project_details.status == ProjectStatus::FundingFailed || + matches!(remainder_end_block, Some(end_block) if now > end_block), Error::::TooEarlyForFundingEnd ); @@ -842,8 +839,8 @@ impl Pallet { // * Validity checks * ensure!( - project_details.status == ProjectStatus::FundingSuccessful - || project_details.status == ProjectStatus::FundingFailed, + project_details.status == ProjectStatus::FundingSuccessful || + project_details.status == ProjectStatus::FundingFailed, Error::::NotAllowed ); @@ -1249,8 +1246,8 @@ impl Pallet { ensure!(project_metadata.participation_currencies == asset, Error::::FundingAssetNotAccepted); ensure!(contributor.clone() != project_details.issuer, Error::::ContributionToThemselves); ensure!( - project_details.status == ProjectStatus::CommunityRound - || project_details.status == ProjectStatus::RemainderRound, + project_details.status == ProjectStatus::CommunityRound || + project_details.status == ProjectStatus::RemainderRound, Error::::AuctionNotStarted ); @@ -1461,13 +1458,12 @@ impl Pallet { remaining_contribution_tokens: (BalanceOf, BalanceOf), ) -> BalanceOf { match status { - ProjectStatus::CommunityRound => { + ProjectStatus::CommunityRound => if amount <= remaining_contribution_tokens.1 { amount } else { remaining_contribution_tokens.1 - } - }, + }, ProjectStatus::RemainderRound => { let sum = remaining_contribution_tokens.0.saturating_add(remaining_contribution_tokens.1); if sum >= amount { @@ -1499,27 +1495,25 @@ impl Pallet { match Self::remove_from_update_store(&project_id) { Ok(iterations) => remove_attempts = iterations, - Err(iterations) => { + Err(iterations) => return Err(DispatchErrorWithPostInfo { post_info: PostDispatchInfo { actual_weight: Some(WeightInfoOf::::decide_project_outcome(insertion_attempts, iterations)), pays_fee: Pays::Yes, }, error: Error::::TooManyInsertionAttempts.into(), - }) - }, + }), }; match Self::add_to_update_store(now + 1u32.into(), (&project_id, UpdateType::ProjectDecision(decision))) { Ok(iterations) => insertion_attempts = iterations, - Err(iterations) => { + Err(iterations) => return Err(DispatchErrorWithPostInfo { post_info: PostDispatchInfo { actual_weight: Some(WeightInfoOf::::decide_project_outcome(iterations, remove_attempts)), pays_fee: Pays::Yes, }, error: Error::::TooManyInsertionAttempts.into(), - }) - }, + }), }; Self::deposit_event(Event::ProjectOutcomeDecided { project_id, decision }); @@ -1658,9 +1652,9 @@ impl Pallet { // * Validity checks * ensure!( - (project_details.evaluation_round_info.evaluators_outcome == EvaluatorsOutcomeOf::::Unchanged - || released_evaluation.rewarded_or_slashed.is_some()) - && matches!( + (project_details.evaluation_round_info.evaluators_outcome == EvaluatorsOutcomeOf::::Unchanged || + released_evaluation.rewarded_or_slashed.is_some()) && + matches!( project_details.status, ProjectStatus::EvaluationFailed | ProjectStatus::FundingFailed | ProjectStatus::FundingSuccessful ), @@ -1714,8 +1708,8 @@ impl Pallet { // * Validity checks * ensure!( - evaluation.rewarded_or_slashed.is_none() - && matches!(project_details.status, ProjectStatus::FundingSuccessful), + evaluation.rewarded_or_slashed.is_none() && + matches!(project_details.status, ProjectStatus::FundingSuccessful), Error::::NotAllowed ); @@ -1787,8 +1781,8 @@ impl Pallet { // * Validity checks * ensure!( - evaluation.rewarded_or_slashed.is_none() - && matches!(project_details.evaluation_round_info.evaluators_outcome, EvaluatorsOutcome::Slashed), + evaluation.rewarded_or_slashed.is_none() && + matches!(project_details.evaluation_round_info.evaluators_outcome, EvaluatorsOutcome::Slashed), Error::::NotAllowed ); @@ -1837,9 +1831,9 @@ impl Pallet { // * Validity checks * ensure!( - bid.plmc_vesting_info.is_none() - && project_details.status == ProjectStatus::FundingSuccessful - && matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..)), + bid.plmc_vesting_info.is_none() && + project_details.status == ProjectStatus::FundingSuccessful && + matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..)), Error::::NotAllowed ); @@ -1947,8 +1941,8 @@ impl Pallet { // * Validity checks * ensure!( - project_details.status == ProjectStatus::FundingFailed - && matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..)), + project_details.status == ProjectStatus::FundingFailed && + matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..)), Error::::NotAllowed ); @@ -1994,9 +1988,9 @@ impl Pallet { // * Validity checks * ensure!( - project_details.status == ProjectStatus::FundingFailed - && matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..)) - && bid.funds_released, + project_details.status == ProjectStatus::FundingFailed && + matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..)) && + bid.funds_released, Error::::NotAllowed ); @@ -2112,8 +2106,8 @@ impl Pallet { // * Validity checks * ensure!( - project_details.status == ProjectStatus::FundingSuccessful - && matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..)), + project_details.status == ProjectStatus::FundingSuccessful && + matches!(bid.status, BidStatus::Accepted | BidStatus::PartiallyAccepted(..)), Error::::NotAllowed ); @@ -2258,10 +2252,10 @@ impl Pallet { match message { Instruction::HrmpNewChannelOpenRequest { sender, max_message_size, max_capacity } - if max_message_size >= max_message_size_thresholds.0 - && max_message_size <= max_message_size_thresholds.1 - && max_capacity >= max_capacity_thresholds.0 - && max_capacity <= max_capacity_thresholds.1 => + if max_message_size >= max_message_size_thresholds.0 && + max_message_size <= max_message_size_thresholds.1 && + max_capacity >= max_capacity_thresholds.0 && + max_capacity <= max_capacity_thresholds.1 => { log::trace!(target: "pallet_funding::hrmp", "HrmpNewChannelOpenRequest accepted"); @@ -2384,8 +2378,8 @@ impl Pallet { // * Validity checks * ensure!(project_details.status == ProjectStatus::FundingSuccessful, Error::::NotAllowed); ensure!( - project_details.hrmp_channel_status - == HRMPChannelStatus { + project_details.hrmp_channel_status == + HRMPChannelStatus { project_to_polimec: ChannelStatus::Open, polimec_to_project: ChannelStatus::Open }, @@ -2529,15 +2523,14 @@ impl Pallet { ( Response::PalletsInfo(pallets_info), MigrationReadinessCheck { pallet_check: (_, CheckOutcome::AwaitingResponse), .. }, - ) => { + ) => if pallets_info.len() == 1 && pallets_info[0] == T::PolimecReceiverInfo::get() { migration_check.pallet_check.1 = CheckOutcome::Passed; Self::deposit_event(Event::::MigrationCheckResponseAccepted { project_id, query_id, response }); } else { migration_check.pallet_check.1 = CheckOutcome::Failed; Self::deposit_event(Event::::MigrationCheckResponseRejected { project_id, query_id, response }); - } - }, + }, _ => return Err(Error::::NotAllowed.into()), }; @@ -2653,8 +2646,8 @@ impl Pallet { // Self::deposit_event(Event::MigrationsConfirmed { project_id }); Ok(()) }, - Response::DispatchResult(MaybeErrorCode::Error(e)) - | Response::DispatchResult(MaybeErrorCode::TruncatedError(e)) => { + Response::DispatchResult(MaybeErrorCode::Error(e)) | + Response::DispatchResult(MaybeErrorCode::TruncatedError(e)) => { Self::mark_migrations_as_failed(unconfirmed_migrations.clone(), e); Self::deposit_event(Event::MigrationsFailed { project_id, diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index 9a80d576e..d0366fb63 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1441,9 +1441,8 @@ pub mod pallet { let projects_needing_cleanup = ProjectsDetails::::iter() .filter_map(|(project_id, info)| match info.cleanup { - cleaner if >::has_remaining_operations(&cleaner) => { - Some((project_id, cleaner)) - }, + cleaner if >::has_remaining_operations(&cleaner) => + Some((project_id, cleaner)), _ => None, }) .collect::>(); diff --git a/pallets/funding/src/mock.rs b/pallets/funding/src/mock.rs index 6ef8b72a6..e0edaa5c9 100644 --- a/pallets/funding/src/mock.rs +++ b/pallets/funding/src/mock.rs @@ -81,9 +81,8 @@ where { fn try_convert(o: RuntimeOrigin) -> Result { o.try_with_caller(|caller| match caller.try_into() { - Ok(SystemRawOrigin::Signed(who)) => { - Ok(Junction::AccountIndex64 { network: Network::get(), index: who.into() }.into()) - }, + Ok(SystemRawOrigin::Signed(who)) => + Ok(Junction::AccountIndex64 { network: Network::get(), index: who.into() }.into()), Ok(other) => Err(other.into()), Err(other) => Err(other), }) diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index fc3dd904d..e8f1b3322 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -242,8 +242,8 @@ pub mod defaults { pub fn project_from_funding_reached(instantiator: &mut MockInstantiator, percent: u64) -> ProjectId { let project_metadata = default_project(instantiator.get_new_nonce(), ISSUER); let min_price = project_metadata.minimum_price; - let usd_to_reach = Perquintill::from_percent(percent) - * (project_metadata + let usd_to_reach = Perquintill::from_percent(percent) * + (project_metadata .minimum_price .checked_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1) .unwrap()); @@ -622,8 +622,8 @@ mod evaluation_round_failure { let project_metadata = default_project(0, ISSUER); let project_id = inst.create_evaluating_project(project_metadata.clone(), ISSUER); let evaluation_success_threshold = ::EvaluationSuccessThreshold::get(); - let evaluation_min_success_amount = evaluation_success_threshold - * project_metadata.minimum_price.saturating_mul_int( + let evaluation_min_success_amount = evaluation_success_threshold * + project_metadata.minimum_price.saturating_mul_int( project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1, ); let evaluation_fail_amount = evaluation_min_success_amount - 100 * ASSET_UNIT; @@ -2071,9 +2071,9 @@ mod auction_round_failure { inst.bid_for_users(project_id, vec![bid_in]).unwrap(); inst.advance_time( - ::EnglishAuctionDuration::get() - + ::CandleAuctionDuration::get() - - 1, + ::EnglishAuctionDuration::get() + + ::CandleAuctionDuration::get() - + 1, ) .unwrap(); @@ -2518,15 +2518,14 @@ mod community_round_success { assert_eq!( new_plmc_bond_stored, - plmc_bond_stored + MockInstantiator::sum_balance_mappings(vec![new_plmc_funding]) - - plmc_funding[0].plmc_amount + plmc_bond_stored + MockInstantiator::sum_balance_mappings(vec![new_plmc_funding]) - + plmc_funding[0].plmc_amount ); assert_eq!( - new_foreign_asset_contributions_stored, - foreign_asset_contributions_stored - + MockInstantiator::sum_foreign_mappings(vec![new_foreign_funding]) - - foreign_funding[0].asset_amount + new_foreign_asset_contributions_stored, + foreign_asset_contributions_stored + MockInstantiator::sum_foreign_mappings(vec![new_foreign_funding]) - + foreign_funding[0].asset_amount ); } @@ -2634,15 +2633,14 @@ mod community_round_success { assert_eq!( new_plmc_bond_stored, - plmc_bond_stored + MockInstantiator::sum_balance_mappings(vec![new_plmc_funding]) - - plmc_funding[0].plmc_amount + plmc_bond_stored + MockInstantiator::sum_balance_mappings(vec![new_plmc_funding]) - + plmc_funding[0].plmc_amount ); assert_eq!( - new_foreign_asset_contributions_stored, - foreign_asset_contributions_stored - + MockInstantiator::sum_foreign_mappings(vec![new_foreign_funding]) - - foreign_funding[0].asset_amount + new_foreign_asset_contributions_stored, + foreign_asset_contributions_stored + MockInstantiator::sum_foreign_mappings(vec![new_foreign_funding]) - + foreign_funding[0].asset_amount ); } @@ -2772,8 +2770,8 @@ mod community_round_success { let plmc_available_for_participating = plmc_evaluation_amount - ::EvaluatorSlash::get() * plmc_evaluation_amount; assert!( - necessary_plmc_for_contribution > plmc_available_for_participating - && necessary_plmc_for_contribution < plmc_evaluation_amount + necessary_plmc_for_contribution > plmc_available_for_participating && + necessary_plmc_for_contribution < plmc_evaluation_amount ); println!( "Plmc contr: {:?}, plmc eval: {:?}, plmc avail: {:?}", @@ -2813,8 +2811,8 @@ mod community_round_success { let plmc_available_for_participating = plmc_evaluation_amount - ::EvaluatorSlash::get() * plmc_evaluation_amount; assert!( - necessary_plmc_for_contribution > plmc_available_for_participating - && necessary_plmc_for_contribution < plmc_evaluation_amount + necessary_plmc_for_contribution > plmc_available_for_participating && + necessary_plmc_for_contribution < plmc_evaluation_amount ); let necessary_usdt_for_contribution = MockInstantiator::calculate_contributed_funding_asset_spent(vec![contribution.clone()], ct_price); @@ -3383,8 +3381,8 @@ mod remainder_round_success { // Check remaining CTs is 0 assert_eq!( - inst.get_project_details(project_id).remaining_contribution_tokens.0 - + inst.get_project_details(project_id).remaining_contribution_tokens.1, + inst.get_project_details(project_id).remaining_contribution_tokens.0 + + inst.get_project_details(project_id).remaining_contribution_tokens.1, 0, "There are still remaining CTs" ); @@ -3414,8 +3412,8 @@ mod remainder_round_success { ); const BOB: AccountId = 808; - let remaining_ct = inst.get_project_details(project_id).remaining_contribution_tokens.0 - + inst.get_project_details(project_id).remaining_contribution_tokens.1; + let remaining_ct = inst.get_project_details(project_id).remaining_contribution_tokens.0 + + inst.get_project_details(project_id).remaining_contribution_tokens.1; let ct_price = inst.get_project_details(project_id).weighted_average_price.expect("CT Price should exist"); @@ -3438,8 +3436,8 @@ mod remainder_round_success { // Check remaining CTs is 0 assert_eq!( - inst.get_project_details(project_id).remaining_contribution_tokens.0 - + inst.get_project_details(project_id).remaining_contribution_tokens.1, + inst.get_project_details(project_id).remaining_contribution_tokens.0 + + inst.get_project_details(project_id).remaining_contribution_tokens.1, 0, "There are still remaining CTs" ); @@ -3826,8 +3824,8 @@ mod funding_end { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let project_metadata = default_project(inst.get_new_nonce(), ISSUER); let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) - * (project_metadata.minimum_price.checked_mul_int(project_metadata.total_allocation_size.0).unwrap()); + let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) * + (project_metadata.minimum_price.checked_mul_int(project_metadata.total_allocation_size.0).unwrap()); let evaluations = default_evaluations(); let bids = MockInstantiator::generate_bids_from_total_usd( Percent::from_percent(50u8) * twenty_percent_funding_usd, @@ -3855,8 +3853,8 @@ mod funding_end { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let project_metadata = default_project(inst.get_new_nonce(), ISSUER); let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) - * (project_metadata + let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) * + (project_metadata .minimum_price .checked_mul_int( project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1, @@ -3889,8 +3887,8 @@ mod funding_end { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let project_metadata = default_project(inst.get_new_nonce(), ISSUER); let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) - * (project_metadata + let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) * + (project_metadata .minimum_price .checked_mul_int( project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1, @@ -3922,8 +3920,8 @@ mod funding_end { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let project_metadata = default_project(inst.get_new_nonce(), ISSUER); let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(55) - * (project_metadata + let twenty_percent_funding_usd = Perquintill::from_percent(55) * + (project_metadata .minimum_price .checked_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1) .unwrap()); @@ -3971,8 +3969,8 @@ mod funding_end { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let project_metadata = default_project(inst.get_new_nonce(), ISSUER); let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(55) - * (project_metadata + let twenty_percent_funding_usd = Perquintill::from_percent(55) * + (project_metadata .minimum_price .checked_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1) .unwrap()); @@ -4024,8 +4022,8 @@ mod funding_end { let mut inst = MockInstantiator::new(Some(RefCell::new(new_test_ext()))); let project_metadata = default_project(inst.get_new_nonce(), ISSUER); let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(55) - * (project_metadata + let twenty_percent_funding_usd = Perquintill::from_percent(55) * + (project_metadata .minimum_price .checked_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1) .unwrap()); @@ -6009,8 +6007,8 @@ mod async_tests { let funding_percent = 93u64; let project_metadata = default_project(0u64, ISSUER.into()); let min_price = project_metadata.minimum_price; - let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) - * (project_metadata + let twenty_percent_funding_usd = Perquintill::from_percent(funding_percent) * + (project_metadata .minimum_price .checked_mul_int(project_metadata.total_allocation_size.0 + project_metadata.total_allocation_size.1) .unwrap()); diff --git a/pallets/funding/src/types.rs b/pallets/funding/src/types.rs index 08b11f6f5..f760fbbb9 100644 --- a/pallets/funding/src/types.rs +++ b/pallets/funding/src/types.rs @@ -430,20 +430,18 @@ pub mod inner_types { impl ParticipantsSize { pub(crate) const fn is_valid(&self) -> Result<(), ValidityError> { match (self.minimum, self.maximum) { - (Some(min), Some(max)) => { + (Some(min), Some(max)) => if min < max && min > 0 && max > 0 { Ok(()) } else { Err(ValidityError::ParticipantsSizeError) - } - }, - (Some(elem), None) | (None, Some(elem)) => { + }, + (Some(elem), None) | (None, Some(elem)) => if elem > 0 { Ok(()) } else { Err(ValidityError::ParticipantsSizeError) - } - }, + }, (None, None) => Err(ValidityError::ParticipantsSizeError), } } @@ -668,9 +666,8 @@ pub mod inner_types { fn try_from(value: ProjectStatus) -> Result { match value { ProjectStatus::FundingSuccessful => Ok(Cleaner::Success(CleanerState::Initialized(PhantomData))), - ProjectStatus::FundingFailed | ProjectStatus::EvaluationFailed => { - Ok(Cleaner::Failure(CleanerState::Initialized(PhantomData))) - }, + ProjectStatus::FundingFailed | ProjectStatus::EvaluationFailed => + Ok(Cleaner::Failure(CleanerState::Initialized(PhantomData))), _ => Err(()), } } @@ -793,8 +790,8 @@ impl MigrationGenerator { } pub fn bid_migration(bid: BidInfoOf) -> Option { - if bid.final_ct_amount == Zero::zero() - || matches!(bid.ct_migration_status, MigrationStatus::Confirmed | MigrationStatus::Sent(_)) + if bid.final_ct_amount == Zero::zero() || + matches!(bid.ct_migration_status, MigrationStatus::Confirmed | MigrationStatus::Sent(_)) { return None; } diff --git a/pallets/linear-release/src/types.rs b/pallets/linear-release/src/types.rs index 6a422c6a3..afdb779bc 100644 --- a/pallets/linear-release/src/types.rs +++ b/pallets/linear-release/src/types.rs @@ -103,8 +103,8 @@ where // the block after starting. One::one() } else { - self.locked / self.per_block() - + if (self.locked % self.per_block()).is_zero() { + self.locked / self.per_block() + + if (self.locked % self.per_block()).is_zero() { Zero::zero() } else { // `per_block` does not perfectly divide `locked`, so we need an extra block to diff --git a/pallets/oracle-ocw/src/lib.rs b/pallets/oracle-ocw/src/lib.rs index dd08d25ac..f576fb535 100644 --- a/pallets/oracle-ocw/src/lib.rs +++ b/pallets/oracle-ocw/src/lib.rs @@ -154,8 +154,8 @@ pub mod pallet { .filter_map(|(asset_name, last_send)| { let window = T::FetchWindow::get(); let remainder = block_number.rem(T::FetchInterval::get()); - if remainder >= BlockNumberFor::::zero() - && remainder < window && last_send < &block_number.saturating_sub(window) + if remainder >= BlockNumberFor::::zero() && + remainder < window && last_send < &block_number.saturating_sub(window) { return Some(*asset_name); } diff --git a/pallets/oracle-ocw/src/tests.rs b/pallets/oracle-ocw/src/tests.rs index c0812580d..2ba236bcd 100644 --- a/pallets/oracle-ocw/src/tests.rs +++ b/pallets/oracle-ocw/src/tests.rs @@ -36,7 +36,7 @@ fn call_offchain_worker() { assert_eq!(tx.signature.unwrap().0, 0); match tx.call { - RuntimeCall::Oracle(orml_oracle::Call::feed_values { values }) => { + RuntimeCall::Oracle(orml_oracle::Call::feed_values { values }) => for (asset, price) in values { match asset { 0 => assert_close_enough(price, FixedU128::from_float(6.138485575453039783)), @@ -44,8 +44,7 @@ fn call_offchain_worker() { 1337 => assert_close_enough(price, FixedU128::from_float(1.000093378020633965)), _ => panic!("Unexpected asset"), } - } - }, + }, _ => panic!("Unexpected call"), } }); diff --git a/pallets/parachain-staking/src/auto_compound.rs b/pallets/parachain-staking/src/auto_compound.rs index b030e74ee..8bb04ca8c 100644 --- a/pallets/parachain-staking/src/auto_compound.rs +++ b/pallets/parachain-staking/src/auto_compound.rs @@ -86,14 +86,13 @@ where /// vector for binary_search to work. pub fn set_for_delegator(&mut self, delegator: T::AccountId, value: Percent) -> Result> { match self.0.binary_search_by(|d| d.delegator.cmp(&delegator)) { - Ok(index) => { + Ok(index) => if self.0[index].value == value { Ok(false) } else { self.0[index].value = value; Ok(true) - } - }, + }, Err(index) => { self.0 .try_insert(index, AutoCompoundConfig { delegator, value }) diff --git a/pallets/parachain-staking/src/types.rs b/pallets/parachain-staking/src/types.rs index 3e962f733..96b985012 100644 --- a/pallets/parachain-staking/src/types.rs +++ b/pallets/parachain-staking/src/types.rs @@ -1069,12 +1069,12 @@ impl< // Temporary manual implementation for migration testing purposes impl PartialEq for CollatorCandidate { fn eq(&self, other: &Self) -> bool { - let must_be_true = self.id == other.id - && self.bond == other.bond - && self.total_counted == other.total_counted - && self.total_backing == other.total_backing - && self.request == other.request - && self.state == other.state; + let must_be_true = self.id == other.id && + self.bond == other.bond && + self.total_counted == other.total_counted && + self.total_backing == other.total_backing && + self.request == other.request && + self.state == other.state; if !must_be_true { return false; } @@ -1161,10 +1161,10 @@ pub struct Delegator { // Temporary manual implementation for migration testing purposes impl PartialEq for Delegator { fn eq(&self, other: &Self) -> bool { - let must_be_true = self.id == other.id - && self.total == other.total - && self.less_total == other.less_total - && self.status == other.status; + let must_be_true = self.id == other.id && + self.total == other.total && + self.less_total == other.less_total && + self.status == other.status; if !must_be_true { return false; } diff --git a/pallets/xcm-executor/src/lib.rs b/pallets/xcm-executor/src/lib.rs index e01538f94..3fdb1f323 100644 --- a/pallets/xcm-executor/src/lib.rs +++ b/pallets/xcm-executor/src/lib.rs @@ -364,11 +364,10 @@ impl XcmExecutor { *r = Err(ExecutorError { index: i as u32, xcm_error: e, weight: Weight::zero() }); } }, - Err(ref mut error) => { + Err(ref mut error) => if let Ok(x) = Config::Weigher::instr_weight(&instr) { error.weight.saturating_accrue(x) - } - }, + }, } } result From ce5c5a1b46f39b9d23abe18cf641bfbec8788624 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 13 Feb 2024 15:34:07 +0100 Subject: [PATCH 208/212] update lock Signed-off-by: Juan Ignacio Rios --- Cargo.lock | 728 +++++++++++++++++++++++++++-------------------------- 1 file changed, 367 insertions(+), 361 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c0ea00736..2faa5d0bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -73,23 +73,23 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" +checksum = "891477e0c6a8957309ee5c45a6368af3ae14bb510732d2684ffa19af310920f9" dependencies = [ - "getrandom 0.2.11", + "getrandom 0.2.12", "once_cell", "version_check", ] [[package]] name = "ahash" -version = "0.8.6" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" +checksum = "42cd52102d3df161c77a887b608d7a4897d7cc112886a9537b738a887a03aaff" dependencies = [ "cfg-if", - "getrandom 0.2.11", + "getrandom 0.2.12", "once_cell", "version_check", "zerocopy", @@ -136,9 +136,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.4" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" +checksum = "6e2e1ebcb11de5c03c67de28a7df593d32191b44939c482e97702baaaa6ab6a5" dependencies = [ "anstyle", "anstyle-parse", @@ -150,9 +150,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "anstyle-parse" @@ -165,9 +165,9 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3a318f1f38d2418400f8209655bfd825785afd25aa30bb7ba6cc792e4596748" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" dependencies = [ "windows-sys 0.52.0", ] @@ -184,9 +184,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.75" +version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" +checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca" [[package]] name = "approx" @@ -285,18 +285,18 @@ dependencies = [ [[package]] name = "async-io" -version = "2.2.1" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6d3b15875ba253d1110c740755e246537483f152fa334f91abd7fe84c88b3ff" +checksum = "8f97ab0c5b00a7cdbe5a371b9a782ee7be1316095885c8a4ea1daf490eb0ef65" dependencies = [ - "async-lock 3.2.0", + "async-lock 3.3.0", "cfg-if", "concurrent-queue", "futures-io", "futures-lite", "parking", "polling", - "rustix 0.38.26", + "rustix 0.38.31", "slab", "tracing", "windows-sys 0.52.0", @@ -313,11 +313,11 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7125e42787d53db9dd54261812ef17e937c95a51e4d291373b670342fa44310c" +checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b" dependencies = [ - "event-listener 4.0.0", + "event-listener 4.0.3", "event-listener-strategy", "pin-project-lite 0.2.13", ] @@ -335,9 +335,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.74" +version = "0.1.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" +checksum = "c980ee35e870bd1a4d2c8294d4c04d0499e67bca1e4b5cefcc693c2fa00caea9" dependencies = [ "proc-macro2", "quote", @@ -359,9 +359,9 @@ dependencies = [ [[package]] name = "atomic-polyfill" -version = "0.1.11" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3ff7eb3f316534d83a8a2c3d1674ace8a5a71198eba31e2e2b597833f699b28" +checksum = "8cf2bce30dfe09ef0bfaef228b9d414faaf7e563035494d7fe092dba54b300f4" dependencies = [ "critical-section", ] @@ -394,7 +394,7 @@ dependencies = [ "cfg-if", "libc", "miniz_oxide", - "object 0.32.1", + "object 0.32.2", "rustc-demangle", ] @@ -418,9 +418,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.5" +version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64ct" @@ -467,7 +467,7 @@ dependencies = [ "lazy_static", "lazycell", "peeking_take_while", - "prettyplease 0.2.15", + "prettyplease 0.2.16", "proc-macro2", "quote", "regex", @@ -484,9 +484,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.1" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" [[package]] name = "bitvec" @@ -623,9 +623,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "542f33a8835a0884b006a0c3df3dadd99c0c3f296ed26c2fdc8028e01ad6230c" +checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc" dependencies = [ "memchr", "serde", @@ -660,9 +660,9 @@ checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytemuck" -version = "1.14.0" +version = "1.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" +checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f" [[package]] name = "byteorder" @@ -698,9 +698,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.5" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e34637b3140142bdf929fb439e8aa4ebad7651ebf7b1080b3930aa16ac1459ff" +checksum = "694c8807f2ae16faecc43dc17d74b3eb042482789fd0eb64b39a2e04e087053f" dependencies = [ "serde", ] @@ -713,7 +713,7 @@ checksum = "eee4243f1f26fc7a42710e7439c149e2b10b05472f88090acce52632f231a73a" dependencies = [ "camino", "cargo-platform", - "semver 1.0.20", + "semver 1.0.21", "serde", "serde_json", "thiserror", @@ -740,9 +740,9 @@ dependencies = [ [[package]] name = "cfg-expr" -version = "0.15.5" +version = "0.15.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03915af431787e6ffdcc74c645077518c6b6e01f80b761e0fbbfa288536311b3" +checksum = "fa50868b64a9a6fda9d593ce778849ea8715cd2a3d2cc17ffdb4a2f2f2f1961d" dependencies = [ "smallvec", ] @@ -785,16 +785,16 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.31" +version = "0.4.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "5bc015644b92d5890fab7489e49d21f879d5c990186827d42ec511919404f38b" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.48.5", + "windows-targets 0.52.0", ] [[package]] @@ -832,9 +832,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" +checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" dependencies = [ "glob", "libc", @@ -843,9 +843,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.11" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" +checksum = "80c21025abd42669a92efc996ef13cfb2c5c627858421ea58d5c3b331a6c134f" dependencies = [ "clap_builder", "clap_derive", @@ -853,9 +853,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.11" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" +checksum = "458bf1f341769dfcf849846f65dffdf9146daa56bcd2a47cb4e1de9915567c99" dependencies = [ "anstream", "anstyle", @@ -865,9 +865,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" dependencies = [ "heck", "proc-macro2", @@ -877,19 +877,18 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "coarsetime" -version = "0.1.33" +version = "0.1.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71367d3385c716342014ad17e3d19f7788ae514885a1f4c24f500260fb365e1a" +checksum = "13b3839cf01bb7960114be3ccf2340f541b6d0c81f8690b007b2b39f750f7e5d" dependencies = [ "libc", - "once_cell", - "wasi 0.11.0+wasi-snapshot-preview1", + "wasix", "wasm-bindgen", ] @@ -958,22 +957,22 @@ dependencies = [ [[package]] name = "console" -version = "0.15.7" +version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c926e00cc70edefdc64d3a5ff31cc65bb97a3460097762bd23afb4d8145fccf8" +checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" dependencies = [ "encode_unicode", "lazy_static", "libc", "unicode-width", - "windows-sys 0.45.0", + "windows-sys 0.52.0", ] [[package]] name = "const-oid" -version = "0.9.5" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "const-random" @@ -990,7 +989,7 @@ version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" dependencies = [ - "getrandom 0.2.11", + "getrandom 0.2.12", "once_cell", "tiny-keccak", ] @@ -1053,9 +1052,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" dependencies = [ "libc", ] @@ -1160,9 +1159,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" +checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" dependencies = [ "cfg-if", ] @@ -1175,46 +1174,37 @@ checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" [[package]] name = "crossbeam-deque" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" dependencies = [ - "cfg-if", "crossbeam-epoch", "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" -version = "0.9.15" +version = "0.9.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" dependencies = [ - "autocfg", - "cfg-if", "crossbeam-utils", - "memoffset 0.9.0", - "scopeguard", ] [[package]] name = "crossbeam-queue" -version = "0.3.8" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" +checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35" dependencies = [ - "cfg-if", "crossbeam-utils", ] [[package]] name = "crossbeam-utils" -version = "0.8.16" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a22b2d63d4d1dc0b7f1b6b2747dd0088008a9be28b6ddf0b1e7d335e3037294" -dependencies = [ - "cfg-if", -] +checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" [[package]] name = "crunchy" @@ -1840,9 +1830,9 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.1.1" +version = "4.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89b8c6a2e4b1f45971ad09761aafb85514a84744b67a95e32c3cc1352d1f65c" +checksum = "0a677b8922c94e01bdbb12126b0bc852f00447528dee1782229af9c720c3f348" dependencies = [ "cfg-if", "cpufeatures", @@ -1868,9 +1858,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.110" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7129e341034ecb940c9072817cd9007974ea696844fc4dd582dc1653a7fbe2e8" +checksum = "8aff472b83efd22bfc0176aa8ba34617dd5c17364670eb201a5f06d339b8abf7" dependencies = [ "cc", "cxxbridge-flags", @@ -1880,9 +1870,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.110" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2a24f3f5f8eed71936f21e570436f024f5c2e25628f7496aa7ccd03b90109d5" +checksum = "bcf6e7a52c19013a9a0ec421c7d9c2d1125faf333551227e0a017288d71b47c3" dependencies = [ "cc", "codespan-reporting", @@ -1895,15 +1885,15 @@ dependencies = [ [[package]] name = "cxxbridge-flags" -version = "1.0.110" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06fdd177fc61050d63f67f5bd6351fac6ab5526694ea8e359cd9cd3b75857f44" +checksum = "589e83d02fc1d4fb78f5ad56ca08835341e23499d086d2821315869426d618dc" [[package]] name = "cxxbridge-macro" -version = "1.0.110" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "587663dd5fb3d10932c8aecfe7c844db1bcf0aee93eeab08fac13dc1212c2e7f" +checksum = "e2cb1fd8ffae4230c7cfbbaf3698dbeaf750fa8c5dadf7ed897df581b9b572a5" dependencies = [ "proc-macro2", "quote", @@ -1962,9 +1952,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eb30d70a07a3b04884d2677f06bec33509dc67ca60d92949e5535352d3191dc" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", ] @@ -2204,11 +2194,11 @@ dependencies = [ [[package]] name = "ed25519-dalek" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f628eaec48bfd21b865dc2950cfa014450c01d2fa2b69a86c2fd5844ec523c0" +checksum = "4a3daa8e81a3963a60642bcc1f90a670680bd4a77535faa384e9d1c79d620871" dependencies = [ - "curve25519-dalek 4.1.1", + "curve25519-dalek 4.1.2", "ed25519 2.2.3", "rand_core 0.6.4", "serde", @@ -2233,9 +2223,9 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "elliptic-curve" @@ -2276,18 +2266,18 @@ dependencies = [ [[package]] name = "enumflags2" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5998b4f30320c9d93aed72f63af821bfdac50465b75428fce77b48ec482c3939" +checksum = "3278c9d5fb675e0a51dabcf4c0d355f692b064171535ba72361be1528a9d8e8d" dependencies = [ "enumflags2_derive", ] [[package]] name = "enumflags2_derive" -version = "0.7.8" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246" +checksum = "5c785274071b1b420972453b306eeca06acf4633829db4223b58a2a8c5953bc4" dependencies = [ "proc-macro2", "quote", @@ -2296,9 +2286,9 @@ dependencies = [ [[package]] name = "enumn" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" +checksum = "6fd000fd6988e73bbe993ea3db9b1aa64906ab88766d654973924340c8cddb42" dependencies = [ "proc-macro2", "quote", @@ -2320,9 +2310,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" +checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" dependencies = [ "humantime", "is-terminal", @@ -2361,9 +2351,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener" -version = "4.0.0" +version = "4.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "770d968249b5d99410d61f5bf89057f3199a077a04d087092f58e7d10692baae" +checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e" dependencies = [ "concurrent-queue", "parking", @@ -2376,7 +2366,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" dependencies = [ - "event-listener 4.0.0", + "event-listener 4.0.3", "pin-project-lite 0.2.13", ] @@ -2490,9 +2480,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" +checksum = "1676f435fc1dadde4d03e43f5d62b259e1ce5f40bd4ffb21db2b42ebe59c1382" [[package]] name = "file-per-thread-logger" @@ -2500,7 +2490,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84f2e425d9790201ba4af4630191feac6dcc98765b118d4d18e91d23c2353866" dependencies = [ - "env_logger 0.10.1", + "env_logger 0.10.2", "log", ] @@ -2904,7 +2894,7 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" dependencies = [ - "rustix 0.38.26", + "rustix 0.38.31", "windows-sys 0.48.0", ] @@ -2916,9 +2906,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" +checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" dependencies = [ "futures-channel", "futures-core", @@ -2931,9 +2921,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", "futures-sink", @@ -2941,15 +2931,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" +checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", @@ -2959,15 +2949,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" +checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-lite" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aeee267a1883f7ebef3700f262d2d54de95dfaf38189015a74fdc4e0c7ad8143" +checksum = "445ba825b27408685aaecefd65178908c36c6e96aaf6d8599419d46e624192ba" dependencies = [ "futures-core", "pin-project-lite 0.2.13", @@ -2975,9 +2965,9 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" +checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", @@ -2997,15 +2987,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-timer" @@ -3015,9 +3005,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.29" +version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-channel", "futures-core", @@ -3083,9 +3073,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" dependencies = [ "cfg-if", "libc", @@ -3132,9 +3122,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" dependencies = [ "aho-corasick", - "bstr 1.8.0", + "bstr 1.9.0", "log", - "regex-automata 0.4.3", + "regex-automata 0.4.5", "regex-syntax 0.8.2", ] @@ -3151,9 +3141,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.22" +version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" +checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" dependencies = [ "bytes", "fnv", @@ -3161,7 +3151,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 2.1.0", + "indexmap 2.2.3", "slab", "tokio", "tokio-util", @@ -3212,7 +3202,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.7", + "ahash 0.7.8", ] [[package]] @@ -3221,7 +3211,7 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.8", ] [[package]] @@ -3232,9 +3222,9 @@ checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "heapless" -version = "0.7.16" +version = "0.7.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db04bc24a18b9ea980628ecf00e6c0264f3c1426dac36c00cb49b6fbad8b0743" +checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f" dependencies = [ "atomic-polyfill", "hash32", @@ -3261,9 +3251,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.3" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" +checksum = "d0c62115964e08cb8039170eb33c1d0e2388a256930279edca206fff675f82c3" [[package]] name = "hex" @@ -3325,11 +3315,11 @@ dependencies = [ [[package]] name = "home" -version = "0.5.5" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -3356,9 +3346,9 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", "http", @@ -3391,9 +3381,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.27" +version = "0.14.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468" +checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" dependencies = [ "bytes", "futures-channel", @@ -3406,7 +3396,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite 0.2.13", - "socket2 0.4.10", + "socket2 0.5.5", "tokio", "tower-service", "tracing", @@ -3423,25 +3413,25 @@ dependencies = [ "http", "hyper", "log", - "rustls 0.21.9", + "rustls 0.21.10", "rustls-native-certs", "tokio", "tokio-rustls", - "webpki-roots 0.25.3", + "webpki-roots 0.25.4", ] [[package]] name = "iana-time-zone" -version = "0.1.58" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8326b86b6cff230b97d0d312a6c40a60726df3332e721f72a1b035f451663b20" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "windows-core", + "windows-core 0.52.0", ] [[package]] @@ -3545,9 +3535,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.1.0" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -3555,9 +3545,9 @@ dependencies = [ [[package]] name = "indicatif" -version = "0.17.7" +version = "0.17.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb28741c9db9a713d93deb3bb9515c20788cef5815265bee4980e87bde7e0f25" +checksum = "763a5a8f45087d6bcea4222e7b72c291a054edf80e4ef6efd2a4979878c7bea3" dependencies = [ "console", "instant", @@ -3605,7 +3595,7 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ - "hermit-abi 0.3.3", + "hermit-abi 0.3.5", "libc", "windows-sys 0.48.0", ] @@ -3636,13 +3626,13 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" -version = "0.4.9" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" +checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" dependencies = [ - "hermit-abi 0.3.3", - "rustix 0.38.26", - "windows-sys 0.48.0", + "hermit-abi 0.3.5", + "libc", + "windows-sys 0.52.0", ] [[package]] @@ -3665,24 +3655,24 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "jobserver" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" dependencies = [ "libc", ] [[package]] name = "js-sys" -version = "0.3.66" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" dependencies = [ "wasm-bindgen", ] @@ -3720,7 +3710,7 @@ dependencies = [ "tokio-rustls", "tokio-util", "tracing", - "webpki-roots 0.25.3", + "webpki-roots 0.25.4", ] [[package]] @@ -3833,9 +3823,9 @@ dependencies = [ [[package]] name = "k256" -version = "0.13.2" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f01b677d82ef7a676aa37e099defd83a28e15687112cafdd112d60236b6115b" +checksum = "956ff9b67e26e1a6a866cb758f12c6f8746208489e3e4a4b5580802f2f0a587b" dependencies = [ "cfg-if", "ecdsa", @@ -3846,9 +3836,9 @@ dependencies = [ [[package]] name = "keccak" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" dependencies = [ "cpufeatures", ] @@ -4025,18 +4015,18 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.150" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libloading" -version = "0.7.4" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" dependencies = [ "cfg-if", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -4048,7 +4038,7 @@ dependencies = [ "bytes", "futures", "futures-timer", - "getrandom 0.2.11", + "getrandom 0.2.12", "instant", "libp2p-allow-block-list", "libp2p-connection-limits", @@ -4167,7 +4157,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "276bb57e7af15d8f100d3c11cbdd32c6752b7eef4ba7a18ecf464972c07abcce" dependencies = [ "bs58", - "ed25519-dalek 2.1.0", + "ed25519-dalek 2.1.1", "log", "multiaddr", "multihash", @@ -4438,7 +4428,7 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "libc", "redox_syscall 0.4.1", ] @@ -4508,9 +4498,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.12" +version = "1.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b" +checksum = "037731f5d3aaa87a5675e895b63ddff1a87624bc29f77004ea829809654e48f6" dependencies = [ "cc", "pkg-config", @@ -4558,9 +4548,9 @@ checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" [[package]] name = "linux-raw-sys" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" [[package]] name = "lock_api" @@ -4738,9 +4728,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" [[package]] name = "memfd" @@ -4748,7 +4738,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.38.26", + "rustix 0.38.31", ] [[package]] @@ -4769,15 +4759,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "memoffset" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" -dependencies = [ - "autocfg", -] - [[package]] name = "memory-db" version = "0.32.0" @@ -4818,9 +4799,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" dependencies = [ "adler", ] @@ -5133,13 +5114,19 @@ dependencies = [ [[package]] name = "num-complex" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" +checksum = "23c6602fda94a57c990fe0df199a035d83576b496aa29f4e634a8ac6004e68a6" dependencies = [ "num-traits", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-format" version = "0.4.4" @@ -5152,11 +5139,10 @@ dependencies = [ [[package]] name = "num-integer" -version = "0.1.45" +version = "0.1.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" dependencies = [ - "autocfg", "num-traits", ] @@ -5174,9 +5160,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] @@ -5187,7 +5173,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.3", + "hermit-abi 0.3.5", "libc", ] @@ -5211,9 +5197,9 @@ dependencies = [ [[package]] name = "object" -version = "0.32.1" +version = "0.32.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" dependencies = [ "memchr", ] @@ -5229,9 +5215,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "opaque-debug" @@ -6615,9 +6601,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59e9ab494af9e6e813c72170f0d3c1de1500990d62c97cc05cc7576f91aa402f" +checksum = "592a28a24b09c9dc20ac8afaa6839abc417c720afe42c12e1e4a9d6aa2508d2e" dependencies = [ "blake2", "crc32fast", @@ -6631,6 +6617,7 @@ dependencies = [ "rand 0.8.5", "siphasher", "snap", + "winapi", ] [[package]] @@ -6654,7 +6641,7 @@ version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" dependencies = [ - "proc-macro-crate 2.0.1", + "proc-macro-crate 2.0.2", "proc-macro2", "quote", "syn 1.0.109", @@ -6779,9 +6766,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pest" -version = "2.7.5" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" +checksum = "219c0dcc30b6a27553f9cc242972b67f75b60eb0db71f0b5462f38b058c41546" dependencies = [ "memchr", "thiserror", @@ -6790,9 +6777,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.5" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" +checksum = "22e1288dbd7786462961e69bfd4df7848c1e37e8b74303dbdab82c3a9cdd2809" dependencies = [ "pest", "pest_generator", @@ -6800,9 +6787,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.5" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" +checksum = "1381c29a877c6d34b8c176e734f35d7f7f5b3adaefe940cb4d1bb7af94678e2e" dependencies = [ "pest", "pest_meta", @@ -6813,9 +6800,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.5" +version = "2.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" +checksum = "d0934d6907f148c22a3acbda520c7eed243ad7487a30f51f6ce52b58b7077a8a" dependencies = [ "once_cell", "pest", @@ -6829,23 +6816,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.1.0", + "indexmap 2.2.3", ] [[package]] name = "pin-project" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422" +checksum = "0302c4a0442c456bd56f841aee5c3bfd17967563f6fadc9ceb9f9c23cf3807e0" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" +checksum = "266c042b60c9c76b8d53061e52b2e0d1116abc57cefc8c5cd671619a56ac3690" dependencies = [ "proc-macro2", "quote", @@ -6882,15 +6869,15 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.27" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" +checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" [[package]] name = "platforms" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" +checksum = "626dec3cac7cc0e1577a2ec3fc496277ec2baa084bebad95bb6fdbfae235f84c" [[package]] name = "polimec-base-runtime" @@ -8356,14 +8343,14 @@ dependencies = [ [[package]] name = "polling" -version = "3.3.1" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf63fa624ab313c11656b4cda960bfc46c410187ad493c41f6ba2d8c1e991c9e" +checksum = "30054e72317ab98eddd8561db0f6524df3367636884b7b21b703e4b280a84a14" dependencies = [ "cfg-if", "concurrent-queue", "pin-project-lite 0.2.13", - "rustix 0.38.26", + "rustix 0.38.31", "tracing", "windows-sys 0.52.0", ] @@ -8451,9 +8438,9 @@ dependencies = [ [[package]] name = "prettyplease" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" +checksum = "a41cf62165e97c7f814d2221421dbb9afcbcdb0a88068e5ea206e19951c2cbb5" dependencies = [ "proc-macro2", "syn 2.0.48", @@ -8500,9 +8487,9 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97dc5fea232fc28d2f597b37c4876b348a40e33f3b02cc975c8d006d78d94b1a" +checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" dependencies = [ "toml_datetime", "toml_edit 0.20.2", @@ -8783,7 +8770,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.11", + "getrandom 0.2.12", ] [[package]] @@ -8812,9 +8799,9 @@ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" [[package]] name = "rayon" -version = "1.8.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1" +checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051" dependencies = [ "either", "rayon-core", @@ -8822,9 +8809,9 @@ dependencies = [ [[package]] name = "rayon-core" -version = "1.12.0" +version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" dependencies = [ "crossbeam-deque", "crossbeam-utils", @@ -8866,7 +8853,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ - "getrandom 0.2.11", + "getrandom 0.2.12", "libredox", "thiserror", ] @@ -8886,18 +8873,18 @@ dependencies = [ [[package]] name = "ref-cast" -version = "1.0.20" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acde58d073e9c79da00f2b5b84eed919c8326832648a5b109b3fce1bb1175280" +checksum = "c4846d4c50d1721b1a3bef8af76924eef20d5e723647333798c1b519b3a9473f" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.20" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7473c2cfcf90008193dd0e3e16599455cb601a9fce322b5bb55de799664925" +checksum = "5fddb4f8d99b0a2ebafc65a87a69a7b9875e4b1ae1f00db265d300ef7f28bccc" dependencies = [ "proc-macro2", "quote", @@ -8918,13 +8905,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.2" +version = "1.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.4.3", + "regex-automata 0.4.5", "regex-syntax 0.8.2", ] @@ -8939,9 +8926,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" dependencies = [ "aho-corasick", "memchr", @@ -9002,7 +8989,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "688c63d65483050968b2a8937f7995f443e27041a0f7700aa59b0822aedebb74" dependencies = [ "cc", - "getrandom 0.2.11", + "getrandom 0.2.12", "libc", "spin 0.9.8", "untrusted 0.9.0", @@ -9189,7 +9176,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.20", + "semver 1.0.21", ] [[package]] @@ -9217,14 +9204,14 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.26" +version = "0.38.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9470c4bf8246c8daf25f9598dca807fb6510347b1e1cfa55749113850c79d88a" +checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "errno", "libc", - "linux-raw-sys 0.4.12", + "linux-raw-sys 0.4.13", "windows-sys 0.52.0", ] @@ -9242,9 +9229,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.9" +version = "0.21.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "629648aced5775d558af50b2b4c7b02983a04b312126d45eeead26e7caa498b9" +checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba" dependencies = [ "log", "ring 0.17.7", @@ -9270,7 +9257,7 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ - "base64 0.21.5", + "base64 0.21.7", ] [[package]] @@ -9302,9 +9289,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "safe-mix" @@ -9714,7 +9701,7 @@ name = "sc-consensus-grandpa" version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.8", "array-bytes", "async-trait", "dyn-clone", @@ -9957,7 +9944,7 @@ name = "sc-network-gossip" version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.8", "futures", "futures-timer", "libp2p", @@ -10448,11 +10435,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] @@ -10461,7 +10448,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "772575a524feeb803e5b0fcbc6dd9f367e579488197c94c6e4023aad2305774d" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.8", "cfg-if", "hashbrown 0.13.2", ] @@ -10590,9 +10577,9 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.20" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" dependencies = [ "serde", ] @@ -10605,9 +10592,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.193" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "870026e60fa08c69f064aa766c10f10b1d62db9ccd4d0abb206472bee0ce3b32" dependencies = [ "serde_derive", ] @@ -10624,9 +10611,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.196" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "33c85360c95e7d137454dc81d9a4ed2b8efd8fbe19cee57357b32b9771fccb67" dependencies = [ "proc-macro2", "quote", @@ -10635,9 +10622,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.108" +version = "1.0.113" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79" dependencies = [ "itoa", "ryu", @@ -10646,9 +10633,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" dependencies = [ "serde", ] @@ -10743,9 +10730,9 @@ dependencies = [ [[package]] name = "shlex" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7cee0529a6d40f580e7a5e6c495c8fbfe21b7b52795ed4bb5e62cdf92bc6380" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" @@ -10787,9 +10774,9 @@ dependencies = [ [[package]] name = "similar" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aeaf503862c419d66959f5d7ca015337d864e9c49485d771b732e2a20453597" +checksum = "32fea41aca09ee824cc9724996433064c89f7777e60762749a4170a14abbfa21" dependencies = [ "bstr 0.2.17", "unicode-segmentation", @@ -10849,9 +10836,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.2" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" [[package]] name = "snap" @@ -10861,14 +10848,14 @@ checksum = "1b6b67fb9a61334225b5b790716f609cd58395f895b3fe8b328786812a40bc3b" [[package]] name = "snow" -version = "0.9.4" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58021967fd0a5eeeb23b08df6cc244a4d4a5b4aec1d27c9e02fad1a58b4cd74e" +checksum = "850948bee068e713b8ab860fe1adc4d109676ab4c3b621fd8147f06b261f2f85" dependencies = [ "aes-gcm", "blake2", "chacha20poly1305", - "curve25519-dalek 4.1.1", + "curve25519-dalek 4.1.2", "rand_core 0.6.4", "ring 0.17.7", "rustc_version 0.4.0", @@ -11550,7 +11537,7 @@ name = "sp-trie" version = "22.0.0" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" dependencies = [ - "ahash 0.8.6", + "ahash 0.8.8", "hash-db", "hashbrown 0.13.2", "lazy_static", @@ -11662,9 +11649,9 @@ dependencies = [ [[package]] name = "ss58-registry" -version = "1.44.0" +version = "1.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35935738370302d5e33963665b77541e4b990a3e919ec904c837a56cfc891de1" +checksum = "b1114ee5900b8569bbc8b1a014a942f937b752af4b44f4607430b5f86cedaac0" dependencies = [ "Inflector", "num-format", @@ -11717,9 +11704,9 @@ dependencies = [ [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "strum" @@ -11970,28 +11957,27 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.12" +version = "0.12.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a" +checksum = "69758bda2e78f098e4ccb393021a0963bb3442eac05f135c30f61b7370bbafae" [[package]] name = "tempfile" -version = "3.8.1" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" +checksum = "a365e8cd18e44762ef95d87f284f4b5cd04107fec2ff3052bd6a3e6069669e67" dependencies = [ "cfg-if", "fastrand", - "redox_syscall 0.4.1", - "rustix 0.38.26", - "windows-sys 0.48.0", + "rustix 0.38.31", + "windows-sys 0.52.0", ] [[package]] name = "termcolor" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" dependencies = [ "winapi-util", ] @@ -12004,18 +11990,18 @@ checksum = "3369f5ac52d5eb6ab48c6b4ffdc8efbcad6b89c765749064ba298f2c68a16a76" [[package]] name = "thiserror" -version = "1.0.50" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" +checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.50" +version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" +checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", @@ -12083,12 +12069,13 @@ dependencies = [ [[package]] name = "time" -version = "0.3.30" +version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5" +checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749" dependencies = [ "deranged", "itoa", + "num-conv", "powerfmt", "serde", "time-core", @@ -12103,10 +12090,11 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.15" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20" +checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774" dependencies = [ + "num-conv", "time-core", ] @@ -12155,9 +12143,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.34.0" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" dependencies = [ "backtrace", "bytes", @@ -12200,7 +12188,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.9", + "rustls 0.21.10", "tokio", ] @@ -12267,7 +12255,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.3", "serde", "serde_spanned", "toml_datetime", @@ -12280,7 +12268,7 @@ version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.2.3", "toml_datetime", "winnow", ] @@ -12302,7 +12290,7 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ - "bitflags 2.4.1", + "bitflags 2.4.2", "bytes", "futures-core", "futures-util", @@ -12506,9 +12494,9 @@ dependencies = [ [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "try-runtime-cli" @@ -12590,9 +12578,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.14" +version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" @@ -12611,9 +12599,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" +checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" @@ -12733,11 +12721,20 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" +[[package]] +name = "wasix" +version = "0.12.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1fbb4ef9bbca0c1170e0b00dd28abc9e3b68669821600cad1caaed606583c6d" +dependencies = [ + "wasi 0.11.0+wasi-snapshot-preview1", +] + [[package]] name = "wasm-bindgen" -version = "0.2.89" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -12745,9 +12742,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.89" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" dependencies = [ "bumpalo", "log", @@ -12760,9 +12757,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.39" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" +checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97" dependencies = [ "cfg-if", "js-sys", @@ -12772,9 +12769,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.89" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -12782,9 +12779,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.89" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", @@ -12795,9 +12792,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.89" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" [[package]] name = "wasm-instrument" @@ -12917,7 +12914,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c86437fa68626fe896e5afc69234bb2b5894949083586535f200385adfd71213" dependencies = [ "anyhow", - "base64 0.21.5", + "base64 0.21.7", "bincode", "directories-next", "file-per-thread-logger", @@ -13046,7 +13043,7 @@ dependencies = [ "log", "mach", "memfd", - "memoffset 0.8.0", + "memoffset", "paste", "rand 0.8.5", "rustix 0.36.17", @@ -13070,9 +13067,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.66" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" +checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" dependencies = [ "js-sys", "wasm-bindgen", @@ -13099,9 +13096,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.3" +version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "westend-runtime" @@ -13219,14 +13216,14 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.26", + "rustix 0.38.31", ] [[package]] name = "wide" -version = "0.7.13" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c68938b57b33da363195412cfc5fc37c9ed49aa9cfe2156fde64b8d2c9498242" +checksum = "89beec544f246e679fc25490e3f8e08003bc4bf612068f325120dad4cea02c1c" dependencies = [ "bytemuck", "safe_arch", @@ -13275,7 +13272,7 @@ version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" dependencies = [ - "windows-core", + "windows-core 0.51.1", "windows-targets 0.48.5", ] @@ -13288,6 +13285,15 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets 0.52.0", +] + [[package]] name = "windows-sys" version = "0.45.0" @@ -13488,9 +13494,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.25" +version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e87b8dfbe3baffbe687eef2e164e32286eff31a5ee16463ce03d991643ec94" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" dependencies = [ "memchr", ] @@ -13637,18 +13643,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.7.29" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d075cf85bbb114e933343e087b92f2146bac0d55b534cbb8188becf0039948e" +checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.29" +version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86cd5ca076997b97ef09d3ad65efe811fa68c9e874cb636ccb211223a813b0c2" +checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ "proc-macro2", "quote", From e474500963a5a1d183b244b03cbf4a8160ab204b Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 13 Feb 2024 15:38:04 +0100 Subject: [PATCH 209/212] assethub naming Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 9450890e0..759e35c76 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -777,11 +777,11 @@ mod benchmarks { let existential_deposits: Vec> = vec![bidder.clone()].existential_deposits(); let ct_account_deposits = vec![bidder.clone()].ct_account_deposits(); - let usdt_for_existing_bids: Vec> = + let usdt_for_existing_bids: Vec> = BenchInstantiator::::calculate_auction_funding_asset_spent(&existing_bids_post_bucketing, None); let escrow_account = Pallet::::fund_account_id(project_id); let prev_total_escrow_usdt_locked = - inst.get_free_statemint_asset_balances_for(usdt_id(), vec![escrow_account.clone()]); + inst.get_free_foreign_asset_balances_for(usdt_id(), vec![escrow_account.clone()]); inst.mint_plmc_to(plmc_for_existing_bids.clone()); inst.mint_plmc_to(existential_deposits.clone()); @@ -797,10 +797,10 @@ mod benchmarks { let mut maybe_filler_bid = None; let new_bidder = account::>("new_bidder", 0, 0); - let mut usdt_for_filler_bidder = vec![UserToStatemintAsset::::new( + let mut usdt_for_filler_bidder = vec![UserToForeignAssets::::new( new_bidder.clone(), Zero::zero(), - AcceptedFundingAsset::USDT.to_statemint_id(), + AcceptedFundingAsset::USDT.to_assethub_id(), )]; if do_perform_bid_calls > 0 { let current_bucket = Buckets::::get(project_id).unwrap(); @@ -840,7 +840,7 @@ mod benchmarks { assert_eq!(extrinsic_bids_post_bucketing.len(), (do_perform_bid_calls as usize).max(1usize)); let plmc_for_extrinsic_bids: Vec> = BenchInstantiator::::calculate_auction_plmc_spent(&extrinsic_bids_post_bucketing, None); - let usdt_for_extrinsic_bids: Vec> = + let usdt_for_extrinsic_bids: Vec> = BenchInstantiator::::calculate_auction_funding_asset_spent(&extrinsic_bids_post_bucketing, None); inst.mint_plmc_to(plmc_for_extrinsic_bids.clone()); inst.mint_statemint_asset_to(usdt_for_extrinsic_bids.clone()); @@ -954,7 +954,7 @@ mod benchmarks { let escrow_account = Pallet::::fund_account_id(project_id); let locked_usdt = - inst.get_free_statemint_asset_balances_for(usdt_id(), vec![escrow_account.clone()])[0].asset_amount; + inst.get_free_foreign_asset_balances_for(usdt_id(), vec![escrow_account.clone()])[0].asset_amount; assert_eq!(locked_usdt, total_usdt_locked); let free_usdt = inst.get_free_foreign_asset_balances_for(usdt_id(), vec![bidder])[0].asset_amount; @@ -1142,8 +1142,7 @@ mod benchmarks { plmc_for_extrinsic_contribution.accounts().ct_account_deposits(); let escrow_account = Pallet::::fund_account_id(project_id); - let prev_total_usdt_locked = - inst.get_free_statemint_asset_balances_for(usdt_id(), vec![escrow_account.clone()]); + let prev_total_usdt_locked = inst.get_free_foreign_asset_balances_for(usdt_id(), vec![escrow_account.clone()]); inst.mint_plmc_to(plmc_for_existing_contributions.clone()); inst.mint_plmc_to(plmc_for_extrinsic_contribution.clone()); @@ -1256,7 +1255,7 @@ mod benchmarks { let escrow_account = Pallet::::fund_account_id(project_id); let locked_usdt = - inst.get_free_statemint_asset_balances_for(usdt_id(), vec![escrow_account.clone()])[0].asset_amount; + inst.get_free_foreign_asset_balances_for(usdt_id(), vec![escrow_account.clone()])[0].asset_amount; assert_eq!(locked_usdt, total_usdt_locked); let free_usdt = inst.get_free_foreign_asset_balances_for(usdt_id(), vec![contributor.clone()])[0].asset_amount; From 633ee9d27d2ba02c4d6115e6534d75469ce96d20 Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Tue, 13 Feb 2024 16:14:12 +0100 Subject: [PATCH 210/212] fixes Signed-off-by: Juan Ignacio Rios --- debug_weight_gen.rs | 53 ----------------------------- nodes/parachain/src/rpc.rs | 2 +- pallets/funding/src/benchmarking.rs | 18 +++++----- pallets/funding/src/functions.rs | 7 +--- pallets/funding/src/instantiator.rs | 2 -- pallets/funding/src/tests.rs | 4 +-- runtimes/base/Cargo.toml | 1 + 7 files changed, 14 insertions(+), 73 deletions(-) delete mode 100644 debug_weight_gen.rs diff --git a/debug_weight_gen.rs b/debug_weight_gen.rs deleted file mode 100644 index 4f6c94870..000000000 --- a/debug_weight_gen.rs +++ /dev/null @@ -1,53 +0,0 @@ - -//! Autogenerated weights for `pallet_funding` -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2024-02-08, STEPS: `20`, REPEAT: `10`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `Juans-MacBook-Pro.local`, CPU: `` -//! EXECUTION: ``, WASM-EXECUTION: `Compiled`, CHAIN: `Some("polimec-rococo-local")`, DB CACHE: 1024 - -// Executed Command: -// target/debug/polimec-parachain-node -// benchmark -// pallet -// --chain=polimec-rococo-local -// --steps=20 -// --repeat=10 -// --pallet=pallet_funding -// --extrinsic=start_settlement_funding_success, -// --output -// ./debug_weight_gen.rs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] -#![allow(missing_docs)] - -use frame_support::{traits::Get, weights::Weight}; -use core::marker::PhantomData; - -/// Weight functions for `pallet_funding`. -pub struct WeightInfo(PhantomData); -impl pallet_funding::WeightInfo for WeightInfo { - /// Storage: `PolimecFunding::ProjectsDetails` (r:1 w:1) - /// Proof: `PolimecFunding::ProjectsDetails` (`max_values`: None, `max_size`: Some(349), added: 2824, mode: `MaxEncodedLen`) - /// Storage: `PolimecFunding::ProjectsMetadata` (r:1 w:0) - /// Proof: `PolimecFunding::ProjectsMetadata` (`max_values`: None, `max_size`: Some(334), added: 2809, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Asset` (r:1 w:1) - /// Proof: `LocalAssets::Asset` (`max_values`: None, `max_size`: Some(210), added: 2685, mode: `MaxEncodedLen`) - /// Storage: `LocalAssets::Metadata` (r:1 w:1) - /// Proof: `LocalAssets::Metadata` (`max_values`: None, `max_size`: Some(140), added: 2615, mode: `MaxEncodedLen`) - /// Storage: `System::Account` (r:1 w:1) - /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) - fn start_settlement_funding_success() -> Weight { - // Proof Size summary in bytes: - // Measured: `970` - // Estimated: `3814` - // Minimum execution time: 542_000_000 picoseconds. - Weight::from_parts(549_000_000, 0) - .saturating_add(Weight::from_parts(0, 3814)) - .saturating_add(T::DbWeight::get().reads(5)) - .saturating_add(T::DbWeight::get().writes(4)) - } -} diff --git a/nodes/parachain/src/rpc.rs b/nodes/parachain/src/rpc.rs index ae8a95ac0..af8a224d5 100644 --- a/nodes/parachain/src/rpc.rs +++ b/nodes/parachain/src/rpc.rs @@ -21,7 +21,7 @@ use std::sync::Arc; use sc_client_api::AuxStore; -pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor}; +pub use sc_rpc::DenyUnsafe; use sc_transaction_pool_api::TransactionPool; use sp_api::ProvideRuntimeApi; use sp_block_builder::BlockBuilder; diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index 759e35c76..df5e3579a 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -40,7 +40,7 @@ use scale_info::prelude::format; use sp_arithmetic::Percent; use sp_core::H256; use sp_io::hashing::blake2_256; -use sp_runtime::traits::{BlakeTwo256, Get, Member}; +use sp_runtime::traits::{BlakeTwo256, Get, Member, TrailingZeroInput}; const METADATA: &str = r#" { @@ -825,7 +825,7 @@ mod benchmarks { inst.mint_plmc_to(plmc_for_new_bidder); inst.mint_plmc_to(plmc_ed); inst.mint_plmc_to(plmc_ct_deposit); - inst.mint_statemint_asset_to(usdt_for_new_bidder.clone()); + inst.mint_foreign_asset_to(usdt_for_new_bidder.clone()); inst.bid_for_users(project_id, vec![bid_params]).unwrap(); @@ -843,7 +843,7 @@ mod benchmarks { let usdt_for_extrinsic_bids: Vec> = BenchInstantiator::::calculate_auction_funding_asset_spent(&extrinsic_bids_post_bucketing, None); inst.mint_plmc_to(plmc_for_extrinsic_bids.clone()); - inst.mint_statemint_asset_to(usdt_for_extrinsic_bids.clone()); + inst.mint_foreign_asset_to(usdt_for_extrinsic_bids.clone()); let total_free_plmc = existential_deposits[0].plmc_amount; let total_plmc_participation_bonded = BenchInstantiator::::sum_balance_mappings(vec![ @@ -851,7 +851,7 @@ mod benchmarks { plmc_for_existing_bids.clone(), ]); let total_free_usdt = Zero::zero(); - let total_escrow_usdt_locked = BenchInstantiator::::sum_statemint_mappings(vec![ + let total_escrow_usdt_locked = BenchInstantiator::::sum_foreign_mappings(vec![ prev_total_escrow_usdt_locked.clone(), usdt_for_extrinsic_bids.clone(), usdt_for_existing_bids.clone(), @@ -1148,8 +1148,8 @@ mod benchmarks { inst.mint_plmc_to(plmc_for_extrinsic_contribution.clone()); inst.mint_plmc_to(existential_deposits.clone()); inst.mint_plmc_to(ct_account_deposits.clone()); - inst.mint_statemint_asset_to(usdt_for_existing_contributions.clone()); - inst.mint_statemint_asset_to(usdt_for_extrinsic_contribution.clone()); + inst.mint_foreign_asset_to(usdt_for_existing_contributions.clone()); + inst.mint_foreign_asset_to(usdt_for_extrinsic_contribution.clone()); // do "x" contributions for this user inst.contribute_for_users(project_id, existing_contributions).expect("All contributions are accepted"); @@ -1158,7 +1158,7 @@ mod benchmarks { plmc_for_existing_contributions.clone(), plmc_for_extrinsic_contribution.clone(), ]); - let mut total_usdt_locked = BenchInstantiator::::sum_statemint_mappings(vec![ + let mut total_usdt_locked = BenchInstantiator::::sum_foreign_mappings(vec![ prev_total_usdt_locked, usdt_for_existing_contributions.clone(), usdt_for_extrinsic_contribution.clone(), @@ -3090,7 +3090,7 @@ mod benchmarks { inst.mint_plmc_to(plmc_needed_for_bids); inst.mint_plmc_to(plmc_ed); inst.mint_plmc_to(plmc_ct_account_deposit); - inst.mint_statemint_asset_to(funding_asset_needed_for_bids); + inst.mint_foreign_asset_to(funding_asset_needed_for_bids); inst.bid_for_users(project_id, accepted_bids).unwrap(); @@ -3124,7 +3124,7 @@ mod benchmarks { inst.mint_plmc_to(plmc_needed_for_bids); inst.mint_plmc_to(plmc_ed); inst.mint_plmc_to(plmc_ct_account_deposit); - inst.mint_statemint_asset_to(funding_asset_needed_for_bids); + inst.mint_foreign_asset_to(funding_asset_needed_for_bids); inst.bid_for_users(project_id, rejected_bids).unwrap(); diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index 628b81be3..e713f66dc 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -43,14 +43,9 @@ use sp_runtime::traits::{Convert, ConvertBack}; use sp_std::{marker::PhantomData, ops::Not}; use xcm::v3::MaxDispatchErrorLen; -use crate::ProjectStatus::FundingSuccessful; -use polimec_common::ReleaseSchedule; - +use super::*; use crate::traits::{BondingRequirementCalculation, ProvideAssetPrice, VestingDurationCalculation}; -use frame_support::traits::fungible::Mutate; use polimec_common::migration_types::{MigrationInfo, MigrationOrigin, Migrations, ParticipationType}; - -use super::*; const POLIMEC_PARA_ID: u32 = 3344u32; const QUERY_RESPONSE_TIME_WINDOW_BLOCKS: u32 = 20u32; diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index fae49dd01..98c287881 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -52,8 +52,6 @@ use sp_std::{ ops::Not, }; -pub use testing_macros::*; - pub type RuntimeOriginOf = ::RuntimeOrigin; pub struct BoxToFunction(pub Box); impl Default for BoxToFunction { diff --git a/pallets/funding/src/tests.rs b/pallets/funding/src/tests.rs index e8f1b3322..d741fe329 100644 --- a/pallets/funding/src/tests.rs +++ b/pallets/funding/src/tests.rs @@ -1872,7 +1872,7 @@ mod auction_round_failure { inst.mint_plmc_to(plmc_for_bidding.clone()); inst.mint_plmc_to(plmc_existential_deposits.clone()); inst.mint_plmc_to(plmc_ct_account_deposits.clone()); - inst.mint_statemint_asset_to(usdt_for_bidding.clone()); + inst.mint_foreign_asset_to(usdt_for_bidding.clone()); inst.bid_for_users(project_id, bids.clone()).unwrap(); @@ -1885,7 +1885,7 @@ mod auction_round_failure { inst.mint_plmc_to(plmc_for_failing_bid.clone()); inst.mint_plmc_to(plmc_existential_deposits.clone()); inst.mint_plmc_to(plmc_ct_account_deposits.clone()); - inst.mint_statemint_asset_to(usdt_for_bidding.clone()); + inst.mint_foreign_asset_to(usdt_for_bidding.clone()); assert_err!(inst.bid_for_users(project_id, vec![failing_bid]), Error::::TooManyBidsForProject); } diff --git a/runtimes/base/Cargo.toml b/runtimes/base/Cargo.toml index 6c93cbe54..5e40e6342 100644 --- a/runtimes/base/Cargo.toml +++ b/runtimes/base/Cargo.toml @@ -194,6 +194,7 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "polimec-xcm-executor/runtime-benchmarks", + "pallet-assets/runtime-benchmarks" ] try-runtime = [ From 7ebf3391458937ca9dbfac92706102784252aa1c Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 14 Feb 2024 12:43:53 +0100 Subject: [PATCH 211/212] remove advance_time performance measurement code Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/instantiator.rs | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/pallets/funding/src/instantiator.rs b/pallets/funding/src/instantiator.rs index 98c287881..09ac8e269 100644 --- a/pallets/funding/src/instantiator.rs +++ b/pallets/funding/src/instantiator.rs @@ -238,50 +238,31 @@ impl< pub fn advance_time(&mut self, amount: BlockNumberFor) -> Result<(), DispatchError> { self.execute(|| { - // time performance - // use std::time::Instant; - // let outer_now = Instant::now(); - // println!("advancing {amount} blocks"); for _block in 0u32..amount.saturated_into() { let mut current_block = frame_system::Pallet::::block_number(); - // let now = Instant::now(); >>::on_finalize(current_block); - // println!("AllPalletsWithoutSystem OnFinalize took {:?}", now.elapsed()); - // let now = Instant::now(); as OnFinalize>>::on_finalize(current_block); - // println!("system OnFinalize took {:?}", now.elapsed()); - // let now = Instant::now(); >>::on_idle(current_block, Weight::MAX); - // println!("AllPalletsWithoutSystem OnIdle took {:?}", now.elapsed()); - // let now = Instant::now(); as OnIdle>>::on_idle(current_block, Weight::MAX); - // println!("system OnIdle took {:?}", now.elapsed()); current_block += One::one(); frame_system::Pallet::::set_block_number(current_block); let pre_events = frame_system::Pallet::::events(); - // let now = Instant::now(); as OnInitialize>>::on_initialize(current_block); - // println!("system OnInitialize took {:?}", now.elapsed()); - // let now = Instant::now(); >>::on_initialize(current_block); - // println!("AllPalletsWithoutSystem OnInitialize took {:?}", now.elapsed()); let post_events = frame_system::Pallet::::events(); if post_events.len() > pre_events.len() { Self::err_if_on_initialize_failed(post_events)?; } } - // println!("advancing {amount} blocks took {:?}", outer_now.elapsed()); - // time per block - // println!("time per block: {:?}", outer_now.elapsed() / amount.saturated_into()); Ok(()) }) } From af9de40e3bb50ba5f01c786bf577ed900b17806d Mon Sep 17 00:00:00 2001 From: Juan Ignacio Rios Date: Wed, 14 Feb 2024 13:04:14 +0100 Subject: [PATCH 212/212] remove unwrap_default for unwrap_or with worst case calculation of weight functions Signed-off-by: Juan Ignacio Rios --- pallets/funding/src/benchmarking.rs | 3 -- pallets/funding/src/functions.rs | 3 +- pallets/funding/src/lib.rs | 61 +++++++++++++++++++++++++---- 3 files changed, 54 insertions(+), 13 deletions(-) diff --git a/pallets/funding/src/benchmarking.rs b/pallets/funding/src/benchmarking.rs index df5e3579a..fd9be7df7 100644 --- a/pallets/funding/src/benchmarking.rs +++ b/pallets/funding/src/benchmarking.rs @@ -3633,9 +3633,6 @@ mod benchmarks { vec![], ); - // let issuer_mint = UserToPLMCBalance::::new(issuer.clone(), (100 * ASSET_UNIT).into()); - // inst.mint_plmc_to(vec![issuer_mint]); - #[block] { Pallet::::do_start_settlement(project_id).unwrap(); diff --git a/pallets/funding/src/functions.rs b/pallets/funding/src/functions.rs index e713f66dc..e7188802f 100644 --- a/pallets/funding/src/functions.rs +++ b/pallets/funding/src/functions.rs @@ -583,7 +583,7 @@ impl Pallet { .update(Some(community_start_block), Some(community_end_block)); project_details.status = ProjectStatus::CommunityRound; ProjectsDetails::::insert(project_id, project_details); - // TODO: return real weights + let insertion_iterations = match Self::add_to_update_store( community_end_block + 1u32.into(), (&project_id, UpdateType::RemainderFundingStart), @@ -3163,7 +3163,6 @@ impl Pallet { project_details.status = ProjectStatus::FundingSuccessful; ProjectsDetails::::insert(project_id, project_details); - // TODO: add real weights let insertion_iterations = match Self::add_to_update_store(now + settlement_delta, (&project_id, UpdateType::StartSettlement)) { Ok(iterations) => iterations, diff --git a/pallets/funding/src/lib.rs b/pallets/funding/src/lib.rs index d0366fb63..07345454b 100644 --- a/pallets/funding/src/lib.rs +++ b/pallets/funding/src/lib.rs @@ -1337,7 +1337,9 @@ pub mod pallet { |e: DispatchErrorWithPostInfo| { e.error } ) .actual_weight - .unwrap_or_default(), + .unwrap_or(WeightInfoOf::::end_evaluation_success( + ::MaxProjectsToUpdateInsertionAttempts::get() - 1, + )), ); }, @@ -1351,7 +1353,10 @@ pub mod pallet { |e: DispatchErrorWithPostInfo| { e.error } ) .actual_weight - .unwrap_or_default(), + .unwrap_or(WeightInfoOf::::start_auction_manually( + ::MaxProjectsToUpdateInsertionAttempts::get() - 1, + 10_000, + )), ); }, @@ -1364,7 +1369,9 @@ pub mod pallet { |e: DispatchErrorWithPostInfo| { e.error } ) .actual_weight - .unwrap_or_default(), + .unwrap_or(WeightInfoOf::::start_candle_phase( + ::MaxProjectsToUpdateInsertionAttempts::get() - 1, + )), ); }, @@ -1377,7 +1384,23 @@ pub mod pallet { |e: DispatchErrorWithPostInfo| { e.error } ) .actual_weight - .unwrap_or_default(), + .unwrap_or( + WeightInfoOf::::start_community_funding_success( + ::MaxProjectsToUpdateInsertionAttempts::get() - 1, + ::MaxBidsPerProject::get() / 2, + ::MaxBidsPerProject::get() / 2, + ) + .max(WeightInfoOf::::start_community_funding_success( + ::MaxProjectsToUpdateInsertionAttempts::get() - 1, + ::MaxBidsPerProject::get(), + 0u32, + )) + .max(WeightInfoOf::::start_community_funding_success( + ::MaxProjectsToUpdateInsertionAttempts::get() - 1, + 0u32, + ::MaxBidsPerProject::get(), + )), + ), ); }, @@ -1390,7 +1413,9 @@ pub mod pallet { |e: DispatchErrorWithPostInfo| { e.error } ) .actual_weight - .unwrap_or_default(), + .unwrap_or(WeightInfoOf::::start_remainder_funding( + ::MaxProjectsToUpdateInsertionAttempts::get() - 1, + )), ); }, @@ -1403,7 +1428,21 @@ pub mod pallet { |e: DispatchErrorWithPostInfo| { e.error } ) .actual_weight - .unwrap_or_default(), + .unwrap_or( + WeightInfoOf::::end_funding_automatically_rejected_evaluators_slashed( + ::MaxProjectsToUpdateInsertionAttempts::get() - 1, + ) + .max(WeightInfoOf::::end_funding_awaiting_decision_evaluators_slashed( + ::MaxProjectsToUpdateInsertionAttempts::get() - 1, + )) + .max(WeightInfoOf::::end_funding_awaiting_decision_evaluators_unchanged( + ::MaxProjectsToUpdateInsertionAttempts::get() - 1, + )) + .max(WeightInfoOf::::end_funding_automatically_accepted_evaluators_rewarded( + ::MaxProjectsToUpdateInsertionAttempts::get() - 1, + ::MaxEvaluationsPerProject::get(), + )), + ), ); }, @@ -1415,7 +1454,10 @@ pub mod pallet { |e: DispatchErrorWithPostInfo| { e.error } ) .actual_weight - .unwrap_or_default(), + .unwrap_or( + WeightInfoOf::::project_decision_accept_funding() + .max(WeightInfoOf::::project_decision_reject_funding()), + ), ); }, @@ -1427,7 +1469,10 @@ pub mod pallet { |e: DispatchErrorWithPostInfo| { e.error } ) .actual_weight - .unwrap_or_default(), + .unwrap_or( + WeightInfoOf::::start_settlement_funding_success() + .max(WeightInfoOf::::start_settlement_funding_failure()), + ), ); }, }