diff --git a/justfile b/justfile index c5db058..3bd777f 100644 --- a/justfile +++ b/justfile @@ -35,7 +35,7 @@ gen-spec-file env: gen-base-spec run-benchmarks: cargo build -r --features runtime-benchmarks - # ./target/release/torus-node benchmark pallet --pallet pallet_torus0 --chain dev --extrinsic "*" --steps 50 --repeat 20 --output pallets/torus0/src/weights.rs --template=./.maintain/frame-weight-template.hbs + ./target/release/torus-node benchmark pallet --pallet pallet_torus0 --chain dev --extrinsic "*" --steps 50 --repeat 20 --output pallets/torus0/src/weights.rs --template=./.maintain/frame-weight-template.hbs ./target/release/torus-node benchmark pallet --pallet pallet_governance --chain dev --extrinsic "*" --steps 50 --repeat 20 --output pallets/governance/src/weights.rs --template=./.maintain/frame-weight-template.hbs ./target/release/torus-node benchmark pallet --pallet pallet_emission0 --chain dev --extrinsic "*" --steps 50 --repeat 20 --output pallets/emission0/src/weights.rs --template=./.maintain/frame-weight-template.hbs diff --git a/pallets/emission0/Cargo.toml b/pallets/emission0/Cargo.toml index 10749aa..ab96192 100644 --- a/pallets/emission0/Cargo.toml +++ b/pallets/emission0/Cargo.toml @@ -19,6 +19,7 @@ std = [ runtime-benchmarks = [ "polkadot-sdk/runtime-benchmarks", "pallet-torus0-api/runtime-benchmarks", + "pallet-governance-api/runtime-benchmarks", ] try-runtime = ["polkadot-sdk/try-runtime"] diff --git a/pallets/emission0/src/weights.rs b/pallets/emission0/src/weights.rs index c5d7741..ad60a2d 100644 --- a/pallets/emission0/src/weights.rs +++ b/pallets/emission0/src/weights.rs @@ -4,7 +4,7 @@ //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 43.0.0 //! DATE: 2025-01-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `MacBook-Pro-de-Joao.local`, CPU: `` +//! HOSTNAME: `Luizs-MacBook-Pro.local`, CPU: `` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: @@ -64,8 +64,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `339` // Estimated: `7638` - // Minimum execution time: 33_000_000 picoseconds. - Weight::from_parts(34_000_000, 7638) + // Minimum execution time: 24_000_000 picoseconds. + Weight::from_parts(26_000_000, 7638) .saturating_add(T::DbWeight::get().reads(8_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -77,8 +77,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `168` // Estimated: `7638` - // Minimum execution time: 17_000_000 picoseconds. - Weight::from_parts(18_000_000, 7638) + // Minimum execution time: 12_000_000 picoseconds. + Weight::from_parts(12_000_000, 7638) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -88,8 +88,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `199` // Estimated: `3529` - // Minimum execution time: 10_000_000 picoseconds. - Weight::from_parts(11_000_000, 3529) + // Minimum execution time: 7_000_000 picoseconds. + Weight::from_parts(8_000_000, 3529) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -115,8 +115,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `339` // Estimated: `7638` - // Minimum execution time: 33_000_000 picoseconds. - Weight::from_parts(34_000_000, 7638) + // Minimum execution time: 24_000_000 picoseconds. + Weight::from_parts(26_000_000, 7638) .saturating_add(RocksDbWeight::get().reads(8_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -128,8 +128,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `168` // Estimated: `7638` - // Minimum execution time: 17_000_000 picoseconds. - Weight::from_parts(18_000_000, 7638) + // Minimum execution time: 12_000_000 picoseconds. + Weight::from_parts(12_000_000, 7638) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -139,8 +139,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `199` // Estimated: `3529` - // Minimum execution time: 10_000_000 picoseconds. - Weight::from_parts(11_000_000, 3529) + // Minimum execution time: 7_000_000 picoseconds. + Weight::from_parts(8_000_000, 3529) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } diff --git a/pallets/governance/Cargo.toml b/pallets/governance/Cargo.toml index 05560c3..038a041 100644 --- a/pallets/governance/Cargo.toml +++ b/pallets/governance/Cargo.toml @@ -22,6 +22,7 @@ runtime-benchmarks = [ "pallet-emission0/runtime-benchmarks", "pallet-torus0-api/runtime-benchmarks", + "pallet-governance-api/runtime-benchmarks", ] try-runtime = [ "polkadot-sdk/try-runtime", diff --git a/pallets/governance/api/src/lib.rs b/pallets/governance/api/src/lib.rs index 9d60155..64a706d 100644 --- a/pallets/governance/api/src/lib.rs +++ b/pallets/governance/api/src/lib.rs @@ -11,5 +11,11 @@ pub trait GovernanceApi { fn ensure_allocator(key: &AccountId) -> DispatchResult; + #[doc(hidden)] + #[cfg(feature = "runtime-benchmarks")] fn set_allocator(key: &AccountId); + + #[doc(hidden)] + #[cfg(feature = "runtime-benchmarks")] + fn set_whitelisted(key: &AccountId); } diff --git a/pallets/governance/src/lib.rs b/pallets/governance/src/lib.rs index d1240a6..4a70814 100644 --- a/pallets/governance/src/lib.rs +++ b/pallets/governance/src/lib.rs @@ -464,7 +464,13 @@ impl pallet_governance_api::GovernanceApi for Pallet crate::roles::ensure_allocator::(key) } + #[cfg(feature = "runtime-benchmarks")] fn set_allocator(key: &T::AccountId) { crate::Allocators::::insert(key, ()); } + + #[cfg(feature = "runtime-benchmarks")] + fn set_whitelisted(key: &T::AccountId) { + crate::Whitelist::::insert(key, ()) + } } diff --git a/pallets/governance/src/weights.rs b/pallets/governance/src/weights.rs index fb69986..a45546d 100644 --- a/pallets/governance/src/weights.rs +++ b/pallets/governance/src/weights.rs @@ -4,7 +4,7 @@ //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 43.0.0 //! DATE: 2025-01-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `MacBook-Pro-de-Joao.local`, CPU: `` +//! HOSTNAME: `Luizs-MacBook-Pro.local`, CPU: `` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` // Executed Command: @@ -67,8 +67,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `6` // Estimated: `3497` - // Minimum execution time: 6_000_000 picoseconds. - Weight::from_parts(7_000_000, 3497) + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 3497) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -78,8 +78,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `60` // Estimated: `3497` - // Minimum execution time: 8_000_000 picoseconds. - Weight::from_parts(9_000_000, 3497) + // Minimum execution time: 6_000_000 picoseconds. + Weight::from_parts(6_000_000, 3497) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -89,8 +89,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `6` // Estimated: `3497` - // Minimum execution time: 6_000_000 picoseconds. - Weight::from_parts(7_000_000, 3497) + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 3497) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -100,8 +100,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `62` // Estimated: `3497` - // Minimum execution time: 8_000_000 picoseconds. - Weight::from_parts(9_000_000, 3497) + // Minimum execution time: 6_000_000 picoseconds. + Weight::from_parts(6_000_000, 3497) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -115,8 +115,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `66` // Estimated: `3822` - // Minimum execution time: 17_000_000 picoseconds. - Weight::from_parts(18_000_000, 3822) + // Minimum execution time: 12_000_000 picoseconds. + Weight::from_parts(12_000_000, 3822) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -132,8 +132,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `130` // Estimated: `4314` - // Minimum execution time: 23_000_000 picoseconds. - Weight::from_parts(24_000_000, 4314) + // Minimum execution time: 16_000_000 picoseconds. + Weight::from_parts(17_000_000, 4314) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -149,8 +149,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `152` // Estimated: `3822` - // Minimum execution time: 45_000_000 picoseconds. - Weight::from_parts(46_000_000, 3822) + // Minimum execution time: 32_000_000 picoseconds. + Weight::from_parts(33_000_000, 3822) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -166,8 +166,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `241` // Estimated: `3822` - // Minimum execution time: 46_000_000 picoseconds. - Weight::from_parts(48_000_000, 3822) + // Minimum execution time: 33_000_000 picoseconds. + Weight::from_parts(34_000_000, 3822) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } @@ -179,8 +179,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `189` // Estimated: `3822` - // Minimum execution time: 18_000_000 picoseconds. - Weight::from_parts(19_000_000, 3822) + // Minimum execution time: 13_000_000 picoseconds. + Weight::from_parts(14_000_000, 3822) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -192,8 +192,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `170` // Estimated: `4314` - // Minimum execution time: 15_000_000 picoseconds. - Weight::from_parts(15_000_000, 4314) + // Minimum execution time: 10_000_000 picoseconds. + Weight::from_parts(11_000_000, 4314) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -207,8 +207,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `152` // Estimated: `3593` - // Minimum execution time: 38_000_000 picoseconds. - Weight::from_parts(40_000_000, 3593) + // Minimum execution time: 26_000_000 picoseconds. + Weight::from_parts(27_000_000, 3593) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -222,8 +222,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `152` // Estimated: `3593` - // Minimum execution time: 38_000_000 picoseconds. - Weight::from_parts(39_000_000, 3593) + // Minimum execution time: 26_000_000 picoseconds. + Weight::from_parts(27_000_000, 3593) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -237,8 +237,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `152` // Estimated: `3593` - // Minimum execution time: 38_000_000 picoseconds. - Weight::from_parts(39_000_000, 3593) + // Minimum execution time: 26_000_000 picoseconds. + Weight::from_parts(27_000_000, 3593) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -254,8 +254,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `316` // Estimated: `6100` - // Minimum execution time: 31_000_000 picoseconds. - Weight::from_parts(33_000_000, 6100) + // Minimum execution time: 23_000_000 picoseconds. + Weight::from_parts(23_000_000, 6100) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -265,8 +265,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `216` // Estimated: `3464` - // Minimum execution time: 15_000_000 picoseconds. - Weight::from_parts(15_000_000, 3464) + // Minimum execution time: 10_000_000 picoseconds. + Weight::from_parts(11_000_000, 3464) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -276,8 +276,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `6` // Estimated: `1484` - // Minimum execution time: 5_000_000 picoseconds. - Weight::from_parts(5_000_000, 1484) + // Minimum execution time: 3_000_000 picoseconds. + Weight::from_parts(4_000_000, 1484) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -287,8 +287,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `6` // Estimated: `1484` - // Minimum execution time: 5_000_000 picoseconds. - Weight::from_parts(5_000_000, 1484) + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(4_000_000, 1484) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -302,8 +302,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `152` // Estimated: `3593` - // Minimum execution time: 37_000_000 picoseconds. - Weight::from_parts(38_000_000, 3593) + // Minimum execution time: 26_000_000 picoseconds. + Weight::from_parts(27_000_000, 3593) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -317,8 +317,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `6` // Estimated: `3497` - // Minimum execution time: 6_000_000 picoseconds. - Weight::from_parts(7_000_000, 3497) + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 3497) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -328,8 +328,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `60` // Estimated: `3497` - // Minimum execution time: 8_000_000 picoseconds. - Weight::from_parts(9_000_000, 3497) + // Minimum execution time: 6_000_000 picoseconds. + Weight::from_parts(6_000_000, 3497) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -339,8 +339,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `6` // Estimated: `3497` - // Minimum execution time: 6_000_000 picoseconds. - Weight::from_parts(7_000_000, 3497) + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(5_000_000, 3497) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -350,8 +350,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `62` // Estimated: `3497` - // Minimum execution time: 8_000_000 picoseconds. - Weight::from_parts(9_000_000, 3497) + // Minimum execution time: 6_000_000 picoseconds. + Weight::from_parts(6_000_000, 3497) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -365,8 +365,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `66` // Estimated: `3822` - // Minimum execution time: 17_000_000 picoseconds. - Weight::from_parts(18_000_000, 3822) + // Minimum execution time: 12_000_000 picoseconds. + Weight::from_parts(12_000_000, 3822) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -382,8 +382,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `130` // Estimated: `4314` - // Minimum execution time: 23_000_000 picoseconds. - Weight::from_parts(24_000_000, 4314) + // Minimum execution time: 16_000_000 picoseconds. + Weight::from_parts(17_000_000, 4314) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -399,8 +399,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `152` // Estimated: `3822` - // Minimum execution time: 45_000_000 picoseconds. - Weight::from_parts(46_000_000, 3822) + // Minimum execution time: 32_000_000 picoseconds. + Weight::from_parts(33_000_000, 3822) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -416,8 +416,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `241` // Estimated: `3822` - // Minimum execution time: 46_000_000 picoseconds. - Weight::from_parts(48_000_000, 3822) + // Minimum execution time: 33_000_000 picoseconds. + Weight::from_parts(34_000_000, 3822) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } @@ -429,8 +429,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `189` // Estimated: `3822` - // Minimum execution time: 18_000_000 picoseconds. - Weight::from_parts(19_000_000, 3822) + // Minimum execution time: 13_000_000 picoseconds. + Weight::from_parts(14_000_000, 3822) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -442,8 +442,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `170` // Estimated: `4314` - // Minimum execution time: 15_000_000 picoseconds. - Weight::from_parts(15_000_000, 4314) + // Minimum execution time: 10_000_000 picoseconds. + Weight::from_parts(11_000_000, 4314) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -457,8 +457,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `152` // Estimated: `3593` - // Minimum execution time: 38_000_000 picoseconds. - Weight::from_parts(40_000_000, 3593) + // Minimum execution time: 26_000_000 picoseconds. + Weight::from_parts(27_000_000, 3593) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -472,8 +472,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `152` // Estimated: `3593` - // Minimum execution time: 38_000_000 picoseconds. - Weight::from_parts(39_000_000, 3593) + // Minimum execution time: 26_000_000 picoseconds. + Weight::from_parts(27_000_000, 3593) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -487,8 +487,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `152` // Estimated: `3593` - // Minimum execution time: 38_000_000 picoseconds. - Weight::from_parts(39_000_000, 3593) + // Minimum execution time: 26_000_000 picoseconds. + Weight::from_parts(27_000_000, 3593) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -504,8 +504,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `316` // Estimated: `6100` - // Minimum execution time: 31_000_000 picoseconds. - Weight::from_parts(33_000_000, 6100) + // Minimum execution time: 23_000_000 picoseconds. + Weight::from_parts(23_000_000, 6100) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -515,8 +515,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `216` // Estimated: `3464` - // Minimum execution time: 15_000_000 picoseconds. - Weight::from_parts(15_000_000, 3464) + // Minimum execution time: 10_000_000 picoseconds. + Weight::from_parts(11_000_000, 3464) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -526,8 +526,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `6` // Estimated: `1484` - // Minimum execution time: 5_000_000 picoseconds. - Weight::from_parts(5_000_000, 1484) + // Minimum execution time: 3_000_000 picoseconds. + Weight::from_parts(4_000_000, 1484) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -537,8 +537,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `6` // Estimated: `1484` - // Minimum execution time: 5_000_000 picoseconds. - Weight::from_parts(5_000_000, 1484) + // Minimum execution time: 4_000_000 picoseconds. + Weight::from_parts(4_000_000, 1484) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -552,8 +552,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `152` // Estimated: `3593` - // Minimum execution time: 37_000_000 picoseconds. - Weight::from_parts(38_000_000, 3593) + // Minimum execution time: 26_000_000 picoseconds. + Weight::from_parts(27_000_000, 3593) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } diff --git a/pallets/torus0/Cargo.toml b/pallets/torus0/Cargo.toml index 820db7a..a36953c 100644 --- a/pallets/torus0/Cargo.toml +++ b/pallets/torus0/Cargo.toml @@ -18,6 +18,7 @@ std = [ runtime-benchmarks = [ "polkadot-sdk/runtime-benchmarks", "pallet-torus0-api/runtime-benchmarks", + "pallet-governance-api/runtime-benchmarks", ] try-runtime = ["polkadot-sdk/try-runtime", "pallet-torus0-api/try-runtime"] diff --git a/pallets/torus0/src/benchmarks.rs b/pallets/torus0/src/benchmarks.rs new file mode 100644 index 0000000..9cfe995 --- /dev/null +++ b/pallets/torus0/src/benchmarks.rs @@ -0,0 +1,77 @@ +use pallet_governance_api::GovernanceApi; +use pallet_torus0_api::Torus0Api; +use polkadot_sdk::{ + frame_benchmarking::{account, benchmarks}, + frame_system::{self, RawOrigin}, + sp_std::vec, +}; + +use crate::*; + +fn mock_agent(id: &T::AccountId) { + as Torus0Api< + T::AccountId, + <::Currency as Currency>::Balance, + <::Currency as Currency>::NegativeImbalance, + >>::force_register_agent(id, vec![], vec![], vec![]) + .expect("failed to register agent"); + + let min_allowed_stake = MinAllowedStake::::get(); + let _ = T::Currency::deposit_creating(id, min_allowed_stake); +} + +benchmarks! { + add_stake { + let module_key: T::AccountId = account("ModuleKey", 0, 2); + mock_agent::(&module_key); + + let min_allowed_stake = MinAllowedStake::::get(); + }: _(RawOrigin::Signed(module_key.clone()), module_key.clone(), min_allowed_stake) + + remove_stake { + let module_key: T::AccountId = account("ModuleKey", 0, 2); + mock_agent::(&module_key); + + let min_allowed_stake = MinAllowedStake::::get(); + stake::add_stake::(module_key.clone(), module_key.clone(), min_allowed_stake) + .expect("failed to stake"); + }: _(RawOrigin::Signed(module_key.clone()), module_key.clone(), min_allowed_stake) + + transfer_stake { + let module_key: T::AccountId = account("ModuleKey", 0, 2); + mock_agent::(&module_key); + + let module_key2: T::AccountId = account("ModuleKey2", 1, 2); + mock_agent::(&module_key2); + + let min_allowed_stake = MinAllowedStake::::get(); + stake::add_stake::(module_key.clone(), module_key.clone(), min_allowed_stake) + .expect("failed to stake"); + }: _(RawOrigin::Signed(module_key.clone()), module_key.clone(), module_key2.clone(), min_allowed_stake) + + register_agent { + let module_key: T::AccountId = account("ModuleKey", 0, 2); + ::set_whitelisted(&module_key); + + let name = vec![b'0'; MinNameLength::::get() as usize]; + let url = vec![b'0'; MinNameLength::::get() as usize]; + let metadata= vec![b'0'; T::MaxAgentMetadataLengthConstraint::get() as usize]; + + }: _(RawOrigin::Signed(module_key.clone()), module_key.clone(), name, url, metadata) + + unregister_agent { + let module_key: T::AccountId = account("ModuleKey", 0, 2); + mock_agent::(&module_key); + }: _(RawOrigin::Signed(module_key)) + + update_agent { + let module_key: T::AccountId = account("ModuleKey", 0, 2); + mock_agent::(&module_key); + + let name = vec![b'0'; MinNameLength::::get() as usize]; + let url = vec![b'0'; MinNameLength::::get() as usize]; + let metadata= vec![b'0'; T::MaxAgentMetadataLengthConstraint::get() as usize]; + + let constraints = FeeConstraints::::get(); + }: _(RawOrigin::Signed(module_key), name, url, Some(metadata), Some(constraints.min_staking_fee), Some(constraints.min_weight_control_fee)) +} diff --git a/pallets/torus0/src/lib.rs b/pallets/torus0/src/lib.rs index d9a547e..cf4f3dd 100644 --- a/pallets/torus0/src/lib.rs +++ b/pallets/torus0/src/lib.rs @@ -6,6 +6,10 @@ mod ext; pub mod fee; pub mod stake; +#[cfg(feature = "runtime-benchmarks")] +pub mod benchmarks; +pub mod weights; + use crate::agent::Agent; use crate::burn::BurnConfiguration; use crate::fee::ValidatorFeeConstraints; @@ -30,6 +34,7 @@ pub mod pallet { use frame::prelude::BlockNumberFor; use pallet_emission0_api::Emission0Api; use pallet_governance_api::GovernanceApi; + use weights::WeightInfo; use super::*; @@ -210,6 +215,8 @@ pub mod pallet { type Governance: GovernanceApi; type Emission: Emission0Api; + + type WeightInfo: WeightInfo; } #[pallet::pallet] @@ -218,7 +225,7 @@ pub mod pallet { #[pallet::call] impl Pallet { #[pallet::call_index(0)] - #[pallet::weight((Weight::zero(), DispatchClass::Normal, Pays::Yes))] + #[pallet::weight((T::WeightInfo::add_stake(), DispatchClass::Normal, Pays::Yes))] pub fn add_stake( origin: OriginFor, agent_key: AccountIdOf, @@ -229,7 +236,7 @@ pub mod pallet { } #[pallet::call_index(1)] - #[pallet::weight((Weight::zero(), DispatchClass::Normal, Pays::Yes))] + #[pallet::weight((T::WeightInfo::remove_stake(), DispatchClass::Normal, Pays::Yes))] pub fn remove_stake( origin: OriginFor, agent_key: AccountIdOf, @@ -240,7 +247,7 @@ pub mod pallet { } #[pallet::call_index(2)] - #[pallet::weight((Weight::zero(), DispatchClass::Normal, Pays::Yes))] + #[pallet::weight((T::WeightInfo::transfer_stake(), DispatchClass::Normal, Pays::Yes))] pub fn transfer_stake( origin: OriginFor, agent_key: AccountIdOf, @@ -252,7 +259,7 @@ pub mod pallet { } #[pallet::call_index(3)] - #[pallet::weight((Weight::zero(), DispatchClass::Normal, Pays::Yes))] + #[pallet::weight((T::WeightInfo::register_agent(), DispatchClass::Normal, Pays::Yes))] pub fn register_agent( origin: OriginFor, agent_key: T::AccountId, @@ -265,14 +272,14 @@ pub mod pallet { } #[pallet::call_index(4)] - #[pallet::weight((Weight::zero(), DispatchClass::Normal, Pays::Yes))] + #[pallet::weight((T::WeightInfo::unregister_agent(), DispatchClass::Normal, Pays::Yes))] pub fn unregister_agent(origin: OriginFor) -> DispatchResult { let agent_key = ensure_signed(origin)?; agent::unregister::(agent_key) } #[pallet::call_index(5)] - #[pallet::weight((Weight::zero(), DispatchClass::Normal, Pays::Yes))] + #[pallet::weight((T::WeightInfo::update_agent(), DispatchClass::Normal, Pays::Yes))] pub fn update_agent( origin: OriginFor, name: Vec, diff --git a/pallets/torus0/src/weights.rs b/pallets/torus0/src/weights.rs new file mode 100644 index 0000000..5171ec3 --- /dev/null +++ b/pallets/torus0/src/weights.rs @@ -0,0 +1,304 @@ + +//! Autogenerated weights for `pallet_torus0` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 43.0.0 +//! DATE: 2025-01-03, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `Luizs-MacBook-Pro.local`, CPU: `` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` + +// Executed Command: +// ./target/release/torus-node +// benchmark +// pallet +// --pallet +// pallet_torus0 +// --chain +// dev +// --extrinsic +// * +// --steps +// 50 +// --repeat +// 20 +// --output +// pallets/torus0/src/weights.rs +// --template=./.maintain/frame-weight-template.hbs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use polkadot_sdk::{ + frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}, + *, +}; +use core::marker::PhantomData; + +/// Weight functions needed for `pallet_torus0`. +pub trait WeightInfo { + fn add_stake() -> Weight; + fn remove_stake() -> Weight; + fn transfer_stake() -> Weight; + fn register_agent() -> Weight; + fn unregister_agent() -> Weight; + fn update_agent() -> Weight; +} + +/// Weights for `pallet_torus0` using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: `Torus0::MinAllowedStake` (r:1 w:0) + /// Proof: `Torus0::MinAllowedStake` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Torus0::Agents` (r:1 w:0) + /// Proof: `Torus0::Agents` (`max_values`: None, `max_size`: Some(849), added: 3324, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Torus0::StakedBy` (r:1 w:1) + /// Proof: `Torus0::StakedBy` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `Torus0::StakingTo` (r:1 w:1) + /// Proof: `Torus0::StakingTo` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `Torus0::TotalStake` (r:1 w:1) + /// Proof: `Torus0::TotalStake` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + fn add_stake() -> Weight { + // Proof Size summary in bytes: + // Measured: `234` + // Estimated: `4314` + // Minimum execution time: 33_000_000 picoseconds. + Weight::from_parts(34_000_000, 4314) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: `Torus0::MinAllowedStake` (r:1 w:0) + /// Proof: `Torus0::MinAllowedStake` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Torus0::Agents` (r:1 w:0) + /// Proof: `Torus0::Agents` (`max_values`: None, `max_size`: Some(849), added: 3324, mode: `MaxEncodedLen`) + /// Storage: `Torus0::StakingTo` (r:1 w:1) + /// Proof: `Torus0::StakingTo` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `Torus0::StakedBy` (r:1 w:1) + /// Proof: `Torus0::StakedBy` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `Torus0::TotalStake` (r:1 w:1) + /// Proof: `Torus0::TotalStake` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn remove_stake() -> Weight { + // Proof Size summary in bytes: + // Measured: `392` + // Estimated: `4314` + // Minimum execution time: 36_000_000 picoseconds. + Weight::from_parts(37_000_000, 4314) + .saturating_add(T::DbWeight::get().reads(6_u64)) + .saturating_add(T::DbWeight::get().writes(4_u64)) + } + /// Storage: `Torus0::MinAllowedStake` (r:1 w:0) + /// Proof: `Torus0::MinAllowedStake` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Torus0::Agents` (r:2 w:0) + /// Proof: `Torus0::Agents` (`max_values`: None, `max_size`: Some(849), added: 3324, mode: `MaxEncodedLen`) + /// Storage: `Torus0::StakingTo` (r:2 w:2) + /// Proof: `Torus0::StakingTo` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `Torus0::StakedBy` (r:2 w:2) + /// Proof: `Torus0::StakedBy` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `Torus0::TotalStake` (r:1 w:1) + /// Proof: `Torus0::TotalStake` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn transfer_stake() -> Weight { + // Proof Size summary in bytes: + // Measured: `466` + // Estimated: `7638` + // Minimum execution time: 61_000_000 picoseconds. + Weight::from_parts(62_000_000, 7638) + .saturating_add(T::DbWeight::get().reads(9_u64)) + .saturating_add(T::DbWeight::get().writes(6_u64)) + } + /// Storage: `Governance::Whitelist` (r:1 w:0) + /// Proof: `Governance::Whitelist` (`max_values`: None, `max_size`: Some(32), added: 2507, mode: `MaxEncodedLen`) + /// Storage: `Torus0::Agents` (r:2 w:1) + /// Proof: `Torus0::Agents` (`max_values`: None, `max_size`: Some(849), added: 3324, mode: `MaxEncodedLen`) + /// Storage: `Torus0::MaxAllowedAgents` (r:1 w:0) + /// Proof: `Torus0::MaxAllowedAgents` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + /// Storage: `Torus0::RegistrationsThisBlock` (r:1 w:0) + /// Proof: `Torus0::RegistrationsThisBlock` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + /// Storage: `Torus0::MaxRegistrationsPerBlock` (r:1 w:0) + /// Proof: `Torus0::MaxRegistrationsPerBlock` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + /// Storage: `Torus0::BurnConfig` (r:1 w:0) + /// Proof: `Torus0::BurnConfig` (`max_values`: Some(1), `max_size`: Some(52), added: 547, mode: `MaxEncodedLen`) + /// Storage: `Torus0::RegistrationsThisInterval` (r:1 w:0) + /// Proof: `Torus0::RegistrationsThisInterval` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + /// Storage: `Torus0::MinNameLength` (r:1 w:0) + /// Proof: `Torus0::MinNameLength` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + /// Storage: `Torus0::MaxNameLength` (r:1 w:0) + /// Proof: `Torus0::MaxNameLength` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + /// Storage: `Torus0::Burn` (r:1 w:0) + /// Proof: `Torus0::Burn` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Torus0::FeeConstraints` (r:1 w:0) + /// Proof: `Torus0::FeeConstraints` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + fn register_agent() -> Weight { + // Proof Size summary in bytes: + // Measured: `68` + // Estimated: `7638` + // Minimum execution time: 24_000_000 picoseconds. + Weight::from_parts(25_000_000, 7638) + .saturating_add(T::DbWeight::get().reads(12_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `Torus0::Agents` (r:1 w:1) + /// Proof: `Torus0::Agents` (`max_values`: None, `max_size`: Some(849), added: 3324, mode: `MaxEncodedLen`) + /// Storage: `Torus0::StakingTo` (r:1 w:0) + /// Proof: `Torus0::StakingTo` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + fn unregister_agent() -> Weight { + // Proof Size summary in bytes: + // Measured: `94` + // Estimated: `4314` + // Minimum execution time: 11_000_000 picoseconds. + Weight::from_parts(12_000_000, 4314) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `Torus0::Agents` (r:1 w:1) + /// Proof: `Torus0::Agents` (`max_values`: None, `max_size`: Some(849), added: 3324, mode: `MaxEncodedLen`) + /// Storage: `Torus0::MinNameLength` (r:1 w:0) + /// Proof: `Torus0::MinNameLength` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + /// Storage: `Torus0::MaxNameLength` (r:1 w:0) + /// Proof: `Torus0::MaxNameLength` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + /// Storage: `Torus0::FeeConstraints` (r:1 w:0) + /// Proof: `Torus0::FeeConstraints` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + fn update_agent() -> Weight { + // Proof Size summary in bytes: + // Measured: `110` + // Estimated: `4314` + // Minimum execution time: 12_000_000 picoseconds. + Weight::from_parts(12_000_000, 4314) + .saturating_add(T::DbWeight::get().reads(4_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } +} + +// For backwards compatibility and tests. +impl WeightInfo for () { + /// Storage: `Torus0::MinAllowedStake` (r:1 w:0) + /// Proof: `Torus0::MinAllowedStake` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Torus0::Agents` (r:1 w:0) + /// Proof: `Torus0::Agents` (`max_values`: None, `max_size`: Some(849), added: 3324, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Torus0::StakedBy` (r:1 w:1) + /// Proof: `Torus0::StakedBy` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `Torus0::StakingTo` (r:1 w:1) + /// Proof: `Torus0::StakingTo` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `Torus0::TotalStake` (r:1 w:1) + /// Proof: `Torus0::TotalStake` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + fn add_stake() -> Weight { + // Proof Size summary in bytes: + // Measured: `234` + // Estimated: `4314` + // Minimum execution time: 33_000_000 picoseconds. + Weight::from_parts(34_000_000, 4314) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: `Torus0::MinAllowedStake` (r:1 w:0) + /// Proof: `Torus0::MinAllowedStake` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Torus0::Agents` (r:1 w:0) + /// Proof: `Torus0::Agents` (`max_values`: None, `max_size`: Some(849), added: 3324, mode: `MaxEncodedLen`) + /// Storage: `Torus0::StakingTo` (r:1 w:1) + /// Proof: `Torus0::StakingTo` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `Torus0::StakedBy` (r:1 w:1) + /// Proof: `Torus0::StakedBy` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `Torus0::TotalStake` (r:1 w:1) + /// Proof: `Torus0::TotalStake` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn remove_stake() -> Weight { + // Proof Size summary in bytes: + // Measured: `392` + // Estimated: `4314` + // Minimum execution time: 36_000_000 picoseconds. + Weight::from_parts(37_000_000, 4314) + .saturating_add(RocksDbWeight::get().reads(6_u64)) + .saturating_add(RocksDbWeight::get().writes(4_u64)) + } + /// Storage: `Torus0::MinAllowedStake` (r:1 w:0) + /// Proof: `Torus0::MinAllowedStake` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Torus0::Agents` (r:2 w:0) + /// Proof: `Torus0::Agents` (`max_values`: None, `max_size`: Some(849), added: 3324, mode: `MaxEncodedLen`) + /// Storage: `Torus0::StakingTo` (r:2 w:2) + /// Proof: `Torus0::StakingTo` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `Torus0::StakedBy` (r:2 w:2) + /// Proof: `Torus0::StakedBy` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + /// Storage: `Torus0::TotalStake` (r:1 w:1) + /// Proof: `Torus0::TotalStake` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + fn transfer_stake() -> Weight { + // Proof Size summary in bytes: + // Measured: `466` + // Estimated: `7638` + // Minimum execution time: 61_000_000 picoseconds. + Weight::from_parts(62_000_000, 7638) + .saturating_add(RocksDbWeight::get().reads(9_u64)) + .saturating_add(RocksDbWeight::get().writes(6_u64)) + } + /// Storage: `Governance::Whitelist` (r:1 w:0) + /// Proof: `Governance::Whitelist` (`max_values`: None, `max_size`: Some(32), added: 2507, mode: `MaxEncodedLen`) + /// Storage: `Torus0::Agents` (r:2 w:1) + /// Proof: `Torus0::Agents` (`max_values`: None, `max_size`: Some(849), added: 3324, mode: `MaxEncodedLen`) + /// Storage: `Torus0::MaxAllowedAgents` (r:1 w:0) + /// Proof: `Torus0::MaxAllowedAgents` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + /// Storage: `Torus0::RegistrationsThisBlock` (r:1 w:0) + /// Proof: `Torus0::RegistrationsThisBlock` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + /// Storage: `Torus0::MaxRegistrationsPerBlock` (r:1 w:0) + /// Proof: `Torus0::MaxRegistrationsPerBlock` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + /// Storage: `Torus0::BurnConfig` (r:1 w:0) + /// Proof: `Torus0::BurnConfig` (`max_values`: Some(1), `max_size`: Some(52), added: 547, mode: `MaxEncodedLen`) + /// Storage: `Torus0::RegistrationsThisInterval` (r:1 w:0) + /// Proof: `Torus0::RegistrationsThisInterval` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + /// Storage: `Torus0::MinNameLength` (r:1 w:0) + /// Proof: `Torus0::MinNameLength` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + /// Storage: `Torus0::MaxNameLength` (r:1 w:0) + /// Proof: `Torus0::MaxNameLength` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + /// Storage: `Torus0::Burn` (r:1 w:0) + /// Proof: `Torus0::Burn` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`) + /// Storage: `Torus0::FeeConstraints` (r:1 w:0) + /// Proof: `Torus0::FeeConstraints` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + fn register_agent() -> Weight { + // Proof Size summary in bytes: + // Measured: `68` + // Estimated: `7638` + // Minimum execution time: 24_000_000 picoseconds. + Weight::from_parts(25_000_000, 7638) + .saturating_add(RocksDbWeight::get().reads(12_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `Torus0::Agents` (r:1 w:1) + /// Proof: `Torus0::Agents` (`max_values`: None, `max_size`: Some(849), added: 3324, mode: `MaxEncodedLen`) + /// Storage: `Torus0::StakingTo` (r:1 w:0) + /// Proof: `Torus0::StakingTo` (`max_values`: None, `max_size`: Some(80), added: 2555, mode: `MaxEncodedLen`) + fn unregister_agent() -> Weight { + // Proof Size summary in bytes: + // Measured: `94` + // Estimated: `4314` + // Minimum execution time: 11_000_000 picoseconds. + Weight::from_parts(12_000_000, 4314) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `Torus0::Agents` (r:1 w:1) + /// Proof: `Torus0::Agents` (`max_values`: None, `max_size`: Some(849), added: 3324, mode: `MaxEncodedLen`) + /// Storage: `Torus0::MinNameLength` (r:1 w:0) + /// Proof: `Torus0::MinNameLength` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + /// Storage: `Torus0::MaxNameLength` (r:1 w:0) + /// Proof: `Torus0::MaxNameLength` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + /// Storage: `Torus0::FeeConstraints` (r:1 w:0) + /// Proof: `Torus0::FeeConstraints` (`max_values`: Some(1), `max_size`: Some(2), added: 497, mode: `MaxEncodedLen`) + fn update_agent() -> Weight { + // Proof Size summary in bytes: + // Measured: `110` + // Estimated: `4314` + // Minimum execution time: 12_000_000 picoseconds. + Weight::from_parts(12_000_000, 4314) + .saturating_add(RocksDbWeight::get().reads(4_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } +} diff --git a/runtime/src/benchmarks.rs b/runtime/src/benchmarks.rs index bc64147..272d3ae 100644 --- a/runtime/src/benchmarks.rs +++ b/runtime/src/benchmarks.rs @@ -4,6 +4,7 @@ polkadot_sdk::frame_benchmarking::define_benchmarks!( [pallet_balances, Balances] [pallet_timestamp, Timestamp] [pallet_sudo, Sudo] + [pallet_torus0, Torus0] [pallet_emission0, Emission0] [pallet_governance, Governance] ); diff --git a/runtime/src/configs.rs b/runtime/src/configs.rs index 994b640..43e8f67 100644 --- a/runtime/src/configs.rs +++ b/runtime/src/configs.rs @@ -354,6 +354,8 @@ impl pallet_torus0::Config for Runtime { type Governance = Governance; type Emission = Emission0; + + type WeightInfo = pallet_torus0::weights::SubstrateWeight; } parameter_types! { diff --git a/test-utils/src/lib.rs b/test-utils/src/lib.rs index 227f411..8d28708 100644 --- a/test-utils/src/lib.rs +++ b/test-utils/src/lib.rs @@ -5,9 +5,7 @@ use std::{cell::RefCell, num::NonZeroU128}; use pallet_torus0::MinAllowedStake; use polkadot_sdk::{ frame_support::{ - self, - pallet_prelude::DispatchResult, - parameter_types, + self, parameter_types, traits::{Currency, Everything, Hooks}, PalletId, }, @@ -85,28 +83,6 @@ parameter_types! { pub const DefaultDividendsParticipationWeight: Percent = Percent::from_parts(40); } -impl pallet_governance_api::GovernanceApi for Test { - fn dao_treasury_address() -> AccountId { - pallet_governance::DaoTreasuryAddress::::get() - } - - fn treasury_emission_fee() -> Percent { - pallet_governance::TreasuryEmissionFee::::get() - } - - fn is_whitelisted(key: &AccountId) -> bool { - pallet_governance::Whitelist::::contains_key(key) - } - - fn ensure_allocator(key: &AccountId) -> DispatchResult { - pallet_governance::roles::ensure_allocator::(key) - } - - fn set_allocator(key: &AccountId) { - pallet_governance::Allocators::::insert(key, ()); - } -} - impl pallet_torus0::Config for Test { type DefaultMinValidatorStake = ConstU128<50_000_000_000_000_000_000_000>; @@ -160,6 +136,8 @@ impl pallet_torus0::Config for Test { type Governance = Governance; type Emission = Emission0; + + type WeightInfo = pallet_torus0::weights::SubstrateWeight; } parameter_types! {