From 5a3978d11465df577ca1a955d92ab7ca381f672d Mon Sep 17 00:00:00 2001 From: didiermis Date: Mon, 25 Mar 2024 11:49:04 -0600 Subject: [PATCH 01/40] - Created a new file `benchmarking.rs` with skeleton structure that will be used for adding benchmarking tests for the Fund Admin pallet. Included a new module for the benchmarks and leveraged several crucial dependencies needed for runtime benchmarks. The benchmarks testing is currently empty and will be filled with individual test cases. - Added the benchmarking module to the Fund Admin pallet's main library file. This facilitates performing benchmarking tests to ensure the optimum performance of the crate. As this action simply involves module addition, there are no significant changes to the existing functionalities. --- pallets/fund-admin/src/benchmarking.rs | 19 +++++++++++++++++++ pallets/fund-admin/src/lib.rs | 2 ++ 2 files changed, 21 insertions(+) create mode 100644 pallets/fund-admin/src/benchmarking.rs diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs new file mode 100644 index 0000000..30c0d3d --- /dev/null +++ b/pallets/fund-admin/src/benchmarking.rs @@ -0,0 +1,19 @@ +//! Fund Admin pallet benchmarking. + +#![cfg(feature = "runtime-benchmarks")] + +use super::*; +use crate::{types::*, Pallet as BitcoinVaults}; +use scale_info::prelude::*; + +use frame_benchmarking::v2::*; +use frame_support::{assert_ok, pallet_prelude::*, traits::Get}; +use frame_system::RawOrigin; +use sp_io::hashing::blake2_256; + + +#[benchmarks(where T: Config)] +mod benchmarks { + use super::*; + +} \ No newline at end of file diff --git a/pallets/fund-admin/src/lib.rs b/pallets/fund-admin/src/lib.rs index 66ec360..16ffae9 100644 --- a/pallets/fund-admin/src/lib.rs +++ b/pallets/fund-admin/src/lib.rs @@ -2,6 +2,8 @@ pub use pallet::*; +mod benchmarking; + #[cfg(test)] mod mock; From bdfb04b774fe46cc0e7be93235ea45960c81de04 Mon Sep 17 00:00:00 2001 From: didiermis Date: Mon, 1 Apr 2024 07:04:23 -0600 Subject: [PATCH 02/40] - Added ./pallets/fund-admin/Cargo.toml to rust-analyzer linked projects and disabled the notification for unlinked files. - Updated source URLs in Cargo.lock to use git protocol instead of https for consistency. --- .vscode/settings.json | 4 ++- Cargo.lock | 76 +++++++++++++++++++++---------------------- 2 files changed, 41 insertions(+), 39 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index b85ed87..815b07d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -14,6 +14,8 @@ "editor.tabSize": 4 }, "rust-analyzer.linkedProjects": [ - "./pallets/confidential-docs/Cargo.toml" + "./pallets/confidential-docs/Cargo.toml", + "./pallets/fund-admin/Cargo.toml" ], + "rust-analyzer.showUnlinkedFileNotification": false, } \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 4d949c7..08cb513 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1108,7 +1108,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-support", "frame-support-procedural", @@ -1145,7 +1145,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "aquamarine", "bitflags 1.3.2", @@ -1185,7 +1185,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "Inflector", "cfg-expr", @@ -1204,7 +1204,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -1216,7 +1216,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "proc-macro2", "quote", @@ -1226,7 +1226,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "cfg-if", "frame-support", @@ -2099,7 +2099,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-benchmarking", "frame-support", @@ -2256,7 +2256,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "docify", "frame-benchmarking", @@ -2276,7 +2276,7 @@ dependencies = [ [[package]] name = "pallet-uniques" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-benchmarking", "frame-support", @@ -3003,7 +3003,7 @@ checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "hash-db", "log", @@ -3024,7 +3024,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "Inflector", "blake2", @@ -3038,7 +3038,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "23.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "scale-info", @@ -3051,7 +3051,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "16.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "integer-sqrt", "num-traits", @@ -3065,7 +3065,7 @@ dependencies = [ [[package]] name = "sp-core" version = "21.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "array-bytes", "bandersnatch_vrfs", @@ -3112,7 +3112,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "9.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "blake2b_simd", "byteorder", @@ -3125,7 +3125,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "9.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "quote", "sp-core-hashing", @@ -3135,7 +3135,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "proc-macro2", "quote", @@ -3145,7 +3145,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.19.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "environmental", "parity-scale-codec", @@ -3156,7 +3156,7 @@ dependencies = [ [[package]] name = "sp-genesis-builder" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "serde_json", "sp-api", @@ -3167,7 +3167,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -3181,7 +3181,7 @@ dependencies = [ [[package]] name = "sp-io" version = "23.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "bytes", "ed25519-dalek", @@ -3205,7 +3205,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.27.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "parking_lot", @@ -3217,7 +3217,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -3228,7 +3228,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "backtrace", "lazy_static", @@ -3238,7 +3238,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "either", "hash256-std-hasher", @@ -3260,7 +3260,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -3278,7 +3278,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "11.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "Inflector", "proc-macro-crate", @@ -3290,7 +3290,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -3304,7 +3304,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.28.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "hash-db", "log", @@ -3325,12 +3325,12 @@ dependencies = [ [[package]] name = "sp-std" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" [[package]] name = "sp-storage" version = "13.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "impl-serde", "parity-scale-codec", @@ -3343,7 +3343,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "async-trait", "parity-scale-codec", @@ -3356,7 +3356,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "10.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "sp-std", @@ -3368,7 +3368,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "22.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "ahash 0.8.6", "hash-db", @@ -3392,7 +3392,7 @@ dependencies = [ [[package]] name = "sp-version" version = "22.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "impl-serde", "parity-scale-codec", @@ -3409,7 +3409,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -3420,7 +3420,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -3433,7 +3433,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "20.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "scale-info", From 7c0cafd772d25ca591bd465afff2060321bfbe04 Mon Sep 17 00:00:00 2001 From: didiermis Date: Mon, 1 Apr 2024 07:08:44 -0600 Subject: [PATCH 03/40] Updated pallet_fund_admin::Config implementation in mock.rs to use pallet_balances::Pallet for the Currency type, added missing import for RawOrigin, and adjusted the test initialization to use FundAdmin::initial_setup(RawOrigin::Root.into()) for configuring initial setup. --- pallets/fund-admin/src/mock.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pallets/fund-admin/src/mock.rs b/pallets/fund-admin/src/mock.rs index 826f564..d93931e 100644 --- a/pallets/fund-admin/src/mock.rs +++ b/pallets/fund-admin/src/mock.rs @@ -1,11 +1,15 @@ use crate as pallet_fund_admin; -use frame_support::parameter_types; +use frame_support::{ + parameter_types, + traits::Currency +}; use frame_system as system; use sp_core::{ConstU64, H256}; use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; +use frame_system::RawOrigin; type Block = frame_system::mocking::MockBlock; use frame_system::EnsureRoot; @@ -101,7 +105,7 @@ impl pallet_fund_admin::Config for Test { type Timestamp = Timestamp; type Moment = u64; type Rbac = RBAC; - type Currency = Balances; + type Currency = pallet_balances::Pallet; type MaxDocuments = MaxDocuments; type MaxProjectsPerUser = MaxProjectsPerUser; @@ -163,6 +167,8 @@ pub fn new_test_ext() -> sp_io::TestExternalities { .assimilate_storage(&mut t) .expect("assimilate_storage failed"); let mut t: sp_io::TestExternalities = t.into(); - t.execute_with(|| FundAdmin::do_initial_setup().expect("Error on configuring initial setup")); + t.execute_with(|| { + FundAdmin::initial_setup(RawOrigin::Root.into()).expect("Error on configuring initial setup"); + }); t } From 089044d1b3d66611d504775b1f441d01b4fdde34 Mon Sep 17 00:00:00 2001 From: didiermis Date: Mon, 1 Apr 2024 07:10:21 -0600 Subject: [PATCH 04/40] - Updated source URLs in Cargo.lock to use git protocol instead of https for consistency. --- Cargo.lock | 76 +++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 08cb513..4d949c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1108,7 +1108,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-support", "frame-support-procedural", @@ -1145,7 +1145,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "aquamarine", "bitflags 1.3.2", @@ -1185,7 +1185,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "Inflector", "cfg-expr", @@ -1204,7 +1204,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -1216,7 +1216,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "proc-macro2", "quote", @@ -1226,7 +1226,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "cfg-if", "frame-support", @@ -2099,7 +2099,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-benchmarking", "frame-support", @@ -2256,7 +2256,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "docify", "frame-benchmarking", @@ -2276,7 +2276,7 @@ dependencies = [ [[package]] name = "pallet-uniques" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-benchmarking", "frame-support", @@ -3003,7 +3003,7 @@ checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "hash-db", "log", @@ -3024,7 +3024,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "Inflector", "blake2", @@ -3038,7 +3038,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "23.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "scale-info", @@ -3051,7 +3051,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "16.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "integer-sqrt", "num-traits", @@ -3065,7 +3065,7 @@ dependencies = [ [[package]] name = "sp-core" version = "21.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "array-bytes", "bandersnatch_vrfs", @@ -3112,7 +3112,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "9.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "blake2b_simd", "byteorder", @@ -3125,7 +3125,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "9.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "quote", "sp-core-hashing", @@ -3135,7 +3135,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "proc-macro2", "quote", @@ -3145,7 +3145,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.19.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "environmental", "parity-scale-codec", @@ -3156,7 +3156,7 @@ dependencies = [ [[package]] name = "sp-genesis-builder" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "serde_json", "sp-api", @@ -3167,7 +3167,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -3181,7 +3181,7 @@ dependencies = [ [[package]] name = "sp-io" version = "23.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "bytes", "ed25519-dalek", @@ -3205,7 +3205,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.27.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "parking_lot", @@ -3217,7 +3217,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -3228,7 +3228,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "backtrace", "lazy_static", @@ -3238,7 +3238,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "either", "hash256-std-hasher", @@ -3260,7 +3260,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -3278,7 +3278,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "11.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "Inflector", "proc-macro-crate", @@ -3290,7 +3290,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -3304,7 +3304,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.28.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "hash-db", "log", @@ -3325,12 +3325,12 @@ dependencies = [ [[package]] name = "sp-std" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" [[package]] name = "sp-storage" version = "13.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "impl-serde", "parity-scale-codec", @@ -3343,7 +3343,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "async-trait", "parity-scale-codec", @@ -3356,7 +3356,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "10.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "sp-std", @@ -3368,7 +3368,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "22.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "ahash 0.8.6", "hash-db", @@ -3392,7 +3392,7 @@ dependencies = [ [[package]] name = "sp-version" version = "22.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "impl-serde", "parity-scale-codec", @@ -3409,7 +3409,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -3420,7 +3420,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -3433,7 +3433,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "20.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "scale-info", From e36ce774d4f9df4610bdc51eca3306d0e51db404 Mon Sep 17 00:00:00 2001 From: didiermis Date: Mon, 1 Apr 2024 07:19:06 -0600 Subject: [PATCH 05/40] - Adjusted new_test_ext() function in mock.rs to remove an unnecessary linebreak and fixed indentation in the execute_with() closure. Additionally, updated the tests in tests.rs to ensure the initialization of the pallet before each test, using FundAdmin::initial_setup(RuntimeOrigin::root()). This ensures proper initialization and execution of tests. --- pallets/fund-admin/src/mock.rs | 3 +- pallets/fund-admin/src/tests.rs | 194 ++++++++++++++++++++++++++++++++ 2 files changed, 195 insertions(+), 2 deletions(-) diff --git a/pallets/fund-admin/src/mock.rs b/pallets/fund-admin/src/mock.rs index d93931e..118d3ba 100644 --- a/pallets/fund-admin/src/mock.rs +++ b/pallets/fund-admin/src/mock.rs @@ -9,7 +9,6 @@ use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, BuildStorage, }; -use frame_system::RawOrigin; type Block = frame_system::mocking::MockBlock; use frame_system::EnsureRoot; @@ -168,7 +167,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { .expect("assimilate_storage failed"); let mut t: sp_io::TestExternalities = t.into(); t.execute_with(|| { - FundAdmin::initial_setup(RawOrigin::Root.into()).expect("Error on configuring initial setup"); + }); t } diff --git a/pallets/fund-admin/src/tests.rs b/pallets/fund-admin/src/tests.rs index 143eac3..c6f51c3 100644 --- a/pallets/fund-admin/src/tests.rs +++ b/pallets/fund-admin/src/tests.rs @@ -484,6 +484,7 @@ fn get_revenue_transaction_id( #[test] fn global_scope_is_created_after_pallet_initialization() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert!(GlobalScope::::exists()); }); } @@ -491,6 +492,7 @@ fn global_scope_is_created_after_pallet_initialization() { #[test] fn cannon_initialize_pallet_twice_shouldnt_work() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_noop!(FundAdmin::initial_setup(RuntimeOrigin::root()), RbacErr::ScopeAlreadyExists); }); } @@ -498,6 +500,7 @@ fn cannon_initialize_pallet_twice_shouldnt_work() { #[test] fn sudo_register_administrator_account_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); let alice_name = make_field_name("Alice Keys"); assert_ok!(FundAdmin::sudo_add_administrator(RuntimeOrigin::root(), 2, alice_name.clone())); assert!(UsersInfo::::contains_key(2)); @@ -507,6 +510,7 @@ fn sudo_register_administrator_account_works() { #[test] fn sudo_a_non_sudo_user_cannot_register_administrator_account_shouldnt_work() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); let alice_name = make_field_name("Alice Keys"); assert_noop!( FundAdmin::sudo_add_administrator(RuntimeOrigin::signed(1), 2, alice_name.clone()), @@ -518,6 +522,7 @@ fn sudo_a_non_sudo_user_cannot_register_administrator_account_shouldnt_work() { #[test] fn sudo_cannot_register_an_administrator_account_twice_shouldnt_work() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); let alice_name = make_field_name("Alice Keys"); assert_ok!(FundAdmin::sudo_add_administrator(RuntimeOrigin::root(), 2, alice_name.clone())); assert_noop!( @@ -530,6 +535,7 @@ fn sudo_cannot_register_an_administrator_account_twice_shouldnt_work() { #[test] fn sudo_delete_administrator_account_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); let alice_name = make_field_name("Alice Keys"); assert_ok!(FundAdmin::sudo_add_administrator(RuntimeOrigin::root(), 2, alice_name.clone())); assert!(FundAdmin::users_info(2).is_some()); @@ -542,6 +548,7 @@ fn sudo_delete_administrator_account_works() { #[test] fn sudo_cannot_delete_an_administrator_account_that_doesnt_exist_shouldnt_work() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_noop!( FundAdmin::sudo_remove_administrator(RuntimeOrigin::root(), 2), Error::::UserNotRegistered @@ -552,6 +559,7 @@ fn sudo_cannot_delete_an_administrator_account_that_doesnt_exist_shouldnt_work() #[test] fn sudo_administrator_can_remove_another_administrator_account_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(FundAdmin::sudo_add_administrator( RuntimeOrigin::root(), 2, @@ -574,6 +582,7 @@ fn sudo_administrator_can_remove_another_administrator_account_works() { #[test] fn sudo_administrator_can_remove_themselves_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(FundAdmin::sudo_add_administrator( RuntimeOrigin::root(), 2, @@ -591,6 +600,7 @@ fn sudo_administrator_can_remove_themselves_works() { #[test] fn balances_main_account_has_an_initial_balance_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); // Get administrator free balance let free_balance = Balances::free_balance(1); assert_eq!(free_balance, InitialAdminBalance::get()); @@ -600,6 +610,7 @@ fn balances_main_account_has_an_initial_balance_works() { #[test] fn balances_any_other_account_should_have_a_zero_balance_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); // Get non-registered user free balance let free_balance = Balances::free_balance(1); let free_balance_2 = Balances::free_balance(2); @@ -614,6 +625,7 @@ fn balances_any_other_account_should_have_a_zero_balance_works() { #[test] fn balances_a_new_registered_user_should_have_a_initial_balance_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::users( @@ -639,6 +651,7 @@ fn balances_a_new_registered_user_should_have_a_initial_balance_works() { #[test] fn balances_an_administrator_goes_out_of_balance_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::users( @@ -675,6 +688,7 @@ fn balances_an_administrator_goes_out_of_balance_should_fail() { #[test] fn balances_an_administrator_does_not_have_anough_free_balance_to_perform_a_user_registration() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::users( @@ -712,6 +726,7 @@ fn balances_an_administrator_does_not_have_anough_free_balance_to_perform_a_user #[test] fn users_register_administrator_account_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::users( @@ -731,6 +746,7 @@ fn users_register_administrator_account_works() { #[test] fn users_register_builder_account_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::users( @@ -750,6 +766,7 @@ fn users_register_builder_account_works() { #[test] fn users_register_investor_account_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::users( @@ -769,6 +786,7 @@ fn users_register_investor_account_works() { #[test] fn users_register_issuer_account_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::users( @@ -788,6 +806,7 @@ fn users_register_issuer_account_works() { #[test] fn users_register_regional_center_account_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::users( @@ -807,6 +826,7 @@ fn users_register_regional_center_account_works() { #[test] fn users_register_multiple_accounts_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::users(RuntimeOrigin::signed(1), make_default_users())); @@ -821,6 +841,7 @@ fn users_register_multiple_accounts_works() { #[test] fn users_a_non_registered_admin_tries_to_register_an_account_shouldnt_work() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_noop!( FundAdmin::users( RuntimeOrigin::signed(1), @@ -839,6 +860,7 @@ fn users_a_non_registered_admin_tries_to_register_an_account_shouldnt_work() { #[test] fn users_a_registered_admin_tries_to_register_an_account_twice_shouldnt_work() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::users( @@ -869,6 +891,7 @@ fn users_a_registered_admin_tries_to_register_an_account_twice_shouldnt_work() { #[test] fn users_update_a_registered_account_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::users( @@ -901,6 +924,7 @@ fn users_update_a_registered_account_works() { #[test] fn users_admnistrator_updates_role_of_a_registered_account_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::users( @@ -932,6 +956,7 @@ fn users_admnistrator_updates_role_of_a_registered_account_works() { #[test] fn users_update_a_non_registered_account_shouldnt_work() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_noop!( @@ -952,6 +977,7 @@ fn users_update_a_non_registered_account_shouldnt_work() { #[test] fn users_delete_a_registered_account_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::users( @@ -976,6 +1002,7 @@ fn users_delete_a_registered_account_works() { #[test] fn users_delete_a_non_registered_account_shouldnt_work() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_noop!( @@ -988,6 +1015,7 @@ fn users_delete_a_non_registered_account_shouldnt_work() { #[test] fn users_user_updates_their_own_account_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::users( @@ -1024,6 +1052,7 @@ fn users_user_updates_their_own_account_works() { #[test] fn users_only_investors_can_upload_documentation_to_their_account_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::users( @@ -1053,6 +1082,7 @@ fn users_only_investors_can_upload_documentation_to_their_account_works() { #[test] fn projects_register_a_project_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::projects_create_project( @@ -1112,6 +1142,7 @@ fn projects_register_a_project_works() { #[test] fn projects_register_a_project_with_job_eligibles_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::projects_create_project( @@ -1147,6 +1178,7 @@ fn projects_register_a_project_with_job_eligibles_works() { #[test] fn projects_register_a_project_with_assigned_users_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::users(RuntimeOrigin::signed(1), make_default_users(),)); @@ -1182,6 +1214,7 @@ fn projects_register_a_project_with_assigned_users_works() { #[test] fn projects_register_a_project_with_allowed_banks_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::projects_create_project( @@ -1212,6 +1245,7 @@ fn projects_register_a_project_with_allowed_banks_works() { #[test] fn projects_register_a_project_without_a_group_id_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_noop!( @@ -1237,6 +1271,7 @@ fn projects_register_a_project_without_a_group_id_should_fail() { #[test] fn projects_a_non_authorized_user_registers_a_project_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::users(RuntimeOrigin::signed(1), make_default_users(),)); @@ -1268,6 +1303,7 @@ fn projects_a_non_authorized_user_registers_a_project_should_fail() { #[test] fn projects_investors_can_be_only_assigned_to_one_project_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::users(RuntimeOrigin::signed(1), make_default_users(),)); @@ -1312,6 +1348,7 @@ fn projects_investors_can_be_only_assigned_to_one_project_should_fail() { #[test] fn projects_edit_a_project_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(register_administrator()); assert_ok!(FundAdmin::users(RuntimeOrigin::signed(1), make_default_users(),)); @@ -1356,6 +1393,7 @@ fn projects_edit_a_project_works() { #[test] fn projects_delete_project_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); assert_eq!(ProjectsInfo::::iter_values().count(), 1); @@ -1398,6 +1436,7 @@ fn projects_delete_project_works() { #[test] fn projects_assign_a_builder_to_a_project_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let builder_data = make_user( @@ -1427,6 +1466,7 @@ fn projects_assign_a_builder_to_a_project_works() { #[test] fn projects_assign_an_investor_to_a_project_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let investor_data = make_user( @@ -1457,6 +1497,7 @@ fn projects_assign_an_investor_to_a_project_works() { #[test] fn projects_assign_an_issuer_to_a_project_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let issuer_data = make_user( @@ -1486,6 +1527,7 @@ fn projects_assign_an_issuer_to_a_project_works() { #[test] fn projects_assign_a_regional_center_to_a_project_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let regional_center_data = make_user( @@ -1516,6 +1558,7 @@ fn projects_assign_a_regional_center_to_a_project_works() { #[test] fn projects_unassign_a_builder_from_a_project_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let builder_data = make_user( @@ -1557,6 +1600,7 @@ fn projects_unassign_a_builder_from_a_project_works() { #[test] fn projects_unassign_an_investor_from_a_project_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let investor_data = make_user( @@ -1599,6 +1643,7 @@ fn projects_unassign_an_investor_from_a_project_works() { #[test] fn projects_unassign_an_issuer_from_a_project_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let issuer_data = make_user( @@ -1640,6 +1685,7 @@ fn projects_unassign_an_issuer_from_a_project_works() { #[test] fn projects_unassign_a_regional_center_from_a_project_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let regional_center_data = make_user( @@ -1682,6 +1728,7 @@ fn projects_unassign_a_regional_center_from_a_project_works() { #[test] fn projects_cannot_assign_a_user_to_a_project_twice_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let builder_data = make_user( @@ -1720,6 +1767,7 @@ fn projects_cannot_assign_a_user_to_a_project_twice_should_fail() { #[test] fn user_cannot_be_assigned_to_a_project_with_a_different_role_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let builder_data = make_user( @@ -1750,6 +1798,7 @@ fn user_cannot_be_assigned_to_a_project_with_a_different_role_should_fail() { #[test] fn projects_a_user_cannot_have_more_than_one_role_in_a_project_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let builder_data = make_user( @@ -1788,6 +1837,7 @@ fn projects_a_user_cannot_have_more_than_one_role_in_a_project_should_fail() { #[test] fn projects_cannot_delete_a_user_who_has_assigned_projects_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let builder_data = make_user( @@ -1822,6 +1872,7 @@ fn projects_cannot_delete_a_user_who_has_assigned_projects_should_fail() { #[test] fn users_cannot_update_user_role_from_an_account_with_assigned_projects_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let builder_data = make_user( @@ -1863,6 +1914,7 @@ fn users_cannot_update_user_role_from_an_account_with_assigned_projects_should_f #[test] fn expenditures_add_a_hard_cost_budget_expenditure_for_a_given_project_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -1924,6 +1976,7 @@ fn expenditures_add_a_hard_cost_budget_expenditure_for_a_given_project_works() { #[test] fn expenditures_add_a_softcost_budget_expenditure_for_a_given_project_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -1985,6 +2038,7 @@ fn expenditures_add_a_softcost_budget_expenditure_for_a_given_project_works() { #[test] fn expenditures_add_an_operational_budget_expenditure_for_a_given_project_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -2046,6 +2100,7 @@ fn expenditures_add_an_operational_budget_expenditure_for_a_given_project_works( #[test] fn expenditures_add_an_others_budget_expenditure_for_a_given_project_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -2107,6 +2162,7 @@ fn expenditures_add_an_others_budget_expenditure_for_a_given_project_works() { #[test] fn expenditures_cannot_send_an_empty_array_of_expenditures_for_a_given_project_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -2128,6 +2184,7 @@ fn expenditures_cannot_send_an_empty_array_of_expenditures_for_a_given_project_s #[test] fn expenditures_cannot_create_a_budget_expenditure_without_a_name_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -2157,6 +2214,7 @@ fn expenditures_cannot_create_a_budget_expenditure_without_a_name_should_fail() #[test] fn expenditures_cannot_create_a_budget_without_expenditure_type_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -2186,6 +2244,7 @@ fn expenditures_cannot_create_a_budget_without_expenditure_type_should_fail() { #[test] fn expenditures_cannot_create_a_budget_expenditute_without_an_amount_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -2215,6 +2274,7 @@ fn expenditures_cannot_create_a_budget_expenditute_without_an_amount_should_fail #[test] fn expenditures_cannot_create_a_budget_expenditure_with_an_empty_name_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -2244,6 +2304,7 @@ fn expenditures_cannot_create_a_budget_expenditure_with_an_empty_name_should_fai #[test] fn expenditures_edit_a_given_expenditure_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -2323,6 +2384,7 @@ fn expenditures_edit_a_given_expenditure_works() { #[test] fn expenditures_edit_a_given_expenditure_from_another_project_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); assert_ok!(FundAdmin::projects_create_project( @@ -2372,6 +2434,7 @@ fn expenditures_edit_a_given_expenditure_from_another_project_should_fail() { #[test] fn expenditures_expenditure_id_is_required_while_editing_a_given_expenditure_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -2418,6 +2481,7 @@ fn expenditures_expenditure_id_is_required_while_editing_a_given_expenditure_sho #[test] fn expenditures_admnistrator_tries_to_update_a_non_existent_expenditure_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -2496,6 +2560,7 @@ fn expenditures_admnistrator_tries_to_update_a_non_existent_expenditure_should_f #[test] fn expenditures_delete_a_selected_expenditure_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -2554,6 +2619,7 @@ fn expenditures_delete_a_selected_expenditure_works() { #[test] fn expenditures_expenditure_id_es_required_to_delete_an_expenditure() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -2601,6 +2667,7 @@ fn expenditures_expenditure_id_es_required_to_delete_an_expenditure() { fn expenditures_an_admin_can_delete_an_expenditure_containing_transactions_with_zero_amount_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -2644,6 +2711,7 @@ fn expenditures_an_admin_can_delete_an_expenditure_containing_transactions_with_ fn expenditures_an_administrator_deletes_an_expenditure_given_a_drawdown_with_multiple_expenditures_work( ) { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -2706,6 +2774,7 @@ fn expenditures_an_administrator_deletes_an_expenditure_given_a_drawdown_with_mu #[test] fn expenditures_an_admin_deletes_all_expenditures_for_a_given_project_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -2792,6 +2861,7 @@ fn expenditures_an_admin_deletes_all_expenditures_for_a_given_project_works() { #[test] fn expenditures_an_admin_cannot_delete_a_expenditure_that_is_being_used_draft_status_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -2833,6 +2903,7 @@ fn expenditures_an_admin_cannot_delete_a_expenditure_that_is_being_used_draft_st #[test] fn expenditures_an_admin_cannot_delete_a_expenditure_that_is_in_use_submitted_status_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -2877,6 +2948,7 @@ fn expenditures_an_admin_cannot_delete_a_expenditure_that_is_in_use_submitted_st #[test] fn expenditures_an_admin_cannot_delete_a_expenditure_that_is_in_use_approved_status_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -2929,6 +3001,7 @@ fn expenditures_an_admin_cannot_delete_a_expenditure_that_is_in_use_approved_sta #[test] fn expenditures_an_admin_cannot_delete_a_expenditure_that_is_in_use_confirmed_status_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -2993,6 +3066,7 @@ fn expenditures_an_admin_cannot_delete_a_expenditure_that_is_in_use_confirmed_st #[test] fn job_eligibles_create_a_job_eligible_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3039,6 +3113,7 @@ fn job_eligibles_create_a_job_eligible_works() { #[test] fn job_eligibles_cannot_send_an_empty_array_of_job_eligibles_for_a_given_project() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3060,6 +3135,7 @@ fn job_eligibles_cannot_send_an_empty_array_of_job_eligibles_for_a_given_project #[test] fn job_eligibles_cannot_create_a_job_eligible_without_a_name_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3088,6 +3164,7 @@ fn job_eligibles_cannot_create_a_job_eligible_without_a_name_should_fail() { #[test] fn job_eligibles_cannot_create_a_job_eligible_without_an_amount_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3116,6 +3193,7 @@ fn job_eligibles_cannot_create_a_job_eligible_without_an_amount_should_fail() { #[test] fn job_eligibles_cannot_create_a_job_eligible_with_an_empty_name_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3144,6 +3222,7 @@ fn job_eligibles_cannot_create_a_job_eligible_with_an_empty_name_should_fail() { #[test] fn job_eligibles_edit_a_job_eligible_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3206,6 +3285,7 @@ fn job_eligibles_edit_a_job_eligible_works() { #[test] fn job_eligibles_edit_a_given_job_eligible_from_another_project_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); assert_ok!(FundAdmin::projects_create_project( @@ -3286,6 +3366,7 @@ fn job_eligibles_edit_a_given_job_eligible_from_another_project_should_fail() { #[test] fn job_eligibles_edit_a_given_job_eligible_with_an_invalid_id_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3330,6 +3411,7 @@ fn job_eligibles_edit_a_given_job_eligible_with_an_invalid_id_should_fail() { #[test] fn job_eligibles_job_eligible_id_is_required_to_update_a_given_job_eligible_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3374,6 +3456,7 @@ fn job_eligibles_job_eligible_id_is_required_to_update_a_given_job_eligible_shou #[test] fn job_eligibles_delete_a_given_job_eligible_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3414,6 +3497,7 @@ fn job_eligibles_delete_a_given_job_eligible_works() { #[test] fn job_eligibles_delete_a_given_job_eligible_with_an_invalid_id_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3452,6 +3536,7 @@ fn job_eligibles_delete_a_given_job_eligible_with_an_invalid_id_should_fail() { #[test] fn job_eligibles_deleting_a_job_eligible_requires_a_job_eligible_id_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3491,6 +3576,7 @@ fn job_eligibles_deleting_a_job_eligible_requires_a_job_eligible_id_should_fail( // fn job_eligibles_admin_cannot_delete_a_job_eligible_if_has_non_zero_transactions_should_fail() fn job_eligibles_admin_can_delete_a_job_eligible_if_has_non_zero_transactions_draft_status_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3527,6 +3613,7 @@ fn job_eligibles_admin_can_delete_a_job_eligible_if_has_non_zero_transactions_dr fn job_eligibles_admin_cannnot_delete_a_job_eligible_if_has_non_zero_transactions_draft_status_should_fail( ) { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3566,6 +3653,7 @@ fn job_eligibles_admin_cannnot_delete_a_job_eligible_if_has_non_zero_transaction fn job_eligibles_an_administrator_deletes_a_job_eligible_given_a_revenue_with_multiple_job_eligibles_works( ) { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3637,6 +3725,7 @@ fn job_eligibles_an_administrator_deletes_a_job_eligible_given_a_revenue_with_mu fn job_eligibles_an_admin_cannot_delete_a_job_eligible_that_is_being_used_draft_status_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3676,6 +3765,7 @@ fn job_eligibles_an_admin_cannot_delete_a_job_eligible_that_is_being_used_draft_ fn job_eligibles_an_admin_cannot_delete_a_job_eligible_that_is_being_used_submitted_status_should_fail( ) { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3716,6 +3806,7 @@ fn job_eligibles_an_admin_cannot_delete_a_job_eligible_that_is_being_used_submit fn job_eligibles_an_admin_cannot_delete_a_job_eligible_that_is_being_used_approved_status_should_fail( ) { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3758,6 +3849,7 @@ fn job_eligibles_an_admin_cannot_delete_a_job_eligible_that_is_being_used_approv #[test] fn drawdowns_drawdowns_are_initialized_correctly_after_a_project_is_created_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_simple_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3783,6 +3875,7 @@ fn drawdowns_drawdowns_are_initialized_correctly_after_a_project_is_created_work #[test] fn drawdowns_a_builder_saves_a_drawdown_as_a_draft_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3827,6 +3920,7 @@ fn drawdowns_a_builder_saves_a_drawdown_as_a_draft_works() { #[test] fn drawdowns_a_user_modifies_a_transaction_in_draft_status_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3875,6 +3969,7 @@ fn drawdowns_a_user_modifies_a_transaction_in_draft_status_works() { #[test] fn drawdowns_a_builder_cannot_submit_a_drawdown_twice_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3928,6 +4023,7 @@ fn drawdowns_a_builder_cannot_submit_a_drawdown_twice_should_fail() { #[test] fn drawdowns_a_user_deletes_a_transaction_in_draft_status_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3970,6 +4066,7 @@ fn drawdowns_a_user_deletes_a_transaction_in_draft_status_works() { fn drawdowns_a_user_cannot_save_transactions_as_draft_if_transactions_are_not_provided_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -3992,6 +4089,7 @@ fn drawdowns_a_user_cannot_save_transactions_as_draft_if_transactions_are_not_pr fn drawdowns_a_user_cannot_send_an_empty_array_of_transactions_when_saving_as_a_draft_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4015,6 +4113,7 @@ fn drawdowns_a_user_cannot_send_an_empty_array_of_transactions_when_saving_as_a_ #[test] fn drawdowns_a_user_cannot_send_a_transaction_without_the_expenditure_id_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4038,6 +4137,7 @@ fn drawdowns_a_user_cannot_send_a_transaction_without_the_expenditure_id_should_ #[test] fn drawdowns_a_user_cannot_create_a_transaction_without_an_amount_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4067,6 +4167,7 @@ fn drawdowns_a_user_cannot_create_a_transaction_without_an_amount_should_fail() #[test] fn drawdowns_transaction_id_is_required_when_editing_a_transaction_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4107,6 +4208,7 @@ fn drawdowns_transaction_id_is_required_when_editing_a_transaction_should_fail() #[test] fn drawdowns_transaction_id_is_required_when_deleting_a_transaction_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4146,6 +4248,7 @@ fn drawdowns_transaction_id_is_required_when_deleting_a_transaction_should_fail( #[test] fn drawdowns_a_user_submits_a_drawdown_for_approval_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4177,6 +4280,7 @@ fn drawdowns_a_user_submits_a_drawdown_for_approval_works() { #[test] fn replicate_overflow_for_a_drawdown_submission() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4221,6 +4325,7 @@ fn replicate_overflow_for_a_drawdown_submission() { #[test] fn drawdowns_a_user_submits_a_draft_drawdown_for_approval_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4263,6 +4368,7 @@ fn drawdowns_a_user_submits_a_draft_drawdown_for_approval_works() { fn drawdowns_a_user_tries_to_add_transactions_using_an_empty_array_before_submitting_the_drawdown_should_fail( ) { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4286,6 +4392,7 @@ fn drawdowns_a_user_tries_to_add_transactions_using_an_empty_array_before_submit #[test] fn drawdowns_a_drawdown_cannot_be_submitted_if_has_no_transactions_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4307,6 +4414,7 @@ fn drawdowns_a_drawdown_cannot_be_submitted_if_has_no_transactions_should_fail() #[test] fn drawdowns_a_builder_deletes_all_transactions_while_submitting_a_drawdown_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4351,6 +4459,7 @@ fn drawdowns_a_builder_deletes_all_transactions_while_submitting_a_drawdown_shou #[test] fn drawdowns_after_a_drawdown_is_submitted_the_status_is_updated_in_project_data_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4382,6 +4491,7 @@ fn drawdowns_after_a_drawdown_is_submitted_the_status_is_updated_in_project_data #[test] fn drawdowns_an_administrators_approves_a_submitted_drawdown_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4421,6 +4531,7 @@ fn drawdowns_an_administrators_approves_a_submitted_drawdown_works() { #[test] fn drawdowns_an_administrator_cannot_aproves_a_drawdown_that_is_not_submitted_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4458,6 +4569,7 @@ fn drawdowns_an_administrator_cannot_aproves_a_drawdown_that_is_not_submitted_sh #[test] fn drawdowns_after_a_drawdown_is_approved_the_next_one_is_generated_autoamtically_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4499,6 +4611,7 @@ fn drawdowns_after_a_drawdown_is_approved_the_next_one_is_generated_autoamticall #[test] fn drawdowns_an_administrator_rejects_a_given_drawdown_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4549,6 +4662,7 @@ fn drawdowns_an_administrator_rejects_a_given_drawdown_works() { #[test] fn drawdowns_an_administrator_cannot_rejects_a_drawdown_that_is_not_submitted_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4591,6 +4705,7 @@ fn drawdowns_an_administrator_cannot_rejects_a_drawdown_that_is_not_submitted_sh #[test] fn drawdowns_an_administrator_cannot_rejects_a_drawdown_without_a_feedback_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4628,6 +4743,7 @@ fn drawdowns_an_administrator_cannot_rejects_a_drawdown_without_a_feedback_shoul #[test] fn drawdowns_an_administrator_rejects_a_eb5_drawdown_with_an_empty_feedback_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4669,6 +4785,7 @@ fn drawdowns_an_administrator_rejects_a_eb5_drawdown_with_an_empty_feedback_shou #[test] fn bulkupload_a_builder_submits_a_construction_loan_drawdown_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4706,6 +4823,7 @@ fn bulkupload_a_builder_submits_a_construction_loan_drawdown_works() { #[test] fn bulkupload_a_builder_submits_a_developer_equity_drawdown_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4743,6 +4861,7 @@ fn bulkupload_a_builder_submits_a_developer_equity_drawdown_works() { #[test] fn bulkupload_a_builder_submits_a_eb5_drawdown_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4770,6 +4889,7 @@ fn bulkupload_a_builder_submits_a_eb5_drawdown_should_fail() { fn bulkupload_a_builder_submits_an_empty_array_of_documents_for_a_construction_loan_drawdown_should_fail( ) { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4797,6 +4917,7 @@ fn bulkupload_a_builder_submits_an_empty_array_of_documents_for_a_construction_l fn bulkupload_a_builder_submits_an_empty_adescription_for_a_construction_loan_drawdown_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4824,6 +4945,7 @@ fn bulkupload_a_builder_submits_an_empty_adescription_for_a_construction_loan_dr fn bulkupload_after_a_contruction_loan_is_submitted_their_status_is_updated_in_project_data_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4853,6 +4975,7 @@ fn bulkupload_after_a_contruction_loan_is_submitted_their_status_is_updated_in_p fn bulkupload_after_a_developer_equity_is_submitted_their_status_is_updated_in_project_data_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4882,6 +5005,7 @@ fn bulkupload_after_a_developer_equity_is_submitted_their_status_is_updated_in_p fn bulkupload_an_administrator_saves_transactions_without_approving_the_drawdown_pseudo_draft_works( ) { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4928,6 +5052,7 @@ fn bulkupload_an_administrator_saves_transactions_without_approving_the_drawdown #[test] fn bulkupload_an_administrator_saves_transactions_and_approves_the_drawdown_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -4975,6 +5100,7 @@ fn bulkupload_an_administrator_saves_transactions_and_approves_the_drawdown_work fn bulkupload_an_array_of_transactions_is_required_to_save_transactions_as_a_pseudo_draft_should_fail( ) { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5006,6 +5132,7 @@ fn bulkupload_an_array_of_transactions_is_required_to_save_transactions_as_a_pse fn bulkupload_an_administrator_sends_an_empty_array_of_transactions_as_a_pseudo_draft_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5038,6 +5165,7 @@ fn bulkupload_an_administrator_sends_an_empty_array_of_transactions_as_a_pseudo_ #[test] fn bulkupload_an_administrator_sends_an_empty_array_while_approving_a_drawdown_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5070,6 +5198,7 @@ fn bulkupload_an_administrator_sends_an_empty_array_while_approving_a_drawdown_s #[test] fn bulkupload_an_administrator_rejects_a_contruction_loan_drawdown_with_a_feedback_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5108,6 +5237,7 @@ fn bulkupload_an_administrator_rejects_a_contruction_loan_drawdown_with_a_feedba #[test] fn bulkupload_an_administrator_rejects_a_developer_equity_drawdown_with_a_feedback_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5146,6 +5276,7 @@ fn bulkupload_an_administrator_rejects_a_developer_equity_drawdown_with_a_feedba #[test] fn bulkupload_an_administrator_rejects_a_bulkupload_drawdown_without_a_feedback_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5176,6 +5307,7 @@ fn bulkupload_an_administrator_rejects_a_bulkupload_drawdown_without_a_feedback_ #[test] fn bulkupload_an_administrator_rejects_a_bulkupload_drawdown_with_an_empty_feedback_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5211,6 +5343,7 @@ fn bulkupload_an_administrator_rejects_a_bulkupload_drawdown_with_an_empty_feedb #[test] fn revenues_are_initialized_correctly_after_a_project_is_created_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5228,6 +5361,7 @@ fn revenues_are_initialized_correctly_after_a_project_is_created_works() { #[test] fn revenues_a_builder_saves_a_revenue_as_draft_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5291,6 +5425,7 @@ fn revenues_a_builder_saves_a_revenue_as_draft_works() { #[test] fn revenues_a_builder_modifies_a_transaction_in_draft_status_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5336,6 +5471,7 @@ fn revenues_a_builder_modifies_a_transaction_in_draft_status_works() { #[test] fn revenues_a_user_deletes_a_transaction_in_draft_status_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5374,6 +5510,7 @@ fn revenues_a_user_deletes_a_transaction_in_draft_status_works() { #[test] fn revenues_a_builder_cannot_submit_a_revenue_if_there_is_no_revenue_transaction_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5396,6 +5533,7 @@ fn revenues_a_builder_cannot_submit_a_revenue_if_there_is_no_revenue_transaction fn revenues_a_user_cannot_submit_a_revenue_as_draft_with_an_empty_array_of_transactions_should_fail( ) { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5419,6 +5557,7 @@ fn revenues_a_user_cannot_submit_a_revenue_as_draft_with_an_empty_array_of_trans #[test] fn revenues_a_user_cannot_create_a_revenue_transaction_with_no_job_eligible_id_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5443,6 +5582,7 @@ fn revenues_a_user_cannot_create_a_revenue_transaction_with_no_job_eligible_id_s #[test] fn revenues_a_user_cannot_create_a_revenue_transaction_with_no_amount_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5468,6 +5608,7 @@ fn revenues_a_user_cannot_create_a_revenue_transaction_with_no_amount_should_fai #[test] fn revenues_transaction_id_is_required_for_updating_a_transaction_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5504,6 +5645,7 @@ fn revenues_transaction_id_is_required_for_updating_a_transaction_should_fail() #[test] fn revenues_transaction_id_is_required_for_deleting_a_transaction_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5540,6 +5682,7 @@ fn revenues_transaction_id_is_required_for_deleting_a_transaction_should_fail() #[test] fn revenues_a_builder_submits_a_revenue_for_approval_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5567,6 +5710,7 @@ fn revenues_a_builder_submits_a_revenue_for_approval_works() { #[test] fn revenues_a_builder_submits_a_draft_revenue_for_approval_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5601,6 +5745,7 @@ fn revenues_a_builder_submits_a_draft_revenue_for_approval_works() { #[test] fn revenues_a_user_tries_to_submit_a_revenue_for_approval_without_being_a_builder_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5626,6 +5771,7 @@ fn revenues_a_user_tries_to_submit_a_revenue_for_approval_without_being_a_builde #[test] fn revenues_a_revenue_cannot_be_submitted_for_approval_if_it_is_already_submitted_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5659,6 +5805,7 @@ fn revenues_a_revenue_cannot_be_submitted_for_approval_if_it_is_already_submitte #[test] fn revenues_a_revenue_cannot_be_submitted_if_has_no_transactions_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5674,6 +5821,7 @@ fn revenues_a_revenue_cannot_be_submitted_if_has_no_transactions_should_fail() { #[test] fn revenues_a_builder_deletes_all_transactions_while_submitting_a_revenue_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5716,6 +5864,7 @@ fn revenues_a_builder_deletes_all_transactions_while_submitting_a_revenue_should #[test] fn revenues_a_builder_tries_to_submit_a_revenue_with_an_empty_array_of_transactions_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5738,6 +5887,7 @@ fn revenues_a_builder_tries_to_submit_a_revenue_with_an_empty_array_of_transacti #[test] fn revenues_after_a_revenue_is_submitted_the_status_is_updated_in_project_data_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5765,6 +5915,7 @@ fn revenues_after_a_revenue_is_submitted_the_status_is_updated_in_project_data_w #[test] fn revenues_an_administrator_approves_a_submitted_revenue_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5791,6 +5942,7 @@ fn revenues_an_administrator_approves_a_submitted_revenue_works() { #[test] fn revenues_an_administrator_cannot_approve_a_revenue_if_it_is_not_submitted_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5806,6 +5958,7 @@ fn revenues_an_administrator_cannot_approve_a_revenue_if_it_is_not_submitted_sho #[test] fn revenues_after_a_revenue_is_submitted_the_next_one_is_generated_automaticaly_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5837,6 +5990,7 @@ fn revenues_after_a_revenue_is_submitted_the_next_one_is_generated_automaticaly_ #[test] fn replicate_overflow_for_a_revenue_submission() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5877,6 +6031,7 @@ fn replicate_overflow_for_a_revenue_submission() { #[test] fn revenues_an_administrator_rejects_a_given_revenue_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5924,6 +6079,7 @@ fn revenues_an_administrator_rejects_a_given_revenue_works() { #[test] fn revenues_an_administrator_cannot_reject_a_revenue_if_it_is_not_submitted_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5962,6 +6118,7 @@ fn revenues_an_administrator_cannot_reject_a_revenue_if_it_is_not_submitted_shou #[test] fn revenues_an_administrator_cannot_reject_a_revenue_with_an_empty_array_of_feedback_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -5996,6 +6153,7 @@ fn revenues_an_administrator_cannot_reject_a_revenue_with_an_empty_array_of_feed #[test] fn revenues_after_a_revenue_is_rejected_the_status_is_updated_in_project_data_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6038,6 +6196,7 @@ fn revenues_after_a_revenue_is_rejected_the_status_is_updated_in_project_data_wo #[test] fn inflation_rate_an_administrator_can_set_the_inflation_rate_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6057,6 +6216,7 @@ fn inflation_rate_an_administrator_can_set_the_inflation_rate_works() { #[test] fn inflation_rate_an_administrator_cannot_submit_an_empty_array_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let inflation_rate_data: ProjectsInflation = bounded_vec![]; @@ -6071,6 +6231,7 @@ fn inflation_rate_an_administrator_cannot_submit_an_empty_array_should_fail() { #[test] fn inflation_rate_an_administrator_cannot_set_the_inflation_rate_without_a_value_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6087,6 +6248,7 @@ fn inflation_rate_an_administrator_cannot_set_the_inflation_rate_without_a_value fn inflation_rate_an_administrator_cannot_set_the_inflation_rate_if_it_is_already_set_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6109,6 +6271,7 @@ fn inflation_rate_an_administrator_cannot_set_the_inflation_rate_if_it_is_alread #[test] fn inflation_rate_an_administrator_updates_the_inflation_rate_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6137,6 +6300,7 @@ fn inflation_rate_an_administrator_updates_the_inflation_rate_works() { #[test] fn inflation_rate_an_administrator_cannot_update_the_inflation_rate_if_it_is_not_set_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6154,6 +6318,7 @@ fn inflation_rate_an_administrator_cannot_update_the_inflation_rate_if_it_is_not #[test] fn inflation_rate_inflation_value_is_required_while_updating_the_inflation_rate_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6178,6 +6343,7 @@ fn inflation_rate_inflation_value_is_required_while_updating_the_inflation_rate_ #[test] fn inflation_rate_an_administrator_deletes_the_inflation_rate_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6201,6 +6367,7 @@ fn inflation_rate_an_administrator_deletes_the_inflation_rate_works() { #[test] fn inflation_rate_an_administrator_cannot_delete_the_inflation_rate_if_it_is_not_set_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6218,6 +6385,7 @@ fn inflation_rate_an_administrator_cannot_delete_the_inflation_rate_if_it_is_not #[test] fn bank_documents_an_administrator_uploads_bank_documents_for_a_given_eb5_drawdown_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6271,6 +6439,7 @@ fn bank_documents_an_administrator_uploads_bank_documents_for_a_given_eb5_drawdo #[test] fn bank_documents_cannot_upload_documents_for_a_contruction_loan_drawdown_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6318,6 +6487,7 @@ fn bank_documents_cannot_upload_documents_for_a_contruction_loan_drawdown_should #[test] fn bank_documents_cannot_upload_documents_for_a_developer_equity_drawdown_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6365,6 +6535,7 @@ fn bank_documents_cannot_upload_documents_for_a_developer_equity_drawdown_should #[test] fn bank_documents_cannot_upload_documents_without_an_array_of_documents_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6410,6 +6581,7 @@ fn bank_documents_cannot_upload_documents_without_an_array_of_documents_should_f #[test] fn bank_documents_cannot_upload_documents_with_an_empty_array_of_documents_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6457,6 +6629,7 @@ fn bank_documents_cannot_upload_documents_with_an_empty_array_of_documents_shoul #[test] fn bank_documents_cannot_upload_documents_if_the_drawdown_is_not_approved_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6496,6 +6669,7 @@ fn bank_documents_cannot_upload_documents_if_the_drawdown_is_not_approved_should #[test] fn bank_documents_cannot_upload_documents_twice_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6551,6 +6725,7 @@ fn bank_documents_cannot_upload_documents_twice_should_fail() { #[test] fn bank_documents_an_administrator_updates_the_bank_documents_should_work() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6610,6 +6785,7 @@ fn bank_documents_an_administrator_updates_the_bank_documents_should_work() { #[test] fn bank_documents_cannot_update_documents_without_uploading_documents_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6665,6 +6841,7 @@ fn bank_documents_cannot_update_documents_without_uploading_documents_should_fai #[test] fn bank_documents_cannot_update_documents_with_an_empty_array_of_documents_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6722,6 +6899,7 @@ fn bank_documents_cannot_update_documents_with_an_empty_array_of_documents_shoul #[test] fn bank_documents_cannot_update_bank_documents_if_the_drawdown_is_not_confirmed_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6761,6 +6939,7 @@ fn bank_documents_cannot_update_bank_documents_if_the_drawdown_is_not_confirmed_ #[test] fn bank_documents_an_administrator_deletes_bank_documents_should_work() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6819,6 +6998,7 @@ fn bank_documents_an_administrator_deletes_bank_documents_should_work() { #[test] fn bank_documents_cannot_delete_documents_if_the_drawdown_is_not_confirmed_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6858,6 +7038,7 @@ fn bank_documents_cannot_delete_documents_if_the_drawdown_is_not_confirmed_shoul #[test] fn reset_drawdown_a_builder_resets_a_eb5_drawdown_should_work() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6903,6 +7084,7 @@ fn reset_drawdown_a_builder_resets_a_eb5_drawdown_should_work() { #[test] fn reset_drawdown_a_builder_resets_a_construction_loan_drawdown_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6939,6 +7121,7 @@ fn reset_drawdown_a_builder_resets_a_construction_loan_drawdown_works() { #[test] fn reset_drawdown_a_builder_resets_a_developer_equity_drawdown_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6975,6 +7158,7 @@ fn reset_drawdown_a_builder_resets_a_developer_equity_drawdown_works() { #[test] fn reset_drawdown_a_builder_cannot_reset_a_drawdown_if_it_is_not_submitted_should_fail() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -6990,6 +7174,7 @@ fn reset_drawdown_a_builder_cannot_reset_a_drawdown_if_it_is_not_submitted_shoul #[test] fn reset_drawdown_a_builder_cannot_reset_an_approved_drawdown() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -7031,6 +7216,7 @@ fn reset_drawdown_a_builder_cannot_reset_an_approved_drawdown() { #[test] fn an_administrators_updates_a_transaction_for_an_approved_drawdown_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); let drawdown_id = get_drawdown_id(project_id, DrawdownType::EB5, 1); @@ -7120,6 +7306,7 @@ fn an_administrators_updates_a_transaction_for_an_approved_drawdown_works() { #[test] fn an_administrators_adds_a_new_transaction_to_an_approved_drawdown_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); let drawdown_id = get_drawdown_id(project_id, DrawdownType::EB5, 1); @@ -7218,6 +7405,7 @@ fn an_administrators_adds_a_new_transaction_to_an_approved_drawdown_works() { #[test] fn an_administrators_deletes_a_transaction_for_an_approved_drawdown_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); let drawdown_id = get_drawdown_id(project_id, DrawdownType::EB5, 1); @@ -7301,6 +7489,7 @@ fn an_administrators_deletes_a_transaction_for_an_approved_drawdown_works() { #[test] fn an_administrators_updates_a_transaction_for_a_confirmed_drawdown_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); let drawdown_id = get_drawdown_id(project_id, DrawdownType::EB5, 1); @@ -7411,6 +7600,7 @@ fn an_administrators_updates_a_transaction_for_a_confirmed_drawdown_works() { #[test] fn an_administrators_adds_a_new_transaction_to_a_confirmed_drawdown_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); let drawdown_id = get_drawdown_id(project_id, DrawdownType::EB5, 1); @@ -7526,6 +7716,7 @@ fn an_administrators_adds_a_new_transaction_to_a_confirmed_drawdown_works() { #[test] fn an_administrators_deletes_a_transaction_for_a_confirmed_drawdown_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); let drawdown_id = get_drawdown_id(project_id, DrawdownType::EB5, 1); @@ -7630,6 +7821,7 @@ fn an_administrators_deletes_a_transaction_for_a_confirmed_drawdown_works() { #[test] fn an_administrators_updates_a_transaction_for_an_approved_revenue_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -7695,6 +7887,7 @@ fn an_administrators_updates_a_transaction_for_an_approved_revenue_works() { #[test] fn an_administrators_adds_a_transaction_for_an_approved_revenue_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); @@ -7782,6 +7975,7 @@ fn an_administrators_adds_a_transaction_for_an_approved_revenue_works() { #[test] fn an_administrators_deletes_a_transaction_for_an_approved_revenue_works() { new_test_ext().execute_with(|| { + assert_ok!(FundAdmin::initial_setup(RuntimeOrigin::root())); assert_ok!(make_default_full_project()); let project_id = ProjectsInfo::::iter_keys().next().unwrap(); From 0cae64e2c0a659c53e0b7c28abd7f6087859dad4 Mon Sep 17 00:00:00 2001 From: didiermis Date: Mon, 1 Apr 2024 16:28:24 -0600 Subject: [PATCH 06/40] Added benchmark tests for the initial_setup, sudo_add_administrator, and sudo_remove_administrator functions in the fund-admin pallet. Also implemented utility functions generate_vector, generate_field_name, and generate_user to generate test data for benchmarking. Updated impl_benchmark_test_suite macro invocation to include the FundAdmin pallet and related dependencies. --- pallets/fund-admin/src/benchmarking.rs | 95 +++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 3 deletions(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index 30c0d3d..5b1647c 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -3,17 +3,106 @@ #![cfg(feature = "runtime-benchmarks")] use super::*; -use crate::{types::*, Pallet as BitcoinVaults}; -use scale_info::prelude::*; +use crate::{types::*, Pallet as FundAdmin}; +use scale_info::prelude::{vec::Vec, *}; use frame_benchmarking::v2::*; use frame_support::{assert_ok, pallet_prelude::*, traits::Get}; use frame_system::RawOrigin; use sp_io::hashing::blake2_256; +const SEED: u32 = 0; + +pub fn generate_vector(values: u8, size: u32) -> Vec { + assert!(size > 0, "vector size must be greater than 0"); + let mut v = vec![values; size as usize]; + v +} + +pub fn generate_field_name(values: u8, size: u32) -> FieldName { + generate_vector(values, size).try_into().unwrap() +} + +pub fn generate_user( + user_account: T::AccountId, + name_size: u32, + role: ProxyRole, + action: CUDAction, +) -> Result, Option, CUDAction), T::MaxRegistrationsAtTime>, DispatchError>{ + let field_name = generate_field_name(1, name_size); + let user = (user_account, Some(field_name), Some(role), action); + let mut users_vec: Vec<_> = Vec::new(); + users_vec.push(user); + + // Convert the Vec to a BoundedVec + let users: BoundedVec<_, T::MaxRegistrationsAtTime> = users_vec.try_into().unwrap(); + Ok(users) +} #[benchmarks(where T: Config)] mod benchmarks { use super::*; -} \ No newline at end of file + #[benchmark] + fn initial_setup() { + #[extrinsic_call] + _(RawOrigin::Root); + + let global_scope = >::get(); + assert_ne!(global_scope, [0u8; 32]); + } + + #[benchmark] + fn sudo_add_administrator(x: Linear<1, 100>) { + let _ = FundAdmin::::initial_setup(RawOrigin::Root.into()); + let admin: T::AccountId = account("admin", 0, SEED); + let field_name = generate_field_name(1, x); + + #[extrinsic_call] + _(RawOrigin::Root, admin.clone(), field_name.clone()); + + assert!(>::get(admin).is_some()); + } + + #[benchmark] + fn sudo_remove_administrator(x: Linear<1, 100>) { + let _ = FundAdmin::::initial_setup(RawOrigin::Root.into()); + let admin: T::AccountId = account("admin", 0, SEED); + let field_name = generate_field_name(1, x); + let _ = FundAdmin::::sudo_add_administrator( + RawOrigin::Root.into(), + admin.clone(), + field_name.clone(), + ); + + #[extrinsic_call] + _(RawOrigin::Root, admin.clone()); + + assert!(>::get(admin).is_none()); + } + + // #[benchmark] + // fn users(x: Linear<1, 100>, y: Linear<1, 100>, z: Linear<1, 100>) { + // let _ = FundAdmin::::initial_setup(RawOrigin::Root.into()); + // let admin: T::AccountId = account("admin", 0, SEED); + // let field_name = generate_field_name(1, x); + // let _ = FundAdmin::::sudo_add_administrator( + // RawOrigin::Root.into(), + // admin.clone(), + // field_name.clone(), + // ); + + // let users = create_random_users(y, z); + + // #[extrinsic_call] + // _(RawOrigin::Root, users.clone()); + + // assert_eq!(>::get(), users); + // } + + impl_benchmark_test_suite! { + FundAdmin, + crate::mock::new_test_ext(), + crate::mock::Test, + } +} From 5f3645dc1aa9327ae9e47d616794b8d44edfd8ee Mon Sep 17 00:00:00 2001 From: didiermis Date: Mon, 1 Apr 2024 16:28:58 -0600 Subject: [PATCH 07/40] Fixed import formatting in the tests module of the fund-admin pallet. Changed the import for Preservation enum to only import Expendable variant instead of importing all variants individually. --- pallets/fund-admin/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/fund-admin/src/tests.rs b/pallets/fund-admin/src/tests.rs index c6f51c3..280d650 100644 --- a/pallets/fund-admin/src/tests.rs +++ b/pallets/fund-admin/src/tests.rs @@ -10,7 +10,7 @@ use frame_support::{ traits::{ tokens::{ fungible::Mutate, - Preservation::{Expendable, Preserve, Protect}, + Preservation::Expendable, }, ConstU32, }, From 7f56909ccd2b69ffd583d488877bbd5af00356e1 Mon Sep 17 00:00:00 2001 From: didiermis Date: Tue, 2 Apr 2024 10:21:18 -0600 Subject: [PATCH 08/40] - Added functions to generate a batch of users and initialize the pallet with an admin. - Modified benchmarks to use the newly added functions for setup. - Implemented a benchmark for adding multiple users to the pallet at once. --- pallets/fund-admin/src/benchmarking.rs | 120 +++++++++++++++++++------ 1 file changed, 93 insertions(+), 27 deletions(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index 5b1647c..bfc81c5 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -7,7 +7,11 @@ use crate::{types::*, Pallet as FundAdmin}; use scale_info::prelude::{vec::Vec, *}; use frame_benchmarking::v2::*; -use frame_support::{assert_ok, pallet_prelude::*, traits::Get}; +use frame_support::{ + assert_ok, + pallet_prelude::*, + traits::{Currency, Get}, +}; use frame_system::RawOrigin; use sp_io::hashing::blake2_256; @@ -24,19 +28,77 @@ pub fn generate_field_name(values: u8, size: u32) -> FieldName { } pub fn generate_user( - user_account: T::AccountId, - name_size: u32, - role: ProxyRole, - action: CUDAction, -) -> Result, Option, CUDAction), T::MaxRegistrationsAtTime>, DispatchError>{ - let field_name = generate_field_name(1, name_size); - let user = (user_account, Some(field_name), Some(role), action); + user_account: T::AccountId, + name_size: u32, + role: ProxyRole, + action: CUDAction, +) -> Result< + BoundedVec< + (T::AccountId, Option, Option, CUDAction), + T::MaxRegistrationsAtTime, + >, + DispatchError, +> { + let field_name = generate_field_name(1, name_size); + let user = (user_account, Some(field_name), Some(role), action); let mut users_vec: Vec<_> = Vec::new(); - users_vec.push(user); + users_vec.push(user); + + // Convert the Vec to a BoundedVec + let users: BoundedVec< + (T::AccountId, Option, Option, CUDAction), + T::MaxRegistrationsAtTime, + > = users_vec.try_into().unwrap(); + Ok(users) +} + +pub fn create_array_users( + num_users: u32, + name_size: u32, + role: ProxyRole, +) -> Result< + BoundedVec< + (T::AccountId, Option, Option, CUDAction), + T::MaxRegistrationsAtTime, + >, + DispatchError, +> { + let mut users_vec: Vec<_> = Vec::new(); + for i in 0..num_users { + let user_account: T::AccountId = account("user", i, SEED); + let action = CUDAction::Create; + let user: BoundedVec< + (T::AccountId, Option, Option, CUDAction), + T::MaxRegistrationsAtTime, + > = generate_user::(user_account, name_size, role, action).unwrap(); + users_vec.push(user.clone().into_iter().next().unwrap()); + } + + // Convert the Vec to a BoundedVec + let users: BoundedVec< + (T::AccountId, Option, Option, CUDAction), + T::MaxRegistrationsAtTime, + > = users_vec.try_into().unwrap(); + Ok(users) +} + +pub fn initialize_pallet(name_size: u32) -> Result { + let _ = FundAdmin::::initial_setup(RawOrigin::Root.into()); + let admin: T::AccountId = account("admin", 0, SEED); + let field_name = generate_field_name(1, name_size); - // Convert the Vec to a BoundedVec - let users: BoundedVec<_, T::MaxRegistrationsAtTime> = users_vec.try_into().unwrap(); - Ok(users) + let _ = FundAdmin::::sudo_add_administrator( + RawOrigin::Root.into(), + admin.clone(), + field_name.clone(), + ); + + // get adminç + let admin_info = >::get(admin.clone()); + assert!(admin_info.is_some()); + T::Currency::make_free_balance_be(&admin, 100000u32.into()); + + Ok(admin.clone().try_into().unwrap()) } #[benchmarks(where T: Config)] @@ -81,24 +143,28 @@ mod benchmarks { assert!(>::get(admin).is_none()); } - // #[benchmark] - // fn users(x: Linear<1, 100>, y: Linear<1, 100>, z: Linear<1, 100>) { - // let _ = FundAdmin::::initial_setup(RawOrigin::Root.into()); - // let admin: T::AccountId = account("admin", 0, SEED); - // let field_name = generate_field_name(1, x); - // let _ = FundAdmin::::sudo_add_administrator( - // RawOrigin::Root.into(), - // admin.clone(), - // field_name.clone(), - // ); + #[benchmark] + fn users(x: Linear<1, 100>, y: Linear<1, 100>) { + let admin = initialize_pallet::(x).unwrap(); - // let users = create_random_users(y, z); + // let user = generate_user::( + // account("user", 0, SEED), + // 1, + // ProxyRole::Administrator, + // CUDAction::Create, + // ) + // .unwrap(); - // #[extrinsic_call] - // _(RawOrigin::Root, users.clone()); + let users_array = create_array_users::(x, y, ProxyRole::Administrator).unwrap(); - // assert_eq!(>::get(), users); - // } + #[extrinsic_call] + _(RawOrigin::Signed(admin), users_array.clone()); + + // #[extrinsic_call] + // _(RawOrigin::Root, users.clone()); + + // assert_eq!(>::get(), users); + } impl_benchmark_test_suite! { FundAdmin, From 5a7762cdc49540cfeaf5d3c5224f439b9543fb8d Mon Sep 17 00:00:00 2001 From: didiermis Date: Tue, 2 Apr 2024 10:22:29 -0600 Subject: [PATCH 09/40] - Unused imports such as use frame_support::{parameter_types, traits::Currency}; have been removed. - The balances for user accounts in the GenesisConfig are now initialized properly. --- pallets/fund-admin/src/mock.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/pallets/fund-admin/src/mock.rs b/pallets/fund-admin/src/mock.rs index 118d3ba..62426c1 100644 --- a/pallets/fund-admin/src/mock.rs +++ b/pallets/fund-admin/src/mock.rs @@ -1,8 +1,5 @@ use crate as pallet_fund_admin; -use frame_support::{ - parameter_types, - traits::Currency -}; +use frame_support::{parameter_types, traits::Currency}; use frame_system as system; use sp_core::{ConstU64, H256}; use sp_runtime::{ @@ -162,12 +159,12 @@ impl pallet_rbac::Config for Test { pub fn new_test_ext() -> sp_io::TestExternalities { let balance_amount = InitialAdminBalance::get(); let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); - pallet_balances::GenesisConfig:: { balances: vec![(1, balance_amount)] } - .assimilate_storage(&mut t) - .expect("assimilate_storage failed"); + pallet_balances::GenesisConfig:: { + balances: vec![(0, balance_amount), (1, balance_amount)], + } + .assimilate_storage(&mut t) + .expect("assimilate_storage failed"); let mut t: sp_io::TestExternalities = t.into(); - t.execute_with(|| { - - }); + t.execute_with(|| {}); t } From b71887bcda800899a6628ed6b2ae13121895da02 Mon Sep 17 00:00:00 2001 From: didiermis Date: Tue, 2 Apr 2024 10:23:00 -0600 Subject: [PATCH 10/40] A new conditional compilation block (#[cfg(feature = "runtime-benchmarks")]) has been added. --- Cargo.lock | 76 +++++++++++++++++------------------ pallets/fund-admin/src/lib.rs | 1 + 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4d949c7..08cb513 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1108,7 +1108,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-support", "frame-support-procedural", @@ -1145,7 +1145,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "aquamarine", "bitflags 1.3.2", @@ -1185,7 +1185,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "Inflector", "cfg-expr", @@ -1204,7 +1204,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -1216,7 +1216,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "proc-macro2", "quote", @@ -1226,7 +1226,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "cfg-if", "frame-support", @@ -2099,7 +2099,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-benchmarking", "frame-support", @@ -2256,7 +2256,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "docify", "frame-benchmarking", @@ -2276,7 +2276,7 @@ dependencies = [ [[package]] name = "pallet-uniques" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-benchmarking", "frame-support", @@ -3003,7 +3003,7 @@ checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "hash-db", "log", @@ -3024,7 +3024,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "Inflector", "blake2", @@ -3038,7 +3038,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "23.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "scale-info", @@ -3051,7 +3051,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "16.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "integer-sqrt", "num-traits", @@ -3065,7 +3065,7 @@ dependencies = [ [[package]] name = "sp-core" version = "21.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "array-bytes", "bandersnatch_vrfs", @@ -3112,7 +3112,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "9.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "blake2b_simd", "byteorder", @@ -3125,7 +3125,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "9.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "quote", "sp-core-hashing", @@ -3135,7 +3135,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "proc-macro2", "quote", @@ -3145,7 +3145,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.19.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "environmental", "parity-scale-codec", @@ -3156,7 +3156,7 @@ dependencies = [ [[package]] name = "sp-genesis-builder" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "serde_json", "sp-api", @@ -3167,7 +3167,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -3181,7 +3181,7 @@ dependencies = [ [[package]] name = "sp-io" version = "23.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "bytes", "ed25519-dalek", @@ -3205,7 +3205,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.27.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "parking_lot", @@ -3217,7 +3217,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -3228,7 +3228,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "backtrace", "lazy_static", @@ -3238,7 +3238,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "either", "hash256-std-hasher", @@ -3260,7 +3260,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -3278,7 +3278,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "11.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "Inflector", "proc-macro-crate", @@ -3290,7 +3290,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -3304,7 +3304,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.28.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "hash-db", "log", @@ -3325,12 +3325,12 @@ dependencies = [ [[package]] name = "sp-std" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" [[package]] name = "sp-storage" version = "13.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "impl-serde", "parity-scale-codec", @@ -3343,7 +3343,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "async-trait", "parity-scale-codec", @@ -3356,7 +3356,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "10.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "sp-std", @@ -3368,7 +3368,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "22.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "ahash 0.8.6", "hash-db", @@ -3392,7 +3392,7 @@ dependencies = [ [[package]] name = "sp-version" version = "22.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "impl-serde", "parity-scale-codec", @@ -3409,7 +3409,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -3420,7 +3420,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -3433,7 +3433,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "20.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "scale-info", diff --git a/pallets/fund-admin/src/lib.rs b/pallets/fund-admin/src/lib.rs index 16ffae9..3ee849b 100644 --- a/pallets/fund-admin/src/lib.rs +++ b/pallets/fund-admin/src/lib.rs @@ -2,6 +2,7 @@ pub use pallet::*; +#[cfg(feature = "runtime-benchmarks")] mod benchmarking; #[cfg(test)] From 941a6e3bc52ae408c3701880cbd6eeab57a32407 Mon Sep 17 00:00:00 2001 From: didiermis Date: Tue, 2 Apr 2024 12:08:41 -0600 Subject: [PATCH 11/40] Revised benchmarking code in benchmarking.rs for the create_array_users and users functions. Simplified the user creation process by directly pushing tuples into the users_vec vector instead of using generate_user. Adjusted the users benchmark function to iterate over the users_array and assert that user information is stored correctly in UsersInfo. Additionally, fixed the benchmark parameter x to use T::MaxRegistrationsAtTime::get() for the upper bound, ensuring consistency with the pallet configuration. --- pallets/fund-admin/src/benchmarking.rs | 27 ++++++++++---------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index bfc81c5..498a196 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -67,11 +67,9 @@ pub fn create_array_users( for i in 0..num_users { let user_account: T::AccountId = account("user", i, SEED); let action = CUDAction::Create; - let user: BoundedVec< - (T::AccountId, Option, Option, CUDAction), - T::MaxRegistrationsAtTime, - > = generate_user::(user_account, name_size, role, action).unwrap(); - users_vec.push(user.clone().into_iter().next().unwrap()); + let field_name = generate_field_name(1, name_size); + let user = (user_account, Some(field_name), Some(role), action); + users_vec.push(user); } // Convert the Vec to a BoundedVec @@ -144,26 +142,21 @@ mod benchmarks { } #[benchmark] - fn users(x: Linear<1, 100>, y: Linear<1, 100>) { + fn users( + x:Linear<1, { T::MaxRegistrationsAtTime::get() }>, + y: Linear<1, 100> + ) { let admin = initialize_pallet::(x).unwrap(); - // let user = generate_user::( - // account("user", 0, SEED), - // 1, - // ProxyRole::Administrator, - // CUDAction::Create, - // ) - // .unwrap(); - let users_array = create_array_users::(x, y, ProxyRole::Administrator).unwrap(); #[extrinsic_call] _(RawOrigin::Signed(admin), users_array.clone()); - // #[extrinsic_call] - // _(RawOrigin::Root, users.clone()); - // assert_eq!(>::get(), users); + for user in users_array.iter() { + assert!(>::get(user.0.clone()).is_some()); + } } impl_benchmark_test_suite! { From 3f6ee7212268aaaeb02a6cd543393a9ab20c51a1 Mon Sep 17 00:00:00 2001 From: didiermis Date: Tue, 2 Apr 2024 16:48:56 -0600 Subject: [PATCH 12/40] Introduced the users_edit_user benchmark function to test editing user information. Initialized the pallet with a default size for names. Created a new user and edited their information to ensure proper functionality, including the updating of user metadata --- Cargo.lock | 76 +++++++++++----------- pallets/fund-admin/src/benchmarking.rs | 88 ++++++++++++++++++++++++-- 2 files changed, 119 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 08cb513..4d949c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1108,7 +1108,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-support", "frame-support-procedural", @@ -1145,7 +1145,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "aquamarine", "bitflags 1.3.2", @@ -1185,7 +1185,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "Inflector", "cfg-expr", @@ -1204,7 +1204,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -1216,7 +1216,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "proc-macro2", "quote", @@ -1226,7 +1226,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "cfg-if", "frame-support", @@ -2099,7 +2099,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-benchmarking", "frame-support", @@ -2256,7 +2256,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "docify", "frame-benchmarking", @@ -2276,7 +2276,7 @@ dependencies = [ [[package]] name = "pallet-uniques" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-benchmarking", "frame-support", @@ -3003,7 +3003,7 @@ checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "hash-db", "log", @@ -3024,7 +3024,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "Inflector", "blake2", @@ -3038,7 +3038,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "23.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "scale-info", @@ -3051,7 +3051,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "16.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "integer-sqrt", "num-traits", @@ -3065,7 +3065,7 @@ dependencies = [ [[package]] name = "sp-core" version = "21.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "array-bytes", "bandersnatch_vrfs", @@ -3112,7 +3112,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "9.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "blake2b_simd", "byteorder", @@ -3125,7 +3125,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "9.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "quote", "sp-core-hashing", @@ -3135,7 +3135,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "proc-macro2", "quote", @@ -3145,7 +3145,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.19.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "environmental", "parity-scale-codec", @@ -3156,7 +3156,7 @@ dependencies = [ [[package]] name = "sp-genesis-builder" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "serde_json", "sp-api", @@ -3167,7 +3167,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -3181,7 +3181,7 @@ dependencies = [ [[package]] name = "sp-io" version = "23.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "bytes", "ed25519-dalek", @@ -3205,7 +3205,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.27.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "parking_lot", @@ -3217,7 +3217,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -3228,7 +3228,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "backtrace", "lazy_static", @@ -3238,7 +3238,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "either", "hash256-std-hasher", @@ -3260,7 +3260,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -3278,7 +3278,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "11.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "Inflector", "proc-macro-crate", @@ -3290,7 +3290,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -3304,7 +3304,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.28.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "hash-db", "log", @@ -3325,12 +3325,12 @@ dependencies = [ [[package]] name = "sp-std" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" [[package]] name = "sp-storage" version = "13.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "impl-serde", "parity-scale-codec", @@ -3343,7 +3343,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "async-trait", "parity-scale-codec", @@ -3356,7 +3356,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "10.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "sp-std", @@ -3368,7 +3368,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "22.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "ahash 0.8.6", "hash-db", @@ -3392,7 +3392,7 @@ dependencies = [ [[package]] name = "sp-version" version = "22.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "impl-serde", "parity-scale-codec", @@ -3409,7 +3409,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -3420,7 +3420,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -3433,7 +3433,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "20.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "scale-info", diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index 498a196..caa56d9 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -13,13 +13,12 @@ use frame_support::{ traits::{Currency, Get}, }; use frame_system::RawOrigin; -use sp_io::hashing::blake2_256; const SEED: u32 = 0; pub fn generate_vector(values: u8, size: u32) -> Vec { assert!(size > 0, "vector size must be greater than 0"); - let mut v = vec![values; size as usize]; + let v = vec![values; size as usize]; v } @@ -80,6 +79,47 @@ pub fn create_array_users( Ok(users) } +#[warn(dead_code)] +pub fn generate_document( + name_size: u32, + cid_size: u32 +) -> Result< + BoundedVec<(FieldName, FieldName), T::MaxDocuments>, + DispatchError, +> { + let field_name = generate_field_name(1, name_size); + let cid = generate_field_name(1, cid_size); + let document = (field_name, cid); + let mut documents_vec: Vec<_> = Vec::new(); + documents_vec.push(document); + + // Convert the Vec to a BoundedVec + let documents: BoundedVec<(FieldName, FieldName), T::MaxDocuments> = documents_vec.try_into().unwrap(); + Ok(documents) +} + +pub fn create_array_documents( + num_documents: u32, + name_size: u32, + cid_size: u32 +) -> Result< + BoundedVec<(FieldName, FieldName), T::MaxDocuments>, + DispatchError, +> { + let mut documents_vec: Vec<_> = Vec::new(); + for _i in 0..num_documents { + let field_name = generate_field_name(1, name_size); + let cid = generate_field_name(1, cid_size); + let document = (field_name, cid); + documents_vec.push(document); + } + + // Convert the Vec to a BoundedVec + let documents: BoundedVec<(FieldName, FieldName), T::MaxDocuments> = documents_vec.try_into().unwrap(); + Ok(documents) +} + + pub fn initialize_pallet(name_size: u32) -> Result { let _ = FundAdmin::::initial_setup(RawOrigin::Root.into()); let admin: T::AccountId = account("admin", 0, SEED); @@ -114,7 +154,7 @@ mod benchmarks { #[benchmark] fn sudo_add_administrator(x: Linear<1, 100>) { - let _ = FundAdmin::::initial_setup(RawOrigin::Root.into()); + assert_ok!(FundAdmin::::initial_setup(RawOrigin::Root.into())); let admin: T::AccountId = account("admin", 0, SEED); let field_name = generate_field_name(1, x); @@ -126,14 +166,14 @@ mod benchmarks { #[benchmark] fn sudo_remove_administrator(x: Linear<1, 100>) { - let _ = FundAdmin::::initial_setup(RawOrigin::Root.into()); + assert_ok!(FundAdmin::::initial_setup(RawOrigin::Root.into())); let admin: T::AccountId = account("admin", 0, SEED); let field_name = generate_field_name(1, x); - let _ = FundAdmin::::sudo_add_administrator( + assert_ok!(FundAdmin::::sudo_add_administrator( RawOrigin::Root.into(), admin.clone(), field_name.clone(), - ); + )); #[extrinsic_call] _(RawOrigin::Root, admin.clone()); @@ -143,7 +183,7 @@ mod benchmarks { #[benchmark] fn users( - x:Linear<1, { T::MaxRegistrationsAtTime::get() }>, + x: Linear<1, { T::MaxRegistrationsAtTime::get() }>, y: Linear<1, 100> ) { let admin = initialize_pallet::(x).unwrap(); @@ -159,6 +199,40 @@ mod benchmarks { } } + #[benchmark] + fn users_edit_user( + x: Linear<1, { T::MaxRegistrationsAtTime::get() }>, + y: Linear<1, 100>, + z: Linear<1, 100>, + a: Linear<1, 100>, + b: Linear<1, 100>, + c: Linear<1, { T::MaxDocuments::get() }>, + d: Linear<1, 100>, + e: Linear<1, 100> + ) { + let admin = initialize_pallet::(100).unwrap(); + + let investor_account: T::AccountId = account("user", 1, SEED); + let investor_payload = generate_user::(investor_account.clone(), y, ProxyRole::Investor, CUDAction::Create).unwrap(); + assert_ok!(FundAdmin::::users(RawOrigin::Signed(admin.clone()).into(), investor_payload.clone())); + let investor_info = >::get(investor_account.clone()); + assert!(investor_info.is_some()); + + let name = generate_field_name(1, z); + let image = generate_field_name(1, a); + let email = generate_field_name(1, b); + let documents = create_array_documents::(c, d, e).unwrap(); + + #[extrinsic_call] + _(RawOrigin::Signed(investor_account.clone()), Some(name.clone()), Some(image.clone()), Some(email.clone()), Some(documents.clone())); + + let user_info = >::get(investor_account.clone()); + assert!(user_info.clone().unwrap().name == name); + assert!(user_info.clone().unwrap().image == image); + assert!(user_info.clone().unwrap().email == email); + assert!(user_info.clone().unwrap().documents == Some(documents)); + } + impl_benchmark_test_suite! { FundAdmin, crate::mock::new_test_ext(), From af545a2647106aa136bcffaf2a1ca73bc7616ce4 Mon Sep 17 00:00:00 2001 From: didiermis Date: Tue, 2 Apr 2024 19:26:43 -0600 Subject: [PATCH 13/40] Updated the benchmarking code in benchmarking.rs for the generate_document and create_array_documents functions, simplifying the error handling and parameter passing. Introduced new functions generate_banks, create_array_expenditures, create_array_job_eligibles, and create_array_users_assignations to generate sample data for benchmarks related to project creation. Added a new benchmark function projects_create_project to test project creation functionality with sample data --- pallets/fund-admin/src/benchmarking.rs | 242 ++++++++++++++++++++++--- 1 file changed, 221 insertions(+), 21 deletions(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index caa56d9..229c9e5 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -82,11 +82,8 @@ pub fn create_array_users( #[warn(dead_code)] pub fn generate_document( name_size: u32, - cid_size: u32 -) -> Result< - BoundedVec<(FieldName, FieldName), T::MaxDocuments>, - DispatchError, -> { + cid_size: u32, +) -> Result, DispatchError> { let field_name = generate_field_name(1, name_size); let cid = generate_field_name(1, cid_size); let document = (field_name, cid); @@ -94,18 +91,16 @@ pub fn generate_document( documents_vec.push(document); // Convert the Vec to a BoundedVec - let documents: BoundedVec<(FieldName, FieldName), T::MaxDocuments> = documents_vec.try_into().unwrap(); + let documents: BoundedVec<(FieldName, FieldName), T::MaxDocuments> = + documents_vec.try_into().unwrap(); Ok(documents) } pub fn create_array_documents( num_documents: u32, name_size: u32, - cid_size: u32 -) -> Result< - BoundedVec<(FieldName, FieldName), T::MaxDocuments>, - DispatchError, -> { + cid_size: u32, +) -> Result, DispatchError> { let mut documents_vec: Vec<_> = Vec::new(); for _i in 0..num_documents { let field_name = generate_field_name(1, name_size); @@ -115,10 +110,149 @@ pub fn create_array_documents( } // Convert the Vec to a BoundedVec - let documents: BoundedVec<(FieldName, FieldName), T::MaxDocuments> = documents_vec.try_into().unwrap(); + let documents: BoundedVec<(FieldName, FieldName), T::MaxDocuments> = + documents_vec.try_into().unwrap(); Ok(documents) } +pub fn generate_banks( + num_banks: u32, + name_size: u32, + address_size: u32, +) -> Result, DispatchError> { + let mut banks_vec: Vec<_> = Vec::new(); + for i in 0..num_banks { + let bank_name = generate_field_name(1, name_size); + let bank_address = generate_field_name(1, address_size); + let bank = (bank_name, bank_address); + banks_vec.push(bank); + } + + // Convert the Vec to a BoundedVec + let banks: BoundedVec<(BankName, BankAddress), T::MaxBanksPerProject> = + banks_vec.try_into().unwrap(); + Ok(banks) +} + +pub fn create_array_expenditures( + num_expenditures: u32, + name_size: u32, + naics_code_size: u32, +) -> Result< + BoundedVec< + ( + Option, + Option, + Option, + Option, + Option, + CUDAction, + Option, + ), + T::MaxRegistrationsAtTime, + >, + DispatchError, +> { + let mut expenditures_vec: Vec<_> = Vec::new(); + for i in 0..num_expenditures { + let name = generate_field_name(1, name_size); + let naics_code = generate_field_name(1, naics_code_size); + let expenditure = ( + Some(name), + Some(ExpenditureType::HardCost), + Some(u64::MAX), + Some(naics_code), + Some(u32::MAX), + Some(CUDAction::Create), + None, + ); + expenditures_vec.push(expenditure); + } + + // Convert the Vec to a BoundedVec + let expenditures: BoundedVec< + ( + Option, + Option, + Option, + Option, + Option, + CUDAction, + Option, + ), + T::MaxRegistrationsAtTime, + > = expenditures_vec.try_into().unwrap(); + Ok(expenditures) +} + +pub fn create_array_job_eligibles( + num_job_eligibles: u32, + name_size: u32, + naics_code_size: u32, +) -> Result< + BoundedVec< + ( + Option, + Option, + Option, + Option, + CUDAction, + Option, + ), + T::MaxRegistrationsAtTime, + >, + DispatchError, +> { + let mut job_eligibles_vec: Vec<_> = Vec::new(); + for i in 0..num_job_eligibles { + let name = generate_field_name(1, name_size); + let naics_code = generate_field_name(1, naics_code_size); + let job_eligible = ( + Some(name), + Some(u64::MAX), + Some(naics_code), + Some(u32::MAX), + Some(CUDAction::Create), + None, + ); + job_eligibles_vec.push(job_eligible); + } + + // Convert the Vec to a BoundedVec + let job_eligibles: BoundedVec< + ( + Option, + Option, + Option, + Option, + CUDAction, + Option, + ), + T::MaxRegistrationsAtTime, + > = job_eligibles_vec.try_into().unwrap(); + Ok(job_eligibles) +} + +pub fn create_array_users_assignations( + num_users: u32, + role: ProxyRole, +) -> Result< + BoundedVec<(T::AccountId, ProxyRole, AssignAction), T::MaxRegistrationsAtTime>, + DispatchError, +> { + let mut users_vec: Vec<_> = Vec::new(); + for i in 0..num_users { + let user_account: T::AccountId = account("user", i + 1, SEED); + let action = AssignAction::Assign; + let user = (user_account, role, action); + users_vec.push(user); + } + + // Convert the Vec to a BoundedVec + let users: BoundedVec<(T::AccountId, ProxyRole, AssignAction), T::MaxRegistrationsAtTime> = + users_vec.try_into().unwrap(); + Ok(users) +} pub fn initialize_pallet(name_size: u32) -> Result { let _ = FundAdmin::::initial_setup(RawOrigin::Root.into()); @@ -182,10 +316,7 @@ mod benchmarks { } #[benchmark] - fn users( - x: Linear<1, { T::MaxRegistrationsAtTime::get() }>, - y: Linear<1, 100> - ) { + fn users(x: Linear<1, { T::MaxRegistrationsAtTime::get() }>, y: Linear<1, 100>) { let admin = initialize_pallet::(x).unwrap(); let users_array = create_array_users::(x, y, ProxyRole::Administrator).unwrap(); @@ -193,7 +324,6 @@ mod benchmarks { #[extrinsic_call] _(RawOrigin::Signed(admin), users_array.clone()); - for user in users_array.iter() { assert!(>::get(user.0.clone()).is_some()); } @@ -208,13 +338,18 @@ mod benchmarks { b: Linear<1, 100>, c: Linear<1, { T::MaxDocuments::get() }>, d: Linear<1, 100>, - e: Linear<1, 100> + e: Linear<1, 100>, ) { let admin = initialize_pallet::(100).unwrap(); let investor_account: T::AccountId = account("user", 1, SEED); - let investor_payload = generate_user::(investor_account.clone(), y, ProxyRole::Investor, CUDAction::Create).unwrap(); - assert_ok!(FundAdmin::::users(RawOrigin::Signed(admin.clone()).into(), investor_payload.clone())); + let investor_payload = + generate_user::(investor_account.clone(), y, ProxyRole::Investor, CUDAction::Create) + .unwrap(); + assert_ok!(FundAdmin::::users( + RawOrigin::Signed(admin.clone()).into(), + investor_payload.clone() + )); let investor_info = >::get(investor_account.clone()); assert!(investor_info.is_some()); @@ -224,7 +359,13 @@ mod benchmarks { let documents = create_array_documents::(c, d, e).unwrap(); #[extrinsic_call] - _(RawOrigin::Signed(investor_account.clone()), Some(name.clone()), Some(image.clone()), Some(email.clone()), Some(documents.clone())); + _( + RawOrigin::Signed(investor_account.clone()), + Some(name.clone()), + Some(image.clone()), + Some(email.clone()), + Some(documents.clone()), + ); let user_info = >::get(investor_account.clone()); assert!(user_info.clone().unwrap().name == name); @@ -233,6 +374,65 @@ mod benchmarks { assert!(user_info.clone().unwrap().documents == Some(documents)); } + #[benchmark] + fn projects_create_project( + a: Linear<1, 100>, + b: Linear<1, 400>, + c: Linear<1, 100>, + d: Linear<1, 100>, + e: Linear<1, { T::MaxBanksPerProject::get() }>, + f: Linear<1, 100>, + g: Linear<1, 100>, + h: Linear<1, { T::MaxRegistrationsAtTime::get() }>, + i: Linear<1, 100>, + j: Linear<1, 400>, + k: Linear<1, { T::MaxRegistrationsAtTime::get() }>, + l: Linear<1, 100>, + m: Linear<1, 400>, + n: Linear<1, { T::MaxRegistrationsAtTime::get() }>, + o: Linear<1, 400>, + ) { + let admin = initialize_pallet::(100).unwrap(); + + let title = generate_field_name(1, a); + let description = generate_field_name(1, b); + let image = generate_field_name(1, c); + let address = generate_field_name(1, d); + let banks = generate_banks::(e, f, g).unwrap(); + let creation_date = u64::MAX; + let completion_date = u64::MAX; + let expenditures = create_array_expenditures::(h, i, j).unwrap(); + let job_eligibles = create_array_job_eligibles::(k, l, m).unwrap(); + let users_assignation = + create_array_users_assignations::(n, ProxyRole::Builder).unwrap(); + let private_group_id = generate_field_name(1, o); + + #[extrinsic_call] + _( + RawOrigin::Signed(admin.clone()), + title.clone(), + description.clone(), + Some(image.clone()), + address.clone(), + Some(banks.clone()), + creation_date, + completion_date, + expenditures.clone(), + Some(job_eligibles.clone()), + Some(users_assignation.clone()), + private_group_id.clone(), + ); + // let project_info = >::get(project_name.clone()); + // assert!(project_info.is_some()); + // assert!(project_info.unwrap().title == title); + // assert!(project_info.unwrap().description == description); + // assert!(project_info.unwrap().image == image); + // assert!(project_info.unwrap().address == address); + // assert!(project_info.unwrap().banks == banks); + // assert!(project_info.unwrap().creation_date == creation_date); + // assert!(project_info.unwrap().completion_date == completion_date); + } + impl_benchmark_test_suite! { FundAdmin, crate::mock::new_test_ext(), From 8daf7c996e72fcdb7323b88121fb27a5d5d0cbf6 Mon Sep 17 00:00:00 2001 From: didiermis Date: Wed, 3 Apr 2024 08:42:07 -0600 Subject: [PATCH 14/40] Updated the benchmarking code in benchmarking.rs to include a new function generate_field_description to generate descriptions for fields, and modified functions create_array_expenditures, create_array_job_eligibles, and create_array_users_assignations to utilize it accordingly. Also adjusted the benchmarking parameters for project creation in the projects_create_project function and added assertions to verify project creation Finish 7:00 pm --- pallets/fund-admin/src/benchmarking.rs | 120 +++++++------------------ 1 file changed, 30 insertions(+), 90 deletions(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index 229c9e5..d84d3ed 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -26,6 +26,10 @@ pub fn generate_field_name(values: u8, size: u32) -> FieldName { generate_vector(values, size).try_into().unwrap() } +pub fn generate_field_description(values: u8, size: u32) -> FieldDescription { + generate_vector(values, size).try_into().unwrap() +} + pub fn generate_user( user_account: T::AccountId, name_size: u32, @@ -121,7 +125,7 @@ pub fn generate_banks( address_size: u32, ) -> Result, DispatchError> { let mut banks_vec: Vec<_> = Vec::new(); - for i in 0..num_banks { + for _i in 0..num_banks { let bank_name = generate_field_name(1, name_size); let bank_address = generate_field_name(1, address_size); let bank = (bank_name, bank_address); @@ -133,125 +137,67 @@ pub fn generate_banks( banks_vec.try_into().unwrap(); Ok(banks) } - +// TODO: REVIEW THE INDEX ON THE SEBASTIANS IOMPLEMENTATION pub fn create_array_expenditures( num_expenditures: u32, name_size: u32, naics_code_size: u32, -) -> Result< - BoundedVec< - ( - Option, - Option, - Option, - Option, - Option, - CUDAction, - Option, - ), - T::MaxRegistrationsAtTime, - >, - DispatchError, -> { - let mut expenditures_vec: Vec<_> = Vec::new(); - for i in 0..num_expenditures { +) -> Result, DispatchError> { + let mut expenditures_vec: Expenditures = BoundedVec::new(); + for _i in 0..num_expenditures { let name = generate_field_name(1, name_size); - let naics_code = generate_field_name(1, naics_code_size); + let naics_code = generate_field_description(1, naics_code_size); let expenditure = ( Some(name), Some(ExpenditureType::HardCost), Some(u64::MAX), Some(naics_code), Some(u32::MAX), - Some(CUDAction::Create), + CUDAction::Create, None, ); - expenditures_vec.push(expenditure); + expenditures_vec.try_push(expenditure).unwrap(); } - // Convert the Vec to a BoundedVec - let expenditures: BoundedVec< - ( - Option, - Option, - Option, - Option, - Option, - CUDAction, - Option, - ), - T::MaxRegistrationsAtTime, - > = expenditures_vec.try_into().unwrap(); - Ok(expenditures) + Ok(expenditures_vec) } pub fn create_array_job_eligibles( num_job_eligibles: u32, name_size: u32, naics_code_size: u32, -) -> Result< - BoundedVec< - ( - Option, - Option, - Option, - Option, - CUDAction, - Option, - ), - T::MaxRegistrationsAtTime, - >, - DispatchError, -> { - let mut job_eligibles_vec: Vec<_> = Vec::new(); - for i in 0..num_job_eligibles { +) -> Result, DispatchError> { + let mut job_eligibles_vec: JobEligibles = BoundedVec::new(); + for _i in 0..num_job_eligibles { let name = generate_field_name(1, name_size); - let naics_code = generate_field_name(1, naics_code_size); + let naics_code = generate_field_description(1, naics_code_size); let job_eligible = ( Some(name), Some(u64::MAX), Some(naics_code), Some(u32::MAX), - Some(CUDAction::Create), + CUDAction::Create, None, ); - job_eligibles_vec.push(job_eligible); + job_eligibles_vec.try_push(job_eligible).unwrap(); } - // Convert the Vec to a BoundedVec - let job_eligibles: BoundedVec< - ( - Option, - Option, - Option, - Option, - CUDAction, - Option, - ), - T::MaxRegistrationsAtTime, - > = job_eligibles_vec.try_into().unwrap(); - Ok(job_eligibles) + Ok(job_eligibles_vec) } pub fn create_array_users_assignations( num_users: u32, role: ProxyRole, -) -> Result< - BoundedVec<(T::AccountId, ProxyRole, AssignAction), T::MaxRegistrationsAtTime>, - DispatchError, -> { - let mut users_vec: Vec<_> = Vec::new(); +) -> Result , DispatchError> { + let mut users_vec: UsersAssignation = BoundedVec::new(); for i in 0..num_users { let user_account: T::AccountId = account("user", i + 1, SEED); let action = AssignAction::Assign; let user = (user_account, role, action); - users_vec.push(user); + users_vec.try_push(user).unwrap(); } - // Convert the Vec to a BoundedVec - let users: BoundedVec<(T::AccountId, ProxyRole, AssignAction), T::MaxRegistrationsAtTime> = - users_vec.try_into().unwrap(); - Ok(users) + Ok(users_vec) } pub fn initialize_pallet(name_size: u32) -> Result { @@ -395,17 +341,17 @@ mod benchmarks { let admin = initialize_pallet::(100).unwrap(); let title = generate_field_name(1, a); - let description = generate_field_name(1, b); + let description = generate_field_description(1, b); let image = generate_field_name(1, c); let address = generate_field_name(1, d); let banks = generate_banks::(e, f, g).unwrap(); - let creation_date = u64::MAX; + let creation_date = u64::MAX - 1; let completion_date = u64::MAX; let expenditures = create_array_expenditures::(h, i, j).unwrap(); let job_eligibles = create_array_job_eligibles::(k, l, m).unwrap(); let users_assignation = create_array_users_assignations::(n, ProxyRole::Builder).unwrap(); - let private_group_id = generate_field_name(1, o); + let private_group_id = generate_field_description(1, o); #[extrinsic_call] _( @@ -422,15 +368,9 @@ mod benchmarks { Some(users_assignation.clone()), private_group_id.clone(), ); - // let project_info = >::get(project_name.clone()); - // assert!(project_info.is_some()); - // assert!(project_info.unwrap().title == title); - // assert!(project_info.unwrap().description == description); - // assert!(project_info.unwrap().image == image); - // assert!(project_info.unwrap().address == address); - // assert!(project_info.unwrap().banks == banks); - // assert!(project_info.unwrap().creation_date == creation_date); - // assert!(project_info.unwrap().completion_date == completion_date); + + let project_id = >::iter_keys().next(); + assert!(project_id.is_some()); } impl_benchmark_test_suite! { From 0ebcffe00034979211b0975913c830a1c7081334 Mon Sep 17 00:00:00 2001 From: didiermis Date: Wed, 3 Apr 2024 11:44:08 -0600 Subject: [PATCH 15/40] pdated the benchmarking code in benchmarking.rs to refactor the user generation functions generate_user and create_array_users to return Users instead of BoundedVec, and similarly refactored the document generation functions to return Documents. Also modified the implementation of create_array_expenditures, create_array_job_eligibles, create_array_users_assignations, and generate_banks functions to utilize try_push method for pushing elements into the bounded vectors. Additionally, introduced a new function register_users to register users and added an assertion to ensure successful user registration during project initialization. --- pallets/fund-admin/src/benchmarking.rs | 119 +++++++++++-------------- 1 file changed, 50 insertions(+), 69 deletions(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index d84d3ed..b1b483a 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -35,117 +35,85 @@ pub fn generate_user( name_size: u32, role: ProxyRole, action: CUDAction, -) -> Result< - BoundedVec< - (T::AccountId, Option, Option, CUDAction), - T::MaxRegistrationsAtTime, - >, - DispatchError, -> { +) -> Result, DispatchError> { let field_name = generate_field_name(1, name_size); let user = (user_account, Some(field_name), Some(role), action); - let mut users_vec: Vec<_> = Vec::new(); - users_vec.push(user); - - // Convert the Vec to a BoundedVec - let users: BoundedVec< - (T::AccountId, Option, Option, CUDAction), - T::MaxRegistrationsAtTime, - > = users_vec.try_into().unwrap(); - Ok(users) + let mut users_vec: Users = BoundedVec::new(); + users_vec.try_push(user).unwrap(); + Ok(users_vec) } pub fn create_array_users( num_users: u32, name_size: u32, role: ProxyRole, -) -> Result< - BoundedVec< - (T::AccountId, Option, Option, CUDAction), - T::MaxRegistrationsAtTime, - >, - DispatchError, -> { - let mut users_vec: Vec<_> = Vec::new(); +) -> Result, DispatchError> { + let mut users_vec: Users = BoundedVec::new(); for i in 0..num_users { let user_account: T::AccountId = account("user", i, SEED); let action = CUDAction::Create; let field_name = generate_field_name(1, name_size); let user = (user_account, Some(field_name), Some(role), action); - users_vec.push(user); + users_vec.try_push(user).unwrap(); } - // Convert the Vec to a BoundedVec - let users: BoundedVec< - (T::AccountId, Option, Option, CUDAction), - T::MaxRegistrationsAtTime, - > = users_vec.try_into().unwrap(); - Ok(users) + Ok(users_vec) } #[warn(dead_code)] pub fn generate_document( name_size: u32, cid_size: u32, -) -> Result, DispatchError> { +) -> Result, DispatchError> { let field_name = generate_field_name(1, name_size); let cid = generate_field_name(1, cid_size); let document = (field_name, cid); - let mut documents_vec: Vec<_> = Vec::new(); - documents_vec.push(document); - - // Convert the Vec to a BoundedVec - let documents: BoundedVec<(FieldName, FieldName), T::MaxDocuments> = - documents_vec.try_into().unwrap(); - Ok(documents) + let mut documents_vec: Documents = BoundedVec::new(); + documents_vec.try_push(document).unwrap(); + Ok(documents_vec) } pub fn create_array_documents( num_documents: u32, name_size: u32, cid_size: u32, -) -> Result, DispatchError> { - let mut documents_vec: Vec<_> = Vec::new(); +) -> Result, DispatchError> { + let mut documents_vec: Documents = BoundedVec::new(); for _i in 0..num_documents { let field_name = generate_field_name(1, name_size); let cid = generate_field_name(1, cid_size); let document = (field_name, cid); - documents_vec.push(document); + documents_vec.try_push(document).unwrap(); } - // Convert the Vec to a BoundedVec - let documents: BoundedVec<(FieldName, FieldName), T::MaxDocuments> = - documents_vec.try_into().unwrap(); - Ok(documents) + Ok(documents_vec) } pub fn generate_banks( num_banks: u32, name_size: u32, address_size: u32, -) -> Result, DispatchError> { - let mut banks_vec: Vec<_> = Vec::new(); +) -> Result, DispatchError> { + let mut banks_vec: Banks = BoundedVec::new(); for _i in 0..num_banks { let bank_name = generate_field_name(1, name_size); let bank_address = generate_field_name(1, address_size); let bank = (bank_name, bank_address); - banks_vec.push(bank); + banks_vec.try_push(bank).unwrap(); } - // Convert the Vec to a BoundedVec - let banks: BoundedVec<(BankName, BankAddress), T::MaxBanksPerProject> = - banks_vec.try_into().unwrap(); - Ok(banks) + Ok(banks_vec) } -// TODO: REVIEW THE INDEX ON THE SEBASTIANS IOMPLEMENTATION + pub fn create_array_expenditures( num_expenditures: u32, name_size: u32, naics_code_size: u32, ) -> Result, DispatchError> { let mut expenditures_vec: Expenditures = BoundedVec::new(); - for _i in 0..num_expenditures { - let name = generate_field_name(1, name_size); + for i in 0..num_expenditures { + let mut name = generate_field_name(1, name_size); + name[0] = i as u8; let naics_code = generate_field_description(1, naics_code_size); let expenditure = ( Some(name), @@ -168,17 +136,12 @@ pub fn create_array_job_eligibles( naics_code_size: u32, ) -> Result, DispatchError> { let mut job_eligibles_vec: JobEligibles = BoundedVec::new(); - for _i in 0..num_job_eligibles { - let name = generate_field_name(1, name_size); + for i in 0..num_job_eligibles { + let mut name = generate_field_name(1, name_size); + name[0] = i as u8; let naics_code = generate_field_description(1, naics_code_size); - let job_eligible = ( - Some(name), - Some(u64::MAX), - Some(naics_code), - Some(u32::MAX), - CUDAction::Create, - None, - ); + let job_eligible = + (Some(name), Some(u64::MAX), Some(naics_code), Some(u32::MAX), CUDAction::Create, None); job_eligibles_vec.try_push(job_eligible).unwrap(); } @@ -188,7 +151,7 @@ pub fn create_array_job_eligibles( pub fn create_array_users_assignations( num_users: u32, role: ProxyRole, -) -> Result , DispatchError> { +) -> Result, DispatchError> { let mut users_vec: UsersAssignation = BoundedVec::new(); for i in 0..num_users { let user_account: T::AccountId = account("user", i + 1, SEED); @@ -200,6 +163,23 @@ pub fn create_array_users_assignations( Ok(users_vec) } +pub fn register_users( + admin: T::AccountId, + users_assignation: UsersAssignation, +) -> Result<(), DispatchError> { + let mut users_array: Users = BoundedVec::new(); + for (user, role, _) in users_assignation.iter() { + let name = generate_field_name(1, 100); + let user_info = (user.clone(), Some(name), Some(role.clone()), CUDAction::Create); + users_array.try_push(user_info).unwrap(); + } + + assert_ok!(FundAdmin::::users(RawOrigin::Signed(admin.clone()).into(), users_array.clone())); + + Ok(()) +} + + pub fn initialize_pallet(name_size: u32) -> Result { let _ = FundAdmin::::initial_setup(RawOrigin::Root.into()); let admin: T::AccountId = account("admin", 0, SEED); @@ -349,8 +329,9 @@ mod benchmarks { let completion_date = u64::MAX; let expenditures = create_array_expenditures::(h, i, j).unwrap(); let job_eligibles = create_array_job_eligibles::(k, l, m).unwrap(); - let users_assignation = - create_array_users_assignations::(n, ProxyRole::Builder).unwrap(); + let users_assignation = create_array_users_assignations::(n, ProxyRole::Builder).unwrap(); + assert_ok!(register_users::(admin.clone(), users_assignation.clone())); + let private_group_id = generate_field_description(1, o); #[extrinsic_call] From 63409c8d09ab5505251fed5cf921eb685c56e250 Mon Sep 17 00:00:00 2001 From: didiermis Date: Wed, 3 Apr 2024 12:46:01 -0600 Subject: [PATCH 16/40] Added new functions create_basic_project and create_full_project to create basic and full projects respectively. These functions facilitate project creation with minimal and comprehensive parameters. Also, modified the benchmarking function projects_edit_project to test the projects_edit_project extrinsic call by editing project attributes and asserting the changes. --- pallets/fund-admin/src/benchmarking.rs | 117 ++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 2 deletions(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index b1b483a..2b93f4a 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -105,6 +105,73 @@ pub fn generate_banks( Ok(banks_vec) } +pub fn create_basic_project(admin: T::AccountId) -> Result<[u8; 32], DispatchError> { + let title = generate_field_name(1, 100); + let description = generate_field_description(1, 400); + let address = generate_field_name(1, 100); + let creation_date = u64::MAX - 1; + let completion_date = u64::MAX; + let expenditures = create_array_expenditures::(1, 100, 100).unwrap(); + + let private_group_id = generate_field_description(1, 100); + + assert_ok!(FundAdmin::::projects_create_project( + RawOrigin::Signed(admin.clone()).into(), + title.clone(), + description.clone(), + None, + address.clone(), + None, + creation_date, + completion_date, + expenditures.clone(), + None, + None, + private_group_id.clone(), + )); + + let project_id = >::iter_keys().next(); + assert!(project_id.is_some()); + + Ok(project_id.unwrap()) +} + +pub fn create_full_project(admin: T::AccountId) -> Result<[u8; 32], DispatchError> { + let title = generate_field_name(1, 100); + let description = generate_field_description(1, 400); + let image = generate_field_name(1, 100); + let address = generate_field_name(1, 100); + let banks = generate_banks::(1, 100, 100).unwrap(); + let creation_date = u64::MAX - 1; + let completion_date = u64::MAX; + let expenditures = create_array_expenditures::(1, 100, 100).unwrap(); + let job_eligibles = create_array_job_eligibles::(1, 100, 100).unwrap(); + let users_assignation = create_array_users_assignations::(1, ProxyRole::Builder).unwrap(); + assert_ok!(register_users::(admin.clone(), users_assignation.clone())); + + let private_group_id = generate_field_description(1, 100); + + assert_ok!(FundAdmin::::projects_create_project( + RawOrigin::Signed(admin.clone()).into(), + title.clone(), + description.clone(), + Some(image.clone()), + address.clone(), + Some(banks.clone()), + creation_date, + completion_date, + expenditures.clone(), + Some(job_eligibles.clone()), + Some(users_assignation.clone()), + private_group_id.clone(), + )); + + let project_id = >::iter_keys().next(); + assert!(project_id.is_some()); + + Ok(project_id.unwrap()) +} + pub fn create_array_expenditures( num_expenditures: u32, name_size: u32, @@ -179,7 +246,6 @@ pub fn register_users( Ok(()) } - pub fn initialize_pallet(name_size: u32) -> Result { let _ = FundAdmin::::initial_setup(RawOrigin::Root.into()); let admin: T::AccountId = account("admin", 0, SEED); @@ -329,7 +395,8 @@ mod benchmarks { let completion_date = u64::MAX; let expenditures = create_array_expenditures::(h, i, j).unwrap(); let job_eligibles = create_array_job_eligibles::(k, l, m).unwrap(); - let users_assignation = create_array_users_assignations::(n, ProxyRole::Builder).unwrap(); + let users_assignation = + create_array_users_assignations::(n, ProxyRole::Builder).unwrap(); assert_ok!(register_users::(admin.clone(), users_assignation.clone())); let private_group_id = generate_field_description(1, o); @@ -354,6 +421,52 @@ mod benchmarks { assert!(project_id.is_some()); } + #[benchmark] + fn projects_edit_project( + a: Linear<1, 100>, + b: Linear<1, 400>, + c: Linear<1, 100>, + d: Linear<1, 100>, + e: Linear<1, { T::MaxBanksPerProject::get() }>, + f: Linear<1, 100>, + g: Linear<1, 100>, + h: Linear<1, { T::MaxRegistrationsAtTime::get() }>, + i: Linear<1, 100>, + j: Linear<1, 400>, + ) { + let admin = initialize_pallet::(100).unwrap(); + let project_id = create_basic_project::(admin.clone()).unwrap(); + + let title = generate_field_name(1, a); + let description = generate_field_description(1, b); + let image = generate_field_name(1, c); + let address = generate_field_name(1, d); + let creation_date = u64::MAX - 1; + let completion_date = u64::MAX; + + #[extrinsic_call] + _( + RawOrigin::Signed(admin.clone()), + project_id.clone(), + Some(title.clone()), + Some(description.clone()), + Some(image.clone()), + Some(address.clone()), + None, + Some(creation_date), + Some(completion_date), + ); + + let project_info = >::get(project_id.clone()); + assert!(project_info.clone().unwrap().title == title); + assert!(project_info.clone().unwrap().description == description); + assert!(project_info.clone().unwrap().image == Some(image)); + assert!(project_info.clone().unwrap().address == address); + assert!(project_info.clone().unwrap().creation_date == creation_date); + assert!(project_info.clone().unwrap().completion_date == completion_date); + } + + impl_benchmark_test_suite! { FundAdmin, crate::mock::new_test_ext(), From d1b7692cd6994ade68438db5205de013ad080b90 Mon Sep 17 00:00:00 2001 From: didiermis Date: Wed, 3 Apr 2024 12:54:27 -0600 Subject: [PATCH 17/40] Added benchmarking function projects_delete_project to test the projects_delete_project extrinsic call by deleting a project and asserting its removal from storage. --- pallets/fund-admin/src/benchmarking.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index 2b93f4a..966121d 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -466,6 +466,17 @@ mod benchmarks { assert!(project_info.clone().unwrap().completion_date == completion_date); } + #[benchmark] + fn projects_delete_project() { + let admin = initialize_pallet::(100).unwrap(); + let project_id = create_basic_project::(admin.clone()).unwrap(); + + #[extrinsic_call] + _(RawOrigin::Signed(admin.clone()), project_id.clone()); + + let project_info = >::get(project_id.clone()); + assert!(project_info.is_none()); + } impl_benchmark_test_suite! { FundAdmin, From 32edca0ba0ab754c0b25e7bd335b02a0d611d433 Mon Sep 17 00:00:00 2001 From: didiermis Date: Wed, 3 Apr 2024 13:13:53 -0600 Subject: [PATCH 18/40] Added benchmarking function projects_assign_user to test the projects_assign_user extrinsic call by assigning users to a project and asserting their addition to the project's builders list. --- pallets/fund-admin/src/benchmarking.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index 966121d..0a9b8a9 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -478,6 +478,31 @@ mod benchmarks { assert!(project_info.is_none()); } + #[benchmark] + fn projects_assign_user( + a: Linear<1, { T::MaxRegistrationsAtTime::get() }> + ) { + let admin = initialize_pallet::(100).unwrap(); + let project_id = create_basic_project::(admin.clone()).unwrap(); + + let users_assignation = create_array_users_assignations::(a, ProxyRole::Builder).unwrap(); + assert_ok!(register_users::(admin.clone(), users_assignation.clone())); + + #[extrinsic_call] + _( + RawOrigin::Signed(admin.clone()), + project_id.clone(), + users_assignation.clone(), + ); + + for (user, role, _) in users_assignation.iter() { + let user_info = >::get(user.clone()); + assert!(user_info.is_some()); + let project_info = >::get(project_id.clone()); + assert!(project_info.unwrap().builder.unwrap().iter().any(|x| x == user)); + } + } + impl_benchmark_test_suite! { FundAdmin, crate::mock::new_test_ext(), From 68e587430772a86985e5c8beb57f9db24c02dda5 Mon Sep 17 00:00:00 2001 From: didiermis Date: Wed, 3 Apr 2024 16:32:02 -0600 Subject: [PATCH 19/40] - Updated create_array_expenditures function to accept an expenditure_type parameter. - Added a new benchmarking function expenditures_and_job_eligibles to test the association of expenditures and job eligibles with a project. --- pallets/fund-admin/src/benchmarking.rs | 174 +++++++++++++++---------- 1 file changed, 105 insertions(+), 69 deletions(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index 0a9b8a9..1e64af2 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -105,77 +105,11 @@ pub fn generate_banks( Ok(banks_vec) } -pub fn create_basic_project(admin: T::AccountId) -> Result<[u8; 32], DispatchError> { - let title = generate_field_name(1, 100); - let description = generate_field_description(1, 400); - let address = generate_field_name(1, 100); - let creation_date = u64::MAX - 1; - let completion_date = u64::MAX; - let expenditures = create_array_expenditures::(1, 100, 100).unwrap(); - - let private_group_id = generate_field_description(1, 100); - - assert_ok!(FundAdmin::::projects_create_project( - RawOrigin::Signed(admin.clone()).into(), - title.clone(), - description.clone(), - None, - address.clone(), - None, - creation_date, - completion_date, - expenditures.clone(), - None, - None, - private_group_id.clone(), - )); - - let project_id = >::iter_keys().next(); - assert!(project_id.is_some()); - - Ok(project_id.unwrap()) -} - -pub fn create_full_project(admin: T::AccountId) -> Result<[u8; 32], DispatchError> { - let title = generate_field_name(1, 100); - let description = generate_field_description(1, 400); - let image = generate_field_name(1, 100); - let address = generate_field_name(1, 100); - let banks = generate_banks::(1, 100, 100).unwrap(); - let creation_date = u64::MAX - 1; - let completion_date = u64::MAX; - let expenditures = create_array_expenditures::(1, 100, 100).unwrap(); - let job_eligibles = create_array_job_eligibles::(1, 100, 100).unwrap(); - let users_assignation = create_array_users_assignations::(1, ProxyRole::Builder).unwrap(); - assert_ok!(register_users::(admin.clone(), users_assignation.clone())); - - let private_group_id = generate_field_description(1, 100); - - assert_ok!(FundAdmin::::projects_create_project( - RawOrigin::Signed(admin.clone()).into(), - title.clone(), - description.clone(), - Some(image.clone()), - address.clone(), - Some(banks.clone()), - creation_date, - completion_date, - expenditures.clone(), - Some(job_eligibles.clone()), - Some(users_assignation.clone()), - private_group_id.clone(), - )); - - let project_id = >::iter_keys().next(); - assert!(project_id.is_some()); - - Ok(project_id.unwrap()) -} - pub fn create_array_expenditures( num_expenditures: u32, name_size: u32, naics_code_size: u32, + expenditure_type: ExpenditureType ) -> Result, DispatchError> { let mut expenditures_vec: Expenditures = BoundedVec::new(); for i in 0..num_expenditures { @@ -184,7 +118,7 @@ pub fn create_array_expenditures( let naics_code = generate_field_description(1, naics_code_size); let expenditure = ( Some(name), - Some(ExpenditureType::HardCost), + Some(expenditure_type), Some(u64::MAX), Some(naics_code), Some(u32::MAX), @@ -265,6 +199,73 @@ pub fn initialize_pallet(name_size: u32) -> Result(admin: T::AccountId) -> Result<[u8; 32], DispatchError> { + let title = generate_field_name(1, 100); + let description = generate_field_description(1, 400); + let address = generate_field_name(1, 100); + let creation_date = u64::MAX - 1; + let completion_date = u64::MAX; + let expenditures = create_array_expenditures::(1, 100, 100, ExpenditureType::HardCost).unwrap(); + + let private_group_id = generate_field_description(1, 100); + + assert_ok!(FundAdmin::::projects_create_project( + RawOrigin::Signed(admin.clone()).into(), + title.clone(), + description.clone(), + None, + address.clone(), + None, + creation_date, + completion_date, + expenditures.clone(), + None, + None, + private_group_id.clone(), + )); + + let project_id = >::iter_keys().next(); + assert!(project_id.is_some()); + + Ok(project_id.unwrap()) +} + +pub fn create_full_project(admin: T::AccountId) -> Result<[u8; 32], DispatchError> { + let title = generate_field_name(1, 100); + let description = generate_field_description(1, 400); + let image = generate_field_name(1, 100); + let address = generate_field_name(1, 100); + let banks = generate_banks::(1, 100, 100).unwrap(); + let creation_date = u64::MAX - 1; + let completion_date = u64::MAX; + let expenditures = create_array_expenditures::(1, 100, 100, ExpenditureType::HardCost).unwrap(); + let job_eligibles = create_array_job_eligibles::(1, 100, 100).unwrap(); + let users_assignation = create_array_users_assignations::(1, ProxyRole::Builder).unwrap(); + assert_ok!(register_users::(admin.clone(), users_assignation.clone())); + + let private_group_id = generate_field_description(1, 100); + + assert_ok!(FundAdmin::::projects_create_project( + RawOrigin::Signed(admin.clone()).into(), + title.clone(), + description.clone(), + Some(image.clone()), + address.clone(), + Some(banks.clone()), + creation_date, + completion_date, + expenditures.clone(), + Some(job_eligibles.clone()), + Some(users_assignation.clone()), + private_group_id.clone(), + )); + + let project_id = >::iter_keys().next(); + assert!(project_id.is_some()); + + Ok(project_id.unwrap()) +} + #[benchmarks(where T: Config)] mod benchmarks { use super::*; @@ -393,7 +394,7 @@ mod benchmarks { let banks = generate_banks::(e, f, g).unwrap(); let creation_date = u64::MAX - 1; let completion_date = u64::MAX; - let expenditures = create_array_expenditures::(h, i, j).unwrap(); + let expenditures = create_array_expenditures::(h, i, j, ExpenditureType::HardCost).unwrap(); let job_eligibles = create_array_job_eligibles::(k, l, m).unwrap(); let users_assignation = create_array_users_assignations::(n, ProxyRole::Builder).unwrap(); @@ -503,6 +504,41 @@ mod benchmarks { } } + #[benchmark] + fn expenditures_and_job_eligibles( + a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, + b: Linear<1, 100>, + c: Linear<1, 400>, + d: Linear<1, { T::MaxRegistrationsAtTime::get() }>, + e: Linear<1, 100>, + f: Linear<1, 400> + ) { + let admin = initialize_pallet::(100).unwrap(); + let project_id = create_basic_project::(admin.clone()).unwrap(); + + let expenditures = create_array_expenditures::(a, b, c, ExpenditureType::SoftCost).unwrap(); + let job_eligibles = create_array_job_eligibles::(d, e, f).unwrap(); + + #[extrinsic_call] + _( + RawOrigin::Signed(admin.clone()), + project_id.clone(), + None, + Some(job_eligibles.clone()), + ); + + let project_info = >::get(project_id.clone()); + >::iter().for_each(|(key, value)| { + assert!(value.project_id == project_id); + }); + + >::iter().for_each(|(key, value)| { + assert!(value.project_id == project_id); + }); + } + + + impl_benchmark_test_suite! { FundAdmin, crate::mock::new_test_ext(), From fe241eaf73a92466d87ea89ea0d2b60c1fdc4e00 Mon Sep 17 00:00:00 2001 From: didiermis Date: Wed, 3 Apr 2024 19:02:59 -0600 Subject: [PATCH 20/40] Enhanced the Fund Admin pallet benchmarking function to include drawdown and transaction generation in test parameters. I added two helper functions, `get_drawdown_id` and `get_expenditure_id`, to fetch respective ids from existing data. I also introduced the `create_array_transactions` function, which allows generating a list of transaction data in a given setup. Finally, I added a new benchmark `submit_drawdown` to simulate the business operation of handling drawdown submissions, leveraging the newly developed helper functions and data generating methods. This significantly improves the granularity and coverage of the benchmark tests. --- pallets/fund-admin/src/benchmarking.rs | 125 ++++++++++++++++++++----- 1 file changed, 103 insertions(+), 22 deletions(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index 1e64af2..a37b937 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -109,7 +109,7 @@ pub fn create_array_expenditures( num_expenditures: u32, name_size: u32, naics_code_size: u32, - expenditure_type: ExpenditureType + expenditure_type: ExpenditureType, ) -> Result, DispatchError> { let mut expenditures_vec: Expenditures = BoundedVec::new(); for i in 0..num_expenditures { @@ -180,6 +180,65 @@ pub fn register_users( Ok(()) } +fn get_drawdown_id( + project_id: ProjectId, + drawdown_type: DrawdownType, + drawdown_number: DrawdownNumber, +) -> DrawdownId { + let mut drawdown_id: DrawdownId = [0; 32]; + let drawdonws_by_project = >::get(project_id); + + for i in 0..drawdonws_by_project.len() { + let drawdown_data = >::get(drawdonws_by_project[i]).unwrap(); + if drawdown_data.drawdown_type == drawdown_type && + drawdown_data.drawdown_number == drawdown_number + { + drawdown_id = drawdonws_by_project[i]; + } + } + drawdown_id +} + +fn get_expenditure_id( + project_id: ProjectId, + name: FieldName, + expenditure_type: ExpenditureType, +) -> ExpenditureId { + let mut expenditure_id: [u8; 32] = [0; 32]; + let expenditures_by_project = >::get(project_id); + + for i in 0..expenditures_by_project.len() { + let expenditure_data = >::get(expenditures_by_project[i]).unwrap(); + if expenditure_data.name == name && expenditure_data.expenditure_type == expenditure_type { + expenditure_id = expenditures_by_project[i]; + } + } + expenditure_id +} + +pub fn create_array_transactions( + num_transactions: u32, + expenditure_id: [u8; 32], + num_documents: u32, + name_size: u32, + cid_size: u32, +) -> Result, DispatchError> { + let mut transactions_vec: Transactions = BoundedVec::new(); + let documents = create_array_documents::(num_documents, name_size, cid_size).unwrap(); + for i in 0..num_transactions { + let transaction = ( + Some(expenditure_id), + Some(i as u64), + None, + CUDAction::Create, + None, + ); + transactions_vec.try_push(transaction).unwrap(); + } + + Ok(transactions_vec) +} + pub fn initialize_pallet(name_size: u32) -> Result { let _ = FundAdmin::::initial_setup(RawOrigin::Root.into()); let admin: T::AccountId = account("admin", 0, SEED); @@ -205,7 +264,8 @@ pub fn create_basic_project(admin: T::AccountId) -> Result<[u8; 32], let address = generate_field_name(1, 100); let creation_date = u64::MAX - 1; let completion_date = u64::MAX; - let expenditures = create_array_expenditures::(1, 100, 100, ExpenditureType::HardCost).unwrap(); + let expenditures = + create_array_expenditures::(1, 100, 100, ExpenditureType::HardCost).unwrap(); let private_group_id = generate_field_description(1, 100); @@ -238,7 +298,8 @@ pub fn create_full_project(admin: T::AccountId) -> Result<[u8; 32], D let banks = generate_banks::(1, 100, 100).unwrap(); let creation_date = u64::MAX - 1; let completion_date = u64::MAX; - let expenditures = create_array_expenditures::(1, 100, 100, ExpenditureType::HardCost).unwrap(); + let expenditures = + create_array_expenditures::(1, 100, 100, ExpenditureType::HardCost).unwrap(); let job_eligibles = create_array_job_eligibles::(1, 100, 100).unwrap(); let users_assignation = create_array_users_assignations::(1, ProxyRole::Builder).unwrap(); assert_ok!(register_users::(admin.clone(), users_assignation.clone())); @@ -394,7 +455,8 @@ mod benchmarks { let banks = generate_banks::(e, f, g).unwrap(); let creation_date = u64::MAX - 1; let completion_date = u64::MAX; - let expenditures = create_array_expenditures::(h, i, j, ExpenditureType::HardCost).unwrap(); + let expenditures = + create_array_expenditures::(h, i, j, ExpenditureType::HardCost).unwrap(); let job_eligibles = create_array_job_eligibles::(k, l, m).unwrap(); let users_assignation = create_array_users_assignations::(n, ProxyRole::Builder).unwrap(); @@ -480,21 +542,16 @@ mod benchmarks { } #[benchmark] - fn projects_assign_user( - a: Linear<1, { T::MaxRegistrationsAtTime::get() }> - ) { + fn projects_assign_user(a: Linear<1, { T::MaxRegistrationsAtTime::get() }>) { let admin = initialize_pallet::(100).unwrap(); let project_id = create_basic_project::(admin.clone()).unwrap(); - let users_assignation = create_array_users_assignations::(a, ProxyRole::Builder).unwrap(); + let users_assignation = + create_array_users_assignations::(a, ProxyRole::Builder).unwrap(); assert_ok!(register_users::(admin.clone(), users_assignation.clone())); #[extrinsic_call] - _( - RawOrigin::Signed(admin.clone()), - project_id.clone(), - users_assignation.clone(), - ); + _(RawOrigin::Signed(admin.clone()), project_id.clone(), users_assignation.clone()); for (user, role, _) in users_assignation.iter() { let user_info = >::get(user.clone()); @@ -511,21 +568,17 @@ mod benchmarks { c: Linear<1, 400>, d: Linear<1, { T::MaxRegistrationsAtTime::get() }>, e: Linear<1, 100>, - f: Linear<1, 400> + f: Linear<1, 400>, ) { let admin = initialize_pallet::(100).unwrap(); let project_id = create_basic_project::(admin.clone()).unwrap(); - let expenditures = create_array_expenditures::(a, b, c, ExpenditureType::SoftCost).unwrap(); + let expenditures = + create_array_expenditures::(a, b, c, ExpenditureType::SoftCost).unwrap(); let job_eligibles = create_array_job_eligibles::(d, e, f).unwrap(); #[extrinsic_call] - _( - RawOrigin::Signed(admin.clone()), - project_id.clone(), - None, - Some(job_eligibles.clone()), - ); + _(RawOrigin::Signed(admin.clone()), project_id.clone(), None, Some(job_eligibles.clone())); let project_info = >::get(project_id.clone()); >::iter().for_each(|(key, value)| { @@ -536,7 +589,35 @@ mod benchmarks { assert!(value.project_id == project_id); }); } - + + #[benchmark] + fn submit_drawdown( + a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, + b: Linear<1, { T::MaxDocuments::get() }>, + c: Linear<1, 100>, + d: Linear<1, 100>, + ) { + let admin = initialize_pallet::(100).unwrap(); + let project_id = create_full_project::(admin.clone()).unwrap(); + let drawdown_type = DrawdownType::EB5; + let drawdown_number = 1 as u32; + let drawdown_id = get_drawdown_id::(project_id.clone(), drawdown_type, drawdown_number); + let expenditure_id = >::iter_keys().next(); + assert!(expenditure_id.is_some()); + let transactions = create_array_transactions::(a, expenditure_id.unwrap(), b, c, d).unwrap(); + + #[extrinsic_call] + _( + RawOrigin::Signed(admin.clone()), + project_id.clone(), + drawdown_id.clone(), + Some(transactions.clone()), + false, + ); + + let drawdown_info = >::get(drawdown_id.clone()); + assert!(drawdown_info.is_some()); + } impl_benchmark_test_suite! { From 5b57bd7cc2a74502013a471a47954d7cc7f41f0c Mon Sep 17 00:00:00 2001 From: didiermis Date: Wed, 3 Apr 2024 20:08:06 -0600 Subject: [PATCH 21/40] Enhanced the Fund Admin pallet benchmarking function with more comprehensive test scenarios. I updated the `create_full_project` function to create two expenditures instead of one. I also corrected the submit_drawdown benchmark to properly reflect the status change once a drawdown is submitted. Furthermore, I added a new `approve_drawdown` benchmark to simulate and measure the performance of the drawdown approval process. This update will allow clearer visibility into the cost of approving drawdowns in different configurations. These changes will ultimately contribute to more accurate and insightful benchmarking results --- pallets/fund-admin/src/benchmarking.rs | 41 ++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index a37b937..526c993 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -299,7 +299,7 @@ pub fn create_full_project(admin: T::AccountId) -> Result<[u8; 32], D let creation_date = u64::MAX - 1; let completion_date = u64::MAX; let expenditures = - create_array_expenditures::(1, 100, 100, ExpenditureType::HardCost).unwrap(); + create_array_expenditures::(2, 100, 100, ExpenditureType::HardCost).unwrap(); let job_eligibles = create_array_job_eligibles::(1, 100, 100).unwrap(); let users_assignation = create_array_users_assignations::(1, ProxyRole::Builder).unwrap(); assert_ok!(register_users::(admin.clone(), users_assignation.clone())); @@ -595,7 +595,7 @@ mod benchmarks { a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, b: Linear<1, { T::MaxDocuments::get() }>, c: Linear<1, 100>, - d: Linear<1, 100>, + d: Linear<1, 100> ) { let admin = initialize_pallet::(100).unwrap(); let project_id = create_full_project::(admin.clone()).unwrap(); @@ -612,13 +612,48 @@ mod benchmarks { project_id.clone(), drawdown_id.clone(), Some(transactions.clone()), - false, + true, ); let drawdown_info = >::get(drawdown_id.clone()); assert!(drawdown_info.is_some()); + assert_eq!(drawdown_info.unwrap().status, DrawdownStatus::Submitted); } + #[benchmark] + fn approve_drawdown( + a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, + b: Linear<1, { T::MaxDocuments::get() }>, + c: Linear<1, 100>, + d: Linear<1, 100> + ) { + let admin = initialize_pallet::(100).unwrap(); + let project_id = create_full_project::(admin.clone()).unwrap(); + let drawdown_type = DrawdownType::EB5; + let drawdown_number = 1 as u32; + let drawdown_id = get_drawdown_id::(project_id.clone(), drawdown_type, drawdown_number); + let expenditure_id = >::iter_keys().next(); + assert!(expenditure_id.is_some()); + let transactions = create_array_transactions::(2, expenditure_id.unwrap(), 1, 100, 100).unwrap(); + assert_ok!(FundAdmin::::submit_drawdown( + RawOrigin::Signed(admin.clone()).into(), + project_id.clone(), + drawdown_id.clone(), + Some(transactions.clone()), + false, + )); + + let last_expenditure_id = >::iter_keys().last(); + let bulkupload_transactions = create_array_transactions::(a, last_expenditure_id.unwrap(), b, c, d).unwrap(); + + #[extrinsic_call] + _(RawOrigin::Signed(admin.clone()), project_id.clone(), drawdown_id.clone(), Some(true), Some(bulkupload_transactions.clone())); + + let drawdown_info = >::get(drawdown_id.clone()); + assert!(drawdown_info.is_some()); + assert_eq!(drawdown_info.unwrap().status, DrawdownStatus::Approved); + + } impl_benchmark_test_suite! { FundAdmin, From f38d4c7419d8ea9017253046c05ca2dea1fbee41 Mon Sep 17 00:00:00 2001 From: didiermis Date: Thu, 4 Apr 2024 08:16:54 -0600 Subject: [PATCH 22/40] Updated format --- Cargo.lock | 76 +++++++++++++------------- pallets/fund-admin/src/benchmarking.rs | 30 +++++----- 2 files changed, 54 insertions(+), 52 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4d949c7..08cb513 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1108,7 +1108,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-support", "frame-support-procedural", @@ -1145,7 +1145,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "aquamarine", "bitflags 1.3.2", @@ -1185,7 +1185,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "Inflector", "cfg-expr", @@ -1204,7 +1204,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -1216,7 +1216,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "proc-macro2", "quote", @@ -1226,7 +1226,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "cfg-if", "frame-support", @@ -2099,7 +2099,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-benchmarking", "frame-support", @@ -2256,7 +2256,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "docify", "frame-benchmarking", @@ -2276,7 +2276,7 @@ dependencies = [ [[package]] name = "pallet-uniques" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-benchmarking", "frame-support", @@ -3003,7 +3003,7 @@ checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "hash-db", "log", @@ -3024,7 +3024,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "Inflector", "blake2", @@ -3038,7 +3038,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "23.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "scale-info", @@ -3051,7 +3051,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "16.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "integer-sqrt", "num-traits", @@ -3065,7 +3065,7 @@ dependencies = [ [[package]] name = "sp-core" version = "21.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "array-bytes", "bandersnatch_vrfs", @@ -3112,7 +3112,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "9.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "blake2b_simd", "byteorder", @@ -3125,7 +3125,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "9.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "quote", "sp-core-hashing", @@ -3135,7 +3135,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "proc-macro2", "quote", @@ -3145,7 +3145,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.19.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "environmental", "parity-scale-codec", @@ -3156,7 +3156,7 @@ dependencies = [ [[package]] name = "sp-genesis-builder" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "serde_json", "sp-api", @@ -3167,7 +3167,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -3181,7 +3181,7 @@ dependencies = [ [[package]] name = "sp-io" version = "23.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "bytes", "ed25519-dalek", @@ -3205,7 +3205,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.27.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "parking_lot", @@ -3217,7 +3217,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -3228,7 +3228,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "backtrace", "lazy_static", @@ -3238,7 +3238,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "either", "hash256-std-hasher", @@ -3260,7 +3260,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -3278,7 +3278,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "11.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "Inflector", "proc-macro-crate", @@ -3290,7 +3290,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -3304,7 +3304,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.28.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "hash-db", "log", @@ -3325,12 +3325,12 @@ dependencies = [ [[package]] name = "sp-std" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" [[package]] name = "sp-storage" version = "13.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "impl-serde", "parity-scale-codec", @@ -3343,7 +3343,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "async-trait", "parity-scale-codec", @@ -3356,7 +3356,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "10.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "sp-std", @@ -3368,7 +3368,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "22.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "ahash 0.8.6", "hash-db", @@ -3392,7 +3392,7 @@ dependencies = [ [[package]] name = "sp-version" version = "22.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "impl-serde", "parity-scale-codec", @@ -3409,7 +3409,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -3420,7 +3420,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -3433,7 +3433,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "20.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "scale-info", diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index 526c993..3a15a30 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -226,13 +226,7 @@ pub fn create_array_transactions( let mut transactions_vec: Transactions = BoundedVec::new(); let documents = create_array_documents::(num_documents, name_size, cid_size).unwrap(); for i in 0..num_transactions { - let transaction = ( - Some(expenditure_id), - Some(i as u64), - None, - CUDAction::Create, - None, - ); + let transaction = (Some(expenditure_id), Some(i as u64), None, CUDAction::Create, None); transactions_vec.try_push(transaction).unwrap(); } @@ -595,7 +589,7 @@ mod benchmarks { a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, b: Linear<1, { T::MaxDocuments::get() }>, c: Linear<1, 100>, - d: Linear<1, 100> + d: Linear<1, 100>, ) { let admin = initialize_pallet::(100).unwrap(); let project_id = create_full_project::(admin.clone()).unwrap(); @@ -604,7 +598,8 @@ mod benchmarks { let drawdown_id = get_drawdown_id::(project_id.clone(), drawdown_type, drawdown_number); let expenditure_id = >::iter_keys().next(); assert!(expenditure_id.is_some()); - let transactions = create_array_transactions::(a, expenditure_id.unwrap(), b, c, d).unwrap(); + let transactions = + create_array_transactions::(a, expenditure_id.unwrap(), b, c, d).unwrap(); #[extrinsic_call] _( @@ -625,7 +620,7 @@ mod benchmarks { a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, b: Linear<1, { T::MaxDocuments::get() }>, c: Linear<1, 100>, - d: Linear<1, 100> + d: Linear<1, 100>, ) { let admin = initialize_pallet::(100).unwrap(); let project_id = create_full_project::(admin.clone()).unwrap(); @@ -634,7 +629,8 @@ mod benchmarks { let drawdown_id = get_drawdown_id::(project_id.clone(), drawdown_type, drawdown_number); let expenditure_id = >::iter_keys().next(); assert!(expenditure_id.is_some()); - let transactions = create_array_transactions::(2, expenditure_id.unwrap(), 1, 100, 100).unwrap(); + let transactions = + create_array_transactions::(2, expenditure_id.unwrap(), 1, 100, 100).unwrap(); assert_ok!(FundAdmin::::submit_drawdown( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -644,15 +640,21 @@ mod benchmarks { )); let last_expenditure_id = >::iter_keys().last(); - let bulkupload_transactions = create_array_transactions::(a, last_expenditure_id.unwrap(), b, c, d).unwrap(); + let bulkupload_transactions = + create_array_transactions::(a, last_expenditure_id.unwrap(), b, c, d).unwrap(); #[extrinsic_call] - _(RawOrigin::Signed(admin.clone()), project_id.clone(), drawdown_id.clone(), Some(true), Some(bulkupload_transactions.clone())); + _( + RawOrigin::Signed(admin.clone()), + project_id.clone(), + drawdown_id.clone(), + Some(true), + Some(bulkupload_transactions.clone()), + ); let drawdown_info = >::get(drawdown_id.clone()); assert!(drawdown_info.is_some()); assert_eq!(drawdown_info.unwrap().status, DrawdownStatus::Approved); - } impl_benchmark_test_suite! { From e8c508a274a0f26a00e6d0fb35d7a02e05843d15 Mon Sep 17 00:00:00 2001 From: didiermis Date: Thu, 4 Apr 2024 10:50:42 -0600 Subject: [PATCH 23/40] Implemented enhancements in the benchmarking module of the Fund Admin pallet. I added a new utility function `create_array_transactions_feedback` for generating test transaction data with feedback information. Also, updated the `submit_drawdown` benchmark to match the new array transactions' size. To test the process of rejection, I added a new benchmark test `reject_drawdown` to simulate the scenario of rejecting a drawdown submission, alongside validating the status change to 'Rejected'. --- pallets/fund-admin/src/benchmarking.rs | 55 +++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index 3a15a30..a18d2f3 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -321,6 +321,21 @@ pub fn create_full_project(admin: T::AccountId) -> Result<[u8; 32], D Ok(project_id.unwrap()) } +pub fn create_array_transactions_feedback( + transaction_ids: Vec<[u8; 32]>, + description_size: u32, +) -> Result, DispatchError> { + let mut transactions_feedback_vec: TransactionsFeedback = BoundedVec::new(); + for i in 0..transaction_ids.len() { + let description = generate_field_description(1, description_size); + let transaction_feedback = (transaction_ids[i], description); + transactions_feedback_vec.try_push(transaction_feedback).unwrap(); + } + + Ok(transactions_feedback_vec) +} + + #[benchmarks(where T: Config)] mod benchmarks { use super::*; @@ -630,7 +645,7 @@ mod benchmarks { let expenditure_id = >::iter_keys().next(); assert!(expenditure_id.is_some()); let transactions = - create_array_transactions::(2, expenditure_id.unwrap(), 1, 100, 100).unwrap(); + create_array_transactions::(1, expenditure_id.unwrap(), 1, 100, 100).unwrap(); assert_ok!(FundAdmin::::submit_drawdown( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -657,6 +672,44 @@ mod benchmarks { assert_eq!(drawdown_info.unwrap().status, DrawdownStatus::Approved); } + #[benchmark] + fn reject_drawdown( + a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, + b: Linear<1, 400>, + c: Linear<1, 400>, + ) { + let admin = initialize_pallet::(100).unwrap(); + let project_id = create_full_project::(admin.clone()).unwrap(); + let drawdown_type = DrawdownType::EB5; + let drawdown_number = 1 as u32; + let drawdown_id = get_drawdown_id::(project_id.clone(), drawdown_type, drawdown_number); + let expenditure_id = >::iter_keys().next(); + assert!(expenditure_id.is_some()); + let transactions = + create_array_transactions::(a, expenditure_id.unwrap(), 1, 100, 100).unwrap(); + assert_ok!(FundAdmin::::submit_drawdown( + RawOrigin::Signed(admin.clone()).into(), + project_id.clone(), + drawdown_id.clone(), + Some(transactions.clone()), + true, + )); + + let transaction_ids = >::get(project_id.clone(), drawdown_id.clone()).to_vec(); + let transactions_feedback = + create_array_transactions_feedback::(transaction_ids.clone(), b).unwrap(); + let drawdown_feedback = generate_field_description(1, c); + + + #[extrinsic_call] + _(RawOrigin::Signed(admin.clone()), project_id.clone(), drawdown_id.clone(), Some(transactions_feedback.clone()), Some(drawdown_feedback.clone())); + + let drawdown_info = >::get(drawdown_id.clone()); + assert!(drawdown_info.is_some()); + assert_eq!(drawdown_info.unwrap().status, DrawdownStatus::Rejected); + + } + impl_benchmark_test_suite! { FundAdmin, crate::mock::new_test_ext(), From 0b0ac667390291f95ff1f17adb1adddc545d0ba7 Mon Sep 17 00:00:00 2001 From: didiermis Date: Thu, 4 Apr 2024 11:10:19 -0600 Subject: [PATCH 24/40] Added a new benchmark 'up_bulkupload' to the Fund Admin pallet. This test simulates the bulk uploading process for Developer Equity drawdowns, creating an array of documents and submitting them. The test evaluates the performance aspect of the uploading process and verifies that the drawdown status is updated to 'Submitted' post submission. --- pallets/fund-admin/src/benchmarking.rs | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index a18d2f3..16ce2f1 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -710,6 +710,38 @@ mod benchmarks { } + #[benchmark] + fn up_bulkupload( + a: Linear<1, 400>, + b: Linear<1, { T::MaxDocuments::get() }>, + c: Linear<1, 100>, + d: Linear<1, 100>, + ) { + let admin = initialize_pallet::(100).unwrap(); + let project_id = create_full_project::(admin.clone()).unwrap(); + let drawdown_type = DrawdownType::DeveloperEquity; + let drawdown_number = 1 as u32; + let drawdown_id = get_drawdown_id::(project_id.clone(), drawdown_type, drawdown_number); + let description = generate_field_description(1, a); + let total_amount = u64::MAX; + let documents = create_array_documents::(b, c, d).unwrap(); + + #[extrinsic_call] + _( + RawOrigin::Signed(admin.clone()), + project_id.clone(), + drawdown_id.clone(), + description.clone(), + total_amount.clone(), + documents.clone(), + ); + + let drawdown_info = >::get(drawdown_id.clone()); + assert!(drawdown_info.is_some()); + assert_eq!(drawdown_info.unwrap().status, DrawdownStatus::Submitted); + + } + impl_benchmark_test_suite! { FundAdmin, crate::mock::new_test_ext(), From 46e2e1ffa1a75302bea801d0475182eff69857e3 Mon Sep 17 00:00:00 2001 From: didiermis Date: Thu, 4 Apr 2024 11:37:52 -0600 Subject: [PATCH 25/40] Extended the benchmarking module for the Fund Admin pallet by adding a new function `create_array_inflation_rate` for generating test data of project inflation rates. I also introduced a benchmark test `inflation_rate` that evaluates the update operation of inflation rates for multiple projects sequentially, and verifies that these updates have been correctly applied in the storage. --- pallets/fund-admin/src/benchmarking.rs | 44 +++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index 16ce2f1..592230a 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -335,6 +335,20 @@ pub fn create_array_transactions_feedback( Ok(transactions_feedback_vec) } +pub fn create_array_inflation_rate( + num_inflation_rates: u32, + project_id: [u8; 32], +) -> Result, DispatchError> { + let mut inflation_rate_vec: ProjectsInflation = BoundedVec::new(); + for i in 0..num_inflation_rates { + let inflation_rate = (project_id, Some(u32::MAX), CUDAction::Update); + inflation_rate_vec.try_push(inflation_rate).unwrap(); + } + + inflation_rate_vec[0].2 = CUDAction::Create; + + Ok(inflation_rate_vec) +} #[benchmarks(where T: Config)] mod benchmarks { @@ -695,19 +709,24 @@ mod benchmarks { true, )); - let transaction_ids = >::get(project_id.clone(), drawdown_id.clone()).to_vec(); + let transaction_ids = + >::get(project_id.clone(), drawdown_id.clone()).to_vec(); let transactions_feedback = create_array_transactions_feedback::(transaction_ids.clone(), b).unwrap(); let drawdown_feedback = generate_field_description(1, c); - #[extrinsic_call] - _(RawOrigin::Signed(admin.clone()), project_id.clone(), drawdown_id.clone(), Some(transactions_feedback.clone()), Some(drawdown_feedback.clone())); + _( + RawOrigin::Signed(admin.clone()), + project_id.clone(), + drawdown_id.clone(), + Some(transactions_feedback.clone()), + Some(drawdown_feedback.clone()), + ); let drawdown_info = >::get(drawdown_id.clone()); assert!(drawdown_info.is_some()); assert_eq!(drawdown_info.unwrap().status, DrawdownStatus::Rejected); - } #[benchmark] @@ -739,7 +758,22 @@ mod benchmarks { let drawdown_info = >::get(drawdown_id.clone()); assert!(drawdown_info.is_some()); assert_eq!(drawdown_info.unwrap().status, DrawdownStatus::Submitted); - + } + + #[benchmark] + fn inflation_rate(a: Linear<1, { T::MaxRegistrationsAtTime::get() }>) { + let admin = initialize_pallet::(100).unwrap(); + let project_id = create_full_project::(admin.clone()).unwrap(); + let inflation_projects = create_array_inflation_rate::(a, project_id).unwrap(); + + #[extrinsic_call] + _(RawOrigin::Signed(admin.clone()), inflation_projects.clone()); + + for (project_id, rate, _) in inflation_projects.iter() { + let project_info = >::get(project_id.clone()); + assert!(project_info.is_some()); + assert_eq!(project_info.unwrap().inflation_rate, *rate); + } } impl_benchmark_test_suite! { From 8bad4485509b4404fff01130ae9872395890414e Mon Sep 17 00:00:00 2001 From: didiermis Date: Thu, 4 Apr 2024 12:01:35 -0600 Subject: [PATCH 26/40] Increased the benchmarking functionality for the Fund Admin pallet by constructing a new function `create_array_revenue_transactions` to generate test data of revenue transactions. Plus, created a new benchmark test `submit_revenue` to simulate submitting revenue and ensuring the status of the revenue is correctly updated to 'Submitted' after submission. --- pallets/fund-admin/src/benchmarking.rs | 49 +++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index 592230a..e3315a0 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -226,7 +226,7 @@ pub fn create_array_transactions( let mut transactions_vec: Transactions = BoundedVec::new(); let documents = create_array_documents::(num_documents, name_size, cid_size).unwrap(); for i in 0..num_transactions { - let transaction = (Some(expenditure_id), Some(i as u64), None, CUDAction::Create, None); + let transaction = (Some(expenditure_id), Some(i as u64), Some(documents.clone()), CUDAction::Create, None); transactions_vec.try_push(transaction).unwrap(); } @@ -350,6 +350,24 @@ pub fn create_array_inflation_rate( Ok(inflation_rate_vec) } +fn create_array_revenue_transactions( + num_transactions: u32, + job_eligible_id: [u8; 32], + num_documents: u32, + name_size: u32, + cid_size: u32, +) -> Result, DispatchError> { + let mut transactions_vec: RevenueTransactions = BoundedVec::new(); + let documents = create_array_documents::(num_documents, name_size, cid_size).unwrap(); + for i in 0..num_transactions { + let transaction = (Some(job_eligible_id), Some(i as u64), Some(documents.clone()), CUDAction::Create, None); + transactions_vec.try_push(transaction).unwrap(); + } + + Ok(transactions_vec) +} + + #[benchmarks(where T: Config)] mod benchmarks { use super::*; @@ -776,6 +794,35 @@ mod benchmarks { } } + #[benchmark] + fn submit_revenue( + a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, + b: Linear<1, { T::MaxDocuments::get() }>, + c: Linear<1, 100>, + d: Linear<1, 100>, + ) { + let admin = initialize_pallet::(100).unwrap(); + let project_id = create_full_project::(admin.clone()).unwrap(); + let revenue_id = >::iter_keys().next(); + let job_eligible_id = >::iter_keys().next(); + assert!(job_eligible_id.is_some()); + let transactions = + create_array_revenue_transactions::(a, job_eligible_id.unwrap(), b, c, d).unwrap(); + + #[extrinsic_call] + _( + RawOrigin::Signed(admin.clone()), + project_id.clone(), + revenue_id.clone().unwrap(), + Some(transactions.clone()), + true, + ); + + let revenue_info = >::get(revenue_id.clone().unwrap()); + assert!(revenue_info.is_some()); + assert_eq!(revenue_info.unwrap().status, RevenueStatus::Submitted); + } + impl_benchmark_test_suite! { FundAdmin, crate::mock::new_test_ext(), From 2ad7323ca682a6147db411c549da779c517bb7de Mon Sep 17 00:00:00 2001 From: didiermis Date: Thu, 4 Apr 2024 12:15:52 -0600 Subject: [PATCH 27/40] Added a new benchmark test for the `approve_revenue` function in the Fund Admin pallet. The test initialize the pallet, creates a full project, and then creates a revenue submission on behalf of an eligible job. It checks that the revenue submission was successful and that the status of the revenue is correctly set to 'Approved'. The changes aim to ensure that the `approve_revenue` function works as expected and maintains a consistent performance. --- pallets/fund-admin/src/benchmarking.rs | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index e3315a0..3026ef6 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -823,6 +823,35 @@ mod benchmarks { assert_eq!(revenue_info.unwrap().status, RevenueStatus::Submitted); } + #[benchmark] + fn approve_revenue() { + let admin = initialize_pallet::(100).unwrap(); + let project_id = create_full_project::(admin.clone()).unwrap(); + let revenue_id = >::iter_keys().next(); + let job_eligible_id = >::iter_keys().next(); + assert!(job_eligible_id.is_some()); + let transactions = + create_array_revenue_transactions::(1, job_eligible_id.unwrap(), 1, 100, 100).unwrap(); + assert_ok!(FundAdmin::::submit_revenue( + RawOrigin::Signed(admin.clone()).into(), + project_id.clone(), + revenue_id.clone().unwrap(), + Some(transactions.clone()), + true, + )); + + #[extrinsic_call] + _( + RawOrigin::Signed(admin.clone()), + project_id.clone(), + revenue_id.clone().unwrap() + ); + + let revenue_info = >::get(revenue_id.clone().unwrap()); + assert!(revenue_info.is_some()); + assert_eq!(revenue_info.unwrap().status, RevenueStatus::Approved); + } + impl_benchmark_test_suite! { FundAdmin, crate::mock::new_test_ext(), From 005c708df3626364dfedad1f6582c1e3f974804a Mon Sep 17 00:00:00 2001 From: didiermis Date: Thu, 4 Apr 2024 12:19:44 -0600 Subject: [PATCH 28/40] Added the benchmark test `reject_revenue` in the Fund Admin pallet which verifies the functionality and performance of the `RejectRevenue` extrinsic. The test includes initialization of the pallet, creating a full project, submitting a revenue, and then rejecting it with transaction feedback. The assert statements validate that the revenue has been updated with the status 'Rejected'. This work improves our testing coverage and validates the performance of revenue rejecting functionality. --- pallets/fund-admin/src/benchmarking.rs | 39 ++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index 3026ef6..95b7a3d 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -852,6 +852,45 @@ mod benchmarks { assert_eq!(revenue_info.unwrap().status, RevenueStatus::Approved); } + #[benchmark] + fn reject_revenue( + a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, + b: Linear<1, 400> + ) { + let admin = initialize_pallet::(100).unwrap(); + let project_id = create_full_project::(admin.clone()).unwrap(); + let revenue_id = >::iter_keys().next(); + let job_eligible_id = >::iter_keys().next(); + assert!(job_eligible_id.is_some()); + let transactions = + create_array_revenue_transactions::(a, job_eligible_id.unwrap(), 1, 100, 100).unwrap(); + assert_ok!(FundAdmin::::submit_revenue( + RawOrigin::Signed(admin.clone()).into(), + project_id.clone(), + revenue_id.clone().unwrap(), + Some(transactions.clone()), + true, + )); + + let transaction_ids = + >::get(project_id.clone(), revenue_id.clone().unwrap()) + .to_vec(); + let transactions_feedback = + create_array_transactions_feedback::(transaction_ids.clone(), b).unwrap(); + + #[extrinsic_call] + _( + RawOrigin::Signed(admin.clone()), + project_id.clone(), + revenue_id.clone().unwrap(), + transactions_feedback.clone() + ); + + let revenue_info = >::get(revenue_id.clone().unwrap()); + assert!(revenue_info.is_some()); + assert_eq!(revenue_info.unwrap().status, RevenueStatus::Rejected); + } + impl_benchmark_test_suite! { FundAdmin, crate::mock::new_test_ext(), From 7dbe6bd7cc352c4cee08c052694c1e3146f4580f Mon Sep 17 00:00:00 2001 From: didiermis Date: Thu, 4 Apr 2024 13:15:59 -0600 Subject: [PATCH 29/40] Reformatted the structure of `transaction` and `revenue_transaction` objects in both `create_array_transactions` and `create_array_revenue_transactions` functions for better readability and maintainability. Updated several benchmark testing functions such as `reject_revenue` and `bank_confirming_documents` ensuring the function parameters are clear and concise. A new benchmark testing function `bank_confirming_documents` has been added to measure the performance of confirming documents operation. Minor changes were made to improve the coding standards and readability of the file, like adjusting the line length for better readability. --- pallets/fund-admin/src/benchmarking.rs | 82 +++++++++++++++++++++----- 1 file changed, 67 insertions(+), 15 deletions(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index 95b7a3d..eb3ee36 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -226,7 +226,13 @@ pub fn create_array_transactions( let mut transactions_vec: Transactions = BoundedVec::new(); let documents = create_array_documents::(num_documents, name_size, cid_size).unwrap(); for i in 0..num_transactions { - let transaction = (Some(expenditure_id), Some(i as u64), Some(documents.clone()), CUDAction::Create, None); + let transaction = ( + Some(expenditure_id), + Some(i as u64), + Some(documents.clone()), + CUDAction::Create, + None, + ); transactions_vec.try_push(transaction).unwrap(); } @@ -360,13 +366,18 @@ fn create_array_revenue_transactions( let mut transactions_vec: RevenueTransactions = BoundedVec::new(); let documents = create_array_documents::(num_documents, name_size, cid_size).unwrap(); for i in 0..num_transactions { - let transaction = (Some(job_eligible_id), Some(i as u64), Some(documents.clone()), CUDAction::Create, None); + let transaction = ( + Some(job_eligible_id), + Some(i as u64), + Some(documents.clone()), + CUDAction::Create, + None, + ); transactions_vec.try_push(transaction).unwrap(); } Ok(transactions_vec) } - #[benchmarks(where T: Config)] mod benchmarks { @@ -831,7 +842,8 @@ mod benchmarks { let job_eligible_id = >::iter_keys().next(); assert!(job_eligible_id.is_some()); let transactions = - create_array_revenue_transactions::(1, job_eligible_id.unwrap(), 1, 100, 100).unwrap(); + create_array_revenue_transactions::(1, job_eligible_id.unwrap(), 1, 100, 100) + .unwrap(); assert_ok!(FundAdmin::::submit_revenue( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -841,11 +853,7 @@ mod benchmarks { )); #[extrinsic_call] - _( - RawOrigin::Signed(admin.clone()), - project_id.clone(), - revenue_id.clone().unwrap() - ); + _(RawOrigin::Signed(admin.clone()), project_id.clone(), revenue_id.clone().unwrap()); let revenue_info = >::get(revenue_id.clone().unwrap()); assert!(revenue_info.is_some()); @@ -853,17 +861,15 @@ mod benchmarks { } #[benchmark] - fn reject_revenue( - a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, - b: Linear<1, 400> - ) { + fn reject_revenue(a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, b: Linear<1, 400>) { let admin = initialize_pallet::(100).unwrap(); let project_id = create_full_project::(admin.clone()).unwrap(); let revenue_id = >::iter_keys().next(); let job_eligible_id = >::iter_keys().next(); assert!(job_eligible_id.is_some()); let transactions = - create_array_revenue_transactions::(a, job_eligible_id.unwrap(), 1, 100, 100).unwrap(); + create_array_revenue_transactions::(a, job_eligible_id.unwrap(), 1, 100, 100) + .unwrap(); assert_ok!(FundAdmin::::submit_revenue( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -883,7 +889,7 @@ mod benchmarks { RawOrigin::Signed(admin.clone()), project_id.clone(), revenue_id.clone().unwrap(), - transactions_feedback.clone() + transactions_feedback.clone(), ); let revenue_info = >::get(revenue_id.clone().unwrap()); @@ -891,6 +897,52 @@ mod benchmarks { assert_eq!(revenue_info.unwrap().status, RevenueStatus::Rejected); } + #[benchmark] + fn bank_confirming_documents( + a: Linear<1, { T::MaxDocuments::get() }>, + b: Linear<1, 100>, + c: Linear<1, 100>, + ) { + let admin = initialize_pallet::(100).unwrap(); + let project_id = create_full_project::(admin.clone()).unwrap(); + let drawdown_type = DrawdownType::EB5; + let drawdown_number = 1 as u32; + let drawdown_id = get_drawdown_id::(project_id.clone(), drawdown_type, drawdown_number); + let expenditure_id = >::iter_keys().next(); + assert!(expenditure_id.is_some()); + let transactions = + create_array_transactions::(1, expenditure_id.unwrap(), 1, 100, 100).unwrap(); + assert_ok!(FundAdmin::::submit_drawdown( + RawOrigin::Signed(admin.clone()).into(), + project_id.clone(), + drawdown_id.clone(), + Some(transactions.clone()), + true, + )); + assert_ok!(FundAdmin::::approve_drawdown( + RawOrigin::Signed(admin.clone()).into(), + project_id.clone(), + drawdown_id.clone(), + None, + None, + )); + + let confirming_documents = create_array_documents::(a, b, c).unwrap(); + + #[extrinsic_call] + _( + RawOrigin::Signed(admin.clone()), + project_id.clone(), + drawdown_id.clone(), + Some(confirming_documents.clone()), + CUDAction::Create, + ); + + let drawdown_info = >::get(drawdown_id.clone()); + assert!(drawdown_info.is_some()); + assert_eq!(drawdown_info.unwrap().status, DrawdownStatus::Confirmed); + } + impl_benchmark_test_suite! { FundAdmin, crate::mock::new_test_ext(), From ce09abf0d2df73724b037be8b1385e8e9f44f65a Mon Sep 17 00:00:00 2001 From: didiermis Date: Thu, 4 Apr 2024 13:22:04 -0600 Subject: [PATCH 30/40] Introduced a new benchmark test function `reset_drawdown`. This function tests the performance of resetting a drawdown status to Draft. The test first submits a drawdown then verifies the status has switched to Submitted. After that, it triggers the reset operation and confirms that the drawdown status has been reset to Draft successfully. This function is useful in validating and measuring the performance of the drawdown reset operation. --- pallets/fund-admin/src/benchmarking.rs | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index eb3ee36..3484122 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -943,6 +943,37 @@ mod benchmarks { assert_eq!(drawdown_info.unwrap().status, DrawdownStatus::Confirmed); } + #[benchmark] + fn reset_drawdown() { + let admin = initialize_pallet::(100).unwrap(); + let project_id = create_full_project::(admin.clone()).unwrap(); + let drawdown_type = DrawdownType::EB5; + let drawdown_number = 1 as u32; + let drawdown_id = get_drawdown_id::(project_id.clone(), drawdown_type, drawdown_number); + let expenditure_id = >::iter_keys().next(); + assert!(expenditure_id.is_some()); + let transactions = + create_array_transactions::(1, expenditure_id.unwrap(), 1, 100, 100).unwrap(); + assert_ok!(FundAdmin::::submit_drawdown( + RawOrigin::Signed(admin.clone()).into(), + project_id.clone(), + drawdown_id.clone(), + Some(transactions.clone()), + true, + )); + assert_eq!( + >::get(drawdown_id.clone()).unwrap().status, + DrawdownStatus::Submitted + ); + + #[extrinsic_call] + _(RawOrigin::Signed(admin.clone()), project_id.clone(), drawdown_id.clone()); + + let drawdown_info = >::get(drawdown_id.clone()); + assert!(drawdown_info.is_some()); + assert_eq!(drawdown_info.unwrap().status, DrawdownStatus::Draft); + } + impl_benchmark_test_suite! { FundAdmin, crate::mock::new_test_ext(), From 8fcd2c1e196cd0a5686a15225b40c5c1bf67c86f Mon Sep 17 00:00:00 2001 From: didiermis Date: Thu, 4 Apr 2024 14:50:26 -0600 Subject: [PATCH 31/40] Added a new benchmark test function `recovery_drawdown`. This function tests the performance of the drawdown recovery operation. It first submits and approves a drawdown, then creates recovery transactions associated with the drawdown. This test then verifies that the drawdown status remains Approved after the recovery operation and checks whether the number of transactions associated with the drawdown equates to the sum of the original and recovery transactions. This function is instrumental in validating and assessing the performance of the drawdown recovery operation. --- pallets/fund-admin/src/benchmarking.rs | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index 3484122..63bd784 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -974,6 +974,52 @@ mod benchmarks { assert_eq!(drawdown_info.unwrap().status, DrawdownStatus::Draft); } + #[benchmark] + fn recovery_drawdown( + a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, + b: Linear<1, { T::MaxDocuments::get() }>, + c: Linear<1, 100>, + d: Linear<1, 100>, + ) { + let admin = initialize_pallet::(100).unwrap(); + let project_id = create_full_project::(admin.clone()).unwrap(); + let drawdown_type = DrawdownType::EB5; + let drawdown_number = 1 as u32; + let drawdown_id = get_drawdown_id::(project_id.clone(), drawdown_type, drawdown_number); + let expenditure_id = >::iter_keys().next(); + let last_expenditure_id = >::iter_keys().last(); + + assert!(expenditure_id.is_some()); + let transactions = + create_array_transactions::(1, expenditure_id.unwrap(), 1, 100, 100).unwrap(); + assert_ok!(FundAdmin::::submit_drawdown( + RawOrigin::Signed(admin.clone()).into(), + project_id.clone(), + drawdown_id.clone(), + Some(transactions.clone()), + true, + )); + assert_ok!(FundAdmin::::approve_drawdown( + RawOrigin::Signed(admin.clone()).into(), + project_id.clone(), + drawdown_id.clone(), + None, + None, + )); + + let recovery_transactions = + create_array_transactions::(a, last_expenditure_id.unwrap(), b, c, d).unwrap(); + + #[extrinsic_call] + _(RawOrigin::Signed(admin.clone()), project_id.clone(), drawdown_id.clone(), recovery_transactions.clone()); + + let drawdown_info = >::get(drawdown_id.clone()); + assert!(drawdown_info.is_some()); + assert_eq!(drawdown_info.unwrap().status, DrawdownStatus::Approved); + let transactions_by_drawdown = >::get(project_id.clone(), drawdown_id.clone()); + assert_eq!(transactions_by_drawdown.len(), transactions.len() + recovery_transactions.len()); + } + impl_benchmark_test_suite! { FundAdmin, crate::mock::new_test_ext(), From ec9aef3ee2e431d97f450af93521e62a0b618a54 Mon Sep 17 00:00:00 2001 From: didiermis Date: Thu, 4 Apr 2024 15:41:42 -0600 Subject: [PATCH 32/40] Altered the `create_full_project` test data function to create two job eligibles instead of one. This prepares better test data for revenue-related benchmark testing. Introduced a new benchmark test function `recovery_revenue`. This function first submits and approves a revenue with a series of transactions, then performs a recovery operation with additional transactions. The test then verifies that the revenue status remains Approved after the recovery and checks whether the number of transactions associated with the revenue equates the sum of the original and recovery transactions. This function is instrumental in measuring the performance of the revenue recovery operation. --- pallets/fund-admin/src/benchmarking.rs | 54 +++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index 63bd784..deef611 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -300,7 +300,7 @@ pub fn create_full_project(admin: T::AccountId) -> Result<[u8; 32], D let completion_date = u64::MAX; let expenditures = create_array_expenditures::(2, 100, 100, ExpenditureType::HardCost).unwrap(); - let job_eligibles = create_array_job_eligibles::(1, 100, 100).unwrap(); + let job_eligibles = create_array_job_eligibles::(2, 100, 100).unwrap(); let users_assignation = create_array_users_assignations::(1, ProxyRole::Builder).unwrap(); assert_ok!(register_users::(admin.clone(), users_assignation.clone())); @@ -988,10 +988,11 @@ mod benchmarks { let drawdown_id = get_drawdown_id::(project_id.clone(), drawdown_type, drawdown_number); let expenditure_id = >::iter_keys().next(); let last_expenditure_id = >::iter_keys().last(); - assert!(expenditure_id.is_some()); + assert!(last_expenditure_id.is_some()); let transactions = create_array_transactions::(1, expenditure_id.unwrap(), 1, 100, 100).unwrap(); + assert_ok!(FundAdmin::::submit_drawdown( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -1020,6 +1021,55 @@ mod benchmarks { assert_eq!(transactions_by_drawdown.len(), transactions.len() + recovery_transactions.len()); } + #[benchmark] + fn recovery_revenue( + a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, + b: Linear<1, { T::MaxDocuments::get() }>, + c: Linear<1, 100>, + d: Linear<1, 100>, + ) { + let admin = initialize_pallet::(100).unwrap(); + let project_id = create_full_project::(admin.clone()).unwrap(); + let revenue_id = >::iter_keys().next(); + let job_eligible_id = >::iter_keys().next(); + let last_job_eligible_id = >::iter_keys().last(); + assert!(job_eligible_id.is_some()); + assert!(last_job_eligible_id.is_some()); + let transactions = + create_array_revenue_transactions::(1, job_eligible_id.unwrap(), 1, 100, 100).unwrap(); + assert_ok!(FundAdmin::::submit_revenue( + RawOrigin::Signed(admin.clone()).into(), + project_id.clone(), + revenue_id.clone().unwrap(), + Some(transactions.clone()), + true, + )); + assert_ok!(FundAdmin::::approve_revenue( + RawOrigin::Signed(admin.clone()).into(), + project_id.clone(), + revenue_id.clone().unwrap(), + )); + + let recovery_transactions = + create_array_revenue_transactions::(a, last_job_eligible_id.unwrap(), b, c, d).unwrap(); + + #[extrinsic_call] + _( + RawOrigin::Signed(admin.clone()), + project_id.clone(), + revenue_id.clone().unwrap(), + recovery_transactions.clone(), + ); + + let revenue_info = >::get(revenue_id.clone().unwrap()); + assert!(revenue_info.is_some()); + assert_eq!(revenue_info.unwrap().status, RevenueStatus::Approved); + let transactions_by_revenue = >::get(project_id.clone(), revenue_id.clone().unwrap()); + assert_eq!(transactions_by_revenue.len(), transactions.len() + recovery_transactions.len()); + } + + + impl_benchmark_test_suite! { FundAdmin, crate::mock::new_test_ext(), From dc1fc2a662bf20c997e1f27d8681587a0f6be3fa Mon Sep 17 00:00:00 2001 From: didiermis Date: Thu, 4 Apr 2024 16:09:39 -0600 Subject: [PATCH 33/40] Reformatted a couple of lines in the `recovery_drawdown` and `recovery_revenue` functions for enhanced readability and better alignment with the coding standard. More crucially, implemented a new benchmark test function `kill_storage`. This function measures the performance of purging all data from storage. It counts the numbers of different entities in the storage after the kill operation to make sure all data have been purged correctly. This function is crucial in testing the performance and effectiveness of the data purging operation. --- pallets/fund-admin/src/benchmarking.rs | 49 ++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index deef611..a6c8dcd 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -1012,13 +1012,22 @@ mod benchmarks { create_array_transactions::(a, last_expenditure_id.unwrap(), b, c, d).unwrap(); #[extrinsic_call] - _(RawOrigin::Signed(admin.clone()), project_id.clone(), drawdown_id.clone(), recovery_transactions.clone()); + _( + RawOrigin::Signed(admin.clone()), + project_id.clone(), + drawdown_id.clone(), + recovery_transactions.clone(), + ); let drawdown_info = >::get(drawdown_id.clone()); assert!(drawdown_info.is_some()); assert_eq!(drawdown_info.unwrap().status, DrawdownStatus::Approved); - let transactions_by_drawdown = >::get(project_id.clone(), drawdown_id.clone()); - assert_eq!(transactions_by_drawdown.len(), transactions.len() + recovery_transactions.len()); + let transactions_by_drawdown = + >::get(project_id.clone(), drawdown_id.clone()); + assert_eq!( + transactions_by_drawdown.len(), + transactions.len() + recovery_transactions.len() + ); } #[benchmark] @@ -1036,7 +1045,8 @@ mod benchmarks { assert!(job_eligible_id.is_some()); assert!(last_job_eligible_id.is_some()); let transactions = - create_array_revenue_transactions::(1, job_eligible_id.unwrap(), 1, 100, 100).unwrap(); + create_array_revenue_transactions::(1, job_eligible_id.unwrap(), 1, 100, 100) + .unwrap(); assert_ok!(FundAdmin::::submit_revenue( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -1051,7 +1061,8 @@ mod benchmarks { )); let recovery_transactions = - create_array_revenue_transactions::(a, last_job_eligible_id.unwrap(), b, c, d).unwrap(); + create_array_revenue_transactions::(a, last_job_eligible_id.unwrap(), b, c, d) + .unwrap(); #[extrinsic_call] _( @@ -1064,11 +1075,37 @@ mod benchmarks { let revenue_info = >::get(revenue_id.clone().unwrap()); assert!(revenue_info.is_some()); assert_eq!(revenue_info.unwrap().status, RevenueStatus::Approved); - let transactions_by_revenue = >::get(project_id.clone(), revenue_id.clone().unwrap()); + let transactions_by_revenue = + >::get(project_id.clone(), revenue_id.clone().unwrap()); assert_eq!(transactions_by_revenue.len(), transactions.len() + recovery_transactions.len()); } + #[benchmark] + fn kill_storage() { + let admin = initialize_pallet::(100).unwrap(); + let project_id = create_full_project::(admin.clone()).unwrap(); + #[extrinsic_call] + _(RawOrigin::Root); + + assert_eq!(>::exists(), false); + assert_eq!(>::iter().count(), 0); + assert_eq!(>::iter().count(), 0); + assert_eq!(>::iter().count(), 0); + assert_eq!(>::iter().count(), 0); + assert_eq!(>::iter().count(), 0); + assert_eq!(>::iter().count(), 0); + assert_eq!(>::iter().count(), 0); + assert_eq!(>::iter().count(), 0); + assert_eq!(>::iter().count(), 0); + assert_eq!(>::iter().count(), 0); + assert_eq!(>::iter().count(), 0); + assert_eq!(>::iter().count(), 0); + assert_eq!(>::iter().count(), 0); + assert_eq!(>::iter().count(), 0); + assert_eq!(>::iter().count(), 0); + assert_eq!(>::iter().count(), 0); + } impl_benchmark_test_suite! { FundAdmin, From ca60b2f61e91cc18624de5e5a049ba3ac45de66d Mon Sep 17 00:00:00 2001 From: didiermis Date: Fri, 5 Apr 2024 12:48:59 -0600 Subject: [PATCH 34/40] Refactored the `create_array_users` function in the fund-admin pallet, removing the unnecessary `Result` type from the function signature and returning a `Users` value directly. Also refactored the `create_array_documents` function, removing the unnecessary `Result` type from the function signature and returning a `Documents` value directly. Refactored the `generate_banks` function, removing the unnecessary `Result` type from the function signature and returning a `Banks` value directly. Refactored the `create_array_expenditures` function, removing the unnecessary `Result` type from the function signature and returning an `Expenditures` value directly. Refactored the `create_array_job_eligibles` function, removing the unnecessary `Result` type from the function signature and returning a `JobEligibles` value directly. Refactored the `create_array_users_assignations` function, removing the unnecessary `Result` type from the function signature and returning a `UsersAssignation` value directly. Refactored the `create_array_transactions` function, removing the unnecessary `Result` type from the function signature and returning a `Transactions` value directly. --- pallets/fund-admin/src/benchmarking.rs | 265 +++++++++++++------------ 1 file changed, 134 insertions(+), 131 deletions(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index a6c8dcd..fcd1535 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -47,7 +47,7 @@ pub fn create_array_users( num_users: u32, name_size: u32, role: ProxyRole, -) -> Result, DispatchError> { +) -> Users { let mut users_vec: Users = BoundedVec::new(); for i in 0..num_users { let user_account: T::AccountId = account("user", i, SEED); @@ -57,27 +57,14 @@ pub fn create_array_users( users_vec.try_push(user).unwrap(); } - Ok(users_vec) -} - -#[warn(dead_code)] -pub fn generate_document( - name_size: u32, - cid_size: u32, -) -> Result, DispatchError> { - let field_name = generate_field_name(1, name_size); - let cid = generate_field_name(1, cid_size); - let document = (field_name, cid); - let mut documents_vec: Documents = BoundedVec::new(); - documents_vec.try_push(document).unwrap(); - Ok(documents_vec) + users_vec } pub fn create_array_documents( num_documents: u32, name_size: u32, cid_size: u32, -) -> Result, DispatchError> { +) -> Documents { let mut documents_vec: Documents = BoundedVec::new(); for _i in 0..num_documents { let field_name = generate_field_name(1, name_size); @@ -86,14 +73,14 @@ pub fn create_array_documents( documents_vec.try_push(document).unwrap(); } - Ok(documents_vec) + documents_vec } pub fn generate_banks( num_banks: u32, name_size: u32, address_size: u32, -) -> Result, DispatchError> { +) -> Banks { let mut banks_vec: Banks = BoundedVec::new(); for _i in 0..num_banks { let bank_name = generate_field_name(1, name_size); @@ -102,7 +89,7 @@ pub fn generate_banks( banks_vec.try_push(bank).unwrap(); } - Ok(banks_vec) + banks_vec } pub fn create_array_expenditures( @@ -110,7 +97,7 @@ pub fn create_array_expenditures( name_size: u32, naics_code_size: u32, expenditure_type: ExpenditureType, -) -> Result, DispatchError> { +) -> Expenditures { let mut expenditures_vec: Expenditures = BoundedVec::new(); for i in 0..num_expenditures { let mut name = generate_field_name(1, name_size); @@ -128,14 +115,14 @@ pub fn create_array_expenditures( expenditures_vec.try_push(expenditure).unwrap(); } - Ok(expenditures_vec) + expenditures_vec } pub fn create_array_job_eligibles( num_job_eligibles: u32, name_size: u32, naics_code_size: u32, -) -> Result, DispatchError> { +) -> JobEligibles { let mut job_eligibles_vec: JobEligibles = BoundedVec::new(); for i in 0..num_job_eligibles { let mut name = generate_field_name(1, name_size); @@ -146,13 +133,13 @@ pub fn create_array_job_eligibles( job_eligibles_vec.try_push(job_eligible).unwrap(); } - Ok(job_eligibles_vec) + job_eligibles_vec } pub fn create_array_users_assignations( num_users: u32, role: ProxyRole, -) -> Result, DispatchError> { +) -> UsersAssignation { let mut users_vec: UsersAssignation = BoundedVec::new(); for i in 0..num_users { let user_account: T::AccountId = account("user", i + 1, SEED); @@ -161,7 +148,7 @@ pub fn create_array_users_assignations( users_vec.try_push(user).unwrap(); } - Ok(users_vec) + users_vec } pub fn register_users( @@ -199,32 +186,15 @@ fn get_drawdown_id( drawdown_id } -fn get_expenditure_id( - project_id: ProjectId, - name: FieldName, - expenditure_type: ExpenditureType, -) -> ExpenditureId { - let mut expenditure_id: [u8; 32] = [0; 32]; - let expenditures_by_project = >::get(project_id); - - for i in 0..expenditures_by_project.len() { - let expenditure_data = >::get(expenditures_by_project[i]).unwrap(); - if expenditure_data.name == name && expenditure_data.expenditure_type == expenditure_type { - expenditure_id = expenditures_by_project[i]; - } - } - expenditure_id -} - pub fn create_array_transactions( num_transactions: u32, expenditure_id: [u8; 32], num_documents: u32, name_size: u32, cid_size: u32, -) -> Result, DispatchError> { +) -> Transactions { let mut transactions_vec: Transactions = BoundedVec::new(); - let documents = create_array_documents::(num_documents, name_size, cid_size).unwrap(); + let documents = create_array_documents::(num_documents, name_size, cid_size); for i in 0..num_transactions { let transaction = ( Some(expenditure_id), @@ -236,38 +206,37 @@ pub fn create_array_transactions( transactions_vec.try_push(transaction).unwrap(); } - Ok(transactions_vec) + transactions_vec } -pub fn initialize_pallet(name_size: u32) -> Result { - let _ = FundAdmin::::initial_setup(RawOrigin::Root.into()); +pub fn initialize_pallet(name_size: u32) -> T::AccountId { + assert_ok!(FundAdmin::::initial_setup(RawOrigin::Root.into())); let admin: T::AccountId = account("admin", 0, SEED); let field_name = generate_field_name(1, name_size); - let _ = FundAdmin::::sudo_add_administrator( + assert_ok!(FundAdmin::::sudo_add_administrator( RawOrigin::Root.into(), admin.clone(), field_name.clone(), - ); + )); - // get adminç - let admin_info = >::get(admin.clone()); - assert!(admin_info.is_some()); + let admin_info = >::get(admin.clone()).unwrap(); + assert!(admin_info.role == ProxyRole::Administrator); + assert_eq!(admin_info.name, field_name); T::Currency::make_free_balance_be(&admin, 100000u32.into()); - Ok(admin.clone().try_into().unwrap()) + admin.try_into().unwrap() } -pub fn create_basic_project(admin: T::AccountId) -> Result<[u8; 32], DispatchError> { +pub fn create_basic_project(admin: T::AccountId) -> [u8; 32] { let title = generate_field_name(1, 100); let description = generate_field_description(1, 400); let address = generate_field_name(1, 100); let creation_date = u64::MAX - 1; let completion_date = u64::MAX; - let expenditures = - create_array_expenditures::(1, 100, 100, ExpenditureType::HardCost).unwrap(); + let expenditures = create_array_expenditures::(T::MaxRegistrationsAtTime::get(), 100, 100, ExpenditureType::HardCost); - let private_group_id = generate_field_description(1, 100); + let private_group_id = generate_field_description(1, 400); assert_ok!(FundAdmin::::projects_create_project( RawOrigin::Signed(admin.clone()).into(), @@ -286,8 +255,7 @@ pub fn create_basic_project(admin: T::AccountId) -> Result<[u8; 32], let project_id = >::iter_keys().next(); assert!(project_id.is_some()); - - Ok(project_id.unwrap()) + project_id.unwrap() } pub fn create_full_project(admin: T::AccountId) -> Result<[u8; 32], DispatchError> { @@ -295,13 +263,12 @@ pub fn create_full_project(admin: T::AccountId) -> Result<[u8; 32], D let description = generate_field_description(1, 400); let image = generate_field_name(1, 100); let address = generate_field_name(1, 100); - let banks = generate_banks::(1, 100, 100).unwrap(); + let banks = generate_banks::(1, 100, 100); let creation_date = u64::MAX - 1; let completion_date = u64::MAX; - let expenditures = - create_array_expenditures::(2, 100, 100, ExpenditureType::HardCost).unwrap(); - let job_eligibles = create_array_job_eligibles::(2, 100, 100).unwrap(); - let users_assignation = create_array_users_assignations::(1, ProxyRole::Builder).unwrap(); + let expenditures = create_array_expenditures::(T::MaxRegistrationsAtTime::get(), 100, 100, ExpenditureType::HardCost); + let job_eligibles = create_array_job_eligibles::(T::MaxRegistrationsAtTime::get(), 100, 100); + let users_assignation = create_array_users_assignations::(T::MaxRegistrationsAtTime::get(), ProxyRole::Builder); assert_ok!(register_users::(admin.clone(), users_assignation.clone())); let private_group_id = generate_field_description(1, 100); @@ -330,7 +297,7 @@ pub fn create_full_project(admin: T::AccountId) -> Result<[u8; 32], D pub fn create_array_transactions_feedback( transaction_ids: Vec<[u8; 32]>, description_size: u32, -) -> Result, DispatchError> { +) -> TransactionsFeedback { let mut transactions_feedback_vec: TransactionsFeedback = BoundedVec::new(); for i in 0..transaction_ids.len() { let description = generate_field_description(1, description_size); @@ -338,7 +305,7 @@ pub fn create_array_transactions_feedback( transactions_feedback_vec.try_push(transaction_feedback).unwrap(); } - Ok(transactions_feedback_vec) + transactions_feedback_vec } pub fn create_array_inflation_rate( @@ -346,9 +313,9 @@ pub fn create_array_inflation_rate( project_id: [u8; 32], ) -> Result, DispatchError> { let mut inflation_rate_vec: ProjectsInflation = BoundedVec::new(); - for i in 0..num_inflation_rates { + for _i in 0..num_inflation_rates { let inflation_rate = (project_id, Some(u32::MAX), CUDAction::Update); - inflation_rate_vec.try_push(inflation_rate).unwrap(); + inflation_rate_vec.try_push(inflation_rate).unwrap() } inflation_rate_vec[0].2 = CUDAction::Create; @@ -364,7 +331,7 @@ fn create_array_revenue_transactions( cid_size: u32, ) -> Result, DispatchError> { let mut transactions_vec: RevenueTransactions = BoundedVec::new(); - let documents = create_array_documents::(num_documents, name_size, cid_size).unwrap(); + let documents = create_array_documents::(num_documents, name_size, cid_size); for i in 0..num_transactions { let transaction = ( Some(job_eligible_id), @@ -393,7 +360,9 @@ mod benchmarks { } #[benchmark] - fn sudo_add_administrator(x: Linear<1, 100>) { + fn sudo_add_administrator( + x: Linear<1, 100> + ) { assert_ok!(FundAdmin::::initial_setup(RawOrigin::Root.into())); let admin: T::AccountId = account("admin", 0, SEED); let field_name = generate_field_name(1, x); @@ -405,7 +374,9 @@ mod benchmarks { } #[benchmark] - fn sudo_remove_administrator(x: Linear<1, 100>) { + fn sudo_remove_administrator( + x: Linear<1, 100> + ) { assert_ok!(FundAdmin::::initial_setup(RawOrigin::Root.into())); let admin: T::AccountId = account("admin", 0, SEED); let field_name = generate_field_name(1, x); @@ -422,10 +393,14 @@ mod benchmarks { } #[benchmark] - fn users(x: Linear<1, { T::MaxRegistrationsAtTime::get() }>, y: Linear<1, 100>) { - let admin = initialize_pallet::(x).unwrap(); + fn users( + a: Linear<1, 100>, + x: Linear<1,{ T::MaxRegistrationsAtTime::get() }>, + y: Linear<1, 100> + ) { + let admin = initialize_pallet::(a); - let users_array = create_array_users::(x, y, ProxyRole::Administrator).unwrap(); + let users_array = create_array_users::(x, y, ProxyRole::Administrator); #[extrinsic_call] _(RawOrigin::Signed(admin), users_array.clone()); @@ -445,8 +420,9 @@ mod benchmarks { c: Linear<1, { T::MaxDocuments::get() }>, d: Linear<1, 100>, e: Linear<1, 100>, + f: Linear<1, 100>, ) { - let admin = initialize_pallet::(100).unwrap(); + let admin = initialize_pallet::(f); let investor_account: T::AccountId = account("user", 1, SEED); let investor_payload = @@ -462,7 +438,7 @@ mod benchmarks { let name = generate_field_name(1, z); let image = generate_field_name(1, a); let email = generate_field_name(1, b); - let documents = create_array_documents::(c, d, e).unwrap(); + let documents = create_array_documents::(c, d, e); #[extrinsic_call] _( @@ -497,21 +473,22 @@ mod benchmarks { m: Linear<1, 400>, n: Linear<1, { T::MaxRegistrationsAtTime::get() }>, o: Linear<1, 400>, + x: Linear<1, 100>, ) { - let admin = initialize_pallet::(100).unwrap(); + let admin = initialize_pallet::(x); let title = generate_field_name(1, a); let description = generate_field_description(1, b); let image = generate_field_name(1, c); let address = generate_field_name(1, d); - let banks = generate_banks::(e, f, g).unwrap(); + let banks = generate_banks::(e, f, g); let creation_date = u64::MAX - 1; let completion_date = u64::MAX; let expenditures = - create_array_expenditures::(h, i, j, ExpenditureType::HardCost).unwrap(); - let job_eligibles = create_array_job_eligibles::(k, l, m).unwrap(); + create_array_expenditures::(h, i, j, ExpenditureType::HardCost); + let job_eligibles = create_array_job_eligibles::(k, l, m); let users_assignation = - create_array_users_assignations::(n, ProxyRole::Builder).unwrap(); + create_array_users_assignations::(n, ProxyRole::Builder); assert_ok!(register_users::(admin.clone(), users_assignation.clone())); let private_group_id = generate_field_description(1, o); @@ -548,9 +525,10 @@ mod benchmarks { h: Linear<1, { T::MaxRegistrationsAtTime::get() }>, i: Linear<1, 100>, j: Linear<1, 400>, + x: Linear<1, 100>, ) { - let admin = initialize_pallet::(100).unwrap(); - let project_id = create_basic_project::(admin.clone()).unwrap(); + let admin = initialize_pallet::(x); + let project_id = create_basic_project::(admin.clone()); let title = generate_field_name(1, a); let description = generate_field_description(1, b); @@ -582,9 +560,11 @@ mod benchmarks { } #[benchmark] - fn projects_delete_project() { - let admin = initialize_pallet::(100).unwrap(); - let project_id = create_basic_project::(admin.clone()).unwrap(); + fn projects_delete_project( + x: Linear<1, 100> + ) { + let admin = initialize_pallet::(x); + let project_id = create_basic_project::(admin.clone()); #[extrinsic_call] _(RawOrigin::Signed(admin.clone()), project_id.clone()); @@ -594,18 +574,21 @@ mod benchmarks { } #[benchmark] - fn projects_assign_user(a: Linear<1, { T::MaxRegistrationsAtTime::get() }>) { - let admin = initialize_pallet::(100).unwrap(); - let project_id = create_basic_project::(admin.clone()).unwrap(); + fn projects_assign_user( + a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, + x: Linear<1, 100>, + ) { + let admin = initialize_pallet::(x); + let project_id = create_basic_project::(admin.clone()); let users_assignation = - create_array_users_assignations::(a, ProxyRole::Builder).unwrap(); + create_array_users_assignations::(a, ProxyRole::Builder); assert_ok!(register_users::(admin.clone(), users_assignation.clone())); #[extrinsic_call] _(RawOrigin::Signed(admin.clone()), project_id.clone(), users_assignation.clone()); - for (user, role, _) in users_assignation.iter() { + for (user, _role, _) in users_assignation.iter() { let user_info = >::get(user.clone()); assert!(user_info.is_some()); let project_info = >::get(project_id.clone()); @@ -621,23 +604,22 @@ mod benchmarks { d: Linear<1, { T::MaxRegistrationsAtTime::get() }>, e: Linear<1, 100>, f: Linear<1, 400>, + x: Linear<1, 100>, ) { - let admin = initialize_pallet::(100).unwrap(); - let project_id = create_basic_project::(admin.clone()).unwrap(); + let admin = initialize_pallet::(x); + let project_id = create_basic_project::(admin.clone()); - let expenditures = - create_array_expenditures::(a, b, c, ExpenditureType::SoftCost).unwrap(); - let job_eligibles = create_array_job_eligibles::(d, e, f).unwrap(); + let expenditures = create_array_expenditures::(a, b, c, ExpenditureType::SoftCost); + let job_eligibles = create_array_job_eligibles::(d, e, f); #[extrinsic_call] - _(RawOrigin::Signed(admin.clone()), project_id.clone(), None, Some(job_eligibles.clone())); + _(RawOrigin::Signed(admin.clone()), project_id.clone(), Some(expenditures.clone()), Some(job_eligibles.clone())); - let project_info = >::get(project_id.clone()); - >::iter().for_each(|(key, value)| { + >::iter().for_each(|(_key, value)| { assert!(value.project_id == project_id); }); - >::iter().for_each(|(key, value)| { + >::iter().for_each(|(_key, value)| { assert!(value.project_id == project_id); }); } @@ -648,8 +630,9 @@ mod benchmarks { b: Linear<1, { T::MaxDocuments::get() }>, c: Linear<1, 100>, d: Linear<1, 100>, + x: Linear<1, 100>, ) { - let admin = initialize_pallet::(100).unwrap(); + let admin = initialize_pallet::(x); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::EB5; let drawdown_number = 1 as u32; @@ -657,7 +640,7 @@ mod benchmarks { let expenditure_id = >::iter_keys().next(); assert!(expenditure_id.is_some()); let transactions = - create_array_transactions::(a, expenditure_id.unwrap(), b, c, d).unwrap(); + create_array_transactions::(a, expenditure_id.unwrap(), b, c, d); #[extrinsic_call] _( @@ -679,8 +662,9 @@ mod benchmarks { b: Linear<1, { T::MaxDocuments::get() }>, c: Linear<1, 100>, d: Linear<1, 100>, + x: Linear<1, 100>, ) { - let admin = initialize_pallet::(100).unwrap(); + let admin = initialize_pallet::(x); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::EB5; let drawdown_number = 1 as u32; @@ -688,7 +672,7 @@ mod benchmarks { let expenditure_id = >::iter_keys().next(); assert!(expenditure_id.is_some()); let transactions = - create_array_transactions::(1, expenditure_id.unwrap(), 1, 100, 100).unwrap(); + create_array_transactions::(1, expenditure_id.unwrap(), 1, 100, 100); assert_ok!(FundAdmin::::submit_drawdown( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -699,7 +683,7 @@ mod benchmarks { let last_expenditure_id = >::iter_keys().last(); let bulkupload_transactions = - create_array_transactions::(a, last_expenditure_id.unwrap(), b, c, d).unwrap(); + create_array_transactions::(a, last_expenditure_id.unwrap(), b, c, d); #[extrinsic_call] _( @@ -720,8 +704,9 @@ mod benchmarks { a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, b: Linear<1, 400>, c: Linear<1, 400>, + x: Linear<1, 100>, ) { - let admin = initialize_pallet::(100).unwrap(); + let admin = initialize_pallet::(x); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::EB5; let drawdown_number = 1 as u32; @@ -729,7 +714,7 @@ mod benchmarks { let expenditure_id = >::iter_keys().next(); assert!(expenditure_id.is_some()); let transactions = - create_array_transactions::(a, expenditure_id.unwrap(), 1, 100, 100).unwrap(); + create_array_transactions::(a, expenditure_id.unwrap(), 1, 100, 100); assert_ok!(FundAdmin::::submit_drawdown( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -741,7 +726,7 @@ mod benchmarks { let transaction_ids = >::get(project_id.clone(), drawdown_id.clone()).to_vec(); let transactions_feedback = - create_array_transactions_feedback::(transaction_ids.clone(), b).unwrap(); + create_array_transactions_feedback::(transaction_ids.clone(), b); let drawdown_feedback = generate_field_description(1, c); #[extrinsic_call] @@ -764,15 +749,16 @@ mod benchmarks { b: Linear<1, { T::MaxDocuments::get() }>, c: Linear<1, 100>, d: Linear<1, 100>, + x: Linear<1, 100>, ) { - let admin = initialize_pallet::(100).unwrap(); + let admin = initialize_pallet::(x); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::DeveloperEquity; let drawdown_number = 1 as u32; let drawdown_id = get_drawdown_id::(project_id.clone(), drawdown_type, drawdown_number); let description = generate_field_description(1, a); let total_amount = u64::MAX; - let documents = create_array_documents::(b, c, d).unwrap(); + let documents = create_array_documents::(b, c, d); #[extrinsic_call] _( @@ -790,8 +776,11 @@ mod benchmarks { } #[benchmark] - fn inflation_rate(a: Linear<1, { T::MaxRegistrationsAtTime::get() }>) { - let admin = initialize_pallet::(100).unwrap(); + fn inflation_rate( + a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, + x: Linear<1, 100>, + ) { + let admin = initialize_pallet::(x); let project_id = create_full_project::(admin.clone()).unwrap(); let inflation_projects = create_array_inflation_rate::(a, project_id).unwrap(); @@ -811,8 +800,9 @@ mod benchmarks { b: Linear<1, { T::MaxDocuments::get() }>, c: Linear<1, 100>, d: Linear<1, 100>, + x: Linear<1, 100>, ) { - let admin = initialize_pallet::(100).unwrap(); + let admin = initialize_pallet::(x); let project_id = create_full_project::(admin.clone()).unwrap(); let revenue_id = >::iter_keys().next(); let job_eligible_id = >::iter_keys().next(); @@ -835,8 +825,10 @@ mod benchmarks { } #[benchmark] - fn approve_revenue() { - let admin = initialize_pallet::(100).unwrap(); + fn approve_revenue( + x: Linear<1, 100> + ) { + let admin = initialize_pallet::(x); let project_id = create_full_project::(admin.clone()).unwrap(); let revenue_id = >::iter_keys().next(); let job_eligible_id = >::iter_keys().next(); @@ -861,8 +853,12 @@ mod benchmarks { } #[benchmark] - fn reject_revenue(a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, b: Linear<1, 400>) { - let admin = initialize_pallet::(100).unwrap(); + fn reject_revenue( + a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, + b: Linear<1, 400>, + x: Linear<1, 100>, + ) { + let admin = initialize_pallet::(x); let project_id = create_full_project::(admin.clone()).unwrap(); let revenue_id = >::iter_keys().next(); let job_eligible_id = >::iter_keys().next(); @@ -882,7 +878,7 @@ mod benchmarks { >::get(project_id.clone(), revenue_id.clone().unwrap()) .to_vec(); let transactions_feedback = - create_array_transactions_feedback::(transaction_ids.clone(), b).unwrap(); + create_array_transactions_feedback::(transaction_ids.clone(), b); #[extrinsic_call] _( @@ -902,8 +898,9 @@ mod benchmarks { a: Linear<1, { T::MaxDocuments::get() }>, b: Linear<1, 100>, c: Linear<1, 100>, + x: Linear<1, 100>, ) { - let admin = initialize_pallet::(100).unwrap(); + let admin = initialize_pallet::(x); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::EB5; let drawdown_number = 1 as u32; @@ -911,7 +908,7 @@ mod benchmarks { let expenditure_id = >::iter_keys().next(); assert!(expenditure_id.is_some()); let transactions = - create_array_transactions::(1, expenditure_id.unwrap(), 1, 100, 100).unwrap(); + create_array_transactions::(1, expenditure_id.unwrap(), 1, 100, 100); assert_ok!(FundAdmin::::submit_drawdown( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -927,7 +924,7 @@ mod benchmarks { None, )); - let confirming_documents = create_array_documents::(a, b, c).unwrap(); + let confirming_documents = create_array_documents::(a, b, c); #[extrinsic_call] _( @@ -944,8 +941,10 @@ mod benchmarks { } #[benchmark] - fn reset_drawdown() { - let admin = initialize_pallet::(100).unwrap(); + fn reset_drawdown( + x: Linear<1, 100>, + ) { + let admin = initialize_pallet::(x); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::EB5; let drawdown_number = 1 as u32; @@ -953,7 +952,7 @@ mod benchmarks { let expenditure_id = >::iter_keys().next(); assert!(expenditure_id.is_some()); let transactions = - create_array_transactions::(1, expenditure_id.unwrap(), 1, 100, 100).unwrap(); + create_array_transactions::(1, expenditure_id.unwrap(), 1, 100, 100); assert_ok!(FundAdmin::::submit_drawdown( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -980,8 +979,9 @@ mod benchmarks { b: Linear<1, { T::MaxDocuments::get() }>, c: Linear<1, 100>, d: Linear<1, 100>, + x: Linear<1, 100>, ) { - let admin = initialize_pallet::(100).unwrap(); + let admin = initialize_pallet::(x); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::EB5; let drawdown_number = 1 as u32; @@ -991,7 +991,7 @@ mod benchmarks { assert!(expenditure_id.is_some()); assert!(last_expenditure_id.is_some()); let transactions = - create_array_transactions::(1, expenditure_id.unwrap(), 1, 100, 100).unwrap(); + create_array_transactions::(1, expenditure_id.unwrap(), 1, 100, 100); assert_ok!(FundAdmin::::submit_drawdown( RawOrigin::Signed(admin.clone()).into(), @@ -1009,7 +1009,7 @@ mod benchmarks { )); let recovery_transactions = - create_array_transactions::(a, last_expenditure_id.unwrap(), b, c, d).unwrap(); + create_array_transactions::(a, last_expenditure_id.unwrap(), b, c, d); #[extrinsic_call] _( @@ -1036,8 +1036,9 @@ mod benchmarks { b: Linear<1, { T::MaxDocuments::get() }>, c: Linear<1, 100>, d: Linear<1, 100>, + x: Linear<1, 100>, ) { - let admin = initialize_pallet::(100).unwrap(); + let admin = initialize_pallet::(x); let project_id = create_full_project::(admin.clone()).unwrap(); let revenue_id = >::iter_keys().next(); let job_eligible_id = >::iter_keys().next(); @@ -1081,9 +1082,11 @@ mod benchmarks { } #[benchmark] - fn kill_storage() { - let admin = initialize_pallet::(100).unwrap(); - let project_id = create_full_project::(admin.clone()).unwrap(); + fn kill_storage( + x: Linear<1, 100> + ) { + let admin = initialize_pallet::(x); + assert_ok!(create_full_project::(admin.clone())); #[extrinsic_call] _(RawOrigin::Root); From 6cce7389e8ba7a3892006c3d9706b48a7f29321d Mon Sep 17 00:00:00 2001 From: didiermis Date: Fri, 5 Apr 2024 13:45:05 -0600 Subject: [PATCH 35/40] Refactored the `create_array_job_eligibles` function in the fund-admin pallet, updating the `job_eligible_id` generation logic to include additional fields in the encoding. Also refactored the `create_array_users_assignations` function, updating the generation of user account IDs to include an incremental `id` value to ensure uniqueness. --- pallets/fund-admin/src/benchmarking.rs | 123 +++++++------------------ pallets/fund-admin/src/functions.rs | 2 +- 2 files changed, 36 insertions(+), 89 deletions(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index fcd1535..8e1ff30 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -129,7 +129,7 @@ pub fn create_array_job_eligibles( name[0] = i as u8; let naics_code = generate_field_description(1, naics_code_size); let job_eligible = - (Some(name), Some(u64::MAX), Some(naics_code), Some(u32::MAX), CUDAction::Create, None); + (Some(name), Some(i as u64), Some(naics_code), Some(u32::MAX), CUDAction::Create, None); job_eligibles_vec.try_push(job_eligible).unwrap(); } @@ -139,10 +139,11 @@ pub fn create_array_job_eligibles( pub fn create_array_users_assignations( num_users: u32, role: ProxyRole, + id: u32 ) -> UsersAssignation { let mut users_vec: UsersAssignation = BoundedVec::new(); for i in 0..num_users { - let user_account: T::AccountId = account("user", i + 1, SEED); + let user_account: T::AccountId = account("user", id + i, SEED); let action = AssignAction::Assign; let user = (user_account, role, action); users_vec.try_push(user).unwrap(); @@ -225,40 +226,9 @@ pub fn initialize_pallet(name_size: u32) -> T::AccountId { assert_eq!(admin_info.name, field_name); T::Currency::make_free_balance_be(&admin, 100000u32.into()); - admin.try_into().unwrap() + admin } - -pub fn create_basic_project(admin: T::AccountId) -> [u8; 32] { - let title = generate_field_name(1, 100); - let description = generate_field_description(1, 400); - let address = generate_field_name(1, 100); - let creation_date = u64::MAX - 1; - let completion_date = u64::MAX; - let expenditures = create_array_expenditures::(T::MaxRegistrationsAtTime::get(), 100, 100, ExpenditureType::HardCost); - - let private_group_id = generate_field_description(1, 400); - - assert_ok!(FundAdmin::::projects_create_project( - RawOrigin::Signed(admin.clone()).into(), - title.clone(), - description.clone(), - None, - address.clone(), - None, - creation_date, - completion_date, - expenditures.clone(), - None, - None, - private_group_id.clone(), - )); - - let project_id = >::iter_keys().next(); - assert!(project_id.is_some()); - project_id.unwrap() -} - -pub fn create_full_project(admin: T::AccountId) -> Result<[u8; 32], DispatchError> { +pub fn create_full_project(admin: T::AccountId) -> Result<[u8;32], DispatchError> { let title = generate_field_name(1, 100); let description = generate_field_description(1, 400); let image = generate_field_name(1, 100); @@ -268,7 +238,7 @@ pub fn create_full_project(admin: T::AccountId) -> Result<[u8; 32], D let completion_date = u64::MAX; let expenditures = create_array_expenditures::(T::MaxRegistrationsAtTime::get(), 100, 100, ExpenditureType::HardCost); let job_eligibles = create_array_job_eligibles::(T::MaxRegistrationsAtTime::get(), 100, 100); - let users_assignation = create_array_users_assignations::(T::MaxRegistrationsAtTime::get(), ProxyRole::Builder); + let users_assignation = create_array_users_assignations::(T::MaxRegistrationsAtTime::get(), ProxyRole::Builder, 1); assert_ok!(register_users::(admin.clone(), users_assignation.clone())); let private_group_id = generate_field_description(1, 100); @@ -473,9 +443,8 @@ mod benchmarks { m: Linear<1, 400>, n: Linear<1, { T::MaxRegistrationsAtTime::get() }>, o: Linear<1, 400>, - x: Linear<1, 100>, ) { - let admin = initialize_pallet::(x); + let admin = initialize_pallet::(100); let title = generate_field_name(1, a); let description = generate_field_description(1, b); @@ -488,7 +457,7 @@ mod benchmarks { create_array_expenditures::(h, i, j, ExpenditureType::HardCost); let job_eligibles = create_array_job_eligibles::(k, l, m); let users_assignation = - create_array_users_assignations::(n, ProxyRole::Builder); + create_array_users_assignations::(n, ProxyRole::Builder, 50); assert_ok!(register_users::(admin.clone(), users_assignation.clone())); let private_group_id = generate_field_description(1, o); @@ -525,10 +494,9 @@ mod benchmarks { h: Linear<1, { T::MaxRegistrationsAtTime::get() }>, i: Linear<1, 100>, j: Linear<1, 400>, - x: Linear<1, 100>, ) { - let admin = initialize_pallet::(x); - let project_id = create_basic_project::(admin.clone()); + let admin = initialize_pallet::(100); + let project_id = create_full_project::(admin.clone()).unwrap(); let title = generate_field_name(1, a); let description = generate_field_description(1, b); @@ -560,11 +528,9 @@ mod benchmarks { } #[benchmark] - fn projects_delete_project( - x: Linear<1, 100> - ) { - let admin = initialize_pallet::(x); - let project_id = create_basic_project::(admin.clone()); + fn projects_delete_project() { + let admin = initialize_pallet::(100); + let project_id = create_full_project::(admin.clone()).unwrap(); #[extrinsic_call] _(RawOrigin::Signed(admin.clone()), project_id.clone()); @@ -576,13 +542,11 @@ mod benchmarks { #[benchmark] fn projects_assign_user( a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, - x: Linear<1, 100>, ) { - let admin = initialize_pallet::(x); - let project_id = create_basic_project::(admin.clone()); + let admin = initialize_pallet::(100); + let project_id = create_full_project::(admin.clone()).unwrap(); - let users_assignation = - create_array_users_assignations::(a, ProxyRole::Builder); + let users_assignation = create_array_users_assignations::(a, ProxyRole::Builder, 100); assert_ok!(register_users::(admin.clone(), users_assignation.clone())); #[extrinsic_call] @@ -604,10 +568,9 @@ mod benchmarks { d: Linear<1, { T::MaxRegistrationsAtTime::get() }>, e: Linear<1, 100>, f: Linear<1, 400>, - x: Linear<1, 100>, ) { - let admin = initialize_pallet::(x); - let project_id = create_basic_project::(admin.clone()); + let admin = initialize_pallet::(100); + let project_id = create_full_project::(admin.clone()).unwrap(); let expenditures = create_array_expenditures::(a, b, c, ExpenditureType::SoftCost); let job_eligibles = create_array_job_eligibles::(d, e, f); @@ -630,9 +593,8 @@ mod benchmarks { b: Linear<1, { T::MaxDocuments::get() }>, c: Linear<1, 100>, d: Linear<1, 100>, - x: Linear<1, 100>, ) { - let admin = initialize_pallet::(x); + let admin = initialize_pallet::(100); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::EB5; let drawdown_number = 1 as u32; @@ -662,9 +624,8 @@ mod benchmarks { b: Linear<1, { T::MaxDocuments::get() }>, c: Linear<1, 100>, d: Linear<1, 100>, - x: Linear<1, 100>, ) { - let admin = initialize_pallet::(x); + let admin = initialize_pallet::(100); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::EB5; let drawdown_number = 1 as u32; @@ -672,7 +633,7 @@ mod benchmarks { let expenditure_id = >::iter_keys().next(); assert!(expenditure_id.is_some()); let transactions = - create_array_transactions::(1, expenditure_id.unwrap(), 1, 100, 100); + create_array_transactions::(T::MaxRegistrationsAtTime::get(), expenditure_id.unwrap(), T::MaxDocuments::get(), 100, 100); assert_ok!(FundAdmin::::submit_drawdown( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -704,9 +665,8 @@ mod benchmarks { a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, b: Linear<1, 400>, c: Linear<1, 400>, - x: Linear<1, 100>, ) { - let admin = initialize_pallet::(x); + let admin = initialize_pallet::(100); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::EB5; let drawdown_number = 1 as u32; @@ -749,9 +709,8 @@ mod benchmarks { b: Linear<1, { T::MaxDocuments::get() }>, c: Linear<1, 100>, d: Linear<1, 100>, - x: Linear<1, 100>, ) { - let admin = initialize_pallet::(x); + let admin = initialize_pallet::(100); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::DeveloperEquity; let drawdown_number = 1 as u32; @@ -778,9 +737,8 @@ mod benchmarks { #[benchmark] fn inflation_rate( a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, - x: Linear<1, 100>, ) { - let admin = initialize_pallet::(x); + let admin = initialize_pallet::(100); let project_id = create_full_project::(admin.clone()).unwrap(); let inflation_projects = create_array_inflation_rate::(a, project_id).unwrap(); @@ -800,9 +758,8 @@ mod benchmarks { b: Linear<1, { T::MaxDocuments::get() }>, c: Linear<1, 100>, d: Linear<1, 100>, - x: Linear<1, 100>, ) { - let admin = initialize_pallet::(x); + let admin = initialize_pallet::(100); let project_id = create_full_project::(admin.clone()).unwrap(); let revenue_id = >::iter_keys().next(); let job_eligible_id = >::iter_keys().next(); @@ -825,10 +782,8 @@ mod benchmarks { } #[benchmark] - fn approve_revenue( - x: Linear<1, 100> - ) { - let admin = initialize_pallet::(x); + fn approve_revenue() { + let admin = initialize_pallet::(100); let project_id = create_full_project::(admin.clone()).unwrap(); let revenue_id = >::iter_keys().next(); let job_eligible_id = >::iter_keys().next(); @@ -856,9 +811,8 @@ mod benchmarks { fn reject_revenue( a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, b: Linear<1, 400>, - x: Linear<1, 100>, ) { - let admin = initialize_pallet::(x); + let admin = initialize_pallet::(100); let project_id = create_full_project::(admin.clone()).unwrap(); let revenue_id = >::iter_keys().next(); let job_eligible_id = >::iter_keys().next(); @@ -898,9 +852,8 @@ mod benchmarks { a: Linear<1, { T::MaxDocuments::get() }>, b: Linear<1, 100>, c: Linear<1, 100>, - x: Linear<1, 100>, ) { - let admin = initialize_pallet::(x); + let admin = initialize_pallet::(100); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::EB5; let drawdown_number = 1 as u32; @@ -941,10 +894,8 @@ mod benchmarks { } #[benchmark] - fn reset_drawdown( - x: Linear<1, 100>, - ) { - let admin = initialize_pallet::(x); + fn reset_drawdown() { + let admin = initialize_pallet::(100); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::EB5; let drawdown_number = 1 as u32; @@ -979,9 +930,8 @@ mod benchmarks { b: Linear<1, { T::MaxDocuments::get() }>, c: Linear<1, 100>, d: Linear<1, 100>, - x: Linear<1, 100>, ) { - let admin = initialize_pallet::(x); + let admin = initialize_pallet::(100); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::EB5; let drawdown_number = 1 as u32; @@ -1036,9 +986,8 @@ mod benchmarks { b: Linear<1, { T::MaxDocuments::get() }>, c: Linear<1, 100>, d: Linear<1, 100>, - x: Linear<1, 100>, ) { - let admin = initialize_pallet::(x); + let admin = initialize_pallet::(100); let project_id = create_full_project::(admin.clone()).unwrap(); let revenue_id = >::iter_keys().next(); let job_eligible_id = >::iter_keys().next(); @@ -1082,10 +1031,8 @@ mod benchmarks { } #[benchmark] - fn kill_storage( - x: Linear<1, 100> - ) { - let admin = initialize_pallet::(x); + fn kill_storage() { + let admin = initialize_pallet::(100); assert_ok!(create_full_project::(admin.clone())); #[extrinsic_call] diff --git a/pallets/fund-admin/src/functions.rs b/pallets/fund-admin/src/functions.rs index a867f44..9fefb59 100644 --- a/pallets/fund-admin/src/functions.rs +++ b/pallets/fund-admin/src/functions.rs @@ -1804,7 +1804,7 @@ impl Pallet { // Create job eligible id let job_eligible_id: JobEligibleId = - (project_id, name.clone(), timestamp).using_encoded(blake2_256); + (project_id, name.clone(), timestamp, job_eligible_amount, naics_code.clone(), jobs_multiplier).using_encoded(blake2_256); // Create job eligible data let job_eligible_data = From 880610b370f91b61cb67378fc090f488b3902931 Mon Sep 17 00:00:00 2001 From: didiermis Date: Fri, 5 Apr 2024 13:52:11 -0600 Subject: [PATCH 36/40] Refactored the `reject_drawdown` function in the fund-admin benchmarking module, removing the unused `a` input parameter. Refactored the `reject_revenue` function, removing the unused `b` input parameter. --- Cargo.lock | 76 +++++++++++++------------- pallets/fund-admin/src/benchmarking.rs | 18 +++--- 2 files changed, 46 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 08cb513..4d949c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1108,7 +1108,7 @@ dependencies = [ [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-support", "frame-support-procedural", @@ -1145,7 +1145,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "aquamarine", "bitflags 1.3.2", @@ -1185,7 +1185,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "Inflector", "cfg-expr", @@ -1204,7 +1204,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -1216,7 +1216,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "proc-macro2", "quote", @@ -1226,7 +1226,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "cfg-if", "frame-support", @@ -2099,7 +2099,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-benchmarking", "frame-support", @@ -2256,7 +2256,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "docify", "frame-benchmarking", @@ -2276,7 +2276,7 @@ dependencies = [ [[package]] name = "pallet-uniques" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-benchmarking", "frame-support", @@ -3003,7 +3003,7 @@ checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "hash-db", "log", @@ -3024,7 +3024,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "Inflector", "blake2", @@ -3038,7 +3038,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "23.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "scale-info", @@ -3051,7 +3051,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "16.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "integer-sqrt", "num-traits", @@ -3065,7 +3065,7 @@ dependencies = [ [[package]] name = "sp-core" version = "21.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "array-bytes", "bandersnatch_vrfs", @@ -3112,7 +3112,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "9.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "blake2b_simd", "byteorder", @@ -3125,7 +3125,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "9.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "quote", "sp-core-hashing", @@ -3135,7 +3135,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "proc-macro2", "quote", @@ -3145,7 +3145,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.19.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "environmental", "parity-scale-codec", @@ -3156,7 +3156,7 @@ dependencies = [ [[package]] name = "sp-genesis-builder" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "serde_json", "sp-api", @@ -3167,7 +3167,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -3181,7 +3181,7 @@ dependencies = [ [[package]] name = "sp-io" version = "23.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "bytes", "ed25519-dalek", @@ -3205,7 +3205,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.27.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "parking_lot", @@ -3217,7 +3217,7 @@ dependencies = [ [[package]] name = "sp-metadata-ir" version = "0.1.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "frame-metadata", "parity-scale-codec", @@ -3228,7 +3228,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "backtrace", "lazy_static", @@ -3238,7 +3238,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "either", "hash256-std-hasher", @@ -3260,7 +3260,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -3278,7 +3278,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "11.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "Inflector", "proc-macro-crate", @@ -3290,7 +3290,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "impl-trait-for-tuples", "parity-scale-codec", @@ -3304,7 +3304,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.28.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "hash-db", "log", @@ -3325,12 +3325,12 @@ dependencies = [ [[package]] name = "sp-std" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" [[package]] name = "sp-storage" version = "13.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "impl-serde", "parity-scale-codec", @@ -3343,7 +3343,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "async-trait", "parity-scale-codec", @@ -3356,7 +3356,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "10.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "sp-std", @@ -3368,7 +3368,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "22.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "ahash 0.8.6", "hash-db", @@ -3392,7 +3392,7 @@ dependencies = [ [[package]] name = "sp-version" version = "22.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "impl-serde", "parity-scale-codec", @@ -3409,7 +3409,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "8.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -3420,7 +3420,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -3433,7 +3433,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "20.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" +source = "git+https://github.com/paritytech/polkadot-sdk?tag=v1.3.0-rc1#7c9fd83805cc446983a7698c7a3281677cf655c8" dependencies = [ "parity-scale-codec", "scale-info", diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index 8e1ff30..77e368f 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -662,7 +662,6 @@ mod benchmarks { #[benchmark] fn reject_drawdown( - a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, b: Linear<1, 400>, c: Linear<1, 400>, ) { @@ -674,7 +673,7 @@ mod benchmarks { let expenditure_id = >::iter_keys().next(); assert!(expenditure_id.is_some()); let transactions = - create_array_transactions::(a, expenditure_id.unwrap(), 1, 100, 100); + create_array_transactions::(T::MaxRegistrationsAtTime::get(), expenditure_id.unwrap(), T::MaxDocuments::get(), 100, 100); assert_ok!(FundAdmin::::submit_drawdown( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -789,7 +788,7 @@ mod benchmarks { let job_eligible_id = >::iter_keys().next(); assert!(job_eligible_id.is_some()); let transactions = - create_array_revenue_transactions::(1, job_eligible_id.unwrap(), 1, 100, 100) + create_array_revenue_transactions::(T::MaxRegistrationsAtTime::get(), job_eligible_id.unwrap(), T::MaxDocuments::get(), 100, 100) .unwrap(); assert_ok!(FundAdmin::::submit_revenue( RawOrigin::Signed(admin.clone()).into(), @@ -809,8 +808,7 @@ mod benchmarks { #[benchmark] fn reject_revenue( - a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, - b: Linear<1, 400>, + a: Linear<1, 400>, ) { let admin = initialize_pallet::(100); let project_id = create_full_project::(admin.clone()).unwrap(); @@ -818,7 +816,7 @@ mod benchmarks { let job_eligible_id = >::iter_keys().next(); assert!(job_eligible_id.is_some()); let transactions = - create_array_revenue_transactions::(a, job_eligible_id.unwrap(), 1, 100, 100) + create_array_revenue_transactions::(T::MaxRegistrationsAtTime::get(), job_eligible_id.unwrap(), T::MaxDocuments::get(), 100, 100) .unwrap(); assert_ok!(FundAdmin::::submit_revenue( RawOrigin::Signed(admin.clone()).into(), @@ -861,7 +859,7 @@ mod benchmarks { let expenditure_id = >::iter_keys().next(); assert!(expenditure_id.is_some()); let transactions = - create_array_transactions::(1, expenditure_id.unwrap(), 1, 100, 100); + create_array_transactions::(T::MaxRegistrationsAtTime::get(), expenditure_id.unwrap(), T::MaxDocuments::get(), 100, 100); assert_ok!(FundAdmin::::submit_drawdown( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -903,7 +901,7 @@ mod benchmarks { let expenditure_id = >::iter_keys().next(); assert!(expenditure_id.is_some()); let transactions = - create_array_transactions::(1, expenditure_id.unwrap(), 1, 100, 100); + create_array_transactions::(T::MaxRegistrationsAtTime::get(), expenditure_id.unwrap(), T::MaxDocuments::get(), 100, 100); assert_ok!(FundAdmin::::submit_drawdown( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -941,7 +939,7 @@ mod benchmarks { assert!(expenditure_id.is_some()); assert!(last_expenditure_id.is_some()); let transactions = - create_array_transactions::(1, expenditure_id.unwrap(), 1, 100, 100); + create_array_transactions::(T::MaxRegistrationsAtTime::get(), expenditure_id.unwrap(), T::MaxDocuments::get(), 100, 100); assert_ok!(FundAdmin::::submit_drawdown( RawOrigin::Signed(admin.clone()).into(), @@ -995,7 +993,7 @@ mod benchmarks { assert!(job_eligible_id.is_some()); assert!(last_job_eligible_id.is_some()); let transactions = - create_array_revenue_transactions::(1, job_eligible_id.unwrap(), 1, 100, 100) + create_array_revenue_transactions::(T::MaxRegistrationsAtTime::get(), job_eligible_id.unwrap(), T::MaxDocuments::get(), 100, 100) .unwrap(); assert_ok!(FundAdmin::::submit_revenue( RawOrigin::Signed(admin.clone()).into(), From b64d6b3104f72f9af811d0050a61878669ec527b Mon Sep 17 00:00:00 2001 From: didiermis Date: Fri, 5 Apr 2024 14:45:17 -0600 Subject: [PATCH 37/40] Updated the `reject_revenue` benchmark function in the fund-admin benchmarking module, replacing the unused `a` input parameter with the correct `b` parameter. Commented out the `#[cfg(feature = "runtime-benchmarks")]` block in the fund-admin library module to enable the compilation of the benchmarking module. --- pallets/fund-admin/src/benchmarking.rs | 2 +- pallets/fund-admin/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index 77e368f..c07932b 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -808,7 +808,7 @@ mod benchmarks { #[benchmark] fn reject_revenue( - a: Linear<1, 400>, + b: Linear<1, 400>, ) { let admin = initialize_pallet::(100); let project_id = create_full_project::(admin.clone()).unwrap(); diff --git a/pallets/fund-admin/src/lib.rs b/pallets/fund-admin/src/lib.rs index 3ee849b..78e8853 100644 --- a/pallets/fund-admin/src/lib.rs +++ b/pallets/fund-admin/src/lib.rs @@ -2,7 +2,7 @@ pub use pallet::*; -#[cfg(feature = "runtime-benchmarks")] +// #[cfg(feature = "runtime-benchmarks")] mod benchmarking; #[cfg(test)] From 33335fb41fba3e402f2be9384a558b5c982c83cc Mon Sep 17 00:00:00 2001 From: Sebastian Montero Date: Mon, 8 Apr 2024 18:44:57 -0600 Subject: [PATCH 38/40] Added bound to the fund-admin benchmarks to allow for u64 balances. --- pallets/fund-admin/src/benchmarking.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index c07932b..975e1a7 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -210,7 +210,9 @@ pub fn create_array_transactions( transactions_vec } -pub fn initialize_pallet(name_size: u32) -> T::AccountId { +pub fn initialize_pallet(name_size: u32) -> T::AccountId +where T: Config, +<::Currency as Currency>::Balance: From, { assert_ok!(FundAdmin::::initial_setup(RawOrigin::Root.into())); let admin: T::AccountId = account("admin", 0, SEED); let field_name = generate_field_name(1, name_size); @@ -224,7 +226,7 @@ pub fn initialize_pallet(name_size: u32) -> T::AccountId { let admin_info = >::get(admin.clone()).unwrap(); assert!(admin_info.role == ProxyRole::Administrator); assert_eq!(admin_info.name, field_name); - T::Currency::make_free_balance_be(&admin, 100000u32.into()); + T::Currency::make_free_balance_be(&admin, 100000u64.into()); admin } @@ -316,7 +318,7 @@ fn create_array_revenue_transactions( Ok(transactions_vec) } -#[benchmarks(where T: Config)] +#[benchmarks(where T: Config, <::Currency as Currency>::Balance: From)] mod benchmarks { use super::*; From b2c3a40b89c4dc9943be358edcdcb34bdf53e0f6 Mon Sep 17 00:00:00 2001 From: Dreyhh Date: Wed, 17 Apr 2024 11:58:29 -0600 Subject: [PATCH 39/40] Simplified fund-admin benchmarks --- pallets/fund-admin/src/benchmarking.rs | 412 ++++++++++--------------- pallets/fund-admin/src/mock.rs | 2 +- 2 files changed, 164 insertions(+), 250 deletions(-) diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index 975e1a7..5ac571a 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -15,6 +15,8 @@ use frame_support::{ use frame_system::RawOrigin; const SEED: u32 = 0; +const MAX_FIELD_NAME_SIZE: u32 = 100; +const MAX_FIELD_DESC_SIZE: u32 = 400; pub fn generate_vector(values: u8, size: u32) -> Vec { assert!(size > 0, "vector size must be greater than 0"); @@ -32,27 +34,22 @@ pub fn generate_field_description(values: u8, size: u32) -> FieldDescription { pub fn generate_user( user_account: T::AccountId, - name_size: u32, role: ProxyRole, action: CUDAction, ) -> Result, DispatchError> { - let field_name = generate_field_name(1, name_size); + let field_name = generate_field_name(1, MAX_FIELD_NAME_SIZE); let user = (user_account, Some(field_name), Some(role), action); let mut users_vec: Users = BoundedVec::new(); users_vec.try_push(user).unwrap(); Ok(users_vec) } -pub fn create_array_users( - num_users: u32, - name_size: u32, - role: ProxyRole, -) -> Users { +pub fn create_array_users(num_users: u32, role: ProxyRole) -> Users { let mut users_vec: Users = BoundedVec::new(); for i in 0..num_users { let user_account: T::AccountId = account("user", i, SEED); let action = CUDAction::Create; - let field_name = generate_field_name(1, name_size); + let field_name = generate_field_name(i as u8, MAX_FIELD_NAME_SIZE); let user = (user_account, Some(field_name), Some(role), action); users_vec.try_push(user).unwrap(); } @@ -60,15 +57,11 @@ pub fn create_array_users( users_vec } -pub fn create_array_documents( - num_documents: u32, - name_size: u32, - cid_size: u32, -) -> Documents { +pub fn create_array_documents(num_documents: u32) -> Documents { let mut documents_vec: Documents = BoundedVec::new(); for _i in 0..num_documents { - let field_name = generate_field_name(1, name_size); - let cid = generate_field_name(1, cid_size); + let field_name = generate_field_name(1, MAX_FIELD_NAME_SIZE); + let cid = generate_field_name(1, MAX_FIELD_NAME_SIZE); let document = (field_name, cid); documents_vec.try_push(document).unwrap(); } @@ -76,15 +69,11 @@ pub fn create_array_documents( documents_vec } -pub fn generate_banks( - num_banks: u32, - name_size: u32, - address_size: u32, -) -> Banks { +pub fn generate_banks(num_banks: u32) -> Banks { let mut banks_vec: Banks = BoundedVec::new(); for _i in 0..num_banks { - let bank_name = generate_field_name(1, name_size); - let bank_address = generate_field_name(1, address_size); + let bank_name = generate_field_name(1, MAX_FIELD_NAME_SIZE); + let bank_address = generate_field_name(1, MAX_FIELD_NAME_SIZE); let bank = (bank_name, bank_address); banks_vec.try_push(bank).unwrap(); } @@ -94,15 +83,13 @@ pub fn generate_banks( pub fn create_array_expenditures( num_expenditures: u32, - name_size: u32, - naics_code_size: u32, expenditure_type: ExpenditureType, ) -> Expenditures { let mut expenditures_vec: Expenditures = BoundedVec::new(); for i in 0..num_expenditures { - let mut name = generate_field_name(1, name_size); + let mut name = generate_field_name(1, MAX_FIELD_NAME_SIZE); name[0] = i as u8; - let naics_code = generate_field_description(1, naics_code_size); + let naics_code = generate_field_description(1, MAX_FIELD_DESC_SIZE); let expenditure = ( Some(name), Some(expenditure_type), @@ -118,16 +105,12 @@ pub fn create_array_expenditures( expenditures_vec } -pub fn create_array_job_eligibles( - num_job_eligibles: u32, - name_size: u32, - naics_code_size: u32, -) -> JobEligibles { +pub fn create_array_job_eligibles(num_job_eligibles: u32, id: u8) -> JobEligibles { let mut job_eligibles_vec: JobEligibles = BoundedVec::new(); for i in 0..num_job_eligibles { - let mut name = generate_field_name(1, name_size); - name[0] = i as u8; - let naics_code = generate_field_description(1, naics_code_size); + let mut name = generate_field_name(1, MAX_FIELD_NAME_SIZE); + name[0] = id; + let naics_code = generate_field_description(1, MAX_FIELD_DESC_SIZE); let job_eligible = (Some(name), Some(i as u64), Some(naics_code), Some(u32::MAX), CUDAction::Create, None); job_eligibles_vec.try_push(job_eligible).unwrap(); @@ -139,7 +122,7 @@ pub fn create_array_job_eligibles( pub fn create_array_users_assignations( num_users: u32, role: ProxyRole, - id: u32 + id: u32, ) -> UsersAssignation { let mut users_vec: UsersAssignation = BoundedVec::new(); for i in 0..num_users { @@ -158,7 +141,7 @@ pub fn register_users( ) -> Result<(), DispatchError> { let mut users_array: Users = BoundedVec::new(); for (user, role, _) in users_assignation.iter() { - let name = generate_field_name(1, 100); + let name = generate_field_name(1, MAX_FIELD_NAME_SIZE); let user_info = (user.clone(), Some(name), Some(role.clone()), CUDAction::Create); users_array.try_push(user_info).unwrap(); } @@ -190,12 +173,9 @@ fn get_drawdown_id( pub fn create_array_transactions( num_transactions: u32, expenditure_id: [u8; 32], - num_documents: u32, - name_size: u32, - cid_size: u32, ) -> Transactions { let mut transactions_vec: Transactions = BoundedVec::new(); - let documents = create_array_documents::(num_documents, name_size, cid_size); + let documents = create_array_documents::(T::MaxDocuments::get()); for i in 0..num_transactions { let transaction = ( Some(expenditure_id), @@ -210,12 +190,14 @@ pub fn create_array_transactions( transactions_vec } -pub fn initialize_pallet(name_size: u32) -> T::AccountId -where T: Config, -<::Currency as Currency>::Balance: From, { +pub fn initialize_pallet() -> T::AccountId +where + T: Config, + <::Currency as Currency>::Balance: From, +{ assert_ok!(FundAdmin::::initial_setup(RawOrigin::Root.into())); let admin: T::AccountId = account("admin", 0, SEED); - let field_name = generate_field_name(1, name_size); + let field_name = generate_field_name(1, MAX_FIELD_NAME_SIZE); assert_ok!(FundAdmin::::sudo_add_administrator( RawOrigin::Root.into(), @@ -230,20 +212,25 @@ where T: Config, admin } -pub fn create_full_project(admin: T::AccountId) -> Result<[u8;32], DispatchError> { - let title = generate_field_name(1, 100); - let description = generate_field_description(1, 400); - let image = generate_field_name(1, 100); - let address = generate_field_name(1, 100); - let banks = generate_banks::(1, 100, 100); +pub fn create_full_project(admin: T::AccountId) -> Result<[u8; 32], DispatchError> { + let title = generate_field_name(1, MAX_FIELD_NAME_SIZE); + let description = generate_field_description(1, MAX_FIELD_DESC_SIZE); + let image = generate_field_name(1, MAX_FIELD_NAME_SIZE); + let address = generate_field_name(1, MAX_FIELD_NAME_SIZE); + let banks = generate_banks::(1); let creation_date = u64::MAX - 1; let completion_date = u64::MAX; - let expenditures = create_array_expenditures::(T::MaxRegistrationsAtTime::get(), 100, 100, ExpenditureType::HardCost); - let job_eligibles = create_array_job_eligibles::(T::MaxRegistrationsAtTime::get(), 100, 100); - let users_assignation = create_array_users_assignations::(T::MaxRegistrationsAtTime::get(), ProxyRole::Builder, 1); + let expenditures = + create_array_expenditures::(T::MaxRegistrationsAtTime::get(), ExpenditureType::HardCost); + let job_eligibles = create_array_job_eligibles::(T::MaxRegistrationsAtTime::get(), 33); + let users_assignation = create_array_users_assignations::( + T::MaxRegistrationsAtTime::get(), + ProxyRole::Builder, + 1, + ); assert_ok!(register_users::(admin.clone(), users_assignation.clone())); - let private_group_id = generate_field_description(1, 100); + let private_group_id = generate_field_description(1, MAX_FIELD_NAME_SIZE); assert_ok!(FundAdmin::::projects_create_project( RawOrigin::Signed(admin.clone()).into(), @@ -268,11 +255,10 @@ pub fn create_full_project(admin: T::AccountId) -> Result<[u8;32], Di pub fn create_array_transactions_feedback( transaction_ids: Vec<[u8; 32]>, - description_size: u32, ) -> TransactionsFeedback { let mut transactions_feedback_vec: TransactionsFeedback = BoundedVec::new(); for i in 0..transaction_ids.len() { - let description = generate_field_description(1, description_size); + let description = generate_field_description(1, MAX_FIELD_DESC_SIZE); let transaction_feedback = (transaction_ids[i], description); transactions_feedback_vec.try_push(transaction_feedback).unwrap(); } @@ -298,12 +284,9 @@ pub fn create_array_inflation_rate( fn create_array_revenue_transactions( num_transactions: u32, job_eligible_id: [u8; 32], - num_documents: u32, - name_size: u32, - cid_size: u32, ) -> Result, DispatchError> { let mut transactions_vec: RevenueTransactions = BoundedVec::new(); - let documents = create_array_documents::(num_documents, name_size, cid_size); + let documents = create_array_documents::(T::MaxDocuments::get()); for i in 0..num_transactions { let transaction = ( Some(job_eligible_id), @@ -332,12 +315,10 @@ mod benchmarks { } #[benchmark] - fn sudo_add_administrator( - x: Linear<1, 100> - ) { + fn sudo_add_administrator() { assert_ok!(FundAdmin::::initial_setup(RawOrigin::Root.into())); let admin: T::AccountId = account("admin", 0, SEED); - let field_name = generate_field_name(1, x); + let field_name = generate_field_name(1, MAX_FIELD_NAME_SIZE); #[extrinsic_call] _(RawOrigin::Root, admin.clone(), field_name.clone()); @@ -346,12 +327,10 @@ mod benchmarks { } #[benchmark] - fn sudo_remove_administrator( - x: Linear<1, 100> - ) { + fn sudo_remove_administrator() { assert_ok!(FundAdmin::::initial_setup(RawOrigin::Root.into())); let admin: T::AccountId = account("admin", 0, SEED); - let field_name = generate_field_name(1, x); + let field_name = generate_field_name(1, MAX_FIELD_NAME_SIZE); assert_ok!(FundAdmin::::sudo_add_administrator( RawOrigin::Root.into(), admin.clone(), @@ -365,14 +344,10 @@ mod benchmarks { } #[benchmark] - fn users( - a: Linear<1, 100>, - x: Linear<1,{ T::MaxRegistrationsAtTime::get() }>, - y: Linear<1, 100> - ) { - let admin = initialize_pallet::(a); + fn users(x: Linear<1, { T::MaxRegistrationsAtTime::get() }>) { + let admin = initialize_pallet::(); - let users_array = create_array_users::(x, y, ProxyRole::Administrator); + let users_array = create_array_users::(x, ProxyRole::Administrator); #[extrinsic_call] _(RawOrigin::Signed(admin), users_array.clone()); @@ -383,22 +358,12 @@ mod benchmarks { } #[benchmark] - fn users_edit_user( - x: Linear<1, { T::MaxRegistrationsAtTime::get() }>, - y: Linear<1, 100>, - z: Linear<1, 100>, - a: Linear<1, 100>, - b: Linear<1, 100>, - c: Linear<1, { T::MaxDocuments::get() }>, - d: Linear<1, 100>, - e: Linear<1, 100>, - f: Linear<1, 100>, - ) { - let admin = initialize_pallet::(f); + fn users_edit_user(d: Linear<1, { T::MaxDocuments::get() }>) { + let admin = initialize_pallet::(); let investor_account: T::AccountId = account("user", 1, SEED); let investor_payload = - generate_user::(investor_account.clone(), y, ProxyRole::Investor, CUDAction::Create) + generate_user::(investor_account.clone(), ProxyRole::Investor, CUDAction::Create) .unwrap(); assert_ok!(FundAdmin::::users( RawOrigin::Signed(admin.clone()).into(), @@ -407,10 +372,10 @@ mod benchmarks { let investor_info = >::get(investor_account.clone()); assert!(investor_info.is_some()); - let name = generate_field_name(1, z); - let image = generate_field_name(1, a); - let email = generate_field_name(1, b); - let documents = create_array_documents::(c, d, e); + let name = generate_field_name(1, MAX_FIELD_NAME_SIZE); + let image = generate_field_name(1, MAX_FIELD_NAME_SIZE); + let email = generate_field_name(1, MAX_FIELD_NAME_SIZE); + let documents = create_array_documents::(d); #[extrinsic_call] _( @@ -430,39 +395,26 @@ mod benchmarks { #[benchmark] fn projects_create_project( - a: Linear<1, 100>, - b: Linear<1, 400>, - c: Linear<1, 100>, - d: Linear<1, 100>, - e: Linear<1, { T::MaxBanksPerProject::get() }>, - f: Linear<1, 100>, - g: Linear<1, 100>, - h: Linear<1, { T::MaxRegistrationsAtTime::get() }>, - i: Linear<1, 100>, - j: Linear<1, 400>, - k: Linear<1, { T::MaxRegistrationsAtTime::get() }>, - l: Linear<1, 100>, - m: Linear<1, 400>, - n: Linear<1, { T::MaxRegistrationsAtTime::get() }>, - o: Linear<1, 400>, + b: Linear<1, { T::MaxBanksPerProject::get() }>, + e: Linear<1, { T::MaxRegistrationsAtTime::get() }>, + j: Linear<1, { T::MaxRegistrationsAtTime::get() }>, + u: Linear<1, { T::MaxRegistrationsAtTime::get() }>, ) { - let admin = initialize_pallet::(100); + let admin = initialize_pallet::(); - let title = generate_field_name(1, a); - let description = generate_field_description(1, b); - let image = generate_field_name(1, c); - let address = generate_field_name(1, d); - let banks = generate_banks::(e, f, g); + let title = generate_field_name(1, MAX_FIELD_NAME_SIZE); + let description = generate_field_description(1, MAX_FIELD_DESC_SIZE); + let image = generate_field_name(1, MAX_FIELD_NAME_SIZE); + let address = generate_field_name(1, MAX_FIELD_NAME_SIZE); + let banks = generate_banks::(b); let creation_date = u64::MAX - 1; let completion_date = u64::MAX; - let expenditures = - create_array_expenditures::(h, i, j, ExpenditureType::HardCost); - let job_eligibles = create_array_job_eligibles::(k, l, m); - let users_assignation = - create_array_users_assignations::(n, ProxyRole::Builder, 50); + let expenditures = create_array_expenditures::(e, ExpenditureType::HardCost); + let job_eligibles = create_array_job_eligibles::(j, 11); + let users_assignation = create_array_users_assignations::(u, ProxyRole::Builder, 50); assert_ok!(register_users::(admin.clone(), users_assignation.clone())); - let private_group_id = generate_field_description(1, o); + let private_group_id = generate_field_description(1, MAX_FIELD_DESC_SIZE); #[extrinsic_call] _( @@ -485,25 +437,15 @@ mod benchmarks { } #[benchmark] - fn projects_edit_project( - a: Linear<1, 100>, - b: Linear<1, 400>, - c: Linear<1, 100>, - d: Linear<1, 100>, - e: Linear<1, { T::MaxBanksPerProject::get() }>, - f: Linear<1, 100>, - g: Linear<1, 100>, - h: Linear<1, { T::MaxRegistrationsAtTime::get() }>, - i: Linear<1, 100>, - j: Linear<1, 400>, - ) { - let admin = initialize_pallet::(100); + fn projects_edit_project(b: Linear<1, { T::MaxBanksPerProject::get() }>) { + let admin = initialize_pallet::(); let project_id = create_full_project::(admin.clone()).unwrap(); - let title = generate_field_name(1, a); - let description = generate_field_description(1, b); - let image = generate_field_name(1, c); - let address = generate_field_name(1, d); + let title = generate_field_name(1, MAX_FIELD_NAME_SIZE); + let description = generate_field_description(1, MAX_FIELD_DESC_SIZE); + let image = generate_field_name(1, MAX_FIELD_NAME_SIZE); + let banks = generate_banks::(b); + let address = generate_field_name(1, MAX_FIELD_NAME_SIZE); let creation_date = u64::MAX - 1; let completion_date = u64::MAX; @@ -515,7 +457,7 @@ mod benchmarks { Some(description.clone()), Some(image.clone()), Some(address.clone()), - None, + Some(banks.clone()), Some(creation_date), Some(completion_date), ); @@ -527,11 +469,12 @@ mod benchmarks { assert!(project_info.clone().unwrap().address == address); assert!(project_info.clone().unwrap().creation_date == creation_date); assert!(project_info.clone().unwrap().completion_date == completion_date); + assert!(project_info.clone().unwrap().banks == Some(banks)); } #[benchmark] fn projects_delete_project() { - let admin = initialize_pallet::(100); + let admin = initialize_pallet::(); let project_id = create_full_project::(admin.clone()).unwrap(); #[extrinsic_call] @@ -542,10 +485,8 @@ mod benchmarks { } #[benchmark] - fn projects_assign_user( - a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, - ) { - let admin = initialize_pallet::(100); + fn projects_assign_user(a: Linear<1, { T::MaxRegistrationsAtTime::get() }>) { + let admin = initialize_pallet::(); let project_id = create_full_project::(admin.clone()).unwrap(); let users_assignation = create_array_users_assignations::(a, ProxyRole::Builder, 100); @@ -564,21 +505,22 @@ mod benchmarks { #[benchmark] fn expenditures_and_job_eligibles( - a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, - b: Linear<1, 100>, - c: Linear<1, 400>, - d: Linear<1, { T::MaxRegistrationsAtTime::get() }>, - e: Linear<1, 100>, - f: Linear<1, 400>, + e: Linear<1, { T::MaxRegistrationsAtTime::get() }>, + j: Linear<1, { T::MaxRegistrationsAtTime::get() }>, ) { - let admin = initialize_pallet::(100); + let admin = initialize_pallet::(); let project_id = create_full_project::(admin.clone()).unwrap(); - let expenditures = create_array_expenditures::(a, b, c, ExpenditureType::SoftCost); - let job_eligibles = create_array_job_eligibles::(d, e, f); + let expenditures = create_array_expenditures::(e, ExpenditureType::SoftCost); + let job_eligibles = create_array_job_eligibles::(j, 22); #[extrinsic_call] - _(RawOrigin::Signed(admin.clone()), project_id.clone(), Some(expenditures.clone()), Some(job_eligibles.clone())); + _( + RawOrigin::Signed(admin.clone()), + project_id.clone(), + Some(expenditures.clone()), + Some(job_eligibles.clone()), + ); >::iter().for_each(|(_key, value)| { assert!(value.project_id == project_id); @@ -590,21 +532,15 @@ mod benchmarks { } #[benchmark] - fn submit_drawdown( - a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, - b: Linear<1, { T::MaxDocuments::get() }>, - c: Linear<1, 100>, - d: Linear<1, 100>, - ) { - let admin = initialize_pallet::(100); + fn submit_drawdown(a: Linear<1, { T::MaxRegistrationsAtTime::get() }>) { + let admin = initialize_pallet::(); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::EB5; let drawdown_number = 1 as u32; let drawdown_id = get_drawdown_id::(project_id.clone(), drawdown_type, drawdown_number); let expenditure_id = >::iter_keys().next(); assert!(expenditure_id.is_some()); - let transactions = - create_array_transactions::(a, expenditure_id.unwrap(), b, c, d); + let transactions = create_array_transactions::(a, expenditure_id.unwrap()); #[extrinsic_call] _( @@ -621,21 +557,18 @@ mod benchmarks { } #[benchmark] - fn approve_drawdown( - a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, - b: Linear<1, { T::MaxDocuments::get() }>, - c: Linear<1, 100>, - d: Linear<1, 100>, - ) { - let admin = initialize_pallet::(100); + fn approve_drawdown(a: Linear<1, { T::MaxRegistrationsAtTime::get() }>) { + let admin = initialize_pallet::(); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::EB5; let drawdown_number = 1 as u32; let drawdown_id = get_drawdown_id::(project_id.clone(), drawdown_type, drawdown_number); let expenditure_id = >::iter_keys().next(); assert!(expenditure_id.is_some()); - let transactions = - create_array_transactions::(T::MaxRegistrationsAtTime::get(), expenditure_id.unwrap(), T::MaxDocuments::get(), 100, 100); + let transactions = create_array_transactions::( + T::MaxRegistrationsAtTime::get(), + expenditure_id.unwrap(), + ); assert_ok!(FundAdmin::::submit_drawdown( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -646,7 +579,7 @@ mod benchmarks { let last_expenditure_id = >::iter_keys().last(); let bulkupload_transactions = - create_array_transactions::(a, last_expenditure_id.unwrap(), b, c, d); + create_array_transactions::(a, last_expenditure_id.unwrap()); #[extrinsic_call] _( @@ -663,19 +596,18 @@ mod benchmarks { } #[benchmark] - fn reject_drawdown( - b: Linear<1, 400>, - c: Linear<1, 400>, - ) { - let admin = initialize_pallet::(100); + fn reject_drawdown() { + let admin = initialize_pallet::(); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::EB5; let drawdown_number = 1 as u32; let drawdown_id = get_drawdown_id::(project_id.clone(), drawdown_type, drawdown_number); let expenditure_id = >::iter_keys().next(); assert!(expenditure_id.is_some()); - let transactions = - create_array_transactions::(T::MaxRegistrationsAtTime::get(), expenditure_id.unwrap(), T::MaxDocuments::get(), 100, 100); + let transactions = create_array_transactions::( + T::MaxRegistrationsAtTime::get(), + expenditure_id.unwrap(), + ); assert_ok!(FundAdmin::::submit_drawdown( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -687,8 +619,8 @@ mod benchmarks { let transaction_ids = >::get(project_id.clone(), drawdown_id.clone()).to_vec(); let transactions_feedback = - create_array_transactions_feedback::(transaction_ids.clone(), b); - let drawdown_feedback = generate_field_description(1, c); + create_array_transactions_feedback::(transaction_ids.clone()); + let drawdown_feedback = generate_field_description(1, MAX_FIELD_DESC_SIZE); #[extrinsic_call] _( @@ -705,20 +637,15 @@ mod benchmarks { } #[benchmark] - fn up_bulkupload( - a: Linear<1, 400>, - b: Linear<1, { T::MaxDocuments::get() }>, - c: Linear<1, 100>, - d: Linear<1, 100>, - ) { - let admin = initialize_pallet::(100); + fn up_bulkupload(d: Linear<1, { T::MaxDocuments::get() }>) { + let admin = initialize_pallet::(); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::DeveloperEquity; let drawdown_number = 1 as u32; let drawdown_id = get_drawdown_id::(project_id.clone(), drawdown_type, drawdown_number); - let description = generate_field_description(1, a); + let description = generate_field_description(1, MAX_FIELD_NAME_SIZE); let total_amount = u64::MAX; - let documents = create_array_documents::(b, c, d); + let documents = create_array_documents::(d); #[extrinsic_call] _( @@ -736,10 +663,8 @@ mod benchmarks { } #[benchmark] - fn inflation_rate( - a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, - ) { - let admin = initialize_pallet::(100); + fn inflation_rate(a: Linear<1, { T::MaxRegistrationsAtTime::get() }>) { + let admin = initialize_pallet::(); let project_id = create_full_project::(admin.clone()).unwrap(); let inflation_projects = create_array_inflation_rate::(a, project_id).unwrap(); @@ -754,19 +679,14 @@ mod benchmarks { } #[benchmark] - fn submit_revenue( - a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, - b: Linear<1, { T::MaxDocuments::get() }>, - c: Linear<1, 100>, - d: Linear<1, 100>, - ) { - let admin = initialize_pallet::(100); + fn submit_revenue(a: Linear<1, { T::MaxRegistrationsAtTime::get() }>) { + let admin = initialize_pallet::(); let project_id = create_full_project::(admin.clone()).unwrap(); let revenue_id = >::iter_keys().next(); let job_eligible_id = >::iter_keys().next(); assert!(job_eligible_id.is_some()); let transactions = - create_array_revenue_transactions::(a, job_eligible_id.unwrap(), b, c, d).unwrap(); + create_array_revenue_transactions::(a, job_eligible_id.unwrap()).unwrap(); #[extrinsic_call] _( @@ -784,14 +704,16 @@ mod benchmarks { #[benchmark] fn approve_revenue() { - let admin = initialize_pallet::(100); + let admin = initialize_pallet::(); let project_id = create_full_project::(admin.clone()).unwrap(); let revenue_id = >::iter_keys().next(); let job_eligible_id = >::iter_keys().next(); assert!(job_eligible_id.is_some()); - let transactions = - create_array_revenue_transactions::(T::MaxRegistrationsAtTime::get(), job_eligible_id.unwrap(), T::MaxDocuments::get(), 100, 100) - .unwrap(); + let transactions = create_array_revenue_transactions::( + T::MaxRegistrationsAtTime::get(), + job_eligible_id.unwrap(), + ) + .unwrap(); assert_ok!(FundAdmin::::submit_revenue( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -809,17 +731,17 @@ mod benchmarks { } #[benchmark] - fn reject_revenue( - b: Linear<1, 400>, - ) { - let admin = initialize_pallet::(100); + fn reject_revenue() { + let admin = initialize_pallet::(); let project_id = create_full_project::(admin.clone()).unwrap(); let revenue_id = >::iter_keys().next(); let job_eligible_id = >::iter_keys().next(); assert!(job_eligible_id.is_some()); - let transactions = - create_array_revenue_transactions::(T::MaxRegistrationsAtTime::get(), job_eligible_id.unwrap(), T::MaxDocuments::get(), 100, 100) - .unwrap(); + let transactions = create_array_revenue_transactions::( + T::MaxRegistrationsAtTime::get(), + job_eligible_id.unwrap(), + ) + .unwrap(); assert_ok!(FundAdmin::::submit_revenue( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -832,7 +754,7 @@ mod benchmarks { >::get(project_id.clone(), revenue_id.clone().unwrap()) .to_vec(); let transactions_feedback = - create_array_transactions_feedback::(transaction_ids.clone(), b); + create_array_transactions_feedback::(transaction_ids.clone()); #[extrinsic_call] _( @@ -848,20 +770,18 @@ mod benchmarks { } #[benchmark] - fn bank_confirming_documents( - a: Linear<1, { T::MaxDocuments::get() }>, - b: Linear<1, 100>, - c: Linear<1, 100>, - ) { - let admin = initialize_pallet::(100); + fn bank_confirming_documents(a: Linear<1, { T::MaxDocuments::get() }>) { + let admin = initialize_pallet::(); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::EB5; let drawdown_number = 1 as u32; let drawdown_id = get_drawdown_id::(project_id.clone(), drawdown_type, drawdown_number); let expenditure_id = >::iter_keys().next(); assert!(expenditure_id.is_some()); - let transactions = - create_array_transactions::(T::MaxRegistrationsAtTime::get(), expenditure_id.unwrap(), T::MaxDocuments::get(), 100, 100); + let transactions = create_array_transactions::( + T::MaxRegistrationsAtTime::get(), + expenditure_id.unwrap(), + ); assert_ok!(FundAdmin::::submit_drawdown( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -877,7 +797,7 @@ mod benchmarks { None, )); - let confirming_documents = create_array_documents::(a, b, c); + let confirming_documents = create_array_documents::(a); #[extrinsic_call] _( @@ -895,15 +815,17 @@ mod benchmarks { #[benchmark] fn reset_drawdown() { - let admin = initialize_pallet::(100); + let admin = initialize_pallet::(); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::EB5; let drawdown_number = 1 as u32; let drawdown_id = get_drawdown_id::(project_id.clone(), drawdown_type, drawdown_number); let expenditure_id = >::iter_keys().next(); assert!(expenditure_id.is_some()); - let transactions = - create_array_transactions::(T::MaxRegistrationsAtTime::get(), expenditure_id.unwrap(), T::MaxDocuments::get(), 100, 100); + let transactions = create_array_transactions::( + T::MaxRegistrationsAtTime::get(), + expenditure_id.unwrap(), + ); assert_ok!(FundAdmin::::submit_drawdown( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -925,13 +847,8 @@ mod benchmarks { } #[benchmark] - fn recovery_drawdown( - a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, - b: Linear<1, { T::MaxDocuments::get() }>, - c: Linear<1, 100>, - d: Linear<1, 100>, - ) { - let admin = initialize_pallet::(100); + fn recovery_drawdown(a: Linear<1, { T::MaxRegistrationsAtTime::get() }>) { + let admin = initialize_pallet::(); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::EB5; let drawdown_number = 1 as u32; @@ -940,8 +857,10 @@ mod benchmarks { let last_expenditure_id = >::iter_keys().last(); assert!(expenditure_id.is_some()); assert!(last_expenditure_id.is_some()); - let transactions = - create_array_transactions::(T::MaxRegistrationsAtTime::get(), expenditure_id.unwrap(), T::MaxDocuments::get(), 100, 100); + let transactions = create_array_transactions::( + T::MaxRegistrationsAtTime::get(), + expenditure_id.unwrap(), + ); assert_ok!(FundAdmin::::submit_drawdown( RawOrigin::Signed(admin.clone()).into(), @@ -958,8 +877,7 @@ mod benchmarks { None, )); - let recovery_transactions = - create_array_transactions::(a, last_expenditure_id.unwrap(), b, c, d); + let recovery_transactions = create_array_transactions::(a, last_expenditure_id.unwrap()); #[extrinsic_call] _( @@ -981,22 +899,19 @@ mod benchmarks { } #[benchmark] - fn recovery_revenue( - a: Linear<1, { T::MaxRegistrationsAtTime::get() }>, - b: Linear<1, { T::MaxDocuments::get() }>, - c: Linear<1, 100>, - d: Linear<1, 100>, - ) { - let admin = initialize_pallet::(100); + fn recovery_revenue(a: Linear<1, { T::MaxRegistrationsAtTime::get() }>) { + let admin = initialize_pallet::(); let project_id = create_full_project::(admin.clone()).unwrap(); let revenue_id = >::iter_keys().next(); let job_eligible_id = >::iter_keys().next(); let last_job_eligible_id = >::iter_keys().last(); assert!(job_eligible_id.is_some()); assert!(last_job_eligible_id.is_some()); - let transactions = - create_array_revenue_transactions::(T::MaxRegistrationsAtTime::get(), job_eligible_id.unwrap(), T::MaxDocuments::get(), 100, 100) - .unwrap(); + let transactions = create_array_revenue_transactions::( + T::MaxRegistrationsAtTime::get(), + job_eligible_id.unwrap(), + ) + .unwrap(); assert_ok!(FundAdmin::::submit_revenue( RawOrigin::Signed(admin.clone()).into(), project_id.clone(), @@ -1011,8 +926,7 @@ mod benchmarks { )); let recovery_transactions = - create_array_revenue_transactions::(a, last_job_eligible_id.unwrap(), b, c, d) - .unwrap(); + create_array_revenue_transactions::(a, last_job_eligible_id.unwrap()).unwrap(); #[extrinsic_call] _( @@ -1032,7 +946,7 @@ mod benchmarks { #[benchmark] fn kill_storage() { - let admin = initialize_pallet::(100); + let admin = initialize_pallet::(); assert_ok!(create_full_project::(admin.clone())); #[extrinsic_call] diff --git a/pallets/fund-admin/src/mock.rs b/pallets/fund-admin/src/mock.rs index 62426c1..8997c73 100644 --- a/pallets/fund-admin/src/mock.rs +++ b/pallets/fund-admin/src/mock.rs @@ -1,5 +1,5 @@ use crate as pallet_fund_admin; -use frame_support::{parameter_types, traits::Currency}; +use frame_support::parameter_types; use frame_system as system; use sp_core::{ConstU64, H256}; use sp_runtime::{ From 76bc2dc50e85726dd9b3baac1c89bf1c5b079918 Mon Sep 17 00:00:00 2001 From: Dreyhh Date: Fri, 19 Apr 2024 10:40:29 -0600 Subject: [PATCH 40/40] Generated weights file for fund-admin pallet, updated fund-admin extrinsics to use the new weights, updated afloat pallet benchmarks to remove unneeded storage maps population, updated frame-weigth-template.hbs file to use the newest version, removed no longer needed fund-admin extrinc . closes #39 --- .maintain/frame-weight-template.hbs | 52 +- pallets/afloat/src/benchmarking.rs | 208 +-- pallets/fund-admin/src/benchmarking.rs | 20 +- pallets/fund-admin/src/lib.rs | 79 +- pallets/fund-admin/src/mock.rs | 1 + pallets/fund-admin/src/weights.rs | 1665 ++++++++++++++++++++++++ 6 files changed, 1741 insertions(+), 284 deletions(-) create mode 100644 pallets/fund-admin/src/weights.rs diff --git a/.maintain/frame-weight-template.hbs b/.maintain/frame-weight-template.hbs index 9c9e297..ecd384a 100644 --- a/.maintain/frame-weight-template.hbs +++ b/.maintain/frame-weight-template.hbs @@ -1,10 +1,11 @@ {{header}} -//! Autogenerated weights for {{pallet}} +//! Autogenerated weights for `{{pallet}}` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION {{version}} -//! DATE: {{date}}, STEPS: `{{cmd.steps}}`, REPEAT: {{cmd.repeat}}, LOW RANGE: `{{cmd.lowest_range_values}}`, HIGH RANGE: `{{cmd.highest_range_values}}` +//! DATE: {{date}}, STEPS: `{{cmd.steps}}`, REPEAT: `{{cmd.repeat}}`, LOW RANGE: `{{cmd.lowest_range_values}}`, HIGH RANGE: `{{cmd.highest_range_values}}` +//! WORST CASE MAP SIZE: `{{cmd.worst_case_map_values}}` //! HOSTNAME: `{{hostname}}`, CPU: `{{cpuname}}` -//! EXECUTION: {{cmd.execution}}, WASM-EXECUTION: {{cmd.wasm_execution}}, CHAIN: {{cmd.chain}}, DB CACHE: {{cmd.db_cache}} +//! WASM-EXECUTION: `{{cmd.wasm_execution}}`, CHAIN: `{{cmd.chain}}`, DB CACHE: `{{cmd.db_cache}}` // Executed Command: {{#each args as |arg|}} @@ -14,11 +15,12 @@ #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] +#![allow(missing_docs)] use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; +use core::marker::PhantomData; -/// Weight functions needed for {{pallet}}. +/// Weight functions needed for `{{pallet}}`. pub trait WeightInfo { {{#each benchmarks as |benchmark|}} fn {{benchmark.name~}} @@ -29,7 +31,7 @@ pub trait WeightInfo { {{/each}} } -/// Weights for {{pallet}} using the Substrate node and recommended hardware. +/// Weights for `{{pallet}}` using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); {{#if (eq pallet "frame_system")}} impl WeightInfo for SubstrateWeight { @@ -38,7 +40,7 @@ impl WeightInfo for SubstrateWeight { {{/if}} {{#each benchmarks as |benchmark|}} {{#each benchmark.comments as |comment|}} - // {{comment}} + /// {{comment}} {{/each}} {{#each benchmark.component_ranges as |range|}} /// The range of component `{{range.name}}` is `[{{range.min}}, {{range.max}}]`. @@ -48,33 +50,39 @@ impl WeightInfo for SubstrateWeight { {{~#each benchmark.components as |c| ~}} {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} ) -> Weight { - // Minimum execution time: {{underscore benchmark.min_execution_time}} nanoseconds. - Weight::from_ref_time({{underscore benchmark.base_weight}}) + // Proof Size summary in bytes: + // Measured: `{{benchmark.base_recorded_proof_size}}{{#each benchmark.component_recorded_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}` + // Estimated: `{{benchmark.base_calculated_proof_size}}{{#each benchmark.component_calculated_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}` + // Minimum execution time: {{underscore benchmark.min_execution_time}}_000 picoseconds. + Weight::from_parts({{underscore benchmark.base_weight}}, {{benchmark.base_calculated_proof_size}}) {{#each benchmark.component_weight as |cw|}} // Standard Error: {{underscore cw.error}} - .saturating_add(Weight::from_ref_time({{underscore cw.slope}}).saturating_mul({{cw.name}}.into())) + .saturating_add(Weight::from_parts({{underscore cw.slope}}, 0).saturating_mul({{cw.name}}.into())) {{/each}} {{#if (ne benchmark.base_reads "0")}} - .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}})) + .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}}_u64)) {{/if}} {{#each benchmark.component_reads as |cr|}} .saturating_add(T::DbWeight::get().reads(({{cr.slope}}_u64).saturating_mul({{cr.name}}.into()))) {{/each}} {{#if (ne benchmark.base_writes "0")}} - .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}})) + .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}}_u64)) {{/if}} {{#each benchmark.component_writes as |cw|}} .saturating_add(T::DbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into()))) {{/each}} + {{#each benchmark.component_calculated_proof_size as |cp|}} + .saturating_add(Weight::from_parts(0, {{cp.slope}}).saturating_mul({{cp.name}}.into())) + {{/each}} } {{/each}} } -// For backwards compatibility and tests +// For backwards compatibility and tests. impl WeightInfo for () { {{#each benchmarks as |benchmark|}} {{#each benchmark.comments as |comment|}} - // {{comment}} + /// {{comment}} {{/each}} {{#each benchmark.component_ranges as |range|}} /// The range of component `{{range.name}}` is `[{{range.min}}, {{range.max}}]`. @@ -84,24 +92,30 @@ impl WeightInfo for () { {{~#each benchmark.components as |c| ~}} {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} ) -> Weight { - // Minimum execution time: {{underscore benchmark.min_execution_time}} nanoseconds. - Weight::from_ref_time({{underscore benchmark.base_weight}}) + // Proof Size summary in bytes: + // Measured: `{{benchmark.base_recorded_proof_size}}{{#each benchmark.component_recorded_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}` + // Estimated: `{{benchmark.base_calculated_proof_size}}{{#each benchmark.component_calculated_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}` + // Minimum execution time: {{underscore benchmark.min_execution_time}}_000 picoseconds. + Weight::from_parts({{underscore benchmark.base_weight}}, {{benchmark.base_calculated_proof_size}}) {{#each benchmark.component_weight as |cw|}} // Standard Error: {{underscore cw.error}} - .saturating_add(Weight::from_ref_time({{underscore cw.slope}}).saturating_mul({{cw.name}}.into())) + .saturating_add(Weight::from_parts({{underscore cw.slope}}, 0).saturating_mul({{cw.name}}.into())) {{/each}} {{#if (ne benchmark.base_reads "0")}} - .saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}})) + .saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}}_u64)) {{/if}} {{#each benchmark.component_reads as |cr|}} .saturating_add(RocksDbWeight::get().reads(({{cr.slope}}_u64).saturating_mul({{cr.name}}.into()))) {{/each}} {{#if (ne benchmark.base_writes "0")}} - .saturating_add(RocksDbWeight::get().writes({{benchmark.base_writes}})) + .saturating_add(RocksDbWeight::get().writes({{benchmark.base_writes}}_u64)) {{/if}} {{#each benchmark.component_writes as |cw|}} .saturating_add(RocksDbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into()))) {{/each}} + {{#each benchmark.component_calculated_proof_size as |cp|}} + .saturating_add(Weight::from_parts(0, {{cp.slope}}).saturating_mul({{cp.name}}.into())) + {{/each}} } {{/each}} } diff --git a/pallets/afloat/src/benchmarking.rs b/pallets/afloat/src/benchmarking.rs index bedfd41..09d5aa8 100644 --- a/pallets/afloat/src/benchmarking.rs +++ b/pallets/afloat/src/benchmarking.rs @@ -11,13 +11,12 @@ use frame_support::{ use frame_system::{Config as SystemConfig, RawOrigin}; use pallet_fruniques::types::{Attributes, ParentInfo}; use scale_info::prelude::{vec::Vec, *}; -use sp_runtime::{traits::Bounded, Permill}; +use sp_runtime::{sp_std::cmp, traits::Bounded, Permill}; use pallet_fruniques::Pallet as Fruniques; use pallet_gated_marketplace::Pallet as GatedMarketplace; use pallet_rbac::types::{IdOrVec, RoleBasedAccessControl, RoleId}; use sp_io::hashing::blake2_256; -use std::cmp; type DepositBalanceOf = <::Currency as Currency< ::AccountId, @@ -52,111 +51,6 @@ fn generate_id(item: Vec) -> [u8; 32] { item.using_encoded(blake2_256) } -fn set_rbac_assign_role_to_user_worst_case( - user: ::AccountId, - num_roles_available_user: u32, - inital_setup: bool, - pallet_ids: Vec, -) -> Result<(), sp_runtime::DispatchError> { - // Leave only one Scope available for the pallet - let max_scopes = - <::Rbac as RoleBasedAccessControl>::MaxScopesPerPallet::get( - ) - 1; - - let afloat_pallet_id = Afloat::::pallet_id().to_id(); - let afloat_scope_id = Afloat::::scope_id(); - let fruniques_pallet_id = Fruniques::::pallet_id().to_id(); - let fruniques_scope_id = Afloat::::collection_id() - .unwrap_or(T::AfloatBenchHelper::collection(0)) - .using_encoded(blake2_256); - let gm_pallet_id = GatedMarketplace::::pallet_id().to_id(); - let gm_scope_id = Afloat::::marketplace_id().unwrap_or(0.using_encoded(blake2_256)); - - for pallet_id in pallet_ids { - let mut scope_ids = Vec::new(); - for s in 0..max_scopes { - let scope = generate_scope_sized(s, 10); - let scope_id = generate_id(scope); - assert_ok!( - <::Rbac as RoleBasedAccessControl>::create_scope( - pallet_id.clone(), - scope_id - ) - ); - scope_ids.push(scope_id); - } - - let max_roles = <::Rbac as RoleBasedAccessControl>::MaxRolesPerPallet::get(); - let num_roles = match pallet_id.clone().to_id() { - v if v == afloat_pallet_id => max_roles - NUM_AFLOAT_ROLES, - v if v == gm_pallet_id => max_roles - NUM_GM_ROLES, - v if v == fruniques_pallet_id => max_roles - NUM_FRUNIQUES_ROLES, - _ => max_roles, - }; - - let size = - <::Rbac as RoleBasedAccessControl>::RoleMaxLen::get( - ); - - let roles = generate_roles_sized(1, num_roles, size); - - assert_ok!( - <::Rbac as RoleBasedAccessControl>::create_and_set_roles( - pallet_id.clone(), - roles.clone() - )); - - if !inital_setup { - let role_ids: Vec = roles.into_iter().map(|role| generate_id(role)).collect(); - let l = role_ids.len(); - let r = l - num_roles_available_user as usize; - let n = cmp::min(l, r); - let role_ids = &role_ids[0..n]; - let scope_id = match pallet_id.clone().to_id() { - v if v == afloat_pallet_id => afloat_scope_id, - v if v == fruniques_pallet_id => fruniques_scope_id, - v if v == gm_pallet_id => gm_scope_id, - _ => scope_ids[0], - }; - for role_id in role_ids { - assert_ok!(<::Rbac as RoleBasedAccessControl>::assign_role_to_user( - user.clone(), - pallet_id.clone(), - &scope_id, - role_id.clone() - )); - } - } - } - - Ok(()) -} - -fn set_start_take_sell_offer_worst_case( - user: ::AccountId, - offer_id: [u8; 32], -) -> Result<(), sp_runtime::DispatchError> -where - ::ItemId: From, - ::CollectionId: From, -{ - let max_trxs = TransactionBoundedVec::bound(); - let num_trxs = max_trxs - 1; - - for _ in 0..num_trxs { - Afloat::::start_take_sell_order( - RawOrigin::Signed(user.clone()).into(), - offer_id, - T::AfloatBenchHelper::balance(99), - )?; - } - let offer = AfloatOffers::::get(offer_id).unwrap(); - let offer_trxs = offer.transactions.clone(); - assert_eq!(offer.status, OfferStatus::CREATED); - assert_eq!(offer_trxs.len(), num_trxs); - Ok(()) -} - fn add_max_afloat_balance(user: T::AccountId) -> Result<(), sp_runtime::DispatchError> where ::ItemId: From, @@ -187,41 +81,6 @@ where ) } -fn set_gm_do_enlist_sell_offer_worst_case( - owner: T::AccountId, -) -> Result<(), sp_runtime::DispatchError> -where - ::ItemId: From, - ::CollectionId: From, -{ - // MaxOffersPerMarket is the limit for OffersByAccount, OffersByMarket and OffersByItem - // add_confirm_sell_transaction() populates those StorageMaps - // we need to create different accounts and different fruniques since the uniqueness of the - // item_id (created and checked by gm) relies on the use of a timestamp that doesn't work for - // the benchmark - - let max_offers_by_market = - ::MaxOffersPerMarket::get() - 1; - - for i in 0..max_offers_by_market { - let acc: T::AccountId = account("acc", 0, i + 1); - assert_ok!(register_user::(acc.clone(), "acc")); - assert_ok!(set_max_balance::(acc.clone())); - assert_ok!(add_max_afloat_balance::(acc.clone())); - let item_id = add_tax_credit::(owner.clone()).unwrap(); - let offer_id = add_sell_order::(owner.clone(), item_id).unwrap(); - let trx_id = add_start_take_sell_order::(acc.clone(), offer_id.clone()).unwrap(); - assert_ok!(add_confirm_sell_transaction::(owner.clone(), trx_id.clone())); - assert_ok!(set_afloat_balance_to_zero::(acc.clone())); - assert_ok!(Afloat::::update_user_info( - RawOrigin::Signed(account("admin", 0, SEED)).into(), - acc.clone(), - UpdateUserArgs::Delete - )); - } - Ok(()) -} - fn set_max_balance(account: T::AccountId) -> Result<(), sp_runtime::DispatchError> { let max_balance = DepositBalanceOf::::max_value(); ::Currency::make_free_balance_be(&account, max_balance); @@ -423,17 +282,6 @@ mod benchmarks { let creator: T::AccountId = account("creator", 0, SEED); assert_ok!(set_max_balance::(admin.clone())); assert_ok!(set_max_balance::(creator.clone())); - let pallet_ids = vec![ - Afloat::::pallet_id(), - Fruniques::::pallet_id(), - GatedMarketplace::::pallet_id(), - ]; - assert_ok!(set_rbac_assign_role_to_user_worst_case::( - admin.clone(), - 0, - true, - pallet_ids - )); let asset_id: T::AssetId = T::AfloatBenchHelper::asset(0); let min_balance: T::Balance = T::AfloatBenchHelper::balance(1); let asset: CreateAsset = CreateAsset::New { asset_id, min_balance }; @@ -469,19 +317,7 @@ mod benchmarks { let sign_up_args = SignUpArgs::BuyerOrSeller { cid: cid.clone(), cid_creator, group }; let user: T::AccountId = account("user", 0, SEED); - let pallet_ids = vec![ - Afloat::::pallet_id(), - Fruniques::::pallet_id(), - // GatedMarketplace::::pallet_id(), if the user already has *any* role in GM, - // sign_up fails because of a validation in gm's self_enroll() - ]; assert_ok!(init::()); - assert_ok!(set_rbac_assign_role_to_user_worst_case::( - user.clone(), - 1, - false, - pallet_ids - )); #[extrinsic_call] _(RawOrigin::Signed(user.clone()), sign_up_args); @@ -505,13 +341,6 @@ mod benchmarks { GatedMarketplace::::pallet_id(), ]; - assert_ok!(set_rbac_assign_role_to_user_worst_case::( - user.clone(), - 1, - false, - pallet_ids - )); - let admin: T::AccountId = account("admin", 0, SEED); #[extrinsic_call] _(RawOrigin::Signed(admin.clone()), user.clone(), update_user_info_args); @@ -573,13 +402,7 @@ mod benchmarks { assert_eq!(offer.status, OfferStatus::CREATED); assert!(offer_trxs.is_empty()); let admin: T::AccountId = account("admin", 0, SEED); - let _ = Afloat::::set_afloat_balance( - RawOrigin::Signed(admin).into(), - other_user.clone(), - T::Balance::max_value().into(), - ); - - assert_ok!(set_start_take_sell_offer_worst_case::(other_user.clone(), offer_id.clone())); + assert_ok!(add_max_afloat_balance::(other_user.clone())); #[extrinsic_call] _(RawOrigin::Signed(other_user), offer_id, MAX_U32.into()); @@ -587,7 +410,7 @@ mod benchmarks { let offer = AfloatOffers::::get(offer_id).unwrap(); let offer_trxs = offer.transactions.clone(); assert_eq!(offer.status, OfferStatus::CREATED); - assert_eq!(offer_trxs.len() as u32, 100); + assert_eq!(offer_trxs.len() as u32, 1); } #[benchmark] @@ -600,7 +423,6 @@ mod benchmarks { assert_ok!(register_user::(user.clone(), "user")); assert_ok!(register_user::(other_user.clone(), "other_user")); assert_ok!(add_tax_credit::(user.clone())); - assert_ok!(set_gm_do_enlist_sell_offer_worst_case::(user.clone())); let offer_id = add_sell_order::(user.clone(), T::AfloatBenchHelper::item(0)).unwrap(); assert_ok!(add_max_afloat_balance::(other_user.clone())); let transaction_id = add_start_take_sell_order::(other_user.clone(), offer_id).unwrap(); @@ -627,8 +449,6 @@ mod benchmarks { let offer_id = add_sell_order::(user.clone(), T::AfloatBenchHelper::item(0)).unwrap(); assert_ok!(add_max_afloat_balance::(other_user.clone())); let transaction_id = add_start_take_sell_order::(other_user.clone(), offer_id).unwrap(); - // used internally by gm do_take_sell_offer when tax credit amount < 100 - assert_ok!(set_up_fruniques_do_spawn_worst_case::(other_user.clone())); assert_ok!(add_confirm_sell_transaction::(user.clone(), transaction_id)); let transaction = AfloatTransactions::::get(transaction_id).unwrap(); assert_eq!(transaction.completed, false); @@ -676,19 +496,8 @@ mod benchmarks { fn add_afloat_admin() { let user: T::AccountId = account("user", 0, SEED); let admin: T::AccountId = account("admin", 0, SEED); - let pallet_ids = vec![ - Afloat::::pallet_id(), - Fruniques::::pallet_id(), - GatedMarketplace::::pallet_id(), - ]; assert_ok!(init::()); assert_ok!(register_user::(user.clone(), "user")); - assert_ok!(set_rbac_assign_role_to_user_worst_case::( - user.clone(), - 2, - false, - pallet_ids - )); assert!(!Afloat::::is_admin(user.clone()).unwrap()); #[extrinsic_call] _(RawOrigin::Signed(admin.clone()), user.clone()); @@ -699,19 +508,8 @@ mod benchmarks { fn assign_user_to_role() { let user: T::AccountId = account("user", 0, SEED); let admin: T::AccountId = account("admin", 0, SEED); - let pallet_ids = vec![ - Afloat::::pallet_id(), - Fruniques::::pallet_id(), - GatedMarketplace::::pallet_id(), - ]; assert_ok!(init::()); assert_ok!(register_user::(user.clone(), "user")); - assert_ok!(set_rbac_assign_role_to_user_worst_case::( - user.clone(), - 2, - false, - pallet_ids - )); let role: AfloatRole = AfloatRole::CPA; assert!(!Afloat::::is_cpa(user.clone()).unwrap()); #[extrinsic_call] diff --git a/pallets/fund-admin/src/benchmarking.rs b/pallets/fund-admin/src/benchmarking.rs index 5ac571a..62ec7f6 100644 --- a/pallets/fund-admin/src/benchmarking.rs +++ b/pallets/fund-admin/src/benchmarking.rs @@ -126,7 +126,7 @@ pub fn create_array_users_assignations( ) -> UsersAssignation { let mut users_vec: UsersAssignation = BoundedVec::new(); for i in 0..num_users { - let user_account: T::AccountId = account("user", id + i, SEED); + let user_account: T::AccountId = account("ua", i, id + i); let action = AssignAction::Assign; let user = (user_account, role, action); users_vec.try_push(user).unwrap(); @@ -208,7 +208,7 @@ where let admin_info = >::get(admin.clone()).unwrap(); assert!(admin_info.role == ProxyRole::Administrator); assert_eq!(admin_info.name, field_name); - T::Currency::make_free_balance_be(&admin, 100000u64.into()); + T::Currency::make_free_balance_be(&admin, u64::MAX.into()); admin } @@ -226,7 +226,7 @@ pub fn create_full_project(admin: T::AccountId) -> Result<[u8; 32], D let users_assignation = create_array_users_assignations::( T::MaxRegistrationsAtTime::get(), ProxyRole::Builder, - 1, + 1000, ); assert_ok!(register_users::(admin.clone(), users_assignation.clone())); @@ -489,7 +489,7 @@ mod benchmarks { let admin = initialize_pallet::(); let project_id = create_full_project::(admin.clone()).unwrap(); - let users_assignation = create_array_users_assignations::(a, ProxyRole::Builder, 100); + let users_assignation = create_array_users_assignations::(a, ProxyRole::Builder, 0); assert_ok!(register_users::(admin.clone(), users_assignation.clone())); #[extrinsic_call] @@ -557,7 +557,7 @@ mod benchmarks { } #[benchmark] - fn approve_drawdown(a: Linear<1, { T::MaxRegistrationsAtTime::get() }>) { + fn approve_drawdown(t: Linear<1, { T::MaxRegistrationsAtTime::get() }>) { let admin = initialize_pallet::(); let project_id = create_full_project::(admin.clone()).unwrap(); let drawdown_type = DrawdownType::EB5; @@ -579,7 +579,7 @@ mod benchmarks { let last_expenditure_id = >::iter_keys().last(); let bulkupload_transactions = - create_array_transactions::(a, last_expenditure_id.unwrap()); + create_array_transactions::(t, last_expenditure_id.unwrap()); #[extrinsic_call] _( @@ -663,10 +663,10 @@ mod benchmarks { } #[benchmark] - fn inflation_rate(a: Linear<1, { T::MaxRegistrationsAtTime::get() }>) { + fn inflation_rate(p: Linear<1, { T::MaxRegistrationsAtTime::get() }>) { let admin = initialize_pallet::(); let project_id = create_full_project::(admin.clone()).unwrap(); - let inflation_projects = create_array_inflation_rate::(a, project_id).unwrap(); + let inflation_projects = create_array_inflation_rate::(p, project_id).unwrap(); #[extrinsic_call] _(RawOrigin::Signed(admin.clone()), inflation_projects.clone()); @@ -679,14 +679,14 @@ mod benchmarks { } #[benchmark] - fn submit_revenue(a: Linear<1, { T::MaxRegistrationsAtTime::get() }>) { + fn submit_revenue(t: Linear<1, { T::MaxRegistrationsAtTime::get() }>) { let admin = initialize_pallet::(); let project_id = create_full_project::(admin.clone()).unwrap(); let revenue_id = >::iter_keys().next(); let job_eligible_id = >::iter_keys().next(); assert!(job_eligible_id.is_some()); let transactions = - create_array_revenue_transactions::(a, job_eligible_id.unwrap()).unwrap(); + create_array_revenue_transactions::(t, job_eligible_id.unwrap()).unwrap(); #[extrinsic_call] _( diff --git a/pallets/fund-admin/src/lib.rs b/pallets/fund-admin/src/lib.rs index 78e8853..67a45f8 100644 --- a/pallets/fund-admin/src/lib.rs +++ b/pallets/fund-admin/src/lib.rs @@ -2,7 +2,6 @@ pub use pallet::*; -// #[cfg(feature = "runtime-benchmarks")] mod benchmarking; #[cfg(test)] @@ -14,8 +13,11 @@ mod tests; mod functions; pub mod migration; mod types; +pub mod weights; +use weights::WeightInfo; #[frame_support::pallet] pub mod pallet { + use super::*; use frame_support::{ pallet_prelude::{ValueQuery, *}, traits::{Currency, Time}, @@ -23,7 +25,7 @@ pub mod pallet { }; use frame_system::pallet_prelude::*; use scale_info::prelude::vec; - use sp_runtime::{sp_std::vec::Vec, traits::Scale}; + use sp_runtime::traits::Scale; const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); use crate::types::*; @@ -51,6 +53,8 @@ pub mod pallet { type Currency: Currency; + type WeightInfo: WeightInfo; + #[pallet::constant] type MaxDocuments: Get; @@ -714,7 +718,7 @@ pub mod pallet { /// - This function can only be called once /// - This function can only be called usinf the sudo pallet #[pallet::call_index(1)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::initial_setup())] pub fn initial_setup(origin: OriginFor) -> DispatchResult { T::RemoveOrigin::ensure_origin(origin.clone())?; Self::do_initial_setup()?; @@ -736,7 +740,7 @@ pub mod pallet { /// - This function grants administrator permissions to the user from the rbac pallet /// - administrator role have global scope permissions #[pallet::call_index(2)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::sudo_add_administrator())] pub fn sudo_add_administrator( origin: OriginFor, admin: T::AccountId, @@ -763,7 +767,7 @@ pub mod pallet { /// WARNING: Administrators can remove themselves from the site, /// but they can add themselves back #[pallet::call_index(3)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::sudo_remove_administrator())] pub fn sudo_remove_administrator( origin: OriginFor, admin: T::AccountId, @@ -810,7 +814,7 @@ pub mod pallet { /// unassigning /// a user from a selected project. #[pallet::call_index(4)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::users(users.len() as u32))] pub fn users(origin: OriginFor, users: Users) -> DispatchResult { let who = ensure_signed(origin)?; // origin need to be an admin @@ -834,7 +838,7 @@ pub mod pallet { /// - ALL parameters are optional because depends on what is being edited /// - ONLY the investor role can edit or update the documents #[pallet::call_index(5)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::users_edit_user(documents.clone().unwrap_or_default().len() as u32))] pub fn users_edit_user( origin: OriginFor, name: Option, @@ -901,7 +905,7 @@ pub mod pallet { /// WARNING: If users are provided, the function will assign the users to the project, /// granting them permissions in the rbac pallet. #[pallet::call_index(6)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::projects_create_project(banks.clone().unwrap_or_default().len() as u32, expenditures.len() as u32, job_eligibles.clone().unwrap_or_default().len() as u32, users.clone().unwrap_or_default().len() as u32))] pub fn projects_create_project( origin: OriginFor, title: FieldName, @@ -959,7 +963,7 @@ pub mod pallet { /// - Project can only be edited in the Started status /// - Completion date must be greater than creation date #[pallet::call_index(7)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::projects_edit_project(banks.clone().unwrap_or_default().len() as u32))] pub fn projects_edit_project( origin: OriginFor, project_id: ProjectId, @@ -1003,7 +1007,7 @@ pub mod pallet { /// the project. /// BE CAREFUL. #[pallet::call_index(8)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::projects_delete_project())] pub fn projects_delete_project( origin: OriginFor, project_id: ProjectId, @@ -1050,7 +1054,7 @@ pub mod pallet { /// - Warning: Do not perform multiple actions over the same user in the same call, it could /// result in an unexpected behavior. #[pallet::call_index(9)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::projects_assign_user(users.len() as u32))] pub fn projects_assign_user( origin: OriginFor, project_id: ProjectId, @@ -1105,7 +1109,7 @@ pub mod pallet { /// - Do not perform multiple actions over the same expenditure in the same call, it could /// result in an unexpected behavior. #[pallet::call_index(10)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::expenditures_and_job_eligibles(expenditures.clone().unwrap_or_default().len() as u32, job_eligibles.clone().unwrap_or_default().len() as u32))] pub fn expenditures_and_job_eligibles( origin: OriginFor, project_id: ProjectId, @@ -1169,7 +1173,7 @@ pub mod pallet { /// - After a drawdown is rejected, builders will use again this extrinsic to update the /// transactions associated to a given drawdown. #[pallet::call_index(11)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::submit_drawdown(transactions.clone().unwrap_or_default().len() as u32))] pub fn submit_drawdown( origin: OriginFor, project_id: ProjectId, @@ -1260,7 +1264,7 @@ pub mod pallet { /// the /// new drawdown version uploaded by the builder. #[pallet::call_index(12)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::approve_drawdown(transactions.clone().unwrap_or_default().len() as u32))] pub fn approve_drawdown( origin: OriginFor, project_id: ProjectId, @@ -1361,7 +1365,7 @@ pub mod pallet { /// drawdown. /// There is no way to reject a single transaction. #[pallet::call_index(13)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::reject_drawdown())] pub fn reject_drawdown( origin: OriginFor, project_id: ProjectId, @@ -1402,7 +1406,7 @@ pub mod pallet { /// - After a builder uploads a drawdown, the administrator will have to /// insert each transaction manually. #[pallet::call_index(14)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::up_bulkupload(documents.len() as u32))] pub fn up_bulkupload( origin: OriginFor, project_id: ProjectId, @@ -1445,7 +1449,7 @@ pub mod pallet { /// * **Delete**: The inflation rate will be deleted. Project id and action are required. /// - The inflation rate can only be modified if the project is in the "started" status. #[pallet::call_index(15)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::inflation_rate(projects.len() as u32))] pub fn inflation_rate( origin: OriginFor, projects: ProjectsInflation, @@ -1501,7 +1505,7 @@ pub mod pallet { /// - After a revenue is rejected, builders will use again this extrinsic to update the /// transactions associated to a given revenue. #[pallet::call_index(16)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::submit_revenue(revenue_transactions.clone().unwrap_or_default().len() as u32))] pub fn submit_revenue( origin: OriginFor, project_id: ProjectId, @@ -1565,7 +1569,7 @@ pub mod pallet { /// new revenue version uploaded by the builder. /// - The revenue status will be updated to Approved. #[pallet::call_index(17)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::approve_revenue())] pub fn approve_revenue( origin: OriginFor, project_id: ProjectId, @@ -1598,7 +1602,7 @@ pub mod pallet { /// revenue. /// There is no way to reject a single revenue transaction. #[pallet::call_index(18)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::reject_revenue())] pub fn reject_revenue( origin: OriginFor, project_id: ProjectId, @@ -1635,7 +1639,7 @@ pub mod pallet { /// drawdown status to "Approved" and the status of all of its transactions to "Approved". /// It does a rollback of the drawdown. #[pallet::call_index(19)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::bank_confirming_documents(confirming_documents.clone().unwrap_or_default().len() as u32))] pub fn bank_confirming_documents( origin: OriginFor, project_id: ProjectId, @@ -1667,7 +1671,7 @@ pub mod pallet { /// - All of its transactions will be deleted. /// - The whole drawdown will be reset to its initial state, so be careful when using this #[pallet::call_index(20)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::reset_drawdown())] pub fn reset_drawdown( origin: OriginFor, project_id: ProjectId, @@ -1700,7 +1704,7 @@ pub mod pallet { /// - This function is only callable by an administrator role account /// - The drawdown status won't be changed #[pallet::call_index(21)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::recovery_drawdown(transactions.clone().len() as u32))] pub fn recovery_drawdown( origin: OriginFor, project_id: ProjectId, @@ -1731,7 +1735,7 @@ pub mod pallet { /// - This function is only callable by an administrator role account /// - The revenue status won't be changed #[pallet::call_index(22)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::recovery_revenue(transactions.clone().len() as u32))] pub fn recovery_revenue( origin: OriginFor, project_id: ProjectId, @@ -1754,7 +1758,7 @@ pub mod pallet { /// ### Considerations: /// - This function is only available to the `admin` with sudo access. #[pallet::call_index(23)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] + #[pallet::weight(T::WeightInfo::kill_storage())] pub fn kill_storage(origin: OriginFor) -> DispatchResult { T::RemoveOrigin::ensure_origin(origin.clone())?; let _ = >::kill(); @@ -1778,30 +1782,5 @@ pub mod pallet { T::Rbac::remove_pallet_storage(Self::pallet_id())?; Ok(()) } - - #[pallet::call_index(24)] - #[pallet::weight(Weight::from_parts(10_000,0) + T::DbWeight::get().writes(10))] - pub fn set_new_admin_permissions(origin: OriginFor) -> DispatchResult { - T::RemoveOrigin::ensure_origin(origin.clone())?; - // New permissions for fund admin administrator role - let admin_id: [u8; 32] = ProxyRole::Administrator.id(); - let pallet_id = Self::pallet_id(); - - let new_admin_permissions: Vec> = vec![ - ProxyPermission::RecoveryDrawdown.to_vec(), - ProxyPermission::RecoveryRevenue.to_vec(), - ProxyPermission::RecoveryTransaction.to_vec(), - ProxyPermission::RecoveryRevenueTransaction.to_vec(), - ProxyPermission::BulkUploadTransaction.to_vec(), - ]; - - T::Rbac::create_and_set_permissions( - pallet_id.clone(), - admin_id, - new_admin_permissions, - )?; - - Ok(()) - } } } diff --git a/pallets/fund-admin/src/mock.rs b/pallets/fund-admin/src/mock.rs index 8997c73..f073c23 100644 --- a/pallets/fund-admin/src/mock.rs +++ b/pallets/fund-admin/src/mock.rs @@ -124,6 +124,7 @@ impl pallet_fund_admin::Config for Test { type MaxRecoveryChanges = MaxRecoveryChanges; type MinAdminBalance = MinAdminBalance; type TransferAmount = TransferAmount; + type WeightInfo = (); } impl pallet_timestamp::Config for Test { diff --git a/pallets/fund-admin/src/weights.rs b/pallets/fund-admin/src/weights.rs new file mode 100644 index 0000000..148e2b8 --- /dev/null +++ b/pallets/fund-admin/src/weights.rs @@ -0,0 +1,1665 @@ + +//! Autogenerated weights for `pallet_fund_admin` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2024-04-19, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `armando-hashed`, CPU: `AMD Ryzen 5 4600H with Radeon Graphics` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` + +// Executed Command: +// ./target/release/hashed-parachain +// benchmark +// pallet +// --chain +// dev +// --pallet +// pallet_fund_admin +// --extrinsic +// * +// --steps +// 50 +// --repeat +// 20 +// --output +// /home/armando/Desktop/hashed-pallets/pallets/fund-admin/src/weights.rs +// --template +// /home/armando/Desktop/hashed-pallets/.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_fund_admin`. +pub trait WeightInfo { + fn initial_setup() -> Weight; + fn sudo_add_administrator() -> Weight; + fn sudo_remove_administrator() -> Weight; + fn users(x: u32, ) -> Weight; + fn users_edit_user(d: u32, ) -> Weight; + fn projects_create_project(b: u32, e: u32, j: u32, u: u32, ) -> Weight; + fn projects_edit_project(b: u32, ) -> Weight; + fn projects_delete_project() -> Weight; + fn projects_assign_user(a: u32, ) -> Weight; + fn expenditures_and_job_eligibles(e: u32, j: u32, ) -> Weight; + fn submit_drawdown(a: u32, ) -> Weight; + fn approve_drawdown(a: u32, ) -> Weight; + fn reject_drawdown() -> Weight; + fn up_bulkupload(d: u32, ) -> Weight; + fn inflation_rate(a: u32, ) -> Weight; + fn submit_revenue(a: u32, ) -> Weight; + fn approve_revenue() -> Weight; + fn reject_revenue() -> Weight; + fn bank_confirming_documents(a: u32, ) -> Weight; + fn reset_drawdown() -> Weight; + fn recovery_drawdown(a: u32, ) -> Weight; + fn recovery_revenue(a: u32, ) -> Weight; + fn kill_storage() -> Weight; +} + +/// Weights for `pallet_fund_admin` using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: `RBAC::Scopes` (r:1 w:1) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Roles` (r:5 w:5) + /// Proof: `RBAC::Roles` (`max_values`: None, `max_size`: Some(83), added: 2558, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PalletRoles` (r:1 w:1) + /// Proof: `RBAC::PalletRoles` (`max_values`: None, `max_size`: Some(1633), added: 4108, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:25 w:25) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:5 w:5) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:0 w:1) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + fn initial_setup() -> Weight { + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `65740` + // Minimum execution time: 368_275_000 picoseconds. + Weight::from_parts(377_843_000, 65740) + .saturating_add(T::DbWeight::get().reads(37_u64)) + .saturating_add(T::DbWeight::get().writes(38_u64)) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:1) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PalletRoles` (r:1 w:0) + /// Proof: `RBAC::PalletRoles` (`max_values`: None, `max_size`: Some(1633), added: 4108, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:1) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::UsersByScope` (r:1 w:1) + /// Proof: `RBAC::UsersByScope` (`max_values`: None, `max_size`: Some(80098), added: 82573, mode: `MaxEncodedLen`) + fn sudo_add_administrator() -> Weight { + // Proof Size summary in bytes: + // Measured: `515` + // Estimated: `83563` + // Minimum execution time: 53_359_000 picoseconds. + Weight::from_parts(59_086_000, 83563) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:1) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:1) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::UsersByScope` (r:1 w:1) + /// Proof: `RBAC::UsersByScope` (`max_values`: None, `max_size`: Some(80098), added: 82573, mode: `MaxEncodedLen`) + fn sudo_remove_administrator() -> Weight { + // Proof Size summary in bytes: + // Measured: `695` + // Estimated: `83563` + // Minimum execution time: 50_077_000 picoseconds. + Weight::from_parts(52_381_000, 83563) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::UsersInfo` (r:101 w:100) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:1 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:101 w:100) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PalletRoles` (r:1 w:0) + /// Proof: `RBAC::PalletRoles` (`max_values`: None, `max_size`: Some(1633), added: 4108, mode: `MaxEncodedLen`) + /// Storage: `RBAC::UsersByScope` (r:1 w:1) + /// Proof: `RBAC::UsersByScope` (`max_values`: None, `max_size`: Some(80098), added: 82573, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:101 w:101) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 100]`. + fn users(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2977 + x * (2 ±0)` + // Estimated: `83563 + x * (23241 ±0)` + // Minimum execution time: 165_804_000 picoseconds. + Weight::from_parts(172_091_000, 83563) + // Standard Error: 225_062 + .saturating_add(Weight::from_parts(97_520_036, 0).saturating_mul(x.into())) + .saturating_add(T::DbWeight::get().reads(10_u64)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(x.into()))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(x.into()))) + .saturating_add(Weight::from_parts(0, 23241).saturating_mul(x.into())) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:1) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// The range of component `d` is `[1, 100]`. + fn users_edit_user(d: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `266` + // Estimated: `24231` + // Minimum execution time: 28_635_000 picoseconds. + Weight::from_parts(37_740_439, 24231) + // Standard Error: 10_782 + .saturating_add(Weight::from_parts(610_507, 0).saturating_mul(d.into())) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::UsersInfo` (r:101 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:1) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:4 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:101 w:100) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresInfo` (r:100 w:100) + /// Proof: `FundAdmin::ExpendituresInfo` (`max_values`: None, `max_size`: Some(583), added: 3058, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresByProject` (r:1 w:1) + /// Proof: `FundAdmin::ExpendituresByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::JobEligiblesInfo` (r:100 w:100) + /// Proof: `FundAdmin::JobEligiblesInfo` (`max_values`: None, `max_size`: Some(582), added: 3057, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::JobEligiblesByProject` (r:1 w:1) + /// Proof: `FundAdmin::JobEligiblesByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::UsersByProject` (r:1 w:1) + /// Proof: `FundAdmin::UsersByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsByUser` (r:100 w:100) + /// Proof: `FundAdmin::ProjectsByUser` (`max_values`: None, `max_size`: Some(320050), added: 322525, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PalletRoles` (r:1 w:0) + /// Proof: `RBAC::PalletRoles` (`max_values`: None, `max_size`: Some(1633), added: 4108, mode: `MaxEncodedLen`) + /// Storage: `RBAC::UsersByScope` (r:1 w:1) + /// Proof: `RBAC::UsersByScope` (`max_values`: None, `max_size`: Some(80098), added: 82573, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsInfo` (r:3 w:3) + /// Proof: `FundAdmin::DrawdownsInfo` (`max_values`: None, `max_size`: Some(90710), added: 93185, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsByProject` (r:1 w:1) + /// Proof: `FundAdmin::DrawdownsByProject` (`max_values`: None, `max_size`: Some(320034), added: 322509, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesInfo` (r:1 w:1) + /// Proof: `FundAdmin::RevenuesInfo` (`max_values`: None, `max_size`: Some(49097), added: 51572, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesByProject` (r:1 w:1) + /// Proof: `FundAdmin::RevenuesByProject` (`max_values`: None, `max_size`: Some(320034), added: 322509, mode: `MaxEncodedLen`) + /// The range of component `b` is `[1, 200]`. + /// The range of component `e` is `[1, 100]`. + /// The range of component `j` is `[1, 100]`. + /// The range of component `u` is `[1, 100]`. + fn projects_create_project(b: u32, e: u32, j: u32, u: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2637 + u * (170 ±0)` + // Estimated: `3203501 + e * (3058 ±0) + j * (3057 ±0) + u * (322525 ±0)` + // Minimum execution time: 9_790_769_000 picoseconds. + Weight::from_parts(10_107_081_000, 3203501) + // Standard Error: 1_276_572 + .saturating_add(Weight::from_parts(118_455_417, 0).saturating_mul(b.into())) + // Standard Error: 2_558_990 + .saturating_add(Weight::from_parts(81_492_563, 0).saturating_mul(u.into())) + .saturating_add(T::DbWeight::get().reads(22_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(e.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(j.into()))) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(u.into()))) + .saturating_add(T::DbWeight::get().writes(12_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(e.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(j.into()))) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(u.into()))) + .saturating_add(Weight::from_parts(0, 3058).saturating_mul(e.into())) + .saturating_add(Weight::from_parts(0, 3057).saturating_mul(j.into())) + .saturating_add(Weight::from_parts(0, 322525).saturating_mul(u.into())) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:1 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// The range of component `b` is `[1, 200]`. + fn projects_edit_project(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `8357` + // Estimated: `2525475` + // Minimum execution time: 133_118_000 picoseconds. + Weight::from_parts(140_642_760, 2525475) + // Standard Error: 17_072 + .saturating_add(Weight::from_parts(1_612_915, 0).saturating_mul(b.into())) + .saturating_add(T::DbWeight::get().reads(8_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `FundAdmin::UsersInfo` (r:101 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:1) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:2 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:101 w:100) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::UsersByProject` (r:1 w:1) + /// Proof: `FundAdmin::UsersByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsByUser` (r:100 w:100) + /// Proof: `FundAdmin::ProjectsByUser` (`max_values`: None, `max_size`: Some(320050), added: 322525, mode: `MaxEncodedLen`) + /// Storage: `RBAC::UsersByScope` (r:2 w:1) + /// Proof: `RBAC::UsersByScope` (`max_values`: None, `max_size`: Some(80098), added: 82573, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresByProject` (r:1 w:1) + /// Proof: `FundAdmin::ExpendituresByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsByProject` (r:1 w:1) + /// Proof: `FundAdmin::DrawdownsByProject` (`max_values`: None, `max_size`: Some(320034), added: 322509, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByDrawdown` (r:3 w:3) + /// Proof: `FundAdmin::TransactionsByDrawdown` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::JobEligiblesByProject` (r:1 w:1) + /// Proof: `FundAdmin::JobEligiblesByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesByProject` (r:1 w:1) + /// Proof: `FundAdmin::RevenuesByProject` (`max_values`: None, `max_size`: Some(320034), added: 322509, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByRevenue` (r:1 w:1) + /// Proof: `FundAdmin::TransactionsByRevenue` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsInfo` (r:0 w:3) + /// Proof: `FundAdmin::DrawdownsInfo` (`max_values`: None, `max_size`: Some(90710), added: 93185, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresInfo` (r:0 w:100) + /// Proof: `FundAdmin::ExpendituresInfo` (`max_values`: None, `max_size`: Some(583), added: 3058, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::JobEligiblesInfo` (r:0 w:100) + /// Proof: `FundAdmin::JobEligiblesInfo` (`max_values`: None, `max_size`: Some(582), added: 3057, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesInfo` (r:0 w:1) + /// Proof: `FundAdmin::RevenuesInfo` (`max_values`: None, `max_size`: Some(49097), added: 51572, mode: `MaxEncodedLen`) + fn projects_delete_project() -> Weight { + // Proof Size summary in bytes: + // Measured: `61657` + // Estimated: `32253490` + // Minimum execution time: 6_707_751_000 picoseconds. + Weight::from_parts(7_116_813_000, 32253490) + .saturating_add(T::DbWeight::get().reads(319_u64)) + .saturating_add(T::DbWeight::get().writes(416_u64)) + } + /// Storage: `FundAdmin::UsersInfo` (r:101 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:1 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:101 w:100) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::UsersByProject` (r:1 w:1) + /// Proof: `FundAdmin::UsersByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsByUser` (r:100 w:100) + /// Proof: `FundAdmin::ProjectsByUser` (`max_values`: None, `max_size`: Some(320050), added: 322525, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PalletRoles` (r:1 w:0) + /// Proof: `RBAC::PalletRoles` (`max_values`: None, `max_size`: Some(1633), added: 4108, mode: `MaxEncodedLen`) + /// Storage: `RBAC::UsersByScope` (r:1 w:1) + /// Proof: `RBAC::UsersByScope` (`max_values`: None, `max_size`: Some(80098), added: 82573, mode: `MaxEncodedLen`) + /// The range of component `a` is `[1, 100]`. + fn projects_assign_user(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `20420 + a * (226 ±0)` + // Estimated: `3203501 + a * (322525 ±0)` + // Minimum execution time: 197_024_000 picoseconds. + Weight::from_parts(116_804_696, 3203501) + // Standard Error: 177_570 + .saturating_add(Weight::from_parts(66_856_513, 0).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(10_u64)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_parts(0, 322525).saturating_mul(a.into())) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:2 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:0) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresInfo` (r:100 w:100) + /// Proof: `FundAdmin::ExpendituresInfo` (`max_values`: None, `max_size`: Some(583), added: 3058, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresByProject` (r:1 w:1) + /// Proof: `FundAdmin::ExpendituresByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::JobEligiblesInfo` (r:100 w:100) + /// Proof: `FundAdmin::JobEligiblesInfo` (`max_values`: None, `max_size`: Some(582), added: 3057, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::JobEligiblesByProject` (r:1 w:1) + /// Proof: `FundAdmin::JobEligiblesByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// The range of component `e` is `[1, 100]`. + /// The range of component `j` is `[1, 100]`. + fn expenditures_and_job_eligibles(e: u32, j: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `18858 + e * (17 ±0) + j * (20 ±0)` + // Estimated: `3203501 + e * (3058 ±0) + j * (3057 ±0)` + // Minimum execution time: 2_179_973_000 picoseconds. + Weight::from_parts(175_581_406, 3203501) + // Standard Error: 96_960 + .saturating_add(Weight::from_parts(20_560_587, 0).saturating_mul(e.into())) + // Standard Error: 96_960 + .saturating_add(Weight::from_parts(21_411_639, 0).saturating_mul(j.into())) + .saturating_add(T::DbWeight::get().reads(11_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(e.into()))) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(j.into()))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(e.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(j.into()))) + .saturating_add(Weight::from_parts(0, 3058).saturating_mul(e.into())) + .saturating_add(Weight::from_parts(0, 3057).saturating_mul(j.into())) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:2 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsInfo` (r:1 w:1) + /// Proof: `FundAdmin::DrawdownsInfo` (`max_values`: None, `max_size`: Some(90710), added: 93185, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresInfo` (r:1 w:0) + /// Proof: `FundAdmin::ExpendituresInfo` (`max_values`: None, `max_size`: Some(583), added: 3058, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsInfo` (r:100 w:100) + /// Proof: `FundAdmin::TransactionsInfo` (`max_values`: None, `max_size`: Some(20967), added: 23442, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByDrawdown` (r:1 w:1) + /// Proof: `FundAdmin::TransactionsByDrawdown` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// The range of component `a` is `[1, 100]`. + fn submit_drawdown(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `9282` + // Estimated: `2525475 + a * (23442 ±0)` + // Minimum execution time: 502_651_000 picoseconds. + Weight::from_parts(238_227_832, 2525475) + // Standard Error: 256_323 + .saturating_add(Weight::from_parts(235_581_283, 0).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(12_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_parts(0, 23442).saturating_mul(a.into())) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:3 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsInfo` (r:2 w:2) + /// Proof: `FundAdmin::DrawdownsInfo` (`max_values`: None, `max_size`: Some(90710), added: 93185, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresInfo` (r:1 w:0) + /// Proof: `FundAdmin::ExpendituresInfo` (`max_values`: None, `max_size`: Some(583), added: 3058, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsInfo` (r:200 w:200) + /// Proof: `FundAdmin::TransactionsInfo` (`max_values`: None, `max_size`: Some(20967), added: 23442, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByDrawdown` (r:1 w:1) + /// Proof: `FundAdmin::TransactionsByDrawdown` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsByProject` (r:1 w:1) + /// Proof: `FundAdmin::DrawdownsByProject` (`max_values`: None, `max_size`: Some(320034), added: 322509, mode: `MaxEncodedLen`) + /// The range of component `a` is `[1, 100]`. + fn approve_drawdown(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2070176` + // Estimated: `2525475 + a * (23442 ±0)` + // Minimum execution time: 19_643_024_000 picoseconds. + Weight::from_parts(19_444_937_640, 2525475) + // Standard Error: 628_560 + .saturating_add(Weight::from_parts(304_456_545, 0).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(115_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(105_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_parts(0, 23442).saturating_mul(a.into())) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:1 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsInfo` (r:1 w:1) + /// Proof: `FundAdmin::DrawdownsInfo` (`max_values`: None, `max_size`: Some(90710), added: 93185, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByDrawdown` (r:1 w:0) + /// Proof: `FundAdmin::TransactionsByDrawdown` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsInfo` (r:100 w:100) + /// Proof: `FundAdmin::TransactionsInfo` (`max_values`: None, `max_size`: Some(20967), added: 23442, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + fn reject_drawdown() -> Weight { + // Proof Size summary in bytes: + // Measured: `2069261` + // Estimated: `2525475` + // Minimum execution time: 13_787_694_000 picoseconds. + Weight::from_parts(13_914_317_000, 2525475) + .saturating_add(T::DbWeight::get().reads(110_u64)) + .saturating_add(T::DbWeight::get().writes(102_u64)) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:1 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsInfo` (r:1 w:1) + /// Proof: `FundAdmin::DrawdownsInfo` (`max_values`: None, `max_size`: Some(90710), added: 93185, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// The range of component `d` is `[1, 100]`. + fn up_bulkupload(d: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `8500` + // Estimated: `2525475` + // Minimum execution time: 147_995_000 picoseconds. + Weight::from_parts(163_935_160, 2525475) + // Standard Error: 15_510 + .saturating_add(Weight::from_parts(1_880_851, 0).saturating_mul(d.into())) + .saturating_add(T::DbWeight::get().reads(9_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + } + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:1 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// The range of component `a` is `[1, 100]`. + fn inflation_rate(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `8288` + // Estimated: `2525475` + // Minimum execution time: 123_969_000 picoseconds. + Weight::from_parts(126_316_183, 2525475) + // Standard Error: 24_264 + .saturating_add(Weight::from_parts(12_619_465, 0).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:2 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesInfo` (r:1 w:1) + /// Proof: `FundAdmin::RevenuesInfo` (`max_values`: None, `max_size`: Some(49097), added: 51572, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenueTransactionsInfo` (r:100 w:100) + /// Proof: `FundAdmin::RevenueTransactionsInfo` (`max_values`: None, `max_size`: Some(20967), added: 23442, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByRevenue` (r:1 w:1) + /// Proof: `FundAdmin::TransactionsByRevenue` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// The range of component `a` is `[1, 100]`. + fn submit_revenue(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `8449` + // Estimated: `2525475 + a * (23442 ±0)` + // Minimum execution time: 490_569_000 picoseconds. + Weight::from_parts(236_757_131, 2525475) + // Standard Error: 345_267 + .saturating_add(Weight::from_parts(234_868_590, 0).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(11_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(3_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_parts(0, 23442).saturating_mul(a.into())) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:1 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesInfo` (r:2 w:2) + /// Proof: `FundAdmin::RevenuesInfo` (`max_values`: None, `max_size`: Some(49097), added: 51572, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByRevenue` (r:1 w:0) + /// Proof: `FundAdmin::TransactionsByRevenue` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenueTransactionsInfo` (r:100 w:100) + /// Proof: `FundAdmin::RevenueTransactionsInfo` (`max_values`: None, `max_size`: Some(20967), added: 23442, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesByProject` (r:1 w:1) + /// Proof: `FundAdmin::RevenuesByProject` (`max_values`: None, `max_size`: Some(320034), added: 322509, mode: `MaxEncodedLen`) + fn approve_revenue() -> Weight { + // Proof Size summary in bytes: + // Measured: `2069236` + // Estimated: `2525475` + // Minimum execution time: 12_293_638_000 picoseconds. + Weight::from_parts(12_507_563_000, 2525475) + .saturating_add(T::DbWeight::get().reads(112_u64)) + .saturating_add(T::DbWeight::get().writes(104_u64)) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:1 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesInfo` (r:1 w:1) + /// Proof: `FundAdmin::RevenuesInfo` (`max_values`: None, `max_size`: Some(49097), added: 51572, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByRevenue` (r:1 w:0) + /// Proof: `FundAdmin::TransactionsByRevenue` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenueTransactionsInfo` (r:100 w:100) + /// Proof: `FundAdmin::RevenueTransactionsInfo` (`max_values`: None, `max_size`: Some(20967), added: 23442, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + fn reject_revenue() -> Weight { + // Proof Size summary in bytes: + // Measured: `2069144` + // Estimated: `2525475` + // Minimum execution time: 18_412_764_000 picoseconds. + Weight::from_parts(18_591_490_000, 2525475) + .saturating_add(T::DbWeight::get().reads(110_u64)) + .saturating_add(T::DbWeight::get().writes(102_u64)) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:1 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:0) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsInfo` (r:1 w:1) + /// Proof: `FundAdmin::DrawdownsInfo` (`max_values`: None, `max_size`: Some(90710), added: 93185, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByDrawdown` (r:1 w:0) + /// Proof: `FundAdmin::TransactionsByDrawdown` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsInfo` (r:100 w:100) + /// Proof: `FundAdmin::TransactionsInfo` (`max_values`: None, `max_size`: Some(20967), added: 23442, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// The range of component `a` is `[1, 100]`. + fn bank_confirming_documents(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2065064` + // Estimated: `2525475` + // Minimum execution time: 7_553_050_000 picoseconds. + Weight::from_parts(7_752_950_488, 2525475) + // Standard Error: 226_141 + .saturating_add(Weight::from_parts(1_532_143, 0).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(110_u64)) + .saturating_add(T::DbWeight::get().writes(101_u64)) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:1 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsInfo` (r:1 w:1) + /// Proof: `FundAdmin::DrawdownsInfo` (`max_values`: None, `max_size`: Some(90710), added: 93185, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByDrawdown` (r:1 w:1) + /// Proof: `FundAdmin::TransactionsByDrawdown` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsInfo` (r:0 w:100) + /// Proof: `FundAdmin::TransactionsInfo` (`max_values`: None, `max_size`: Some(20967), added: 23442, mode: `MaxEncodedLen`) + fn reset_drawdown() -> Weight { + // Proof Size summary in bytes: + // Measured: `11813` + // Estimated: `2525475` + // Minimum execution time: 356_822_000 picoseconds. + Weight::from_parts(368_486_000, 2525475) + .saturating_add(T::DbWeight::get().reads(10_u64)) + .saturating_add(T::DbWeight::get().writes(103_u64)) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:2 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:0) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsInfo` (r:1 w:1) + /// Proof: `FundAdmin::DrawdownsInfo` (`max_values`: None, `max_size`: Some(90710), added: 93185, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsByProject` (r:1 w:0) + /// Proof: `FundAdmin::DrawdownsByProject` (`max_values`: None, `max_size`: Some(320034), added: 322509, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByDrawdown` (r:1 w:1) + /// Proof: `FundAdmin::TransactionsByDrawdown` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresInfo` (r:1 w:0) + /// Proof: `FundAdmin::ExpendituresInfo` (`max_values`: None, `max_size`: Some(583), added: 3058, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsInfo` (r:200 w:100) + /// Proof: `FundAdmin::TransactionsInfo` (`max_values`: None, `max_size`: Some(20967), added: 23442, mode: `MaxEncodedLen`) + /// The range of component `a` is `[1, 100]`. + fn recovery_drawdown(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2070245` + // Estimated: `2525475 + a * (23442 ±0)` + // Minimum execution time: 12_614_492_000 picoseconds. + Weight::from_parts(12_466_050_756, 2525475) + // Standard Error: 392_127 + .saturating_add(Weight::from_parts(303_815_694, 0).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(113_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_parts(0, 23442).saturating_mul(a.into())) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:2 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:0) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesInfo` (r:1 w:1) + /// Proof: `FundAdmin::RevenuesInfo` (`max_values`: None, `max_size`: Some(49097), added: 51572, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesByProject` (r:1 w:0) + /// Proof: `FundAdmin::RevenuesByProject` (`max_values`: None, `max_size`: Some(320034), added: 322509, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByRevenue` (r:1 w:1) + /// Proof: `FundAdmin::TransactionsByRevenue` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenueTransactionsInfo` (r:200 w:100) + /// Proof: `FundAdmin::RevenueTransactionsInfo` (`max_values`: None, `max_size`: Some(20967), added: 23442, mode: `MaxEncodedLen`) + /// The range of component `a` is `[1, 100]`. + fn recovery_revenue(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2069441` + // Estimated: `2525475 + a * (23442 ±0)` + // Minimum execution time: 12_740_348_000 picoseconds. + Weight::from_parts(12_498_173_075, 2525475) + // Standard Error: 392_799 + .saturating_add(Weight::from_parts(298_353_500, 0).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(112_u64)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_parts(0, 23442).saturating_mul(a.into())) + } + /// Storage: `FundAdmin::UsersInfo` (r:101 w:101) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::UsersByProject` (r:1 w:1) + /// Proof: `FundAdmin::UsersByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsByUser` (r:100 w:100) + /// Proof: `FundAdmin::ProjectsByUser` (`max_values`: None, `max_size`: Some(320050), added: 322525, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresInfo` (r:100 w:100) + /// Proof: `FundAdmin::ExpendituresInfo` (`max_values`: None, `max_size`: Some(583), added: 3058, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresByProject` (r:1 w:1) + /// Proof: `FundAdmin::ExpendituresByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsInfo` (r:3 w:3) + /// Proof: `FundAdmin::DrawdownsInfo` (`max_values`: None, `max_size`: Some(90710), added: 93185, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsByProject` (r:1 w:1) + /// Proof: `FundAdmin::DrawdownsByProject` (`max_values`: None, `max_size`: Some(320034), added: 322509, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::JobEligiblesInfo` (r:100 w:100) + /// Proof: `FundAdmin::JobEligiblesInfo` (`max_values`: None, `max_size`: Some(582), added: 3057, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::JobEligiblesByProject` (r:1 w:1) + /// Proof: `FundAdmin::JobEligiblesByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesInfo` (r:1 w:1) + /// Proof: `FundAdmin::RevenuesInfo` (`max_values`: None, `max_size`: Some(49097), added: 51572, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesByProject` (r:1 w:1) + /// Proof: `FundAdmin::RevenuesByProject` (`max_values`: None, `max_size`: Some(320034), added: 322509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:1) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::UsersByScope` (r:4 w:2) + /// Proof: `RBAC::UsersByScope` (`max_values`: None, `max_size`: Some(80098), added: 82573, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PalletRoles` (r:2 w:1) + /// Proof: `RBAC::PalletRoles` (`max_values`: None, `max_size`: Some(1633), added: 4108, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:5 w:5) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:25 w:25) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:0 w:1) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Roles` (r:0 w:5) + /// Proof: `RBAC::Roles` (`max_values`: None, `max_size`: Some(83), added: 2558, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:0 w:101) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + fn kill_storage() -> Weight { + // Proof Size summary in bytes: + // Measured: `41100` + // Estimated: `32253490` + // Minimum execution time: 1_245_208_000 picoseconds. + Weight::from_parts(1_282_585_000, 32253490) + .saturating_add(T::DbWeight::get().reads(448_u64)) + .saturating_add(T::DbWeight::get().writes(552_u64)) + } +} + +// For backwards compatibility and tests. +impl WeightInfo for () { + /// Storage: `RBAC::Scopes` (r:1 w:1) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Roles` (r:5 w:5) + /// Proof: `RBAC::Roles` (`max_values`: None, `max_size`: Some(83), added: 2558, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PalletRoles` (r:1 w:1) + /// Proof: `RBAC::PalletRoles` (`max_values`: None, `max_size`: Some(1633), added: 4108, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:25 w:25) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:5 w:5) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:0 w:1) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + fn initial_setup() -> Weight { + // Proof Size summary in bytes: + // Measured: `42` + // Estimated: `65740` + // Minimum execution time: 368_275_000 picoseconds. + Weight::from_parts(377_843_000, 65740) + .saturating_add(RocksDbWeight::get().reads(37_u64)) + .saturating_add(RocksDbWeight::get().writes(38_u64)) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:1) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PalletRoles` (r:1 w:0) + /// Proof: `RBAC::PalletRoles` (`max_values`: None, `max_size`: Some(1633), added: 4108, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:1) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::UsersByScope` (r:1 w:1) + /// Proof: `RBAC::UsersByScope` (`max_values`: None, `max_size`: Some(80098), added: 82573, mode: `MaxEncodedLen`) + fn sudo_add_administrator() -> Weight { + // Proof Size summary in bytes: + // Measured: `515` + // Estimated: `83563` + // Minimum execution time: 53_359_000 picoseconds. + Weight::from_parts(59_086_000, 83563) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:1) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:1) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::UsersByScope` (r:1 w:1) + /// Proof: `RBAC::UsersByScope` (`max_values`: None, `max_size`: Some(80098), added: 82573, mode: `MaxEncodedLen`) + fn sudo_remove_administrator() -> Weight { + // Proof Size summary in bytes: + // Measured: `695` + // Estimated: `83563` + // Minimum execution time: 50_077_000 picoseconds. + Weight::from_parts(52_381_000, 83563) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::UsersInfo` (r:101 w:100) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:1 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:101 w:100) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PalletRoles` (r:1 w:0) + /// Proof: `RBAC::PalletRoles` (`max_values`: None, `max_size`: Some(1633), added: 4108, mode: `MaxEncodedLen`) + /// Storage: `RBAC::UsersByScope` (r:1 w:1) + /// Proof: `RBAC::UsersByScope` (`max_values`: None, `max_size`: Some(80098), added: 82573, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:101 w:101) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// The range of component `x` is `[1, 100]`. + fn users(x: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2977 + x * (2 ±0)` + // Estimated: `83563 + x * (23241 ±0)` + // Minimum execution time: 165_804_000 picoseconds. + Weight::from_parts(172_091_000, 83563) + // Standard Error: 225_062 + .saturating_add(Weight::from_parts(97_520_036, 0).saturating_mul(x.into())) + .saturating_add(RocksDbWeight::get().reads(10_u64)) + .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(x.into()))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(x.into()))) + .saturating_add(Weight::from_parts(0, 23241).saturating_mul(x.into())) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:1) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// The range of component `d` is `[1, 100]`. + fn users_edit_user(d: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `266` + // Estimated: `24231` + // Minimum execution time: 28_635_000 picoseconds. + Weight::from_parts(37_740_439, 24231) + // Standard Error: 10_782 + .saturating_add(Weight::from_parts(610_507, 0).saturating_mul(d.into())) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::UsersInfo` (r:101 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:1) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:4 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:101 w:100) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresInfo` (r:100 w:100) + /// Proof: `FundAdmin::ExpendituresInfo` (`max_values`: None, `max_size`: Some(583), added: 3058, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresByProject` (r:1 w:1) + /// Proof: `FundAdmin::ExpendituresByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::JobEligiblesInfo` (r:100 w:100) + /// Proof: `FundAdmin::JobEligiblesInfo` (`max_values`: None, `max_size`: Some(582), added: 3057, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::JobEligiblesByProject` (r:1 w:1) + /// Proof: `FundAdmin::JobEligiblesByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::UsersByProject` (r:1 w:1) + /// Proof: `FundAdmin::UsersByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsByUser` (r:100 w:100) + /// Proof: `FundAdmin::ProjectsByUser` (`max_values`: None, `max_size`: Some(320050), added: 322525, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PalletRoles` (r:1 w:0) + /// Proof: `RBAC::PalletRoles` (`max_values`: None, `max_size`: Some(1633), added: 4108, mode: `MaxEncodedLen`) + /// Storage: `RBAC::UsersByScope` (r:1 w:1) + /// Proof: `RBAC::UsersByScope` (`max_values`: None, `max_size`: Some(80098), added: 82573, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsInfo` (r:3 w:3) + /// Proof: `FundAdmin::DrawdownsInfo` (`max_values`: None, `max_size`: Some(90710), added: 93185, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsByProject` (r:1 w:1) + /// Proof: `FundAdmin::DrawdownsByProject` (`max_values`: None, `max_size`: Some(320034), added: 322509, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesInfo` (r:1 w:1) + /// Proof: `FundAdmin::RevenuesInfo` (`max_values`: None, `max_size`: Some(49097), added: 51572, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesByProject` (r:1 w:1) + /// Proof: `FundAdmin::RevenuesByProject` (`max_values`: None, `max_size`: Some(320034), added: 322509, mode: `MaxEncodedLen`) + /// The range of component `b` is `[1, 200]`. + /// The range of component `e` is `[1, 100]`. + /// The range of component `j` is `[1, 100]`. + /// The range of component `u` is `[1, 100]`. + fn projects_create_project(b: u32, e: u32, j: u32, u: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2637 + u * (170 ±0)` + // Estimated: `3203501 + e * (3058 ±0) + j * (3057 ±0) + u * (322525 ±0)` + // Minimum execution time: 9_790_769_000 picoseconds. + Weight::from_parts(10_107_081_000, 3203501) + // Standard Error: 1_276_572 + .saturating_add(Weight::from_parts(118_455_417, 0).saturating_mul(b.into())) + // Standard Error: 2_558_990 + .saturating_add(Weight::from_parts(81_492_563, 0).saturating_mul(u.into())) + .saturating_add(RocksDbWeight::get().reads(22_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(e.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(j.into()))) + .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(u.into()))) + .saturating_add(RocksDbWeight::get().writes(12_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(e.into()))) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(j.into()))) + .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(u.into()))) + .saturating_add(Weight::from_parts(0, 3058).saturating_mul(e.into())) + .saturating_add(Weight::from_parts(0, 3057).saturating_mul(j.into())) + .saturating_add(Weight::from_parts(0, 322525).saturating_mul(u.into())) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:1 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// The range of component `b` is `[1, 200]`. + fn projects_edit_project(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `8357` + // Estimated: `2525475` + // Minimum execution time: 133_118_000 picoseconds. + Weight::from_parts(140_642_760, 2525475) + // Standard Error: 17_072 + .saturating_add(Weight::from_parts(1_612_915, 0).saturating_mul(b.into())) + .saturating_add(RocksDbWeight::get().reads(8_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `FundAdmin::UsersInfo` (r:101 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:1) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:2 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:101 w:100) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::UsersByProject` (r:1 w:1) + /// Proof: `FundAdmin::UsersByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsByUser` (r:100 w:100) + /// Proof: `FundAdmin::ProjectsByUser` (`max_values`: None, `max_size`: Some(320050), added: 322525, mode: `MaxEncodedLen`) + /// Storage: `RBAC::UsersByScope` (r:2 w:1) + /// Proof: `RBAC::UsersByScope` (`max_values`: None, `max_size`: Some(80098), added: 82573, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresByProject` (r:1 w:1) + /// Proof: `FundAdmin::ExpendituresByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsByProject` (r:1 w:1) + /// Proof: `FundAdmin::DrawdownsByProject` (`max_values`: None, `max_size`: Some(320034), added: 322509, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByDrawdown` (r:3 w:3) + /// Proof: `FundAdmin::TransactionsByDrawdown` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::JobEligiblesByProject` (r:1 w:1) + /// Proof: `FundAdmin::JobEligiblesByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesByProject` (r:1 w:1) + /// Proof: `FundAdmin::RevenuesByProject` (`max_values`: None, `max_size`: Some(320034), added: 322509, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByRevenue` (r:1 w:1) + /// Proof: `FundAdmin::TransactionsByRevenue` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsInfo` (r:0 w:3) + /// Proof: `FundAdmin::DrawdownsInfo` (`max_values`: None, `max_size`: Some(90710), added: 93185, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresInfo` (r:0 w:100) + /// Proof: `FundAdmin::ExpendituresInfo` (`max_values`: None, `max_size`: Some(583), added: 3058, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::JobEligiblesInfo` (r:0 w:100) + /// Proof: `FundAdmin::JobEligiblesInfo` (`max_values`: None, `max_size`: Some(582), added: 3057, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesInfo` (r:0 w:1) + /// Proof: `FundAdmin::RevenuesInfo` (`max_values`: None, `max_size`: Some(49097), added: 51572, mode: `MaxEncodedLen`) + fn projects_delete_project() -> Weight { + // Proof Size summary in bytes: + // Measured: `61657` + // Estimated: `32253490` + // Minimum execution time: 6_707_751_000 picoseconds. + Weight::from_parts(7_116_813_000, 32253490) + .saturating_add(RocksDbWeight::get().reads(319_u64)) + .saturating_add(RocksDbWeight::get().writes(416_u64)) + } + /// Storage: `FundAdmin::UsersInfo` (r:101 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:1 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:101 w:100) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::UsersByProject` (r:1 w:1) + /// Proof: `FundAdmin::UsersByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsByUser` (r:100 w:100) + /// Proof: `FundAdmin::ProjectsByUser` (`max_values`: None, `max_size`: Some(320050), added: 322525, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PalletRoles` (r:1 w:0) + /// Proof: `RBAC::PalletRoles` (`max_values`: None, `max_size`: Some(1633), added: 4108, mode: `MaxEncodedLen`) + /// Storage: `RBAC::UsersByScope` (r:1 w:1) + /// Proof: `RBAC::UsersByScope` (`max_values`: None, `max_size`: Some(80098), added: 82573, mode: `MaxEncodedLen`) + /// The range of component `a` is `[1, 100]`. + fn projects_assign_user(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `20420 + a * (226 ±0)` + // Estimated: `3203501 + a * (322525 ±0)` + // Minimum execution time: 197_024_000 picoseconds. + Weight::from_parts(116_804_696, 3203501) + // Standard Error: 177_570 + .saturating_add(Weight::from_parts(66_856_513, 0).saturating_mul(a.into())) + .saturating_add(RocksDbWeight::get().reads(10_u64)) + .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(a.into()))) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_parts(0, 322525).saturating_mul(a.into())) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:2 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:0) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresInfo` (r:100 w:100) + /// Proof: `FundAdmin::ExpendituresInfo` (`max_values`: None, `max_size`: Some(583), added: 3058, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresByProject` (r:1 w:1) + /// Proof: `FundAdmin::ExpendituresByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::JobEligiblesInfo` (r:100 w:100) + /// Proof: `FundAdmin::JobEligiblesInfo` (`max_values`: None, `max_size`: Some(582), added: 3057, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::JobEligiblesByProject` (r:1 w:1) + /// Proof: `FundAdmin::JobEligiblesByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// The range of component `e` is `[1, 100]`. + /// The range of component `j` is `[1, 100]`. + fn expenditures_and_job_eligibles(e: u32, j: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `18858 + e * (17 ±0) + j * (20 ±0)` + // Estimated: `3203501 + e * (3058 ±0) + j * (3057 ±0)` + // Minimum execution time: 2_179_973_000 picoseconds. + Weight::from_parts(175_581_406, 3203501) + // Standard Error: 96_960 + .saturating_add(Weight::from_parts(20_560_587, 0).saturating_mul(e.into())) + // Standard Error: 96_960 + .saturating_add(Weight::from_parts(21_411_639, 0).saturating_mul(j.into())) + .saturating_add(RocksDbWeight::get().reads(11_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(e.into()))) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(j.into()))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(e.into()))) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(j.into()))) + .saturating_add(Weight::from_parts(0, 3058).saturating_mul(e.into())) + .saturating_add(Weight::from_parts(0, 3057).saturating_mul(j.into())) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:2 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsInfo` (r:1 w:1) + /// Proof: `FundAdmin::DrawdownsInfo` (`max_values`: None, `max_size`: Some(90710), added: 93185, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresInfo` (r:1 w:0) + /// Proof: `FundAdmin::ExpendituresInfo` (`max_values`: None, `max_size`: Some(583), added: 3058, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsInfo` (r:100 w:100) + /// Proof: `FundAdmin::TransactionsInfo` (`max_values`: None, `max_size`: Some(20967), added: 23442, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByDrawdown` (r:1 w:1) + /// Proof: `FundAdmin::TransactionsByDrawdown` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// The range of component `a` is `[1, 100]`. + fn submit_drawdown(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `9282` + // Estimated: `2525475 + a * (23442 ±0)` + // Minimum execution time: 502_651_000 picoseconds. + Weight::from_parts(238_227_832, 2525475) + // Standard Error: 256_323 + .saturating_add(Weight::from_parts(235_581_283, 0).saturating_mul(a.into())) + .saturating_add(RocksDbWeight::get().reads(12_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_parts(0, 23442).saturating_mul(a.into())) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:3 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsInfo` (r:2 w:2) + /// Proof: `FundAdmin::DrawdownsInfo` (`max_values`: None, `max_size`: Some(90710), added: 93185, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresInfo` (r:1 w:0) + /// Proof: `FundAdmin::ExpendituresInfo` (`max_values`: None, `max_size`: Some(583), added: 3058, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsInfo` (r:200 w:200) + /// Proof: `FundAdmin::TransactionsInfo` (`max_values`: None, `max_size`: Some(20967), added: 23442, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByDrawdown` (r:1 w:1) + /// Proof: `FundAdmin::TransactionsByDrawdown` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsByProject` (r:1 w:1) + /// Proof: `FundAdmin::DrawdownsByProject` (`max_values`: None, `max_size`: Some(320034), added: 322509, mode: `MaxEncodedLen`) + /// The range of component `a` is `[1, 100]`. + fn approve_drawdown(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2070176` + // Estimated: `2525475 + a * (23442 ±0)` + // Minimum execution time: 19_643_024_000 picoseconds. + Weight::from_parts(19_444_937_640, 2525475) + // Standard Error: 628_560 + .saturating_add(Weight::from_parts(304_456_545, 0).saturating_mul(a.into())) + .saturating_add(RocksDbWeight::get().reads(115_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(RocksDbWeight::get().writes(105_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_parts(0, 23442).saturating_mul(a.into())) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:1 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsInfo` (r:1 w:1) + /// Proof: `FundAdmin::DrawdownsInfo` (`max_values`: None, `max_size`: Some(90710), added: 93185, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByDrawdown` (r:1 w:0) + /// Proof: `FundAdmin::TransactionsByDrawdown` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsInfo` (r:100 w:100) + /// Proof: `FundAdmin::TransactionsInfo` (`max_values`: None, `max_size`: Some(20967), added: 23442, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + fn reject_drawdown() -> Weight { + // Proof Size summary in bytes: + // Measured: `2069261` + // Estimated: `2525475` + // Minimum execution time: 13_787_694_000 picoseconds. + Weight::from_parts(13_914_317_000, 2525475) + .saturating_add(RocksDbWeight::get().reads(110_u64)) + .saturating_add(RocksDbWeight::get().writes(102_u64)) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:1 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsInfo` (r:1 w:1) + /// Proof: `FundAdmin::DrawdownsInfo` (`max_values`: None, `max_size`: Some(90710), added: 93185, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// The range of component `d` is `[1, 100]`. + fn up_bulkupload(d: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `8500` + // Estimated: `2525475` + // Minimum execution time: 147_995_000 picoseconds. + Weight::from_parts(163_935_160, 2525475) + // Standard Error: 15_510 + .saturating_add(Weight::from_parts(1_880_851, 0).saturating_mul(d.into())) + .saturating_add(RocksDbWeight::get().reads(9_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + } + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:1 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// The range of component `a` is `[1, 100]`. + fn inflation_rate(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `8288` + // Estimated: `2525475` + // Minimum execution time: 123_969_000 picoseconds. + Weight::from_parts(126_316_183, 2525475) + // Standard Error: 24_264 + .saturating_add(Weight::from_parts(12_619_465, 0).saturating_mul(a.into())) + .saturating_add(RocksDbWeight::get().reads(7_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:2 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesInfo` (r:1 w:1) + /// Proof: `FundAdmin::RevenuesInfo` (`max_values`: None, `max_size`: Some(49097), added: 51572, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenueTransactionsInfo` (r:100 w:100) + /// Proof: `FundAdmin::RevenueTransactionsInfo` (`max_values`: None, `max_size`: Some(20967), added: 23442, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByRevenue` (r:1 w:1) + /// Proof: `FundAdmin::TransactionsByRevenue` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// The range of component `a` is `[1, 100]`. + fn submit_revenue(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `8449` + // Estimated: `2525475 + a * (23442 ±0)` + // Minimum execution time: 490_569_000 picoseconds. + Weight::from_parts(236_757_131, 2525475) + // Standard Error: 345_267 + .saturating_add(Weight::from_parts(234_868_590, 0).saturating_mul(a.into())) + .saturating_add(RocksDbWeight::get().reads(11_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_parts(0, 23442).saturating_mul(a.into())) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:1 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesInfo` (r:2 w:2) + /// Proof: `FundAdmin::RevenuesInfo` (`max_values`: None, `max_size`: Some(49097), added: 51572, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByRevenue` (r:1 w:0) + /// Proof: `FundAdmin::TransactionsByRevenue` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenueTransactionsInfo` (r:100 w:100) + /// Proof: `FundAdmin::RevenueTransactionsInfo` (`max_values`: None, `max_size`: Some(20967), added: 23442, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesByProject` (r:1 w:1) + /// Proof: `FundAdmin::RevenuesByProject` (`max_values`: None, `max_size`: Some(320034), added: 322509, mode: `MaxEncodedLen`) + fn approve_revenue() -> Weight { + // Proof Size summary in bytes: + // Measured: `2069236` + // Estimated: `2525475` + // Minimum execution time: 12_293_638_000 picoseconds. + Weight::from_parts(12_507_563_000, 2525475) + .saturating_add(RocksDbWeight::get().reads(112_u64)) + .saturating_add(RocksDbWeight::get().writes(104_u64)) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:1 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesInfo` (r:1 w:1) + /// Proof: `FundAdmin::RevenuesInfo` (`max_values`: None, `max_size`: Some(49097), added: 51572, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByRevenue` (r:1 w:0) + /// Proof: `FundAdmin::TransactionsByRevenue` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenueTransactionsInfo` (r:100 w:100) + /// Proof: `FundAdmin::RevenueTransactionsInfo` (`max_values`: None, `max_size`: Some(20967), added: 23442, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + fn reject_revenue() -> Weight { + // Proof Size summary in bytes: + // Measured: `2069144` + // Estimated: `2525475` + // Minimum execution time: 18_412_764_000 picoseconds. + Weight::from_parts(18_591_490_000, 2525475) + .saturating_add(RocksDbWeight::get().reads(110_u64)) + .saturating_add(RocksDbWeight::get().writes(102_u64)) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:1 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:0) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsInfo` (r:1 w:1) + /// Proof: `FundAdmin::DrawdownsInfo` (`max_values`: None, `max_size`: Some(90710), added: 93185, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByDrawdown` (r:1 w:0) + /// Proof: `FundAdmin::TransactionsByDrawdown` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsInfo` (r:100 w:100) + /// Proof: `FundAdmin::TransactionsInfo` (`max_values`: None, `max_size`: Some(20967), added: 23442, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// The range of component `a` is `[1, 100]`. + fn bank_confirming_documents(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2065064` + // Estimated: `2525475` + // Minimum execution time: 7_553_050_000 picoseconds. + Weight::from_parts(7_752_950_488, 2525475) + // Standard Error: 226_141 + .saturating_add(Weight::from_parts(1_532_143, 0).saturating_mul(a.into())) + .saturating_add(RocksDbWeight::get().reads(110_u64)) + .saturating_add(RocksDbWeight::get().writes(101_u64)) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:1 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsInfo` (r:1 w:1) + /// Proof: `FundAdmin::DrawdownsInfo` (`max_values`: None, `max_size`: Some(90710), added: 93185, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByDrawdown` (r:1 w:1) + /// Proof: `FundAdmin::TransactionsByDrawdown` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsInfo` (r:0 w:100) + /// Proof: `FundAdmin::TransactionsInfo` (`max_values`: None, `max_size`: Some(20967), added: 23442, mode: `MaxEncodedLen`) + fn reset_drawdown() -> Weight { + // Proof Size summary in bytes: + // Measured: `11813` + // Estimated: `2525475` + // Minimum execution time: 356_822_000 picoseconds. + Weight::from_parts(368_486_000, 2525475) + .saturating_add(RocksDbWeight::get().reads(10_u64)) + .saturating_add(RocksDbWeight::get().writes(103_u64)) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:2 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:0) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsInfo` (r:1 w:1) + /// Proof: `FundAdmin::DrawdownsInfo` (`max_values`: None, `max_size`: Some(90710), added: 93185, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsByProject` (r:1 w:0) + /// Proof: `FundAdmin::DrawdownsByProject` (`max_values`: None, `max_size`: Some(320034), added: 322509, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByDrawdown` (r:1 w:1) + /// Proof: `FundAdmin::TransactionsByDrawdown` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresInfo` (r:1 w:0) + /// Proof: `FundAdmin::ExpendituresInfo` (`max_values`: None, `max_size`: Some(583), added: 3058, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsInfo` (r:200 w:100) + /// Proof: `FundAdmin::TransactionsInfo` (`max_values`: None, `max_size`: Some(20967), added: 23442, mode: `MaxEncodedLen`) + /// The range of component `a` is `[1, 100]`. + fn recovery_drawdown(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2070245` + // Estimated: `2525475 + a * (23442 ±0)` + // Minimum execution time: 12_614_492_000 picoseconds. + Weight::from_parts(12_466_050_756, 2525475) + // Standard Error: 392_127 + .saturating_add(Weight::from_parts(303_815_694, 0).saturating_mul(a.into())) + .saturating_add(RocksDbWeight::get().reads(113_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_parts(0, 23442).saturating_mul(a.into())) + } + /// Storage: `FundAdmin::UsersInfo` (r:1 w:0) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:1 w:0) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:0) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:2 w:0) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:1 w:0) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:1 w:0) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:0) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesInfo` (r:1 w:1) + /// Proof: `FundAdmin::RevenuesInfo` (`max_values`: None, `max_size`: Some(49097), added: 51572, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesByProject` (r:1 w:0) + /// Proof: `FundAdmin::RevenuesByProject` (`max_values`: None, `max_size`: Some(320034), added: 322509, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::TransactionsByRevenue` (r:1 w:1) + /// Proof: `FundAdmin::TransactionsByRevenue` (`max_values`: None, `max_size`: Some(32066), added: 34541, mode: `MaxEncodedLen`) + /// Storage: `Timestamp::Now` (r:1 w:0) + /// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenueTransactionsInfo` (r:200 w:100) + /// Proof: `FundAdmin::RevenueTransactionsInfo` (`max_values`: None, `max_size`: Some(20967), added: 23442, mode: `MaxEncodedLen`) + /// The range of component `a` is `[1, 100]`. + fn recovery_revenue(a: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `2069441` + // Estimated: `2525475 + a * (23442 ±0)` + // Minimum execution time: 12_740_348_000 picoseconds. + Weight::from_parts(12_498_173_075, 2525475) + // Standard Error: 392_799 + .saturating_add(Weight::from_parts(298_353_500, 0).saturating_mul(a.into())) + .saturating_add(RocksDbWeight::get().reads(112_u64)) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(a.into()))) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(a.into()))) + .saturating_add(Weight::from_parts(0, 23442).saturating_mul(a.into())) + } + /// Storage: `FundAdmin::UsersInfo` (r:101 w:101) + /// Proof: `FundAdmin::UsersInfo` (`max_values`: None, `max_size`: Some(20766), added: 23241, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsInfo` (r:1 w:1) + /// Proof: `FundAdmin::ProjectsInfo` (`max_values`: None, `max_size`: Some(2522010), added: 2524485, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::UsersByProject` (r:1 w:1) + /// Proof: `FundAdmin::UsersByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ProjectsByUser` (r:100 w:100) + /// Proof: `FundAdmin::ProjectsByUser` (`max_values`: None, `max_size`: Some(320050), added: 322525, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresInfo` (r:100 w:100) + /// Proof: `FundAdmin::ExpendituresInfo` (`max_values`: None, `max_size`: Some(583), added: 3058, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::ExpendituresByProject` (r:1 w:1) + /// Proof: `FundAdmin::ExpendituresByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsInfo` (r:3 w:3) + /// Proof: `FundAdmin::DrawdownsInfo` (`max_values`: None, `max_size`: Some(90710), added: 93185, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::DrawdownsByProject` (r:1 w:1) + /// Proof: `FundAdmin::DrawdownsByProject` (`max_values`: None, `max_size`: Some(320034), added: 322509, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::JobEligiblesInfo` (r:100 w:100) + /// Proof: `FundAdmin::JobEligiblesInfo` (`max_values`: None, `max_size`: Some(582), added: 3057, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::JobEligiblesByProject` (r:1 w:1) + /// Proof: `FundAdmin::JobEligiblesByProject` (`max_values`: None, `max_size`: Some(3200036), added: 3202511, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesInfo` (r:1 w:1) + /// Proof: `FundAdmin::RevenuesInfo` (`max_values`: None, `max_size`: Some(49097), added: 51572, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::RevenuesByProject` (r:1 w:1) + /// Proof: `FundAdmin::RevenuesByProject` (`max_values`: None, `max_size`: Some(320034), added: 322509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Scopes` (r:1 w:1) + /// Proof: `RBAC::Scopes` (`max_values`: None, `max_size`: Some(32034), added: 34509, mode: `MaxEncodedLen`) + /// Storage: `RBAC::UsersByScope` (r:4 w:2) + /// Proof: `RBAC::UsersByScope` (`max_values`: None, `max_size`: Some(80098), added: 82573, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PalletRoles` (r:2 w:1) + /// Proof: `RBAC::PalletRoles` (`max_values`: None, `max_size`: Some(1633), added: 4108, mode: `MaxEncodedLen`) + /// Storage: `RBAC::PermissionsByRole` (r:5 w:5) + /// Proof: `RBAC::PermissionsByRole` (`max_values`: None, `max_size`: Some(3266), added: 5741, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Permissions` (r:25 w:25) + /// Proof: `RBAC::Permissions` (`max_values`: None, `max_size`: Some(115), added: 2590, mode: `MaxEncodedLen`) + /// Storage: `FundAdmin::GlobalScope` (r:0 w:1) + /// Proof: `FundAdmin::GlobalScope` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`) + /// Storage: `RBAC::Roles` (r:0 w:5) + /// Proof: `RBAC::Roles` (`max_values`: None, `max_size`: Some(83), added: 2558, mode: `MaxEncodedLen`) + /// Storage: `RBAC::RolesByUser` (r:0 w:101) + /// Proof: `RBAC::RolesByUser` (`max_values`: None, `max_size`: Some(433), added: 2908, mode: `MaxEncodedLen`) + fn kill_storage() -> Weight { + // Proof Size summary in bytes: + // Measured: `41100` + // Estimated: `32253490` + // Minimum execution time: 1_245_208_000 picoseconds. + Weight::from_parts(1_282_585_000, 32253490) + .saturating_add(RocksDbWeight::get().reads(448_u64)) + .saturating_add(RocksDbWeight::get().writes(552_u64)) + } +}