From dc2e3416dbeca1b58bf085144004ffbd19200115 Mon Sep 17 00:00:00 2001 From: Elden Young <59600396+ytqaljn@users.noreply.github.com> Date: Mon, 25 Sep 2023 10:46:46 +0800 Subject: [PATCH] 0.7.0 weight (#233) * feat: use new weight, template save * feat: file bank weights * style: DispatchResultWithPostInfo * style: generate new weight * feat: DispatchResultWithPostInfo error * fix: chain_spec update, and fix challenge proposal * fix: build error * test: test data --- .maintain/frame-weight-template.hbs | 53 +- c-pallets/audit/src/lib.rs | 82 ++- c-pallets/audit/src/weights.rs | 160 +++-- c-pallets/audit/src/weights_demo.rs | 153 ----- c-pallets/file-bank/src/benchmarking.rs | 99 ++- c-pallets/file-bank/src/functions.rs | 16 + c-pallets/file-bank/src/lib.rs | 207 +++---- c-pallets/file-bank/src/weights.rs | 580 ++++++++++++------ c-pallets/file-bank/src/weights_demo.rs | 442 ------------- c-pallets/oss/src/weights_demo.rs | 126 ---- c-pallets/sminer/src/constants.rs | 2 +- c-pallets/sminer/src/lib.rs | 12 +- c-pallets/sminer/src/weights.rs | 314 ++++------ c-pallets/sminer/src/weights_demo.rs | 203 ------ c-pallets/storage-handler/src/weights.rs | 133 ++-- c-pallets/storage-handler/src/weights_demo.rs | 124 ---- node/src/chain_spec.rs | 20 +- runtime/src/lib.rs | 2 +- 18 files changed, 957 insertions(+), 1771 deletions(-) delete mode 100644 c-pallets/audit/src/weights_demo.rs delete mode 100644 c-pallets/file-bank/src/weights_demo.rs delete mode 100644 c-pallets/oss/src/weights_demo.rs delete mode 100644 c-pallets/sminer/src/weights_demo.rs delete mode 100644 c-pallets/storage-handler/src/weights_demo.rs diff --git a/.maintain/frame-weight-template.hbs b/.maintain/frame-weight-template.hbs index 9ee039fa..9c9e2978 100644 --- a/.maintain/frame-weight-template.hbs +++ b/.maintain/frame-weight-template.hbs @@ -1,24 +1,9 @@ -// This file is part of Substrate. - -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - +{{header}} //! 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}}` +//! HOSTNAME: `{{hostname}}`, CPU: `{{cpuname}}` //! EXECUTION: {{cmd.execution}}, WASM-EXECUTION: {{cmd.wasm_execution}}, CHAIN: {{cmd.chain}}, DB CACHE: {{cmd.db_cache}} // Executed Command: @@ -55,27 +40,31 @@ impl WeightInfo for SubstrateWeight { {{#each benchmark.comments as |comment|}} // {{comment}} {{/each}} + {{#each benchmark.component_ranges as |range|}} + /// The range of component `{{range.name}}` is `[{{range.min}}, {{range.max}}]`. + {{/each}} fn {{benchmark.name~}} ( {{~#each benchmark.components as |c| ~}} {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} ) -> Weight { - ({{underscore benchmark.base_weight}} as Weight) + // Minimum execution time: {{underscore benchmark.min_execution_time}} nanoseconds. + Weight::from_ref_time({{underscore benchmark.base_weight}}) {{#each benchmark.component_weight as |cw|}} // Standard Error: {{underscore cw.error}} - .saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)) + .saturating_add(Weight::from_ref_time({{underscore cw.slope}}).saturating_mul({{cw.name}}.into())) {{/each}} {{#if (ne benchmark.base_reads "0")}} - .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}} as Weight)) + .saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}})) {{/if}} {{#each benchmark.component_reads as |cr|}} - .saturating_add(T::DbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight))) + .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}} as Weight)) + .saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}})) {{/if}} {{#each benchmark.component_writes as |cw|}} - .saturating_add(T::DbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))) + .saturating_add(T::DbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into()))) {{/each}} } {{/each}} @@ -87,28 +76,32 @@ impl WeightInfo for () { {{#each benchmark.comments as |comment|}} // {{comment}} {{/each}} + {{#each benchmark.component_ranges as |range|}} + /// The range of component `{{range.name}}` is `[{{range.min}}, {{range.max}}]`. + {{/each}} fn {{benchmark.name~}} ( {{~#each benchmark.components as |c| ~}} {{~#if (not c.is_used)}}_{{/if}}{{c.name}}: u32, {{/each~}} ) -> Weight { - ({{underscore benchmark.base_weight}} as Weight) + // Minimum execution time: {{underscore benchmark.min_execution_time}} nanoseconds. + Weight::from_ref_time({{underscore benchmark.base_weight}}) {{#each benchmark.component_weight as |cw|}} // Standard Error: {{underscore cw.error}} - .saturating_add(({{underscore cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight)) + .saturating_add(Weight::from_ref_time({{underscore cw.slope}}).saturating_mul({{cw.name}}.into())) {{/each}} {{#if (ne benchmark.base_reads "0")}} - .saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}} as Weight)) + .saturating_add(RocksDbWeight::get().reads({{benchmark.base_reads}})) {{/if}} {{#each benchmark.component_reads as |cr|}} - .saturating_add(RocksDbWeight::get().reads(({{cr.slope}} as Weight).saturating_mul({{cr.name}} as Weight))) + .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}} as Weight)) + .saturating_add(RocksDbWeight::get().writes({{benchmark.base_writes}})) {{/if}} {{#each benchmark.component_writes as |cw|}} - .saturating_add(RocksDbWeight::get().writes(({{cw.slope}} as Weight).saturating_mul({{cw.name}} as Weight))) + .saturating_add(RocksDbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into()))) {{/each}} } {{/each}} -} \ No newline at end of file +} diff --git a/c-pallets/audit/src/lib.rs b/c-pallets/audit/src/lib.rs index 9016ecbc..10384145 100644 --- a/c-pallets/audit/src/lib.rs +++ b/c-pallets/audit/src/lib.rs @@ -56,6 +56,8 @@ pub use pallet::*; #[cfg(feature = "runtime-benchmarks")] pub mod benchmarking; +pub mod weights; + use sp_runtime::{ traits::{CheckedAdd, SaturatedConversion}, RuntimeDebug, Permill, @@ -94,7 +96,6 @@ use sp_std::{ }; use cp_enclave_verify::verify_rsa; use cp_cess_common::*; -pub mod weights; pub use weights::WeightInfo; use cp_bloom_filter::BloomFilter; use cp_scheduler_credit::SchedulerCreditCounter; @@ -152,7 +153,7 @@ pub mod pallet { use super::*; // use frame_benchmarking::baseline::Config; use frame_support::{traits::Get}; - use frame_system::{ensure_signed, pallet_prelude::*}; + use frame_system::{ensure_signed, pallet_prelude::{*, OriginFor}}; ///18446744073709551615 pub const LIMIT: u64 = u64::MAX; @@ -353,6 +354,10 @@ pub mod pallet { #[pallet::getter(fn verify_reassign_count)] pub(super) type VerifyReassignCount = StorageValue<_, u8, ValueQuery>; + #[pallet::storage] + #[pallet::getter(fn exec_block)] + pub(super) type ExecBlock = StorageValue<_, BlockNumberOf, ValueQuery>; + // FOR TESTING #[pallet::storage] #[pallet::getter(fn lock)] @@ -380,6 +385,8 @@ pub mod pallet { if now > deadline { //Determine whether to trigger a challenge // if Self::trigger_challenge(now) { + let exec_block = >::get(); + if now == exec_block { log::info!("offchain worker random challenge start"); if let Err(e) = Self::offchain_work_start(now) { match e { @@ -388,6 +395,7 @@ pub mod pallet { }; } log::info!("offchain worker random challenge end"); + } // } } } @@ -418,31 +426,36 @@ pub mod pallet { .checked_mul(2).ok_or(Error::::Overflow)? .checked_div(3).ok_or(Error::::Overflow)?; let now = >::block_number(); + + let cur_block = >::get(); + + if now <= cur_block { + return Ok(()); + } if ChallengeProposal::::contains_key(&hash) { - let proposal = ChallengeProposal::::get(&hash).unwrap(); - if proposal.0 + 1 >= limit { - let cur_blcok = >::get(); - - if now > cur_blcok { - let duration = now.checked_add(&proposal.1.net_snap_shot.life).ok_or(Error::::Overflow)?; - >::put(duration); - let idle_duration = duration; - let one_hour = T::OneHours::get(); - let tee_length = T::TeeWorkerHandler::get_controller_list().len(); - let duration: u32 = (proposal.1.net_snap_shot.total_idle_space - .checked_add(proposal.1.net_snap_shot.total_service_space).ok_or(Error::::Overflow)? - .checked_div(IDLE_VERIFY_RATE).ok_or(Error::::Overflow)? - .checked_div(tee_length as u128).ok_or(Error::::Overflow)? - ) as u32; - let v_duration = idle_duration - .checked_add(&duration.saturated_into()).ok_or(Error::::Overflow)? - .checked_add(&one_hour).ok_or(Error::::Overflow)?; - >::put(v_duration); - >::put(proposal.1); - let _ = ChallengeProposal::::clear(ChallengeProposal::::count(), None); - Self::deposit_event(Event::::GenerateChallenge); - } + let mut proposal = ChallengeProposal::::get(&hash).unwrap(); + proposal.0 += 1; + if proposal.0 >= limit { + let duration = now.checked_add(&proposal.1.net_snap_shot.life).ok_or(Error::::Overflow)?; + >::put(duration); + let idle_duration = duration; + let one_hour = T::OneHours::get(); + let tee_length = T::TeeWorkerHandler::get_controller_list().len(); + let duration: u32 = (proposal.1.net_snap_shot.total_idle_space + .checked_add(proposal.1.net_snap_shot.total_service_space).ok_or(Error::::Overflow)? + .checked_div(IDLE_VERIFY_RATE).ok_or(Error::::Overflow)? + .checked_div(tee_length as u128).ok_or(Error::::Overflow)? + ) as u32; + let v_duration = idle_duration + .checked_add(&duration.saturated_into()).ok_or(Error::::Overflow)? + .checked_add(&one_hour).ok_or(Error::::Overflow)?; + >::put(v_duration); + >::put(proposal.1); + let _ = ChallengeProposal::::clear(ChallengeProposal::::count(), None); + Self::deposit_event(Event::::GenerateChallenge); + } else { + ChallengeProposal::::insert(&hash, proposal); } } else { if ChallengeProposal::::count() > count { @@ -461,7 +474,7 @@ pub mod pallet { #[pallet::call_index(1)] #[transactional] - #[pallet::weight(100_000_000)] + #[pallet::weight(::WeightInfo::submit_idle_proof())] pub fn submit_idle_proof( origin: OriginFor, idle_prove: BoundedVec, @@ -516,7 +529,7 @@ pub mod pallet { #[pallet::call_index(2)] #[transactional] - #[pallet::weight(100_000_000)] + #[pallet::weight(::WeightInfo::submit_service_proof())] pub fn submit_service_proof( origin: OriginFor, service_prove: BoundedVec, @@ -573,7 +586,7 @@ pub mod pallet { #[pallet::call_index(3)] #[transactional] - #[pallet::weight(100_000_000)] + #[pallet::weight(::WeightInfo::submit_verify_idle_result())] pub fn submit_verify_idle_result( origin: OriginFor, total_prove_hash: BoundedVec, @@ -657,7 +670,7 @@ pub mod pallet { #[pallet::call_index(4)] #[transactional] - #[pallet::weight(100_000_000)] + #[pallet::weight(::WeightInfo::submit_verify_service_result())] pub fn submit_verify_service_result( origin: OriginFor, service_result: bool, @@ -789,6 +802,17 @@ pub mod pallet { Ok(()) } + + #[pallet::call_index(9)] + #[transactional] + #[pallet::weight(100_000_000)] + pub fn update_exec_block(origin: OriginFor, target: BlockNumberOf) -> DispatchResult { + let _ = ensure_root(origin)?; + + >::put(target); + + Ok(()) + } } #[pallet::validate_unsigned] diff --git a/c-pallets/audit/src/weights.rs b/c-pallets/audit/src/weights.rs index d80eb903..8fe5d22a 100644 --- a/c-pallets/audit/src/weights.rs +++ b/c-pallets/audit/src/weights.rs @@ -1,31 +1,17 @@ -// This file is part of Substrate. - -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. //! Autogenerated weights for pallet_audit //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-08-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("cess-staking-testnet"), DB CACHE: 1024 +//! DATE: 2023-09-04, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `ubuntu`, CPU: `Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("cess-initial-devnet"), DB CACHE: 1024 // Executed Command: // ./target/release/cess-node // benchmark +// pallet // --chain -// cess-staking-testnet +// cess-initial-devnet // --execution=wasm // --wasm-execution=compiled // --pallet @@ -37,7 +23,7 @@ // --repeat // 20 // --template=./.maintain/frame-weight-template.hbs -// --output=./c-pallets/audit/src/weights +// --output=./c-pallets/audit/src/weights.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -48,55 +34,113 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_audit. pub trait WeightInfo { - fn submit_challenge_prove(v: u32, ) -> Weight; - fn verify_proof(v: u32, ) -> Weight; + fn submit_idle_proof() -> Weight; + fn submit_service_proof() -> Weight; + fn submit_verify_idle_result() -> Weight; + fn submit_verify_service_result() -> Weight; } /// Weights for pallet_audit using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: System Digest (r:1 w:0) - // Storage: TeeWorker SchedulerMap (r:1 w:0) - // Storage: Audit ChallengeMap (r:1 w:1) - // Storage: Audit UnVerifyProof (r:1 w:1) - fn submit_challenge_prove(v: u32, ) -> Weight { - Weight::from_ref_time(116_351_000 as u64) - // Standard Error: 82_000 - .saturating_add(Weight::from_ref_time(6_532_000 as u64).saturating_mul(v as u64)) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Storage: Audit ChallengeSnapShot (r:1 w:1) + // Storage: TeeWorker TeeWorkerMap (r:2 w:0) + // Storage: Babe AuthorVrfRandomness (r:1 w:0) + // Storage: Audit UnverifyIdleProof (r:1 w:1) + fn submit_idle_proof() -> Weight { + // Minimum execution time: 124_658 nanoseconds. + Weight::from_ref_time(131_390_000) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: Audit ChallengeSnapShot (r:1 w:1) + // Storage: TeeWorker TeeWorkerMap (r:2 w:0) + // Storage: Babe AuthorVrfRandomness (r:1 w:0) + // Storage: Audit UnverifyServiceProof (r:1 w:1) + fn submit_service_proof() -> Weight { + // Minimum execution time: 127_080 nanoseconds. + Weight::from_ref_time(132_384_000) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(2)) } - // Storage: TeeWorker SchedulerMap (r:1 w:0) - // Storage: Audit UnVerifyProof (r:1 w:1) - fn verify_proof(v: u32, ) -> Weight { - Weight::from_ref_time(144_028_000 as u64) - // Standard Error: 120_000 - .saturating_add(Weight::from_ref_time(15_284_000 as u64).saturating_mul(v as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Storage: Audit UnverifyIdleProof (r:1 w:1) + // Storage: Audit ChallengeSnapShot (r:1 w:0) + // Storage: TeeWorker TeePodr2Pk (r:1 w:0) + // Storage: Audit VerifyResult (r:1 w:1) + // Storage: Sminer RewardMap (r:1 w:1) + // Storage: Sminer CurrencyReward (r:1 w:1) + // Storage: SchedulerCredit CurrentCounters (r:1 w:1) + // Storage: Audit CountedIdleFailed (r:0 w:1) + fn submit_verify_idle_result() -> Weight { + // Minimum execution time: 1_495_812 nanoseconds. + Weight::from_ref_time(1_517_527_000) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(6)) + } + // Storage: Audit UnverifyServiceProof (r:1 w:1) + // Storage: Audit ChallengeSnapShot (r:1 w:0) + // Storage: TeeWorker TeePodr2Pk (r:1 w:0) + // Storage: Audit VerifyResult (r:1 w:1) + // Storage: Sminer RewardMap (r:1 w:1) + // Storage: Sminer CurrencyReward (r:1 w:1) + // Storage: SchedulerCredit CurrentCounters (r:1 w:1) + // Storage: Audit CountedIdleFailed (r:0 w:1) + fn submit_verify_service_result() -> Weight { + // Minimum execution time: 1_521_687 nanoseconds. + Weight::from_ref_time(1_549_366_000) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(6)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: System Digest (r:1 w:0) - // Storage: TeeWorker SchedulerMap (r:1 w:0) - // Storage: Audit ChallengeMap (r:1 w:1) - // Storage: Audit UnVerifyProof (r:1 w:1) - fn submit_challenge_prove(v: u32, ) -> Weight { - Weight::from_ref_time(116_351_000 as u64) - // Standard Error: 82_000 - .saturating_add(Weight::from_ref_time(6_532_000 as u64).saturating_mul(v as u64)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Storage: Audit ChallengeSnapShot (r:1 w:1) + // Storage: TeeWorker TeeWorkerMap (r:2 w:0) + // Storage: Babe AuthorVrfRandomness (r:1 w:0) + // Storage: Audit UnverifyIdleProof (r:1 w:1) + fn submit_idle_proof() -> Weight { + // Minimum execution time: 124_658 nanoseconds. + Weight::from_ref_time(131_390_000) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(2)) + } + // Storage: Audit ChallengeSnapShot (r:1 w:1) + // Storage: TeeWorker TeeWorkerMap (r:2 w:0) + // Storage: Babe AuthorVrfRandomness (r:1 w:0) + // Storage: Audit UnverifyServiceProof (r:1 w:1) + fn submit_service_proof() -> Weight { + // Minimum execution time: 127_080 nanoseconds. + Weight::from_ref_time(132_384_000) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(2)) + } + // Storage: Audit UnverifyIdleProof (r:1 w:1) + // Storage: Audit ChallengeSnapShot (r:1 w:0) + // Storage: TeeWorker TeePodr2Pk (r:1 w:0) + // Storage: Audit VerifyResult (r:1 w:1) + // Storage: Sminer RewardMap (r:1 w:1) + // Storage: Sminer CurrencyReward (r:1 w:1) + // Storage: SchedulerCredit CurrentCounters (r:1 w:1) + // Storage: Audit CountedIdleFailed (r:0 w:1) + fn submit_verify_idle_result() -> Weight { + // Minimum execution time: 1_495_812 nanoseconds. + Weight::from_ref_time(1_517_527_000) + .saturating_add(RocksDbWeight::get().reads(7)) + .saturating_add(RocksDbWeight::get().writes(6)) } - // Storage: TeeWorker SchedulerMap (r:1 w:0) - // Storage: Audit UnVerifyProof (r:1 w:1) - fn verify_proof(v: u32, ) -> Weight { - Weight::from_ref_time(144_028_000 as u64) - // Standard Error: 120_000 - .saturating_add(Weight::from_ref_time(15_284_000 as u64).saturating_mul(v as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Storage: Audit UnverifyServiceProof (r:1 w:1) + // Storage: Audit ChallengeSnapShot (r:1 w:0) + // Storage: TeeWorker TeePodr2Pk (r:1 w:0) + // Storage: Audit VerifyResult (r:1 w:1) + // Storage: Sminer RewardMap (r:1 w:1) + // Storage: Sminer CurrencyReward (r:1 w:1) + // Storage: SchedulerCredit CurrentCounters (r:1 w:1) + // Storage: Audit CountedIdleFailed (r:0 w:1) + fn submit_verify_service_result() -> Weight { + // Minimum execution time: 1_521_687 nanoseconds. + Weight::from_ref_time(1_549_366_000) + .saturating_add(RocksDbWeight::get().reads(7)) + .saturating_add(RocksDbWeight::get().writes(6)) } } diff --git a/c-pallets/audit/src/weights_demo.rs b/c-pallets/audit/src/weights_demo.rs deleted file mode 100644 index fc161a76..00000000 --- a/c-pallets/audit/src/weights_demo.rs +++ /dev/null @@ -1,153 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Autogenerated weights for pallet_audit -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-08-29, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("cess-initial-devnet"), DB CACHE: 1024 - -// Executed Command: -// ./target/release/cess-node -// benchmark -// pallet -// --chain -// cess-initial-devnet -// --execution=wasm -// --wasm-execution=compiled -// --pallet -// pallet_audit -// --extrinsic -// * -// --steps -// 50 -// --repeat -// 20 -// --template=./.maintain/frame-weight-template.hbs -// --output=./c-pallets/audit/src/weights_demo.rs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; - -/// Weight functions needed for pallet_audit. -pub trait WeightInfo { - fn submit_idle_proof() -> Weight; - fn submit_service_proof() -> Weight; - fn submit_verify_idle_result() -> Weight; - fn submit_verify_service_result() -> Weight; -} - -/// Weights for pallet_audit using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight { - // Storage: Audit ChallengeSnapShot (r:1 w:1) - // Storage: TeeWorker TeeWorkerMap (r:2 w:0) - // Storage: Babe AuthorVrfRandomness (r:1 w:0) - // Storage: Audit UnverifyIdleProof (r:1 w:1) - fn submit_idle_proof() -> Weight { - (172_133_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - // Storage: Audit ChallengeSnapShot (r:1 w:1) - // Storage: TeeWorker TeeWorkerMap (r:2 w:0) - // Storage: Babe AuthorVrfRandomness (r:1 w:0) - // Storage: Audit UnverifyServiceProof (r:1 w:1) - fn submit_service_proof() -> Weight { - (144_386_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - // Storage: Audit UnverifyIdleProof (r:1 w:1) - // Storage: Audit ChallengeSnapShot (r:1 w:0) - // Storage: TeeWorker TeePodr2Pk (r:1 w:0) - // Storage: Audit VerifyResult (r:1 w:1) - // Storage: Sminer RewardMap (r:1 w:1) - // Storage: Sminer CurrencyReward (r:1 w:1) - // Storage: SchedulerCredit CurrentCounters (r:1 w:1) - // Storage: Audit CountedIdleFailed (r:0 w:1) - fn submit_verify_idle_result() -> Weight { - (1_722_404_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) - } - // Storage: Audit UnverifyServiceProof (r:1 w:1) - // Storage: Audit ChallengeSnapShot (r:1 w:0) - // Storage: TeeWorker TeePodr2Pk (r:1 w:0) - // Storage: Audit VerifyResult (r:1 w:1) - // Storage: Sminer RewardMap (r:1 w:1) - // Storage: Sminer CurrencyReward (r:1 w:1) - // Storage: SchedulerCredit CurrentCounters (r:1 w:1) - // Storage: Audit CountedIdleFailed (r:0 w:1) - fn submit_verify_service_result() -> Weight { - (1_768_883_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) - } -} - -// For backwards compatibility and tests -impl WeightInfo for () { - // Storage: Audit ChallengeSnapShot (r:1 w:1) - // Storage: TeeWorker TeeWorkerMap (r:2 w:0) - // Storage: Babe AuthorVrfRandomness (r:1 w:0) - // Storage: Audit UnverifyIdleProof (r:1 w:1) - fn submit_idle_proof() -> Weight { - (172_133_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } - // Storage: Audit ChallengeSnapShot (r:1 w:1) - // Storage: TeeWorker TeeWorkerMap (r:2 w:0) - // Storage: Babe AuthorVrfRandomness (r:1 w:0) - // Storage: Audit UnverifyServiceProof (r:1 w:1) - fn submit_service_proof() -> Weight { - (144_386_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } - // Storage: Audit UnverifyIdleProof (r:1 w:1) - // Storage: Audit ChallengeSnapShot (r:1 w:0) - // Storage: TeeWorker TeePodr2Pk (r:1 w:0) - // Storage: Audit VerifyResult (r:1 w:1) - // Storage: Sminer RewardMap (r:1 w:1) - // Storage: Sminer CurrencyReward (r:1 w:1) - // Storage: SchedulerCredit CurrentCounters (r:1 w:1) - // Storage: Audit CountedIdleFailed (r:0 w:1) - fn submit_verify_idle_result() -> Weight { - (1_722_404_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) - } - // Storage: Audit UnverifyServiceProof (r:1 w:1) - // Storage: Audit ChallengeSnapShot (r:1 w:0) - // Storage: TeeWorker TeePodr2Pk (r:1 w:0) - // Storage: Audit VerifyResult (r:1 w:1) - // Storage: Sminer RewardMap (r:1 w:1) - // Storage: Sminer CurrencyReward (r:1 w:1) - // Storage: SchedulerCredit CurrentCounters (r:1 w:1) - // Storage: Audit CountedIdleFailed (r:0 w:1) - fn submit_verify_service_result() -> Weight { - (1_768_883_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) - } -} \ No newline at end of file diff --git a/c-pallets/file-bank/src/benchmarking.rs b/c-pallets/file-bank/src/benchmarking.rs index 77433166..39389e07 100755 --- a/c-pallets/file-bank/src/benchmarking.rs +++ b/c-pallets/file-bank/src/benchmarking.rs @@ -73,11 +73,11 @@ pub fn buy_space(user: T::AccountId) -> Result<(), &'static str> { Ok(()) } -pub fn create_deal_info(acc: AccountOf, length: u32) -> Result, &'static str> { +pub fn create_deal_info(acc: AccountOf, length: u32, hash_seed: u8) -> Result, &'static str> { let mut deal_info: BoundedVec, T::SegmentCount> = Default::default(); let file_name = "test-file".as_bytes().to_vec(); let bucket_name = "test-bucket1".as_bytes().to_vec(); - let file_hash: Hash = Hash([4u8; 64]); + let file_hash: Hash = Hash([hash_seed; 64]); let user_brief = UserBrief::{ user: acc, file_name: file_name.try_into().map_err(|_e| "file name convert err")?, @@ -212,7 +212,7 @@ benchmarks! { } buy_space::(caller.clone())?; - let deal_info = create_deal_info::(caller.clone(), v)?; + let deal_info = create_deal_info::(caller.clone(), v, 4)?; }: upload_declaration(RawOrigin::Signed(caller), deal_info.file_hash.clone(), deal_info.segment_list, deal_info.user_brief, deal_info.file_size) verify { assert!(DealMap::::contains_key(&deal_info.file_hash)); @@ -223,16 +223,13 @@ benchmarks! { log::info!("start transfer_report"); let caller: AccountOf = account("user1", 100, SEED); let _ = pallet_tee_worker::benchmarking::tee_register::()?; - for i in 0 .. 15 { + for i in 0 .. 3 { let miner = pallet_sminer::benchmarking::add_miner::(miner_list[i as usize])?; add_idle_space::(miner.clone())?; - if i < 12 { - pallet_sminer::benchmarking::freeze_miner::(miner.clone())?; - } } buy_space::(caller.clone())?; - let deal_submit_info = create_deal_info::(caller.clone(), v)?; + let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; FileBank::::upload_declaration( RawOrigin::Signed(caller).into(), deal_submit_info.file_hash.clone(), @@ -240,11 +237,11 @@ benchmarks! { deal_submit_info.user_brief, deal_submit_info.file_size, )?; - let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - }: _(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()), vec![deal_submit_info.file_hash]) + + }: _(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()), deal_submit_info.file_hash) verify { - let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); + let deal_info = DealMap::::get(deal_submit_info.file_hash).unwrap(); assert_eq!(deal_info.complete_list.len(), 1); } @@ -262,7 +259,7 @@ benchmarks! { } buy_space::(caller.clone())?; - let deal_submit_info = create_deal_info::(caller.clone(), v)?; + let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; FileBank::::upload_declaration( RawOrigin::Signed(caller).into(), deal_submit_info.file_hash.clone(), @@ -272,9 +269,9 @@ benchmarks! { )?; let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), vec![deal_submit_info.file_hash])?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), vec![deal_submit_info.file_hash])?; - }: transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()), vec![deal_submit_info.file_hash]) + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; + }: transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()), deal_submit_info.file_hash) verify { assert!(File::::contains_key(&deal_submit_info.file_hash)); } @@ -293,7 +290,7 @@ benchmarks! { } buy_space::(caller.clone())?; - let deal_submit_info = create_deal_info::(caller.clone(), v)?; + let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; FileBank::::upload_declaration( RawOrigin::Signed(caller).into(), deal_submit_info.file_hash.clone(), @@ -303,12 +300,12 @@ benchmarks! { )?; let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), vec![deal_submit_info.file_hash])?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), vec![deal_submit_info.file_hash])?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), vec![deal_submit_info.file_hash])?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; let caller: AccountOf = account("user2", 100, SEED); buy_space::(caller.clone())?; - let deal_submit_info = create_deal_info::(caller.clone(), v)?; + let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; }: upload_declaration(RawOrigin::Signed(caller.clone()), deal_submit_info.file_hash.clone(), deal_submit_info.segment_list, deal_submit_info.user_brief.clone(), deal_submit_info.file_size) verify { let file = File::::get(deal_submit_info.file_hash.clone()).unwrap(); @@ -329,7 +326,7 @@ benchmarks! { } buy_space::(caller.clone())?; - let deal_submit_info = create_deal_info::(caller.clone(), v)?; + let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; FileBank::::upload_declaration( RawOrigin::Signed(caller.clone()).into(), deal_submit_info.file_hash.clone(), @@ -359,7 +356,7 @@ benchmarks! { } buy_space::(caller.clone())?; - let deal_submit_info = create_deal_info::(caller.clone(), v)?; + let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; FileBank::::upload_declaration( RawOrigin::Signed(caller.clone()).into(), deal_submit_info.file_hash.clone(), @@ -383,7 +380,7 @@ benchmarks! { } buy_space::(caller.clone())?; - let deal_submit_info = create_deal_info::(caller.clone(), v)?; + let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; FileBank::::upload_declaration( RawOrigin::Signed(caller).into(), deal_submit_info.file_hash.clone(), @@ -393,9 +390,9 @@ benchmarks! { )?; let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), vec![deal_submit_info.file_hash])?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), vec![deal_submit_info.file_hash])?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), vec![deal_submit_info.file_hash])?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; let file_info = File::::get(&deal_submit_info.file_hash).unwrap(); }: _(RawOrigin::Root, deal_submit_info.file_hash) verify { @@ -413,7 +410,7 @@ benchmarks! { } buy_space::(caller.clone())?; - let deal_submit_info = create_deal_info::(caller.clone(), 50)?; + let deal_submit_info = create_deal_info::(caller.clone(), 50, 4)?; FileBank::::upload_declaration( RawOrigin::Signed(caller).into(), deal_submit_info.file_hash.clone(), @@ -423,9 +420,9 @@ benchmarks! { )?; let miner: AccountOf = account("miner1", 100, SEED); let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), vec![deal_submit_info.file_hash])?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), vec![deal_submit_info.file_hash])?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), vec![deal_submit_info.file_hash])?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; let avail_replace_space = deal_info.assigned_miner[0].fragment_list.len() as u128 * FRAGMENT_SIZE; let front = avail_replace_space / IDLE_SEG_SIZE; @@ -454,7 +451,7 @@ benchmarks! { } delete_file { - let v in 0 ..30; + let v in 0 .. 30; log::info!("start delete_file"); let caller: AccountOf = account("user1", 100, SEED); let _ = pallet_tee_worker::benchmarking::tee_register::()?; @@ -464,7 +461,7 @@ benchmarks! { } buy_space::(caller.clone())?; - let deal_submit_info = create_deal_info::(caller.clone(), v)?; + let deal_submit_info = create_deal_info::(caller.clone(), v, 4)?; FileBank::::upload_declaration( RawOrigin::Signed(caller.clone()).into(), deal_submit_info.file_hash.clone(), @@ -474,9 +471,9 @@ benchmarks! { )?; let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), vec![deal_submit_info.file_hash])?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), vec![deal_submit_info.file_hash])?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), vec![deal_submit_info.file_hash])?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; FileBank::::calculate_end(RawOrigin::Root.into(), deal_submit_info.file_hash.clone()); }: _(RawOrigin::Signed(caller.clone()), caller.clone(), vec![deal_submit_info.file_hash.clone()]) verify { @@ -515,7 +512,7 @@ benchmarks! { } buy_space::(caller.clone())?; - let deal_submit_info = create_deal_info::(caller.clone(), 50)?; + let deal_submit_info = create_deal_info::(caller.clone(), 50, 4)?; FileBank::::upload_declaration( RawOrigin::Signed(caller.clone()).into(), deal_submit_info.file_hash.clone(), @@ -525,9 +522,9 @@ benchmarks! { )?; let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), vec![deal_submit_info.file_hash])?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), vec![deal_submit_info.file_hash])?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), vec![deal_submit_info.file_hash])?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; FileBank::::calculate_end(RawOrigin::Root.into(), deal_submit_info.file_hash.clone()); }: _(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()), deal_submit_info.file_hash, Hash([99u8; 64])) verify { @@ -544,7 +541,7 @@ benchmarks! { } buy_space::(caller.clone())?; - let deal_submit_info = create_deal_info::(caller.clone(), 50)?; + let deal_submit_info = create_deal_info::(caller.clone(), 50, 4)?; FileBank::::upload_declaration( RawOrigin::Signed(caller).into(), deal_submit_info.file_hash.clone(), @@ -554,9 +551,9 @@ benchmarks! { )?; let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), vec![deal_submit_info.file_hash])?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), vec![deal_submit_info.file_hash])?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), vec![deal_submit_info.file_hash])?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; FileBank::::calculate_end(RawOrigin::Root.into(), deal_submit_info.file_hash)?; FileBank::::generate_restoral_order(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash, Hash([99u8; 64]))?; }: _(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()), Hash([99u8; 64])) @@ -575,7 +572,7 @@ benchmarks! { } buy_space::(caller.clone())?; - let deal_submit_info = create_deal_info::(caller.clone(), 50)?; + let deal_submit_info = create_deal_info::(caller.clone(), 50, 4)?; FileBank::::upload_declaration( RawOrigin::Signed(caller).into(), deal_submit_info.file_hash.clone(), @@ -585,9 +582,9 @@ benchmarks! { )?; let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), vec![deal_submit_info.file_hash])?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), vec![deal_submit_info.file_hash])?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), vec![deal_submit_info.file_hash])?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; FileBank::::calculate_end(RawOrigin::Root.into(), deal_submit_info.file_hash)?; FileBank::::generate_restoral_order(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash, Hash([99u8; 64]))?; frame_system::pallet::Pallet::::set_block_number(2u32.saturated_into()); @@ -607,7 +604,7 @@ benchmarks! { } buy_space::(caller.clone())?; - let deal_submit_info = create_deal_info::(caller.clone(), 50)?; + let deal_submit_info = create_deal_info::(caller.clone(), 50, 4)?; FileBank::::upload_declaration( RawOrigin::Signed(caller).into(), deal_submit_info.file_hash.clone(), @@ -617,9 +614,9 @@ benchmarks! { )?; let deal_info = DealMap::::get(&deal_submit_info.file_hash).unwrap(); - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), vec![deal_submit_info.file_hash])?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), vec![deal_submit_info.file_hash])?; - FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), vec![deal_submit_info.file_hash])?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[0].miner.clone()).into(), deal_submit_info.file_hash)?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()).into(), deal_submit_info.file_hash)?; + FileBank::::transfer_report(RawOrigin::Signed(deal_info.assigned_miner[2].miner.clone()).into(), deal_submit_info.file_hash)?; FileBank::::calculate_end(RawOrigin::Root.into(), deal_submit_info.file_hash)?; pallet_sminer::benchmarking::bench_miner_exit::(deal_info.assigned_miner[2].miner.clone())?; }: _(RawOrigin::Signed(deal_info.assigned_miner[1].miner.clone()), deal_info.assigned_miner[2].miner.clone(), deal_submit_info.file_hash, Hash([99u8; 64])) diff --git a/c-pallets/file-bank/src/functions.rs b/c-pallets/file-bank/src/functions.rs index ba84d6cc..b09cb0c2 100644 --- a/c-pallets/file-bank/src/functions.rs +++ b/c-pallets/file-bank/src/functions.rs @@ -669,4 +669,20 @@ impl Pallet { count >= 5 } + + pub(super) fn get_segment_length_from_deal(deal_hash: &Hash) -> u32 { + if let Ok(deal) = >::try_get(deal_hash) { + return deal.segment_list.len() as u32; + } + + return 0; + } + + pub(super) fn get_segment_length_from_file(file_hash: &Hash) -> u32 { + if let Ok(file) = >::try_get(file_hash) { + return file.segment_list.len() as u32; + } + + return 0; + } } \ No newline at end of file diff --git a/c-pallets/file-bank/src/lib.rs b/c-pallets/file-bank/src/lib.rs index e7fdb35d..ed52a0f5 100755 --- a/c-pallets/file-bank/src/lib.rs +++ b/c-pallets/file-bank/src/lib.rs @@ -168,9 +168,9 @@ pub mod pallet { //file upload declaration UploadDeclaration { operator: AccountOf, owner: AccountOf, deal_hash: Hash }, //file uploaded. - TransferReport { acc: AccountOf, failed_list: Vec }, + TransferReport { acc: AccountOf, deal_hash: Hash }, //File deletion event - DeleteFile { operator:AccountOf, owner: AccountOf, file_hash_list: Vec }, + DeleteFile { operator:AccountOf, owner: AccountOf, file_hash: Hash }, ReplaceFiller { acc: AccountOf, filler_list: Vec }, @@ -339,6 +339,7 @@ pub mod pallet { fn on_initialize(now: BlockNumberOf) -> Weight { let days = T::OneDay::get(); let mut weight: Weight = Weight::from_ref_time(0); + // FOR TESTING if now % days == 0u32.saturated_into() { let (temp_weight, acc_list) = T::StorageHandle::frozen_task(); weight = weight.saturating_add(temp_weight); @@ -420,7 +421,7 @@ pub mod pallet { /// - `file_name`: User defined file name. #[pallet::call_index(0)] #[transactional] - #[pallet::weight(::WeightInfo::upload_declaration())] + #[pallet::weight(::WeightInfo::upload_declaration(deal_info.len() as u32))] pub fn upload_declaration( origin: OriginFor, file_hash: Hash, @@ -473,8 +474,12 @@ pub mod pallet { } #[pallet::call_index(1)] - #[transactional] - #[pallet::weight(1_000_000_000)] + // #[transactional] + #[pallet::weight( + { + let v = Pallet::::get_segment_length_from_deal(&deal_hash); + ::WeightInfo::deal_reassign_miner(v) + })] pub fn deal_reassign_miner( origin: OriginFor, deal_hash: Hash, @@ -482,7 +487,7 @@ pub mod pallet { life: u32, ) -> DispatchResult { let _ = ensure_root(origin)?; - + let segment_length = Self::get_segment_length_from_deal(&deal_hash); if count < 20 { if let Err(_e) = >::try_mutate(&deal_hash, |opt| -> DispatchResult { let deal_info = opt.as_mut().ok_or(Error::::NonExistent)?; @@ -537,7 +542,7 @@ pub mod pallet { /// - `file_hash`: File hash, which is also the unique identifier of the file #[pallet::call_index(2)] #[transactional] - #[pallet::weight(::WeightInfo::ownership_transfer())] + #[pallet::weight(1_000_000_000)] pub fn ownership_transfer( origin: OriginFor, target_brief: UserBrief, @@ -600,108 +605,90 @@ pub mod pallet { /// - `file_size`: File size calculated by consensus. /// - `slice_info`: List of file slice information. #[pallet::call_index(3)] - #[transactional] - #[pallet::weight(::WeightInfo::upload(2))] + // #[transactional] + #[pallet::weight(::WeightInfo::transfer_report(Pallet::::get_segment_length_from_deal(&deal_hash)))] pub fn transfer_report( origin: OriginFor, - deal_hash: Vec, + deal_hash: Hash, ) -> DispatchResult { let sender = ensure_signed(origin)?; - ensure!(deal_hash.len() < 5, Error::::LengthExceedsLimit); - let mut failed_list: Vec = Default::default(); - for hash in deal_hash { - if !>::contains_key(&hash) { - failed_list.push(hash); - continue; - } else { - >::try_mutate(&hash, |deal_info_opt| -> DispatchResult { - // can use unwrap because there was a judgment above - let deal_info = deal_info_opt.as_mut().unwrap(); - let mut task_miner_list: Vec> = Default::default(); - for miner_task in &deal_info.assigned_miner { - task_miner_list.push(miner_task.miner.clone()); - } - if task_miner_list.contains(&sender) { - if !deal_info.complete_list.contains(&sender) { - deal_info.complete_list.try_push(sender.clone()).map_err(|_| Error::::BoundedVecError)?; - } - // If it is the last submitter of the order. - if deal_info.complete_list.len() == deal_info.assigned_miner.len() { - deal_info.stage = 2; - Self::generate_file( - &hash, - deal_info.segment_list.clone(), - deal_info.assigned_miner.clone(), - deal_info.share_info.to_vec(), - deal_info.user.clone(), - FileState::Calculate, - deal_info.file_size, - )?; - - let mut max_task_count = 0; - for miner_task in deal_info.assigned_miner.iter() { - let count = miner_task.fragment_list.len() as u128; - if count > max_task_count { - max_task_count = count; - } - // Miners need to report the replaced documents themselves. - // If a challenge is triggered before the report is completed temporarily, - // these documents to be replaced also need to be verified - >::try_mutate(miner_task.miner.clone(), |pending_space| -> DispatchResult { - let replace_space = FRAGMENT_SIZE.checked_mul(count).ok_or(Error::::Overflow)?; - let pending_space_temp = pending_space.checked_add(replace_space).ok_or(Error::::Overflow)?; - *pending_space = pending_space_temp; - Ok(()) - })?; - - Self::zero_task_failed_count(&miner_task.miner)?; - } - let needed_space = Self::cal_file_size(deal_info.segment_list.len() as u128); - - T::StorageHandle::unlock_and_used_user_space(&deal_info.user.user, needed_space)?; - T::StorageHandle::sub_total_idle_space(needed_space)?; - T::StorageHandle::add_total_service_space(needed_space)?; - - let result = T::FScheduler::cancel_named(hash.0.to_vec()).map_err(|_| Error::::Unexpected); - if let Err(_) = result { - log::info!("transfer report cancel schedule failed: {:?}", hash.clone()); - } - // Calculate the maximum time required for storage nodes to tag files - let max_needed_cal_space = (max_task_count as u32).checked_mul(FRAGMENT_SIZE as u32).ok_or(Error::::Overflow)?; - let mut life: u32 = (max_needed_cal_space / TRANSFER_RATE as u32).checked_add(11).ok_or(Error::::Overflow)?; - life = (max_needed_cal_space / CALCULATE_RATE as u32) - .checked_add(10).ok_or(Error::::Overflow)? - .checked_add(life).ok_or(Error::::Overflow)?; - - Self::start_second_task(hash.0.to_vec(), hash, life)?; - if >::contains_key(&deal_info.user.user, &deal_info.user.bucket_name) { - Self::add_file_to_bucket(&deal_info.user.user, &deal_info.user.bucket_name, &hash)?; - } else { - Self::create_bucket_helper(&deal_info.user.user, &deal_info.user.bucket_name, Some(hash))?; - } - - Self::add_user_hold_fileslice(&deal_info.user.user, hash.clone(), needed_space)?; - - Self::deposit_event(Event::::StorageCompleted{ file_hash: hash }); + ensure!(>::contains_key(&deal_hash), Error::::NonExistent); + >::try_mutate(&deal_hash, |deal_info_opt| -> DispatchResult { + // can use unwrap because there was a judgment above + let deal_info = deal_info_opt.as_mut().unwrap(); + let mut task_miner_list: Vec> = Default::default(); + for miner_task in &deal_info.assigned_miner { + task_miner_list.push(miner_task.miner.clone()); + } + if task_miner_list.contains(&sender) { + if !deal_info.complete_list.contains(&sender) { + deal_info.complete_list.try_push(sender.clone()).map_err(|_| Error::::BoundedVecError)?; + } + // If it is the last submitter of the order. + if deal_info.complete_list.len() == deal_info.assigned_miner.len() { + deal_info.stage = 2; + Self::generate_file( + &deal_hash, + deal_info.segment_list.clone(), + deal_info.assigned_miner.clone(), + deal_info.share_info.to_vec(), + deal_info.user.clone(), + FileState::Calculate, + deal_info.file_size, + )?; + let mut max_task_count = 0; + for miner_task in deal_info.assigned_miner.iter() { + let count = miner_task.fragment_list.len() as u128; + if count > max_task_count { + max_task_count = count; } + // Miners need to report the replaced documents themselves. + // If a challenge is triggered before the report is completed temporarily, + // these documents to be replaced also need to be verified + >::try_mutate(miner_task.miner.clone(), |pending_space| -> DispatchResult { + let replace_space = FRAGMENT_SIZE.checked_mul(count).ok_or(Error::::Overflow)?; + let pending_space_temp = pending_space.checked_add(replace_space).ok_or(Error::::Overflow)?; + *pending_space = pending_space_temp; + Ok(()) + })?; + Self::zero_task_failed_count(&miner_task.miner)?; + } + let needed_space = Self::cal_file_size(deal_info.segment_list.len() as u128); + T::StorageHandle::unlock_and_used_user_space(&deal_info.user.user, needed_space)?; + T::StorageHandle::sub_total_idle_space(needed_space)?; + T::StorageHandle::add_total_service_space(needed_space)?; + let result = T::FScheduler::cancel_named(deal_hash.0.to_vec()).map_err(|_| Error::::Unexpected); + if let Err(_) = result { + log::info!("transfer report cancel schedule failed: {:?}", deal_hash.clone()); + } + // Calculate the maximum time required for storage nodes to tag files + let max_needed_cal_space = (max_task_count as u32).checked_mul(FRAGMENT_SIZE as u32).ok_or(Error::::Overflow)?; + let mut life: u32 = (max_needed_cal_space / TRANSFER_RATE as u32).checked_add(11).ok_or(Error::::Overflow)?; + life = (max_needed_cal_space / CALCULATE_RATE as u32) + .checked_add(10).ok_or(Error::::Overflow)? + .checked_add(life).ok_or(Error::::Overflow)?; + Self::start_second_task(deal_hash.0.to_vec(), deal_hash, life)?; + if >::contains_key(&deal_info.user.user, &deal_info.user.bucket_name) { + Self::add_file_to_bucket(&deal_info.user.user, &deal_info.user.bucket_name, &deal_hash)?; } else { - failed_list.push(hash); + Self::create_bucket_helper(&deal_info.user.user, &deal_info.user.bucket_name, Some(deal_hash))?; } - - Ok(()) - })?; + Self::add_user_hold_fileslice(&deal_info.user.user, deal_hash.clone(), needed_space)?; + Self::deposit_event(Event::::StorageCompleted{ file_hash: deal_hash }); + } } - } + Ok(()) + })?; - Self::deposit_event(Event::::TransferReport{acc: sender, failed_list}); + Self::deposit_event(Event::::TransferReport{acc: sender, deal_hash: deal_hash}); Ok(()) } #[pallet::call_index(4)] #[transactional] - #[pallet::weight(1_000_000_000)] + #[pallet::weight(::WeightInfo::calculate_end(Pallet::::get_segment_length_from_deal(&deal_hash)))] pub fn calculate_end( origin: OriginFor, deal_hash: Hash, @@ -737,7 +724,7 @@ pub mod pallet { #[pallet::call_index(5)] #[transactional] - #[pallet::weight(1_000_000_000)] + #[pallet::weight(::WeightInfo::replace_idle_space())] pub fn replace_idle_space( origin: OriginFor, idle_sig_info: SpaceProofInfo>, @@ -780,21 +767,21 @@ pub mod pallet { #[pallet::call_index(6)] #[transactional] - #[pallet::weight(1_000_000_000)] - pub fn delete_file(origin: OriginFor, owner: AccountOf, file_hash_list: Vec) -> DispatchResult { + #[pallet::weight({ + let v = Pallet::::get_segment_length_from_file(&file_hash); + ::WeightInfo::delete_file(v) + })] + pub fn delete_file(origin: OriginFor, owner: AccountOf, file_hash: Hash) -> DispatchResult { let sender = ensure_signed(origin)?; // Check if you have operation permissions. ensure!(Self::check_permission(sender.clone(), owner.clone()), Error::::NoPermission); - ensure!(file_hash_list.len() < 10, Error::::LengthExceedsLimit); - for file_hash in file_hash_list.iter() { - let file = >::try_get(&file_hash).map_err(|_| Error::::NonExistent)?; - let _ = Self::delete_user_file(&file_hash, &owner, &file)?; - Self::bucket_remove_file(&file_hash, &owner, &file)?; - Self::remove_user_hold_file_list(&file_hash, &owner)?; - } - - Self::deposit_event(Event::::DeleteFile{ operator: sender, owner, file_hash_list }); + let file = >::try_get(&file_hash).map_err(|_| Error::::NonExistent)?; + let _ = Self::delete_user_file(&file_hash, &owner, &file)?; + Self::bucket_remove_file(&file_hash, &owner, &file)?; + Self::remove_user_hold_file_list(&file_hash, &owner)?; + + Self::deposit_event(Event::::DeleteFile{ operator: sender, owner, file_hash }); Ok(()) } @@ -810,7 +797,7 @@ pub mod pallet { /// - `filler_list`: Meta information list of idle files. #[pallet::call_index(8)] #[transactional] - #[pallet::weight(100_000_000)] + #[pallet::weight(::WeightInfo::cert_idle_space())] pub fn cert_idle_space( origin: OriginFor, idle_sig_info: SpaceProofInfo>, @@ -907,7 +894,7 @@ pub mod pallet { // restoral file #[pallet::call_index(13)] #[transactional] - #[pallet::weight(100_000_000)] + #[pallet::weight(::WeightInfo::generate_restoral_order())] pub fn generate_restoral_order( origin: OriginFor, file_hash: Hash, @@ -954,7 +941,7 @@ pub mod pallet { #[pallet::call_index(14)] #[transactional] - #[pallet::weight(100_000_000)] + #[pallet::weight(::WeightInfo::claim_restoral_order())] pub fn claim_restoral_order( origin: OriginFor, restoral_fragment: Hash, @@ -984,7 +971,7 @@ pub mod pallet { #[pallet::call_index(15)] #[transactional] - #[pallet::weight(100_000_000)] + #[pallet::weight(::WeightInfo::claim_restoral_noexist_order())] pub fn claim_restoral_noexist_order( origin: OriginFor, miner: AccountOf, @@ -1044,7 +1031,7 @@ pub mod pallet { #[pallet::call_index(16)] #[transactional] - #[pallet::weight(100_000_000)] + #[pallet::weight(::WeightInfo::restoral_order_complete())] pub fn restoral_order_complete( origin: OriginFor, fragment_hash: Hash, diff --git a/c-pallets/file-bank/src/weights.rs b/c-pallets/file-bank/src/weights.rs index 7b0e3a6f..737b3896 100644 --- a/c-pallets/file-bank/src/weights.rs +++ b/c-pallets/file-bank/src/weights.rs @@ -1,31 +1,17 @@ -// This file is part of Substrate. - -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. //! Autogenerated weights for pallet_file_bank //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-11-11, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("cess-initial-devnet"), DB CACHE: 1024 +//! DATE: 2023-09-04, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `ubuntu`, CPU: `Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("cess-initial-testnet"), DB CACHE: 1024 // Executed Command: // ./target/release/cess-node // benchmark +// pallet // --chain -// cess-initial-devnet +// cess-initial-testnet // --execution=wasm // --wasm-execution=compiled // --pallet @@ -48,232 +34,442 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_file_bank. pub trait WeightInfo { - fn upload_filler(v: u32, ) -> Weight; - fn upload_declaration() -> Weight; - fn upload(v: u32, ) -> Weight; - fn delete_file() -> Weight; - fn recover_file() -> Weight; - fn clear_invalid_file() -> Weight; + fn cert_idle_space() -> Weight; + fn upload_declaration(v: u32, ) -> Weight; + fn upload_declaration_expected_max(v: u32, ) -> Weight; + fn transfer_report(v: u32, ) -> Weight; + fn transfer_report_last(v: u32, ) -> Weight; + fn upload_declaration_fly_upload(v: u32, ) -> Weight; + fn deal_reassign_miner(v: u32, ) -> Weight; + fn deal_reassign_miner_exceed_limit(v: u32, ) -> Weight; + fn calculate_end(v: u32, ) -> Weight; + fn replace_idle_space() -> Weight; + fn delete_file(v: u32, ) -> Weight; fn create_bucket() -> Weight; fn delete_bucket() -> Weight; - fn ownership_transfer() -> Weight; + fn generate_restoral_order() -> Weight; + fn claim_restoral_order() -> Weight; + fn restoral_order_complete() -> Weight; + fn claim_restoral_noexist_order() -> Weight; } /// Weights for pallet_file_bank using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { - // Storage: TeeWorker SchedulerMap (r:1 w:0) + // Storage: TeeWorker TeePodr2Pk (r:1 w:0) // Storage: Sminer MinerItems (r:1 w:1) - // Storage: FileBank FillerIndexCount (r:1 w:1) - // Storage: Sminer TotalIdleSpace (r:1 w:1) - // Storage: FileBank FillerMap (r:1 w:1) - // Storage: FileBank FillerKeysMap (r:1 w:1) - // Storage: FileBank CounterForFillerKeysMap (r:1 w:1) - // Storage: SchedulerCredit CurrentCounters (r:1 w:1) - fn upload_filler(v: u32, ) -> Weight { - Weight::from_ref_time(11_120_000 as u64) - // Standard Error: 1_155_000 - .saturating_add(Weight::from_ref_time(34_225_000 as u64).saturating_mul(v as u64)) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(v as u64))) - .saturating_add(T::DbWeight::get().writes(4 as u64)) - .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(v as u64))) + // Storage: StorageHandler TotalIdleSpace (r:1 w:1) + fn cert_idle_space() -> Weight { + // Minimum execution time: 1_465_084 nanoseconds. + Weight::from_ref_time(1_520_990_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) } - // Storage: FileBank Bucket (r:1 w:1) - // Storage: FileBank File (r:1 w:1) - // Storage: FileBank FileIndexCount (r:1 w:1) - fn upload_declaration() -> Weight { - Weight::from_ref_time(39_047_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Storage: StorageHandler UserOwnedSpace (r:1 w:1) + // Storage: FileBank File (r:1 w:0) + // Storage: Sminer AllMiner (r:1 w:0) + // Storage: Babe AuthorVrfRandomness (r:1 w:0) + // Storage: FileBank TaskFailedCount (r:1 w:0) + // Storage: Sminer MinerItems (r:1 w:1) + // Storage: Scheduler Lookup (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + // Storage: FileBank DealMap (r:0 w:1) + /// The range of component `v` is `[1, 30]`. + fn upload_declaration(v: u32, ) -> Weight { + // Minimum execution time: 130_096 nanoseconds. + Weight::from_ref_time(173_201_944) + // Standard Error: 112_849 + .saturating_add(Weight::from_ref_time(3_023_108).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().reads(11)) + .saturating_add(T::DbWeight::get().writes(7)) } - // Storage: TeeWorker SchedulerMap (r:1 w:0) - // Storage: FileBank File (r:1 w:1) - // Storage: FileBank UserOwnedSpace (r:1 w:1) + // Storage: StorageHandler UserOwnedSpace (r:1 w:1) + // Storage: FileBank File (r:1 w:0) + // Storage: Sminer AllMiner (r:1 w:0) + // Storage: Babe AuthorVrfRandomness (r:1 w:0) + // Storage: FileBank TaskFailedCount (r:15 w:0) + // Storage: Sminer MinerItems (r:15 w:2) + // Storage: Scheduler Lookup (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + // Storage: FileBank DealMap (r:0 w:1) + /// The range of component `v` is `[1, 30]`. + fn upload_declaration_expected_max(_v: u32, ) -> Weight { + // Minimum execution time: 372_440 nanoseconds. + Weight::from_ref_time(472_294_231) + .saturating_add(T::DbWeight::get().reads(36)) + .saturating_add(T::DbWeight::get().writes(6)) + } + // Storage: FileBank DealMap (r:1 w:1) + /// The range of component `v` is `[1, 30]`. + fn transfer_report(v: u32, ) -> Weight { + // Minimum execution time: 57_255 nanoseconds. + Weight::from_ref_time(68_385_886) + // Standard Error: 37_035 + .saturating_add(Weight::from_ref_time(519_563).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: FileBank DealMap (r:1 w:1) + // Storage: FileBank PendingReplacements (r:3 w:3) + // Storage: FileBank TaskFailedCount (r:3 w:3) + // Storage: StorageHandler UserOwnedSpace (r:1 w:1) + // Storage: StorageHandler TotalIdleSpace (r:1 w:1) + // Storage: StorageHandler TotalServiceSpace (r:1 w:1) + // Storage: Scheduler Lookup (r:1 w:1) + // Storage: Scheduler Agenda (r:2 w:2) + // Storage: FileBank Bucket (r:1 w:1) + // Storage: FileBank UserBucketList (r:1 w:1) // Storage: FileBank UserHoldFileList (r:1 w:1) - // Storage: FileBank FileKeysMap (r:1 w:1) - // Storage: FileBank CounterForFileKeysMap (r:1 w:1) - // Storage: SchedulerCredit CurrentCounters (r:1 w:1) - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: FileBank FillerMap (r:3 w:1) - // Storage: FileBank FillerKeysMap (r:1 w:1) - // Storage: FileBank CounterForFillerKeysMap (r:1 w:1) - // Storage: FileBank InvalidFile (r:1 w:1) - // Storage: Sminer TotalServiceSpace (r:1 w:1) - // Storage: Sminer TotalIdleSpace (r:1 w:1) - fn upload(v: u32, ) -> Weight { - Weight::from_ref_time(0 as u64) - // Standard Error: 1_634_000 - .saturating_add(Weight::from_ref_time(182_972_000 as u64).saturating_mul(v as u64)) - .saturating_add(T::DbWeight::get().reads(13 as u64)) - .saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(v as u64))) - .saturating_add(T::DbWeight::get().writes(10 as u64)) - .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(v as u64))) + // Storage: FileBank File (r:0 w:1) + /// The range of component `v` is `[1, 30]`. + fn transfer_report_last(v: u32, ) -> Weight { + // Minimum execution time: 177_496 nanoseconds. + Weight::from_ref_time(180_547_407) + // Standard Error: 74_093 + .saturating_add(Weight::from_ref_time(4_661_110).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().reads(16)) + .saturating_add(T::DbWeight::get().writes(17)) } + // Storage: StorageHandler UserOwnedSpace (r:1 w:1) // Storage: FileBank File (r:1 w:1) // Storage: FileBank Bucket (r:1 w:1) - // Storage: FileBank UserOwnedSpace (r:1 w:1) - // Storage: FileBank InvalidFile (r:1 w:1) - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: Sminer TotalServiceSpace (r:1 w:1) - // Storage: FileBank FileKeysMap (r:1 w:1) - // Storage: FileBank CounterForFileKeysMap (r:1 w:1) + // Storage: FileBank UserBucketList (r:1 w:1) // Storage: FileBank UserHoldFileList (r:1 w:1) - fn delete_file() -> Weight { - Weight::from_ref_time(376_051_000 as u64) - .saturating_add(T::DbWeight::get().reads(9 as u64)) - .saturating_add(T::DbWeight::get().writes(9 as u64)) + /// The range of component `v` is `[1, 30]`. + fn upload_declaration_fly_upload(v: u32, ) -> Weight { + // Minimum execution time: 100_259 nanoseconds. + Weight::from_ref_time(115_372_577) + // Standard Error: 51_183 + .saturating_add(Weight::from_ref_time(943_540).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: FileBank DealMap (r:1 w:1) + // Storage: Sminer AllMiner (r:1 w:0) + // Storage: Babe AuthorVrfRandomness (r:1 w:0) + // Storage: FileBank TaskFailedCount (r:18 w:3) + // Storage: Sminer MinerItems (r:18 w:6) + // Storage: Scheduler Lookup (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + /// The range of component `v` is `[0, 30]`. + fn deal_reassign_miner(v: u32, ) -> Weight { + // Minimum execution time: 381_575 nanoseconds. + Weight::from_ref_time(411_033_067) + // Standard Error: 74_850 + .saturating_add(Weight::from_ref_time(1_245_688).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().reads(41)) + .saturating_add(T::DbWeight::get().writes(12)) + } + // Storage: FileBank DealMap (r:1 w:1) + // Storage: StorageHandler UserOwnedSpace (r:1 w:1) + // Storage: Sminer MinerItems (r:3 w:3) + /// The range of component `v` is `[0, 30]`. + fn deal_reassign_miner_exceed_limit(v: u32, ) -> Weight { + // Minimum execution time: 99_424 nanoseconds. + Weight::from_ref_time(111_303_061) + // Standard Error: 33_521 + .saturating_add(Weight::from_ref_time(586_379).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) } - // Storage: FileBank FileRecovery (r:1 w:1) + // Storage: FileBank DealMap (r:1 w:1) + // Storage: Sminer MinerItems (r:3 w:3) // Storage: FileBank File (r:1 w:1) - // Storage: FileBank UserOwnedSpace (r:1 w:1) - // Storage: FileBank InvalidFile (r:1 w:1) + /// The range of component `v` is `[1, 30]`. + fn calculate_end(v: u32, ) -> Weight { + // Minimum execution time: 144_573 nanoseconds. + Weight::from_ref_time(151_655_693) + // Standard Error: 38_575 + .saturating_add(Weight::from_ref_time(3_286_351).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: TeeWorker TeePodr2Pk (r:1 w:0) // Storage: Sminer MinerItems (r:1 w:1) - // Storage: Sminer TotalServiceSpace (r:1 w:1) - // Storage: FileBank FileKeysMap (r:1 w:1) - // Storage: FileBank CounterForFileKeysMap (r:1 w:1) - fn recover_file() -> Weight { - Weight::from_ref_time(346_865_000 as u64) - // Standard Error: 118_000 - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(5 as u64)) - } - // Storage: FileBank InvalidFile (r:1 w:1) - fn clear_invalid_file() -> Weight { - Weight::from_ref_time(25_341_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Storage: FileBank PendingReplacements (r:1 w:1) + fn replace_idle_space() -> Weight { + // Minimum execution time: 1_484_864 nanoseconds. + Weight::from_ref_time(1_519_692_000) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: FileBank File (r:1 w:1) + // Storage: StorageHandler UserOwnedSpace (r:1 w:1) + // Storage: StorageHandler TotalServiceSpace (r:1 w:1) + // Storage: FileBank Bucket (r:1 w:1) + // Storage: FileBank UserHoldFileList (r:1 w:1) + // Storage: Sminer RestoralTarget (r:3 w:0) + // Storage: Sminer MinerItems (r:3 w:3) + /// The range of component `v` is `[0, 30]`. + fn delete_file(v: u32, ) -> Weight { + // Minimum execution time: 87_256 nanoseconds. + Weight::from_ref_time(195_439_527) + // Standard Error: 121_694 + .saturating_add(Weight::from_ref_time(4_058_900).saturating_mul(v.into())) + .saturating_add(T::DbWeight::get().reads(10)) + .saturating_add(T::DbWeight::get().writes(8)) } // Storage: FileBank Bucket (r:1 w:1) // Storage: FileBank UserBucketList (r:1 w:1) fn create_bucket() -> Weight { - Weight::from_ref_time(31_818_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Minimum execution time: 44_383 nanoseconds. + Weight::from_ref_time(45_277_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: FileBank Bucket (r:1 w:1) // Storage: FileBank UserBucketList (r:1 w:1) fn delete_bucket() -> Weight { - Weight::from_ref_time(36_686_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Minimum execution time: 52_452 nanoseconds. + Weight::from_ref_time(55_820_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: FileBank RestoralOrder (r:1 w:1) + // Storage: FileBank File (r:1 w:1) + fn generate_restoral_order() -> Weight { + // Minimum execution time: 88_578 nanoseconds. + Weight::from_ref_time(94_129_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) + } + // Storage: Sminer MinerItems (r:1 w:0) + // Storage: FileBank RestoralOrder (r:1 w:1) + fn claim_restoral_order() -> Weight { + // Minimum execution time: 64_488 nanoseconds. + Weight::from_ref_time(70_910_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(1)) + } + // Storage: Sminer MinerItems (r:2 w:2) + // Storage: FileBank RestoralOrder (r:1 w:1) + // Storage: FileBank File (r:1 w:1) + // Storage: FileBank PendingReplacements (r:1 w:1) + // Storage: Sminer RestoralTarget (r:1 w:0) + fn restoral_order_complete() -> Weight { + // Minimum execution time: 185_004 nanoseconds. + Weight::from_ref_time(196_225_000) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) } + // Storage: Sminer MinerItems (r:1 w:0) + // Storage: FileBank RestoralOrder (r:1 w:1) + // Storage: Sminer RestoralTarget (r:1 w:0) // Storage: FileBank File (r:1 w:1) - // Storage: FileBank Bucket (r:2 w:2) - // Storage: FileBank UserOwnedSpace (r:2 w:2) - // Storage: FileBank UserHoldFileList (r:2 w:2) - fn ownership_transfer() -> Weight { - Weight::from_ref_time(322_561_000 as u64) - .saturating_add(T::DbWeight::get().reads(7 as u64)) - .saturating_add(T::DbWeight::get().writes(7 as u64)) + fn claim_restoral_noexist_order() -> Weight { + // Minimum execution time: 106_741 nanoseconds. + Weight::from_ref_time(113_477_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(2)) } } // For backwards compatibility and tests impl WeightInfo for () { - // Storage: TeeWorker SchedulerMap (r:1 w:0) + // Storage: TeeWorker TeePodr2Pk (r:1 w:0) // Storage: Sminer MinerItems (r:1 w:1) - // Storage: FileBank FillerIndexCount (r:1 w:1) - // Storage: Sminer TotalIdleSpace (r:1 w:1) - // Storage: FileBank FillerMap (r:1 w:1) - // Storage: FileBank FillerKeysMap (r:1 w:1) - // Storage: FileBank CounterForFillerKeysMap (r:1 w:1) - // Storage: SchedulerCredit CurrentCounters (r:1 w:1) - fn upload_filler(v: u32, ) -> Weight { - Weight::from_ref_time(11_120_000 as u64) - // Standard Error: 1_155_000 - .saturating_add(Weight::from_ref_time(34_225_000 as u64).saturating_mul(v as u64)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().reads((2 as u64).saturating_mul(v as u64))) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) - .saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(v as u64))) + // Storage: StorageHandler TotalIdleSpace (r:1 w:1) + fn cert_idle_space() -> Weight { + // Minimum execution time: 1_465_084 nanoseconds. + Weight::from_ref_time(1_520_990_000) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().writes(2)) } - // Storage: FileBank Bucket (r:1 w:1) - // Storage: FileBank File (r:1 w:1) - // Storage: FileBank FileIndexCount (r:1 w:1) - fn upload_declaration() -> Weight { - Weight::from_ref_time(39_047_000 as u64) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Storage: StorageHandler UserOwnedSpace (r:1 w:1) + // Storage: FileBank File (r:1 w:0) + // Storage: Sminer AllMiner (r:1 w:0) + // Storage: Babe AuthorVrfRandomness (r:1 w:0) + // Storage: FileBank TaskFailedCount (r:1 w:0) + // Storage: Sminer MinerItems (r:1 w:1) + // Storage: Scheduler Lookup (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + // Storage: FileBank DealMap (r:0 w:1) + /// The range of component `v` is `[1, 30]`. + fn upload_declaration(v: u32, ) -> Weight { + // Minimum execution time: 130_096 nanoseconds. + Weight::from_ref_time(173_201_944) + // Standard Error: 112_849 + .saturating_add(Weight::from_ref_time(3_023_108).saturating_mul(v.into())) + .saturating_add(RocksDbWeight::get().reads(11)) + .saturating_add(RocksDbWeight::get().writes(7)) } - // Storage: TeeWorker SchedulerMap (r:1 w:0) - // Storage: FileBank File (r:1 w:1) - // Storage: FileBank UserOwnedSpace (r:1 w:1) + // Storage: StorageHandler UserOwnedSpace (r:1 w:1) + // Storage: FileBank File (r:1 w:0) + // Storage: Sminer AllMiner (r:1 w:0) + // Storage: Babe AuthorVrfRandomness (r:1 w:0) + // Storage: FileBank TaskFailedCount (r:15 w:0) + // Storage: Sminer MinerItems (r:15 w:2) + // Storage: Scheduler Lookup (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + // Storage: FileBank DealMap (r:0 w:1) + /// The range of component `v` is `[1, 30]`. + fn upload_declaration_expected_max(_v: u32, ) -> Weight { + // Minimum execution time: 372_440 nanoseconds. + Weight::from_ref_time(472_294_231) + .saturating_add(RocksDbWeight::get().reads(36)) + .saturating_add(RocksDbWeight::get().writes(6)) + } + // Storage: FileBank DealMap (r:1 w:1) + /// The range of component `v` is `[1, 30]`. + fn transfer_report(v: u32, ) -> Weight { + // Minimum execution time: 57_255 nanoseconds. + Weight::from_ref_time(68_385_886) + // Standard Error: 37_035 + .saturating_add(Weight::from_ref_time(519_563).saturating_mul(v.into())) + .saturating_add(RocksDbWeight::get().reads(1)) + .saturating_add(RocksDbWeight::get().writes(1)) + } + // Storage: FileBank DealMap (r:1 w:1) + // Storage: FileBank PendingReplacements (r:3 w:3) + // Storage: FileBank TaskFailedCount (r:3 w:3) + // Storage: StorageHandler UserOwnedSpace (r:1 w:1) + // Storage: StorageHandler TotalIdleSpace (r:1 w:1) + // Storage: StorageHandler TotalServiceSpace (r:1 w:1) + // Storage: Scheduler Lookup (r:1 w:1) + // Storage: Scheduler Agenda (r:2 w:2) + // Storage: FileBank Bucket (r:1 w:1) + // Storage: FileBank UserBucketList (r:1 w:1) // Storage: FileBank UserHoldFileList (r:1 w:1) - // Storage: FileBank FileKeysMap (r:1 w:1) - // Storage: FileBank CounterForFileKeysMap (r:1 w:1) - // Storage: SchedulerCredit CurrentCounters (r:1 w:1) - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: FileBank FillerMap (r:3 w:1) - // Storage: FileBank FillerKeysMap (r:1 w:1) - // Storage: FileBank CounterForFillerKeysMap (r:1 w:1) - // Storage: FileBank InvalidFile (r:1 w:1) - // Storage: Sminer TotalServiceSpace (r:1 w:1) - // Storage: Sminer TotalIdleSpace (r:1 w:1) - fn upload(v: u32, ) -> Weight { - Weight::from_ref_time(0 as u64) - // Standard Error: 1_634_000 - .saturating_add(Weight::from_ref_time(182_972_000 as u64).saturating_mul(v as u64)) - .saturating_add(RocksDbWeight::get().reads(13 as u64)) - .saturating_add(RocksDbWeight::get().reads((2 as u64).saturating_mul(v as u64))) - .saturating_add(RocksDbWeight::get().writes(10 as u64)) - .saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(v as u64))) + // Storage: FileBank File (r:0 w:1) + /// The range of component `v` is `[1, 30]`. + fn transfer_report_last(v: u32, ) -> Weight { + // Minimum execution time: 177_496 nanoseconds. + Weight::from_ref_time(180_547_407) + // Standard Error: 74_093 + .saturating_add(Weight::from_ref_time(4_661_110).saturating_mul(v.into())) + .saturating_add(RocksDbWeight::get().reads(16)) + .saturating_add(RocksDbWeight::get().writes(17)) } + // Storage: StorageHandler UserOwnedSpace (r:1 w:1) // Storage: FileBank File (r:1 w:1) // Storage: FileBank Bucket (r:1 w:1) - // Storage: FileBank UserOwnedSpace (r:1 w:1) - // Storage: FileBank InvalidFile (r:1 w:1) - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: Sminer TotalServiceSpace (r:1 w:1) - // Storage: FileBank FileKeysMap (r:1 w:1) - // Storage: FileBank CounterForFileKeysMap (r:1 w:1) + // Storage: FileBank UserBucketList (r:1 w:1) // Storage: FileBank UserHoldFileList (r:1 w:1) - fn delete_file() -> Weight { - Weight::from_ref_time(376_051_000 as u64) - .saturating_add(RocksDbWeight::get().reads(9 as u64)) - .saturating_add(RocksDbWeight::get().writes(9 as u64)) + /// The range of component `v` is `[1, 30]`. + fn upload_declaration_fly_upload(v: u32, ) -> Weight { + // Minimum execution time: 100_259 nanoseconds. + Weight::from_ref_time(115_372_577) + // Standard Error: 51_183 + .saturating_add(Weight::from_ref_time(943_540).saturating_mul(v.into())) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(5)) } - // Storage: FileBank FileRecovery (r:1 w:1) + // Storage: FileBank DealMap (r:1 w:1) + // Storage: Sminer AllMiner (r:1 w:0) + // Storage: Babe AuthorVrfRandomness (r:1 w:0) + // Storage: FileBank TaskFailedCount (r:18 w:3) + // Storage: Sminer MinerItems (r:18 w:6) + // Storage: Scheduler Lookup (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + /// The range of component `v` is `[0, 30]`. + fn deal_reassign_miner(v: u32, ) -> Weight { + // Minimum execution time: 381_575 nanoseconds. + Weight::from_ref_time(411_033_067) + // Standard Error: 74_850 + .saturating_add(Weight::from_ref_time(1_245_688).saturating_mul(v.into())) + .saturating_add(RocksDbWeight::get().reads(41)) + .saturating_add(RocksDbWeight::get().writes(12)) + } + // Storage: FileBank DealMap (r:1 w:1) + // Storage: StorageHandler UserOwnedSpace (r:1 w:1) + // Storage: Sminer MinerItems (r:3 w:3) + /// The range of component `v` is `[0, 30]`. + fn deal_reassign_miner_exceed_limit(v: u32, ) -> Weight { + // Minimum execution time: 99_424 nanoseconds. + Weight::from_ref_time(111_303_061) + // Standard Error: 33_521 + .saturating_add(Weight::from_ref_time(586_379).saturating_mul(v.into())) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(5)) + } + // Storage: FileBank DealMap (r:1 w:1) + // Storage: Sminer MinerItems (r:3 w:3) // Storage: FileBank File (r:1 w:1) - // Storage: FileBank UserOwnedSpace (r:1 w:1) - // Storage: FileBank InvalidFile (r:1 w:1) + /// The range of component `v` is `[1, 30]`. + fn calculate_end(v: u32, ) -> Weight { + // Minimum execution time: 144_573 nanoseconds. + Weight::from_ref_time(151_655_693) + // Standard Error: 38_575 + .saturating_add(Weight::from_ref_time(3_286_351).saturating_mul(v.into())) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(5)) + } + // Storage: TeeWorker TeePodr2Pk (r:1 w:0) // Storage: Sminer MinerItems (r:1 w:1) - // Storage: Sminer TotalServiceSpace (r:1 w:1) - // Storage: FileBank FileKeysMap (r:1 w:1) - // Storage: FileBank CounterForFileKeysMap (r:1 w:1) - fn recover_file() -> Weight { - Weight::from_ref_time(346_865_000 as u64) - // Standard Error: 118_000 - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(5 as u64)) - } - // Storage: FileBank InvalidFile (r:1 w:1) - fn clear_invalid_file() -> Weight { - Weight::from_ref_time(25_341_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Storage: FileBank PendingReplacements (r:1 w:1) + fn replace_idle_space() -> Weight { + // Minimum execution time: 1_484_864 nanoseconds. + Weight::from_ref_time(1_519_692_000) + .saturating_add(RocksDbWeight::get().reads(3)) + .saturating_add(RocksDbWeight::get().writes(2)) + } + // Storage: FileBank File (r:1 w:1) + // Storage: StorageHandler UserOwnedSpace (r:1 w:1) + // Storage: StorageHandler TotalServiceSpace (r:1 w:1) + // Storage: FileBank Bucket (r:1 w:1) + // Storage: FileBank UserHoldFileList (r:1 w:1) + // Storage: Sminer RestoralTarget (r:3 w:0) + // Storage: Sminer MinerItems (r:3 w:3) + /// The range of component `v` is `[0, 30]`. + fn delete_file(v: u32, ) -> Weight { + // Minimum execution time: 87_256 nanoseconds. + Weight::from_ref_time(195_439_527) + // Standard Error: 121_694 + .saturating_add(Weight::from_ref_time(4_058_900).saturating_mul(v.into())) + .saturating_add(RocksDbWeight::get().reads(10)) + .saturating_add(RocksDbWeight::get().writes(8)) } // Storage: FileBank Bucket (r:1 w:1) // Storage: FileBank UserBucketList (r:1 w:1) fn create_bucket() -> Weight { - Weight::from_ref_time(31_818_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Minimum execution time: 44_383 nanoseconds. + Weight::from_ref_time(45_277_000) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: FileBank Bucket (r:1 w:1) // Storage: FileBank UserBucketList (r:1 w:1) fn delete_bucket() -> Weight { - Weight::from_ref_time(36_686_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Minimum execution time: 52_452 nanoseconds. + Weight::from_ref_time(55_820_000) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) + } + // Storage: FileBank RestoralOrder (r:1 w:1) + // Storage: FileBank File (r:1 w:1) + fn generate_restoral_order() -> Weight { + // Minimum execution time: 88_578 nanoseconds. + Weight::from_ref_time(94_129_000) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) + } + // Storage: Sminer MinerItems (r:1 w:0) + // Storage: FileBank RestoralOrder (r:1 w:1) + fn claim_restoral_order() -> Weight { + // Minimum execution time: 64_488 nanoseconds. + Weight::from_ref_time(70_910_000) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(1)) + } + // Storage: Sminer MinerItems (r:2 w:2) + // Storage: FileBank RestoralOrder (r:1 w:1) + // Storage: FileBank File (r:1 w:1) + // Storage: FileBank PendingReplacements (r:1 w:1) + // Storage: Sminer RestoralTarget (r:1 w:0) + fn restoral_order_complete() -> Weight { + // Minimum execution time: 185_004 nanoseconds. + Weight::from_ref_time(196_225_000) + .saturating_add(RocksDbWeight::get().reads(6)) + .saturating_add(RocksDbWeight::get().writes(5)) } + // Storage: Sminer MinerItems (r:1 w:0) + // Storage: FileBank RestoralOrder (r:1 w:1) + // Storage: Sminer RestoralTarget (r:1 w:0) // Storage: FileBank File (r:1 w:1) - // Storage: FileBank Bucket (r:2 w:2) - // Storage: FileBank UserOwnedSpace (r:2 w:2) - // Storage: FileBank UserHoldFileList (r:2 w:2) - fn ownership_transfer() -> Weight { - Weight::from_ref_time(322_561_000 as u64) - .saturating_add(RocksDbWeight::get().reads(7 as u64)) - .saturating_add(RocksDbWeight::get().writes(7 as u64)) + fn claim_restoral_noexist_order() -> Weight { + // Minimum execution time: 106_741 nanoseconds. + Weight::from_ref_time(113_477_000) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(2)) } } diff --git a/c-pallets/file-bank/src/weights_demo.rs b/c-pallets/file-bank/src/weights_demo.rs deleted file mode 100644 index b09c7f19..00000000 --- a/c-pallets/file-bank/src/weights_demo.rs +++ /dev/null @@ -1,442 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Autogenerated weights for pallet_file_bank -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-08-28, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("cess-initial-testnet"), DB CACHE: 1024 - -// Executed Command: -// ./target/release/cess-node -// benchmark -// pallet -// --chain -// cess-initial-testnet -// --execution=wasm -// --wasm-execution=compiled -// --pallet -// pallet_file_bank -// --extrinsic -// * -// --steps -// 50 -// --repeat -// 20 -// --template=./.maintain/frame-weight-template.hbs -// --output=./c-pallets/file-bank/src/weights_demo.rs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; - -/// Weight functions needed for pallet_file_bank. -pub trait WeightInfo { - fn cert_idle_space() -> Weight; - fn upload_declaration(v: u32, ) -> Weight; - fn upload_declaration_expected_max(v: u32, ) -> Weight; - fn transfer_report(v: u32, ) -> Weight; - fn transfer_report_last(v: u32, ) -> Weight; - fn upload_declaration_fly_upload(v: u32, ) -> Weight; - fn deal_reassign_miner(v: u32, ) -> Weight; - fn deal_reassign_miner_exceed_limit(v: u32, ) -> Weight; - fn calculate_end(v: u32, ) -> Weight; - fn replace_idle_space() -> Weight; - fn delete_file(v: u32, ) -> Weight; - fn create_bucket() -> Weight; - fn delete_bucket() -> Weight; - fn generate_restoral_order() -> Weight; - fn claim_restoral_order() -> Weight; - fn restoral_order_complete() -> Weight; - fn claim_restoral_noexist_order() -> Weight; -} - -/// Weights for pallet_file_bank using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight { - // Storage: TeeWorker TeePodr2Pk (r:1 w:0) - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: StorageHandler TotalIdleSpace (r:1 w:1) - fn cert_idle_space() -> Weight { - (1_526_565_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - // Storage: StorageHandler UserOwnedSpace (r:1 w:1) - // Storage: FileBank File (r:1 w:0) - // Storage: Sminer AllMiner (r:1 w:0) - // Storage: Babe AuthorVrfRandomness (r:1 w:0) - // Storage: FileBank TaskFailedCount (r:1 w:0) - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) - // Storage: FileBank DealMap (r:0 w:1) - fn upload_declaration(v: u32, ) -> Weight { - (193_518_325 as Weight) - // Standard Error: 81_931 - .saturating_add((1_556_936 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(11 as Weight)) - .saturating_add(T::DbWeight::get().writes(7 as Weight)) - } - // Storage: StorageHandler UserOwnedSpace (r:1 w:1) - // Storage: FileBank File (r:1 w:0) - // Storage: Sminer AllMiner (r:1 w:0) - // Storage: Babe AuthorVrfRandomness (r:1 w:0) - // Storage: FileBank TaskFailedCount (r:15 w:0) - // Storage: Sminer MinerItems (r:15 w:2) - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) - // Storage: FileBank DealMap (r:0 w:1) - fn upload_declaration_expected_max(v: u32, ) -> Weight { - (417_790_915 as Weight) - // Standard Error: 90_219 - .saturating_add((448_381 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(36 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) - } - // Storage: FileBank DealMap (r:1 w:1) - fn transfer_report(v: u32, ) -> Weight { - (72_203_328 as Weight) - // Standard Error: 26_036 - .saturating_add((798_142 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: FileBank DealMap (r:1 w:1) - // Storage: FileBank PendingReplacements (r:3 w:3) - // Storage: FileBank TaskFailedCount (r:3 w:3) - // Storage: StorageHandler UserOwnedSpace (r:1 w:1) - // Storage: StorageHandler TotalIdleSpace (r:1 w:1) - // Storage: StorageHandler TotalServiceSpace (r:1 w:1) - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: FileBank Bucket (r:1 w:1) - // Storage: FileBank UserBucketList (r:1 w:1) - // Storage: FileBank UserHoldFileList (r:1 w:1) - // Storage: FileBank File (r:0 w:1) - fn transfer_report_last(v: u32, ) -> Weight { - (183_457_174 as Weight) - // Standard Error: 73_260 - .saturating_add((4_738_236 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(16 as Weight)) - .saturating_add(T::DbWeight::get().writes(17 as Weight)) - } - // Storage: StorageHandler UserOwnedSpace (r:1 w:1) - // Storage: FileBank File (r:1 w:1) - // Storage: FileBank Bucket (r:1 w:1) - // Storage: FileBank UserBucketList (r:1 w:1) - // Storage: FileBank UserHoldFileList (r:1 w:1) - fn upload_declaration_fly_upload(v: u32, ) -> Weight { - (117_464_406 as Weight) - // Standard Error: 39_959 - .saturating_add((916_856 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) - } - // Storage: FileBank DealMap (r:1 w:1) - // Storage: Sminer AllMiner (r:1 w:0) - // Storage: Babe AuthorVrfRandomness (r:1 w:0) - // Storage: FileBank TaskFailedCount (r:18 w:3) - // Storage: Sminer MinerItems (r:18 w:6) - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) - fn deal_reassign_miner(v: u32, ) -> Weight { - (444_951_473 as Weight) - // Standard Error: 75_341 - .saturating_add((866_536 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(41 as Weight)) - .saturating_add(T::DbWeight::get().writes(12 as Weight)) - } - // Storage: FileBank DealMap (r:1 w:1) - // Storage: StorageHandler UserOwnedSpace (r:1 w:1) - // Storage: Sminer MinerItems (r:3 w:3) - fn deal_reassign_miner_exceed_limit(v: u32, ) -> Weight { - (113_027_061 as Weight) - // Standard Error: 35_814 - .saturating_add((602_107 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) - } - // Storage: FileBank DealMap (r:1 w:1) - // Storage: Sminer MinerItems (r:3 w:3) - // Storage: FileBank File (r:1 w:1) - fn calculate_end(v: u32, ) -> Weight { - (152_148_501 as Weight) - // Standard Error: 32_534 - .saturating_add((3_139_336 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) - } - // Storage: TeeWorker TeePodr2Pk (r:1 w:0) - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: FileBank PendingReplacements (r:1 w:1) - fn replace_idle_space() -> Weight { - (1_508_960_000 as Weight) - .saturating_add(T::DbWeight::get().reads(3 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - // Storage: FileBank File (r:1 w:1) - // Storage: StorageHandler UserOwnedSpace (r:1 w:1) - // Storage: StorageHandler TotalServiceSpace (r:1 w:1) - // Storage: FileBank Bucket (r:1 w:1) - // Storage: FileBank UserHoldFileList (r:1 w:1) - // Storage: Sminer RestoralTarget (r:3 w:0) - // Storage: Sminer MinerItems (r:3 w:3) - fn delete_file(v: u32, ) -> Weight { - (190_020_234 as Weight) - // Standard Error: 110_544 - .saturating_add((4_197_987 as Weight).saturating_mul(v as Weight)) - .saturating_add(T::DbWeight::get().reads(10 as Weight)) - .saturating_add(T::DbWeight::get().writes(8 as Weight)) - } - // Storage: FileBank Bucket (r:1 w:1) - // Storage: FileBank UserBucketList (r:1 w:1) - fn create_bucket() -> Weight { - (45_647_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - // Storage: FileBank Bucket (r:1 w:1) - // Storage: FileBank UserBucketList (r:1 w:1) - fn delete_bucket() -> Weight { - (52_822_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - // Storage: FileBank RestoralOrder (r:1 w:1) - // Storage: FileBank File (r:1 w:1) - fn generate_restoral_order() -> Weight { - (92_979_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - // Storage: Sminer MinerItems (r:1 w:0) - // Storage: FileBank RestoralOrder (r:1 w:1) - fn claim_restoral_order() -> Weight { - (73_633_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Sminer MinerItems (r:2 w:2) - // Storage: FileBank RestoralOrder (r:1 w:1) - // Storage: FileBank File (r:1 w:1) - // Storage: FileBank PendingReplacements (r:1 w:1) - // Storage: Sminer RestoralTarget (r:1 w:0) - fn restoral_order_complete() -> Weight { - (197_280_000 as Weight) - .saturating_add(T::DbWeight::get().reads(6 as Weight)) - .saturating_add(T::DbWeight::get().writes(5 as Weight)) - } - // Storage: Sminer MinerItems (r:1 w:0) - // Storage: FileBank RestoralOrder (r:1 w:1) - // Storage: Sminer RestoralTarget (r:1 w:0) - // Storage: FileBank File (r:1 w:1) - fn claim_restoral_noexist_order() -> Weight { - (118_929_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } -} - -// For backwards compatibility and tests -impl WeightInfo for () { - // Storage: TeeWorker TeePodr2Pk (r:1 w:0) - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: StorageHandler TotalIdleSpace (r:1 w:1) - fn cert_idle_space() -> Weight { - (1_526_565_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } - // Storage: StorageHandler UserOwnedSpace (r:1 w:1) - // Storage: FileBank File (r:1 w:0) - // Storage: Sminer AllMiner (r:1 w:0) - // Storage: Babe AuthorVrfRandomness (r:1 w:0) - // Storage: FileBank TaskFailedCount (r:1 w:0) - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) - // Storage: FileBank DealMap (r:0 w:1) - fn upload_declaration(v: u32, ) -> Weight { - (193_518_325 as Weight) - // Standard Error: 81_931 - .saturating_add((1_556_936 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(11 as Weight)) - .saturating_add(RocksDbWeight::get().writes(7 as Weight)) - } - // Storage: StorageHandler UserOwnedSpace (r:1 w:1) - // Storage: FileBank File (r:1 w:0) - // Storage: Sminer AllMiner (r:1 w:0) - // Storage: Babe AuthorVrfRandomness (r:1 w:0) - // Storage: FileBank TaskFailedCount (r:15 w:0) - // Storage: Sminer MinerItems (r:15 w:2) - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) - // Storage: FileBank DealMap (r:0 w:1) - fn upload_declaration_expected_max(v: u32, ) -> Weight { - (417_790_915 as Weight) - // Standard Error: 90_219 - .saturating_add((448_381 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(36 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) - } - // Storage: FileBank DealMap (r:1 w:1) - fn transfer_report(v: u32, ) -> Weight { - (72_203_328 as Weight) - // Standard Error: 26_036 - .saturating_add((798_142 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - // Storage: FileBank DealMap (r:1 w:1) - // Storage: FileBank PendingReplacements (r:3 w:3) - // Storage: FileBank TaskFailedCount (r:3 w:3) - // Storage: StorageHandler UserOwnedSpace (r:1 w:1) - // Storage: StorageHandler TotalIdleSpace (r:1 w:1) - // Storage: StorageHandler TotalServiceSpace (r:1 w:1) - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:2 w:2) - // Storage: FileBank Bucket (r:1 w:1) - // Storage: FileBank UserBucketList (r:1 w:1) - // Storage: FileBank UserHoldFileList (r:1 w:1) - // Storage: FileBank File (r:0 w:1) - fn transfer_report_last(v: u32, ) -> Weight { - (183_457_174 as Weight) - // Standard Error: 73_260 - .saturating_add((4_738_236 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(16 as Weight)) - .saturating_add(RocksDbWeight::get().writes(17 as Weight)) - } - // Storage: StorageHandler UserOwnedSpace (r:1 w:1) - // Storage: FileBank File (r:1 w:1) - // Storage: FileBank Bucket (r:1 w:1) - // Storage: FileBank UserBucketList (r:1 w:1) - // Storage: FileBank UserHoldFileList (r:1 w:1) - fn upload_declaration_fly_upload(v: u32, ) -> Weight { - (117_464_406 as Weight) - // Standard Error: 39_959 - .saturating_add((916_856 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) - } - // Storage: FileBank DealMap (r:1 w:1) - // Storage: Sminer AllMiner (r:1 w:0) - // Storage: Babe AuthorVrfRandomness (r:1 w:0) - // Storage: FileBank TaskFailedCount (r:18 w:3) - // Storage: Sminer MinerItems (r:18 w:6) - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) - fn deal_reassign_miner(v: u32, ) -> Weight { - (444_951_473 as Weight) - // Standard Error: 75_341 - .saturating_add((866_536 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(41 as Weight)) - .saturating_add(RocksDbWeight::get().writes(12 as Weight)) - } - // Storage: FileBank DealMap (r:1 w:1) - // Storage: StorageHandler UserOwnedSpace (r:1 w:1) - // Storage: Sminer MinerItems (r:3 w:3) - fn deal_reassign_miner_exceed_limit(v: u32, ) -> Weight { - (113_027_061 as Weight) - // Standard Error: 35_814 - .saturating_add((602_107 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) - } - // Storage: FileBank DealMap (r:1 w:1) - // Storage: Sminer MinerItems (r:3 w:3) - // Storage: FileBank File (r:1 w:1) - fn calculate_end(v: u32, ) -> Weight { - (152_148_501 as Weight) - // Standard Error: 32_534 - .saturating_add((3_139_336 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) - } - // Storage: TeeWorker TeePodr2Pk (r:1 w:0) - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: FileBank PendingReplacements (r:1 w:1) - fn replace_idle_space() -> Weight { - (1_508_960_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(3 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } - // Storage: FileBank File (r:1 w:1) - // Storage: StorageHandler UserOwnedSpace (r:1 w:1) - // Storage: StorageHandler TotalServiceSpace (r:1 w:1) - // Storage: FileBank Bucket (r:1 w:1) - // Storage: FileBank UserHoldFileList (r:1 w:1) - // Storage: Sminer RestoralTarget (r:3 w:0) - // Storage: Sminer MinerItems (r:3 w:3) - fn delete_file(v: u32, ) -> Weight { - (190_020_234 as Weight) - // Standard Error: 110_544 - .saturating_add((4_197_987 as Weight).saturating_mul(v as Weight)) - .saturating_add(RocksDbWeight::get().reads(10 as Weight)) - .saturating_add(RocksDbWeight::get().writes(8 as Weight)) - } - // Storage: FileBank Bucket (r:1 w:1) - // Storage: FileBank UserBucketList (r:1 w:1) - fn create_bucket() -> Weight { - (45_647_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } - // Storage: FileBank Bucket (r:1 w:1) - // Storage: FileBank UserBucketList (r:1 w:1) - fn delete_bucket() -> Weight { - (52_822_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } - // Storage: FileBank RestoralOrder (r:1 w:1) - // Storage: FileBank File (r:1 w:1) - fn generate_restoral_order() -> Weight { - (92_979_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } - // Storage: Sminer MinerItems (r:1 w:0) - // Storage: FileBank RestoralOrder (r:1 w:1) - fn claim_restoral_order() -> Weight { - (73_633_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - // Storage: Sminer MinerItems (r:2 w:2) - // Storage: FileBank RestoralOrder (r:1 w:1) - // Storage: FileBank File (r:1 w:1) - // Storage: FileBank PendingReplacements (r:1 w:1) - // Storage: Sminer RestoralTarget (r:1 w:0) - fn restoral_order_complete() -> Weight { - (197_280_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(6 as Weight)) - .saturating_add(RocksDbWeight::get().writes(5 as Weight)) - } - // Storage: Sminer MinerItems (r:1 w:0) - // Storage: FileBank RestoralOrder (r:1 w:1) - // Storage: Sminer RestoralTarget (r:1 w:0) - // Storage: FileBank File (r:1 w:1) - fn claim_restoral_noexist_order() -> Weight { - (118_929_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } -} \ No newline at end of file diff --git a/c-pallets/oss/src/weights_demo.rs b/c-pallets/oss/src/weights_demo.rs deleted file mode 100644 index 4c2c75e6..00000000 --- a/c-pallets/oss/src/weights_demo.rs +++ /dev/null @@ -1,126 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Autogenerated weights for pallet_oss -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-08-29, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("cess-initial-testnet"), DB CACHE: 1024 - -// Executed Command: -// ./target/release/cess-node -// benchmark -// pallet -// --chain -// cess-initial-testnet -// --execution=wasm -// --wasm-execution=compiled -// --pallet -// pallet_oss -// --extrinsic -// * -// --steps -// 50 -// --repeat -// 20 -// --template=./.maintain/frame-weight-template.hbs -// --output=./c-pallets/oss/src/weights_demo.rs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; - -/// Weight functions needed for pallet_oss. -pub trait WeightInfo { - fn authorize() -> Weight; - fn cancel_authorize() -> Weight; - fn register() -> Weight; - fn update() -> Weight; - fn destroy() -> Weight; -} - -/// Weights for pallet_oss using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight { - // Storage: Oss AuthorityList (r:1 w:1) - fn authorize() -> Weight { - (50_169_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Oss AuthorityList (r:1 w:1) - fn cancel_authorize() -> Weight { - (66_539_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Oss Oss (r:1 w:1) - fn register() -> Weight { - (57_477_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Oss Oss (r:1 w:1) - fn update() -> Weight { - (63_189_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Oss Oss (r:1 w:1) - fn destroy() -> Weight { - (37_122_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } -} - -// For backwards compatibility and tests -impl WeightInfo for () { - // Storage: Oss AuthorityList (r:1 w:1) - fn authorize() -> Weight { - (50_169_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - // Storage: Oss AuthorityList (r:1 w:1) - fn cancel_authorize() -> Weight { - (66_539_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - // Storage: Oss Oss (r:1 w:1) - fn register() -> Weight { - (57_477_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - // Storage: Oss Oss (r:1 w:1) - fn update() -> Weight { - (63_189_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - // Storage: Oss Oss (r:1 w:1) - fn destroy() -> Weight { - (37_122_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } -} \ No newline at end of file diff --git a/c-pallets/sminer/src/constants.rs b/c-pallets/sminer/src/constants.rs index b06d48d1..785ee71c 100644 --- a/c-pallets/sminer/src/constants.rs +++ b/c-pallets/sminer/src/constants.rs @@ -10,7 +10,7 @@ pub(super) const STATE_LOCK: &str = "lock"; pub(super) const STATE_OFFLINE: &str = "offline"; -pub(super) const FAUCET_VALUE: u128 = 10000000000000000; +pub(super) const FAUCET_VALUE: u128 = 10_000_000_000_000_000; pub(super) const IDLE_MUTI: Perbill = Perbill::from_percent(30); diff --git a/c-pallets/sminer/src/lib.rs b/c-pallets/sminer/src/lib.rs index f4b776ea..b6bb51c8 100644 --- a/c-pallets/sminer/src/lib.rs +++ b/c-pallets/sminer/src/lib.rs @@ -469,7 +469,7 @@ pub mod pallet { /// - `ip`: The registered IP of storage miner. #[pallet::call_index(3)] #[transactional] - #[pallet::weight(::WeightInfo::update_ip())] + #[pallet::weight(::WeightInfo::update_peer_id())] pub fn update_peer_id(origin: OriginFor, peer_id: PeerId) -> DispatchResult { let sender = ensure_signed(origin)?; ensure!(MinerItems::::contains_key(&sender), Error::::NotMiner); @@ -526,7 +526,7 @@ pub mod pallet { // The lock in time must be greater than the survival period of the challenge #[pallet::call_index(7)] #[transactional] - #[pallet::weight(100_000_000)] + #[pallet::weight(::WeightInfo::miner_exit_prep())] pub fn miner_exit_prep( origin: OriginFor, ) -> DispatchResult { @@ -572,7 +572,7 @@ pub mod pallet { #[pallet::call_index(8)] #[transactional] - #[pallet::weight(100_000_000)] + #[pallet::weight(::WeightInfo::miner_exit())] pub fn miner_exit( origin: OriginFor, miner: AccountOf, @@ -595,7 +595,7 @@ pub mod pallet { #[pallet::call_index(9)] #[transactional] - #[pallet::weight(100_000_000)] + #[pallet::weight(::WeightInfo::miner_withdraw())] pub fn miner_withdraw(origin: OriginFor) -> DispatchResult { let sender = ensure_signed(origin)?; @@ -629,7 +629,7 @@ pub mod pallet { /// - `acc`: Top-up amount . #[pallet::call_index(13)] #[transactional] - #[pallet::weight(100_000)] + #[pallet::weight(::WeightInfo::faucet_top_up())] pub fn faucet_top_up(origin: OriginFor, award: BalanceOf) -> DispatchResult { let sender = ensure_signed(origin)?; @@ -648,7 +648,7 @@ pub mod pallet { /// - `acc`: Withdraw money account. #[pallet::call_index(14)] #[transactional] - #[pallet::weight(100_000)] + #[pallet::weight(35_000_000)] pub fn faucet(origin: OriginFor, to: AccountOf) -> DispatchResult { let _ = ensure_signed(origin)?; diff --git a/c-pallets/sminer/src/weights.rs b/c-pallets/sminer/src/weights.rs index e0f6fc02..c8d01996 100644 --- a/c-pallets/sminer/src/weights.rs +++ b/c-pallets/sminer/src/weights.rs @@ -1,31 +1,17 @@ -// This file is part of Substrate. - -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. //! Autogenerated weights for pallet_sminer //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-09-29, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("cess-staking-testnet"), DB CACHE: 1024 +//! DATE: 2023-09-04, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `ubuntu`, CPU: `Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("cess-initial-devnet"), DB CACHE: 1024 // Executed Command: // ./target/release/cess-node // benchmark +// pallet // --chain -// cess-staking-testnet +// cess-initial-devnet // --execution=wasm // --wasm-execution=compiled // --pallet @@ -51,15 +37,11 @@ pub trait WeightInfo { fn regnstk() -> Weight; fn increase_collateral() -> Weight; fn update_beneficiary() -> Weight; - fn update_ip() -> Weight; - fn exit_miner() -> Weight; - fn withdraw() -> Weight; - fn timed_increase_rewards() -> Weight; - fn timed_task_award_table(v: u32, ) -> Weight; - fn timed_user_receive_award1(v: u32, ) -> Weight; - fn timing_task_increase_power_rewards() -> Weight; - fn timing_task_award_table() -> Weight; - fn timing_user_receive_award() -> Weight; + fn update_peer_id() -> Weight; + fn faucet_top_up() -> Weight; + fn miner_exit_prep() -> Weight; + fn miner_exit() -> Weight; + fn miner_withdraw() -> Weight; } /// Weights for pallet_sminer using the Substrate node and recommended hardware. @@ -67,107 +49,78 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: Sminer MinerItems (r:1 w:1) // Storage: System Account (r:1 w:1) - // Storage: Sminer PeerIndex (r:1 w:1) + // Storage: TeeWorker TeePodr2Pk (r:1 w:0) + // Storage: Sminer CounterForMinerItems (r:1 w:1) // Storage: Sminer AllMiner (r:1 w:1) + // Storage: Sminer RewardMap (r:0 w:1) + // Storage: Sminer MinerPublicKey (r:0 w:1) fn regnstk() -> Weight { - Weight::from_ref_time(62_798_000 as u64) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + // Minimum execution time: 1_549_086 nanoseconds. + Weight::from_ref_time(1_641_778_000) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(6)) } // Storage: Sminer MinerItems (r:1 w:1) + // Storage: System Account (r:1 w:1) fn increase_collateral() -> Weight { - Weight::from_ref_time(58_597_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Minimum execution time: 75_685 nanoseconds. + Weight::from_ref_time(77_185_000) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(2)) } // Storage: Sminer MinerItems (r:1 w:1) fn update_beneficiary() -> Weight { - Weight::from_ref_time(41_298_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + // Minimum execution time: 56_771 nanoseconds. + Weight::from_ref_time(60_287_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } // Storage: Sminer MinerItems (r:1 w:1) - fn update_ip() -> Weight { - Weight::from_ref_time(42_699_000 as u64) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) + fn update_peer_id() -> Weight { + // Minimum execution time: 57_187 nanoseconds. + Weight::from_ref_time(61_289_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: Sminer TotalServiceSpace (r:1 w:1) - // Storage: Sminer TotalIdleSpace (r:1 w:1) - // Storage: Sminer MinerLockIn (r:0 w:1) - fn exit_miner() -> Weight { - Weight::from_ref_time(66_298_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + // Storage: System Account (r:1 w:1) + fn faucet_top_up() -> Weight { + // Minimum execution time: 75_384 nanoseconds. + Weight::from_ref_time(79_388_000) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) } + // Storage: Sminer MinerLock (r:1 w:1) // Storage: Sminer MinerItems (r:1 w:1) - // Storage: Sminer MinerLockIn (r:1 w:1) - // Storage: Sminer TotalIdleSpace (r:1 w:1) - // Storage: Sminer TotalServiceSpace (r:1 w:1) - // Storage: Sminer AllMiner (r:1 w:1) - // Storage: Sminer BadMiner (r:0 w:1) - fn withdraw() -> Weight { - Weight::from_ref_time(85_296_000 as u64) - .saturating_add(T::DbWeight::get().reads(5 as u64)) - .saturating_add(T::DbWeight::get().writes(6 as u64)) - } - // Storage: Sminer TotalIdleSpace (r:1 w:0) - // Storage: Sminer TotalServiceSpace (r:1 w:0) - // Storage: Sminer CurrencyReward (r:1 w:1) - // Storage: Sminer MinerItems (r:2 w:0) - // Storage: Sminer CalculateRewardOrderMap (r:1 w:1) - // Storage: Sminer CounterForCalculateRewardOrderMap (r:1 w:1) - fn timed_increase_rewards() -> Weight { - Weight::from_ref_time(68_497_000 as u64) - .saturating_add(T::DbWeight::get().reads(7 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Storage: Scheduler Lookup (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + fn miner_exit_prep() -> Weight { + // Minimum execution time: 76_791 nanoseconds. + Weight::from_ref_time(77_847_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } - // Storage: Sminer CalculateRewardOrderMap (r:2 w:0) // Storage: Sminer MinerItems (r:1 w:1) - // Storage: Sminer RewardClaimMap (r:1 w:1) - // Storage: Sminer CounterForRewardClaimMap (r:1 w:1) - fn timed_task_award_table(v: u32, ) -> Weight { - Weight::from_ref_time(30_507_000 as u64) - // Standard Error: 122_000 - .saturating_add(Weight::from_ref_time(31_887_000 as u64).saturating_mul(v as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(v as u64))) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(v as u64))) + // Storage: StorageHandler TotalIdleSpace (r:1 w:1) + // Storage: Sminer RewardMap (r:1 w:1) + // Storage: Sminer CurrencyReward (r:1 w:1) + // Storage: Sminer AllMiner (r:1 w:1) + // Storage: Sminer RestoralTarget (r:0 w:1) + fn miner_exit() -> Weight { + // Minimum execution time: 71_523 nanoseconds. + Weight::from_ref_time(73_043_000) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(6)) } - // Storage: Sminer RewardClaimMap (r:2 w:1) + // Storage: Sminer RestoralTarget (r:1 w:0) // Storage: Sminer MinerItems (r:1 w:1) // Storage: System Account (r:1 w:1) - fn timed_user_receive_award1(v: u32, ) -> Weight { - Weight::from_ref_time(20_872_000 as u64) - // Standard Error: 129_000 - .saturating_add(Weight::from_ref_time(47_205_000 as u64).saturating_mul(v as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(v as u64))) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(v as u64))) - } - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) - fn timing_task_increase_power_rewards() -> Weight { - Weight::from_ref_time(43_398_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) - fn timing_task_award_table() -> Weight { - Weight::from_ref_time(43_099_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) - } - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) - fn timing_user_receive_award() -> Weight { - Weight::from_ref_time(43_399_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Storage: Sminer CounterForMinerItems (r:1 w:1) + // Storage: Sminer MinerPublicKey (r:0 w:1) + fn miner_withdraw() -> Weight { + // Minimum execution time: 84_622 nanoseconds. + Weight::from_ref_time(88_092_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) } } @@ -175,106 +128,77 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { // Storage: Sminer MinerItems (r:1 w:1) // Storage: System Account (r:1 w:1) - // Storage: Sminer PeerIndex (r:1 w:1) + // Storage: TeeWorker TeePodr2Pk (r:1 w:0) + // Storage: Sminer CounterForMinerItems (r:1 w:1) // Storage: Sminer AllMiner (r:1 w:1) + // Storage: Sminer RewardMap (r:0 w:1) + // Storage: Sminer MinerPublicKey (r:0 w:1) fn regnstk() -> Weight { - Weight::from_ref_time(62_798_000 as u64) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Minimum execution time: 1_549_086 nanoseconds. + Weight::from_ref_time(1_641_778_000) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(6)) } // Storage: Sminer MinerItems (r:1 w:1) + // Storage: System Account (r:1 w:1) fn increase_collateral() -> Weight { - Weight::from_ref_time(58_597_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Minimum execution time: 75_685 nanoseconds. + Weight::from_ref_time(77_185_000) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().writes(2)) } // Storage: Sminer MinerItems (r:1 w:1) fn update_beneficiary() -> Weight { - Weight::from_ref_time(41_298_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + // Minimum execution time: 56_771 nanoseconds. + Weight::from_ref_time(60_287_000) + .saturating_add(RocksDbWeight::get().reads(1)) + .saturating_add(RocksDbWeight::get().writes(1)) } // Storage: Sminer MinerItems (r:1 w:1) - fn update_ip() -> Weight { - Weight::from_ref_time(42_699_000 as u64) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) + fn update_peer_id() -> Weight { + // Minimum execution time: 57_187 nanoseconds. + Weight::from_ref_time(61_289_000) + .saturating_add(RocksDbWeight::get().reads(1)) + .saturating_add(RocksDbWeight::get().writes(1)) } - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: Sminer TotalServiceSpace (r:1 w:1) - // Storage: Sminer TotalIdleSpace (r:1 w:1) - // Storage: Sminer MinerLockIn (r:0 w:1) - fn exit_miner() -> Weight { - Weight::from_ref_time(66_298_000 as u64) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Storage: System Account (r:1 w:1) + fn faucet_top_up() -> Weight { + // Minimum execution time: 75_384 nanoseconds. + Weight::from_ref_time(79_388_000) + .saturating_add(RocksDbWeight::get().reads(1)) + .saturating_add(RocksDbWeight::get().writes(1)) } + // Storage: Sminer MinerLock (r:1 w:1) // Storage: Sminer MinerItems (r:1 w:1) - // Storage: Sminer MinerLockIn (r:1 w:1) - // Storage: Sminer TotalIdleSpace (r:1 w:1) - // Storage: Sminer TotalServiceSpace (r:1 w:1) - // Storage: Sminer AllMiner (r:1 w:1) - // Storage: Sminer BadMiner (r:0 w:1) - fn withdraw() -> Weight { - Weight::from_ref_time(85_296_000 as u64) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(6 as u64)) - } - // Storage: Sminer TotalIdleSpace (r:1 w:0) - // Storage: Sminer TotalServiceSpace (r:1 w:0) - // Storage: Sminer CurrencyReward (r:1 w:1) - // Storage: Sminer MinerItems (r:2 w:0) - // Storage: Sminer CalculateRewardOrderMap (r:1 w:1) - // Storage: Sminer CounterForCalculateRewardOrderMap (r:1 w:1) - fn timed_increase_rewards() -> Weight { - Weight::from_ref_time(68_497_000 as u64) - .saturating_add(RocksDbWeight::get().reads(7 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Storage: Scheduler Lookup (r:1 w:1) + // Storage: Scheduler Agenda (r:1 w:1) + fn miner_exit_prep() -> Weight { + // Minimum execution time: 76_791 nanoseconds. + Weight::from_ref_time(77_847_000) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(4)) } - // Storage: Sminer CalculateRewardOrderMap (r:2 w:0) // Storage: Sminer MinerItems (r:1 w:1) - // Storage: Sminer RewardClaimMap (r:1 w:1) - // Storage: Sminer CounterForRewardClaimMap (r:1 w:1) - fn timed_task_award_table(v: u32, ) -> Weight { - Weight::from_ref_time(30_507_000 as u64) - // Standard Error: 122_000 - .saturating_add(Weight::from_ref_time(31_887_000 as u64).saturating_mul(v as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().reads((3 as u64).saturating_mul(v as u64))) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - .saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(v as u64))) + // Storage: StorageHandler TotalIdleSpace (r:1 w:1) + // Storage: Sminer RewardMap (r:1 w:1) + // Storage: Sminer CurrencyReward (r:1 w:1) + // Storage: Sminer AllMiner (r:1 w:1) + // Storage: Sminer RestoralTarget (r:0 w:1) + fn miner_exit() -> Weight { + // Minimum execution time: 71_523 nanoseconds. + Weight::from_ref_time(73_043_000) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(6)) } - // Storage: Sminer RewardClaimMap (r:2 w:1) + // Storage: Sminer RestoralTarget (r:1 w:0) // Storage: Sminer MinerItems (r:1 w:1) // Storage: System Account (r:1 w:1) - fn timed_user_receive_award1(v: u32, ) -> Weight { - Weight::from_ref_time(20_872_000 as u64) - // Standard Error: 129_000 - .saturating_add(Weight::from_ref_time(47_205_000 as u64).saturating_mul(v as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().reads((2 as u64).saturating_mul(v as u64))) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - .saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(v as u64))) + // Storage: Sminer CounterForMinerItems (r:1 w:1) + // Storage: Sminer MinerPublicKey (r:0 w:1) + fn miner_withdraw() -> Weight { + // Minimum execution time: 84_622 nanoseconds. + Weight::from_ref_time(88_092_000) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(4)) } - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) - fn timing_task_increase_power_rewards() -> Weight { - Weight::from_ref_time(43_398_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) - fn timing_task_award_table() -> Weight { - Weight::from_ref_time(43_099_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) - fn timing_user_receive_award() -> Weight { - Weight::from_ref_time(43_399_000 as u64) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) - } -} \ No newline at end of file +} diff --git a/c-pallets/sminer/src/weights_demo.rs b/c-pallets/sminer/src/weights_demo.rs deleted file mode 100644 index 2cf1b05b..00000000 --- a/c-pallets/sminer/src/weights_demo.rs +++ /dev/null @@ -1,203 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Autogenerated weights for pallet_sminer -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-08-28, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("cess-initial-devnet"), DB CACHE: 1024 - -// Executed Command: -// ./target/release/cess-node -// benchmark -// pallet -// --chain -// cess-initial-devnet -// --execution=wasm -// --wasm-execution=compiled -// --pallet -// pallet_sminer -// --extrinsic -// * -// --steps -// 50 -// --repeat -// 20 -// --template=./.maintain/frame-weight-template.hbs -// --output=./c-pallets/sminer/src/weights_demo.rs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; - -/// Weight functions needed for pallet_sminer. -pub trait WeightInfo { - fn regnstk() -> Weight; - fn increase_collateral() -> Weight; - fn update_beneficiary() -> Weight; - fn update_peer_id() -> Weight; - fn faucet_top_up() -> Weight; - fn miner_exit_prep() -> Weight; - fn miner_exit() -> Weight; - fn miner_withdraw() -> Weight; -} - -/// Weights for pallet_sminer using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight { - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: TeeWorker TeePodr2Pk (r:1 w:0) - // Storage: Sminer CounterForMinerItems (r:1 w:1) - // Storage: Sminer AllMiner (r:1 w:1) - // Storage: Sminer RewardMap (r:0 w:1) - // Storage: Sminer MinerPublicKey (r:0 w:1) - fn regnstk() -> Weight { - (1_692_205_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) - } - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: System Account (r:1 w:1) - fn increase_collateral() -> Weight { - (78_646_000 as Weight) - .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(2 as Weight)) - } - // Storage: Sminer MinerItems (r:1 w:1) - fn update_beneficiary() -> Weight { - (62_968_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Sminer MinerItems (r:1 w:1) - fn update_peer_id() -> Weight { - (62_354_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: System Account (r:1 w:1) - fn faucet_top_up() -> Weight { - (76_437_000 as Weight) - .saturating_add(T::DbWeight::get().reads(1 as Weight)) - .saturating_add(T::DbWeight::get().writes(1 as Weight)) - } - // Storage: Sminer MinerLock (r:1 w:1) - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) - fn miner_exit_prep() -> Weight { - (79_163_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - } - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: StorageHandler TotalIdleSpace (r:1 w:1) - // Storage: Sminer RewardMap (r:1 w:1) - // Storage: Sminer CurrencyReward (r:1 w:1) - // Storage: Sminer AllMiner (r:1 w:1) - // Storage: Sminer RestoralTarget (r:0 w:1) - fn miner_exit() -> Weight { - (73_918_000 as Weight) - .saturating_add(T::DbWeight::get().reads(5 as Weight)) - .saturating_add(T::DbWeight::get().writes(6 as Weight)) - } - // Storage: Sminer RestoralTarget (r:1 w:0) - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Sminer CounterForMinerItems (r:1 w:1) - // Storage: Sminer MinerPublicKey (r:0 w:1) - fn miner_withdraw() -> Weight { - (86_556_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - } -} - -// For backwards compatibility and tests -impl WeightInfo for () { - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: TeeWorker TeePodr2Pk (r:1 w:0) - // Storage: Sminer CounterForMinerItems (r:1 w:1) - // Storage: Sminer AllMiner (r:1 w:1) - // Storage: Sminer RewardMap (r:0 w:1) - // Storage: Sminer MinerPublicKey (r:0 w:1) - fn regnstk() -> Weight { - (1_692_205_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) - } - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: System Account (r:1 w:1) - fn increase_collateral() -> Weight { - (78_646_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(2 as Weight)) - } - // Storage: Sminer MinerItems (r:1 w:1) - fn update_beneficiary() -> Weight { - (62_968_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - // Storage: Sminer MinerItems (r:1 w:1) - fn update_peer_id() -> Weight { - (62_354_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - // Storage: System Account (r:1 w:1) - fn faucet_top_up() -> Weight { - (76_437_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(1 as Weight)) - .saturating_add(RocksDbWeight::get().writes(1 as Weight)) - } - // Storage: Sminer MinerLock (r:1 w:1) - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: Scheduler Lookup (r:1 w:1) - // Storage: Scheduler Agenda (r:1 w:1) - fn miner_exit_prep() -> Weight { - (79_163_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) - } - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: StorageHandler TotalIdleSpace (r:1 w:1) - // Storage: Sminer RewardMap (r:1 w:1) - // Storage: Sminer CurrencyReward (r:1 w:1) - // Storage: Sminer AllMiner (r:1 w:1) - // Storage: Sminer RestoralTarget (r:0 w:1) - fn miner_exit() -> Weight { - (73_918_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(5 as Weight)) - .saturating_add(RocksDbWeight::get().writes(6 as Weight)) - } - // Storage: Sminer RestoralTarget (r:1 w:0) - // Storage: Sminer MinerItems (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: Sminer CounterForMinerItems (r:1 w:1) - // Storage: Sminer MinerPublicKey (r:0 w:1) - fn miner_withdraw() -> Weight { - (86_556_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) - } -} \ No newline at end of file diff --git a/c-pallets/storage-handler/src/weights.rs b/c-pallets/storage-handler/src/weights.rs index 991ea1da..ce2d1d40 100644 --- a/c-pallets/storage-handler/src/weights.rs +++ b/c-pallets/storage-handler/src/weights.rs @@ -1,3 +1,30 @@ + +//! Autogenerated weights for pallet_storage_handler +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-09-04, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `ubuntu`, CPU: `Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("cess-initial-devnet"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/cess-node +// benchmark +// pallet +// --chain +// cess-initial-devnet +// --execution=wasm +// --wasm-execution=compiled +// --pallet +// pallet_storage_handler +// --extrinsic +// * +// --steps +// 50 +// --repeat +// 20 +// --template=./.maintain/frame-weight-template.hbs +// --output=./c-pallets/storage-handler/src/weights.rs + #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] @@ -5,76 +32,84 @@ use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use sp_std::marker::PhantomData; +/// Weight functions needed for pallet_storage_handler. pub trait WeightInfo { - fn buy_space() -> Weight; + fn buy_space() -> Weight; fn expansion_space() -> Weight; fn renewal_space() -> Weight; } +/// Weights for pallet_storage_handler using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); - impl WeightInfo for SubstrateWeight { - // Storage: FileBank UserOwnedSpace (r:1 w:1) - // Storage: FileBank UnitPrice (r:1 w:0) - // Storage: Sminer PurchasedSpace (r:1 w:1) - // Storage: Sminer TotalIdleSpace (r:1 w:0) - // Storage: Sminer TotalServiceSpace (r:1 w:0) + // Storage: StorageHandler UserOwnedSpace (r:1 w:1) + // Storage: StorageHandler UnitPrice (r:1 w:0) + // Storage: StorageHandler PurchasedSpace (r:1 w:1) + // Storage: StorageHandler TotalIdleSpace (r:1 w:0) + // Storage: StorageHandler TotalServiceSpace (r:1 w:0) // Storage: System Account (r:2 w:2) fn buy_space() -> Weight { - Weight::from_ref_time(297_601_000 as u64) - .saturating_add(T::DbWeight::get().reads(7 as u64)) - .saturating_add(T::DbWeight::get().writes(4 as u64)) + // Minimum execution time: 92_464 nanoseconds. + Weight::from_ref_time(93_249_000) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(4)) } - // Storage: FileBank UserOwnedSpace (r:1 w:1) - // Storage: FileBank UnitPrice (r:1 w:0) - // Storage: Sminer PurchasedSpace (r:1 w:1) - // Storage: Sminer TotalIdleSpace (r:1 w:0) - // Storage: Sminer TotalServiceSpace (r:1 w:0) - // Storage: System Account (r:1 w:1) + // Storage: StorageHandler UserOwnedSpace (r:1 w:1) + // Storage: StorageHandler UnitPrice (r:1 w:0) + // Storage: System Account (r:2 w:2) + // Storage: StorageHandler PurchasedSpace (r:1 w:1) + // Storage: StorageHandler TotalIdleSpace (r:1 w:0) + // Storage: StorageHandler TotalServiceSpace (r:1 w:0) fn expansion_space() -> Weight { - Weight::from_ref_time(3_972_139_000 as u64) - .saturating_add(T::DbWeight::get().reads(6 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + // Minimum execution time: 84_456 nanoseconds. + Weight::from_ref_time(87_497_000) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(4)) } - // Storage: FileBank UserOwnedSpace (r:1 w:1) - // Storage: FileBank UnitPrice (r:1 w:0) - // Storage: System Account (r:1 w:1) + // Storage: StorageHandler UserOwnedSpace (r:1 w:1) + // Storage: StorageHandler UnitPrice (r:1 w:0) + // Storage: System Account (r:2 w:2) fn renewal_space() -> Weight { - Weight::from_ref_time(313_401_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(2 as u64)) + // Minimum execution time: 75_841 nanoseconds. + Weight::from_ref_time(78_035_000) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) } } +// For backwards compatibility and tests impl WeightInfo for () { - // Storage: FileBank UserOwnedSpace (r:1 w:1) - // Storage: FileBank UnitPrice (r:1 w:0) - // Storage: Sminer PurchasedSpace (r:1 w:1) - // Storage: Sminer TotalIdleSpace (r:1 w:0) - // Storage: Sminer TotalServiceSpace (r:1 w:0) + // Storage: StorageHandler UserOwnedSpace (r:1 w:1) + // Storage: StorageHandler UnitPrice (r:1 w:0) + // Storage: StorageHandler PurchasedSpace (r:1 w:1) + // Storage: StorageHandler TotalIdleSpace (r:1 w:0) + // Storage: StorageHandler TotalServiceSpace (r:1 w:0) // Storage: System Account (r:2 w:2) fn buy_space() -> Weight { - Weight::from_ref_time(297_601_000 as u64) - .saturating_add(RocksDbWeight::get().reads(7 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Minimum execution time: 92_464 nanoseconds. + Weight::from_ref_time(93_249_000) + .saturating_add(RocksDbWeight::get().reads(7)) + .saturating_add(RocksDbWeight::get().writes(4)) } - // Storage: FileBank UserOwnedSpace (r:1 w:1) - // Storage: FileBank UnitPrice (r:1 w:0) - // Storage: Sminer PurchasedSpace (r:1 w:1) - // Storage: Sminer TotalIdleSpace (r:1 w:0) - // Storage: Sminer TotalServiceSpace (r:1 w:0) - // Storage: System Account (r:1 w:1) + // Storage: StorageHandler UserOwnedSpace (r:1 w:1) + // Storage: StorageHandler UnitPrice (r:1 w:0) + // Storage: System Account (r:2 w:2) + // Storage: StorageHandler PurchasedSpace (r:1 w:1) + // Storage: StorageHandler TotalIdleSpace (r:1 w:0) + // Storage: StorageHandler TotalServiceSpace (r:1 w:0) fn expansion_space() -> Weight { - Weight::from_ref_time(3_972_139_000 as u64) - .saturating_add(RocksDbWeight::get().reads(6 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + // Minimum execution time: 84_456 nanoseconds. + Weight::from_ref_time(87_497_000) + .saturating_add(RocksDbWeight::get().reads(7)) + .saturating_add(RocksDbWeight::get().writes(4)) } - // Storage: FileBank UserOwnedSpace (r:1 w:1) - // Storage: FileBank UnitPrice (r:1 w:0) - // Storage: System Account (r:1 w:1) + // Storage: StorageHandler UserOwnedSpace (r:1 w:1) + // Storage: StorageHandler UnitPrice (r:1 w:0) + // Storage: System Account (r:2 w:2) fn renewal_space() -> Weight { - Weight::from_ref_time(313_401_000 as u64) - .saturating_add(RocksDbWeight::get().reads(3 as u64)) - .saturating_add(RocksDbWeight::get().writes(2 as u64)) + // Minimum execution time: 75_841 nanoseconds. + Weight::from_ref_time(78_035_000) + .saturating_add(RocksDbWeight::get().reads(4)) + .saturating_add(RocksDbWeight::get().writes(3)) } -} \ No newline at end of file +} diff --git a/c-pallets/storage-handler/src/weights_demo.rs b/c-pallets/storage-handler/src/weights_demo.rs deleted file mode 100644 index 095afd2e..00000000 --- a/c-pallets/storage-handler/src/weights_demo.rs +++ /dev/null @@ -1,124 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) 2022 Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Autogenerated weights for pallet_storage_handler -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-08-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("cess-initial-devnet"), DB CACHE: 1024 - -// Executed Command: -// ./target/release/cess-node -// benchmark -// pallet -// --chain -// cess-initial-devnet -// --execution=wasm -// --wasm-execution=compiled -// --pallet -// pallet_storage_handler -// --extrinsic -// * -// --steps -// 50 -// --repeat -// 20 -// --template=./.maintain/frame-weight-template.hbs -// --output=./c-pallets/storage-handler/src/weights_demo.rs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] - -use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; -use sp_std::marker::PhantomData; - -/// Weight functions needed for pallet_storage_handler. -pub trait WeightInfo { - fn buy_space() -> Weight; - fn expansion_space() -> Weight; - fn renewal_space() -> Weight; -} - -/// Weights for pallet_storage_handler using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight { - // Storage: StorageHandler UserOwnedSpace (r:1 w:1) - // Storage: StorageHandler UnitPrice (r:1 w:0) - // Storage: StorageHandler PurchasedSpace (r:1 w:1) - // Storage: StorageHandler TotalIdleSpace (r:1 w:0) - // Storage: StorageHandler TotalServiceSpace (r:1 w:0) - // Storage: System Account (r:2 w:2) - fn buy_space() -> Weight { - (92_002_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - } - // Storage: StorageHandler UserOwnedSpace (r:1 w:1) - // Storage: StorageHandler UnitPrice (r:1 w:0) - // Storage: System Account (r:2 w:2) - // Storage: StorageHandler PurchasedSpace (r:1 w:1) - // Storage: StorageHandler TotalIdleSpace (r:1 w:0) - // Storage: StorageHandler TotalServiceSpace (r:1 w:0) - fn expansion_space() -> Weight { - (101_652_000 as Weight) - .saturating_add(T::DbWeight::get().reads(7 as Weight)) - .saturating_add(T::DbWeight::get().writes(4 as Weight)) - } - // Storage: StorageHandler UserOwnedSpace (r:1 w:1) - // Storage: StorageHandler UnitPrice (r:1 w:0) - // Storage: System Account (r:2 w:2) - fn renewal_space() -> Weight { - (76_537_000 as Weight) - .saturating_add(T::DbWeight::get().reads(4 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) - } -} - -// For backwards compatibility and tests -impl WeightInfo for () { - // Storage: StorageHandler UserOwnedSpace (r:1 w:1) - // Storage: StorageHandler UnitPrice (r:1 w:0) - // Storage: StorageHandler PurchasedSpace (r:1 w:1) - // Storage: StorageHandler TotalIdleSpace (r:1 w:0) - // Storage: StorageHandler TotalServiceSpace (r:1 w:0) - // Storage: System Account (r:2 w:2) - fn buy_space() -> Weight { - (92_002_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) - } - // Storage: StorageHandler UserOwnedSpace (r:1 w:1) - // Storage: StorageHandler UnitPrice (r:1 w:0) - // Storage: System Account (r:2 w:2) - // Storage: StorageHandler PurchasedSpace (r:1 w:1) - // Storage: StorageHandler TotalIdleSpace (r:1 w:0) - // Storage: StorageHandler TotalServiceSpace (r:1 w:0) - fn expansion_space() -> Weight { - (101_652_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(7 as Weight)) - .saturating_add(RocksDbWeight::get().writes(4 as Weight)) - } - // Storage: StorageHandler UserOwnedSpace (r:1 w:1) - // Storage: StorageHandler UnitPrice (r:1 w:0) - // Storage: System Account (r:2 w:2) - fn renewal_space() -> Weight { - (76_537_000 as Weight) - .saturating_add(RocksDbWeight::get().reads(4 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) - } -} \ No newline at end of file diff --git a/node/src/chain_spec.rs b/node/src/chain_spec.rs index 4381931f..89eb34d6 100644 --- a/node/src/chain_spec.rs +++ b/node/src/chain_spec.rs @@ -174,6 +174,20 @@ fn cess_main_genesis() -> GenesisConfig { array_bytes::hex2array_unchecked("521917850191d8787c10d9e35a0f3ff218e992e4ed476e5c33f7de5ab04f1a38") .unchecked_into(), ), + ( + array_bytes::hex_n_into_unchecked("3aa51ef77986966c8aa4c801229e3d0210500bc92be5c7c6542fc540826dad7e"), + array_bytes::hex_n_into_unchecked("4cd8cdd8684aa21c647cc62207815ff9f8414ee72e8068be3db4e19ae34bde7f"), + array_bytes::hex2array_unchecked("2692ccff99f336e6291c5f01ca19b0ddd53662adafd07a94ce27d50db888a838") + .unchecked_into(), + array_bytes::hex2array_unchecked("fa93c04ccad2297b8f231291d46599fe9ef54db4c2b41f2a5fdd469adf5dfd18") + .unchecked_into(), + array_bytes::hex2array_unchecked("fa93c04ccad2297b8f231291d46599fe9ef54db4c2b41f2a5fdd469adf5dfd18") + .unchecked_into(), + array_bytes::hex2array_unchecked("fa93c04ccad2297b8f231291d46599fe9ef54db4c2b41f2a5fdd469adf5dfd18") + .unchecked_into(), + array_bytes::hex2array_unchecked("fa93c04ccad2297b8f231291d46599fe9ef54db4c2b41f2a5fdd469adf5dfd18") + .unchecked_into(), + ), ]; // generated with secret: subkey inspect "$secret"/fir @@ -202,6 +216,10 @@ fn cess_main_genesis() -> GenesisConfig { array_bytes::hex_n_into_unchecked("2e829b75650eac0d4c8dcfb8aa724d2df70dc5a44b16a8800b87403c3a4d8959"), array_bytes::hex_n_into_unchecked("74579f9baed2d7151cb0f5adfe0084f59b4bbf8696d5aa0493f584097bfe3cb1"), array_bytes::hex_n_into_unchecked("521917850191d8787c10d9e35a0f3ff218e992e4ed476e5c33f7de5ab04f1a38"), + array_bytes::hex_n_into_unchecked("3aa51ef77986966c8aa4c801229e3d0210500bc92be5c7c6542fc540826dad7e"), + array_bytes::hex_n_into_unchecked("4cd8cdd8684aa21c647cc62207815ff9f8414ee72e8068be3db4e19ae34bde7f"), + array_bytes::hex_n_into_unchecked("2692ccff99f336e6291c5f01ca19b0ddd53662adafd07a94ce27d50db888a838"), + array_bytes::hex_n_into_unchecked("fa93c04ccad2297b8f231291d46599fe9ef54db4c2b41f2a5fdd469adf5dfd18"), ]; testnet_genesis(initial_authorities, vec![], root_key, Some(endowed_accounts)) @@ -507,7 +525,7 @@ fn testnet_genesis( }, storage_handler: StorageHandlerConfig { price: 30 * DOLLARS }, // FOR TESTING - sminer: SminerConfig { expenders: (8, 1024*1024, 64) }, + sminer: SminerConfig { expenders: (8, 1024 * 1024, 64) }, indices: IndicesConfig { indices: vec![] }, session: SessionConfig { keys: initial_authorities diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 63ac3db6..e5b13a0e 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -169,7 +169,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 102, + spec_version: 105, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1,