Skip to content

Commit

Permalink
Everything compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
ntn-x2 committed Jan 16, 2025
1 parent 2d95311 commit e7e4c72
Show file tree
Hide file tree
Showing 16 changed files with 268 additions and 178 deletions.
96 changes: 96 additions & 0 deletions .maintain/runtime-hooks-template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{{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}}`
//! WORST CASE MAP SIZE: `{{cmd.worst_case_map_values}}`
//! HOSTNAME: `{{hostname}}`, CPU: `{{cpuname}}`
//! EXECUTION: {{cmd.execution}}, WASM-EXECUTION: {{cmd.wasm_execution}}, CHAIN: {{cmd.chain}}, DB CACHE: {{cmd.db_cache}}

// Executed Command:
{{#each args as |arg|}}
// {{arg}}
{{/each}}

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_imports)]
#![allow(clippy::as_conversions)]

use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use sp_std::marker::PhantomData;

/// Weight functions needed for {{pallet}}.
pub trait WeightInfo {
{{#each benchmarks as |benchmark|}}
fn {{benchmark.name~}}
(
{{~#each benchmark.components as |c| ~}}
{{c.name}}: u32, {{/each~}}
) -> Weight;
{{/each}}
}

/// Weight functions for `{{pallet}}`.
pub struct WeightsInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for WeightsInfo<T> {
{{#each benchmarks as |benchmark|}}
{{#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 {
// Proof Size summary in bytes:
// Measured: `{{benchmark.base_recorded_proof_size}}{{#each benchmark.component_recorded_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}`
// Estimated: `{{benchmark.base_calculated_proof_size}}{{#each benchmark.component_calculated_proof_size as |cp|}} + {{cp.name}} * ({{cp.slope}} ±{{underscore cp.error}}){{/each}}`
// Minimum execution time: {{underscore benchmark.min_execution_time}}_000 picoseconds.
Weight::from_parts({{underscore benchmark.base_weight}}, 0)
.saturating_add(Weight::from_parts(0, {{benchmark.base_calculated_proof_size}}))
{{#each benchmark.component_weight as |cw|}}
// Standard Error: {{underscore cw.error}}
.saturating_add(Weight::from_parts({{underscore cw.slope}}, 0).saturating_mul({{cw.name}}.into()))
{{/each}}
{{#if (ne benchmark.base_reads "0")}}
.saturating_add(T::DbWeight::get().reads({{benchmark.base_reads}}))
{{/if}}
{{#each benchmark.component_reads as |cr|}}
.saturating_add(T::DbWeight::get().reads(({{cr.slope}}_u64).saturating_mul({{cr.name}}.into())))
{{/each}}
{{#if (ne benchmark.base_writes "0")}}
.saturating_add(T::DbWeight::get().writes({{benchmark.base_writes}}))
{{/if}}
{{#each benchmark.component_writes as |cw|}}
.saturating_add(T::DbWeight::get().writes(({{cw.slope}}_u64).saturating_mul({{cw.name}}.into())))
{{/each}}
{{#each benchmark.component_calculated_proof_size as |cp|}}
.saturating_add(Weight::from_parts(0, {{cp.slope}}).saturating_mul({{cp.name}}.into()))
{{/each}}
}
{{/each}}
}

#[cfg(test)]
mod tests {
{{#each benchmarks as |benchmark|}}
{{#if (ne benchmark.base_calculated_proof_size "0")}}
#[test]
fn test_{{benchmark.name~}} () {
assert!(
<crate::Runtime as frame_system::Config>::BlockWeights::get()
.per_class
.get(frame_support::dispatch::DispatchClass::Normal)
.max_extrinsic
.unwrap_or_else(<sp_weights::Weight as sp_runtime::traits::Bounded>::max_value)
.proof_size()
> {{benchmark.base_calculated_proof_size}}
);
}
{{/if}}
{{/each}}
}
59 changes: 0 additions & 59 deletions out.rs

This file was deleted.

9 changes: 2 additions & 7 deletions pallets/delegation/src/tests/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@

use frame_support::{
assert_noop, assert_ok,
traits::{
fungible::{Inspect, InspectHold},
StorageInfoTrait,
},
traits::fungible::{Inspect, InspectHold},
};
use kilt_support::mock::mock_origin::DoubleOrigin;
use sp_runtime::traits::Zero;

use crate::{self as delegation, mock::*, Config, DelegationNodes, Error, HoldReason};
use crate::{self as delegation, mock::*, Config, Error, HoldReason};

#[test]
fn create_root_delegation_successful() {
Expand Down Expand Up @@ -70,8 +67,6 @@ fn create_root_delegation_successful() {
assert_eq!(stored_delegation_root.details.owner, creator.clone());
assert_eq!(stored_delegation_root.deposit.owner, ACCOUNT_00);
assert!(!stored_delegation_root.details.revoked);

println!("{:?}", DelegationNodes::<Test>::storage_info());
});
}

Expand Down
File renamed without changes.
19 changes: 19 additions & 0 deletions runtimes/peregrine/src/benchmarks/did/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// KILT Blockchain – https://botlabs.org
// Copyright (C) 2019-2024 BOTLabs GmbH

// The KILT Blockchain is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// The KILT Blockchain is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

// If you feel like getting in touch with us, you can do so at [email protected]

pub(crate) mod deletion_hooks;
5 changes: 3 additions & 2 deletions runtimes/peregrine/src/benchmarks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ define_benchmarks!(
[pallet_message_queue, MessageQueue]
[pallet_bonded_coins, BondedCurrencies]
[cumulus_pallet_parachain_system, ParachainSystem]
[did_deletion_hooks, crate::benchmarks::did::Pallet<Runtime>]
[frame_benchmarking::baseline, frame_benchmarking::baseline::Pallet::<Runtime>]
// DID deletion hooks
[did_deletion_hooks, crate::benchmarks::did::deletion_hooks::Pallet<Runtime>]
// pallet_collective instances
[pallet_collective, Council]
[pallet_technical_committee_collective, TechnicalCommittee]
Expand Down Expand Up @@ -172,7 +173,7 @@ impl frame_system_benchmarking::Config for Runtime {
impl cumulus_pallet_session_benchmarking::Config for Runtime {}
impl frame_benchmarking::baseline::Config for Runtime {}

impl crate::benchmarks::did::Config for Runtime {}
impl crate::benchmarks::did::deletion_hooks::Config for Runtime {}

pub(crate) fn benchmark_metadata(extra: bool) -> (Vec<BenchmarkList>, Vec<StorageInfo>) {
let mut list = Vec::<BenchmarkList>::new();
Expand Down
8 changes: 0 additions & 8 deletions runtimes/peregrine/src/kilt/did/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,6 @@ impl did::traits::DidLifecycleHooks<Runtime> for DidLifecycleHooks {
type DeletionHook = EnsureNoNamesAndNoLinkedAccountsOnDidDeletion;
}

//TODO: Add proper docs for this.
pub(crate) trait DidDeletionHookBenchmarkWeightInfo {
fn read_web3_name() -> Weight;
fn read_dot_name() -> Weight;
fn read_web3_account() -> Weight;
fn read_dot_account() -> Weight;
}

// Since the trait is not `const`, we have unit tests that make sure this value
// matches what's contained in the respective weight file.
const WORST_CASE_WEB3_NAME_STORAGE_READ: Weight = Weight::from_parts(400_556_000, 0)
Expand Down
12 changes: 6 additions & 6 deletions runtimes/peregrine/src/kilt/did/tests/did_hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,41 @@

use crate::{
kilt::did::{
DidDeletionHookBenchmarkWeightInfo, WORST_CASE_DOT_NAME_LINKING_STORAGE_READ, WORST_CASE_DOT_NAME_STORAGE_READ,
WORST_CASE_DOT_NAME_LINKING_STORAGE_READ, WORST_CASE_DOT_NAME_STORAGE_READ,
WORST_CASE_WEB3_NAME_LINKING_STORAGE_READ, WORST_CASE_WEB3_NAME_STORAGE_READ,
},
weights::did_deletion_hooks,
weights::did_deletion_hooks::{self, WeightInfo},
Runtime,
};

#[test]
fn test_worst_case_web3_name_storage_read() {
assert_eq!(
WORST_CASE_WEB3_NAME_STORAGE_READ,
did_deletion_hooks::WeightInfo::<Runtime>::read_web3_name()
did_deletion_hooks::WeightsInfo::<Runtime>::read_web3_name()
);
}

#[test]
fn test_worst_case_dot_name_storage_read() {
assert_eq!(
WORST_CASE_DOT_NAME_STORAGE_READ,
did_deletion_hooks::WeightInfo::<Runtime>::read_dot_name()
did_deletion_hooks::WeightsInfo::<Runtime>::read_dot_name()
);
}

#[test]
fn test_worst_case_web3_name_linked_account_storage_read() {
assert_eq!(
WORST_CASE_WEB3_NAME_LINKING_STORAGE_READ,
did_deletion_hooks::WeightInfo::<Runtime>::read_web3_account()
did_deletion_hooks::WeightsInfo::<Runtime>::read_web3_account()
);
}

#[test]
fn test_worst_case_dot_name_linked_account_storage_read() {
assert_eq!(
WORST_CASE_DOT_NAME_LINKING_STORAGE_READ,
did_deletion_hooks::WeightInfo::<Runtime>::read_dot_account()
did_deletion_hooks::WeightsInfo::<Runtime>::read_dot_account()
);
}
Loading

0 comments on commit e7e4c72

Please sign in to comment.