From 0c56e4cc821c169ae1a7cc97be6644efbdaa10c3 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Tue, 14 Nov 2023 10:44:24 +0100 Subject: [PATCH 01/71] change trait for retrieve --- crates/kilt-dip-support/src/utils.rs | 7 +++++++ pallets/pallet-dip-provider/src/traits.rs | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/crates/kilt-dip-support/src/utils.rs b/crates/kilt-dip-support/src/utils.rs index 30d2d01d50..dd1ecc2662 100644 --- a/crates/kilt-dip-support/src/utils.rs +++ b/crates/kilt-dip-support/src/utils.rs @@ -16,6 +16,7 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org +use frame_support::weights::Weight; use pallet_dip_provider::traits::IdentityProvider; use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; @@ -133,6 +134,12 @@ where (_, _, Err(e)) => Err(CombineError::C(e)), } } + + fn get_retrieve_weight(identifier: &Identifier) -> Weight { + A::get_retrieve_weight(identifier) + .saturating_add(B::get_retrieve_weight(identifier)) + .saturating_add(C::get_retrieve_weight(identifier)) + } } pub type OutputOf = ::Output; diff --git a/pallets/pallet-dip-provider/src/traits.rs b/pallets/pallet-dip-provider/src/traits.rs index 52785c8ad0..0b8a874ad0 100644 --- a/pallets/pallet-dip-provider/src/traits.rs +++ b/pallets/pallet-dip-provider/src/traits.rs @@ -62,6 +62,7 @@ pub mod identity_generation { pub use identity_provision::*; pub mod identity_provision { + use frame_support::weights::Weight; use sp_std::marker::PhantomData; pub trait IdentityProvider { @@ -69,6 +70,8 @@ pub mod identity_provision { type Success; fn retrieve(identifier: &Identifier) -> Result, Self::Error>; + + fn get_retrieve_weight(identifier: &Identifier) -> Weight; } // Return the `Default` value if `Identity` adn `Details` both implement it. @@ -84,6 +87,10 @@ pub mod identity_provision { fn retrieve(_identifier: &Identifier) -> Result, Self::Error> { Ok(Some(Identity::default())) } + + fn get_retrieve_weight(_identifier: &Identifier) -> Weight { + Weight::zero() + } } // Always return `None`. Might be useful for tests. @@ -96,6 +103,10 @@ pub mod identity_provision { fn retrieve(_identifier: &Identifier) -> Result, Self::Error> { Ok(None) } + + fn get_retrieve_weight(_identifier: &Identifier) -> Weight { + Weight::zero() + } } } From 2df9776bac6bcfd22d287067bfd5046a3933faa2 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 15 Nov 2023 11:37:49 +0100 Subject: [PATCH 02/71] identity provider --- Cargo.lock | 1 + runtimes/common/Cargo.toml | 11 ++- runtimes/common/src/dip/benchmarks.rs | 106 ++++++++++++++++++++++++ runtimes/common/src/dip/did.rs | 17 +++- runtimes/common/src/dip/mod.rs | 4 + runtimes/common/src/dip/weights.rs | 113 ++++++++++++++++++++++++++ runtimes/peregrine/src/lib.rs | 2 + runtimes/spiritnet/src/lib.rs | 2 + 8 files changed, 252 insertions(+), 4 deletions(-) create mode 100644 runtimes/common/src/dip/benchmarks.rs create mode 100644 runtimes/common/src/dip/weights.rs diff --git a/Cargo.lock b/Cargo.lock index abcc85ce85..7d0d30099e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9860,6 +9860,7 @@ dependencies = [ "cumulus-pallet-xcmp-queue", "cumulus-primitives-core", "did", + "frame-benchmarking", "frame-support", "frame-system", "kilt-asset-dids", diff --git a/runtimes/common/Cargo.toml b/runtimes/common/Cargo.toml index 7134a22ed9..bf466fdf14 100644 --- a/runtimes/common/Cargo.toml +++ b/runtimes/common/Cargo.toml @@ -11,14 +11,14 @@ repository.workspace = true version.workspace = true [dev-dependencies] -sp-io = {workspace = true, features = ["std"]} +sp-io = { workspace = true, features = ["std"] } [dependencies] # External dependencies kilt-asset-dids.workspace = true log.workspace = true -parity-scale-codec = {workspace = true, features = ["derive"]} -scale-info = {workspace = true, features = ["derive"]} +parity-scale-codec = { workspace = true, features = ["derive"] } +scale-info = { workspace = true, features = ["derive"] } smallvec.workspace = true attestation.workspace = true @@ -50,6 +50,7 @@ sp-io.workspace = true sp-runtime.workspace = true sp-std.workspace = true sp-trie.workspace = true +frame-benchmarking = { workspace = true, optional = true } # Cumulus dependencies cumulus-primitives-core.workspace = true @@ -82,6 +83,8 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", + "did/runtime-benchmarks", ] std = [ "cumulus-pallet-parachain-system/std", @@ -122,6 +125,8 @@ std = [ "xcm-builder/std", "xcm-executor/std", "xcm/std", + "did/std", + "frame-benchmarking/std", ] try-runtime = [ "cumulus-pallet-parachain-system/try-runtime", diff --git a/runtimes/common/src/dip/benchmarks.rs b/runtimes/common/src/dip/benchmarks.rs new file mode 100644 index 0000000000..bc7d543463 --- /dev/null +++ b/runtimes/common/src/dip/benchmarks.rs @@ -0,0 +1,106 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + + +use did::{did_details::DidVerificationKey, DidIdentifierOf}; +use frame_benchmarking::v2::*; +use kilt_support::traits::GenerateBenchmarkOrigin; +use pallet_dip_provider::traits::IdentityProvider; +use sp_core::ed25519::Public; +use sp_io::crypto::ed25519_generate; +use sp_runtime::{traits::IdentifyAccount, KeyTypeId, MultiSigner}; +use frame_support::{traits::fungible::Mutate, BoundedVec }; +use pallet_balances::Pallet as BalancePallet; +use sp_runtime::SaturatedConversion; +use pallet_did_lookup::linkable_account::LinkableAccountId; + +use crate::{dip::did::{DidIdentityProvider, DidWeb3NameProvider, DidLinkedAccountsProvider}, constants::KILT}; + +const AUTHENTICATION_KEY_ID: KeyTypeId = KeyTypeId(*b"0000"); + + +pub trait Config: did::Config + frame_system::Config + pallet_balances::Config + pallet_web3_names::Config + pallet_did_lookup::Config {} +pub struct Pallet(did::Pallet); + +pub fn get_ed25519_public_authentication_key() -> Public { + ed25519_generate(AUTHENTICATION_KEY_ID, None) +} + +fn generate_web3_name_input(length: usize) -> Vec { + vec![b'1'; length] +} + +#[benchmarks(where + ::DidIdentifier: From, + ::AccountId: AsRef<[u8; 32]> + From<[u8; 32]> + Into, + ::AccountId: From, + T::OwnerOrigin: GenerateBenchmarkOrigin<::RuntimeOrigin, T::AccountId, T::Web3NameOwner>, + )] +pub mod benchmarks { + use super::{Config, Pallet, *}; + + #[benchmark] + fn retrieve_did() { + let submitter: ::AccountId = account("ALICE", 0, 0); + let amount = KILT * 10; + as Mutate>::set_balance(&submitter, amount.saturated_into()); + let authentication_key = get_ed25519_public_authentication_key(); + let did_public_auth_key = get_ed25519_public_authentication_key(); + let did_subject: DidIdentifierOf = MultiSigner::from(did_public_auth_key).into_account().into(); + let entry = did::mock_utils::generate_base_did_details::(DidVerificationKey::from(authentication_key), Some(submitter.clone())); + did::Pallet::::try_insert_did(did_subject.clone(), entry, submitter).expect("Inserting DID should not fail."); + + #[block] + { + DidIdentityProvider::::retrieve(&did_subject).expect("Retrieve DID should not fail."); + } + } + + #[benchmark] + fn retrieve_w3n() { + + let claimer: pallet_web3_names::AccountIdOf = account("ALICE", 0, 0); + let owner: ::Web3NameOwner = account("BOB", 0, 0); + let web3_name_input: BoundedVec = BoundedVec::try_from(generate_web3_name_input(5.saturated_into())).expect("BoundedVec creation should not fail."); + let origin_create = T::OwnerOrigin::generate_origin(claimer.clone(), owner.clone()); + let amount = KILT * 10; + as Mutate>::set_balance(&claimer, amount.saturated_into()); + pallet_web3_names::Pallet::::claim(origin_create, web3_name_input).expect("Claiming w3n should not fail."); + + #[block] + { + DidWeb3NameProvider::::retrieve(&owner).expect("Retrieve w3n should not fail."); + } + } + + #[benchmark] + fn retrieve_linked_accounts() { + let caller: T::AccountId = account("caller", 0, 0); + let linkable_id: LinkableAccountId = caller.clone().into(); + let did: ::DidIdentifier = account("did", 0, 0); + + let amount = KILT * 10; + as Mutate>::set_balance(&caller, amount.saturated_into()); + pallet_did_lookup::Pallet::::add_association(caller.clone(), did.clone(), linkable_id.clone()).expect("Inserting association should not fail."); + + #[block] + { + DidLinkedAccountsProvider::::retrieve(&did).expect("Retrieve linked accounts should not fail."); + } + } +} diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index f4255c438b..14d8e7066f 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -17,6 +17,7 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use did::did_details::DidDetails; +use frame_support::weights::Weight; use frame_system::pallet_prelude::BlockNumberFor; use kilt_dip_support::{ merkle::RevealedWeb3Name, @@ -28,7 +29,9 @@ use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_std::{marker::PhantomData, vec::Vec}; -#[derive(Encode, Decode, TypeInfo)] +use crate::dip::weights::{SubstrateWeight, WeightInfo}; + +#[derive(Encode, Decode, TypeInfo, Debug)] pub enum DidIdentityProviderError { DidNotFound, Internal, @@ -62,6 +65,10 @@ where _ => Err(DidIdentityProviderError::DidNotFound), } } + + fn get_retrieve_weight(_identifier: &T::DidIdentifier) -> Weight { + SubstrateWeight::::retrieve_did() + } } pub type Web3OwnershipOf = RevealedWeb3Name<::Web3Name, BlockNumberFor>; @@ -91,6 +98,10 @@ where claimed_at: details.claimed_at, })) } + + fn get_retrieve_weight(_identifier: &T::Web3NameOwner) -> Weight { + SubstrateWeight::::retrieve_w3n() + } } pub struct DidLinkedAccountsProvider(PhantomData); @@ -107,6 +118,10 @@ where pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(identifier).collect(), )) } + + fn get_retrieve_weight(_identifier: &T::DidIdentifier) -> Weight { + SubstrateWeight::::retrieve_linked_accounts() + } } pub type LinkedDidInfoProviderOf = diff --git a/runtimes/common/src/dip/mod.rs b/runtimes/common/src/dip/mod.rs index a3955297d6..c152ec2757 100644 --- a/runtimes/common/src/dip/mod.rs +++ b/runtimes/common/src/dip/mod.rs @@ -16,5 +16,9 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org +#[cfg(feature = "runtime-benchmarks")] +pub mod benchmarks; + pub mod did; pub mod merkle; +pub mod weights; diff --git a/runtimes/common/src/dip/weights.rs b/runtimes/common/src/dip/weights.rs new file mode 100644 index 0000000000..af0c082301 --- /dev/null +++ b/runtimes/common/src/dip/weights.rs @@ -0,0 +1,113 @@ + +//! Autogenerated weights for runtime_common +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-11-15 +//! STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/debug/kilt-parachain +// benchmark +// pallet +// --pallet +// runtime-common +// --extrinsic +// * +// --template +// ./.maintain/weight-template.hbs +// --output +// ./runtimes/common/src/dip/weights/did_provider.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 runtime_common. +pub trait WeightInfo { + fn retrieve_did() -> Weight; + fn retrieve_w3n() -> Weight; + fn retrieve_linked_accounts() -> Weight; +} + +/// Weights for runtime_common using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: `Did::Did` (r:1 w:0) + /// Proof: `Did::Did` (`max_values`: None, `max_size`: Some(2312), added: 4787, mode: `MaxEncodedLen`) + /// Storage: `Did::DidBlacklist` (r:1 w:0) + /// Proof: `Did::DidBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + fn retrieve_did() -> Weight { + // Proof Size summary in bytes: + // Measured: `352` + // Estimated: `5777` + // Minimum execution time: 85_802 nanoseconds. + Weight::from_parts(87_094_000, 5777) + .saturating_add(T::DbWeight::get().reads(2_u64)) + } + /// Storage: `Web3Names::Names` (r:1 w:0) + /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Owner` (r:1 w:0) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(137), added: 2612, mode: `MaxEncodedLen`) + fn retrieve_w3n() -> Weight { + // Proof Size summary in bytes: + // Measured: `219` + // Estimated: `3602` + // Minimum execution time: 91_390 nanoseconds. + Weight::from_parts(93_203_000, 3602) + .saturating_add(T::DbWeight::get().reads(2_u64)) + } + /// Storage: `DidLookup::ConnectedAccounts` (r:2 w:0) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + fn retrieve_linked_accounts() -> Weight { + // Proof Size summary in bytes: + // Measured: `241` + // Estimated: `6134` + // Minimum execution time: 91_911 nanoseconds. + Weight::from_parts(92_738_000, 6134) + .saturating_add(T::DbWeight::get().reads(2_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + /// Storage: `Did::Did` (r:1 w:0) + /// Proof: `Did::Did` (`max_values`: None, `max_size`: Some(2312), added: 4787, mode: `MaxEncodedLen`) + /// Storage: `Did::DidBlacklist` (r:1 w:0) + /// Proof: `Did::DidBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + fn retrieve_did() -> Weight { + // Proof Size summary in bytes: + // Measured: `352` + // Estimated: `5777` + // Minimum execution time: 85_802 nanoseconds. + Weight::from_parts(87_094_000, 5777) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + } + /// Storage: `Web3Names::Names` (r:1 w:0) + /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Owner` (r:1 w:0) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(137), added: 2612, mode: `MaxEncodedLen`) + fn retrieve_w3n() -> Weight { + // Proof Size summary in bytes: + // Measured: `219` + // Estimated: `3602` + // Minimum execution time: 91_390 nanoseconds. + Weight::from_parts(93_203_000, 3602) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + } + /// Storage: `DidLookup::ConnectedAccounts` (r:2 w:0) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + fn retrieve_linked_accounts() -> Weight { + // Proof Size summary in bytes: + // Measured: `241` + // Estimated: `6134` + // Minimum execution time: 91_911 nanoseconds. + Weight::from_parts(92_738_000, 6134) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + } +} diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index 9fc8776cd7..0a9522ab0a 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -1147,6 +1147,7 @@ mod benches { [pallet_xcm, PolkadotXcm] [pallet_migration, Migration] [frame_benchmarking::baseline, Baseline::] + [runtime_common, runtime_common::dip::benchmarks::Pallet::] ); } @@ -1443,6 +1444,7 @@ impl_runtime_apis! { impl frame_system_benchmarking::Config for Runtime {} impl cumulus_pallet_session_benchmarking::Config for Runtime {} impl frame_benchmarking::baseline::Config for Runtime {} + impl runtime_common::dip::benchmarks::Config for Runtime {} let whitelist: Vec = vec![ // Block Number diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index 8aab597733..f7bfe25ff8 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -1130,6 +1130,7 @@ mod benches { [pallet_xcm, PolkadotXcm] [pallet_migration, Migration] [frame_benchmarking::baseline, Baseline::] + [runtime_common, runtime_common::dip::benchmarks::Pallet::] ); } @@ -1426,6 +1427,7 @@ impl_runtime_apis! { impl frame_system_benchmarking::Config for Runtime {} impl cumulus_pallet_session_benchmarking::Config for Runtime {} impl frame_benchmarking::baseline::Config for Runtime {} + impl runtime_common::dip::benchmarks::Config for Runtime {} let whitelist: Vec = vec![ // Block Number From e1f186d4cec9d15e4e8a6c8a185faffa4fcf8911 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 15 Nov 2023 13:43:30 +0100 Subject: [PATCH 03/71] alter traits --- crates/kilt-dip-support/src/utils.rs | 1 + pallets/pallet-dip-provider/src/traits.rs | 7 +++++++ runtimes/common/src/dip/benchmarks.rs | 23 +++++++++++++++++++++-- runtimes/common/src/dip/merkle.rs | 6 +++++- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/crates/kilt-dip-support/src/utils.rs b/crates/kilt-dip-support/src/utils.rs index dd1ecc2662..ac04a6059c 100644 --- a/crates/kilt-dip-support/src/utils.rs +++ b/crates/kilt-dip-support/src/utils.rs @@ -22,6 +22,7 @@ use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_std::marker::PhantomData; +#[derive(Default)] pub struct CombinedIdentityResult { pub a: OutputA, pub b: OutputB, diff --git a/pallets/pallet-dip-provider/src/traits.rs b/pallets/pallet-dip-provider/src/traits.rs index 0b8a874ad0..a90bcb4c21 100644 --- a/pallets/pallet-dip-provider/src/traits.rs +++ b/pallets/pallet-dip-provider/src/traits.rs @@ -25,6 +25,7 @@ pub use identity_generation::*; pub mod identity_generation { use super::*; + use frame_support::weights::Weight; use sp_std::marker::PhantomData; pub trait IdentityCommitmentGenerator { @@ -36,6 +37,8 @@ pub mod identity_generation { identity: &Identity, version: IdentityCommitmentVersion, ) -> Result; + + fn get_generate_commitment_weight() -> Weight; } // Implement the `IdentityCommitmentGenerator` by returning the `Default` value @@ -57,6 +60,10 @@ pub mod identity_generation { ) -> Result { Ok(Output::default()) } + + fn get_generate_commitment_weight() -> Weight { + Weight::zero() + } } } diff --git a/runtimes/common/src/dip/benchmarks.rs b/runtimes/common/src/dip/benchmarks.rs index bc7d543463..8529ce0ca2 100644 --- a/runtimes/common/src/dip/benchmarks.rs +++ b/runtimes/common/src/dip/benchmarks.rs @@ -29,7 +29,7 @@ use pallet_balances::Pallet as BalancePallet; use sp_runtime::SaturatedConversion; use pallet_did_lookup::linkable_account::LinkableAccountId; -use crate::{dip::did::{DidIdentityProvider, DidWeb3NameProvider, DidLinkedAccountsProvider}, constants::KILT}; +use crate::{dip::{did::{DidIdentityProvider, DidWeb3NameProvider, DidLinkedAccountsProvider, LinkedDidInfoOf}, merkle::DidMerkleRootGenerator }, constants::KILT}; const AUTHENTICATION_KEY_ID: KeyTypeId = KeyTypeId(*b"0000"); @@ -52,7 +52,10 @@ fn generate_web3_name_input(length: usize) -> Vec { T::OwnerOrigin: GenerateBenchmarkOrigin<::RuntimeOrigin, T::AccountId, T::Web3NameOwner>, )] pub mod benchmarks { - use super::{Config, Pallet, *}; + +use pallet_dip_provider::IdentityCommitmentVersion; + +use super::{Config, Pallet, *}; #[benchmark] fn retrieve_did() { @@ -103,4 +106,20 @@ pub mod benchmarks { DidLinkedAccountsProvider::::retrieve(&did).expect("Retrieve linked accounts should not fail."); } } + + #[benchmark] + fn proof_generator() { + + let identity = LinkedDidInfoOf:: { + ..Default::default() + }; + + let version = 0; + + + #[block] + { + DidMerkleRootGenerator::::generate_proof(identity, version, key_ids, true, account_ids) + } + } } diff --git a/runtimes/common/src/dip/merkle.rs b/runtimes/common/src/dip/merkle.rs index d7af9c87b5..d40283f7d4 100644 --- a/runtimes/common/src/dip/merkle.rs +++ b/runtimes/common/src/dip/merkle.rs @@ -16,7 +16,7 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use did::{DidVerificationKeyRelationship, KeyIdOf}; -use frame_support::RuntimeDebug; +use frame_support::{pallet_prelude::Weight, RuntimeDebug}; use frame_system::pallet_prelude::BlockNumberFor; use kilt_dip_support::merkle::{DidKeyMerkleKey, DidKeyMerkleValue, DidMerkleProof}; use pallet_did_lookup::linkable_account::LinkableAccountId; @@ -357,6 +357,10 @@ where _ => Err(DidMerkleProofError::UnsupportedVersion), } } + + fn get_generate_commitment_weight() -> Weight { + Weight::zero() + } } impl DidMerkleRootGenerator From f20bebabc21a6b6fd2e218452704030cbbcc07d4 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 16 Nov 2023 14:21:17 +0100 Subject: [PATCH 04/71] compiling --- runtimes/common/src/dip/benchmarks.rs | 121 +++++++++++++++++++------- runtimes/common/src/dip/merkle.rs | 116 ++++++++++++++++-------- runtimes/common/src/dip/weights.rs | 43 ++++++--- 3 files changed, 199 insertions(+), 81 deletions(-) diff --git a/runtimes/common/src/dip/benchmarks.rs b/runtimes/common/src/dip/benchmarks.rs index 8529ce0ca2..fb0400d5fa 100644 --- a/runtimes/common/src/dip/benchmarks.rs +++ b/runtimes/common/src/dip/benchmarks.rs @@ -21,15 +21,16 @@ use did::{did_details::DidVerificationKey, DidIdentifierOf}; use frame_benchmarking::v2::*; use kilt_support::traits::GenerateBenchmarkOrigin; use pallet_dip_provider::traits::IdentityProvider; -use sp_core::ed25519::Public; +use sp_core::{ed25519::Public}; use sp_io::crypto::ed25519_generate; use sp_runtime::{traits::IdentifyAccount, KeyTypeId, MultiSigner}; -use frame_support::{traits::fungible::Mutate, BoundedVec }; +use frame_support::{traits::fungible::Mutate, BoundedVec}; use pallet_balances::Pallet as BalancePallet; use sp_runtime::SaturatedConversion; use pallet_did_lookup::linkable_account::LinkableAccountId; +use pallet_dip_provider::traits::IdentityCommitmentGenerator; -use crate::{dip::{did::{DidIdentityProvider, DidWeb3NameProvider, DidLinkedAccountsProvider, LinkedDidInfoOf}, merkle::DidMerkleRootGenerator }, constants::KILT}; +use crate::{dip::{did::{Web3OwnershipOf ,DidIdentityProvider, DidWeb3NameProvider, DidLinkedAccountsProvider, LinkedDidInfoOf}, merkle::DidMerkleRootGenerator }, constants::KILT}; const AUTHENTICATION_KEY_ID: KeyTypeId = KeyTypeId(*b"0000"); @@ -37,7 +38,34 @@ const AUTHENTICATION_KEY_ID: KeyTypeId = KeyTypeId(*b"0000"); pub trait Config: did::Config + frame_system::Config + pallet_balances::Config + pallet_web3_names::Config + pallet_did_lookup::Config {} pub struct Pallet(did::Pallet); -pub fn get_ed25519_public_authentication_key() -> Public { + +fn insert_w3n(owner: ::Web3NameOwner , claimer: pallet_web3_names::AccountIdOf ) + where + T: pallet_web3_names::Config + pallet_balances::Config, + T::OwnerOrigin: GenerateBenchmarkOrigin<::RuntimeOrigin, T::AccountId, T::Web3NameOwner> + { + let web3_name_input: BoundedVec = BoundedVec::try_from(generate_web3_name_input(5.saturated_into())).expect("BoundedVec creation should not fail."); + let origin_create = T::OwnerOrigin::generate_origin(claimer.clone(), owner.clone()); + let amount = KILT * 10; + as Mutate>::set_balance(&claimer, amount.saturated_into()); + pallet_web3_names::Pallet::::claim(origin_create, web3_name_input).expect("Claiming w3n should not fail."); +} + +fn insert_linked_acc(did: ::DidIdentifier, caller: T::AccountId ) + where + T: pallet_did_lookup::Config + pallet_balances::Config, + ::AccountId: AsRef<[u8; 32]> + From<[u8; 32]> + Into, +{ + + let linkable_id: LinkableAccountId = caller.clone().into(); + + let amount = KILT * 10; + as Mutate>::set_balance(&caller, amount.saturated_into()); + pallet_did_lookup::Pallet::::add_association(caller.clone(), did.clone(), linkable_id.clone()).expect("Inserting association should not fail."); +} + + +fn get_ed25519_public_authentication_key() -> Public { ed25519_generate(AUTHENTICATION_KEY_ID, None) } @@ -46,27 +74,31 @@ fn generate_web3_name_input(length: usize) -> Vec { } #[benchmarks(where - ::DidIdentifier: From, + ::DidIdentifier: From + + Into<::Web3NameOwner> + + Into<::DidIdentifier>, ::AccountId: AsRef<[u8; 32]> + From<[u8; 32]> + Into, ::AccountId: From, + ::Hash: From<[u8; 32]>, T::OwnerOrigin: GenerateBenchmarkOrigin<::RuntimeOrigin, T::AccountId, T::Web3NameOwner>, + sp_runtime::AccountId32: From<::DidIdentifier> )] pub mod benchmarks { -use pallet_dip_provider::IdentityCommitmentVersion; +use frame_system::pallet_prelude::BlockNumberFor; use super::{Config, Pallet, *}; #[benchmark] fn retrieve_did() { - let submitter: ::AccountId = account("ALICE", 0, 0); + let owner: ::AccountId = account("ALICE", 0, 0); let amount = KILT * 10; - as Mutate>::set_balance(&submitter, amount.saturated_into()); + as Mutate>::set_balance(&owner, amount.saturated_into()); let authentication_key = get_ed25519_public_authentication_key(); let did_public_auth_key = get_ed25519_public_authentication_key(); let did_subject: DidIdentifierOf = MultiSigner::from(did_public_auth_key).into_account().into(); - let entry = did::mock_utils::generate_base_did_details::(DidVerificationKey::from(authentication_key), Some(submitter.clone())); - did::Pallet::::try_insert_did(did_subject.clone(), entry, submitter).expect("Inserting DID should not fail."); + let entry = did::mock_utils::generate_base_did_details::(DidVerificationKey::from(authentication_key), Some(owner.clone())); + did::Pallet::::try_insert_did(did_subject.clone(), entry, owner).expect("Inserting DID should not fail."); #[block] { @@ -76,15 +108,9 @@ use super::{Config, Pallet, *}; #[benchmark] fn retrieve_w3n() { - - let claimer: pallet_web3_names::AccountIdOf = account("ALICE", 0, 0); - let owner: ::Web3NameOwner = account("BOB", 0, 0); - let web3_name_input: BoundedVec = BoundedVec::try_from(generate_web3_name_input(5.saturated_into())).expect("BoundedVec creation should not fail."); - let origin_create = T::OwnerOrigin::generate_origin(claimer.clone(), owner.clone()); - let amount = KILT * 10; - as Mutate>::set_balance(&claimer, amount.saturated_into()); - pallet_web3_names::Pallet::::claim(origin_create, web3_name_input).expect("Claiming w3n should not fail."); - + let claimer: pallet_web3_names::AccountIdOf = account("ALICE", 0, 0); + let owner: ::Web3NameOwner = account("BOB", 0, 0); + insert_w3n::(owner.clone(), claimer); #[block] { DidWeb3NameProvider::::retrieve(&owner).expect("Retrieve w3n should not fail."); @@ -93,13 +119,10 @@ use super::{Config, Pallet, *}; #[benchmark] fn retrieve_linked_accounts() { - let caller: T::AccountId = account("caller", 0, 0); - let linkable_id: LinkableAccountId = caller.clone().into(); - let did: ::DidIdentifier = account("did", 0, 0); - let amount = KILT * 10; - as Mutate>::set_balance(&caller, amount.saturated_into()); - pallet_did_lookup::Pallet::::add_association(caller.clone(), did.clone(), linkable_id.clone()).expect("Inserting association should not fail."); + let did: ::DidIdentifier = account("did", 0, 0); + let caller: T::AccountId = account("caller", 0, 0); + insert_linked_acc::(did.clone(), caller); #[block] { @@ -108,18 +131,54 @@ use super::{Config, Pallet, *}; } #[benchmark] - fn proof_generator() { + fn create_commitment() { - let identity = LinkedDidInfoOf:: { - ..Default::default() + // insert DID + let owner: ::AccountId = account("ALICE", 0, 0); + let amount = KILT * 10; + as Mutate>::set_balance(&owner, amount.saturated_into()); + let authentication_key = get_ed25519_public_authentication_key(); + let did_public_auth_key = get_ed25519_public_authentication_key(); + let did_subject: DidIdentifierOf = MultiSigner::from(did_public_auth_key).into_account().into(); + let entry = did::mock_utils::generate_base_did_details::(DidVerificationKey::from(authentication_key.clone()), Some(owner.clone())); + + // Todo. fill up with keys. + // let key: ::Hash = H256::from_slice(&[1;32]) .0.into(); + // entry.delegation_key = Some(key.clone()); + // entry.attestation_key = Some(key); + + + // TODO + // entry.key_agreement_keys = BoundedBTreeSet::try_from(vec![key]).expect("Did details setup should not fail."); + + did::Pallet::::try_insert_did(did_subject.clone(), entry.clone(), owner.clone()).expect("Inserting DID should not fail."); + + + // insert w3n + + insert_w3n::(did_subject.clone().into(), owner.clone()); + + // insert linked acc + insert_linked_acc::(did_subject.clone().into(), owner.clone()); + + + // prepare combined identity + let web3_name = pallet_web3_names::Pallet::::names::<::Web3NameOwner>(did_subject.clone().into()).expect("w3n should be in storage"); + let w3n_ownership = Web3OwnershipOf:: { + web3_name, + claimed_at: BlockNumberFor::::zero() }; + let identity = LinkedDidInfoOf:: { + a: Some(entry), + b: Some(w3n_ownership), + c: Some(vec![owner.into()]) + }; let version = 0; - - + #[block] { - DidMerkleRootGenerator::::generate_proof(identity, version, key_ids, true, account_ids) + DidMerkleRootGenerator::::generate_commitment(&did_subject.into(), &identity, version).expect("Generate commitment should not fail."); } } } diff --git a/runtimes/common/src/dip/merkle.rs b/runtimes/common/src/dip/merkle.rs index d40283f7d4..5a23907cdf 100644 --- a/runtimes/common/src/dip/merkle.rs +++ b/runtimes/common/src/dip/merkle.rs @@ -16,7 +16,7 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use did::{DidVerificationKeyRelationship, KeyIdOf}; -use frame_support::{pallet_prelude::Weight, RuntimeDebug}; +use frame_support::{ensure, pallet_prelude::Weight, RuntimeDebug}; use frame_system::pallet_prelude::BlockNumberFor; use kilt_dip_support::merkle::{DidKeyMerkleKey, DidKeyMerkleValue, DidMerkleProof}; use pallet_did_lookup::linkable_account::LinkableAccountId; @@ -56,6 +56,7 @@ pub enum DidMerkleProofError { LinkedAccountNotFound, Web3NameNotFound, Internal, + ExcessiveLinkedAccounts, } impl From for u16 { @@ -66,12 +67,17 @@ impl From for u16 { DidMerkleProofError::KeyNotFound => 2, DidMerkleProofError::LinkedAccountNotFound => 3, DidMerkleProofError::Web3NameNotFound => 4, + DidMerkleProofError::ExcessiveLinkedAccounts => 5, DidMerkleProofError::Internal => u16::MAX, } } } pub mod v0 { + use sp_trie::TrieDBMut; + + use crate::dip::did::Web3OwnershipOf; + use super::*; type ProofLeafOf = RevealedDidMerkleProofLeaf< @@ -81,6 +87,61 @@ pub mod v0 { ::Web3Name, LinkableAccountId, >; + pub(crate) fn insert_linked_accounts( + trie_builder: &mut TrieDBMut>, + linked_accounts: &Vec, + ) -> Result<(), DidMerkleProofError> + where + Runtime: did::Config + pallet_web3_names::Config, + { + linked_accounts + .iter() + .try_for_each(|linked_account| -> Result<(), DidMerkleProofError> { + let linked_account_leaf = + ProofLeafOf::::LinkedAccount(linked_account.clone().into(), ().into()); + trie_builder + .insert( + linked_account_leaf.encoded_key().as_slice(), + linked_account_leaf.encoded_value().as_slice(), + ) + .map_err(|_| { + log::error!( + "Failed to insert linked account in the trie builder. Linked account leaf: {:#?}", + linked_account_leaf + ); + DidMerkleProofError::Internal + })?; + Ok(()) + }) + } + + // Function to insert web3name into the trie builder + pub(crate) fn insert_web3name( + trie_builder: &mut TrieDBMut>, + web3name_details: &Web3OwnershipOf, + ) -> Result<(), DidMerkleProofError> + where + Runtime: did::Config + pallet_web3_names::Config, + { + let web3_name_leaf = ProofLeafOf::::Web3Name( + web3name_details.web3_name.clone().into(), + web3name_details.claimed_at.into(), + ); + trie_builder + .insert( + web3_name_leaf.encoded_key().as_slice(), + web3_name_leaf.encoded_value().as_slice(), + ) + .map_err(|_| { + log::error!( + "Failed to insert web3name in the trie builder. Web3name leaf: {:#?}", + web3_name_leaf + ); + DidMerkleProofError::Internal + })?; + + Ok(()) + } pub(super) fn calculate_root_with_db( identity: &LinkedDidInfoOf, @@ -104,6 +165,7 @@ pub mod v0 { log::error!("Authentication key should be part of the public keys."); DidMerkleProofError::Internal })?; + let auth_leaf = ProofLeafOf::::DidKey( DidKeyMerkleKey( did_details.authentication_key, @@ -187,45 +249,12 @@ pub mod v0 { // Linked accounts if let Some(linked_accounts) = linked_accounts { - linked_accounts - .iter() - .try_for_each(|linked_account| -> Result<(), DidMerkleProofError> { - let linked_account_leaf = - ProofLeafOf::::LinkedAccount(linked_account.clone().into(), ().into()); - trie_builder - .insert( - linked_account_leaf.encoded_key().as_slice(), - linked_account_leaf.encoded_value().as_slice(), - ) - .map_err(|_| { - log::error!( - "Failed to insert linked account in the trie builder. Linked account leaf: {:#?}", - linked_account_leaf - ); - DidMerkleProofError::Internal - })?; - Ok(()) - })?; + insert_linked_accounts::(&mut trie_builder, linked_accounts)?; } // Web3name, if present if let Some(web3name_details) = web3_name { - let web3_name_leaf = ProofLeafOf::::Web3Name( - web3name_details.web3_name.clone().into(), - web3name_details.claimed_at.into(), - ); - trie_builder - .insert( - web3_name_leaf.encoded_key().as_slice(), - web3_name_leaf.encoded_value().as_slice(), - ) - .map_err(|_| { - log::error!( - "Failed to insert web3name in the trie builder. Web3name leaf: {:#?}", - web3_name_leaf - ); - DidMerkleProofError::Internal - })?; + insert_web3name::(&mut trie_builder, web3name_details)?; } trie_builder.commit(); @@ -352,6 +381,13 @@ where identity: &LinkedDidInfoOf, version: IdentityCommitmentVersion, ) -> Result { + if let Some(linked_accounts) = &identity.c { + ensure!( + linked_accounts.len() < Self::MAX_LINKED_ACCOUNTS, + DidMerkleProofError::ExcessiveLinkedAccounts + ); + } + match version { 0 => v0::generate_commitment::(identity), _ => Err(DidMerkleProofError::UnsupportedVersion), @@ -384,3 +420,11 @@ where } } } + +pub trait MaxAccounts { + const MAX_LINKED_ACCOUNTS: usize; +} + +impl MaxAccounts for DidMerkleRootGenerator { + const MAX_LINKED_ACCOUNTS: usize = 25; +} diff --git a/runtimes/common/src/dip/weights.rs b/runtimes/common/src/dip/weights.rs index af0c082301..ee247c8c10 100644 --- a/runtimes/common/src/dip/weights.rs +++ b/runtimes/common/src/dip/weights.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for runtime_common //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-11-15 +//! DATE: 2023-11-16 //! STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` @@ -19,7 +19,7 @@ // --template // ./.maintain/weight-template.hbs // --output -// ./runtimes/common/src/dip/weights/did_provider.rs +// ./runtimes/common/src/dip/weights.rs #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] @@ -33,6 +33,7 @@ pub trait WeightInfo { fn retrieve_did() -> Weight; fn retrieve_w3n() -> Weight; fn retrieve_linked_accounts() -> Weight; + fn proof_generator() -> Weight; } /// Weights for runtime_common using the Substrate node and recommended hardware. @@ -46,8 +47,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `352` // Estimated: `5777` - // Minimum execution time: 85_802 nanoseconds. - Weight::from_parts(87_094_000, 5777) + // Minimum execution time: 85_981 nanoseconds. + Weight::from_parts(91_423_000, 5777) .saturating_add(T::DbWeight::get().reads(2_u64)) } /// Storage: `Web3Names::Names` (r:1 w:0) @@ -58,8 +59,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `219` // Estimated: `3602` - // Minimum execution time: 91_390 nanoseconds. - Weight::from_parts(93_203_000, 3602) + // Minimum execution time: 91_613 nanoseconds. + Weight::from_parts(95_186_000, 3602) .saturating_add(T::DbWeight::get().reads(2_u64)) } /// Storage: `DidLookup::ConnectedAccounts` (r:2 w:0) @@ -68,10 +69,17 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `241` // Estimated: `6134` - // Minimum execution time: 91_911 nanoseconds. - Weight::from_parts(92_738_000, 6134) + // Minimum execution time: 93_054 nanoseconds. + Weight::from_parts(98_463_000, 6134) .saturating_add(T::DbWeight::get().reads(2_u64)) } + fn proof_generator() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 84_192 nanoseconds. + Weight::from_parts(96_118_000, 0) + } } // For backwards compatibility and tests @@ -84,8 +92,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `352` // Estimated: `5777` - // Minimum execution time: 85_802 nanoseconds. - Weight::from_parts(87_094_000, 5777) + // Minimum execution time: 85_981 nanoseconds. + Weight::from_parts(91_423_000, 5777) .saturating_add(RocksDbWeight::get().reads(2_u64)) } /// Storage: `Web3Names::Names` (r:1 w:0) @@ -96,8 +104,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `219` // Estimated: `3602` - // Minimum execution time: 91_390 nanoseconds. - Weight::from_parts(93_203_000, 3602) + // Minimum execution time: 91_613 nanoseconds. + Weight::from_parts(95_186_000, 3602) .saturating_add(RocksDbWeight::get().reads(2_u64)) } /// Storage: `DidLookup::ConnectedAccounts` (r:2 w:0) @@ -106,8 +114,15 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `241` // Estimated: `6134` - // Minimum execution time: 91_911 nanoseconds. - Weight::from_parts(92_738_000, 6134) + // Minimum execution time: 93_054 nanoseconds. + Weight::from_parts(98_463_000, 6134) .saturating_add(RocksDbWeight::get().reads(2_u64)) } + fn proof_generator() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 84_192 nanoseconds. + Weight::from_parts(96_118_000, 0) + } } From fddc666046ff0187b848dab4b5ad561915eab17d Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 16 Nov 2023 16:36:58 +0100 Subject: [PATCH 05/71] runtime missing --- dip-template/runtimes/dip-provider/src/dip.rs | 2 +- runtimes/common/src/dip/benchmarks.rs | 47 +++++++------------ runtimes/common/src/dip/did.rs | 8 ++-- runtimes/common/src/dip/merkle.rs | 2 +- 4 files changed, 23 insertions(+), 36 deletions(-) diff --git a/dip-template/runtimes/dip-provider/src/dip.rs b/dip-template/runtimes/dip-provider/src/dip.rs index 91c52a8c1b..77a3bd3185 100644 --- a/dip-template/runtimes/dip-provider/src/dip.rs +++ b/dip-template/runtimes/dip-provider/src/dip.rs @@ -140,7 +140,7 @@ impl pallet_dip_provider::Config for Runtime { type CommitOrigin = DidRawOrigin; type Identifier = DidIdentifier; type IdentityCommitmentGenerator = DidMerkleRootGenerator; - type IdentityProvider = LinkedDidInfoProvider; + type IdentityProvider = LinkedDidInfoProvider; type ProviderHooks = deposit::DepositCollectorHooks; type RuntimeEvent = RuntimeEvent; } diff --git a/runtimes/common/src/dip/benchmarks.rs b/runtimes/common/src/dip/benchmarks.rs index 96bee13c4a..ee08442288 100644 --- a/runtimes/common/src/dip/benchmarks.rs +++ b/runtimes/common/src/dip/benchmarks.rs @@ -21,21 +21,22 @@ use did::{did_details::DidVerificationKey, DidIdentifierOf}; use frame_benchmarking::v2::*; use kilt_support::traits::GenerateBenchmarkOrigin; use pallet_dip_provider::traits::IdentityProvider; -use sp_core::{ed25519::Public}; +use sp_core::ed25519::Public; use sp_io::crypto::ed25519_generate; use sp_runtime::{traits::IdentifyAccount, KeyTypeId, MultiSigner}; use frame_support::{traits::fungible::Mutate, BoundedVec}; use pallet_balances::Pallet as BalancePallet; +use frame_system::pallet_prelude::BlockNumberFor; use sp_runtime::SaturatedConversion; use pallet_did_lookup::linkable_account::LinkableAccountId; use pallet_dip_provider::traits::IdentityCommitmentGenerator; -use crate::{dip::{did::{Web3OwnershipOf ,DidIdentityProvider, DidWeb3NameProvider, DidLinkedAccountsProvider, LinkedDidInfoOf}, merkle::DidMerkleRootGenerator }, constants::KILT}; +use crate::{dip::{did::{Web3OwnershipOf, LinkedDidInfoProvider, LinkedDidInfoOf}, merkle::DidMerkleRootGenerator }, constants::KILT}; const AUTHENTICATION_KEY_ID: KeyTypeId = KeyTypeId(*b"0000"); -pub trait Config: did::Config + frame_system::Config + pallet_balances::Config + pallet_web3_names::Config + pallet_did_lookup::Config {} +pub trait Config: did::Config + frame_system::Config + pallet_balances::Config + pallet_web3_names::Config + pallet_did_lookup::Config + pallet_dip_provider::Config {} pub struct Pallet(did::Pallet); @@ -81,11 +82,16 @@ fn generate_web3_name_input(length: usize) -> Vec { ::AccountId: From, ::Hash: From<[u8; 32]>, T::OwnerOrigin: GenerateBenchmarkOrigin<::RuntimeOrigin, T::AccountId, T::Web3NameOwner>, - sp_runtime::AccountId32: From<::DidIdentifier> + sp_runtime::AccountId32: From<::DidIdentifier>, + T: did::Config::Identifier> + + pallet_web3_names::Config::Identifier> + + pallet_did_lookup::Config::Identifier> + + pallet_dip_provider::Config, + T::IdentityProvider: IdentityProvider>, )] pub mod benchmarks { -use frame_system::pallet_prelude::BlockNumberFor; + use super::{Config, Pallet, *}; @@ -98,35 +104,16 @@ use super::{Config, Pallet, *}; let did_public_auth_key = get_ed25519_public_authentication_key(); let did_subject: DidIdentifierOf = MultiSigner::from(did_public_auth_key).into_account().into(); let entry = did::mock_utils::generate_base_did_details::(DidVerificationKey::from(authentication_key), Some(owner.clone())); - did::Pallet::::try_insert_did(did_subject.clone(), entry, owner).expect("Inserting DID should not fail."); - - #[block] - { - DidIdentityProvider::::retrieve(&did_subject).expect("Retrieve DID should not fail."); - } - } + did::Pallet::::try_insert_did(did_subject.clone(), entry, owner.clone()).expect("Inserting DID should not fail."); - #[benchmark] - fn retrieve_w3n() { - let claimer: pallet_web3_names::AccountIdOf = account("ALICE", 0, 0); - let owner: ::Web3NameOwner = account("BOB", 0, 0); - insert_w3n::(owner.clone(), claimer); - #[block] - { - DidWeb3NameProvider::::retrieve(&owner).expect("Retrieve w3n should not fail."); - } - } + insert_linked_acc::(did_subject.clone().into(), owner.clone()); - #[benchmark] - fn retrieve_linked_accounts() { + insert_w3n::(did_subject.clone().into(), owner); - let did: ::DidIdentifier = account("did", 0, 0); - let caller: T::AccountId = account("caller", 0, 0); - insert_linked_acc::(did.clone(), caller); - + #[block] { - DidLinkedAccountsProvider::::retrieve(&did).expect("Retrieve linked accounts should not fail."); + LinkedDidInfoProvider::::retrieve(&did_subject).expect("Retrieve DID should not fail."); } } @@ -174,7 +161,7 @@ use super::{Config, Pallet, *}; web3_name_details: Some(w3n_ownership), linked_accounts: vec![owner.into()] }; - + let version = 0; #[block] diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index e6ab5746e0..732ad82c45 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -24,11 +24,11 @@ use pallet_did_lookup::linkable_account::LinkableAccountId; use pallet_dip_provider::traits::IdentityProvider; use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; -use sp_std::vec::Vec; +use sp_std::{marker::PhantomData, vec::Vec}; use crate::dip::weights::{SubstrateWeight, WeightInfo}; -#[derive(Encode, Decode, TypeInfo)] +#[derive(Encode, Decode, TypeInfo, Debug)] pub enum LinkedDidInfoProviderError { DidNotFound, DidDeleted, @@ -57,9 +57,9 @@ where pub linked_accounts: Vec, } -pub struct LinkedDidInfoProvider; +pub struct LinkedDidInfoProvider(PhantomData); -impl IdentityProvider for LinkedDidInfoProvider +impl IdentityProvider for LinkedDidInfoProvider where Runtime: did::Config::Identifier> + pallet_web3_names::Config::Identifier> diff --git a/runtimes/common/src/dip/merkle.rs b/runtimes/common/src/dip/merkle.rs index e88675d108..b2a1c518a6 100644 --- a/runtimes/common/src/dip/merkle.rs +++ b/runtimes/common/src/dip/merkle.rs @@ -88,6 +88,7 @@ pub mod v0 { ::Web3Name, LinkableAccountId, >; + pub(crate) fn insert_linked_accounts( trie_builder: &mut TrieDBMut>, linked_accounts: &Vec, @@ -116,7 +117,6 @@ pub mod v0 { }) } - // Function to insert web3name into the trie builder pub(crate) fn insert_web3name( trie_builder: &mut TrieDBMut>, web3name_details: &Web3OwnershipOf, From 681dc7739598c4c283edd72a379a637eb226b9ae Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Fri, 17 Nov 2023 10:10:30 +0100 Subject: [PATCH 06/71] Clean up runtime-common Cargo.toml --- runtimes/common/Cargo.toml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/runtimes/common/Cargo.toml b/runtimes/common/Cargo.toml index bf466fdf14..02ce7df11f 100644 --- a/runtimes/common/Cargo.toml +++ b/runtimes/common/Cargo.toml @@ -11,14 +11,14 @@ repository.workspace = true version.workspace = true [dev-dependencies] -sp-io = { workspace = true, features = ["std"] } +sp-io = {workspace = true, features = ["std"]} [dependencies] # External dependencies kilt-asset-dids.workspace = true log.workspace = true -parity-scale-codec = { workspace = true, features = ["derive"] } -scale-info = { workspace = true, features = ["derive"] } +parity-scale-codec = {workspace = true, features = ["derive"]} +scale-info = {workspace = true, features = ["derive"]} smallvec.workspace = true attestation.workspace = true @@ -50,7 +50,6 @@ sp-io.workspace = true sp-runtime.workspace = true sp-std.workspace = true sp-trie.workspace = true -frame-benchmarking = { workspace = true, optional = true } # Cumulus dependencies cumulus-primitives-core.workspace = true @@ -61,10 +60,14 @@ xcm-builder.workspace = true xcm-executor.workspace = true xcm.workspace = true +# Benchmarking +frame-benchmarking = {workspace = true, optional = true} + [features] default = ["std"] fast-gov = [] runtime-benchmarks = [ + "did/runtime-benchmarks", "cumulus-pallet-parachain-system/runtime-benchmarks", "cumulus-pallet-xcmp-queue/runtime-benchmarks", "attestation/runtime-benchmarks", @@ -84,7 +87,6 @@ runtime-benchmarks = [ "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", - "did/runtime-benchmarks", ] std = [ "cumulus-pallet-parachain-system/std", @@ -125,7 +127,6 @@ std = [ "xcm-builder/std", "xcm-executor/std", "xcm/std", - "did/std", "frame-benchmarking/std", ] try-runtime = [ From 279d2410e468d6976468986d99acf5f2bd2c3f72 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Fri, 17 Nov 2023 13:37:30 +0100 Subject: [PATCH 07/71] DIP provider pallet benchmarks WIP --- Cargo.lock | 4 + pallets/pallet-dip-provider/Cargo.toml | 15 ++- .../pallet-dip-provider/src/benchmarking.rs | 59 +++++++++++ pallets/pallet-dip-provider/src/lib.rs | 5 + pallets/pallet-dip-provider/src/mock.rs | 100 ++++++++++++++++++ pallets/pallet-dip-provider/src/traits.rs | 11 ++ support/src/traits.rs | 16 ++- 7 files changed, 208 insertions(+), 2 deletions(-) create mode 100644 pallets/pallet-dip-provider/src/benchmarking.rs create mode 100644 pallets/pallet-dip-provider/src/mock.rs diff --git a/Cargo.lock b/Cargo.lock index 4e9b7aada6..55915fabb9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6509,10 +6509,14 @@ name = "pallet-dip-provider" version = "1.12.0-dev" dependencies = [ "did", + "frame-benchmarking", "frame-support", "frame-system", + "kilt-support", "parity-scale-codec", "scale-info", + "sp-io", + "sp-keystore", "sp-std", ] diff --git a/pallets/pallet-dip-provider/Cargo.toml b/pallets/pallet-dip-provider/Cargo.toml index 5e22e357a1..b88aa8cd69 100644 --- a/pallets/pallet-dip-provider/Cargo.toml +++ b/pallets/pallet-dip-provider/Cargo.toml @@ -13,6 +13,10 @@ version.workspace = true [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] +[dev-dependencies] +kilt-support = { workspace = true, features = ["mock", "std"] } +sp-io = { workspace = true, features = ["std"] } + [dependencies] did.workspace = true frame-support.workspace = true @@ -21,6 +25,11 @@ parity-scale-codec = {workspace = true, features = ["derive"]} scale-info = {workspace = true, features = ["derive"]} sp-std.workspace = true +# Benchmarks +frame-benchmarking = { workspace = true, optional = true } +kilt-support = { workspace = true, optional = true } +sp-keystore = { workspace = true, optional = true } + [features] default = ["std"] std = [ @@ -34,5 +43,9 @@ std = [ runtime-benchmarks = [ "did/runtime-benchmarks", "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks" + "frame-system/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", + "kilt-support/mock", + "kilt-support/runtime-benchmarks", + "sp-keystore" ] diff --git a/pallets/pallet-dip-provider/src/benchmarking.rs b/pallets/pallet-dip-provider/src/benchmarking.rs new file mode 100644 index 0000000000..6bb64048be --- /dev/null +++ b/pallets/pallet-dip-provider/src/benchmarking.rs @@ -0,0 +1,59 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use crate::{Call, Config, Pallet}; +use frame_benchmarking::v2::*; +use kilt_support::traits::{GenerateBenchmarkOrigin, Instanciate}; + +#[benchmarks( + where + T::CommitOriginCheck: GenerateBenchmarkOrigin, + T::AccountId: Instanciate, + T::Identifier: Instanciate, +)] +mod benchmarks { + use super::*; + + #[benchmark] + fn commit_identity() { + let submitter = T::AccountId::new(1); + let subject = T::Identifier::new(1); + let commitment_version = 0; + + assert!(Pallet::identity_commitments(&subject, commitment_version).is_none()); + + let origin: T::RuntimeOrigin = T::CommitOriginCheck::generate_origin(submitter, subject); + + #[extrinsic_call] + Pallet::commit_identity(origin, subject, Some(commitment_version)); + + assert!(Pallet::identity_commitments(&subject, commitment_version).is_some()); + } + + #[cfg(test)] + mod benchmarks_tests { + use crate::Pallet; + use frame_benchmarking::impl_benchmark_test_suite; + + impl_benchmark_test_suite!( + Pallet, + crate::mock::ExtBuilder::default().build_with_keystore(), + crate::mock::TestRuntime, + ); + } +} diff --git a/pallets/pallet-dip-provider/src/lib.rs b/pallets/pallet-dip-provider/src/lib.rs index 45ac1d34da..28ce28d701 100644 --- a/pallets/pallet-dip-provider/src/lib.rs +++ b/pallets/pallet-dip-provider/src/lib.rs @@ -22,6 +22,11 @@ pub mod traits; +#[cfg(feature = "runtime-benchmarks")] +mod benchmarking; +#[cfg(test)] +mod mock; + pub use crate::{ pallet::*, traits::{DefaultIdentityCommitmentGenerator, DefaultIdentityProvider, NoopHooks}, diff --git a/pallets/pallet-dip-provider/src/mock.rs b/pallets/pallet-dip-provider/src/mock.rs new file mode 100644 index 0000000000..873496a76f --- /dev/null +++ b/pallets/pallet-dip-provider/src/mock.rs @@ -0,0 +1,100 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{ + construct_runtime, + sp_runtime::{ + testing::H256, + traits::{BlakeTwo256, IdentityLookup}, + AccountId32, + }, + traits::{ConstU16, ConstU32, ConstU64, Everything}, +}; +use frame_system::mocking::MockBlock; +use kilt_support::mock::mock_origin::{self as mock_origin, DoubleOrigin, EnsureDoubleOrigin}; + +use crate::{DefaultIdentityCommitmentGenerator, DefaultIdentityProvider, NoopHooks}; + +construct_runtime!( + pub struct TestRuntime { + System: frame_system, + DipProvider: crate, + MockOrigin: mock_origin, + } +); + +impl frame_system::Config for TestRuntime { + type AccountData = (); + type AccountId = AccountId32; + type BaseCallFilter = Everything; + type Block = MockBlock; + type BlockHashCount = ConstU64<256>; + type BlockLength = (); + type BlockWeights = (); + type DbWeight = (); + type Hash = H256; + type Hashing = BlakeTwo256; + type Lookup = IdentityLookup; + type MaxConsumers = ConstU32<16>; + type Nonce = u64; + type OnKilledAccount = (); + type OnNewAccount = (); + type OnSetCode = (); + type PalletInfo = PalletInfo; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type SS58Prefix = ConstU16<1>; + type SystemWeightInfo = (); + type Version = (); +} + +impl crate::Config for TestRuntime { + type CommitOrigin = DoubleOrigin; + type CommitOriginCheck = EnsureDoubleOrigin; + type Identifier = AccountId32; + type IdentityCommitmentGenerator = DefaultIdentityCommitmentGenerator; + type IdentityProvider = DefaultIdentityProvider; + type ProviderHooks = NoopHooks; + type RuntimeEvent = RuntimeEvent; +} + +impl mock_origin::Config for TestRuntime { + type AccountId = ::AccountId; + type RuntimeOrigin = RuntimeOrigin; + type SubjectId = ::Identifier; +} + +#[derive(Default)] +pub(crate) struct ExtBuilder; + +impl ExtBuilder { + pub fn build(self) -> sp_io::TestExternalities { + sp_io::TestExternalities::default() + } + + #[cfg(feature = "runtime-benchmarks")] + pub fn build_with_keystore(self) -> sp_io::TestExternalities { + let mut ext = self.build(); + + let keystore = sp_keystore::testing::MemoryKeystore::new(); + ext.register_extension(sp_keystore::KeystoreExt(sp_std::sync::Arc::new(keystore))); + + ext + } +} diff --git a/pallets/pallet-dip-provider/src/traits.rs b/pallets/pallet-dip-provider/src/traits.rs index 43142ba83f..c988dece10 100644 --- a/pallets/pallet-dip-provider/src/traits.rs +++ b/pallets/pallet-dip-provider/src/traits.rs @@ -139,6 +139,17 @@ where } } +#[cfg(any(test, feature = "runtime-benchmarks"))] +impl SubmitterInfo for kilt_support::mock::mock_origin::DoubleOrigin +where + AccountId: Clone, +{ + type Submitter = AccountId; + fn submitter(&self) -> Self::Submitter { + self.0.clone() + } +} + pub trait ProviderHooks where Runtime: Config, diff --git a/support/src/traits.rs b/support/src/traits.rs index 2c2fa6a668..9b22a9fc80 100644 --- a/support/src/traits.rs +++ b/support/src/traits.rs @@ -20,7 +20,7 @@ use frame_support::traits::{ fungible::hold::Mutate, tokens::fungible::{Inspect, MutateHold}, }; -use sp_runtime::DispatchError; +use sp_runtime::{traits::BlakeTwo256, AccountId32, DispatchError}; use sp_std::vec::Vec; use crate::deposit::{free_deposit, reserve_deposit, Deposit}; @@ -85,6 +85,20 @@ pub trait GetWorstCase { fn worst_case() -> Self; } +/// Trait that allows instanciating multiple instances of a type. +#[cfg(feature = "runtime-benchmarks")] +pub trait Instanciate { + fn new(instance: u32) -> Self; +} + +#[cfg(feature = "runtime-benchmarks")] +impl Instanciate for AccountId32 { + fn new(instance: u32) -> Self { + use sp_runtime::traits::Hash; + AccountId32::from(<[u8; 32]>::from(BlakeTwo256::hash(&instance.to_be_bytes()))) + } +} + /// Generic filter. pub trait ItemFilter { fn should_include(&self, credential: &Item) -> bool; From 7fe35939c7e2d40d15954567488aae3d68593a1f Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Tue, 21 Nov 2023 14:14:45 +0100 Subject: [PATCH 08/71] intermediate state --- pallets/ctype/src/lib.rs | 2 +- pallets/pallet-dip-provider/Cargo.toml | 6 +- .../pallet-dip-provider/src/benchmarking.rs | 2 +- pallets/pallet-dip-provider/src/lib.rs | 1 + runtimes/common/src/dip/benchmarks.rs | 172 ------------------ runtimes/common/src/dip/merkle.rs | 55 ------ runtimes/common/src/dip/mod.rs | 4 - runtimes/common/src/dip/weights.rs | 128 ------------- runtimes/peregrine/src/lib.rs | 2 - runtimes/spiritnet/src/lib.rs | 4 +- 10 files changed, 8 insertions(+), 368 deletions(-) delete mode 100644 runtimes/common/src/dip/benchmarks.rs delete mode 100644 runtimes/common/src/dip/weights.rs diff --git a/pallets/ctype/src/lib.rs b/pallets/ctype/src/lib.rs index a4c27d8f6d..5936cd5587 100644 --- a/pallets/ctype/src/lib.rs +++ b/pallets/ctype/src/lib.rs @@ -94,7 +94,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config { - type EnsureOrigin: EnsureOrigin<::RuntimeOrigin, Success = Self::OriginSuccess>; + type EnsureOrigin: EnsureOrigin; type OverarchingOrigin: EnsureOrigin<::RuntimeOrigin>; type OriginSuccess: CallSources, CtypeCreatorOf>; type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/pallets/pallet-dip-provider/Cargo.toml b/pallets/pallet-dip-provider/Cargo.toml index b88aa8cd69..fe5c23cd11 100644 --- a/pallets/pallet-dip-provider/Cargo.toml +++ b/pallets/pallet-dip-provider/Cargo.toml @@ -21,8 +21,8 @@ sp-io = { workspace = true, features = ["std"] } did.workspace = true frame-support.workspace = true frame-system.workspace = true -parity-scale-codec = {workspace = true, features = ["derive"]} -scale-info = {workspace = true, features = ["derive"]} +parity-scale-codec = { workspace = true, features = ["derive"] } +scale-info = { workspace = true, features = ["derive"] } sp-std.workspace = true # Benchmarks @@ -47,5 +47,5 @@ runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "kilt-support/mock", "kilt-support/runtime-benchmarks", - "sp-keystore" + "sp-keystore", ] diff --git a/pallets/pallet-dip-provider/src/benchmarking.rs b/pallets/pallet-dip-provider/src/benchmarking.rs index 6bb64048be..370458d4ab 100644 --- a/pallets/pallet-dip-provider/src/benchmarking.rs +++ b/pallets/pallet-dip-provider/src/benchmarking.rs @@ -40,7 +40,7 @@ mod benchmarks { let origin: T::RuntimeOrigin = T::CommitOriginCheck::generate_origin(submitter, subject); #[extrinsic_call] - Pallet::commit_identity(origin, subject, Some(commitment_version)); + Pallet::::commit_identity(origin.into(), subject, Some(commitment_version)); assert!(Pallet::identity_commitments(&subject, commitment_version).is_some()); } diff --git a/pallets/pallet-dip-provider/src/lib.rs b/pallets/pallet-dip-provider/src/lib.rs index 28ce28d701..259109c7bd 100644 --- a/pallets/pallet-dip-provider/src/lib.rs +++ b/pallets/pallet-dip-provider/src/lib.rs @@ -24,6 +24,7 @@ pub mod traits; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; + #[cfg(test)] mod mock; diff --git a/runtimes/common/src/dip/benchmarks.rs b/runtimes/common/src/dip/benchmarks.rs deleted file mode 100644 index ee08442288..0000000000 --- a/runtimes/common/src/dip/benchmarks.rs +++ /dev/null @@ -1,172 +0,0 @@ -// KILT Blockchain – https://botlabs.org -// Copyright (C) 2019-2023 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 . - -// If you feel like getting in touch with us, you can do so at info@botlabs.org - - -use did::{did_details::DidVerificationKey, DidIdentifierOf}; -use frame_benchmarking::v2::*; -use kilt_support::traits::GenerateBenchmarkOrigin; -use pallet_dip_provider::traits::IdentityProvider; -use sp_core::ed25519::Public; -use sp_io::crypto::ed25519_generate; -use sp_runtime::{traits::IdentifyAccount, KeyTypeId, MultiSigner}; -use frame_support::{traits::fungible::Mutate, BoundedVec}; -use pallet_balances::Pallet as BalancePallet; -use frame_system::pallet_prelude::BlockNumberFor; -use sp_runtime::SaturatedConversion; -use pallet_did_lookup::linkable_account::LinkableAccountId; -use pallet_dip_provider::traits::IdentityCommitmentGenerator; - -use crate::{dip::{did::{Web3OwnershipOf, LinkedDidInfoProvider, LinkedDidInfoOf}, merkle::DidMerkleRootGenerator }, constants::KILT}; - -const AUTHENTICATION_KEY_ID: KeyTypeId = KeyTypeId(*b"0000"); - - -pub trait Config: did::Config + frame_system::Config + pallet_balances::Config + pallet_web3_names::Config + pallet_did_lookup::Config + pallet_dip_provider::Config {} -pub struct Pallet(did::Pallet); - - -fn insert_w3n(owner: ::Web3NameOwner , claimer: pallet_web3_names::AccountIdOf ) - where - T: pallet_web3_names::Config + pallet_balances::Config, - T::OwnerOrigin: GenerateBenchmarkOrigin<::RuntimeOrigin, T::AccountId, T::Web3NameOwner> - { - let web3_name_input: BoundedVec = BoundedVec::try_from(generate_web3_name_input(5.saturated_into())).expect("BoundedVec creation should not fail."); - let origin_create = T::OwnerOrigin::generate_origin(claimer.clone(), owner.clone()); - let amount = KILT * 10; - as Mutate>::set_balance(&claimer, amount.saturated_into()); - pallet_web3_names::Pallet::::claim(origin_create, web3_name_input).expect("Claiming w3n should not fail."); -} - -fn insert_linked_acc(did: ::DidIdentifier, caller: T::AccountId ) - where - T: pallet_did_lookup::Config + pallet_balances::Config, - ::AccountId: AsRef<[u8; 32]> + From<[u8; 32]> + Into, -{ - - let linkable_id: LinkableAccountId = caller.clone().into(); - - let amount = KILT * 10; - as Mutate>::set_balance(&caller, amount.saturated_into()); - pallet_did_lookup::Pallet::::add_association(caller.clone(), did.clone(), linkable_id.clone()).expect("Inserting association should not fail."); -} - - -fn get_ed25519_public_authentication_key() -> Public { - ed25519_generate(AUTHENTICATION_KEY_ID, None) -} - -fn generate_web3_name_input(length: usize) -> Vec { - vec![b'1'; length] -} - -#[benchmarks(where - ::DidIdentifier: From - + Into<::Web3NameOwner> - + Into<::DidIdentifier>, - ::AccountId: AsRef<[u8; 32]> + From<[u8; 32]> + Into, - ::AccountId: From, - ::Hash: From<[u8; 32]>, - T::OwnerOrigin: GenerateBenchmarkOrigin<::RuntimeOrigin, T::AccountId, T::Web3NameOwner>, - sp_runtime::AccountId32: From<::DidIdentifier>, - T: did::Config::Identifier> - + pallet_web3_names::Config::Identifier> - + pallet_did_lookup::Config::Identifier> - + pallet_dip_provider::Config, - T::IdentityProvider: IdentityProvider>, - )] -pub mod benchmarks { - - - -use super::{Config, Pallet, *}; - - #[benchmark] - fn retrieve_did() { - let owner: ::AccountId = account("ALICE", 0, 0); - let amount = KILT * 10; - as Mutate>::set_balance(&owner, amount.saturated_into()); - let authentication_key = get_ed25519_public_authentication_key(); - let did_public_auth_key = get_ed25519_public_authentication_key(); - let did_subject: DidIdentifierOf = MultiSigner::from(did_public_auth_key).into_account().into(); - let entry = did::mock_utils::generate_base_did_details::(DidVerificationKey::from(authentication_key), Some(owner.clone())); - did::Pallet::::try_insert_did(did_subject.clone(), entry, owner.clone()).expect("Inserting DID should not fail."); - - insert_linked_acc::(did_subject.clone().into(), owner.clone()); - - insert_w3n::(did_subject.clone().into(), owner); - - - #[block] - { - LinkedDidInfoProvider::::retrieve(&did_subject).expect("Retrieve DID should not fail."); - } - } - - #[benchmark] - fn create_commitment() { - - // insert DID - let owner: ::AccountId = account("ALICE", 0, 0); - let amount = KILT * 10; - as Mutate>::set_balance(&owner, amount.saturated_into()); - let authentication_key = get_ed25519_public_authentication_key(); - let did_public_auth_key = get_ed25519_public_authentication_key(); - let did_subject: DidIdentifierOf = MultiSigner::from(did_public_auth_key).into_account().into(); - let entry = did::mock_utils::generate_base_did_details::(DidVerificationKey::from(authentication_key.clone()), Some(owner.clone())); - - // Todo. fill up with keys. - // let key: ::Hash = H256::from_slice(&[1;32]) .0.into(); - // entry.delegation_key = Some(key.clone()); - // entry.attestation_key = Some(key); - - - // TODO - // entry.key_agreement_keys = BoundedBTreeSet::try_from(vec![key]).expect("Did details setup should not fail."); - - did::Pallet::::try_insert_did(did_subject.clone(), entry.clone(), owner.clone()).expect("Inserting DID should not fail."); - - - // insert w3n - - insert_w3n::(did_subject.clone().into(), owner.clone()); - - // insert linked acc - insert_linked_acc::(did_subject.clone().into(), owner.clone()); - - - // prepare combined identity - let web3_name = pallet_web3_names::Pallet::::names::<::Web3NameOwner>(did_subject.clone().into()).expect("w3n should be in storage"); - let w3n_ownership = Web3OwnershipOf:: { - web3_name, - claimed_at: BlockNumberFor::::zero() - }; - - let identity = LinkedDidInfoOf:: { - did_details: entry, - web3_name_details: Some(w3n_ownership), - linked_accounts: vec![owner.into()] - }; - - let version = 0; - - #[block] - { - DidMerkleRootGenerator::::generate_commitment(&did_subject.into(), &identity, version).expect("Generate commitment should not fail."); - } - } -} diff --git a/runtimes/common/src/dip/merkle.rs b/runtimes/common/src/dip/merkle.rs index b2a1c518a6..54800e669f 100644 --- a/runtimes/common/src/dip/merkle.rs +++ b/runtimes/common/src/dip/merkle.rs @@ -89,61 +89,6 @@ pub mod v0 { LinkableAccountId, >; - pub(crate) fn insert_linked_accounts( - trie_builder: &mut TrieDBMut>, - linked_accounts: &Vec, - ) -> Result<(), DidMerkleProofError> - where - Runtime: did::Config + pallet_web3_names::Config, - { - linked_accounts - .iter() - .try_for_each(|linked_account| -> Result<(), DidMerkleProofError> { - let linked_account_leaf = - ProofLeafOf::::LinkedAccount(linked_account.clone().into(), ().into()); - trie_builder - .insert( - linked_account_leaf.encoded_key().as_slice(), - linked_account_leaf.encoded_value().as_slice(), - ) - .map_err(|_| { - log::error!( - "Failed to insert linked account in the trie builder. Linked account leaf: {:#?}", - linked_account_leaf - ); - DidMerkleProofError::Internal - })?; - Ok(()) - }) - } - - pub(crate) fn insert_web3name( - trie_builder: &mut TrieDBMut>, - web3name_details: &Web3OwnershipOf, - ) -> Result<(), DidMerkleProofError> - where - Runtime: did::Config + pallet_web3_names::Config, - { - let web3_name_leaf = ProofLeafOf::::Web3Name( - web3name_details.web3_name.clone().into(), - web3name_details.claimed_at.into(), - ); - trie_builder - .insert( - web3_name_leaf.encoded_key().as_slice(), - web3_name_leaf.encoded_value().as_slice(), - ) - .map_err(|_| { - log::error!( - "Failed to insert web3name in the trie builder. Web3name leaf: {:#?}", - web3_name_leaf - ); - DidMerkleProofError::Internal - })?; - - Ok(()) - } - pub(super) fn calculate_root_with_db( identity: &LinkedDidInfoOf, db: &mut MemoryDB, diff --git a/runtimes/common/src/dip/mod.rs b/runtimes/common/src/dip/mod.rs index c152ec2757..a3955297d6 100644 --- a/runtimes/common/src/dip/mod.rs +++ b/runtimes/common/src/dip/mod.rs @@ -16,9 +16,5 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -#[cfg(feature = "runtime-benchmarks")] -pub mod benchmarks; - pub mod did; pub mod merkle; -pub mod weights; diff --git a/runtimes/common/src/dip/weights.rs b/runtimes/common/src/dip/weights.rs deleted file mode 100644 index ee247c8c10..0000000000 --- a/runtimes/common/src/dip/weights.rs +++ /dev/null @@ -1,128 +0,0 @@ - -//! Autogenerated weights for runtime_common -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-11-16 -//! STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! WORST CASE MAP SIZE: `1000000` -//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` -//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 - -// Executed Command: -// ./target/debug/kilt-parachain -// benchmark -// pallet -// --pallet -// runtime-common -// --extrinsic -// * -// --template -// ./.maintain/weight-template.hbs -// --output -// ./runtimes/common/src/dip/weights.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 runtime_common. -pub trait WeightInfo { - fn retrieve_did() -> Weight; - fn retrieve_w3n() -> Weight; - fn retrieve_linked_accounts() -> Weight; - fn proof_generator() -> Weight; -} - -/// Weights for runtime_common using the Substrate node and recommended hardware. -pub struct SubstrateWeight(PhantomData); -impl WeightInfo for SubstrateWeight { - /// Storage: `Did::Did` (r:1 w:0) - /// Proof: `Did::Did` (`max_values`: None, `max_size`: Some(2312), added: 4787, mode: `MaxEncodedLen`) - /// Storage: `Did::DidBlacklist` (r:1 w:0) - /// Proof: `Did::DidBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - fn retrieve_did() -> Weight { - // Proof Size summary in bytes: - // Measured: `352` - // Estimated: `5777` - // Minimum execution time: 85_981 nanoseconds. - Weight::from_parts(91_423_000, 5777) - .saturating_add(T::DbWeight::get().reads(2_u64)) - } - /// Storage: `Web3Names::Names` (r:1 w:0) - /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) - /// Storage: `Web3Names::Owner` (r:1 w:0) - /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(137), added: 2612, mode: `MaxEncodedLen`) - fn retrieve_w3n() -> Weight { - // Proof Size summary in bytes: - // Measured: `219` - // Estimated: `3602` - // Minimum execution time: 91_613 nanoseconds. - Weight::from_parts(95_186_000, 3602) - .saturating_add(T::DbWeight::get().reads(2_u64)) - } - /// Storage: `DidLookup::ConnectedAccounts` (r:2 w:0) - /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) - fn retrieve_linked_accounts() -> Weight { - // Proof Size summary in bytes: - // Measured: `241` - // Estimated: `6134` - // Minimum execution time: 93_054 nanoseconds. - Weight::from_parts(98_463_000, 6134) - .saturating_add(T::DbWeight::get().reads(2_u64)) - } - fn proof_generator() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 84_192 nanoseconds. - Weight::from_parts(96_118_000, 0) - } -} - -// For backwards compatibility and tests -impl WeightInfo for () { - /// Storage: `Did::Did` (r:1 w:0) - /// Proof: `Did::Did` (`max_values`: None, `max_size`: Some(2312), added: 4787, mode: `MaxEncodedLen`) - /// Storage: `Did::DidBlacklist` (r:1 w:0) - /// Proof: `Did::DidBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) - fn retrieve_did() -> Weight { - // Proof Size summary in bytes: - // Measured: `352` - // Estimated: `5777` - // Minimum execution time: 85_981 nanoseconds. - Weight::from_parts(91_423_000, 5777) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - } - /// Storage: `Web3Names::Names` (r:1 w:0) - /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) - /// Storage: `Web3Names::Owner` (r:1 w:0) - /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(137), added: 2612, mode: `MaxEncodedLen`) - fn retrieve_w3n() -> Weight { - // Proof Size summary in bytes: - // Measured: `219` - // Estimated: `3602` - // Minimum execution time: 91_613 nanoseconds. - Weight::from_parts(95_186_000, 3602) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - } - /// Storage: `DidLookup::ConnectedAccounts` (r:2 w:0) - /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) - fn retrieve_linked_accounts() -> Weight { - // Proof Size summary in bytes: - // Measured: `241` - // Estimated: `6134` - // Minimum execution time: 93_054 nanoseconds. - Weight::from_parts(98_463_000, 6134) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - } - fn proof_generator() -> Weight { - // Proof Size summary in bytes: - // Measured: `0` - // Estimated: `0` - // Minimum execution time: 84_192 nanoseconds. - Weight::from_parts(96_118_000, 0) - } -} diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index 0a9522ab0a..9fc8776cd7 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -1147,7 +1147,6 @@ mod benches { [pallet_xcm, PolkadotXcm] [pallet_migration, Migration] [frame_benchmarking::baseline, Baseline::] - [runtime_common, runtime_common::dip::benchmarks::Pallet::] ); } @@ -1444,7 +1443,6 @@ impl_runtime_apis! { impl frame_system_benchmarking::Config for Runtime {} impl cumulus_pallet_session_benchmarking::Config for Runtime {} impl frame_benchmarking::baseline::Config for Runtime {} - impl runtime_common::dip::benchmarks::Config for Runtime {} let whitelist: Vec = vec![ // Block Number diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index f7bfe25ff8..7488a96142 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -1130,7 +1130,7 @@ mod benches { [pallet_xcm, PolkadotXcm] [pallet_migration, Migration] [frame_benchmarking::baseline, Baseline::] - [runtime_common, runtime_common::dip::benchmarks::Pallet::] + ); } @@ -1427,7 +1427,7 @@ impl_runtime_apis! { impl frame_system_benchmarking::Config for Runtime {} impl cumulus_pallet_session_benchmarking::Config for Runtime {} impl frame_benchmarking::baseline::Config for Runtime {} - impl runtime_common::dip::benchmarks::Config for Runtime {} + let whitelist: Vec = vec![ // Block Number From 2ccadf5d3b8e52999576e1afa5eac9c34df58110 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Tue, 21 Nov 2023 14:55:50 +0100 Subject: [PATCH 09/71] compiling --- .../pallet-dip-provider/src/benchmarking.rs | 32 ++++++++++++++++--- pallets/pallet-dip-provider/src/traits.rs | 6 ---- runtimes/common/src/dip/did.rs | 7 ---- runtimes/common/src/dip/merkle.rs | 5 +-- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/pallets/pallet-dip-provider/src/benchmarking.rs b/pallets/pallet-dip-provider/src/benchmarking.rs index 370458d4ab..0524b1ca6a 100644 --- a/pallets/pallet-dip-provider/src/benchmarking.rs +++ b/pallets/pallet-dip-provider/src/benchmarking.rs @@ -34,15 +34,39 @@ mod benchmarks { let submitter = T::AccountId::new(1); let subject = T::Identifier::new(1); let commitment_version = 0; + // TODO insert worst case. Did with all keys. - assert!(Pallet::identity_commitments(&subject, commitment_version).is_none()); + assert!(Pallet::::identity_commitments(&subject, commitment_version).is_none()); - let origin: T::RuntimeOrigin = T::CommitOriginCheck::generate_origin(submitter, subject); + let origin: T::RuntimeOrigin = T::CommitOriginCheck::generate_origin(submitter, subject.clone()); #[extrinsic_call] - Pallet::::commit_identity(origin.into(), subject, Some(commitment_version)); + Pallet::::commit_identity(origin as T::RuntimeOrigin, subject.clone(), Some(commitment_version)); - assert!(Pallet::identity_commitments(&subject, commitment_version).is_some()); + assert!(Pallet::::identity_commitments(&subject, commitment_version).is_some()); + } + + #[benchmark] + fn delete_identity_commitment() { + let submitter = T::AccountId::new(1); + let subject = T::Identifier::new(1); + let commitment_version = 0; + + let origin: T::RuntimeOrigin = T::CommitOriginCheck::generate_origin(submitter, subject.clone()); + + Pallet::::commit_identity( + origin.clone() as T::RuntimeOrigin, + subject.clone(), + Some(commitment_version), + ) + .expect("Inserting Identity should not fail."); + + assert!(Pallet::::identity_commitments(&subject, commitment_version).is_some()); + + #[extrinsic_call] + Pallet::::delete_identity_commitment(origin as T::RuntimeOrigin, subject.clone(), Some(commitment_version)); + + assert!(Pallet::::identity_commitments(&subject, commitment_version).is_none()); } #[cfg(test)] diff --git a/pallets/pallet-dip-provider/src/traits.rs b/pallets/pallet-dip-provider/src/traits.rs index c988dece10..7e9ec41484 100644 --- a/pallets/pallet-dip-provider/src/traits.rs +++ b/pallets/pallet-dip-provider/src/traits.rs @@ -25,7 +25,6 @@ pub use identity_provision::*; pub mod identity_provision { use super::*; - use frame_support::weights::Weight; use sp_std::marker::PhantomData; pub trait IdentityProvider @@ -36,7 +35,6 @@ pub mod identity_provision { type Success; fn retrieve(identifier: &Runtime::Identifier) -> Result; - fn get_retrieve_weight() -> Weight; } // Return the `Default` value if `Identity` adn `Details` both implement it. @@ -53,10 +51,6 @@ pub mod identity_provision { fn retrieve(_identifier: &Runtime::Identifier) -> Result { Ok(Identity::default()) } - - fn get_retrieve_weight() -> Weight { - Weight::zero() - } } } diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index 732ad82c45..a2f8aec5eb 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -17,7 +17,6 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use did::did_details::DidDetails; -use frame_support::weights::Weight; use frame_system::pallet_prelude::BlockNumberFor; use kilt_dip_support::merkle::RevealedWeb3Name; use pallet_did_lookup::linkable_account::LinkableAccountId; @@ -26,8 +25,6 @@ use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_std::{marker::PhantomData, vec::Vec}; -use crate::dip::weights::{SubstrateWeight, WeightInfo}; - #[derive(Encode, Decode, TypeInfo, Debug)] pub enum LinkedDidInfoProviderError { DidNotFound, @@ -100,8 +97,4 @@ where linked_accounts, }) } - - fn get_retrieve_weight() -> Weight { - SubstrateWeight::::retrieve_linked_accounts() - } } diff --git a/runtimes/common/src/dip/merkle.rs b/runtimes/common/src/dip/merkle.rs index 54800e669f..d984afab63 100644 --- a/runtimes/common/src/dip/merkle.rs +++ b/runtimes/common/src/dip/merkle.rs @@ -16,7 +16,7 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use did::{DidVerificationKeyRelationship, KeyIdOf}; -use frame_support::{ensure, pallet_prelude::Weight, RuntimeDebug}; +use frame_support::{pallet_prelude::Weight, RuntimeDebug}; use frame_system::pallet_prelude::BlockNumberFor; use kilt_dip_support::merkle::{DidKeyMerkleKey, DidKeyMerkleValue, DidMerkleProof}; use pallet_did_lookup::linkable_account::LinkableAccountId; @@ -75,9 +75,6 @@ impl From for u16 { } pub mod v0 { - use sp_trie::TrieDBMut; - - use crate::dip::did::Web3OwnershipOf; use super::*; From 70431ef37a5fafcb46015e651fafa26c134c8f28 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Tue, 21 Nov 2023 17:24:28 +0100 Subject: [PATCH 10/71] std error with features --- Cargo.lock | 3 + pallets/pallet-dip-consumer/Cargo.toml | 19 +++- .../pallet-dip-consumer/src/benchmarking.rs | 73 +++++++++++++++ pallets/pallet-dip-consumer/src/lib.rs | 17 +++- pallets/pallet-dip-consumer/src/mock.rs | 90 +++++++++++++++++++ .../pallet-dip-provider/src/benchmarking.rs | 2 +- 6 files changed, 198 insertions(+), 6 deletions(-) create mode 100644 pallets/pallet-dip-consumer/src/benchmarking.rs create mode 100644 pallets/pallet-dip-consumer/src/mock.rs diff --git a/Cargo.lock b/Cargo.lock index 55915fabb9..9be819c711 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6495,12 +6495,15 @@ dependencies = [ name = "pallet-dip-consumer" version = "1.12.0-dev" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "kilt-support", "parity-scale-codec", "scale-info", "sp-core", + "sp-io", + "sp-keystore", "sp-std", ] diff --git a/pallets/pallet-dip-consumer/Cargo.toml b/pallets/pallet-dip-consumer/Cargo.toml index 5025ad90dd..d1ddf7fa45 100644 --- a/pallets/pallet-dip-consumer/Cargo.toml +++ b/pallets/pallet-dip-consumer/Cargo.toml @@ -17,13 +17,19 @@ targets = ["x86_64-unknown-linux-gnu"] frame-support.workspace = true frame-system.workspace = true kilt-support.workspace = true -parity-scale-codec = {workspace = true, features = ["derive"]} -scale-info = {workspace = true, features = ["derive"]} +parity-scale-codec = { workspace = true, features = ["derive"] } +scale-info = { workspace = true, features = ["derive"] } sp-core.workspace = true sp-std.workspace = true +# Benchmarks +sp-io = { workspace = true, optional = true } +sp-keystore = { workspace = true, optional = true } +frame-benchmarking = { workspace = true, optional = true } + [features] default = ["std"] + std = [ "frame-support/std", "frame-system/std", @@ -32,8 +38,17 @@ std = [ "scale-info/std", "sp-core/std", "sp-std/std", + "sp-io/std", + "sp-keystore/std", + "frame-benchmarking/std", ] + runtime-benchmarks = [ "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", + "sp-io", + "sp-keystore", + "frame-benchmarking/runtime-benchmarks", + "kilt-support/mock", + "kilt-support/runtime-benchmarks", ] diff --git a/pallets/pallet-dip-consumer/src/benchmarking.rs b/pallets/pallet-dip-consumer/src/benchmarking.rs new file mode 100644 index 0000000000..20a3e74f52 --- /dev/null +++ b/pallets/pallet-dip-consumer/src/benchmarking.rs @@ -0,0 +1,73 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use crate::{ + traits::{IdentityProofVerifier, SuccessfulProofVerifier}, + Config, IdentityEntries, Pallet, +}; +use frame_benchmarking::v2::*; +use frame_support::pallet_prelude::IsType; +use frame_system::RawOrigin; +use kilt_support::traits::Instanciate; + +#[benchmarks( + where + T::AccountId: Instanciate, + T::Identifier: Instanciate, + <::ProofVerifier as IdentityProofVerifier>::Proof: IsType<>::Proof>, + ::RuntimeCall: From> + +) ] +mod benchmarks { + + use super::*; + + #[benchmark] + fn commit_identity() { + let submitter = T::AccountId::new(1); + let subject = T::Identifier::new(1); + + assert!(IdentityEntries::::get(&subject).is_none()); + + let origin = RawOrigin::Signed(submitter); + + let call: ::RuntimeCall = frame_system::Call::::remark { remark: vec![] }.into(); + + let boxed_call = Box::from(call); + + #[block] + { + Pallet::::dispatch_as(origin.into(), subject.clone(), ().into(), boxed_call) + .expect("Dispatch_as should not fail."); + } + + // assert!(Pallet::::identity_commitments(&subject, commitment_version).is_some()); + } + + #[cfg(test)] + mod benchmarks_tests { + use crate::Pallet; + use frame_benchmarking::impl_benchmark_test_suite; + + impl_benchmark_test_suite!( + Pallet, + crate::mock::ExtBuilder::default().build_with_keystore(), + crate::mock::TestRuntime, + ); + } +} diff --git a/pallets/pallet-dip-consumer/src/lib.rs b/pallets/pallet-dip-consumer/src/lib.rs index e3a0a2133b..5d41d47777 100644 --- a/pallets/pallet-dip-consumer/src/lib.rs +++ b/pallets/pallet-dip-consumer/src/lib.rs @@ -23,6 +23,12 @@ pub mod identity; pub mod traits; +#[cfg(test)] +pub mod mock; + +#[cfg(feature = "runtime-benchmarks")] +pub mod benchmarking; + mod origin; pub use crate::{origin::*, pallet::*, traits::SuccessfulProofVerifier}; @@ -31,7 +37,12 @@ pub use crate::{origin::*, pallet::*, traits::SuccessfulProofVerifier}; pub mod pallet { use super::*; - use frame_support::{dispatch::Dispatchable, pallet_prelude::*, traits::Contains, Twox64Concat}; + use frame_support::{ + dispatch::{Dispatchable, GetDispatchInfo}, + pallet_prelude::*, + traits::Contains, + Twox64Concat, + }; use frame_system::pallet_prelude::*; use parity_scale_codec::{FullCodec, MaxEncodedLen}; use scale_info::TypeInfo; @@ -47,7 +58,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn identity_proofs)] - pub(crate) type IdentityEntries = + pub type IdentityEntries = StorageMap<_, Twox64Concat, ::Identifier, ::LocalIdentityInfo>; #[pallet::config] @@ -64,7 +75,7 @@ pub mod pallet { /// The logic of the proof verifier, called upon each execution of the /// `dispatch_as` extrinsic. type ProofVerifier: IdentityProofVerifier; - type RuntimeCall: Parameter + Dispatchable::RuntimeOrigin>; + type RuntimeCall: Parameter + Dispatchable::RuntimeOrigin> + GetDispatchInfo; type RuntimeOrigin: From> + From<::RuntimeOrigin>; } diff --git a/pallets/pallet-dip-consumer/src/mock.rs b/pallets/pallet-dip-consumer/src/mock.rs new file mode 100644 index 0000000000..ade402c711 --- /dev/null +++ b/pallets/pallet-dip-consumer/src/mock.rs @@ -0,0 +1,90 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{ + construct_runtime, + sp_runtime::{ + testing::H256, + traits::{BlakeTwo256, IdentityLookup}, + AccountId32, + }, + traits::{ConstU16, ConstU32, ConstU64, Everything}, +}; +use frame_system::{mocking::MockBlock, EnsureSigned}; + +use crate::{self as dip_consumer, traits::SuccessfulProofVerifier}; + +construct_runtime!( + pub struct TestRuntime { + System: frame_system, + DipConsumer: dip_consumer, + } +); + +impl frame_system::Config for TestRuntime { + type AccountData = (); + type AccountId = AccountId32; + type BaseCallFilter = Everything; + type Block = MockBlock; + type BlockHashCount = ConstU64<256>; + type BlockLength = (); + type BlockWeights = (); + type DbWeight = (); + type Hash = H256; + type Hashing = BlakeTwo256; + type Lookup = IdentityLookup; + type MaxConsumers = ConstU32<16>; + type Nonce = u64; + type OnKilledAccount = (); + type OnNewAccount = (); + type OnSetCode = (); + type PalletInfo = PalletInfo; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type SS58Prefix = ConstU16<1>; + type SystemWeightInfo = (); + type Version = (); +} + +impl crate::Config for TestRuntime { + type RuntimeOrigin = RuntimeOrigin; + type RuntimeCall = RuntimeCall; + type ProofVerifier = SuccessfulProofVerifier; + type LocalIdentityInfo = u128; + type Identifier = AccountId32; + type DispatchOriginCheck = EnsureSigned; + type DipCallOriginFilter = (); +} + +#[derive(Default)] +pub(crate) struct ExtBuilder; + +impl ExtBuilder { + pub fn build(self) -> sp_io::TestExternalities { + sp_io::TestExternalities::default() + } + + #[cfg(feature = "runtime-benchmarks")] + pub fn build_with_keystore(self) -> sp_io::TestExternalities { + let mut ext = self.build(); + let keystore = sp_keystore::testing::MemoryKeystore::new(); + ext.register_extension(sp_keystore::KeystoreExt(sp_std::sync::Arc::new(keystore))); + ext + } +} diff --git a/pallets/pallet-dip-provider/src/benchmarking.rs b/pallets/pallet-dip-provider/src/benchmarking.rs index 0524b1ca6a..c17a65e98b 100644 --- a/pallets/pallet-dip-provider/src/benchmarking.rs +++ b/pallets/pallet-dip-provider/src/benchmarking.rs @@ -34,7 +34,7 @@ mod benchmarks { let submitter = T::AccountId::new(1); let subject = T::Identifier::new(1); let commitment_version = 0; - // TODO insert worst case. Did with all keys. + // TODO insert worst case. Did with all keys, w3n and . assert!(Pallet::::identity_commitments(&subject, commitment_version).is_none()); From 538a2341b5bc34ede9f292024f125c5899782f39 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 22 Nov 2023 10:02:19 +0100 Subject: [PATCH 11/71] compiling --- Cargo.lock | 892 +++++++++++----------- pallets/pallet-dip-consumer/src/mock.rs | 4 +- pallets/pallet-dip-provider/src/mock.rs | 4 +- pallets/pallet-dip-provider/src/traits.rs | 7 - runtimes/common/src/dip/merkle.rs | 6 +- support/src/traits.rs | 5 +- 6 files changed, 467 insertions(+), 451 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9be819c711..ee0aad02c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -149,25 +149,26 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.11", "once_cell", "version_check", ] [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "91429305e9f0a25f6205c5b8e0d2db09e0708a7a6df0f42212bb56c32c8ac97a" dependencies = [ "cfg-if", - "getrandom 0.2.10", + "getrandom 0.2.11", "once_cell", "version_check", + "zerocopy", ] [[package]] @@ -280,9 +281,9 @@ checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" [[package]] name = "array-bytes" -version = "6.1.0" +version = "6.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b1c5a481ec30a5abd8dfbd94ab5cf1bb4e9a66be7f1b3b322f2f1170c200fd" +checksum = "de17a919934ad8c5cc99a1a74de4e2dab95d6121a8f27f94755ff525b630382c" [[package]] name = "arrayref" @@ -382,28 +383,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", - "event-listener", + "event-listener 2.5.3", "futures-core", ] [[package]] name = "async-io" -version = "1.13.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" +checksum = "41ed9d5715c2d329bf1b4da8d60455b99b187f27ba726df2883799af9af60997" dependencies = [ - "async-lock", - "autocfg", + "async-lock 3.1.1", "cfg-if", "concurrent-queue", + "futures-io", "futures-lite", - "log", "parking", "polling", - "rustix 0.37.25", + "rustix 0.38.25", "slab", - "socket2 0.4.9", + "tracing", "waker-fn", + "windows-sys 0.48.0", ] [[package]] @@ -412,7 +413,18 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" dependencies = [ - "event-listener", + "event-listener 2.5.3", +] + +[[package]] +name = "async-lock" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "655b9c7fe787d3b25cc0f804a1a8401790f0c5bc395beb5a64dc77d8de079105" +dependencies = [ + "event-listener 3.1.0", + "event-listener-strategy", + "pin-project-lite 0.2.13", ] [[package]] @@ -423,7 +435,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -434,7 +446,7 @@ checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -541,9 +553,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.4" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "base64ct" @@ -596,7 +608,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -751,9 +763,9 @@ checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bstr" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c79ad7fb2dd38f3dabd76b09c6a5a20c038fc0213ef1e9afd30eb777f120f019" +checksum = "542f33a8835a0884b006a0c3df3dadd99c0c3f296ed26c2fdc8028e01ad6230c" dependencies = [ "memchr", "serde", @@ -826,9 +838,9 @@ dependencies = [ [[package]] name = "cargo-platform" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12024c4645c97566567129c204f65d5815a8c9aecf30fcbe682b2fe034996d36" +checksum = "e34637b3140142bdf929fb439e8aa4ebad7651ebf7b1080b3930aa16ac1459ff" dependencies = [ "serde", ] @@ -900,25 +912,24 @@ checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" [[package]] name = "chacha20" -version = "0.8.2" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c80e5460aa66fe3b91d40bcbdab953a597b60053e34d684ac6903f863b680a6" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" dependencies = [ "cfg-if", - "cipher 0.3.0", + "cipher 0.4.4", "cpufeatures", - "zeroize", ] [[package]] name = "chacha20poly1305" -version = "0.9.1" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a18446b09be63d457bbec447509e85f662f32952b035ce892290396bc0b0cff5" +checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" dependencies = [ - "aead 0.4.3", + "aead 0.5.2", "chacha20", - "cipher 0.3.0", + "cipher 0.4.4", "poly1305", "zeroize", ] @@ -976,6 +987,7 @@ checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ "crypto-common", "inout", + "zeroize", ] [[package]] @@ -1000,9 +1012,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.6" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d04704f56c2cde07f43e8e2c154b43f216dc5c92fc98ada720177362f953b956" +checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" dependencies = [ "clap_builder", "clap_derive", @@ -1010,9 +1022,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.6" +version = "4.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e231faeaca65ebd1ea3c737966bf858971cd38c3849107aa3ea7de90a804e45" +checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" dependencies = [ "anstream", "anstyle", @@ -1022,27 +1034,27 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.2" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] name = "clap_lex" -version = "0.5.1" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "coarsetime" -version = "0.1.29" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a73ef0d00d14301df35d0f13f5ea32344de6b00837485c358458f1e7f2d27db4" +checksum = "71367d3385c716342014ad17e3d19f7788ae514885a1f4c24f500260fb365e1a" dependencies = [ "libc", "once_cell", @@ -1068,12 +1080,12 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "comfy-table" -version = "7.0.1" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ab77dbd8adecaf3f0db40581631b995f312a8a5ae3aa9993188bb8f23d83a5b" +checksum = "7c64043d6c7b7a4c58e39e7efccfdea7b93d885a795d0c054a69dbbf4dd52686" dependencies = [ - "strum", - "strum_macros", + "strum 0.25.0", + "strum_macros 0.25.3", "unicode-width", ] @@ -1113,23 +1125,21 @@ checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" [[package]] name = "const-random" -version = "0.1.15" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368a7a772ead6ce7e1de82bfb04c485f3db8ec744f72925af5735e29a22cc18e" +checksum = "5aaf16c9c2c612020bcfd042e170f6e32de9b9d75adb5277cdbbd2e2c8c8299a" dependencies = [ "const-random-macro", - "proc-macro-hack", ] [[package]] name = "const-random-macro" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d7d6ab3c3a2282db210df5f02c4dab6e0a7057af0fb7ebd4070f30fe05c0ddb" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.11", "once_cell", - "proc-macro-hack", "tiny-keccak", ] @@ -1191,9 +1201,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -1307,9 +1317,9 @@ dependencies = [ [[package]] name = "crc-catalog" -version = "2.2.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cace84e55f07e7301bae1c519df89cdad8cc3cd868413d3fdbdeca9ff3db484" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" [[package]] name = "crc32fast" @@ -1383,9 +1393,9 @@ dependencies = [ [[package]] name = "crypto-bigint" -version = "0.5.3" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "740fe28e594155f10cfc383984cbefd529d7396050557148f79cb0f621204124" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" dependencies = [ "generic-array 0.14.7", "rand_core 0.6.4", @@ -1737,7 +1747,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2044,20 +2054,20 @@ dependencies = [ [[package]] name = "curve25519-dalek-derive" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] name = "cxx" -version = "1.0.109" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c390c123d671cc547244943ecad81bdaab756c6ea332d9ca9c1f48d952a24895" +checksum = "7129e341034ecb940c9072817cd9007974ea696844fc4dd582dc1653a7fbe2e8" dependencies = [ "cc", "cxxbridge-flags", @@ -2067,9 +2077,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.109" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00d3d3ac9ffb900304edf51ca719187c779f4001bb544f26c4511d621de905cf" +checksum = "a2a24f3f5f8eed71936f21e570436f024f5c2e25628f7496aa7ccd03b90109d5" dependencies = [ "cc", "codespan-reporting", @@ -2077,24 +2087,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] name = "cxxbridge-flags" -version = "1.0.109" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94415827ecfea0f0c74c8cad7d1a86ddb3f05354d6a6ddeda0adee5e875d2939" +checksum = "06fdd177fc61050d63f67f5bd6351fac6ab5526694ea8e359cd9cd3b75857f44" [[package]] name = "cxxbridge-macro" -version = "1.0.109" +version = "1.0.110" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33dbbe9f5621c9247f97ec14213b04f350bff4b6cebefe834c60055db266ecf" +checksum = "587663dd5fb3d10932c8aecfe7c844db1bcf0aee93eeab08fac13dc1212c2e7f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2134,15 +2144,15 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2e66c9d817f1720209181c316d28635c050fa304f9c79e47a520882661b7308" +checksum = "7e962a19be5cfc3f3bf6dd8f61eb50107f356ad6270fbb3ed41476571db78be5" [[package]] name = "data-encoding-macro" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c904b33cc60130e1aeea4956ab803d08a3f4a0ca82d64ed757afac3891f2bb99" +checksum = "20c01c06f5f429efdf2bae21eb67c28b3df3cf85b7dd2d8ef09c0838dac5d33e" dependencies = [ "data-encoding", "data-encoding-macro-internal", @@ -2150,9 +2160,9 @@ dependencies = [ [[package]] name = "data-encoding-macro-internal" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fdf3fce3ce863539ec1d7fd1b6dcc3c645663376b43ed376bbf887733e4f772" +checksum = "0047d07f2c89b17dd631c80450d69841a6b5d7fb17278cbc43d7e4cfcf2576f3" dependencies = [ "data-encoding", "syn 1.0.109", @@ -2310,7 +2320,7 @@ name = "did" version = "1.12.0-dev" dependencies = [ "ctype", - "env_logger 0.10.0", + "env_logger 0.10.1", "fluent-uri", "frame-benchmarking", "frame-support", @@ -2617,7 +2627,7 @@ checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2641,7 +2651,7 @@ dependencies = [ "proc-macro2", "quote", "regex", - "syn 2.0.38", + "syn 2.0.39", "termcolor", "walkdir", ] @@ -2681,9 +2691,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.14" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d2f3407d9a573d666de4b5bdf10569d73ca9478087346697dcbae6244bfbcd" +checksum = "545b22097d44f8a9581187cdf93de7a71e4722bf51200cfaba810865b49a495d" [[package]] name = "ecdsa" @@ -2699,15 +2709,15 @@ dependencies = [ [[package]] name = "ecdsa" -version = "0.16.8" +version = "0.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4b1e0c257a9e9f25f90ff76d7a68360ed497ee519c8e428d1825ef0000799d4" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" dependencies = [ "der 0.7.8", "digest 0.10.7", - "elliptic-curve 0.13.6", + "elliptic-curve 0.13.8", "rfc6979 0.4.0", - "signature 2.1.0", + "signature 2.2.0", "spki 0.7.2", ] @@ -2727,7 +2737,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" dependencies = [ "pkcs8 0.10.2", - "signature 2.1.0", + "signature 2.2.0", ] [[package]] @@ -2744,15 +2754,16 @@ dependencies = [ [[package]] name = "ed25519-dalek" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" +checksum = "1f628eaec48bfd21b865dc2950cfa014450c01d2fa2b69a86c2fd5844ec523c0" dependencies = [ "curve25519-dalek 4.1.1", "ed25519 2.2.3", "rand_core 0.6.4", "serde", "sha2 0.10.8", + "subtle", "zeroize", ] @@ -2800,12 +2811,12 @@ dependencies = [ [[package]] name = "elliptic-curve" -version = "0.13.6" +version = "0.13.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d97ca172ae9dc9f9b779a6e3a65d308f2af74e5b8c921299075bdb4a0370e914" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" dependencies = [ "base16ct 0.2.0", - "crypto-bigint 0.5.3", + "crypto-bigint 0.5.5", "digest 0.10.7", "ff 0.13.0", "generic-array 0.14.7", @@ -2852,7 +2863,7 @@ checksum = "f95e2801cd355d4a1a3e3953ce6ee5ae9603a5c833455343a8bfe3f44d418246" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2863,7 +2874,7 @@ checksum = "c2ad8cef1d801a4686bfd8919f0b30eac4c8e48968c437a6405ded4fb5272d2b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2881,9 +2892,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.10.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85cdab6a89accf66733ad5a1693a4dcced6aeff64602b634530dd73c1f3ee9f0" +checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece" dependencies = [ "humantime", "is-terminal", @@ -2906,9 +2917,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860" +checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8" dependencies = [ "libc", "windows-sys 0.48.0", @@ -2920,6 +2931,27 @@ version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" +[[package]] +name = "event-listener" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite 0.2.13", +] + +[[package]] +name = "event-listener-strategy" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d96b852f1345da36d551b9473fa1e2b1eb5c5195585c6c018118bc92a8d91160" +dependencies = [ + "event-listener 3.1.0", + "pin-project-lite 0.2.13", +] + [[package]] name = "exit-future" version = "0.2.0" @@ -2963,7 +2995,7 @@ dependencies = [ "fs-err", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -2978,15 +3010,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" -[[package]] -name = "fastrand" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] - [[package]] name = "fastrand" version = "2.0.1" @@ -3049,9 +3072,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.2.1" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0870c84016d4b481be5c9f323c24f65e31e901ae618f0e80f4308fb00de1d2d" +checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" [[package]] name = "file-per-thread-logger" @@ -3059,7 +3082,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "84f2e425d9790201ba4af4630191feac6dcc98765b118d4d18e91d23c2353866" dependencies = [ - "env_logger 0.10.0", + "env_logger 0.10.1", "log", ] @@ -3248,7 +3271,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -3367,7 +3390,7 @@ dependencies = [ "proc-macro-warning", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -3379,7 +3402,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -3389,7 +3412,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948 dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -3449,9 +3472,12 @@ dependencies = [ [[package]] name = "fs-err" -version = "2.9.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0845fa252299212f0389d64ba26f34fa32cfe41588355f21ed507c59a0f64541" +checksum = "88a41f105fe1d5b6b34b2055e3dc59bb79b46b48b2040b9e6c7b4b5de097aa41" +dependencies = [ + "autocfg", +] [[package]] name = "fs2" @@ -3469,7 +3495,7 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" dependencies = [ - "rustix 0.38.19", + "rustix 0.38.25", "windows-sys 0.48.0", ] @@ -3481,9 +3507,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" +checksum = "da0290714b38af9b4a7b094b8a37086d1b4e61f2df9122c3cad2577669145335" dependencies = [ "futures-channel", "futures-core", @@ -3496,9 +3522,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb" dependencies = [ "futures-core", "futures-sink", @@ -3506,15 +3532,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" +checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c" [[package]] name = "futures-executor" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" +checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc" dependencies = [ "futures-core", "futures-task", @@ -3524,34 +3550,29 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" +checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa" [[package]] name = "futures-lite" -version = "1.13.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" +checksum = "d3831c2651acb5177cbd83943f3d9c8912c5ad03c76afcc0e9511ba568ec5ebb" dependencies = [ - "fastrand 1.9.0", "futures-core", - "futures-io", - "memchr", - "parking", "pin-project-lite 0.2.13", - "waker-fn", ] [[package]] name = "futures-macro" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" +checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -3567,15 +3588,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" +checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817" [[package]] name = "futures-task" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" +checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2" [[package]] name = "futures-timer" @@ -3585,9 +3606,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.28" +version = "0.3.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104" dependencies = [ "futures-channel", "futures-core", @@ -3653,9 +3674,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" +checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" dependencies = [ "cfg-if", "libc", @@ -3742,9 +3763,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.21" +version = "0.3.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" +checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178" dependencies = [ "bytes", "fnv", @@ -3752,7 +3773,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 1.9.3", + "indexmap 2.1.0", "slab", "tokio", "tokio-util", @@ -3761,9 +3782,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "4.4.0" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c39b3bc2a8f715298032cf5087e58573809374b08160aa7d750582bdb82d2683" +checksum = "faa67bab9ff362228eb3d00bd024a4965d8231bbb7921167f0cfa66c6626b225" dependencies = [ "log", "pest", @@ -3794,7 +3815,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.6", + "ahash 0.7.7", ] [[package]] @@ -3803,14 +3824,14 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", ] [[package]] name = "hashbrown" -version = "0.14.1" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" +checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" [[package]] name = "heck" @@ -3922,9 +3943,9 @@ dependencies = [ [[package]] name = "http" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb" dependencies = [ "bytes", "fnv", @@ -3983,7 +4004,7 @@ dependencies = [ "httpdate", "itoa", "pin-project-lite 0.2.13", - "socket2 0.4.9", + "socket2 0.4.10", "tokio", "tower-service", "tracing", @@ -3992,19 +4013,19 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d78e1e73ec14cf7375674f74d7dde185c8206fd9dea6fb6295e8a98098aaa97" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" dependencies = [ "futures-util", "http", "hyper", "log", - "rustls 0.21.7", + "rustls 0.21.9", "rustls-native-certs", "tokio", "tokio-rustls", - "webpki-roots 0.23.1", + "webpki-roots 0.25.2", ] [[package]] @@ -4059,19 +4080,19 @@ dependencies = [ [[package]] name = "if-addrs" -version = "0.7.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbc0fa01ffc752e9dbc72818cdb072cd028b86be5e09dd04c5a643704fe101a9" +checksum = "cabb0019d51a643781ff15c9c8a3e5dedc365c47211270f4e8f82812fedd8f0a" dependencies = [ "libc", - "winapi", + "windows-sys 0.48.0", ] [[package]] name = "if-watch" -version = "3.1.0" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb892e5777fe09e16f3d44de7802f4daa7267ecbe8c466f19d94e25bb0c303e" +checksum = "d6b0422c86d7ce0e97169cc42e04ae643caf278874a7a3c87b8150a220dc7e1e" dependencies = [ "async-io", "core-foundation", @@ -4128,12 +4149,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" dependencies = [ "equivalent", - "hashbrown 0.14.1", + "hashbrown 0.14.2", ] [[package]] @@ -4224,7 +4245,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" dependencies = [ - "socket2 0.5.4", + "socket2 0.5.5", "widestring", "windows-sys 0.48.0", "winreg", @@ -4232,9 +4253,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" @@ -4243,7 +4264,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi 0.3.3", - "rustix 0.38.19", + "rustix 0.38.25", "windows-sys 0.48.0", ] @@ -4282,9 +4303,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" +checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" dependencies = [ "wasm-bindgen", ] @@ -4333,7 +4354,7 @@ checksum = "2b5dde66c53d6dcdc8caea1874a45632ec0fcf5b437789f1e45766a1512ce803" dependencies = [ "anyhow", "arrayvec 0.7.4", - "async-lock", + "async-lock 2.8.0", "async-trait", "beef", "futures-channel", @@ -4435,13 +4456,13 @@ dependencies = [ [[package]] name = "k256" -version = "0.13.1" +version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cadb76004ed8e97623117f3df85b17aaa6626ab0b0831e6573f104df16cd1bcc" +checksum = "3f01b677d82ef7a676aa37e099defd83a28e15687112cafdd112d60236b6115b" dependencies = [ "cfg-if", - "ecdsa 0.16.8", - "elliptic-curve 0.13.6", + "ecdsa 0.16.9", + "elliptic-curve 0.13.8", "once_cell", "sha2 0.10.8", ] @@ -4846,9 +4867,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.149" +version = "0.2.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libloading" @@ -4869,7 +4890,7 @@ dependencies = [ "bytes", "futures", "futures-timer", - "getrandom 0.2.10", + "getrandom 0.2.11", "instant", "libp2p-allow-block-list", "libp2p-connection-limits", @@ -4989,7 +5010,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "276bb57e7af15d8f100d3c11cbdd32c6752b7eef4ba7a18ecf464972c07abcce" dependencies = [ "bs58", - "ed25519-dalek 2.0.0", + "ed25519-dalek 2.1.0", "log", "multiaddr", "multihash", @@ -5043,7 +5064,7 @@ dependencies = [ "log", "rand 0.8.5", "smallvec", - "socket2 0.4.9", + "socket2 0.4.10", "tokio", "trust-dns-proto", "void", @@ -5185,7 +5206,7 @@ dependencies = [ "libc", "libp2p-core", "log", - "socket2 0.4.9", + "socket2 0.4.10", "tokio", ] @@ -5285,6 +5306,17 @@ dependencies = [ "yamux", ] +[[package]] +name = "libredox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" +dependencies = [ + "bitflags 2.4.1", + "libc", + "redox_syscall 0.4.1", +] + [[package]] name = "librocksdb-sys" version = "0.11.0+8.1.1" @@ -5400,15 +5432,9 @@ checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" [[package]] name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - -[[package]] -name = "linux-raw-sys" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" +checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" [[package]] name = "lock_api" @@ -5491,7 +5517,7 @@ dependencies = [ "macro_magic_core", "macro_magic_macros", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -5505,7 +5531,7 @@ dependencies = [ "macro_magic_core_macros", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -5516,7 +5542,7 @@ checksum = "d710e1214dffbab3b5dacb21475dde7d6ed84c69ff722b3a47a782668d44fbac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -5527,7 +5553,7 @@ checksum = "b8fb85ec1620619edf2984a7693497d4ec88a9665d8b87e942856884c92dbf2a" dependencies = [ "macro_magic_core", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -5589,7 +5615,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" dependencies = [ - "rustix 0.38.19", + "rustix 0.38.25", ] [[package]] @@ -5677,9 +5703,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", "wasi 0.11.0+wasi-snapshot-preview1", @@ -6470,7 +6496,7 @@ version = "1.12.0-dev" dependencies = [ "base58", "blake2", - "env_logger 0.10.0", + "env_logger 0.10.1", "frame-benchmarking", "frame-support", "frame-system", @@ -6543,7 +6569,7 @@ dependencies = [ "sp-npos-elections", "sp-runtime", "sp-std", - "strum", + "strum 0.24.1", ] [[package]] @@ -6733,7 +6759,7 @@ dependencies = [ "ctype", "delegation", "did", - "env_logger 0.10.0", + "env_logger 0.10.1", "frame-benchmarking", "frame-support", "frame-system", @@ -7110,7 +7136,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -7662,9 +7688,9 @@ dependencies = [ [[package]] name = "pest" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c022f1e7b65d6a24c0dbbd5fb344c66881bc01f3e5ae74a1c8100f2f985d98a4" +checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" dependencies = [ "memchr", "thiserror", @@ -7673,9 +7699,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35513f630d46400a977c4cb58f78e1bfbe01434316e60c37d27b9ad6139c66d8" +checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" dependencies = [ "pest", "pest_generator", @@ -7683,22 +7709,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc9fc1b9e7057baba189b5c626e2d6f40681ae5b6eb064dc7c7834101ec8123a" +checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] name = "pest_meta" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df74e9e7ec4053ceb980e7c0c8bd3594e977fde1af91daba9c928e8e8c6708d" +checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" dependencies = [ "once_cell", "pest", @@ -7712,7 +7738,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.0.2", + "indexmap 2.1.0", ] [[package]] @@ -7732,7 +7758,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -7781,9 +7807,9 @@ checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "platforms" -version = "3.1.2" +version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4503fa043bf02cee09a9582e9554b4c6403b2ef55e4612e96561d294419429f8" +checksum = "14e6ab3f592e6fb464fc9712d8d6e6912de6473954635fd76a589d832cffcbb0" [[package]] name = "polkadot-approval-distribution" @@ -8400,7 +8426,7 @@ dependencies = [ "rand 0.8.5", "sc-authority-discovery", "sc-network", - "strum", + "strum 0.24.1", "thiserror", "tracing-gum", ] @@ -8973,29 +8999,27 @@ dependencies = [ [[package]] name = "polling" -version = "2.8.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" +checksum = "e53b6af1f60f36f8c2ac2aad5459d75a5a9b4be1e8cdd40264f315d78193e531" dependencies = [ - "autocfg", - "bitflags 1.3.2", "cfg-if", "concurrent-queue", - "libc", - "log", "pin-project-lite 0.2.13", + "rustix 0.38.25", + "tracing", "windows-sys 0.48.0", ] [[package]] name = "poly1305" -version = "0.7.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" dependencies = [ "cpufeatures", "opaque-debug 0.3.0", - "universal-hash 0.4.1", + "universal-hash 0.5.1", ] [[package]] @@ -9024,9 +9048,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.4.3" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b" +checksum = "3bccab0e7fd7cc19f820a1c8c91720af652d0c88dc9664dd72aef2614f04af3b" [[package]] name = "powerfmt" @@ -9087,7 +9111,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -9153,12 +9177,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "proc-macro-hack" -version = "0.5.20+deprecated" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" - [[package]] name = "proc-macro-warning" version = "0.4.2" @@ -9167,7 +9185,7 @@ checksum = "3d1eaa7fa0aa1929ffdf7eeb6eac234dde6268914a14ad44d23521ab6a9b258e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -9213,7 +9231,7 @@ checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -9430,7 +9448,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.11", ] [[package]] @@ -9531,12 +9549,12 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ - "getrandom 0.2.10", - "redox_syscall 0.2.16", + "getrandom 0.2.11", + "libredox", "thiserror", ] @@ -9570,7 +9588,7 @@ checksum = "7f7473c2cfcf90008193dd0e3e16599455cb601a9fce322b5bb55de799664925" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -9677,12 +9695,12 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.4" +version = "0.17.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce3045ffa7c981a6ee93f640b538952e155f1ae3a1a02b84547fc7a56b7059a" +checksum = "fb0205304757e5d899b9c2e448b867ffd03ae7f988002e47cd24954391394d0b" dependencies = [ "cc", - "getrandom 0.2.10", + "getrandom 0.2.11", "libc", "spin 0.9.8", "untrusted 0.9.0", @@ -9802,13 +9820,13 @@ dependencies = [ [[package]] name = "rpassword" -version = "7.2.0" +version = "7.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6678cf63ab3491898c0d021b493c94c9b221d91295294a2a5746eacbe5928322" +checksum = "80472be3c897911d0137b2d2b9055faf6eeac5b14e324073d83bc17b191d7e3f" dependencies = [ "libc", "rtoolbox", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -9839,12 +9857,12 @@ dependencies = [ [[package]] name = "rtoolbox" -version = "0.0.1" +version = "0.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "034e22c514f5c0cb8a10ff341b9b048b5ceb21591f31c8f44c43b960f9b3524a" +checksum = "c247d24e63230cdb56463ae328478bd5eac8b8faa8c69461a77e8e323afac90e" dependencies = [ "libc", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -9943,9 +9961,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.16" +version = "0.36.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6da3636faa25820d8648e0e31c5d519bbb01f72fdf57131f0f5f7da5fed36eab" +checksum = "305efbd14fde4139eb501df5f136994bb520b033fa9fbdce287507dc23b8c7ed" dependencies = [ "bitflags 1.3.2", "errno", @@ -9957,28 +9975,14 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4eb579851244c2c03e7c24f501c3432bed80b8f720af1d6e5b0e0f01555a035" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.8", - "windows-sys 0.48.0", -] - -[[package]] -name = "rustix" -version = "0.38.19" +version = "0.38.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "745ecfa778e66b2b63c88a61cb36e0eea109e803b0b86bf9879fbc77c70e86ed" +checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" dependencies = [ "bitflags 2.4.1", "errno", "libc", - "linux-raw-sys 0.4.10", + "linux-raw-sys 0.4.11", "windows-sys 0.48.0", ] @@ -10003,20 +10007,20 @@ checksum = "1b80e3dec595989ea8510028f30c408a4630db12c9cbb8de34203b89d6577e99" dependencies = [ "log", "ring 0.16.20", - "sct 0.7.0", + "sct 0.7.1", "webpki 0.22.4", ] [[package]] name = "rustls" -version = "0.21.7" +version = "0.21.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +checksum = "629648aced5775d558af50b2b4c7b02983a04b312126d45eeead26e7caa498b9" dependencies = [ "log", - "ring 0.16.20", - "rustls-webpki 0.101.6", - "sct 0.7.0", + "ring 0.17.5", + "rustls-webpki", + "sct 0.7.1", ] [[package]] @@ -10033,31 +10037,21 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", ] [[package]] name = "rustls-webpki" -version = "0.100.3" +version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f6a5fc258f1c1276dfe3016516945546e2d5383911efc0fc4f1cdc5df3a4ae3" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", -] - -[[package]] -name = "rustls-webpki" -version = "0.101.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" -dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", + "ring 0.17.5", + "untrusted 0.9.0", ] [[package]] @@ -10205,7 +10199,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -10482,7 +10476,7 @@ name = "sc-consensus-grandpa" version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", "array-bytes", "async-trait", "dyn-clone", @@ -10604,7 +10598,7 @@ dependencies = [ "cfg-if", "libc", "log", - "rustix 0.36.16", + "rustix 0.36.17", "sc-allocator", "sc-executor-common", "sp-runtime-interface", @@ -10725,7 +10719,7 @@ name = "sc-network-gossip" version = "0.10.0-dev" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", "futures", "futures-timer", "libp2p", @@ -11128,7 +11122,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -11190,9 +11184,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35c0a159d0c45c12b20c5a844feb1fe4bea86e28f17b92a5f0c42193634d3782" +checksum = "7f7d66a1128282b7ef025a8ead62a4a9fcf017382ec53b8ffbf4d7bf77bd3c60" dependencies = [ "bitvec", "cfg-if", @@ -11204,9 +11198,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "912e55f6d20e0e80d63733872b40e1227c0bce1e1ab81ba67d696339bfd7fd29" +checksum = "abf2c68b89cafb3b8d918dd07b42be0da66ff202cf1155c5739a4e0c1ea0dc19" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -11229,7 +11223,7 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "772575a524feeb803e5b0fcbc6dd9f367e579488197c94c6e4023aad2305774d" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", "cfg-if", "hashbrown 0.13.2", ] @@ -11276,12 +11270,12 @@ dependencies = [ [[package]] name = "sct" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", + "ring 0.17.5", + "untrusted 0.9.0", ] [[package]] @@ -11400,29 +11394,29 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.189" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.189" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -11431,9 +11425,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" dependencies = [ "serde", ] @@ -11544,9 +11538,9 @@ dependencies = [ [[package]] name = "signature" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" dependencies = [ "digest 0.10.7", "rand_core 0.6.4", @@ -11609,9 +11603,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.11.1" +version = "1.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" +checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "snap" @@ -11621,16 +11615,16 @@ checksum = "5e9f0ab6ef7eb7353d9119c170a436d1bf248eea575ac42d19d12f4e34130831" [[package]] name = "snow" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9d1425eb528a21de2755c75af4c9b5d57f50a0d4c3b7f1828a4cd03f8ba155" +checksum = "58021967fd0a5eeeb23b08df6cc244a4d4a5b4aec1d27c9e02fad1a58b4cd74e" dependencies = [ - "aes-gcm 0.9.4", + "aes-gcm 0.10.3", "blake2", "chacha20poly1305", "curve25519-dalek 4.1.1", "rand_core 0.6.4", - "ring 0.16.20", + "ring 0.17.5", "rustc_version", "sha2 0.10.8", "subtle", @@ -11638,9 +11632,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" dependencies = [ "libc", "winapi", @@ -11648,9 +11642,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" +checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", "windows-sys 0.48.0", @@ -11705,7 +11699,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -11844,7 +11838,7 @@ dependencies = [ "sp-mmr-primitives", "sp-runtime", "sp-std", - "strum", + "strum 0.24.1", ] [[package]] @@ -11942,7 +11936,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948 dependencies = [ "quote", "sp-core-hashing", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -11961,7 +11955,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948 dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -12022,7 +12016,7 @@ dependencies = [ "lazy_static", "sp-core", "sp-runtime", - "strum", + "strum 0.24.1", ] [[package]] @@ -12168,7 +12162,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -12310,7 +12304,7 @@ name = "sp-trie" version = "22.0.0" source = "git+https://github.com/paritytech/substrate?branch=polkadot-v1.0.0#948fbd2fd1233dc26dbb9f9bbc1d2cca2c03945d" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.6", "hash-db", "hashbrown 0.13.2", "lazy_static", @@ -12353,7 +12347,7 @@ dependencies = [ "parity-scale-codec", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -12398,13 +12392,13 @@ checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" [[package]] name = "spinners" -version = "4.1.0" +version = "4.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08615eea740067d9899969bc2891c68a19c315cb1f66640af9a9ecb91b13bcab" +checksum = "a0ef947f358b9c238923f764c72a4a9d42f2d637c46e059dbd319d6e7cfb4f82" dependencies = [ "lazy_static", "maplit", - "strum", + "strum 0.24.1", ] [[package]] @@ -12508,9 +12502,9 @@ dependencies = [ [[package]] name = "ss58-registry" -version = "1.43.0" +version = "1.44.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e6915280e2d0db8911e5032a5c275571af6bdded2916abd691a659be25d3439" +checksum = "35935738370302d5e33963665b77541e4b990a3e919ec904c837a56cfc891de1" dependencies = [ "Inflector", "num-format", @@ -12619,9 +12613,15 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" dependencies = [ - "strum_macros", + "strum_macros 0.24.3", ] +[[package]] +name = "strum" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "290d54ea6f91c969195bdbcd7442c8c2a2ba87da8bf60a7ee86a235d4bc1e125" + [[package]] name = "strum_macros" version = "0.24.3" @@ -12635,6 +12635,19 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "strum_macros" +version = "0.25.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.39", +] + [[package]] name = "stun" version = "0.4.4" @@ -12656,9 +12669,9 @@ dependencies = [ [[package]] name = "substrate-bip39" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49eee6965196b32f882dd2ee85a92b1dbead41b04e53907f269de3b0dc04733c" +checksum = "e620c7098893ba667438b47169c00aacdd9e7c10e042250ce2b60b087ec97328" dependencies = [ "hmac 0.11.0", "pbkdf2 0.8.0", @@ -12744,7 +12757,7 @@ dependencies = [ "filetime", "parity-wasm", "sp-maybe-compressed-blob", - "strum", + "strum 0.24.1", "tempfile", "toml 0.7.8", "walkdir", @@ -12779,9 +12792,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.38" +version = "2.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e96b79aaa137db8f61e26363a0c9b47d8b4ec75da28b7d1d614c2303e232408b" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" dependencies = [ "proc-macro2", "quote", @@ -12829,28 +12842,28 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.11" +version = "0.12.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d0e916b1148c8e263850e1ebcbd046f333e0683c724876bb0da63ea4373dc8a" +checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a" [[package]] name = "tempfile" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", - "fastrand 2.0.1", - "redox_syscall 0.3.5", - "rustix 0.38.19", + "fastrand", + "redox_syscall 0.4.1", + "rustix 0.38.25", "windows-sys 0.48.0", ] [[package]] name = "termcolor" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" +checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449" dependencies = [ "winapi-util", ] @@ -12869,27 +12882,27 @@ checksum = "f66edd6b6cd810743c0c71e1d085e92b01ce6a72782032e3f794c8284fe4bcdd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] name = "thiserror" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -13035,9 +13048,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.33.0" +version = "1.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f38200e3ef7995e5ef13baec2f432a6da0aa9ac495b2c0e8f3b7eec2c92d653" +checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" dependencies = [ "backtrace", "bytes", @@ -13047,20 +13060,20 @@ dependencies = [ "parking_lot 0.12.1", "pin-project-lite 0.2.13", "signal-hook-registry", - "socket2 0.5.4", + "socket2 0.5.5", "tokio-macros", "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" +checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -13080,7 +13093,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.7", + "rustls 0.21.9", "tokio", ] @@ -13098,9 +13111,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.9" +version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d68074620f57a0b21594d9735eb2e98ab38b17f80d3fcb189fca266771ca60d" +checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15" dependencies = [ "bytes", "futures-core", @@ -13134,9 +13147,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", ] @@ -13147,7 +13160,7 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.0.2", + "indexmap 2.1.0", "serde", "serde_spanned", "toml_datetime", @@ -13197,9 +13210,9 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.39" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2ef2af84856a50c1d430afce2fdded0a4ec7eda868db86409b4543df0797f9" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "log", "pin-project-lite 0.2.13", @@ -13215,7 +13228,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -13258,17 +13271,17 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] @@ -13345,7 +13358,7 @@ dependencies = [ "lazy_static", "rand 0.8.5", "smallvec", - "socket2 0.4.9", + "socket2 0.4.10", "thiserror", "tinyvec", "tokio", @@ -13572,11 +13585,11 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.4.1" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" +checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" dependencies = [ - "getrandom 0.2.10", + "getrandom 0.2.11", ] [[package]] @@ -13651,9 +13664,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" +checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -13661,24 +13674,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" +checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.37" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c02dbc21516f9f1f04f187958890d7e6026df8d16540b7ad9492bc34a67cea03" +checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" dependencies = [ "cfg-if", "js-sys", @@ -13688,9 +13701,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" +checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -13698,22 +13711,22 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" +checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.87" +version = "0.2.88" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" [[package]] name = "wasm-instrument" @@ -13732,8 +13745,8 @@ checksum = "87fef6d0d508f08334e0ab0e6877feb4c0ecb3956bcf2cb950699b22fedf3e9c" dependencies = [ "anyhow", "libc", - "strum", - "strum_macros", + "strum 0.24.1", + "strum_macros 0.24.3", "tempfile", "thiserror", "wasm-opt-cxx-sys", @@ -13833,12 +13846,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c86437fa68626fe896e5afc69234bb2b5894949083586535f200385adfd71213" dependencies = [ "anyhow", - "base64 0.21.4", + "base64 0.21.5", "bincode", "directories-next", "file-per-thread-logger", "log", - "rustix 0.36.16", + "rustix 0.36.17", "serde", "sha2 0.10.8", "toml 0.5.11", @@ -13934,7 +13947,7 @@ checksum = "6e0554b84c15a27d76281d06838aed94e13a77d7bf604bbbaf548aa20eb93846" dependencies = [ "object 0.30.4", "once_cell", - "rustix 0.36.16", + "rustix 0.36.17", ] [[package]] @@ -13965,7 +13978,7 @@ dependencies = [ "memoffset 0.8.0", "paste", "rand 0.8.5", - "rustix 0.36.16", + "rustix 0.36.17", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", @@ -13986,9 +13999,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.64" +version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b85cbef8c220a6abc02aefd892dfc0fc23afb1c6a426316ec33253a3877249b" +checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" dependencies = [ "js-sys", "wasm-bindgen", @@ -14010,7 +14023,7 @@ version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed63aea5ce73d0ff405984102c42de94fc55a6b75765d621c65262469b3c9b53" dependencies = [ - "ring 0.17.4", + "ring 0.17.5", "untrusted 0.9.0", ] @@ -14023,15 +14036,6 @@ dependencies = [ "webpki 0.22.4", ] -[[package]] -name = "webpki-roots" -version = "0.23.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" -dependencies = [ - "rustls-webpki 0.100.3", -] - [[package]] name = "webpki-roots" version = "0.25.2" @@ -14165,7 +14169,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f08dfd7a6e3987e255c4dbe710dde5d94d0f0574f8a21afa95d171376c143106" dependencies = [ "log", - "socket2 0.4.9", + "socket2 0.4.10", "thiserror", "tokio", "webrtc-util", @@ -14362,7 +14366,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.19", + "rustix 0.38.25", ] [[package]] @@ -14565,9 +14569,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.17" +version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3b801d0e0a6726477cc207f60162da452f3a95adb368399bef20a946e06f65c" +checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b" dependencies = [ "memchr", ] @@ -14717,7 +14721,7 @@ dependencies = [ "Inflector", "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] @@ -14743,11 +14747,31 @@ dependencies = [ "time", ] +[[package]] +name = "zerocopy" +version = "0.7.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] + [[package]] name = "zeroize" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" dependencies = [ "zeroize_derive", ] @@ -14760,7 +14784,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.38", + "syn 2.0.39", ] [[package]] diff --git a/pallets/pallet-dip-consumer/src/mock.rs b/pallets/pallet-dip-consumer/src/mock.rs index ade402c711..39ef758999 100644 --- a/pallets/pallet-dip-consumer/src/mock.rs +++ b/pallets/pallet-dip-consumer/src/mock.rs @@ -76,13 +76,13 @@ impl crate::Config for TestRuntime { pub(crate) struct ExtBuilder; impl ExtBuilder { - pub fn build(self) -> sp_io::TestExternalities { + pub fn _build(self) -> sp_io::TestExternalities { sp_io::TestExternalities::default() } #[cfg(feature = "runtime-benchmarks")] pub fn build_with_keystore(self) -> sp_io::TestExternalities { - let mut ext = self.build(); + let mut ext = self._build(); let keystore = sp_keystore::testing::MemoryKeystore::new(); ext.register_extension(sp_keystore::KeystoreExt(sp_std::sync::Arc::new(keystore))); ext diff --git a/pallets/pallet-dip-provider/src/mock.rs b/pallets/pallet-dip-provider/src/mock.rs index 873496a76f..0e6282847d 100644 --- a/pallets/pallet-dip-provider/src/mock.rs +++ b/pallets/pallet-dip-provider/src/mock.rs @@ -84,13 +84,13 @@ impl mock_origin::Config for TestRuntime { pub(crate) struct ExtBuilder; impl ExtBuilder { - pub fn build(self) -> sp_io::TestExternalities { + pub fn _build(self) -> sp_io::TestExternalities { sp_io::TestExternalities::default() } #[cfg(feature = "runtime-benchmarks")] pub fn build_with_keystore(self) -> sp_io::TestExternalities { - let mut ext = self.build(); + let mut ext = self._build(); let keystore = sp_keystore::testing::MemoryKeystore::new(); ext.register_extension(sp_keystore::KeystoreExt(sp_std::sync::Arc::new(keystore))); diff --git a/pallets/pallet-dip-provider/src/traits.rs b/pallets/pallet-dip-provider/src/traits.rs index 7e9ec41484..12efda455d 100644 --- a/pallets/pallet-dip-provider/src/traits.rs +++ b/pallets/pallet-dip-provider/src/traits.rs @@ -60,7 +60,6 @@ pub mod identity_generation { use crate::IdentityOf; - use frame_support::weights::Weight; use parity_scale_codec::{FullCodec, MaxEncodedLen}; use scale_info::TypeInfo; use sp_std::{fmt::Debug, marker::PhantomData}; @@ -78,8 +77,6 @@ pub mod identity_generation { identity: &IdentityOf, version: IdentityCommitmentVersion, ) -> Result; - - fn get_generate_commitment_weight(_identifier: &Runtime::Identifier) -> Weight; } // Implement the `IdentityCommitmentGenerator` by returning the `Default` value @@ -101,10 +98,6 @@ pub mod identity_generation { ) -> Result { Ok(Output::default()) } - - fn get_generate_commitment_weight(_identifier: &Runtime::Identifier) -> Weight { - Weight::zero() - } } } diff --git a/runtimes/common/src/dip/merkle.rs b/runtimes/common/src/dip/merkle.rs index d984afab63..d8ffeafea7 100644 --- a/runtimes/common/src/dip/merkle.rs +++ b/runtimes/common/src/dip/merkle.rs @@ -16,7 +16,7 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use did::{DidVerificationKeyRelationship, KeyIdOf}; -use frame_support::{pallet_prelude::Weight, RuntimeDebug}; +use frame_support::RuntimeDebug; use frame_system::pallet_prelude::BlockNumberFor; use kilt_dip_support::merkle::{DidKeyMerkleKey, DidKeyMerkleValue, DidMerkleProof}; use pallet_did_lookup::linkable_account::LinkableAccountId; @@ -359,10 +359,6 @@ where _ => Err(DidMerkleProofError::UnsupportedVersion), } } - - fn get_generate_commitment_weight(_identifier: &Runtime::Identifier) -> Weight { - Weight::zero() - } } impl DidMerkleRootGenerator diff --git a/support/src/traits.rs b/support/src/traits.rs index 9b22a9fc80..3455f849dc 100644 --- a/support/src/traits.rs +++ b/support/src/traits.rs @@ -20,9 +20,12 @@ use frame_support::traits::{ fungible::hold::Mutate, tokens::fungible::{Inspect, MutateHold}, }; -use sp_runtime::{traits::BlakeTwo256, AccountId32, DispatchError}; +use sp_runtime::DispatchError; use sp_std::vec::Vec; +#[cfg(feature = "runtime-benchmarks")] +use sp_runtime::{traits::BlakeTwo256, AccountId32}; + use crate::deposit::{free_deposit, reserve_deposit, Deposit}; /// The sources of a call struct. From cacf04c1b0bd4de33721a457935a526a7ba120a9 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 22 Nov 2023 11:10:39 +0100 Subject: [PATCH 12/71] remove stuff --- Cargo.lock | 2 +- pallets/pallet-dip-consumer/src/benchmarking.rs | 2 -- pallets/pallet-dip-consumer/src/lib.rs | 1 + pallets/pallet-dip-provider/Cargo.toml | 3 +++ pallets/pallet-dip-provider/src/benchmarking.rs | 9 ++++++--- pallets/pallet-dip-provider/src/traits.rs | 2 +- runtimes/common/Cargo.toml | 12 +++--------- runtimes/common/src/dip/did.rs | 6 +++--- runtimes/common/src/dip/merkle.rs | 10 ---------- support/src/traits.rs | 7 +++++++ 10 files changed, 25 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ee0aad02c0..4cf58b29f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6542,6 +6542,7 @@ dependencies = [ "frame-support", "frame-system", "kilt-support", + "pallet-did-lookup", "parity-scale-codec", "scale-info", "sp-io", @@ -9889,7 +9890,6 @@ dependencies = [ "cumulus-pallet-xcmp-queue", "cumulus-primitives-core", "did", - "frame-benchmarking", "frame-support", "frame-system", "kilt-asset-dids", diff --git a/pallets/pallet-dip-consumer/src/benchmarking.rs b/pallets/pallet-dip-consumer/src/benchmarking.rs index 20a3e74f52..642088d63b 100644 --- a/pallets/pallet-dip-consumer/src/benchmarking.rs +++ b/pallets/pallet-dip-consumer/src/benchmarking.rs @@ -55,8 +55,6 @@ mod benchmarks { Pallet::::dispatch_as(origin.into(), subject.clone(), ().into(), boxed_call) .expect("Dispatch_as should not fail."); } - - // assert!(Pallet::::identity_commitments(&subject, commitment_version).is_some()); } #[cfg(test)] diff --git a/pallets/pallet-dip-consumer/src/lib.rs b/pallets/pallet-dip-consumer/src/lib.rs index 5d41d47777..7a062ba299 100644 --- a/pallets/pallet-dip-consumer/src/lib.rs +++ b/pallets/pallet-dip-consumer/src/lib.rs @@ -127,6 +127,7 @@ pub mod pallet { details: proof_verification_result, }; // TODO: Use dispatch info for weight calculation + #[cfg(not(feature = "runtime-benchmark"))] let _ = call.dispatch(did_origin.into()).map_err(|e| e.error)?; Ok(()) } diff --git a/pallets/pallet-dip-provider/Cargo.toml b/pallets/pallet-dip-provider/Cargo.toml index fe5c23cd11..9bdbb17763 100644 --- a/pallets/pallet-dip-provider/Cargo.toml +++ b/pallets/pallet-dip-provider/Cargo.toml @@ -29,6 +29,7 @@ sp-std.workspace = true frame-benchmarking = { workspace = true, optional = true } kilt-support = { workspace = true, optional = true } sp-keystore = { workspace = true, optional = true } +pallet-did-lookup = { workspace = true, optional = true } [features] default = ["std"] @@ -48,4 +49,6 @@ runtime-benchmarks = [ "kilt-support/mock", "kilt-support/runtime-benchmarks", "sp-keystore", + "pallet-did-lookup", + ] diff --git a/pallets/pallet-dip-provider/src/benchmarking.rs b/pallets/pallet-dip-provider/src/benchmarking.rs index c17a65e98b..3928cc712a 100644 --- a/pallets/pallet-dip-provider/src/benchmarking.rs +++ b/pallets/pallet-dip-provider/src/benchmarking.rs @@ -16,17 +16,19 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use crate::{Call, Config, Pallet}; +use crate::{traits::IdentityProvider, Call, Config, Pallet}; use frame_benchmarking::v2::*; -use kilt_support::traits::{GenerateBenchmarkOrigin, Instanciate}; +use kilt_support::traits::{GenerateBenchmarkOrigin, GetWorstCase, Instanciate}; #[benchmarks( where T::CommitOriginCheck: GenerateBenchmarkOrigin, T::AccountId: Instanciate, T::Identifier: Instanciate, + <::IdentityProvider as IdentityProvider>::Success: GetWorstCase )] mod benchmarks { + use super::*; #[benchmark] @@ -34,12 +36,13 @@ mod benchmarks { let submitter = T::AccountId::new(1); let subject = T::Identifier::new(1); let commitment_version = 0; - // TODO insert worst case. Did with all keys, w3n and . assert!(Pallet::::identity_commitments(&subject, commitment_version).is_none()); let origin: T::RuntimeOrigin = T::CommitOriginCheck::generate_origin(submitter, subject.clone()); + <<::IdentityProvider as IdentityProvider>::Success as GetWorstCase>::worst_case(); + #[extrinsic_call] Pallet::::commit_identity(origin as T::RuntimeOrigin, subject.clone(), Some(commitment_version)); diff --git a/pallets/pallet-dip-provider/src/traits.rs b/pallets/pallet-dip-provider/src/traits.rs index 12efda455d..80af347d34 100644 --- a/pallets/pallet-dip-provider/src/traits.rs +++ b/pallets/pallet-dip-provider/src/traits.rs @@ -37,7 +37,7 @@ pub mod identity_provision { fn retrieve(identifier: &Runtime::Identifier) -> Result; } - // Return the `Default` value if `Identity` adn `Details` both implement it. + // Return the `Default` value if `Identity` and `Details` both implement it. pub struct DefaultIdentityProvider(PhantomData); impl IdentityProvider for DefaultIdentityProvider diff --git a/runtimes/common/Cargo.toml b/runtimes/common/Cargo.toml index 02ce7df11f..47cd4d1137 100644 --- a/runtimes/common/Cargo.toml +++ b/runtimes/common/Cargo.toml @@ -11,14 +11,14 @@ repository.workspace = true version.workspace = true [dev-dependencies] -sp-io = {workspace = true, features = ["std"]} +sp-io = { workspace = true, features = ["std"] } [dependencies] # External dependencies kilt-asset-dids.workspace = true log.workspace = true -parity-scale-codec = {workspace = true, features = ["derive"]} -scale-info = {workspace = true, features = ["derive"]} +parity-scale-codec = { workspace = true, features = ["derive"] } +scale-info = { workspace = true, features = ["derive"] } smallvec.workspace = true attestation.workspace = true @@ -60,14 +60,10 @@ xcm-builder.workspace = true xcm-executor.workspace = true xcm.workspace = true -# Benchmarking -frame-benchmarking = {workspace = true, optional = true} - [features] default = ["std"] fast-gov = [] runtime-benchmarks = [ - "did/runtime-benchmarks", "cumulus-pallet-parachain-system/runtime-benchmarks", "cumulus-pallet-xcmp-queue/runtime-benchmarks", "attestation/runtime-benchmarks", @@ -86,7 +82,6 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "frame-benchmarking/runtime-benchmarks", ] std = [ "cumulus-pallet-parachain-system/std", @@ -127,7 +122,6 @@ std = [ "xcm-builder/std", "xcm-executor/std", "xcm/std", - "frame-benchmarking/std", ] try-runtime = [ "cumulus-pallet-parachain-system/try-runtime", diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index a2f8aec5eb..7772107326 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -23,7 +23,7 @@ use pallet_did_lookup::linkable_account::LinkableAccountId; use pallet_dip_provider::traits::IdentityProvider; use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; -use sp_std::{marker::PhantomData, vec::Vec}; +use sp_std::vec::Vec; #[derive(Encode, Decode, TypeInfo, Debug)] pub enum LinkedDidInfoProviderError { @@ -54,9 +54,9 @@ where pub linked_accounts: Vec, } -pub struct LinkedDidInfoProvider(PhantomData); +pub struct LinkedDidInfoProvider; -impl IdentityProvider for LinkedDidInfoProvider +impl IdentityProvider for LinkedDidInfoProvider where Runtime: did::Config::Identifier> + pallet_web3_names::Config::Identifier> diff --git a/runtimes/common/src/dip/merkle.rs b/runtimes/common/src/dip/merkle.rs index d8ffeafea7..9c24a78055 100644 --- a/runtimes/common/src/dip/merkle.rs +++ b/runtimes/common/src/dip/merkle.rs @@ -58,7 +58,6 @@ pub enum DidMerkleProofError { LinkedAccountNotFound, Web3NameNotFound, Internal, - ExcessiveLinkedAccounts, } impl From for u16 { @@ -68,7 +67,6 @@ impl From for u16 { DidMerkleProofError::KeyNotFound => 1, DidMerkleProofError::LinkedAccountNotFound => 2, DidMerkleProofError::Web3NameNotFound => 3, - DidMerkleProofError::ExcessiveLinkedAccounts => 4, DidMerkleProofError::Internal => u16::MAX, } } @@ -382,11 +380,3 @@ where } } } - -pub trait MaxAccounts { - const MAX_LINKED_ACCOUNTS: usize; -} - -impl MaxAccounts for DidMerkleRootGenerator { - const MAX_LINKED_ACCOUNTS: usize = 25; -} diff --git a/support/src/traits.rs b/support/src/traits.rs index 3455f849dc..a42654da0a 100644 --- a/support/src/traits.rs +++ b/support/src/traits.rs @@ -88,6 +88,13 @@ pub trait GetWorstCase { fn worst_case() -> Self; } +#[cfg(feature = "runtime-benchmarks")] +impl GetWorstCase for u32 { + fn worst_case() -> Self { + u32::MAX + } +} + /// Trait that allows instanciating multiple instances of a type. #[cfg(feature = "runtime-benchmarks")] pub trait Instanciate { From 870f4246644a56ef5d20c286a91bcec040ac2504 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 22 Nov 2023 11:12:29 +0100 Subject: [PATCH 13/71] remove whitespaces --- runtimes/spiritnet/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index 7488a96142..8aab597733 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -1130,7 +1130,6 @@ mod benches { [pallet_xcm, PolkadotXcm] [pallet_migration, Migration] [frame_benchmarking::baseline, Baseline::] - ); } @@ -1428,7 +1427,6 @@ impl_runtime_apis! { impl cumulus_pallet_session_benchmarking::Config for Runtime {} impl frame_benchmarking::baseline::Config for Runtime {} - let whitelist: Vec = vec![ // Block Number hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac") From 22ccaad70c8913642ab9752682d1d431e15e3b72 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 22 Nov 2023 11:15:11 +0100 Subject: [PATCH 14/71] remove generic --- dip-template/runtimes/dip-provider/src/dip.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dip-template/runtimes/dip-provider/src/dip.rs b/dip-template/runtimes/dip-provider/src/dip.rs index 77a3bd3185..91c52a8c1b 100644 --- a/dip-template/runtimes/dip-provider/src/dip.rs +++ b/dip-template/runtimes/dip-provider/src/dip.rs @@ -140,7 +140,7 @@ impl pallet_dip_provider::Config for Runtime { type CommitOrigin = DidRawOrigin; type Identifier = DidIdentifier; type IdentityCommitmentGenerator = DidMerkleRootGenerator; - type IdentityProvider = LinkedDidInfoProvider; + type IdentityProvider = LinkedDidInfoProvider; type ProviderHooks = deposit::DepositCollectorHooks; type RuntimeEvent = RuntimeEvent; } From c8aed6f751d2167231c6884a747a045f730c0a4b Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 22 Nov 2023 11:41:12 +0100 Subject: [PATCH 15/71] feature error --- pallets/pallet-dip-consumer/src/benchmarking.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pallets/pallet-dip-consumer/src/benchmarking.rs b/pallets/pallet-dip-consumer/src/benchmarking.rs index 642088d63b..acdd444c0b 100644 --- a/pallets/pallet-dip-consumer/src/benchmarking.rs +++ b/pallets/pallet-dip-consumer/src/benchmarking.rs @@ -38,7 +38,7 @@ mod benchmarks { use super::*; #[benchmark] - fn commit_identity() { + fn dispatch_as() { let submitter = T::AccountId::new(1); let subject = T::Identifier::new(1); @@ -50,6 +50,7 @@ mod benchmarks { let boxed_call = Box::from(call); + // todo no into in block. #[block] { Pallet::::dispatch_as(origin.into(), subject.clone(), ().into(), boxed_call) From da6314d71940243e90d90f74e580bf4160e403ee Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 22 Nov 2023 16:28:40 +0100 Subject: [PATCH 16/71] feature error --- crates/kilt-dip-support/Cargo.toml | 7 ++++--- runtimes/common/Cargo.toml | 1 - 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/kilt-dip-support/Cargo.toml b/crates/kilt-dip-support/Cargo.toml index d9d6048840..1debed56e0 100644 --- a/crates/kilt-dip-support/Cargo.toml +++ b/crates/kilt-dip-support/Cargo.toml @@ -24,8 +24,8 @@ pallet-relay-store.workspace = true pallet-web3-names.workspace = true # Parity dependencies -parity-scale-codec = {workspace = true, features = ["derive"]} -scale-info = {workspace = true, features = ["derive"]} +parity-scale-codec = { workspace = true, features = ["derive"] } +scale-info = { workspace = true, features = ["derive"] } # Substrate dependencies frame-system.workspace = true @@ -81,5 +81,6 @@ std = [ ] runtime-benchmarks = [ "pallet-dip-consumer/runtime-benchmarks", - "rococo-runtime/runtime-benchmarks" + "rococo-runtime/runtime-benchmarks", + "pallet-dip-provider/runtime-benchmarks", ] diff --git a/runtimes/common/Cargo.toml b/runtimes/common/Cargo.toml index 47cd4d1137..8fcf7a24b4 100644 --- a/runtimes/common/Cargo.toml +++ b/runtimes/common/Cargo.toml @@ -71,7 +71,6 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "kilt-dip-support/runtime-benchmarks", "kilt-support/runtime-benchmarks", - "kilt-dip-support/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-membership/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", From 57066385ed96b7708dfac24a289553bb80fe794e Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 22 Nov 2023 16:38:39 +0100 Subject: [PATCH 17/71] with working features --- Cargo.lock | 4 +++- pallets/pallet-dip-consumer/Cargo.toml | 16 ++++++++------- pallets/pallet-dip-provider/Cargo.toml | 28 ++++++++++++++++---------- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4cf58b29f1..2ef5f3f79f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6530,6 +6530,7 @@ dependencies = [ "sp-core", "sp-io", "sp-keystore", + "sp-runtime", "sp-std", ] @@ -6542,11 +6543,12 @@ dependencies = [ "frame-support", "frame-system", "kilt-support", - "pallet-did-lookup", "parity-scale-codec", "scale-info", + "sp-core", "sp-io", "sp-keystore", + "sp-runtime", "sp-std", ] diff --git a/pallets/pallet-dip-consumer/Cargo.toml b/pallets/pallet-dip-consumer/Cargo.toml index d1ddf7fa45..5fb579f91f 100644 --- a/pallets/pallet-dip-consumer/Cargo.toml +++ b/pallets/pallet-dip-consumer/Cargo.toml @@ -13,6 +13,11 @@ version.workspace = true [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] +[dev-dependencies] +sp-keystore = { workspace = true, features = ["std"] } +sp-io = { workspace = true, features = ["std"] } +kilt-support = { workspace = true, features = ["mock", "try-runtime"] } + [dependencies] frame-support.workspace = true frame-system.workspace = true @@ -24,8 +29,8 @@ sp-std.workspace = true # Benchmarks sp-io = { workspace = true, optional = true } -sp-keystore = { workspace = true, optional = true } frame-benchmarking = { workspace = true, optional = true } +sp-runtime.workspace = true [features] default = ["std"] @@ -42,13 +47,10 @@ std = [ "sp-keystore/std", "frame-benchmarking/std", ] - runtime-benchmarks = [ + "frame-benchmarking", + "kilt-support/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", - "sp-io", - "sp-keystore", - "frame-benchmarking/runtime-benchmarks", - "kilt-support/mock", - "kilt-support/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", ] diff --git a/pallets/pallet-dip-provider/Cargo.toml b/pallets/pallet-dip-provider/Cargo.toml index 9bdbb17763..f7374b57bc 100644 --- a/pallets/pallet-dip-provider/Cargo.toml +++ b/pallets/pallet-dip-provider/Cargo.toml @@ -13,42 +13,48 @@ version.workspace = true [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] + [dev-dependencies] -kilt-support = { workspace = true, features = ["mock", "std"] } +sp-keystore = { workspace = true, features = ["std"] } sp-io = { workspace = true, features = ["std"] } +kilt-support = { workspace = true, features = ["mock", "try-runtime"] } [dependencies] -did.workspace = true frame-support.workspace = true frame-system.workspace = true +kilt-support.workspace = true parity-scale-codec = { workspace = true, features = ["derive"] } scale-info = { workspace = true, features = ["derive"] } +sp-core.workspace = true sp-std.workspace = true +did.workspace = true # Benchmarks +sp-io = { workspace = true, optional = true } frame-benchmarking = { workspace = true, optional = true } -kilt-support = { workspace = true, optional = true } -sp-keystore = { workspace = true, optional = true } -pallet-did-lookup = { workspace = true, optional = true } +sp-runtime.workspace = true [features] default = ["std"] + std = [ "did/std", "frame-support/std", "frame-system/std", + "kilt-support/std", "parity-scale-codec/std", "scale-info/std", + "sp-core/std", "sp-std/std", + "sp-io/std", + "sp-keystore/std", + "frame-benchmarking/std", ] runtime-benchmarks = [ "did/runtime-benchmarks", + "frame-benchmarking", + "kilt-support/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", - "frame-benchmarking/runtime-benchmarks", - "kilt-support/mock", - "kilt-support/runtime-benchmarks", - "sp-keystore", - "pallet-did-lookup", - + "sp-runtime/runtime-benchmarks", ] From 14748ef021c51c84d045589915f271abb0f2ff62 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 23 Nov 2023 10:48:07 +0100 Subject: [PATCH 18/71] linked accounts missing --- Cargo.lock | 1 + .../pallet-dip-consumer/src/benchmarking.rs | 17 +++-- pallets/pallet-dip-consumer/src/lib.rs | 2 +- pallets/pallet-dip-provider/src/mock.rs | 1 + runtimes/common/Cargo.toml | 4 ++ runtimes/common/src/dip/did.rs | 72 +++++++++++++++++++ 6 files changed, 89 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2ef5f3f79f..8ed3ab8aca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9892,6 +9892,7 @@ dependencies = [ "cumulus-pallet-xcmp-queue", "cumulus-primitives-core", "did", + "frame-benchmarking", "frame-support", "frame-system", "kilt-asset-dids", diff --git a/pallets/pallet-dip-consumer/src/benchmarking.rs b/pallets/pallet-dip-consumer/src/benchmarking.rs index acdd444c0b..b7f081bacd 100644 --- a/pallets/pallet-dip-consumer/src/benchmarking.rs +++ b/pallets/pallet-dip-consumer/src/benchmarking.rs @@ -18,7 +18,7 @@ use crate::{ traits::{IdentityProofVerifier, SuccessfulProofVerifier}, - Config, IdentityEntries, Pallet, + Call, Config, IdentityEntries, Pallet, }; use frame_benchmarking::v2::*; use frame_support::pallet_prelude::IsType; @@ -50,12 +50,15 @@ mod benchmarks { let boxed_call = Box::from(call); - // todo no into in block. - #[block] - { - Pallet::::dispatch_as(origin.into(), subject.clone(), ().into(), boxed_call) - .expect("Dispatch_as should not fail."); - } + let proof = ().into(); + + #[extrinsic_call] + Pallet::::dispatch_as( + ::RuntimeOrigin::from(origin) as ::RuntimeOrigin, + subject.clone(), + proof, + boxed_call, + ); } #[cfg(test)] diff --git a/pallets/pallet-dip-consumer/src/lib.rs b/pallets/pallet-dip-consumer/src/lib.rs index 7a062ba299..876f84ee2d 100644 --- a/pallets/pallet-dip-consumer/src/lib.rs +++ b/pallets/pallet-dip-consumer/src/lib.rs @@ -126,7 +126,7 @@ pub mod pallet { account_address: submitter, details: proof_verification_result, }; - // TODO: Use dispatch info for weight calculation + #[cfg(not(feature = "runtime-benchmark"))] let _ = call.dispatch(did_origin.into()).map_err(|e| e.error)?; Ok(()) diff --git a/pallets/pallet-dip-provider/src/mock.rs b/pallets/pallet-dip-provider/src/mock.rs index 0e6282847d..7bb7af02aa 100644 --- a/pallets/pallet-dip-provider/src/mock.rs +++ b/pallets/pallet-dip-provider/src/mock.rs @@ -25,6 +25,7 @@ use frame_support::{ }, traits::{ConstU16, ConstU32, ConstU64, Everything}, }; + use frame_system::mocking::MockBlock; use kilt_support::mock::mock_origin::{self as mock_origin, DoubleOrigin, EnsureDoubleOrigin}; diff --git a/runtimes/common/Cargo.toml b/runtimes/common/Cargo.toml index 8fcf7a24b4..1c09794d0f 100644 --- a/runtimes/common/Cargo.toml +++ b/runtimes/common/Cargo.toml @@ -60,6 +60,9 @@ xcm-builder.workspace = true xcm-executor.workspace = true xcm.workspace = true +# Benchmarking +frame-benchmarking = { workspace = true, optional = true } + [features] default = ["std"] fast-gov = [] @@ -81,6 +84,7 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", + "frame-benchmarking", ] std = [ "cumulus-pallet-parachain-system/std", diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index 7772107326..0a672bdbbc 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -25,6 +25,9 @@ use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_std::vec::Vec; +#[cfg(feature = "runtime-benchmarks")] +use kilt_support::traits::GetWorstCase; + #[derive(Encode, Decode, TypeInfo, Debug)] pub enum LinkedDidInfoProviderError { DidNotFound, @@ -98,3 +101,72 @@ where }) } } + +#[cfg(feature = "runtime-benchmarks")] +impl GetWorstCase for LinkedDidInfoOf +where + Runtime: did::Config::Identifier> + + pallet_web3_names::Config::Identifier> + + pallet_did_lookup::Config::Identifier> + + pallet_dip_provider::Config, + ::AccountId: AsRef<[u8; 32]> + From<[u8; 32]>, +{ + /// The worst case for the [LinkedDidInfor] is a DID with all keys set, a web3name and linked accounts in the palled_did_lookup pallet. + fn worst_case() -> Self { + use did::{ + did_details::DidVerificationKey, + mock_utils::{generate_base_did_creation_details, get_key_agreement_keys}, + }; + use frame_benchmarking::{account, Zero}; + use sp_io::crypto::ed25519_generate; + use sp_runtime::{traits::Get, BoundedVec, KeyTypeId}; + + // Did Details. + let did: ::DidIdentifier = account("did", 0, 0); + let submitter: ::AccountId = account("submitter", 1, 1); + + let max_new_keys = ::MaxNewKeyAgreementKeys::get(); + + let new_key_agreement_keys = get_key_agreement_keys::(max_new_keys); + + let mut did_creation_details = generate_base_did_creation_details(did, submitter); + + // TODO check if I have to set different seed. Prob not but lets be sure. + let attestation_key = ed25519_generate(KeyTypeId(*b"0001"), None); + let delegation_key = ed25519_generate(KeyTypeId(*b"0002"), None); + let auth_key = ed25519_generate(KeyTypeId(*b"0003"), None); + did_creation_details.new_attestation_key = Some(DidVerificationKey::from(attestation_key)); + did_creation_details.new_delegation_key = Some(DidVerificationKey::from(delegation_key)); + did_creation_details.new_key_agreement_keys = new_key_agreement_keys; + + let did_details = did::did_details::DidDetails::new_with_creation_details( + did_creation_details, + DidVerificationKey::from(auth_key), + ) + .expect("Creation of DID details should not fail."); + + let max_name_length = ::MaxNameLength::get() + .try_into() + .expect("max name length should not fail."); + + let web3_name_input: BoundedVec::MaxNameLength> = + BoundedVec::try_from(vec![b'1'; max_name_length]).expect("BoundedVec creation should not fail."); + + let web3_name = pallet_web3_names::Web3NameOf::::try_from(web3_name_input.to_vec()) + .expect("Creation of w3n from w3n input should not fail."); + + let web3_name_details = Some(RevealedWeb3Name { + web3_name, + claimed_at: BlockNumberFor::::zero(), + }); + + // Difficult. How many linked accounts can a did have? + let linked_accounts = vec![]; + + LinkedDidInfoOf { + did_details, + linked_accounts, + web3_name_details, + } + } +} From 0cba1d1f12450cd210aa0baa3e46c53742f96041 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 23 Nov 2023 13:30:41 +0100 Subject: [PATCH 19/71] finish worst case for LinkedDidInfoOf --- pallets/pallet-did-lookup/src/lib.rs | 4 +++ pallets/pallet-did-lookup/src/try_state.rs | 14 ++++++++-- runtimes/common/src/dip/did.rs | 30 +++++++++++++++++----- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/pallets/pallet-did-lookup/src/lib.rs b/pallets/pallet-did-lookup/src/lib.rs index 14f4af63d9..cacd699f3f 100644 --- a/pallets/pallet-did-lookup/src/lib.rs +++ b/pallets/pallet-did-lookup/src/lib.rs @@ -85,6 +85,10 @@ pub mod pallet { pub(crate) type BalanceMigrationManagerOf = ::BalanceMigrationManager; + /// Defines a upper limit for the benchmarks. Has to be alter if a user has more linked accounts. + #[cfg(any(feature = "runtime-benchmarks", feature = "try-runtime"))] + pub const MAX_LINKED_ACCOUNT: u32 = 10; + const STORAGE_VERSION: StorageVersion = StorageVersion::new(4); #[pallet::composite_enum] diff --git a/pallets/pallet-did-lookup/src/try_state.rs b/pallets/pallet-did-lookup/src/try_state.rs index 2ad1c0caf2..47fe65a10f 100644 --- a/pallets/pallet-did-lookup/src/try_state.rs +++ b/pallets/pallet-did-lookup/src/try_state.rs @@ -19,9 +19,9 @@ use frame_support::ensure; use kilt_support::test_utils::log_and_return_error_message; use scale_info::prelude::format; -use sp_runtime::TryRuntimeError; +use sp_runtime::{SaturatedConversion, TryRuntimeError}; -use crate::{Config, ConnectedAccounts, ConnectedDids}; +use crate::{Config, ConnectedAccounts, ConnectedDids, MAX_LINKED_ACCOUNT}; pub(crate) fn do_try_state() -> Result<(), TryRuntimeError> { ConnectedDids::::iter().try_for_each(|(account, record)| -> Result<(), TryRuntimeError> { @@ -41,6 +41,16 @@ pub(crate) fn do_try_state() -> Result<(), TryRuntimeError> { linked_account_id, did_identifier )) ); + + ensure!( + ConnectedAccounts::::iter_prefix(did_identifier.clone()).count() + < MAX_LINKED_ACCOUNT.saturated_into(), + log_and_return_error_message(format!( + "DID {:?} has more linked accounts as {:?}", + did_identifier, MAX_LINKED_ACCOUNT + )) + ); + Ok(()) }, ) diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index 0a672bdbbc..7ff7657dc1 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -108,7 +108,9 @@ where Runtime: did::Config::Identifier> + pallet_web3_names::Config::Identifier> + pallet_did_lookup::Config::Identifier> - + pallet_dip_provider::Config, + + pallet_dip_provider::Config + + pallet_balances::Config, + ::AccountId: Into + From, ::AccountId: AsRef<[u8; 32]> + From<[u8; 32]>, { /// The worst case for the [LinkedDidInfor] is a DID with all keys set, a web3name and linked accounts in the palled_did_lookup pallet. @@ -117,8 +119,8 @@ where did_details::DidVerificationKey, mock_utils::{generate_base_did_creation_details, get_key_agreement_keys}, }; - use frame_benchmarking::{account, Zero}; - use sp_io::crypto::ed25519_generate; + use frame_benchmarking::{account, vec, Zero}; + use sp_io::crypto::{ed25519_generate, sr25519_generate}; use sp_runtime::{traits::Get, BoundedVec, KeyTypeId}; // Did Details. @@ -129,7 +131,7 @@ where let new_key_agreement_keys = get_key_agreement_keys::(max_new_keys); - let mut did_creation_details = generate_base_did_creation_details(did, submitter); + let mut did_creation_details = generate_base_did_creation_details(did.clone(), submitter.clone()); // TODO check if I have to set different seed. Prob not but lets be sure. let attestation_key = ed25519_generate(KeyTypeId(*b"0001"), None); @@ -145,6 +147,10 @@ where ) .expect("Creation of DID details should not fail."); + // add to storage. + did::Pallet::::try_insert_did(did.clone(), did_details.clone(), submitter.clone()) + .expect("Inserting Did should not fail."); + let max_name_length = ::MaxNameLength::get() .try_into() .expect("max name length should not fail."); @@ -155,13 +161,25 @@ where let web3_name = pallet_web3_names::Web3NameOf::::try_from(web3_name_input.to_vec()) .expect("Creation of w3n from w3n input should not fail."); + pallet_web3_names::Pallet::::register_name(web3_name.clone(), did.clone(), submitter.clone()) + .expect("Inserting w3n into storage should not fail."); + let web3_name_details = Some(RevealedWeb3Name { web3_name, claimed_at: BlockNumberFor::::zero(), }); - // Difficult. How many linked accounts can a did have? - let linked_accounts = vec![]; + let mut linked_accounts = vec![]; + + (0..pallet_did_lookup::MAX_LINKED_ACCOUNT).for_each(|index| { + let connected_acc = sr25519_generate(KeyTypeId(*b"aura"), Some(index.to_be_bytes().to_vec())); + let connected_acc_id: ::AccountId = connected_acc.into(); + let linkable_id: LinkableAccountId = connected_acc_id.clone().into(); + pallet_did_lookup::Pallet::::add_association(submitter.clone(), did.clone(), linkable_id.clone()) + .expect("association should not fail."); + + linked_accounts.push(linkable_id); + }); LinkedDidInfoOf { did_details, From 90f5fe4b6a63ec1c2899a8cb9ef222d43458ffef Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 23 Nov 2023 13:50:59 +0100 Subject: [PATCH 20/71] give money --- runtimes/common/src/dip/did.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index 7ff7657dc1..b45053d8be 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -120,12 +120,22 @@ where mock_utils::{generate_base_did_creation_details, get_key_agreement_keys}, }; use frame_benchmarking::{account, vec, Zero}; + use frame_support::traits::fungible::Mutate; use sp_io::crypto::{ed25519_generate, sr25519_generate}; - use sp_runtime::{traits::Get, BoundedVec, KeyTypeId}; + use sp_runtime::{traits::Get, BoundedVec, KeyTypeId, SaturatedConversion}; + + use crate::constants::KILT; // Did Details. let did: ::DidIdentifier = account("did", 0, 0); let submitter: ::AccountId = account("submitter", 1, 1); + let amount = KILT * 100; + + // give a bit money + as Mutate<::AccountId>>::set_balance( + &submitter, + amount.saturated_into(), + ); let max_new_keys = ::MaxNewKeyAgreementKeys::get(); From cc00b0b2a361dec3dac6d076be28c3f95314e590 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 23 Nov 2023 16:57:47 +0100 Subject: [PATCH 21/71] add default weights --- pallets/pallet-dip-consumer/Cargo.toml | 2 + .../src/default_weights.rs | 65 +++++++++++ pallets/pallet-dip-consumer/src/lib.rs | 3 + pallets/pallet-dip-consumer/src/mock.rs | 1 + pallets/pallet-dip-provider/Cargo.toml | 2 + .../pallet-dip-provider/src/benchmarking.rs | 2 + .../src/default_weights.rs | 108 ++++++++++++++++++ pallets/pallet-dip-provider/src/lib.rs | 3 + pallets/pallet-dip-provider/src/mock.rs | 1 + runtimes/common/src/dip/did.rs | 11 +- 10 files changed, 194 insertions(+), 4 deletions(-) create mode 100644 pallets/pallet-dip-consumer/src/default_weights.rs create mode 100644 pallets/pallet-dip-provider/src/default_weights.rs diff --git a/pallets/pallet-dip-consumer/Cargo.toml b/pallets/pallet-dip-consumer/Cargo.toml index 5fb579f91f..c1d236053d 100644 --- a/pallets/pallet-dip-consumer/Cargo.toml +++ b/pallets/pallet-dip-consumer/Cargo.toml @@ -54,3 +54,5 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", ] + +try-runtime = ["kilt-support/try-runtime"] diff --git a/pallets/pallet-dip-consumer/src/default_weights.rs b/pallets/pallet-dip-consumer/src/default_weights.rs new file mode 100644 index 0000000000..f425e7da3f --- /dev/null +++ b/pallets/pallet-dip-consumer/src/default_weights.rs @@ -0,0 +1,65 @@ + +//! Autogenerated weights for pallet_dip_consumer +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-11-23 +//! STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/debug/kilt-parachain +// benchmark +// pallet +// --pallet +// pallet-dip-consumer +// --extrinsic +// * +// --template +// ./.maintain/weight-template.hbs +// --output +// ./pallets/pallet-dip-consumer/src/weights.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_dip_consumer. +pub trait WeightInfo { + fn dispatch_as() -> Weight; +} + +/// Weights for pallet_dip_consumer using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: `PalletDipConsumer::IdentityEntries` (r:1 w:1) + /// Proof: `PalletDipConsumer::IdentityEntries` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn dispatch_as() -> Weight { + // Proof Size summary in bytes: + // Measured: `147` + // Estimated: `3612` + // Minimum execution time: 127_413 nanoseconds. + Weight::from_parts(129_497_000, 3612) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + /// Storage: `PalletDipConsumer::IdentityEntries` (r:1 w:1) + /// Proof: `PalletDipConsumer::IdentityEntries` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn dispatch_as() -> Weight { + // Proof Size summary in bytes: + // Measured: `147` + // Estimated: `3612` + // Minimum execution time: 127_413 nanoseconds. + Weight::from_parts(129_497_000, 3612) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } +} diff --git a/pallets/pallet-dip-consumer/src/lib.rs b/pallets/pallet-dip-consumer/src/lib.rs index 876f84ee2d..b226777bfd 100644 --- a/pallets/pallet-dip-consumer/src/lib.rs +++ b/pallets/pallet-dip-consumer/src/lib.rs @@ -20,6 +20,7 @@ #![cfg_attr(not(feature = "std"), no_std)] +pub mod default_weights; pub mod identity; pub mod traits; @@ -37,6 +38,7 @@ pub use crate::{origin::*, pallet::*, traits::SuccessfulProofVerifier}; pub mod pallet { use super::*; + use default_weights::WeightInfo; use frame_support::{ dispatch::{Dispatchable, GetDispatchInfo}, pallet_prelude::*, @@ -77,6 +79,7 @@ pub mod pallet { type ProofVerifier: IdentityProofVerifier; type RuntimeCall: Parameter + Dispatchable::RuntimeOrigin> + GetDispatchInfo; type RuntimeOrigin: From> + From<::RuntimeOrigin>; + type WeightInfo: WeightInfo; } #[pallet::pallet] diff --git a/pallets/pallet-dip-consumer/src/mock.rs b/pallets/pallet-dip-consumer/src/mock.rs index 39ef758999..4f51ff9222 100644 --- a/pallets/pallet-dip-consumer/src/mock.rs +++ b/pallets/pallet-dip-consumer/src/mock.rs @@ -70,6 +70,7 @@ impl crate::Config for TestRuntime { type Identifier = AccountId32; type DispatchOriginCheck = EnsureSigned; type DipCallOriginFilter = (); + type WeightInfo = (); } #[derive(Default)] diff --git a/pallets/pallet-dip-provider/Cargo.toml b/pallets/pallet-dip-provider/Cargo.toml index f7374b57bc..f76aae2a20 100644 --- a/pallets/pallet-dip-provider/Cargo.toml +++ b/pallets/pallet-dip-provider/Cargo.toml @@ -58,3 +58,5 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", ] + +try-runtime = ["did/try-runtime", "kilt-support/try-runtime"] diff --git a/pallets/pallet-dip-provider/src/benchmarking.rs b/pallets/pallet-dip-provider/src/benchmarking.rs index 3928cc712a..4b9b515b82 100644 --- a/pallets/pallet-dip-provider/src/benchmarking.rs +++ b/pallets/pallet-dip-provider/src/benchmarking.rs @@ -57,6 +57,8 @@ mod benchmarks { let origin: T::RuntimeOrigin = T::CommitOriginCheck::generate_origin(submitter, subject.clone()); + <<::IdentityProvider as IdentityProvider>::Success as GetWorstCase>::worst_case(); + Pallet::::commit_identity( origin.clone() as T::RuntimeOrigin, subject.clone(), diff --git a/pallets/pallet-dip-provider/src/default_weights.rs b/pallets/pallet-dip-provider/src/default_weights.rs new file mode 100644 index 0000000000..51c54bbe09 --- /dev/null +++ b/pallets/pallet-dip-provider/src/default_weights.rs @@ -0,0 +1,108 @@ + +//! Autogenerated weights for pallet_dip_provider +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-11-23 +//! STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/debug/kilt-parachain +// benchmark +// pallet +// --pallet +// pallet-dip-provider +// --extrinsic +// * +// --template +// ./.maintain/weight-template.hbs +// --output +// ./pallets/pallet-dip-provider/src/weights.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_dip_provider. +pub trait WeightInfo { + fn commit_identity() -> Weight; + fn delete_identity_commitment() -> Weight; +} + +/// Weights for pallet_dip_provider using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: `Did::Did` (r:1 w:0) + /// Proof: `Did::Did` (`max_values`: None, `max_size`: Some(2312), added: 4787, mode: `MaxEncodedLen`) + /// Storage: `Did::DidBlacklist` (r:1 w:0) + /// Proof: `Did::DidBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Names` (r:1 w:0) + /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Owner` (r:1 w:0) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(137), added: 2612, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:11 w:0) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + /// Storage: `PalletDipProvider::IdentityCommitments` (r:1 w:1) + /// Proof: `PalletDipProvider::IdentityCommitments` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn commit_identity() -> Weight { + // Proof Size summary in bytes: + // Measured: `2781` + // Estimated: `29282` + // Minimum execution time: 1_244_624 nanoseconds. + Weight::from_parts(1_401_381_000, 29282) + .saturating_add(T::DbWeight::get().reads(16_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } + /// Storage: `PalletDipProvider::IdentityCommitments` (r:1 w:1) + /// Proof: `PalletDipProvider::IdentityCommitments` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn delete_identity_commitment() -> Weight { + // Proof Size summary in bytes: + // Measured: `250` + // Estimated: `3715` + // Minimum execution time: 169_415 nanoseconds. + Weight::from_parts(190_131_000, 3715) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(1_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + /// Storage: `Did::Did` (r:1 w:0) + /// Proof: `Did::Did` (`max_values`: None, `max_size`: Some(2312), added: 4787, mode: `MaxEncodedLen`) + /// Storage: `Did::DidBlacklist` (r:1 w:0) + /// Proof: `Did::DidBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Names` (r:1 w:0) + /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Owner` (r:1 w:0) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(137), added: 2612, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:11 w:0) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + /// Storage: `PalletDipProvider::IdentityCommitments` (r:1 w:1) + /// Proof: `PalletDipProvider::IdentityCommitments` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn commit_identity() -> Weight { + // Proof Size summary in bytes: + // Measured: `2781` + // Estimated: `29282` + // Minimum execution time: 1_244_624 nanoseconds. + Weight::from_parts(1_401_381_000, 29282) + .saturating_add(RocksDbWeight::get().reads(16_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } + /// Storage: `PalletDipProvider::IdentityCommitments` (r:1 w:1) + /// Proof: `PalletDipProvider::IdentityCommitments` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn delete_identity_commitment() -> Weight { + // Proof Size summary in bytes: + // Measured: `250` + // Estimated: `3715` + // Minimum execution time: 169_415 nanoseconds. + Weight::from_parts(190_131_000, 3715) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + .saturating_add(RocksDbWeight::get().writes(1_u64)) + } +} diff --git a/pallets/pallet-dip-provider/src/lib.rs b/pallets/pallet-dip-provider/src/lib.rs index 259109c7bd..87a63e7d6a 100644 --- a/pallets/pallet-dip-provider/src/lib.rs +++ b/pallets/pallet-dip-provider/src/lib.rs @@ -20,6 +20,7 @@ #![cfg_attr(not(feature = "std"), no_std)] +pub mod default_weights; pub mod traits; #[cfg(feature = "runtime-benchmarks")] @@ -37,6 +38,7 @@ pub use crate::{ pub mod pallet { use super::*; + use default_weights::WeightInfo; use frame_support::{pallet_prelude::*, traits::EnsureOrigin}; use frame_system::pallet_prelude::*; @@ -60,6 +62,7 @@ pub mod pallet { type IdentityProvider: IdentityProvider; type ProviderHooks: ProviderHooks; type RuntimeEvent: From> + IsType<::RuntimeEvent>; + type WeightInfo: WeightInfo; } #[pallet::storage] diff --git a/pallets/pallet-dip-provider/src/mock.rs b/pallets/pallet-dip-provider/src/mock.rs index 7bb7af02aa..2d98ed26ba 100644 --- a/pallets/pallet-dip-provider/src/mock.rs +++ b/pallets/pallet-dip-provider/src/mock.rs @@ -73,6 +73,7 @@ impl crate::Config for TestRuntime { type IdentityProvider = DefaultIdentityProvider; type ProviderHooks = NoopHooks; type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); } impl mock_origin::Config for TestRuntime { diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index b45053d8be..679e06d926 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -19,6 +19,7 @@ use did::did_details::DidDetails; use frame_system::pallet_prelude::BlockNumberFor; use kilt_dip_support::merkle::RevealedWeb3Name; +use kilt_support::traits::Instanciate; use pallet_did_lookup::linkable_account::LinkableAccountId; use pallet_dip_provider::traits::IdentityProvider; use parity_scale_codec::{Decode, Encode}; @@ -112,6 +113,8 @@ where + pallet_balances::Config, ::AccountId: Into + From, ::AccountId: AsRef<[u8; 32]> + From<[u8; 32]>, + Runtime::AccountId: Instanciate, + Runtime::Identifier: Instanciate, { /// The worst case for the [LinkedDidInfor] is a DID with all keys set, a web3name and linked accounts in the palled_did_lookup pallet. fn worst_case() -> Self { @@ -119,7 +122,7 @@ where did_details::DidVerificationKey, mock_utils::{generate_base_did_creation_details, get_key_agreement_keys}, }; - use frame_benchmarking::{account, vec, Zero}; + use frame_benchmarking::{vec, Zero}; use frame_support::traits::fungible::Mutate; use sp_io::crypto::{ed25519_generate, sr25519_generate}; use sp_runtime::{traits::Get, BoundedVec, KeyTypeId, SaturatedConversion}; @@ -127,8 +130,8 @@ where use crate::constants::KILT; // Did Details. - let did: ::DidIdentifier = account("did", 0, 0); - let submitter: ::AccountId = account("submitter", 1, 1); + let submitter = Runtime::AccountId::new(1); + let did = Runtime::Identifier::new(1); let amount = KILT * 100; // give a bit money @@ -182,7 +185,7 @@ where let mut linked_accounts = vec![]; (0..pallet_did_lookup::MAX_LINKED_ACCOUNT).for_each(|index| { - let connected_acc = sr25519_generate(KeyTypeId(*b"aura"), Some(index.to_be_bytes().to_vec())); + let connected_acc = sr25519_generate(KeyTypeId(index.to_be_bytes()), None); let connected_acc_id: ::AccountId = connected_acc.into(); let linkable_id: LinkableAccountId = connected_acc_id.clone().into(); pallet_did_lookup::Pallet::::add_association(submitter.clone(), did.clone(), linkable_id.clone()) From d276f0ed2e7d07326e6600e68d05c66b21cd61c7 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 23 Nov 2023 16:58:18 +0100 Subject: [PATCH 22/71] has to be reverted. Add provider and cosumer to peregrine --- runtimes/peregrine/Cargo.toml | 27 ++++++++++++++++----------- runtimes/peregrine/src/lib.rs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/runtimes/peregrine/Cargo.toml b/runtimes/peregrine/Cargo.toml index e4ee385029..bb9066dbe5 100644 --- a/runtimes/peregrine/Cargo.toml +++ b/runtimes/peregrine/Cargo.toml @@ -19,10 +19,10 @@ sp-io.workspace = true [dependencies] # External dependencies log.workspace = true -parity-scale-codec = {workspace = true, features = ["derive"]} -scale-info = {workspace = true, features = ["derive"]} +parity-scale-codec = { workspace = true, features = ["derive"] } +scale-info = { workspace = true, features = ["derive"] } -hex-literal = {workspace = true, optional = true} +hex-literal = { workspace = true, optional = true } # RPC & Runtime API frame-system-rpc-runtime-api.workspace = true @@ -45,6 +45,8 @@ pallet-migration.workspace = true parachain-staking.workspace = true public-credentials.workspace = true runtime-common.workspace = true +pallet-dip-provider.workspace = true +pallet-dip-consumer.workspace = true # Substrate dependencies sp-api.workspace = true @@ -101,12 +103,12 @@ xcm-executor.workspace = true xcm.workspace = true # Benchmarking dependencies -cumulus-pallet-session-benchmarking = {workspace = true, optional = true} -frame-benchmarking = {workspace = true, optional = true} -frame-system-benchmarking = {workspace = true, optional = true} +cumulus-pallet-session-benchmarking = { workspace = true, optional = true } +frame-benchmarking = { workspace = true, optional = true } +frame-system-benchmarking = { workspace = true, optional = true } # Runtime tests -frame-try-runtime = {workspace = true, optional = true} +frame-try-runtime = { workspace = true, optional = true } [features] default = ["std"] @@ -152,6 +154,8 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", + "pallet-dip-provider/runtime-benchmarks", + "pallet-dip-consumer/runtime-benchmarks", ] std = [ "attestation/std", @@ -227,6 +231,8 @@ std = [ "xcm-builder/std", "xcm-executor/std", "xcm/std", + "pallet-dip-provider/std", + "pallet-dip-consumer/std", ] try-runtime = [ "attestation/try-runtime", @@ -272,8 +278,7 @@ try-runtime = [ "parachain-staking/try-runtime", "public-credentials/try-runtime", "runtime-common/try-runtime", + "pallet-dip-provider/try-runtime", + "pallet-dip-consumer/try-runtime", ] -with-tracing = [ - "frame-executive/with-tracing", - "sp-io/with-tracing", -] +with-tracing = ["frame-executive/with-tracing", "sp-io/with-tracing"] diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index 9fc8776cd7..970f4684d7 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -945,6 +945,34 @@ impl pallet_proxy::Config for Runtime { type WeightInfo = weights::pallet_proxy::WeightInfo; } +impl pallet_dip_provider::Config for Runtime { + type CommitOriginCheck = did::EnsureDidOrigin; + type CommitOrigin = did::DidRawOrigin; + type Identifier = DidIdentifier; + type IdentityCommitmentGenerator = runtime_common::dip::merkle::DidMerkleRootGenerator; + type IdentityProvider = runtime_common::dip::did::LinkedDidInfoProvider; + type ProviderHooks = pallet_dip_provider::NoopHooks; + type RuntimeEvent = RuntimeEvent; +} + +pub struct PreliminaryDipOriginFilter; + +impl frame_support::traits::Contains for PreliminaryDipOriginFilter { + fn contains(_t: &RuntimeCall) -> bool { + true + } +} + +impl pallet_dip_consumer::Config for Runtime { + type DipCallOriginFilter = PreliminaryDipOriginFilter; + type DispatchOriginCheck = EnsureSigned; + type Identifier = DidIdentifier; + type LocalIdentityInfo = u128; + type ProofVerifier = pallet_dip_consumer::traits::SuccessfulProofVerifier; + type RuntimeCall = RuntimeCall; + type RuntimeOrigin = RuntimeOrigin; +} + construct_runtime! { pub enum Runtime { @@ -1008,6 +1036,8 @@ construct_runtime! { Web3Names: pallet_web3_names = 68, PublicCredentials: public_credentials = 69, Migration: pallet_migration = 70, + PalletDipProvider: pallet_dip_provider = 71, + PalletDipConsumer: pallet_dip_consumer = 72, // Parachains pallets. Start indices at 80 to leave room. @@ -1147,6 +1177,8 @@ mod benches { [pallet_xcm, PolkadotXcm] [pallet_migration, Migration] [frame_benchmarking::baseline, Baseline::] + [pallet_dip_provider, PalletDipProvider] + [pallet_dip_consumer, PalletDipConsumer] ); } From 489806f65c71a607c48975cf5cb13d9d87e45693 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 23 Nov 2023 16:58:43 +0100 Subject: [PATCH 23/71] lockfile --- Cargo.lock | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index 8ed3ab8aca..9320db4b06 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7645,6 +7645,8 @@ dependencies = [ "pallet-configuration", "pallet-democracy", "pallet-did-lookup", + "pallet-dip-consumer", + "pallet-dip-provider", "pallet-indices", "pallet-inflation", "pallet-membership", From b493baffcc12ff7b366be33deeaf6dabf9faa659 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 23 Nov 2023 17:21:22 +0100 Subject: [PATCH 24/71] adjust cargo toml --- Cargo.lock | 1 - pallets/pallet-dip-consumer/src/benchmarking.rs | 10 +++------- pallets/pallet-dip-provider/src/traits.rs | 5 +++++ runtimes/common/Cargo.toml | 3 --- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9320db4b06..14a66c166b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9894,7 +9894,6 @@ dependencies = [ "cumulus-pallet-xcmp-queue", "cumulus-primitives-core", "did", - "frame-benchmarking", "frame-support", "frame-system", "kilt-asset-dids", diff --git a/pallets/pallet-dip-consumer/src/benchmarking.rs b/pallets/pallet-dip-consumer/src/benchmarking.rs index b7f081bacd..1e93425abe 100644 --- a/pallets/pallet-dip-consumer/src/benchmarking.rs +++ b/pallets/pallet-dip-consumer/src/benchmarking.rs @@ -16,12 +16,8 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use crate::{ - traits::{IdentityProofVerifier, SuccessfulProofVerifier}, - Call, Config, IdentityEntries, Pallet, -}; +use crate::{traits::IdentityProofVerifier, Call, Config, IdentityEntries, Pallet}; use frame_benchmarking::v2::*; -use frame_support::pallet_prelude::IsType; use frame_system::RawOrigin; use kilt_support::traits::Instanciate; @@ -29,7 +25,7 @@ use kilt_support::traits::Instanciate; where T::AccountId: Instanciate, T::Identifier: Instanciate, - <::ProofVerifier as IdentityProofVerifier>::Proof: IsType<>::Proof>, + <::ProofVerifier as IdentityProofVerifier>::Proof: Default, ::RuntimeCall: From> ) ] @@ -50,7 +46,7 @@ mod benchmarks { let boxed_call = Box::from(call); - let proof = ().into(); + let proof: <::ProofVerifier as IdentityProofVerifier>::Proof = Default::default(); #[extrinsic_call] Pallet::::dispatch_as( diff --git a/pallets/pallet-dip-provider/src/traits.rs b/pallets/pallet-dip-provider/src/traits.rs index 80af347d34..04a08e3103 100644 --- a/pallets/pallet-dip-provider/src/traits.rs +++ b/pallets/pallet-dip-provider/src/traits.rs @@ -184,3 +184,8 @@ where Ok(()) } } + +#[cfg(feature = "runtime-benchmarks")] +pub trait SetupDipIdentityProviderBenchmark { + fn get_worst_case(did: DidIdentifier, submitter: AccountId) -> Self; +} diff --git a/runtimes/common/Cargo.toml b/runtimes/common/Cargo.toml index 1c09794d0f..1ee16a90cb 100644 --- a/runtimes/common/Cargo.toml +++ b/runtimes/common/Cargo.toml @@ -60,8 +60,6 @@ xcm-builder.workspace = true xcm-executor.workspace = true xcm.workspace = true -# Benchmarking -frame-benchmarking = { workspace = true, optional = true } [features] default = ["std"] @@ -84,7 +82,6 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "frame-benchmarking", ] std = [ "cumulus-pallet-parachain-system/std", From 8b97889835385d1eb08e4489204281176959640c Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 24 Nov 2023 09:21:07 +0100 Subject: [PATCH 25/71] compiling --- Cargo.lock | 1 + pallets/pallet-dip-consumer/src/benchmarking.rs | 6 +++--- pallets/pallet-dip-consumer/src/traits.rs | 1 + runtimes/common/Cargo.toml | 3 +++ support/src/traits.rs | 7 +++++++ 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 14a66c166b..9320db4b06 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9894,6 +9894,7 @@ dependencies = [ "cumulus-pallet-xcmp-queue", "cumulus-primitives-core", "did", + "frame-benchmarking", "frame-support", "frame-system", "kilt-asset-dids", diff --git a/pallets/pallet-dip-consumer/src/benchmarking.rs b/pallets/pallet-dip-consumer/src/benchmarking.rs index 1e93425abe..2e1bb7e6c3 100644 --- a/pallets/pallet-dip-consumer/src/benchmarking.rs +++ b/pallets/pallet-dip-consumer/src/benchmarking.rs @@ -19,13 +19,13 @@ use crate::{traits::IdentityProofVerifier, Call, Config, IdentityEntries, Pallet}; use frame_benchmarking::v2::*; use frame_system::RawOrigin; -use kilt_support::traits::Instanciate; +use kilt_support::traits::{GetWorstCase, Instanciate}; #[benchmarks( where T::AccountId: Instanciate, T::Identifier: Instanciate, - <::ProofVerifier as IdentityProofVerifier>::Proof: Default, + <::ProofVerifier as IdentityProofVerifier>::Proof: GetWorstCase, ::RuntimeCall: From> ) ] @@ -46,7 +46,7 @@ mod benchmarks { let boxed_call = Box::from(call); - let proof: <::ProofVerifier as IdentityProofVerifier>::Proof = Default::default(); + let proof = <<::ProofVerifier as IdentityProofVerifier>::Proof as GetWorstCase>::worst_case(); #[extrinsic_call] Pallet::::dispatch_as( diff --git a/pallets/pallet-dip-consumer/src/traits.rs b/pallets/pallet-dip-consumer/src/traits.rs index 9213166288..a544faa748 100644 --- a/pallets/pallet-dip-consumer/src/traits.rs +++ b/pallets/pallet-dip-consumer/src/traits.rs @@ -17,6 +17,7 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use frame_support::Parameter; +use kilt_support::traits::GetWorstCase; use crate::{Config, RuntimeCallOf}; diff --git a/runtimes/common/Cargo.toml b/runtimes/common/Cargo.toml index 1ee16a90cb..c60a322556 100644 --- a/runtimes/common/Cargo.toml +++ b/runtimes/common/Cargo.toml @@ -60,6 +60,8 @@ xcm-builder.workspace = true xcm-executor.workspace = true xcm.workspace = true +#benchmarking +frame-benchmarking = { workspace = true, optional = true } [features] default = ["std"] @@ -82,6 +84,7 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", + "frame-benchmarking", ] std = [ "cumulus-pallet-parachain-system/std", diff --git a/support/src/traits.rs b/support/src/traits.rs index a42654da0a..d2f7f978b4 100644 --- a/support/src/traits.rs +++ b/support/src/traits.rs @@ -95,6 +95,13 @@ impl GetWorstCase for u32 { } } +#[cfg(feature = "runtime-benchmarks")] +impl GetWorstCase for () { + fn worst_case() -> Self { + () + } +} + /// Trait that allows instanciating multiple instances of a type. #[cfg(feature = "runtime-benchmarks")] pub trait Instanciate { From 048b72dd84d866ff41276be65a4f1103ddd51ced Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 24 Nov 2023 09:25:47 +0100 Subject: [PATCH 26/71] comment --- pallets/pallet-did-lookup/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/pallet-did-lookup/src/lib.rs b/pallets/pallet-did-lookup/src/lib.rs index cacd699f3f..a8967c57a5 100644 --- a/pallets/pallet-did-lookup/src/lib.rs +++ b/pallets/pallet-did-lookup/src/lib.rs @@ -85,7 +85,7 @@ pub mod pallet { pub(crate) type BalanceMigrationManagerOf = ::BalanceMigrationManager; - /// Defines a upper limit for the benchmarks. Has to be alter if a user has more linked accounts. + /// Sets an upper limit for the benchmarks, which must be altered if a user has more linked accounts. #[cfg(any(feature = "runtime-benchmarks", feature = "try-runtime"))] pub const MAX_LINKED_ACCOUNT: u32 = 10; From 192e665f7fe5d9317fcdf41a4d743849d30f24a3 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 24 Nov 2023 11:55:26 +0100 Subject: [PATCH 27/71] compiling --- dip-template/runtimes/dip-consumer/src/dip.rs | 1 + dip-template/runtimes/dip-provider/src/dip.rs | 1 + .../pallet-dip-consumer/src/benchmarking.rs | 19 +++++++++---- pallets/pallet-dip-consumer/src/traits.rs | 1 - .../pallet-dip-provider/src/benchmarking.rs | 27 +++++++++++++++---- pallets/pallet-migration/src/benchmarking.rs | 2 +- pallets/pallet-migration/src/mock.rs | 2 +- .../public-credentials/src/benchmarking.rs | 14 +++++----- pallets/public-credentials/src/mock.rs | 2 +- runtimes/common/src/assets.rs | 2 +- runtimes/common/src/dip/did.rs | 15 +++++------ runtimes/peregrine/src/lib.rs | 2 ++ support/src/traits.rs | 18 ++++++++----- 13 files changed, 70 insertions(+), 36 deletions(-) diff --git a/dip-template/runtimes/dip-consumer/src/dip.rs b/dip-template/runtimes/dip-consumer/src/dip.rs index db25e19333..e116284321 100644 --- a/dip-template/runtimes/dip-consumer/src/dip.rs +++ b/dip-template/runtimes/dip-consumer/src/dip.rs @@ -49,6 +49,7 @@ impl pallet_dip_consumer::Config for Runtime { type ProofVerifier = ProofVerifier; type RuntimeCall = RuntimeCall; type RuntimeOrigin = RuntimeOrigin; + type WeightInfo = (); } pub struct PreliminaryDipOriginFilter; diff --git a/dip-template/runtimes/dip-provider/src/dip.rs b/dip-template/runtimes/dip-provider/src/dip.rs index 91c52a8c1b..ff8e3a6af7 100644 --- a/dip-template/runtimes/dip-provider/src/dip.rs +++ b/dip-template/runtimes/dip-provider/src/dip.rs @@ -143,4 +143,5 @@ impl pallet_dip_provider::Config for Runtime { type IdentityProvider = LinkedDidInfoProvider; type ProviderHooks = deposit::DepositCollectorHooks; type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); } diff --git a/pallets/pallet-dip-consumer/src/benchmarking.rs b/pallets/pallet-dip-consumer/src/benchmarking.rs index 2e1bb7e6c3..1de8604af4 100644 --- a/pallets/pallet-dip-consumer/src/benchmarking.rs +++ b/pallets/pallet-dip-consumer/src/benchmarking.rs @@ -19,25 +19,32 @@ use crate::{traits::IdentityProofVerifier, Call, Config, IdentityEntries, Pallet}; use frame_benchmarking::v2::*; use frame_system::RawOrigin; -use kilt_support::traits::{GetWorstCase, Instanciate}; +use kilt_support::traits::{GetWorstCase, IdentityContext, Instanciate}; #[benchmarks( where T::AccountId: Instanciate, T::Identifier: Instanciate, - <::ProofVerifier as IdentityProofVerifier>::Proof: GetWorstCase, - ::RuntimeCall: From> - + <::ProofVerifier as IdentityProofVerifier>::Proof: GetWorstCase>, + ::RuntimeCall: From>, ) ] mod benchmarks { use super::*; + type IdentityContextOf = + IdentityContext<::Identifier, ::AccountId>; + #[benchmark] fn dispatch_as() { let submitter = T::AccountId::new(1); let subject = T::Identifier::new(1); + let context = IdentityContext:: { + did: subject.clone(), + submitter: submitter.clone(), + }; + assert!(IdentityEntries::::get(&subject).is_none()); let origin = RawOrigin::Signed(submitter); @@ -46,7 +53,9 @@ mod benchmarks { let boxed_call = Box::from(call); - let proof = <<::ProofVerifier as IdentityProofVerifier>::Proof as GetWorstCase>::worst_case(); + let proof = <<::ProofVerifier as IdentityProofVerifier>::Proof as GetWorstCase< + IdentityContextOf, + >>::worst_case(context); #[extrinsic_call] Pallet::::dispatch_as( diff --git a/pallets/pallet-dip-consumer/src/traits.rs b/pallets/pallet-dip-consumer/src/traits.rs index a544faa748..9213166288 100644 --- a/pallets/pallet-dip-consumer/src/traits.rs +++ b/pallets/pallet-dip-consumer/src/traits.rs @@ -17,7 +17,6 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use frame_support::Parameter; -use kilt_support::traits::GetWorstCase; use crate::{Config, RuntimeCallOf}; diff --git a/pallets/pallet-dip-provider/src/benchmarking.rs b/pallets/pallet-dip-provider/src/benchmarking.rs index 4b9b515b82..9d99826e04 100644 --- a/pallets/pallet-dip-provider/src/benchmarking.rs +++ b/pallets/pallet-dip-provider/src/benchmarking.rs @@ -18,17 +18,20 @@ use crate::{traits::IdentityProvider, Call, Config, Pallet}; use frame_benchmarking::v2::*; -use kilt_support::traits::{GenerateBenchmarkOrigin, GetWorstCase, Instanciate}; +use kilt_support::traits::{GenerateBenchmarkOrigin, GetWorstCase, IdentityContext, Instanciate}; #[benchmarks( where T::CommitOriginCheck: GenerateBenchmarkOrigin, T::AccountId: Instanciate, T::Identifier: Instanciate, - <::IdentityProvider as IdentityProvider>::Success: GetWorstCase + <::IdentityProvider as IdentityProvider>::Success: GetWorstCase> )] mod benchmarks { + type IdentityContextOf = + IdentityContext<::Identifier, ::AccountId>; + use super::*; #[benchmark] @@ -37,11 +40,18 @@ mod benchmarks { let subject = T::Identifier::new(1); let commitment_version = 0; + let context = IdentityContext:: { + did: subject.clone(), + submitter: submitter.clone(), + }; + assert!(Pallet::::identity_commitments(&subject, commitment_version).is_none()); let origin: T::RuntimeOrigin = T::CommitOriginCheck::generate_origin(submitter, subject.clone()); - <<::IdentityProvider as IdentityProvider>::Success as GetWorstCase>::worst_case(); + <<::IdentityProvider as IdentityProvider>::Success as GetWorstCase< + IdentityContextOf, + >>::worst_case(context); #[extrinsic_call] Pallet::::commit_identity(origin as T::RuntimeOrigin, subject.clone(), Some(commitment_version)); @@ -55,9 +65,16 @@ mod benchmarks { let subject = T::Identifier::new(1); let commitment_version = 0; - let origin: T::RuntimeOrigin = T::CommitOriginCheck::generate_origin(submitter, subject.clone()); + let origin: T::RuntimeOrigin = T::CommitOriginCheck::generate_origin(submitter.clone(), subject.clone()); + + let context = IdentityContext:: { + did: subject.clone(), + submitter: submitter.clone(), + }; - <<::IdentityProvider as IdentityProvider>::Success as GetWorstCase>::worst_case(); + <<::IdentityProvider as IdentityProvider>::Success as GetWorstCase< + IdentityContextOf, + >>::worst_case(context); Pallet::::commit_identity( origin.clone() as T::RuntimeOrigin, diff --git a/pallets/pallet-migration/src/benchmarking.rs b/pallets/pallet-migration/src/benchmarking.rs index 68b748cdd5..6ced3cd012 100644 --- a/pallets/pallet-migration/src/benchmarking.rs +++ b/pallets/pallet-migration/src/benchmarking.rs @@ -203,7 +203,7 @@ benchmarks! { let sender: AccountIdOf = account("sender", 0, SEED); let attester: ::AttesterId = account("attester", 0, SEED); let ctype_hash: T::Hash = T::Hash::default(); - let subject_id = ::SubjectId::worst_case(); + let subject_id = ::SubjectId::worst_case(()); let contents = BoundedVec::try_from(vec![0; ::MaxEncodedClaimsLength::get() as usize]).expect("Contents should not fail."); let origin = ::EnsureOrigin::generate_origin(sender.clone(), attester.clone()); diff --git a/pallets/pallet-migration/src/mock.rs b/pallets/pallet-migration/src/mock.rs index 2567b1bd8b..02efd367e6 100644 --- a/pallets/pallet-migration/src/mock.rs +++ b/pallets/pallet-migration/src/mock.rs @@ -377,7 +377,7 @@ pub mod runtime { #[cfg(feature = "runtime-benchmarks")] impl kilt_support::traits::GetWorstCase for TestSubjectId { // Only used for benchmark testing, not really relevant. - fn worst_case() -> Self { + fn worst_case(_context: ()) -> Self { crate::mock::TestSubjectId::default() } } diff --git a/pallets/public-credentials/src/benchmarking.rs b/pallets/public-credentials/src/benchmarking.rs index 1153bdf63a..087f2bfec2 100644 --- a/pallets/public-credentials/src/benchmarking.rs +++ b/pallets/public-credentials/src/benchmarking.rs @@ -71,7 +71,7 @@ benchmarks! { let sender: T::AccountId = account("sender", 0, SEED); let attester: T::AttesterId = account("attester", 0, SEED); let ctype_hash: T::Hash = T::Hash::default(); - let subject_id = ::SubjectId::worst_case(); + let subject_id = ::SubjectId::worst_case(()); let contents = BoundedVec::try_from(vec![0; c as usize]).expect("Contents should not fail."); let creation_op = Box::new(generate_base_public_credential_creation_op::( @@ -98,7 +98,7 @@ benchmarks! { let sender: T::AccountId = account("sender", 0, SEED); let attester: T::AttesterId = account("attester", 0, SEED); let ctype_hash: T::Hash = T::Hash::default(); - let subject_id = ::SubjectId::worst_case(); + let subject_id = ::SubjectId::worst_case(()); let contents = BoundedVec::try_from(vec![0; ::MaxEncodedClaimsLength::get() as usize]).expect("Contents should not fail."); let origin = ::EnsureOrigin::generate_origin(sender.clone(), attester.clone()); @@ -127,7 +127,7 @@ benchmarks! { let sender: T::AccountId = account("sender", 0, SEED); let attester: T::AttesterId = account("attester", 0, SEED); let ctype_hash: T::Hash = T::Hash::default(); - let subject_id = ::SubjectId::worst_case(); + let subject_id = ::SubjectId::worst_case(()); let contents = BoundedVec::try_from(vec![0; ::MaxEncodedClaimsLength::get() as usize]).expect("Contents should not fail."); let origin = ::EnsureOrigin::generate_origin(sender.clone(), attester.clone()); @@ -156,7 +156,7 @@ benchmarks! { let sender: T::AccountId = account("sender", 0, SEED); let attester: T::AttesterId = account("attester", 0, SEED); let ctype_hash: T::Hash = T::Hash::default(); - let subject_id = ::SubjectId::worst_case(); + let subject_id = ::SubjectId::worst_case(()); let contents = BoundedVec::try_from(vec![0; ::MaxEncodedClaimsLength::get() as usize]).expect("Contents should not fail."); let origin = ::EnsureOrigin::generate_origin(sender.clone(), attester.clone()); @@ -185,7 +185,7 @@ benchmarks! { let sender: T::AccountId = account("sender", 0, SEED); let attester: T::AttesterId = account("attester", 0, SEED); let ctype_hash: T::Hash = T::Hash::default(); - let subject_id = ::SubjectId::worst_case(); + let subject_id = ::SubjectId::worst_case(()); let contents = BoundedVec::try_from(vec![0; ::MaxEncodedClaimsLength::get() as usize]).expect("Contents should not fail."); let origin = ::EnsureOrigin::generate_origin(sender.clone(), attester.clone()); @@ -216,7 +216,7 @@ benchmarks! { let deposit_owner_new: AccountIdOf = account("caller", 1, SEED); let attester: T::AttesterId = account("attester", 0, SEED); let ctype_hash: T::Hash = T::Hash::default(); - let subject_id = ::SubjectId::worst_case(); + let subject_id = ::SubjectId::worst_case(()); let contents = BoundedVec::try_from(vec![0; ::MaxEncodedClaimsLength::get() as usize]).expect("Contents should not fail."); let origin = ::EnsureOrigin::generate_origin(deposit_owner_old.clone(), attester.clone()); @@ -252,7 +252,7 @@ benchmarks! { let deposit_owner: AccountIdOf = account("caller", 0, SEED); let attester: T::AttesterId = account("attester", 0, SEED); let ctype_hash: T::Hash = T::Hash::default(); - let subject_id = ::SubjectId::worst_case(); + let subject_id = ::SubjectId::worst_case(()); let origin = ::EnsureOrigin::generate_origin(deposit_owner.clone(), attester.clone()); reserve_balance::(&deposit_owner); diff --git a/pallets/public-credentials/src/mock.rs b/pallets/public-credentials/src/mock.rs index 07f53d6e3d..8e2634d2d9 100644 --- a/pallets/public-credentials/src/mock.rs +++ b/pallets/public-credentials/src/mock.rs @@ -249,7 +249,7 @@ pub(crate) mod runtime { #[cfg(feature = "runtime-benchmarks")] impl kilt_support::traits::GetWorstCase for TestSubjectId { // Only used for benchmark testing, not really relevant. - fn worst_case() -> Self { + fn worst_case(_context: ()) -> Self { crate::mock::TestSubjectId::default() } } diff --git a/runtimes/common/src/assets.rs b/runtimes/common/src/assets.rs index b0754e044d..4d4e03c859 100644 --- a/runtimes/common/src/assets.rs +++ b/runtimes/common/src/assets.rs @@ -105,7 +105,7 @@ mod benchmarks { } impl kilt_support::traits::GetWorstCase for AssetDid { - fn worst_case() -> Self { + fn worst_case(_context: ()) -> Self { // Returns the worst case for an AssetDID, which is represented by the longest // identifier according to the spec. Self::try_from( diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index 679e06d926..6f202d3345 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -19,7 +19,6 @@ use did::did_details::DidDetails; use frame_system::pallet_prelude::BlockNumberFor; use kilt_dip_support::merkle::RevealedWeb3Name; -use kilt_support::traits::Instanciate; use pallet_did_lookup::linkable_account::LinkableAccountId; use pallet_dip_provider::traits::IdentityProvider; use parity_scale_codec::{Decode, Encode}; @@ -27,7 +26,7 @@ use scale_info::TypeInfo; use sp_std::vec::Vec; #[cfg(feature = "runtime-benchmarks")] -use kilt_support::traits::GetWorstCase; +use kilt_support::traits::{GetWorstCase, IdentityContext}; #[derive(Encode, Decode, TypeInfo, Debug)] pub enum LinkedDidInfoProviderError { @@ -104,7 +103,7 @@ where } #[cfg(feature = "runtime-benchmarks")] -impl GetWorstCase for LinkedDidInfoOf +impl GetWorstCase> for LinkedDidInfoOf where Runtime: did::Config::Identifier> + pallet_web3_names::Config::Identifier> @@ -113,11 +112,9 @@ where + pallet_balances::Config, ::AccountId: Into + From, ::AccountId: AsRef<[u8; 32]> + From<[u8; 32]>, - Runtime::AccountId: Instanciate, - Runtime::Identifier: Instanciate, { /// The worst case for the [LinkedDidInfor] is a DID with all keys set, a web3name and linked accounts in the palled_did_lookup pallet. - fn worst_case() -> Self { + fn worst_case(context: IdentityContext) -> Self { use did::{ did_details::DidVerificationKey, mock_utils::{generate_base_did_creation_details, get_key_agreement_keys}, @@ -130,8 +127,10 @@ where use crate::constants::KILT; // Did Details. - let submitter = Runtime::AccountId::new(1); - let did = Runtime::Identifier::new(1); + + let submitter = context.submitter; + let did = context.did; + let amount = KILT * 100; // give a bit money diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index 970f4684d7..c66a4a4a41 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -953,6 +953,7 @@ impl pallet_dip_provider::Config for Runtime { type IdentityProvider = runtime_common::dip::did::LinkedDidInfoProvider; type ProviderHooks = pallet_dip_provider::NoopHooks; type RuntimeEvent = RuntimeEvent; + type WeightInfo = (); } pub struct PreliminaryDipOriginFilter; @@ -971,6 +972,7 @@ impl pallet_dip_consumer::Config for Runtime { type ProofVerifier = pallet_dip_consumer::traits::SuccessfulProofVerifier; type RuntimeCall = RuntimeCall; type RuntimeOrigin = RuntimeOrigin; + type WeightInfo = (); } construct_runtime! { diff --git a/support/src/traits.rs b/support/src/traits.rs index d2f7f978b4..789b28ada9 100644 --- a/support/src/traits.rs +++ b/support/src/traits.rs @@ -84,24 +84,30 @@ pub trait GenerateBenchmarkOrigin { /// Trait that allows types to implement a worst case value for a type, /// only when running benchmarks. #[cfg(feature = "runtime-benchmarks")] -pub trait GetWorstCase { - fn worst_case() -> Self; +pub trait GetWorstCase { + fn worst_case(context: Context) -> Self; } #[cfg(feature = "runtime-benchmarks")] -impl GetWorstCase for u32 { - fn worst_case() -> Self { +impl GetWorstCase> for u32 { + fn worst_case(_context: IdentityContext) -> Self { u32::MAX } } #[cfg(feature = "runtime-benchmarks")] -impl GetWorstCase for () { - fn worst_case() -> Self { +impl GetWorstCase> for () { + fn worst_case(_context: IdentityContext) -> Self { () } } +#[cfg(feature = "runtime-benchmarks")] +pub struct IdentityContext { + pub did: DidIdentifier, + pub submitter: AccountId, +} + /// Trait that allows instanciating multiple instances of a type. #[cfg(feature = "runtime-benchmarks")] pub trait Instanciate { From a5d246efce4d06a4d0dd2788a62f3648a4d83def Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 24 Nov 2023 12:03:46 +0100 Subject: [PATCH 28/71] clean up --- .../pallet-dip-consumer/src/benchmarking.rs | 5 ++- .../pallet-dip-provider/src/benchmarking.rs | 5 ++- support/src/benchmark.rs | 34 +++++++++++++++++++ support/src/lib.rs | 3 ++ support/src/traits.rs | 20 ----------- 5 files changed, 45 insertions(+), 22 deletions(-) create mode 100644 support/src/benchmark.rs diff --git a/pallets/pallet-dip-consumer/src/benchmarking.rs b/pallets/pallet-dip-consumer/src/benchmarking.rs index 1de8604af4..e1f8a71bd7 100644 --- a/pallets/pallet-dip-consumer/src/benchmarking.rs +++ b/pallets/pallet-dip-consumer/src/benchmarking.rs @@ -19,7 +19,10 @@ use crate::{traits::IdentityProofVerifier, Call, Config, IdentityEntries, Pallet}; use frame_benchmarking::v2::*; use frame_system::RawOrigin; -use kilt_support::traits::{GetWorstCase, IdentityContext, Instanciate}; +use kilt_support::{ + benchmark::IdentityContext, + traits::{GetWorstCase, Instanciate}, +}; #[benchmarks( where diff --git a/pallets/pallet-dip-provider/src/benchmarking.rs b/pallets/pallet-dip-provider/src/benchmarking.rs index 9d99826e04..df55cf10fb 100644 --- a/pallets/pallet-dip-provider/src/benchmarking.rs +++ b/pallets/pallet-dip-provider/src/benchmarking.rs @@ -18,7 +18,10 @@ use crate::{traits::IdentityProvider, Call, Config, Pallet}; use frame_benchmarking::v2::*; -use kilt_support::traits::{GenerateBenchmarkOrigin, GetWorstCase, IdentityContext, Instanciate}; +use kilt_support::{ + benchmark::IdentityContext, + traits::{GenerateBenchmarkOrigin, GetWorstCase, Instanciate}, +}; #[benchmarks( where diff --git a/support/src/benchmark.rs b/support/src/benchmark.rs new file mode 100644 index 0000000000..2c7409365d --- /dev/null +++ b/support/src/benchmark.rs @@ -0,0 +1,34 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +use crate::traits::GetWorstCase; + +pub struct IdentityContext { + pub did: DidIdentifier, + pub submitter: AccountId, +} + +impl GetWorstCase> for u32 { + fn worst_case(_context: IdentityContext) -> Self { + u32::MAX + } +} + +impl GetWorstCase> for () { + fn worst_case(_context: IdentityContext) -> Self { + () + } +} diff --git a/support/src/lib.rs b/support/src/lib.rs index 758062f925..e156ddc020 100644 --- a/support/src/lib.rs +++ b/support/src/lib.rs @@ -28,3 +28,6 @@ pub mod mock; #[cfg(any(feature = "try-runtime", test))] pub mod test_utils; + +#[cfg(feature = "runtime-benchmarks")] +pub mod benchmark; diff --git a/support/src/traits.rs b/support/src/traits.rs index 789b28ada9..51f6cc9179 100644 --- a/support/src/traits.rs +++ b/support/src/traits.rs @@ -88,26 +88,6 @@ pub trait GetWorstCase { fn worst_case(context: Context) -> Self; } -#[cfg(feature = "runtime-benchmarks")] -impl GetWorstCase> for u32 { - fn worst_case(_context: IdentityContext) -> Self { - u32::MAX - } -} - -#[cfg(feature = "runtime-benchmarks")] -impl GetWorstCase> for () { - fn worst_case(_context: IdentityContext) -> Self { - () - } -} - -#[cfg(feature = "runtime-benchmarks")] -pub struct IdentityContext { - pub did: DidIdentifier, - pub submitter: AccountId, -} - /// Trait that allows instanciating multiple instances of a type. #[cfg(feature = "runtime-benchmarks")] pub trait Instanciate { From b0f42c4bb79040e2a68f28695da94335c2d8cdb5 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 24 Nov 2023 12:31:19 +0100 Subject: [PATCH 29/71] clean up --- pallets/pallet-did-lookup/src/lib.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/pallets/pallet-did-lookup/src/lib.rs b/pallets/pallet-did-lookup/src/lib.rs index a8967c57a5..9c00e1dc36 100644 --- a/pallets/pallet-did-lookup/src/lib.rs +++ b/pallets/pallet-did-lookup/src/lib.rs @@ -86,7 +86,6 @@ pub mod pallet { pub(crate) type BalanceMigrationManagerOf = ::BalanceMigrationManager; /// Sets an upper limit for the benchmarks, which must be altered if a user has more linked accounts. - #[cfg(any(feature = "runtime-benchmarks", feature = "try-runtime"))] pub const MAX_LINKED_ACCOUNT: u32 = 10; const STORAGE_VERSION: StorageVersion = StorageVersion::new(4); From db976e46e9258334c789f9064ec84c5f6be5a6bc Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 24 Nov 2023 12:34:37 +0100 Subject: [PATCH 30/71] remove trait --- pallets/pallet-dip-provider/src/traits.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pallets/pallet-dip-provider/src/traits.rs b/pallets/pallet-dip-provider/src/traits.rs index 04a08e3103..80af347d34 100644 --- a/pallets/pallet-dip-provider/src/traits.rs +++ b/pallets/pallet-dip-provider/src/traits.rs @@ -184,8 +184,3 @@ where Ok(()) } } - -#[cfg(feature = "runtime-benchmarks")] -pub trait SetupDipIdentityProviderBenchmark { - fn get_worst_case(did: DidIdentifier, submitter: AccountId) -> Self; -} From 11f9e28bcef42b82514a54669a538764de44ad03 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 24 Nov 2023 12:35:35 +0100 Subject: [PATCH 31/71] comment --- runtimes/common/src/dip/did.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index 6f202d3345..1b1de8a4ac 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -133,7 +133,7 @@ where let amount = KILT * 100; - // give a bit money + // give some money as Mutate<::AccountId>>::set_balance( &submitter, amount.saturated_into(), From faf0a30af73f0991d9f46d9a9952b5a4273ec37f Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 24 Nov 2023 12:38:56 +0100 Subject: [PATCH 32/71] comments --- runtimes/common/src/dip/did.rs | 1 - support/src/benchmark.rs | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index 1b1de8a4ac..471c33f4aa 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -145,7 +145,6 @@ where let mut did_creation_details = generate_base_did_creation_details(did.clone(), submitter.clone()); - // TODO check if I have to set different seed. Prob not but lets be sure. let attestation_key = ed25519_generate(KeyTypeId(*b"0001"), None); let delegation_key = ed25519_generate(KeyTypeId(*b"0002"), None); let auth_key = ed25519_generate(KeyTypeId(*b"0003"), None); diff --git a/support/src/benchmark.rs b/support/src/benchmark.rs index 2c7409365d..ac7d80a387 100644 --- a/support/src/benchmark.rs +++ b/support/src/benchmark.rs @@ -16,7 +16,8 @@ use crate::traits::GetWorstCase; -pub struct IdentityContext { +/// Manly used for the DIP benchmarking. The worst case can be created for the did and submitter. +pub struct IdentityContext { pub did: DidIdentifier, pub submitter: AccountId, } From e94caab229cb66913492310cb029e1db58eca40d Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 24 Nov 2023 14:43:22 +0100 Subject: [PATCH 33/71] pallet storage deposit! --- Cargo.lock | 5 + pallets/pallet-deposit-storage/Cargo.toml | 18 ++- .../src/benchmarking.rs | 88 ++++++++++++ .../src/default_weights.rs | 73 ++++++++++ pallets/pallet-deposit-storage/src/lib.rs | 6 + pallets/pallet-deposit-storage/src/mock.rs | 131 ++++++++++++++++++ runtimes/common/src/dip/did.rs | 2 +- runtimes/peregrine/Cargo.toml | 5 + runtimes/peregrine/src/lib.rs | 23 +++ 9 files changed, 348 insertions(+), 3 deletions(-) create mode 100644 pallets/pallet-deposit-storage/src/benchmarking.rs create mode 100644 pallets/pallet-deposit-storage/src/default_weights.rs create mode 100644 pallets/pallet-deposit-storage/src/mock.rs diff --git a/Cargo.lock b/Cargo.lock index 9320db4b06..eb20d752a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6479,13 +6479,17 @@ dependencies = [ name = "pallet-deposit-storage" version = "1.12.0-dev" dependencies = [ + "frame-benchmarking", "frame-support", "frame-system", "kilt-support", "log", + "pallet-balances", "pallet-dip-provider", "parity-scale-codec", "scale-info", + "sp-io", + "sp-keystore", "sp-runtime", "sp-std", ] @@ -7644,6 +7648,7 @@ dependencies = [ "pallet-collective", "pallet-configuration", "pallet-democracy", + "pallet-deposit-storage", "pallet-did-lookup", "pallet-dip-consumer", "pallet-dip-provider", diff --git a/pallets/pallet-deposit-storage/Cargo.toml b/pallets/pallet-deposit-storage/Cargo.toml index 914806a69e..dd7757f7a1 100644 --- a/pallets/pallet-deposit-storage/Cargo.toml +++ b/pallets/pallet-deposit-storage/Cargo.toml @@ -13,19 +13,28 @@ description = "Stores all deposits under a single pallet, with suport for namesp [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] +[dev-dependencies] +sp-keystore = { workspace = true, features = ["std"] } + [dependencies] # Substrate dependencies frame-support.workspace = true frame-system.workspace = true kilt-support.workspace = true pallet-dip-provider.workspace = true -parity-scale-codec = {workspace = true, features = ["derive"]} -scale-info = {workspace = true, features = ["derive"]} +parity-scale-codec = { workspace = true, features = ["derive"] } +scale-info = { workspace = true, features = ["derive"] } sp-runtime.workspace = true sp-std.workspace = true log.workspace = true +# Benchmarking +pallet-balances = { workspace = true, optional = true } +frame-benchmarking = { workspace = true, optional = true } +sp-io = { workspace = true, optional = true } + + [features] default = ["std"] std = [ @@ -38,4 +47,9 @@ std = [ "sp-runtime/std", "sp-std/std", "log/std", + "sp-keystore/std", ] + +runtime-benchmarks = ["frame-benchmarking", "pallet-balances"] + +try-runtime = ["kilt-support/try-runtime"] diff --git a/pallets/pallet-deposit-storage/src/benchmarking.rs b/pallets/pallet-deposit-storage/src/benchmarking.rs new file mode 100644 index 0000000000..e4827a83e7 --- /dev/null +++ b/pallets/pallet-deposit-storage/src/benchmarking.rs @@ -0,0 +1,88 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use crate::{Call, Config, DepositEntryOf, DepositKeyOf, Deposits, HoldReason, Pallet}; +use frame_benchmarking::v2::*; +use frame_support::traits::fungible::Mutate; +use frame_system::RawOrigin; +use kilt_support::{traits::Instanciate, Deposit}; +use sp_runtime::SaturatedConversion; + +#[benchmarks( + where + T::AccountId: Instanciate, + T: Config + pallet_balances::Config, + T::Namespace: Default +) ] +mod benchmarks { + + use sp_runtime::BoundedVec; + + use super::*; + + const KILT: u128 = 10u128.pow(15); + + #[benchmark] + fn reclaim_deposit() { + let submitter = T::AccountId::new(1); + + let origin = RawOrigin::Signed(submitter.clone()); + + let namespace: ::Namespace = Default::default(); + + let key: DepositKeyOf = BoundedVec::try_from(vec![1]).expect("Creation of key should not fail."); + + assert!(Deposits::::get(&namespace, &key).is_none()); + + let entry = DepositEntryOf:: { + deposit: Deposit { + amount: KILT.saturated_into(), + owner: submitter.clone(), + }, + reason: ::RuntimeHoldReason::from(HoldReason::Deposit), + }; + + let amount = KILT * 100; + + as Mutate<::AccountId>>::set_balance( + &submitter, + amount.saturated_into(), + ); + + Pallet::::add_deposit(namespace.clone(), key.clone(), entry).expect("Creating Deposit should not fail."); + + assert!(Deposits::::get(&namespace, &key).is_some()); + + #[extrinsic_call] + Pallet::::reclaim_deposit(origin, namespace.clone(), key.clone()); + + assert!(Deposits::::get(&namespace, &key).is_none()); + } + + #[cfg(test)] + mod benchmarks_tests { + use crate::Pallet; + use frame_benchmarking::impl_benchmark_test_suite; + + impl_benchmark_test_suite!( + Pallet, + crate::mock::ExtBuilder::default().build_with_keystore(), + crate::mock::TestRuntime, + ); + } +} diff --git a/pallets/pallet-deposit-storage/src/default_weights.rs b/pallets/pallet-deposit-storage/src/default_weights.rs new file mode 100644 index 0000000000..6d06180676 --- /dev/null +++ b/pallets/pallet-deposit-storage/src/default_weights.rs @@ -0,0 +1,73 @@ + +//! Autogenerated weights for pallet_deposit_storage +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-11-24 +//! STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/debug/kilt-parachain +// benchmark +// pallet +// --pallet +// pallet-deposit-storage +// --extrinsic +// * +// --template +// ./.maintain/weight-template.hbs +// --output +// ./pallets/pallet-deposit-storage/src/defaul_weights.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_deposit_storage. +pub trait WeightInfo { + fn reclaim_deposit() -> Weight; +} + +/// Weights for pallet_deposit_storage using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: `StorageDeposit::Deposits` (r:1 w:1) + /// Proof: `StorageDeposit::Deposits` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + fn reclaim_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `907` + // Estimated: `4414` + // Minimum execution time: 704_964 nanoseconds. + Weight::from_parts(1_003_107_000, 4414) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + /// Storage: `StorageDeposit::Deposits` (r:1 w:1) + /// Proof: `StorageDeposit::Deposits` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(132), added: 2607, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + fn reclaim_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `907` + // Estimated: `4414` + // Minimum execution time: 704_964 nanoseconds. + Weight::from_parts(1_003_107_000, 4414) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } +} diff --git a/pallets/pallet-deposit-storage/src/lib.rs b/pallets/pallet-deposit-storage/src/lib.rs index e683b27eac..86f2c7e689 100644 --- a/pallets/pallet-deposit-storage/src/lib.rs +++ b/pallets/pallet-deposit-storage/src/lib.rs @@ -22,6 +22,12 @@ mod deposit; pub mod traits; +#[cfg(test)] +mod mock; + +#[cfg(feature = "runtime-benchmarks")] +mod benchmarking; + pub use deposit::FixedDepositCollectorViaDepositsPallet; pub use pallet::*; pub use traits::NoopDepositStorageHooks; diff --git a/pallets/pallet-deposit-storage/src/mock.rs b/pallets/pallet-deposit-storage/src/mock.rs new file mode 100644 index 0000000000..5f40b5b240 --- /dev/null +++ b/pallets/pallet-deposit-storage/src/mock.rs @@ -0,0 +1,131 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::{ + construct_runtime, parameter_types, + sp_runtime::{ + testing::H256, + traits::{BlakeTwo256, IdentityLookup}, + AccountId32, + }, + traits::{ConstU16, ConstU32, ConstU64, Everything}, +}; +use frame_system::{mocking::MockBlock, EnsureSigned}; +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; +use scale_info::TypeInfo; +use sp_runtime::RuntimeDebug; + +use crate::{self as storage_deposit_pallet, NoopDepositStorageHooks}; + +pub(crate) type Balance = u128; + +#[derive(Encode, Decode, MaxEncodedLen, TypeInfo, Clone, PartialEq, Eq, RuntimeDebug)] +pub enum DepositNamespaces { + ExampleNameSpaces, +} + +impl Default for DepositNamespaces { + fn default() -> Self { + DepositNamespaces::ExampleNameSpaces + } +} + +construct_runtime!( + pub struct TestRuntime { + System: frame_system, + StorageDepositPallet: storage_deposit_pallet, + Balances: pallet_balances, + } +); + +impl frame_system::Config for TestRuntime { + type AccountData = pallet_balances::AccountData; + type AccountId = AccountId32; + type BaseCallFilter = Everything; + type Block = MockBlock; + type BlockHashCount = ConstU64<256>; + type BlockLength = (); + type BlockWeights = (); + type DbWeight = (); + type Hash = H256; + type Hashing = BlakeTwo256; + type Lookup = IdentityLookup; + type MaxConsumers = ConstU32<16>; + type Nonce = u64; + type OnKilledAccount = (); + type OnNewAccount = (); + type OnSetCode = (); + type PalletInfo = PalletInfo; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type SS58Prefix = ConstU16<1>; + type SystemWeightInfo = (); + type Version = (); +} + +parameter_types! { + pub const ExistentialDeposit: Balance = 500; + pub const MaxLocks: u32 = 50; + pub const MaxReserves: u32 = 50; + pub const MaxHolds: u32 = 50; + pub const MaxFreezes: u32 = 50; +} + +impl pallet_balances::Config for TestRuntime { + type FreezeIdentifier = RuntimeFreezeReason; + type RuntimeHoldReason = RuntimeHoldReason; + type MaxFreezes = MaxFreezes; + type MaxHolds = MaxHolds; + type Balance = Balance; + type DustRemoval = (); + type RuntimeEvent = RuntimeEvent; + type ExistentialDeposit = ExistentialDeposit; + type AccountStore = System; + type WeightInfo = (); + type MaxLocks = MaxLocks; + type MaxReserves = MaxReserves; + type ReserveIdentifier = [u8; 8]; +} + +impl crate::Config for TestRuntime { + type CheckOrigin = EnsureSigned; + type Currency = Balances; + type DepositHooks = NoopDepositStorageHooks; + type RuntimeEvent = RuntimeEvent; + type RuntimeHoldReason = RuntimeHoldReason; + type MaxKeyLength = ConstU32<256>; + type Namespace = DepositNamespaces; +} + +#[derive(Default)] +pub(crate) struct ExtBuilder; + +impl ExtBuilder { + pub fn _build(self) -> sp_io::TestExternalities { + sp_io::TestExternalities::default() + } + + #[cfg(feature = "runtime-benchmarks")] + pub fn build_with_keystore(self) -> sp_io::TestExternalities { + let mut ext = self._build(); + let keystore = sp_keystore::testing::MemoryKeystore::new(); + ext.register_extension(sp_keystore::KeystoreExt(sp_std::sync::Arc::new(keystore))); + ext + } +} diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index 471c33f4aa..689832d02c 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -26,7 +26,7 @@ use scale_info::TypeInfo; use sp_std::vec::Vec; #[cfg(feature = "runtime-benchmarks")] -use kilt_support::traits::{GetWorstCase, IdentityContext}; +use kilt_support::{benchmark::IdentityContext, traits::GetWorstCase}; #[derive(Encode, Decode, TypeInfo, Debug)] pub enum LinkedDidInfoProviderError { diff --git a/runtimes/peregrine/Cargo.toml b/runtimes/peregrine/Cargo.toml index bb9066dbe5..b2d484eecc 100644 --- a/runtimes/peregrine/Cargo.toml +++ b/runtimes/peregrine/Cargo.toml @@ -47,6 +47,8 @@ public-credentials.workspace = true runtime-common.workspace = true pallet-dip-provider.workspace = true pallet-dip-consumer.workspace = true +pallet-deposit-storage.workspace = true + # Substrate dependencies sp-api.workspace = true @@ -156,6 +158,7 @@ runtime-benchmarks = [ "xcm-executor/runtime-benchmarks", "pallet-dip-provider/runtime-benchmarks", "pallet-dip-consumer/runtime-benchmarks", + "pallet-deposit-storage/runtime-benchmarks", ] std = [ "attestation/std", @@ -233,6 +236,7 @@ std = [ "xcm/std", "pallet-dip-provider/std", "pallet-dip-consumer/std", + "pallet-deposit-storage/std", ] try-runtime = [ "attestation/try-runtime", @@ -280,5 +284,6 @@ try-runtime = [ "runtime-common/try-runtime", "pallet-dip-provider/try-runtime", "pallet-dip-consumer/try-runtime", + "pallet-deposit-storage/try-runtime", ] with-tracing = ["frame-executive/with-tracing", "sp-io/with-tracing"] diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index c66a4a4a41..294322bb83 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -956,6 +956,27 @@ impl pallet_dip_provider::Config for Runtime { type WeightInfo = (); } +#[derive(Encode, Decode, MaxEncodedLen, scale_info::TypeInfo, Clone, PartialEq, Eq, RuntimeDebug)] +pub enum DepositNamespaces { + ExampleNameSpaces, +} + +impl Default for DepositNamespaces { + fn default() -> Self { + DepositNamespaces::ExampleNameSpaces + } +} + +impl pallet_deposit_storage::Config for Runtime { + type CheckOrigin = EnsureSigned; + type Currency = Balances; + type DepositHooks = pallet_deposit_storage::traits::NoopDepositStorageHooks; + type MaxKeyLength = ConstU32<256>; + type RuntimeEvent = RuntimeEvent; + type RuntimeHoldReason = RuntimeHoldReason; + type Namespace = DepositNamespaces; +} + pub struct PreliminaryDipOriginFilter; impl frame_support::traits::Contains for PreliminaryDipOriginFilter { @@ -1040,6 +1061,7 @@ construct_runtime! { Migration: pallet_migration = 70, PalletDipProvider: pallet_dip_provider = 71, PalletDipConsumer: pallet_dip_consumer = 72, + StorageDeposit: pallet_deposit_storage = 73, // Parachains pallets. Start indices at 80 to leave room. @@ -1181,6 +1203,7 @@ mod benches { [frame_benchmarking::baseline, Baseline::] [pallet_dip_provider, PalletDipProvider] [pallet_dip_consumer, PalletDipConsumer] + [pallet_deposit_storage, StorageDeposit] ); } From 650d311001531290273266be5658c7437289dce7 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 24 Nov 2023 14:50:07 +0100 Subject: [PATCH 34/71] add weightinfo --- dip-template/runtimes/dip-provider/src/dip.rs | 1 + pallets/pallet-deposit-storage/src/lib.rs | 3 +++ runtimes/peregrine/src/lib.rs | 1 + 3 files changed, 5 insertions(+) diff --git a/dip-template/runtimes/dip-provider/src/dip.rs b/dip-template/runtimes/dip-provider/src/dip.rs index ff8e3a6af7..d0b8bb3904 100644 --- a/dip-template/runtimes/dip-provider/src/dip.rs +++ b/dip-template/runtimes/dip-provider/src/dip.rs @@ -133,6 +133,7 @@ impl pallet_deposit_storage::Config for Runtime { type Namespace = DepositNamespaces; type RuntimeEvent = RuntimeEvent; type RuntimeHoldReason = RuntimeHoldReason; + type WeightInfo = (); } impl pallet_dip_provider::Config for Runtime { diff --git a/pallets/pallet-deposit-storage/src/lib.rs b/pallets/pallet-deposit-storage/src/lib.rs index 86f2c7e689..86fdc31c50 100644 --- a/pallets/pallet-deposit-storage/src/lib.rs +++ b/pallets/pallet-deposit-storage/src/lib.rs @@ -19,6 +19,7 @@ #![cfg_attr(not(feature = "std"), no_std)] #![recursion_limit = "256"] +pub mod default_weights; mod deposit; pub mod traits; @@ -35,6 +36,7 @@ pub use traits::NoopDepositStorageHooks; #[frame_support::pallet(dev_mode)] pub mod pallet { use crate::{ + default_weights::WeightInfo, deposit::{free_deposit, reserve_deposit, DepositEntry}, traits::DepositStorageHooks, }; @@ -73,6 +75,7 @@ pub mod pallet { type Namespace: Parameter; type RuntimeEvent: From> + IsType<::RuntimeEvent>; type RuntimeHoldReason: From + Clone + PartialEq + Debug + FullCodec + MaxEncodedLen + TypeInfo; + type WeightInfo: WeightInfo; } #[pallet::composite_enum] diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index 0cbdb0708c..c58ba7f7b9 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -975,6 +975,7 @@ impl pallet_deposit_storage::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeHoldReason = RuntimeHoldReason; type Namespace = DepositNamespaces; + type WeightInfo = (); } pub struct PreliminaryDipOriginFilter; From 3b33c6151297664449e7db78128c03e21af95154 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 24 Nov 2023 14:57:38 +0100 Subject: [PATCH 35/71] add weight logic --- pallets/pallet-deposit-storage/src/lib.rs | 5 +++-- pallets/pallet-dip-consumer/src/lib.rs | 6 +++++- pallets/pallet-dip-provider/src/lib.rs | 8 ++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pallets/pallet-deposit-storage/src/lib.rs b/pallets/pallet-deposit-storage/src/lib.rs index 86fdc31c50..b707db62bc 100644 --- a/pallets/pallet-deposit-storage/src/lib.rs +++ b/pallets/pallet-deposit-storage/src/lib.rs @@ -119,8 +119,9 @@ pub mod pallet { #[pallet::call] impl Pallet { #[pallet::call_index(0)] - // TODO: Update weight - #[pallet::weight(0)] + #[pallet::weight({ + ::WeightInfo::reclaim_deposit() + })] pub fn reclaim_deposit(origin: OriginFor, namespace: T::Namespace, key: DepositKeyOf) -> DispatchResult { let dispatcher = T::CheckOrigin::ensure_origin(origin)?; diff --git a/pallets/pallet-dip-consumer/src/lib.rs b/pallets/pallet-dip-consumer/src/lib.rs index 788bb4de46..480e88842f 100644 --- a/pallets/pallet-dip-consumer/src/lib.rs +++ b/pallets/pallet-dip-consumer/src/lib.rs @@ -109,7 +109,11 @@ pub mod pallet { impl Pallet { // TODO: Replace with a SignedExtra. #[pallet::call_index(0)] - #[pallet::weight(0)] + #[pallet::weight({ + let extrinsic_weight = ::WeightInfo::dispatch_as(); + let call_weight = call.get_dispatch_info().weight; + extrinsic_weight.saturating_add(call_weight) + })] pub fn dispatch_as( origin: OriginFor, identifier: T::Identifier, diff --git a/pallets/pallet-dip-provider/src/lib.rs b/pallets/pallet-dip-provider/src/lib.rs index 8e2d2cc227..3ae6e32173 100644 --- a/pallets/pallet-dip-provider/src/lib.rs +++ b/pallets/pallet-dip-provider/src/lib.rs @@ -106,7 +106,9 @@ pub mod pallet { impl Pallet { #[pallet::call_index(0)] // TODO: Update weight - #[pallet::weight(0)] + #[pallet::weight({ + ::WeightInfo::commit_identity() + })] pub fn commit_identity( origin: OriginFor, identifier: T::Identifier, @@ -151,7 +153,9 @@ pub mod pallet { #[pallet::call_index(1)] // TODO: Update weight - #[pallet::weight(0)] + #[pallet::weight({ + ::WeightInfo::delete_identity_commitment() + })] pub fn delete_identity_commitment( origin: OriginFor, identifier: T::Identifier, From 9dfcf0396aca4f876d548d1b96d43f70bca805d7 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 24 Nov 2023 15:03:02 +0100 Subject: [PATCH 36/71] remove comments --- pallets/pallet-dip-provider/src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/pallets/pallet-dip-provider/src/lib.rs b/pallets/pallet-dip-provider/src/lib.rs index 3ae6e32173..4223c9cb77 100644 --- a/pallets/pallet-dip-provider/src/lib.rs +++ b/pallets/pallet-dip-provider/src/lib.rs @@ -105,7 +105,6 @@ pub mod pallet { #[pallet::call] impl Pallet { #[pallet::call_index(0)] - // TODO: Update weight #[pallet::weight({ ::WeightInfo::commit_identity() })] @@ -152,7 +151,6 @@ pub mod pallet { } #[pallet::call_index(1)] - // TODO: Update weight #[pallet::weight({ ::WeightInfo::delete_identity_commitment() })] From ad270c5742422f1cf4174a38ec0cf9d2d4813c17 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 24 Nov 2023 15:05:07 +0100 Subject: [PATCH 37/71] remove comments --- runtimes/common/src/dip/did.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index 689832d02c..c36a0354a6 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -113,7 +113,6 @@ where ::AccountId: Into + From, ::AccountId: AsRef<[u8; 32]> + From<[u8; 32]>, { - /// The worst case for the [LinkedDidInfor] is a DID with all keys set, a web3name and linked accounts in the palled_did_lookup pallet. fn worst_case(context: IdentityContext) -> Self { use did::{ did_details::DidVerificationKey, From 1fe7290f292c760332f5c1324e6efcaca5bc28dd Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 29 Nov 2023 09:23:11 +0100 Subject: [PATCH 38/71] change imports --- support/src/traits.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/support/src/traits.rs b/support/src/traits.rs index 51f6cc9179..96138f182d 100644 --- a/support/src/traits.rs +++ b/support/src/traits.rs @@ -23,9 +23,6 @@ use frame_support::traits::{ use sp_runtime::DispatchError; use sp_std::vec::Vec; -#[cfg(feature = "runtime-benchmarks")] -use sp_runtime::{traits::BlakeTwo256, AccountId32}; - use crate::deposit::{free_deposit, reserve_deposit, Deposit}; /// The sources of a call struct. @@ -95,10 +92,12 @@ pub trait Instanciate { } #[cfg(feature = "runtime-benchmarks")] -impl Instanciate for AccountId32 { +impl Instanciate for sp_runtime::AccountId32 { fn new(instance: u32) -> Self { use sp_runtime::traits::Hash; - AccountId32::from(<[u8; 32]>::from(BlakeTwo256::hash(&instance.to_be_bytes()))) + sp_runtime::AccountId32::from(<[u8; 32]>::from(sp_runtime::traits::BlakeTwo256::hash( + &instance.to_be_bytes(), + ))) } } From daea05f2c50c368e9cfd7395f62fe6921622a0b6 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 29 Nov 2023 09:37:32 +0100 Subject: [PATCH 39/71] change default implementation --- support/src/benchmark.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/support/src/benchmark.rs b/support/src/benchmark.rs index ac7d80a387..b2e82f84e1 100644 --- a/support/src/benchmark.rs +++ b/support/src/benchmark.rs @@ -22,14 +22,14 @@ pub struct IdentityContext { pub submitter: AccountId, } -impl GetWorstCase> for u32 { - fn worst_case(_context: IdentityContext) -> Self { +impl GetWorstCase for u32 { + fn worst_case(_context: T) -> Self { u32::MAX } } -impl GetWorstCase> for () { - fn worst_case(_context: IdentityContext) -> Self { +impl GetWorstCase for () { + fn worst_case(_context: T) -> Self { () } } From 76c79bf81b351b4ed83f2c1cdfae6904af455aff Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 29 Nov 2023 09:55:51 +0100 Subject: [PATCH 40/71] remove dummy impl --- Cargo.lock | 3 -- pallets/pallet-deposit-storage/src/mock.rs | 1 + runtimes/peregrine/Cargo.toml | 13 ----- runtimes/peregrine/src/lib.rs | 58 ---------------------- 4 files changed, 1 insertion(+), 74 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eb20d752a9..44f3b83927 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7648,10 +7648,7 @@ dependencies = [ "pallet-collective", "pallet-configuration", "pallet-democracy", - "pallet-deposit-storage", "pallet-did-lookup", - "pallet-dip-consumer", - "pallet-dip-provider", "pallet-indices", "pallet-inflation", "pallet-membership", diff --git a/pallets/pallet-deposit-storage/src/mock.rs b/pallets/pallet-deposit-storage/src/mock.rs index 5f40b5b240..23c0a68264 100644 --- a/pallets/pallet-deposit-storage/src/mock.rs +++ b/pallets/pallet-deposit-storage/src/mock.rs @@ -111,6 +111,7 @@ impl crate::Config for TestRuntime { type RuntimeHoldReason = RuntimeHoldReason; type MaxKeyLength = ConstU32<256>; type Namespace = DepositNamespaces; + type WeightInfo = (); } #[derive(Default)] diff --git a/runtimes/peregrine/Cargo.toml b/runtimes/peregrine/Cargo.toml index b2d484eecc..2e116941ce 100644 --- a/runtimes/peregrine/Cargo.toml +++ b/runtimes/peregrine/Cargo.toml @@ -45,10 +45,6 @@ pallet-migration.workspace = true parachain-staking.workspace = true public-credentials.workspace = true runtime-common.workspace = true -pallet-dip-provider.workspace = true -pallet-dip-consumer.workspace = true -pallet-deposit-storage.workspace = true - # Substrate dependencies sp-api.workspace = true @@ -156,9 +152,6 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "pallet-dip-provider/runtime-benchmarks", - "pallet-dip-consumer/runtime-benchmarks", - "pallet-deposit-storage/runtime-benchmarks", ] std = [ "attestation/std", @@ -234,9 +227,6 @@ std = [ "xcm-builder/std", "xcm-executor/std", "xcm/std", - "pallet-dip-provider/std", - "pallet-dip-consumer/std", - "pallet-deposit-storage/std", ] try-runtime = [ "attestation/try-runtime", @@ -282,8 +272,5 @@ try-runtime = [ "parachain-staking/try-runtime", "public-credentials/try-runtime", "runtime-common/try-runtime", - "pallet-dip-provider/try-runtime", - "pallet-dip-consumer/try-runtime", - "pallet-deposit-storage/try-runtime", ] with-tracing = ["frame-executive/with-tracing", "sp-io/with-tracing"] diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index c58ba7f7b9..f92550a3a1 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -945,58 +945,6 @@ impl pallet_proxy::Config for Runtime { type WeightInfo = weights::pallet_proxy::WeightInfo; } -impl pallet_dip_provider::Config for Runtime { - type CommitOriginCheck = did::EnsureDidOrigin; - type CommitOrigin = did::DidRawOrigin; - type Identifier = DidIdentifier; - type IdentityCommitmentGenerator = runtime_common::dip::merkle::DidMerkleRootGenerator; - type IdentityProvider = runtime_common::dip::did::LinkedDidInfoProvider; - type ProviderHooks = pallet_dip_provider::NoopHooks; - type RuntimeEvent = RuntimeEvent; - type WeightInfo = (); -} - -#[derive(Encode, Decode, MaxEncodedLen, scale_info::TypeInfo, Clone, PartialEq, Eq, RuntimeDebug)] -pub enum DepositNamespaces { - ExampleNameSpaces, -} - -impl Default for DepositNamespaces { - fn default() -> Self { - DepositNamespaces::ExampleNameSpaces - } -} - -impl pallet_deposit_storage::Config for Runtime { - type CheckOrigin = EnsureSigned; - type Currency = Balances; - type DepositHooks = pallet_deposit_storage::traits::NoopDepositStorageHooks; - type MaxKeyLength = ConstU32<256>; - type RuntimeEvent = RuntimeEvent; - type RuntimeHoldReason = RuntimeHoldReason; - type Namespace = DepositNamespaces; - type WeightInfo = (); -} - -pub struct PreliminaryDipOriginFilter; - -impl frame_support::traits::Contains for PreliminaryDipOriginFilter { - fn contains(_t: &RuntimeCall) -> bool { - true - } -} - -impl pallet_dip_consumer::Config for Runtime { - type DipCallOriginFilter = PreliminaryDipOriginFilter; - type DispatchOriginCheck = EnsureSigned; - type Identifier = DidIdentifier; - type LocalIdentityInfo = u128; - type ProofVerifier = pallet_dip_consumer::traits::SuccessfulProofVerifier; - type RuntimeCall = RuntimeCall; - type RuntimeOrigin = RuntimeOrigin; - type WeightInfo = (); -} - construct_runtime! { pub enum Runtime { @@ -1060,9 +1008,6 @@ construct_runtime! { Web3Names: pallet_web3_names = 68, PublicCredentials: public_credentials = 69, Migration: pallet_migration = 70, - PalletDipProvider: pallet_dip_provider = 71, - PalletDipConsumer: pallet_dip_consumer = 72, - StorageDeposit: pallet_deposit_storage = 73, // Parachains pallets. Start indices at 80 to leave room. @@ -1203,9 +1148,6 @@ mod benches { [pallet_xcm, PolkadotXcm] [pallet_migration, Migration] [frame_benchmarking::baseline, Baseline::] - [pallet_dip_provider, PalletDipProvider] - [pallet_dip_consumer, PalletDipConsumer] - [pallet_deposit_storage, StorageDeposit] ); } From 9594535d4361d0c380c8e97cc5c33c80b6ec16c3 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 29 Nov 2023 10:31:12 +0100 Subject: [PATCH 41/71] remove casts --- pallets/pallet-deposit-storage/src/benchmarking.rs | 5 ++++- pallets/pallet-dip-consumer/src/benchmarking.rs | 7 +++++-- pallets/pallet-dip-provider/src/benchmarking.rs | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pallets/pallet-deposit-storage/src/benchmarking.rs b/pallets/pallet-deposit-storage/src/benchmarking.rs index e4827a83e7..1ced420c73 100644 --- a/pallets/pallet-deposit-storage/src/benchmarking.rs +++ b/pallets/pallet-deposit-storage/src/benchmarking.rs @@ -68,8 +68,11 @@ mod benchmarks { assert!(Deposits::::get(&namespace, &key).is_some()); + let cloned_namespace = namespace.clone(); + let cloned_key = key.clone(); + #[extrinsic_call] - Pallet::::reclaim_deposit(origin, namespace.clone(), key.clone()); + Pallet::::reclaim_deposit(origin, cloned_namespace, cloned_key); assert!(Deposits::::get(&namespace, &key).is_none()); } diff --git a/pallets/pallet-dip-consumer/src/benchmarking.rs b/pallets/pallet-dip-consumer/src/benchmarking.rs index e1f8a71bd7..fcad9a13aa 100644 --- a/pallets/pallet-dip-consumer/src/benchmarking.rs +++ b/pallets/pallet-dip-consumer/src/benchmarking.rs @@ -60,10 +60,13 @@ mod benchmarks { IdentityContextOf, >>::worst_case(context); + let cloned_subject = subject.clone(); + let origin = ::RuntimeOrigin::from(origin); + #[extrinsic_call] Pallet::::dispatch_as( - ::RuntimeOrigin::from(origin) as ::RuntimeOrigin, - subject.clone(), + origin as ::RuntimeOrigin, + cloned_subject, proof, boxed_call, ); diff --git a/pallets/pallet-dip-provider/src/benchmarking.rs b/pallets/pallet-dip-provider/src/benchmarking.rs index df55cf10fb..3918c9d181 100644 --- a/pallets/pallet-dip-provider/src/benchmarking.rs +++ b/pallets/pallet-dip-provider/src/benchmarking.rs @@ -56,8 +56,10 @@ mod benchmarks { IdentityContextOf, >>::worst_case(context); + let cloned_subject = subject.clone(); + #[extrinsic_call] - Pallet::::commit_identity(origin as T::RuntimeOrigin, subject.clone(), Some(commitment_version)); + Pallet::::commit_identity(origin as T::RuntimeOrigin, cloned_subject, Some(commitment_version)); assert!(Pallet::::identity_commitments(&subject, commitment_version).is_some()); } From 9899e4d11559c5cb8ee5efd30aa8a59578f63d10 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 29 Nov 2023 10:34:01 +0100 Subject: [PATCH 42/71] alter feature flag --- pallets/pallet-dip-provider/src/traits.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/pallet-dip-provider/src/traits.rs b/pallets/pallet-dip-provider/src/traits.rs index 80af347d34..8f3422e834 100644 --- a/pallets/pallet-dip-provider/src/traits.rs +++ b/pallets/pallet-dip-provider/src/traits.rs @@ -126,7 +126,7 @@ where } } -#[cfg(any(test, feature = "runtime-benchmarks"))] +#[cfg(feature = "runtime-benchmarks")] impl SubmitterInfo for kilt_support::mock::mock_origin::DoubleOrigin where AccountId: Clone, From 8b7dc127f13676840e5dc991c2b21e2a245f691a Mon Sep 17 00:00:00 2001 From: Adel Golghalyani <48685760+Ad96el@users.noreply.github.com> Date: Wed, 29 Nov 2023 10:48:00 +0100 Subject: [PATCH 43/71] Update pallets/pallet-did-lookup/src/try_state.rs Co-authored-by: Antonio --- pallets/pallet-did-lookup/src/try_state.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/pallet-did-lookup/src/try_state.rs b/pallets/pallet-did-lookup/src/try_state.rs index 47fe65a10f..212922b54d 100644 --- a/pallets/pallet-did-lookup/src/try_state.rs +++ b/pallets/pallet-did-lookup/src/try_state.rs @@ -46,7 +46,7 @@ pub(crate) fn do_try_state() -> Result<(), TryRuntimeError> { ConnectedAccounts::::iter_prefix(did_identifier.clone()).count() < MAX_LINKED_ACCOUNT.saturated_into(), log_and_return_error_message(format!( - "DID {:?} has more linked accounts as {:?}", + "DID {:?} has more linked accounts than {:?}", did_identifier, MAX_LINKED_ACCOUNT )) ); From 34c2aadddad67d5cccaf2654ffb2ca1bb6853c64 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 29 Nov 2023 10:54:38 +0100 Subject: [PATCH 44/71] change trait implementation --- support/src/benchmark.rs | 14 -------------- support/src/traits.rs | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/support/src/benchmark.rs b/support/src/benchmark.rs index b2e82f84e1..221a843a32 100644 --- a/support/src/benchmark.rs +++ b/support/src/benchmark.rs @@ -14,22 +14,8 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use crate::traits::GetWorstCase; - /// Manly used for the DIP benchmarking. The worst case can be created for the did and submitter. pub struct IdentityContext { pub did: DidIdentifier, pub submitter: AccountId, } - -impl GetWorstCase for u32 { - fn worst_case(_context: T) -> Self { - u32::MAX - } -} - -impl GetWorstCase for () { - fn worst_case(_context: T) -> Self { - () - } -} diff --git a/support/src/traits.rs b/support/src/traits.rs index 96138f182d..c122d0cf25 100644 --- a/support/src/traits.rs +++ b/support/src/traits.rs @@ -85,6 +85,20 @@ pub trait GetWorstCase { fn worst_case(context: Context) -> Self; } +#[cfg(feature = "runtime-benchmarks")] +impl GetWorstCase for u32 { + fn worst_case(_context: T) -> Self { + u32::MAX + } +} + +#[cfg(feature = "runtime-benchmarks")] +impl GetWorstCase for () { + fn worst_case(_context: T) -> Self { + () + } +} + /// Trait that allows instanciating multiple instances of a type. #[cfg(feature = "runtime-benchmarks")] pub trait Instanciate { From a3daa243d223f24474f75a30dab4c4ecff7c69bb Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 29 Nov 2023 10:58:26 +0100 Subject: [PATCH 45/71] revert --- pallets/pallet-dip-consumer/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/pallet-dip-consumer/src/lib.rs b/pallets/pallet-dip-consumer/src/lib.rs index 480e88842f..6c0cb27ac4 100644 --- a/pallets/pallet-dip-consumer/src/lib.rs +++ b/pallets/pallet-dip-consumer/src/lib.rs @@ -60,7 +60,7 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn identity_proofs)] - pub type IdentityEntries = + pub(crate) type IdentityEntries = StorageMap<_, Twox64Concat, ::Identifier, ::LocalIdentityInfo>; #[pallet::config] From 9625dfc273d93f8cdc6cfe43f89cae664821aa97 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 29 Nov 2023 11:19:16 +0100 Subject: [PATCH 46/71] adjust mocks --- support/src/mock.rs | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/support/src/mock.rs b/support/src/mock.rs index df757cfd0e..a6b5fdde5f 100644 --- a/support/src/mock.rs +++ b/support/src/mock.rs @@ -32,7 +32,10 @@ use sp_runtime::AccountId32; pub mod mock_origin { use sp_std::marker::PhantomData; - use frame_support::{traits::EnsureOrigin, Parameter}; + use frame_support::{ + traits::{EnsureOrigin, EnsureOriginWithArg}, + Parameter, + }; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; use sp_runtime::AccountId32; @@ -105,6 +108,35 @@ pub mod mock_origin { } } + impl EnsureOriginWithArg + for EnsureDoubleOrigin + where + OuterOrigin: Into, OuterOrigin>> + + From> + + Clone, + SubjectId: PartialEq + Clone, + AccountId: Clone + Decode, + { + type Success = DoubleOrigin; + + fn try_origin(o: OuterOrigin, a: &SubjectId) -> Result { + let did_origin: DoubleOrigin = o.clone().into()?; + if did_origin.1 == *a { + Ok(did_origin) + } else { + Err(o) + } + } + + #[cfg(feature = "runtime-benchmarks")] + fn try_successful_origin(a: &SubjectId) -> Result { + let zero_account_id = AccountId::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes()) + .expect("infinite length input; no invalid inputs for type; qed"); + + Ok(OuterOrigin::from(DoubleOrigin(zero_account_id, a.clone()))) + } + } + #[cfg(feature = "runtime-benchmarks")] impl crate::traits::GenerateBenchmarkOrigin for EnsureDoubleOrigin From 1c70fcbc59769b1bb6fd14924fcb182a53b0f9bb Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 29 Nov 2023 13:05:34 +0100 Subject: [PATCH 47/71] fix mock --- pallets/pallet-dip-consumer/src/mock.rs | 16 ++++++++++++---- pallets/pallet-dip-provider/src/mock.rs | 2 -- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/pallets/pallet-dip-consumer/src/mock.rs b/pallets/pallet-dip-consumer/src/mock.rs index 4f51ff9222..07d4186250 100644 --- a/pallets/pallet-dip-consumer/src/mock.rs +++ b/pallets/pallet-dip-consumer/src/mock.rs @@ -23,16 +23,16 @@ use frame_support::{ traits::{BlakeTwo256, IdentityLookup}, AccountId32, }, - traits::{ConstU16, ConstU32, ConstU64, Everything}, + traits::{ConstU16, ConstU32, ConstU64, Contains, Everything}, }; use frame_system::{mocking::MockBlock, EnsureSigned}; -use crate::{self as dip_consumer, traits::SuccessfulProofVerifier}; +use crate::traits::SuccessfulProofVerifier; construct_runtime!( pub struct TestRuntime { System: frame_system, - DipConsumer: dip_consumer, + DipConsumer: crate, } ); @@ -62,6 +62,14 @@ impl frame_system::Config for TestRuntime { type Version = (); } +pub struct CallFilter; + +impl Contains for CallFilter { + fn contains(t: &RuntimeCall) -> bool { + matches!(t, RuntimeCall::System { .. }) + } +} + impl crate::Config for TestRuntime { type RuntimeOrigin = RuntimeOrigin; type RuntimeCall = RuntimeCall; @@ -69,7 +77,7 @@ impl crate::Config for TestRuntime { type LocalIdentityInfo = u128; type Identifier = AccountId32; type DispatchOriginCheck = EnsureSigned; - type DipCallOriginFilter = (); + type DipCallOriginFilter = CallFilter; type WeightInfo = (); } diff --git a/pallets/pallet-dip-provider/src/mock.rs b/pallets/pallet-dip-provider/src/mock.rs index 2d98ed26ba..af57977aff 100644 --- a/pallets/pallet-dip-provider/src/mock.rs +++ b/pallets/pallet-dip-provider/src/mock.rs @@ -93,10 +93,8 @@ impl ExtBuilder { #[cfg(feature = "runtime-benchmarks")] pub fn build_with_keystore(self) -> sp_io::TestExternalities { let mut ext = self._build(); - let keystore = sp_keystore::testing::MemoryKeystore::new(); ext.register_extension(sp_keystore::KeystoreExt(sp_std::sync::Arc::new(keystore))); - ext } } From 052254a39d7d1234b944d9d4e50a4a88942ff68d Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 29 Nov 2023 14:04:08 +0100 Subject: [PATCH 48/71] limit linked accounts --- pallets/pallet-deposit-storage/Cargo.toml | 1 + pallets/pallet-did-lookup/src/lib.rs | 3 --- pallets/pallet-did-lookup/src/try_state.rs | 13 ++----------- pallets/pallet-dip-provider/src/traits.rs | 2 ++ runtimes/common/src/dip/did.rs | 19 ++++++++++++++++--- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/pallets/pallet-deposit-storage/Cargo.toml b/pallets/pallet-deposit-storage/Cargo.toml index dd7757f7a1..e4432fc6e0 100644 --- a/pallets/pallet-deposit-storage/Cargo.toml +++ b/pallets/pallet-deposit-storage/Cargo.toml @@ -48,6 +48,7 @@ std = [ "sp-std/std", "log/std", "sp-keystore/std", + "pallet-balances/std", ] runtime-benchmarks = ["frame-benchmarking", "pallet-balances"] diff --git a/pallets/pallet-did-lookup/src/lib.rs b/pallets/pallet-did-lookup/src/lib.rs index 9c00e1dc36..14f4af63d9 100644 --- a/pallets/pallet-did-lookup/src/lib.rs +++ b/pallets/pallet-did-lookup/src/lib.rs @@ -85,9 +85,6 @@ pub mod pallet { pub(crate) type BalanceMigrationManagerOf = ::BalanceMigrationManager; - /// Sets an upper limit for the benchmarks, which must be altered if a user has more linked accounts. - pub const MAX_LINKED_ACCOUNT: u32 = 10; - const STORAGE_VERSION: StorageVersion = StorageVersion::new(4); #[pallet::composite_enum] diff --git a/pallets/pallet-did-lookup/src/try_state.rs b/pallets/pallet-did-lookup/src/try_state.rs index 212922b54d..2160be005a 100644 --- a/pallets/pallet-did-lookup/src/try_state.rs +++ b/pallets/pallet-did-lookup/src/try_state.rs @@ -19,9 +19,9 @@ use frame_support::ensure; use kilt_support::test_utils::log_and_return_error_message; use scale_info::prelude::format; -use sp_runtime::{SaturatedConversion, TryRuntimeError}; +use sp_runtime::TryRuntimeError; -use crate::{Config, ConnectedAccounts, ConnectedDids, MAX_LINKED_ACCOUNT}; +use crate::{Config, ConnectedAccounts, ConnectedDids}; pub(crate) fn do_try_state() -> Result<(), TryRuntimeError> { ConnectedDids::::iter().try_for_each(|(account, record)| -> Result<(), TryRuntimeError> { @@ -42,15 +42,6 @@ pub(crate) fn do_try_state() -> Result<(), TryRuntimeError> { )) ); - ensure!( - ConnectedAccounts::::iter_prefix(did_identifier.clone()).count() - < MAX_LINKED_ACCOUNT.saturated_into(), - log_and_return_error_message(format!( - "DID {:?} has more linked accounts than {:?}", - did_identifier, MAX_LINKED_ACCOUNT - )) - ); - Ok(()) }, ) diff --git a/pallets/pallet-dip-provider/src/traits.rs b/pallets/pallet-dip-provider/src/traits.rs index 8f3422e834..273c421217 100644 --- a/pallets/pallet-dip-provider/src/traits.rs +++ b/pallets/pallet-dip-provider/src/traits.rs @@ -33,6 +33,7 @@ pub mod identity_provision { { type Error: Into; type Success; + const MAX_LINKED_ACCOUNT: u32; fn retrieve(identifier: &Runtime::Identifier) -> Result; } @@ -47,6 +48,7 @@ pub mod identity_provision { { type Error = u16; type Success = Identity; + const MAX_LINKED_ACCOUNT: u32 = 0; fn retrieve(_identifier: &Runtime::Identifier) -> Result { Ok(Identity::default()) diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index c36a0354a6..11aeb74ce6 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -17,12 +17,14 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use did::did_details::DidDetails; +use frame_support::ensure; use frame_system::pallet_prelude::BlockNumberFor; use kilt_dip_support::merkle::RevealedWeb3Name; use pallet_did_lookup::linkable_account::LinkableAccountId; use pallet_dip_provider::traits::IdentityProvider; use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; +use sp_runtime::SaturatedConversion; use sp_std::vec::Vec; #[cfg(feature = "runtime-benchmarks")] @@ -33,6 +35,7 @@ pub enum LinkedDidInfoProviderError { DidNotFound, DidDeleted, Internal, + MaxLinkedAccounts, } impl From for u16 { @@ -40,6 +43,7 @@ impl From for u16 { match value { LinkedDidInfoProviderError::DidNotFound => 0, LinkedDidInfoProviderError::DidDeleted => 1, + LinkedDidInfoProviderError::MaxLinkedAccounts => 2, LinkedDidInfoProviderError::Internal => u16::MAX, } } @@ -68,6 +72,7 @@ where { type Error = LinkedDidInfoProviderError; type Success = LinkedDidInfoOf; + const MAX_LINKED_ACCOUNT: u32 = 20; fn retrieve(identifier: &Runtime::Identifier) -> Result { let did_details = match ( @@ -93,7 +98,14 @@ where } else { Ok(None) }?; - let linked_accounts = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(identifier).collect(); + let linked_accounts: Vec<_> = + pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(identifier).collect(); + + ensure!( + >::MAX_LINKED_ACCOUNT > linked_accounts.len().saturated_into(), + LinkedDidInfoProviderError::MaxLinkedAccounts + ); + Ok(LinkedDidInfoOf { did_details, web3_name_details, @@ -112,6 +124,7 @@ where + pallet_balances::Config, ::AccountId: Into + From, ::AccountId: AsRef<[u8; 32]> + From<[u8; 32]>, + LinkedDidInfoOf: IdentityProvider, { fn worst_case(context: IdentityContext) -> Self { use did::{ @@ -121,7 +134,7 @@ where use frame_benchmarking::{vec, Zero}; use frame_support::traits::fungible::Mutate; use sp_io::crypto::{ed25519_generate, sr25519_generate}; - use sp_runtime::{traits::Get, BoundedVec, KeyTypeId, SaturatedConversion}; + use sp_runtime::{traits::Get, BoundedVec, KeyTypeId}; use crate::constants::KILT; @@ -181,7 +194,7 @@ where let mut linked_accounts = vec![]; - (0..pallet_did_lookup::MAX_LINKED_ACCOUNT).for_each(|index| { + (0..Self::MAX_LINKED_ACCOUNT).for_each(|index| { let connected_acc = sr25519_generate(KeyTypeId(index.to_be_bytes()), None); let connected_acc_id: ::AccountId = connected_acc.into(); let linkable_id: LinkableAccountId = connected_acc_id.clone().into(); From 1f59a54dcebd02ef4024b9f5cc7a03abc206fd5b Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 29 Nov 2023 14:25:02 +0100 Subject: [PATCH 49/71] compiling --- pallets/pallet-deposit-storage/Cargo.toml | 1 + pallets/pallet-dip-provider/src/traits.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pallets/pallet-deposit-storage/Cargo.toml b/pallets/pallet-deposit-storage/Cargo.toml index e4432fc6e0..c4ffbe5595 100644 --- a/pallets/pallet-deposit-storage/Cargo.toml +++ b/pallets/pallet-deposit-storage/Cargo.toml @@ -49,6 +49,7 @@ std = [ "log/std", "sp-keystore/std", "pallet-balances/std", + "sp-io/std", ] runtime-benchmarks = ["frame-benchmarking", "pallet-balances"] diff --git a/pallets/pallet-dip-provider/src/traits.rs b/pallets/pallet-dip-provider/src/traits.rs index 273c421217..037510f7db 100644 --- a/pallets/pallet-dip-provider/src/traits.rs +++ b/pallets/pallet-dip-provider/src/traits.rs @@ -128,7 +128,7 @@ where } } -#[cfg(feature = "runtime-benchmarks")] +#[cfg(any(feature = "runtime-benchmarks", test))] impl SubmitterInfo for kilt_support::mock::mock_origin::DoubleOrigin where AccountId: Clone, From e73c68600174bba02853e5f59f33e28aa234502f Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 29 Nov 2023 15:57:17 +0100 Subject: [PATCH 50/71] changed max accounts --- dip-template/runtimes/dip-provider/src/dip.rs | 4 ++- pallets/pallet-dip-provider/src/traits.rs | 2 -- runtimes/common/src/dip/did.rs | 31 ++++++++++--------- runtimes/common/src/dip/merkle.rs | 22 ++++++------- 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/dip-template/runtimes/dip-provider/src/dip.rs b/dip-template/runtimes/dip-provider/src/dip.rs index d0b8bb3904..d0c1f7220d 100644 --- a/dip-template/runtimes/dip-provider/src/dip.rs +++ b/dip-template/runtimes/dip-provider/src/dip.rs @@ -34,6 +34,8 @@ use crate::{ AccountId, Balances, DidIdentifier, Runtime, RuntimeEvent, RuntimeHoldReason, }; +const MAX_LINKED_ACCOUNTS: u32 = 20; + pub mod runtime_api { use super::*; @@ -141,7 +143,7 @@ impl pallet_dip_provider::Config for Runtime { type CommitOrigin = DidRawOrigin; type Identifier = DidIdentifier; type IdentityCommitmentGenerator = DidMerkleRootGenerator; - type IdentityProvider = LinkedDidInfoProvider; + type IdentityProvider = LinkedDidInfoProvider; type ProviderHooks = deposit::DepositCollectorHooks; type RuntimeEvent = RuntimeEvent; type WeightInfo = (); diff --git a/pallets/pallet-dip-provider/src/traits.rs b/pallets/pallet-dip-provider/src/traits.rs index 037510f7db..a475c0c9ed 100644 --- a/pallets/pallet-dip-provider/src/traits.rs +++ b/pallets/pallet-dip-provider/src/traits.rs @@ -33,7 +33,6 @@ pub mod identity_provision { { type Error: Into; type Success; - const MAX_LINKED_ACCOUNT: u32; fn retrieve(identifier: &Runtime::Identifier) -> Result; } @@ -48,7 +47,6 @@ pub mod identity_provision { { type Error = u16; type Success = Identity; - const MAX_LINKED_ACCOUNT: u32 = 0; fn retrieve(_identifier: &Runtime::Identifier) -> Result { Ok(Identity::default()) diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index 11aeb74ce6..af32636f29 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -52,7 +52,7 @@ impl From for u16 { pub type Web3OwnershipOf = RevealedWeb3Name<::Web3Name, BlockNumberFor>; -pub struct LinkedDidInfoOf +pub struct LinkedDidInfoOf where Runtime: did::Config + pallet_web3_names::Config, { @@ -61,9 +61,9 @@ where pub linked_accounts: Vec, } -pub struct LinkedDidInfoProvider; +pub struct LinkedDidInfoProvider; -impl IdentityProvider for LinkedDidInfoProvider +impl IdentityProvider for LinkedDidInfoProvider where Runtime: did::Config::Identifier> + pallet_web3_names::Config::Identifier> @@ -71,8 +71,7 @@ where + pallet_dip_provider::Config, { type Error = LinkedDidInfoProviderError; - type Success = LinkedDidInfoOf; - const MAX_LINKED_ACCOUNT: u32 = 20; + type Success = LinkedDidInfoOf; fn retrieve(identifier: &Runtime::Identifier) -> Result { let did_details = match ( @@ -98,13 +97,17 @@ where } else { Ok(None) }?; - let linked_accounts: Vec<_> = - pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(identifier).collect(); - ensure!( - >::MAX_LINKED_ACCOUNT > linked_accounts.len().saturated_into(), - LinkedDidInfoProviderError::MaxLinkedAccounts - ); + let has_user_to_many_acc = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(identifier) + .skip(MAX_LINKED_ACCOUNTS.saturated_into()) + .next() + .is_some(); + + ensure!(has_user_to_many_acc, LinkedDidInfoProviderError::MaxLinkedAccounts); + + let linked_accounts: Vec<_> = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(identifier) + .take(MAX_LINKED_ACCOUNTS.saturated_into()) + .collect(); Ok(LinkedDidInfoOf { did_details, @@ -115,7 +118,8 @@ where } #[cfg(feature = "runtime-benchmarks")] -impl GetWorstCase> for LinkedDidInfoOf +impl GetWorstCase> + for LinkedDidInfoOf where Runtime: did::Config::Identifier> + pallet_web3_names::Config::Identifier> @@ -124,7 +128,6 @@ where + pallet_balances::Config, ::AccountId: Into + From, ::AccountId: AsRef<[u8; 32]> + From<[u8; 32]>, - LinkedDidInfoOf: IdentityProvider, { fn worst_case(context: IdentityContext) -> Self { use did::{ @@ -194,7 +197,7 @@ where let mut linked_accounts = vec![]; - (0..Self::MAX_LINKED_ACCOUNT).for_each(|index| { + (0..MAX_LINKED_ACCOUNTS).for_each(|index| { let connected_acc = sr25519_generate(KeyTypeId(index.to_be_bytes()), None); let connected_acc_id: ::AccountId = connected_acc.into(); let linkable_id: LinkableAccountId = connected_acc_id.clone().into(); diff --git a/runtimes/common/src/dip/merkle.rs b/runtimes/common/src/dip/merkle.rs index 9c24a78055..d8c5352533 100644 --- a/runtimes/common/src/dip/merkle.rs +++ b/runtimes/common/src/dip/merkle.rs @@ -84,8 +84,8 @@ pub mod v0 { LinkableAccountId, >; - pub(super) fn calculate_root_with_db( - identity: &LinkedDidInfoOf, + pub(super) fn calculate_root_with_db( + identity: &LinkedDidInfoOf, db: &mut MemoryDB, ) -> Result where @@ -234,8 +234,8 @@ pub mod v0 { Ok(trie_builder.root().to_owned()) } - pub(super) fn generate_proof<'a, Runtime, K, A>( - identity: &LinkedDidInfoOf, + pub(super) fn generate_proof<'a, Runtime, K, A, const MAX_LINKED_ACCOUNT: u32>( + identity: &LinkedDidInfoOf, key_ids: K, should_include_web3_name: bool, account_ids: A, @@ -325,12 +325,12 @@ pub mod v0 { }) } - pub(super) fn generate_commitment( + pub(super) fn generate_commitment( identity: &IdentityOf, ) -> Result where Runtime: did::Config + pallet_did_lookup::Config + pallet_web3_names::Config + pallet_dip_provider::Config, - Runtime::IdentityProvider: IdentityProvider>, + Runtime::IdentityProvider: IdentityProvider>, { let mut db = MemoryDB::default(); calculate_root_with_db(identity, &mut db) @@ -339,10 +339,10 @@ pub mod v0 { pub struct DidMerkleRootGenerator(PhantomData); -impl IdentityCommitmentGenerator for DidMerkleRootGenerator +impl IdentityCommitmentGenerator for DidMerkleRootGenerator where Runtime: did::Config + pallet_did_lookup::Config + pallet_web3_names::Config + pallet_dip_provider::Config, - Runtime::IdentityProvider: IdentityProvider>, + Runtime::IdentityProvider: IdentityProvider>, { type Error = DidMerkleProofError; type Output = Runtime::Hash; @@ -353,7 +353,7 @@ where version: IdentityCommitmentVersion, ) -> Result { match version { - 0 => v0::generate_commitment::(identity), + 0 => v0::generate_commitment::(identity), _ => Err(DidMerkleProofError::UnsupportedVersion), } } @@ -363,8 +363,8 @@ impl DidMerkleRootGenerator where Runtime: did::Config + pallet_did_lookup::Config + pallet_web3_names::Config, { - pub fn generate_proof<'a, K, A>( - identity: &LinkedDidInfoOf, + pub fn generate_proof<'a, K, A, const MAX_LINKED_ACCOUNT: u32>( + identity: &LinkedDidInfoOf, version: IdentityCommitmentVersion, key_ids: K, should_include_web3_name: bool, From e91bb501113de95f3a20b42d45a6ea122809f384 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 29 Nov 2023 16:00:11 +0100 Subject: [PATCH 51/71] none not some --- runtimes/common/src/dip/did.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index af32636f29..9e1d68ba33 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -101,7 +101,7 @@ where let has_user_to_many_acc = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(identifier) .skip(MAX_LINKED_ACCOUNTS.saturated_into()) .next() - .is_some(); + .is_none(); ensure!(has_user_to_many_acc, LinkedDidInfoProviderError::MaxLinkedAccounts); From e8f02007919527d2d5aa95c925b4c751e2d625d8 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 29 Nov 2023 16:20:22 +0100 Subject: [PATCH 52/71] clippy --- pallets/pallet-deposit-storage/src/mock.rs | 9 ++------- pallets/pallet-dip-consumer/src/benchmarking.rs | 3 +-- pallets/pallet-dip-provider/src/benchmarking.rs | 2 +- runtimes/common/src/dip/did.rs | 5 ++--- support/src/traits.rs | 4 +--- 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/pallets/pallet-deposit-storage/src/mock.rs b/pallets/pallet-deposit-storage/src/mock.rs index 23c0a68264..7662457310 100644 --- a/pallets/pallet-deposit-storage/src/mock.rs +++ b/pallets/pallet-deposit-storage/src/mock.rs @@ -34,17 +34,12 @@ use crate::{self as storage_deposit_pallet, NoopDepositStorageHooks}; pub(crate) type Balance = u128; -#[derive(Encode, Decode, MaxEncodedLen, TypeInfo, Clone, PartialEq, Eq, RuntimeDebug)] +#[derive(Encode, Decode, MaxEncodedLen, TypeInfo, Clone, PartialEq, Eq, RuntimeDebug, Default)] pub enum DepositNamespaces { + #[default] ExampleNameSpaces, } -impl Default for DepositNamespaces { - fn default() -> Self { - DepositNamespaces::ExampleNameSpaces - } -} - construct_runtime!( pub struct TestRuntime { System: frame_system, diff --git a/pallets/pallet-dip-consumer/src/benchmarking.rs b/pallets/pallet-dip-consumer/src/benchmarking.rs index fcad9a13aa..9c124e3193 100644 --- a/pallets/pallet-dip-consumer/src/benchmarking.rs +++ b/pallets/pallet-dip-consumer/src/benchmarking.rs @@ -60,13 +60,12 @@ mod benchmarks { IdentityContextOf, >>::worst_case(context); - let cloned_subject = subject.clone(); let origin = ::RuntimeOrigin::from(origin); #[extrinsic_call] Pallet::::dispatch_as( origin as ::RuntimeOrigin, - cloned_subject, + subject, proof, boxed_call, ); diff --git a/pallets/pallet-dip-provider/src/benchmarking.rs b/pallets/pallet-dip-provider/src/benchmarking.rs index 3918c9d181..43bf57891c 100644 --- a/pallets/pallet-dip-provider/src/benchmarking.rs +++ b/pallets/pallet-dip-provider/src/benchmarking.rs @@ -74,7 +74,7 @@ mod benchmarks { let context = IdentityContext:: { did: subject.clone(), - submitter: submitter.clone(), + submitter, }; <<::IdentityProvider as IdentityProvider>::Success as GetWorstCase< diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index 9e1d68ba33..35c626f1f6 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -99,8 +99,7 @@ where }?; let has_user_to_many_acc = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(identifier) - .skip(MAX_LINKED_ACCOUNTS.saturated_into()) - .next() + .nth(MAX_LINKED_ACCOUNTS.saturated_into()) .is_none(); ensure!(has_user_to_many_acc, LinkedDidInfoProviderError::MaxLinkedAccounts); @@ -200,7 +199,7 @@ where (0..MAX_LINKED_ACCOUNTS).for_each(|index| { let connected_acc = sr25519_generate(KeyTypeId(index.to_be_bytes()), None); let connected_acc_id: ::AccountId = connected_acc.into(); - let linkable_id: LinkableAccountId = connected_acc_id.clone().into(); + let linkable_id: LinkableAccountId = connected_acc_id.into(); pallet_did_lookup::Pallet::::add_association(submitter.clone(), did.clone(), linkable_id.clone()) .expect("association should not fail."); diff --git a/support/src/traits.rs b/support/src/traits.rs index c122d0cf25..b2a9f8f17f 100644 --- a/support/src/traits.rs +++ b/support/src/traits.rs @@ -94,9 +94,7 @@ impl GetWorstCase for u32 { #[cfg(feature = "runtime-benchmarks")] impl GetWorstCase for () { - fn worst_case(_context: T) -> Self { - () - } + fn worst_case(_context: T) -> Self {} } /// Trait that allows instanciating multiple instances of a type. From 4fad41b8df10f5904f9fca1e4c971d46b647e213 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 30 Nov 2023 10:14:43 +0100 Subject: [PATCH 53/71] fmt cargo file --- pallets/pallet-deposit-storage/Cargo.toml | 48 +++++++++---------- pallets/pallet-dip-consumer/Cargo.toml | 49 +++++++++---------- pallets/pallet-dip-provider/Cargo.toml | 57 +++++++++++------------ 3 files changed, 72 insertions(+), 82 deletions(-) diff --git a/pallets/pallet-deposit-storage/Cargo.toml b/pallets/pallet-deposit-storage/Cargo.toml index c4ffbe5595..4e36b97178 100644 --- a/pallets/pallet-deposit-storage/Cargo.toml +++ b/pallets/pallet-deposit-storage/Cargo.toml @@ -1,57 +1,53 @@ [package] authors.workspace = true +description = "Stores all deposits under a single pallet, with suport for namespacing different deposit contexts." documentation.workspace = true edition.workspace = true homepage.workspace = true license-file.workspace = true +name = "pallet-deposit-storage" readme.workspace = true repository.workspace = true version.workspace = true -name = "pallet-deposit-storage" -description = "Stores all deposits under a single pallet, with suport for namespacing different deposit contexts." [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] [dev-dependencies] -sp-keystore = { workspace = true, features = ["std"] } +pallet-balances = {workspace = true, features = ["std"]} +sp-io = {workspace = true, features = ["std"]} +sp-keystore = {workspace = true, features = ["std"]} [dependencies] # Substrate dependencies frame-support.workspace = true frame-system.workspace = true kilt-support.workspace = true +log.workspace = true pallet-dip-provider.workspace = true -parity-scale-codec = { workspace = true, features = ["derive"] } -scale-info = { workspace = true, features = ["derive"] } +parity-scale-codec = {workspace = true, features = ["derive"]} +scale-info = {workspace = true, features = ["derive"]} sp-runtime.workspace = true sp-std.workspace = true -log.workspace = true - # Benchmarking -pallet-balances = { workspace = true, optional = true } -frame-benchmarking = { workspace = true, optional = true } -sp-io = { workspace = true, optional = true } - +frame-benchmarking = {workspace = true, optional = true} +pallet-balances = {workspace = true, optional = true} [features] -default = ["std"] +default = [ "std" ] std = [ - "frame-support/std", - "frame-system/std", - "kilt-support/std", - "pallet-dip-provider/std", - "parity-scale-codec/std", - "scale-info/std", - "sp-runtime/std", - "sp-std/std", - "log/std", - "sp-keystore/std", - "pallet-balances/std", - "sp-io/std", + "frame-support/std", + "frame-system/std", + "kilt-support/std", + "log/std", + "pallet-dip-provider/std", + "parity-scale-codec/std", + "scale-info/std", + "sp-runtime/std", + "sp-std/std", ] -runtime-benchmarks = ["frame-benchmarking", "pallet-balances"] +runtime-benchmarks = [ "frame-benchmarking", "pallet-balances" ] -try-runtime = ["kilt-support/try-runtime"] +try-runtime = [ "kilt-support/try-runtime" ] diff --git a/pallets/pallet-dip-consumer/Cargo.toml b/pallets/pallet-dip-consumer/Cargo.toml index c1d236053d..e7d44e9350 100644 --- a/pallets/pallet-dip-consumer/Cargo.toml +++ b/pallets/pallet-dip-consumer/Cargo.toml @@ -14,45 +14,42 @@ version.workspace = true targets = ["x86_64-unknown-linux-gnu"] [dev-dependencies] -sp-keystore = { workspace = true, features = ["std"] } -sp-io = { workspace = true, features = ["std"] } -kilt-support = { workspace = true, features = ["mock", "try-runtime"] } +kilt-support = {workspace = true, features = ["mock", "try-runtime"]} +sp-io = {workspace = true, features = ["std"]} +sp-keystore = {workspace = true, features = ["std"]} [dependencies] frame-support.workspace = true frame-system.workspace = true kilt-support.workspace = true -parity-scale-codec = { workspace = true, features = ["derive"] } -scale-info = { workspace = true, features = ["derive"] } +parity-scale-codec = {workspace = true, features = ["derive"]} +scale-info = {workspace = true, features = ["derive"]} sp-core.workspace = true sp-std.workspace = true # Benchmarks -sp-io = { workspace = true, optional = true } -frame-benchmarking = { workspace = true, optional = true } +frame-benchmarking = {workspace = true, optional = true} sp-runtime.workspace = true [features] -default = ["std"] +default = [ "std" ] -std = [ - "frame-support/std", - "frame-system/std", - "kilt-support/std", - "parity-scale-codec/std", - "scale-info/std", - "sp-core/std", - "sp-std/std", - "sp-io/std", - "sp-keystore/std", - "frame-benchmarking/std", -] runtime-benchmarks = [ - "frame-benchmarking", - "kilt-support/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", + "frame-benchmarking", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "kilt-support/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", +] +std = [ + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", + "kilt-support/std", + "parity-scale-codec/std", + "scale-info/std", + "sp-core/std", + "sp-std/std", ] -try-runtime = ["kilt-support/try-runtime"] +try-runtime = [ "kilt-support/try-runtime" ] diff --git a/pallets/pallet-dip-provider/Cargo.toml b/pallets/pallet-dip-provider/Cargo.toml index f76aae2a20..4b74051944 100644 --- a/pallets/pallet-dip-provider/Cargo.toml +++ b/pallets/pallet-dip-provider/Cargo.toml @@ -13,50 +13,47 @@ version.workspace = true [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] - [dev-dependencies] -sp-keystore = { workspace = true, features = ["std"] } -sp-io = { workspace = true, features = ["std"] } -kilt-support = { workspace = true, features = ["mock", "try-runtime"] } +kilt-support = {workspace = true, features = ["mock", "try-runtime"]} +sp-io = {workspace = true, features = ["std"]} +sp-keystore = {workspace = true, features = ["std"]} [dependencies] +did.workspace = true frame-support.workspace = true frame-system.workspace = true kilt-support.workspace = true -parity-scale-codec = { workspace = true, features = ["derive"] } -scale-info = { workspace = true, features = ["derive"] } +parity-scale-codec = {workspace = true, features = ["derive"]} +scale-info = {workspace = true, features = ["derive"]} sp-core.workspace = true sp-std.workspace = true -did.workspace = true # Benchmarks -sp-io = { workspace = true, optional = true } -frame-benchmarking = { workspace = true, optional = true } +frame-benchmarking = {workspace = true, optional = true} +sp-io = {workspace = true, optional = true} sp-runtime.workspace = true [features] -default = ["std"] +default = [ "std" ] -std = [ - "did/std", - "frame-support/std", - "frame-system/std", - "kilt-support/std", - "parity-scale-codec/std", - "scale-info/std", - "sp-core/std", - "sp-std/std", - "sp-io/std", - "sp-keystore/std", - "frame-benchmarking/std", -] runtime-benchmarks = [ - "did/runtime-benchmarks", - "frame-benchmarking", - "kilt-support/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", + "did/runtime-benchmarks", + "frame-benchmarking", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "kilt-support/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", +] +std = [ + "did/std", + "frame-benchmarking/std", + "frame-support/std", + "frame-system/std", + "kilt-support/std", + "parity-scale-codec/std", + "scale-info/std", + "sp-core/std", + "sp-std/std", ] -try-runtime = ["did/try-runtime", "kilt-support/try-runtime"] +try-runtime = [ "did/try-runtime", "kilt-support/try-runtime" ] From 42414a56dc188038a0aac00e6f050f082f2bc7c9 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 30 Nov 2023 10:19:06 +0100 Subject: [PATCH 54/71] change error --- runtimes/common/src/dip/did.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index 35c626f1f6..7953ebb7ba 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -35,7 +35,7 @@ pub enum LinkedDidInfoProviderError { DidNotFound, DidDeleted, Internal, - MaxLinkedAccounts, + TooManyLinkedAccounts, } impl From for u16 { @@ -43,7 +43,7 @@ impl From for u16 { match value { LinkedDidInfoProviderError::DidNotFound => 0, LinkedDidInfoProviderError::DidDeleted => 1, - LinkedDidInfoProviderError::MaxLinkedAccounts => 2, + LinkedDidInfoProviderError::TooManyLinkedAccounts => 2, LinkedDidInfoProviderError::Internal => u16::MAX, } } @@ -98,11 +98,12 @@ where Ok(None) }?; + // Check if the user has to many linked accounts. If he has more then [MAX_LINKED_ACCOUNTS] we throw an error let has_user_to_many_acc = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(identifier) .nth(MAX_LINKED_ACCOUNTS.saturated_into()) .is_none(); - ensure!(has_user_to_many_acc, LinkedDidInfoProviderError::MaxLinkedAccounts); + ensure!(has_user_to_many_acc, LinkedDidInfoProviderError::TooManyLinkedAccounts); let linked_accounts: Vec<_> = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(identifier) .take(MAX_LINKED_ACCOUNTS.saturated_into()) From 0bad8c088e322f4cf2b45a440ebbb1727efe3d38 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 30 Nov 2023 10:20:57 +0100 Subject: [PATCH 55/71] change comment --- runtimes/common/src/dip/did.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index 7953ebb7ba..32d22e4e63 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -98,7 +98,7 @@ where Ok(None) }?; - // Check if the user has to many linked accounts. If he has more then [MAX_LINKED_ACCOUNTS] we throw an error + // Check if the user has too many linked accounts. If they have more than [MAX_LINKED_ACCOUNTS], we throw an error. let has_user_to_many_acc = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(identifier) .nth(MAX_LINKED_ACCOUNTS.saturated_into()) .is_none(); From 6b3e1e3f6ef5074d15e01a6b8220fe3f2cf41577 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 30 Nov 2023 10:30:19 +0100 Subject: [PATCH 56/71] remove dev mode --- pallets/pallet-deposit-storage/src/lib.rs | 4 ++-- pallets/pallet-dip-consumer/src/lib.rs | 2 +- pallets/pallet-dip-provider/src/lib.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pallets/pallet-deposit-storage/src/lib.rs b/pallets/pallet-deposit-storage/src/lib.rs index b707db62bc..cdf624db7d 100644 --- a/pallets/pallet-deposit-storage/src/lib.rs +++ b/pallets/pallet-deposit-storage/src/lib.rs @@ -33,7 +33,7 @@ pub use deposit::FixedDepositCollectorViaDepositsPallet; pub use pallet::*; pub use traits::NoopDepositStorageHooks; -#[frame_support::pallet(dev_mode)] +#[frame_support::pallet] pub mod pallet { use crate::{ default_weights::WeightInfo, @@ -72,7 +72,7 @@ pub mod pallet { type CheckOrigin: EnsureOrigin; type Currency: Mutate; type DepositHooks: DepositStorageHooks; - type Namespace: Parameter; + type Namespace: Parameter + MaxEncodedLen; type RuntimeEvent: From> + IsType<::RuntimeEvent>; type RuntimeHoldReason: From + Clone + PartialEq + Debug + FullCodec + MaxEncodedLen + TypeInfo; type WeightInfo: WeightInfo; diff --git a/pallets/pallet-dip-consumer/src/lib.rs b/pallets/pallet-dip-consumer/src/lib.rs index 6c0cb27ac4..b96ca92294 100644 --- a/pallets/pallet-dip-consumer/src/lib.rs +++ b/pallets/pallet-dip-consumer/src/lib.rs @@ -34,7 +34,7 @@ mod origin; pub use crate::{origin::*, pallet::*, traits::SuccessfulProofVerifier}; -#[frame_support::pallet(dev_mode)] +#[frame_support::pallet] pub mod pallet { use super::*; diff --git a/pallets/pallet-dip-provider/src/lib.rs b/pallets/pallet-dip-provider/src/lib.rs index 4223c9cb77..c6d00d5355 100644 --- a/pallets/pallet-dip-provider/src/lib.rs +++ b/pallets/pallet-dip-provider/src/lib.rs @@ -34,7 +34,7 @@ pub use crate::{ traits::{DefaultIdentityCommitmentGenerator, DefaultIdentityProvider, NoopHooks}, }; -#[frame_support::pallet(dev_mode)] +#[frame_support::pallet] pub mod pallet { use super::*; From c0efd83b392b1211f616ffe86e74f31f9fb6dda8 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Fri, 1 Dec 2023 10:29:57 +0100 Subject: [PATCH 57/71] Remove clone in benchmarks --- pallets/pallet-dip-provider/src/benchmarking.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pallets/pallet-dip-provider/src/benchmarking.rs b/pallets/pallet-dip-provider/src/benchmarking.rs index 43bf57891c..28a73c5cb8 100644 --- a/pallets/pallet-dip-provider/src/benchmarking.rs +++ b/pallets/pallet-dip-provider/src/benchmarking.rs @@ -35,6 +35,8 @@ mod benchmarks { type IdentityContextOf = IdentityContext<::Identifier, ::AccountId>; + use crate::IdentityOf; + use super::*; #[benchmark] @@ -52,9 +54,7 @@ mod benchmarks { let origin: T::RuntimeOrigin = T::CommitOriginCheck::generate_origin(submitter, subject.clone()); - <<::IdentityProvider as IdentityProvider>::Success as GetWorstCase< - IdentityContextOf, - >>::worst_case(context); + as GetWorstCase>>::worst_case(context); let cloned_subject = subject.clone(); @@ -77,9 +77,8 @@ mod benchmarks { submitter, }; - <<::IdentityProvider as IdentityProvider>::Success as GetWorstCase< - IdentityContextOf, - >>::worst_case(context); + as GetWorstCase>>::worst_case(context); + let cloned_subject = subject.clone(); Pallet::::commit_identity( origin.clone() as T::RuntimeOrigin, @@ -91,7 +90,7 @@ mod benchmarks { assert!(Pallet::::identity_commitments(&subject, commitment_version).is_some()); #[extrinsic_call] - Pallet::::delete_identity_commitment(origin as T::RuntimeOrigin, subject.clone(), Some(commitment_version)); + Pallet::::delete_identity_commitment(origin as T::RuntimeOrigin, cloned_subject, Some(commitment_version)); assert!(Pallet::::identity_commitments(&subject, commitment_version).is_none()); } From 78e0959ad59e03bea31e517cb3dd7ecda1832c78 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Fri, 1 Dec 2023 14:58:01 +0100 Subject: [PATCH 58/71] Benchmarks for pallet-relay-store --- Cargo.lock | 4 + pallets/pallet-relay-store/Cargo.toml | 12 +++ .../pallet-relay-store/src/benchmarking.rs | 93 ++++++++++++++++ pallets/pallet-relay-store/src/lib.rs | 17 ++- pallets/pallet-relay-store/src/mock.rs | 101 ++++++++++++++++++ 5 files changed, 226 insertions(+), 1 deletion(-) create mode 100644 pallets/pallet-relay-store/src/benchmarking.rs create mode 100644 pallets/pallet-relay-store/src/mock.rs diff --git a/Cargo.lock b/Cargo.lock index 44f3b83927..2b6e6af14e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7029,12 +7029,16 @@ name = "pallet-relay-store" version = "1.12.0-dev" dependencies = [ "cumulus-pallet-parachain-system", + "cumulus-primitives-core", + "frame-benchmarking", "frame-support", "frame-system", "log", "parity-scale-codec", "scale-info", "sp-core", + "sp-io", + "sp-keystore", "sp-runtime", "sp-std", ] diff --git a/pallets/pallet-relay-store/Cargo.toml b/pallets/pallet-relay-store/Cargo.toml index c5398f052f..1422506d3d 100644 --- a/pallets/pallet-relay-store/Cargo.toml +++ b/pallets/pallet-relay-store/Cargo.toml @@ -13,6 +13,10 @@ version.workspace = true [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] +[dev-dependencies] +cumulus-primitives-core = { workspace = true, features = ["std"] } +sp-io = {workspace = true, features = ["std"]} + [dependencies] cumulus-pallet-parachain-system.workspace = true frame-support.workspace = true @@ -21,9 +25,13 @@ log.workspace = true parity-scale-codec = {workspace = true, features = ["derive"]} scale-info = {workspace = true, features = ["derive"]} sp-core.workspace = true +sp-keystore = {workspace = true, optional = true} sp-runtime.workspace = true sp-std.workspace = true +# Benchmarks +frame-benchmarking = {workspace = true, optional = true} + [features] default = ["std"] std = [ @@ -35,8 +43,12 @@ std = [ "sp-core/std", "sp-runtime/std", "sp-std/std", + "frame-benchmarking?/std", ] runtime-benchmarks = [ + "cumulus-pallet-parachain-system/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", + "frame-benchmarking", + "sp-keystore" ] diff --git a/pallets/pallet-relay-store/src/benchmarking.rs b/pallets/pallet-relay-store/src/benchmarking.rs new file mode 100644 index 0000000000..3520016ba4 --- /dev/null +++ b/pallets/pallet-relay-store/src/benchmarking.rs @@ -0,0 +1,93 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use crate::{Config, Pallet}; +use frame_benchmarking::v2::*; + +#[benchmarks( + where + T: cumulus_pallet_parachain_system::Config +)] +mod benchmarks { + use cumulus_pallet_parachain_system::RelaychainDataProvider; + use sp_core::H256; + use sp_runtime::{ + traits::{BlockNumberProvider, Get}, + BoundedVec, + }; + + use crate::{relay::RelayParentInfo, LatestBlockHeights, LatestRelayHeads}; + + use super::*; + + #[benchmark] + fn on_finalize() { + let max_blocks_stored = T::MaxRelayBlocksStored::get(); + let latest_block_heights: BoundedVec = (1..=max_blocks_stored) + .collect::>() + .try_into() + .expect("Should not fail to build BoundedVec for LatestBlockHeights"); + let latest_block_heads_iter = latest_block_heights.iter().map(|block_height| { + ( + block_height, + RelayParentInfo { + relay_parent_storage_root: H256::default(), + }, + ) + }); + latest_block_heads_iter + .for_each(|(block_height, parent_info)| LatestRelayHeads::::insert(block_height, parent_info)); + LatestBlockHeights::::put(latest_block_heights); + + assert_eq!( + LatestRelayHeads::::iter().count(), + max_blocks_stored as usize, + "The maximum allowed number of blocks should be stored in storage." + ); + + let new_block_number = max_blocks_stored + 1; + frame_system::Pallet::::set_block_number(new_block_number.into()); + RelaychainDataProvider::::set_block_number(new_block_number); + + #[block] + { + Pallet::::on_finalize_internal(new_block_number.into()) + } + + assert!( + LatestBlockHeights::::get().contains(&new_block_number), + "LatestBlockHeights should contain the information about the new block" + ); + assert!( + LatestRelayHeads::::contains_key(new_block_number), + "LatestRelayHeads should contain the information about the new block" + ); + } + + #[cfg(test)] + mod benchmarks_tests { + use crate::Pallet; + use frame_benchmarking::impl_benchmark_test_suite; + + impl_benchmark_test_suite!( + Pallet, + crate::mock::ExtBuilder::default().build_with_keystore(), + crate::mock::TestRuntime, + ); + } +} diff --git a/pallets/pallet-relay-store/src/lib.rs b/pallets/pallet-relay-store/src/lib.rs index d5ca7bc1cf..4e005c2182 100644 --- a/pallets/pallet-relay-store/src/lib.rs +++ b/pallets/pallet-relay-store/src/lib.rs @@ -22,6 +22,12 @@ mod relay; +#[cfg(feature = "runtime-benchmarks")] +mod benchmarking; + +#[cfg(test)] +mod mock; + pub use crate::pallet::*; #[frame_support::pallet] @@ -68,7 +74,16 @@ pub mod pallet { } // TODO: Benchmarks - fn on_finalize(_n: BlockNumberFor) { + fn on_finalize(n: BlockNumberFor) { + Self::on_finalize_internal(n) + } + } + + impl Pallet + where + T: cumulus_pallet_parachain_system::Config, + { + pub(crate) fn on_finalize_internal(_n: BlockNumberFor) { // Called before the validation data is cleaned in the // parachain_system::on_finalize hook let Some(new_validation_data) = cumulus_pallet_parachain_system::Pallet::::validation_data() else { diff --git a/pallets/pallet-relay-store/src/mock.rs b/pallets/pallet-relay-store/src/mock.rs new file mode 100644 index 0000000000..f4aabb1f71 --- /dev/null +++ b/pallets/pallet-relay-store/src/mock.rs @@ -0,0 +1,101 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use cumulus_pallet_parachain_system::{ParachainSetCode, RelayNumberStrictlyIncreases}; +use cumulus_primitives_core::ParaId; +use frame_support::{ + construct_runtime, parameter_types, + sp_runtime::{ + testing::H256, + traits::{BlakeTwo256, IdentityLookup}, + AccountId32, + }, + traits::{ConstU16, ConstU32, ConstU64, Everything}, +}; +use frame_system::mocking::MockBlock; + +construct_runtime!( + pub struct TestRuntime { + System: frame_system, + ParachainSystem: cumulus_pallet_parachain_system, + RelayStore: crate, + } +); + +impl frame_system::Config for TestRuntime { + type AccountData = (); + type AccountId = AccountId32; + type BaseCallFilter = Everything; + type Block = MockBlock; + type BlockHashCount = ConstU64<256>; + type BlockLength = (); + type BlockWeights = (); + type DbWeight = (); + type Hash = H256; + type Hashing = BlakeTwo256; + type Lookup = IdentityLookup; + type MaxConsumers = ConstU32<16>; + type Nonce = u64; + type OnKilledAccount = (); + type OnNewAccount = (); + type OnSetCode = ParachainSetCode; + type PalletInfo = PalletInfo; + type RuntimeCall = RuntimeCall; + type RuntimeEvent = RuntimeEvent; + type RuntimeOrigin = RuntimeOrigin; + type SS58Prefix = ConstU16<1>; + type SystemWeightInfo = (); + type Version = (); +} + +parameter_types! { + pub const ParachainId: ParaId = ParaId::new(2_000); +} + +impl cumulus_pallet_parachain_system::Config for TestRuntime { + type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases; + type DmpMessageHandler = (); + type OnSystemEvent = (); + type OutboundXcmpMessageSource = (); + type ReservedDmpWeight = (); + type ReservedXcmpWeight = (); + type RuntimeEvent = RuntimeEvent; + type SelfParaId = ParachainId; + type XcmpMessageHandler = (); +} + +impl crate::Config for TestRuntime { + type MaxRelayBlocksStored = ConstU32<5>; +} + +#[derive(Default)] +pub(crate) struct ExtBuilder; + +impl ExtBuilder { + pub fn _build(self) -> sp_io::TestExternalities { + sp_io::TestExternalities::default() + } + + #[cfg(feature = "runtime-benchmarks")] + pub fn build_with_keystore(self) -> sp_io::TestExternalities { + let mut ext = self._build(); + let keystore = sp_keystore::testing::MemoryKeystore::new(); + ext.register_extension(sp_keystore::KeystoreExt(sp_std::sync::Arc::new(keystore))); + ext + } +} From 09f1f6c51f889b96e4af2ec8fc2b604173a5a968 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Fri, 1 Dec 2023 15:46:30 +0100 Subject: [PATCH 59/71] Fix features --- pallets/pallet-deposit-storage/Cargo.toml | 17 ++++++++++++++--- pallets/pallet-dip-consumer/Cargo.toml | 11 ++++++----- pallets/pallet-dip-provider/Cargo.toml | 13 +++++++------ pallets/pallet-relay-store/Cargo.toml | 9 +++++---- 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/pallets/pallet-deposit-storage/Cargo.toml b/pallets/pallet-deposit-storage/Cargo.toml index 4e36b97178..a05517d9c3 100644 --- a/pallets/pallet-deposit-storage/Cargo.toml +++ b/pallets/pallet-deposit-storage/Cargo.toml @@ -17,6 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"] pallet-balances = {workspace = true, features = ["std"]} sp-io = {workspace = true, features = ["std"]} sp-keystore = {workspace = true, features = ["std"]} +sp-runtime = {workspace = true, features = ["std"]} [dependencies] # Substrate dependencies @@ -27,12 +28,12 @@ log.workspace = true pallet-dip-provider.workspace = true parity-scale-codec = {workspace = true, features = ["derive"]} scale-info = {workspace = true, features = ["derive"]} -sp-runtime.workspace = true sp-std.workspace = true # Benchmarking frame-benchmarking = {workspace = true, optional = true} pallet-balances = {workspace = true, optional = true} +sp-runtime = {workspace = true, optional = true} [features] default = [ "std" ] @@ -44,10 +45,20 @@ std = [ "pallet-dip-provider/std", "parity-scale-codec/std", "scale-info/std", - "sp-runtime/std", "sp-std/std", + "frame-benchmarking?/std", + "pallet-balances?/std", + "sp-runtime?/std", ] -runtime-benchmarks = [ "frame-benchmarking", "pallet-balances" ] +runtime-benchmarks = [ + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "kilt-support/runtime-benchmarks", + "pallet-dip-provider/runtime-benchmarks", + "frame-benchmarking", + "pallet-balances/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", +] try-runtime = [ "kilt-support/try-runtime" ] diff --git a/pallets/pallet-dip-consumer/Cargo.toml b/pallets/pallet-dip-consumer/Cargo.toml index e7d44e9350..6440849204 100644 --- a/pallets/pallet-dip-consumer/Cargo.toml +++ b/pallets/pallet-dip-consumer/Cargo.toml @@ -14,9 +14,9 @@ version.workspace = true targets = ["x86_64-unknown-linux-gnu"] [dev-dependencies] -kilt-support = {workspace = true, features = ["mock", "try-runtime"]} sp-io = {workspace = true, features = ["std"]} sp-keystore = {workspace = true, features = ["std"]} +sp-runtime = {workspace = true, features = ["std"]} [dependencies] frame-support.workspace = true @@ -29,20 +29,19 @@ sp-std.workspace = true # Benchmarks frame-benchmarking = {workspace = true, optional = true} -sp-runtime.workspace = true +sp-runtime = {workspace = true, optional = true} [features] default = [ "std" ] runtime-benchmarks = [ - "frame-benchmarking", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "kilt-support/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", + "frame-benchmarking", + "sp-runtime/runtime-benchmarks", ] std = [ - "frame-benchmarking/std", "frame-support/std", "frame-system/std", "kilt-support/std", @@ -50,6 +49,8 @@ std = [ "scale-info/std", "sp-core/std", "sp-std/std", + "frame-benchmarking?/std", + "sp-runtime?/std", ] try-runtime = [ "kilt-support/try-runtime" ] diff --git a/pallets/pallet-dip-provider/Cargo.toml b/pallets/pallet-dip-provider/Cargo.toml index 4b74051944..6c3c0942d3 100644 --- a/pallets/pallet-dip-provider/Cargo.toml +++ b/pallets/pallet-dip-provider/Cargo.toml @@ -14,9 +14,10 @@ version.workspace = true targets = ["x86_64-unknown-linux-gnu"] [dev-dependencies] -kilt-support = {workspace = true, features = ["mock", "try-runtime"]} +kilt-support = {workspace = true, features = ["std", "mock", "try-runtime"]} sp-io = {workspace = true, features = ["std"]} sp-keystore = {workspace = true, features = ["std"]} +sp-runtime = {workspace = true, features = ["std"]} [dependencies] did.workspace = true @@ -30,23 +31,21 @@ sp-std.workspace = true # Benchmarks frame-benchmarking = {workspace = true, optional = true} -sp-io = {workspace = true, optional = true} -sp-runtime.workspace = true +sp-runtime = {workspace = true, optional = true} [features] default = [ "std" ] runtime-benchmarks = [ "did/runtime-benchmarks", - "frame-benchmarking", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "kilt-support/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", + "frame-benchmarking", + "sp-runtime/runtime-benchmarks", ] std = [ "did/std", - "frame-benchmarking/std", "frame-support/std", "frame-system/std", "kilt-support/std", @@ -54,6 +53,8 @@ std = [ "scale-info/std", "sp-core/std", "sp-std/std", + "frame-benchmarking?/std", + "sp-runtime?/std", ] try-runtime = [ "did/try-runtime", "kilt-support/try-runtime" ] diff --git a/pallets/pallet-relay-store/Cargo.toml b/pallets/pallet-relay-store/Cargo.toml index 1422506d3d..96f1051b04 100644 --- a/pallets/pallet-relay-store/Cargo.toml +++ b/pallets/pallet-relay-store/Cargo.toml @@ -16,6 +16,8 @@ targets = ["x86_64-unknown-linux-gnu"] [dev-dependencies] cumulus-primitives-core = { workspace = true, features = ["std"] } sp-io = {workspace = true, features = ["std"]} +sp-keystore = {workspace = true, features = ["std"]} +sp-runtime = {workspace = true, features = ["std"]} [dependencies] cumulus-pallet-parachain-system.workspace = true @@ -25,12 +27,11 @@ log.workspace = true parity-scale-codec = {workspace = true, features = ["derive"]} scale-info = {workspace = true, features = ["derive"]} sp-core.workspace = true -sp-keystore = {workspace = true, optional = true} -sp-runtime.workspace = true sp-std.workspace = true # Benchmarks frame-benchmarking = {workspace = true, optional = true} +sp-runtime = {workspace = true, optional = true} [features] default = ["std"] @@ -41,14 +42,14 @@ std = [ "parity-scale-codec/std", "scale-info/std", "sp-core/std", - "sp-runtime/std", "sp-std/std", "frame-benchmarking?/std", + "sp-runtime?/std", ] runtime-benchmarks = [ "cumulus-pallet-parachain-system/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", "frame-benchmarking", - "sp-keystore" + "sp-runtime/runtime-benchmarks", ] From 387767b030efc1361119c3ce193f8e80f9e7e899 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Fri, 1 Dec 2023 15:59:15 +0100 Subject: [PATCH 60/71] Default weights --- .../pallet-relay-store/src/default_weights.rs | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 pallets/pallet-relay-store/src/default_weights.rs diff --git a/pallets/pallet-relay-store/src/default_weights.rs b/pallets/pallet-relay-store/src/default_weights.rs new file mode 100644 index 0000000000..ab5ae9ce4d --- /dev/null +++ b/pallets/pallet-relay-store/src/default_weights.rs @@ -0,0 +1,92 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for pallet_relay_store +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-01 +//! STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// ./target/release/kilt-parachain +// benchmark +// pallet +// --template=.maintain/weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --chain=dev +// --pallet=pallet-relay-store +// --extrinsic=* +// --output=./pallets/pallet-relay-store/src/default_weights.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_relay_store. +pub trait WeightInfo { + fn on_finalize() -> Weight; +} + +/// Weights for pallet_relay_store using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: `ParachainSystem::ValidationData` (r:1 w:0) + /// Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `RelayStore::LatestBlockHeights` (r:1 w:1) + /// Proof: `RelayStore::LatestBlockHeights` (`max_values`: Some(1), `max_size`: Some(402), added: 897, mode: `MaxEncodedLen`) + /// Storage: `RelayStore::LatestRelayHeads` (r:0 w:2) + /// Proof: `RelayStore::LatestRelayHeads` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + fn on_finalize() -> Weight { + // Proof Size summary in bytes: + // Measured: `577` + // Estimated: `2062` + // Minimum execution time: 132_937 nanoseconds. + Weight::from_parts(146_340_000, 2062) + .saturating_add(T::DbWeight::get().reads(2_u64)) + .saturating_add(T::DbWeight::get().writes(3_u64)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + /// Storage: `ParachainSystem::ValidationData` (r:1 w:0) + /// Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `RelayStore::LatestBlockHeights` (r:1 w:1) + /// Proof: `RelayStore::LatestBlockHeights` (`max_values`: Some(1), `max_size`: Some(402), added: 897, mode: `MaxEncodedLen`) + /// Storage: `RelayStore::LatestRelayHeads` (r:0 w:2) + /// Proof: `RelayStore::LatestRelayHeads` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + fn on_finalize() -> Weight { + // Proof Size summary in bytes: + // Measured: `577` + // Estimated: `2062` + // Minimum execution time: 132_937 nanoseconds. + Weight::from_parts(146_340_000, 2062) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + .saturating_add(RocksDbWeight::get().writes(3_u64)) + } +} From 7a8e572f4d9c655615d92bbbafe33c0039fa64f9 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Fri, 1 Dec 2023 16:12:13 +0100 Subject: [PATCH 61/71] Fix compilation --- dip-template/runtimes/dip-consumer/src/dip.rs | 1 + pallets/pallet-deposit-storage/Cargo.toml | 7 +++---- pallets/pallet-relay-store/src/lib.rs | 9 ++++----- pallets/pallet-relay-store/src/mock.rs | 1 + 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dip-template/runtimes/dip-consumer/src/dip.rs b/dip-template/runtimes/dip-consumer/src/dip.rs index e116284321..2362c6f2b1 100644 --- a/dip-template/runtimes/dip-consumer/src/dip.rs +++ b/dip-template/runtimes/dip-consumer/src/dip.rs @@ -124,4 +124,5 @@ impl DipCallOriginFilter for DipCallFilter { impl pallet_relay_store::Config for Runtime { type MaxRelayBlocksStored = ConstU32<100>; + type WeightInfo = (); } diff --git a/pallets/pallet-deposit-storage/Cargo.toml b/pallets/pallet-deposit-storage/Cargo.toml index a05517d9c3..c686a9a5e5 100644 --- a/pallets/pallet-deposit-storage/Cargo.toml +++ b/pallets/pallet-deposit-storage/Cargo.toml @@ -17,7 +17,6 @@ targets = ["x86_64-unknown-linux-gnu"] pallet-balances = {workspace = true, features = ["std"]} sp-io = {workspace = true, features = ["std"]} sp-keystore = {workspace = true, features = ["std"]} -sp-runtime = {workspace = true, features = ["std"]} [dependencies] # Substrate dependencies @@ -28,12 +27,12 @@ log.workspace = true pallet-dip-provider.workspace = true parity-scale-codec = {workspace = true, features = ["derive"]} scale-info = {workspace = true, features = ["derive"]} +sp-runtime.workspace = true sp-std.workspace = true # Benchmarking frame-benchmarking = {workspace = true, optional = true} pallet-balances = {workspace = true, optional = true} -sp-runtime = {workspace = true, optional = true} [features] default = [ "std" ] @@ -45,10 +44,10 @@ std = [ "pallet-dip-provider/std", "parity-scale-codec/std", "scale-info/std", + "sp-runtime/std", "sp-std/std", "frame-benchmarking?/std", "pallet-balances?/std", - "sp-runtime?/std", ] runtime-benchmarks = [ @@ -56,9 +55,9 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "kilt-support/runtime-benchmarks", "pallet-dip-provider/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", "frame-benchmarking", "pallet-balances/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", ] try-runtime = [ "kilt-support/try-runtime" ] diff --git a/pallets/pallet-relay-store/src/lib.rs b/pallets/pallet-relay-store/src/lib.rs index 4e005c2182..26a66ebe4e 100644 --- a/pallets/pallet-relay-store/src/lib.rs +++ b/pallets/pallet-relay-store/src/lib.rs @@ -20,6 +20,7 @@ #![cfg_attr(not(feature = "std"), no_std)] +mod default_weights; mod relay; #[cfg(feature = "runtime-benchmarks")] @@ -38,7 +39,7 @@ pub mod pallet { use frame_system::pallet_prelude::*; use sp_core::H256; - use crate::relay::RelayParentInfo; + use crate::{default_weights::WeightInfo, relay::RelayParentInfo}; const STORAGE_VERSION: StorageVersion = StorageVersion::new(0); @@ -56,6 +57,7 @@ pub mod pallet { pub trait Config: frame_system::Config { #[pallet::constant] type MaxRelayBlocksStored: Get; + type WeightInfo: WeightInfo; } #[pallet::pallet] @@ -68,12 +70,9 @@ pub mod pallet { T: cumulus_pallet_parachain_system::Config, { fn on_initialize(_n: BlockNumberFor) -> Weight { - // Reserve weight to update the last relay state root - // TODO: Replace with benchmarked version of `on_finalize(` - ::DbWeight::get().writes(2) + ::WeightInfo::on_finalize() } - // TODO: Benchmarks fn on_finalize(n: BlockNumberFor) { Self::on_finalize_internal(n) } diff --git a/pallets/pallet-relay-store/src/mock.rs b/pallets/pallet-relay-store/src/mock.rs index f4aabb1f71..2aea08ef70 100644 --- a/pallets/pallet-relay-store/src/mock.rs +++ b/pallets/pallet-relay-store/src/mock.rs @@ -81,6 +81,7 @@ impl cumulus_pallet_parachain_system::Config for TestRuntime { impl crate::Config for TestRuntime { type MaxRelayBlocksStored = ConstU32<5>; + type WeightInfo = (); } #[derive(Default)] From b33e6caafc1b7145608775ee7b7f23ed1934bc9d Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Fri, 1 Dec 2023 16:23:26 +0100 Subject: [PATCH 62/71] Revert logic --- runtimes/common/src/dip/did.rs | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index 32d22e4e63..2f008d4823 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -24,7 +24,8 @@ use pallet_did_lookup::linkable_account::LinkableAccountId; use pallet_dip_provider::traits::IdentityProvider; use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; -use sp_runtime::SaturatedConversion; +use sp_core::ConstU32; +use sp_runtime::{BoundedVec, SaturatedConversion}; use sp_std::vec::Vec; #[cfg(feature = "runtime-benchmarks")] @@ -58,7 +59,7 @@ where { pub did_details: DidDetails, pub web3_name_details: Option>, - pub linked_accounts: Vec, + pub linked_accounts: BoundedVec>, } pub struct LinkedDidInfoProvider; @@ -98,16 +99,23 @@ where Ok(None) }?; - // Check if the user has too many linked accounts. If they have more than [MAX_LINKED_ACCOUNTS], we throw an error. - let has_user_to_many_acc = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(identifier) - .nth(MAX_LINKED_ACCOUNTS.saturated_into()) - .is_none(); + // Check if the user has too many linked accounts. If they have more than + // [MAX_LINKED_ACCOUNTS], we throw an error. + let are_linked_accounts_within_limit = + pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(identifier) + .nth(MAX_LINKED_ACCOUNTS.saturated_into()) + .is_none(); - ensure!(has_user_to_many_acc, LinkedDidInfoProviderError::TooManyLinkedAccounts); + ensure!( + are_linked_accounts_within_limit, + LinkedDidInfoProviderError::TooManyLinkedAccounts + ); - let linked_accounts: Vec<_> = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(identifier) + let linked_accounts = pallet_did_lookup::ConnectedAccounts::::iter_key_prefix(identifier) .take(MAX_LINKED_ACCOUNTS.saturated_into()) - .collect(); + .collect::>() + .try_into() + .map_err(|_| LinkedDidInfoProviderError::TooManyLinkedAccounts)?; Ok(LinkedDidInfoOf { did_details, From 459ab82c5ee68f0c05f215c9ab1d62b0cf397287 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Fri, 1 Dec 2023 17:21:04 +0100 Subject: [PATCH 63/71] Final changes --- Cargo.lock | 1 + crates/kilt-dip-support/Cargo.toml | 6 ++--- dip-template/runtimes/dip-provider/Cargo.toml | 9 +++++-- dip-template/runtimes/dip-provider/src/lib.rs | 24 +++++++++++++++++++ pallets/pallet-deposit-storage/Cargo.toml | 22 ++++++++--------- .../src/benchmarking.rs | 2 +- pallets/pallet-deposit-storage/src/lib.rs | 2 +- pallets/pallet-did-lookup/src/try_state.rs | 1 - .../pallet-dip-consumer/src/benchmarking.rs | 2 +- pallets/pallet-dip-consumer/src/lib.rs | 5 +++- pallets/pallet-migration/src/mock.rs | 4 ++-- pallets/public-credentials/src/mock.rs | 4 ++-- runtimes/common/Cargo.toml | 11 +++++---- runtimes/common/src/assets.rs | 4 ++-- runtimes/common/src/dip/did.rs | 9 ++++--- runtimes/common/src/dip/merkle.rs | 2 -- runtimes/peregrine/Cargo.toml | 19 ++++++++------- 17 files changed, 82 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fd900e9c14..025a6ac684 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2539,6 +2539,7 @@ dependencies = [ "cumulus-primitives-timestamp", "cumulus-primitives-utility", "did", + "frame-benchmarking", "frame-executive", "frame-support", "frame-system", diff --git a/crates/kilt-dip-support/Cargo.toml b/crates/kilt-dip-support/Cargo.toml index 1debed56e0..9f2bc2ab36 100644 --- a/crates/kilt-dip-support/Cargo.toml +++ b/crates/kilt-dip-support/Cargo.toml @@ -24,8 +24,8 @@ pallet-relay-store.workspace = true pallet-web3-names.workspace = true # Parity dependencies -parity-scale-codec = { workspace = true, features = ["derive"] } -scale-info = { workspace = true, features = ["derive"] } +parity-scale-codec = {workspace = true, features = ["derive"]} +scale-info = {workspace = true, features = ["derive"]} # Substrate dependencies frame-system.workspace = true @@ -81,6 +81,6 @@ std = [ ] runtime-benchmarks = [ "pallet-dip-consumer/runtime-benchmarks", - "rococo-runtime/runtime-benchmarks", "pallet-dip-provider/runtime-benchmarks", + "rococo-runtime/runtime-benchmarks" ] diff --git a/dip-template/runtimes/dip-provider/Cargo.toml b/dip-template/runtimes/dip-provider/Cargo.toml index 58db107592..18c9b8cd91 100644 --- a/dip-template/runtimes/dip-provider/Cargo.toml +++ b/dip-template/runtimes/dip-provider/Cargo.toml @@ -66,6 +66,9 @@ cumulus-primitives-utility.workspace = true pallet-collator-selection.workspace = true parachain-info.workspace = true +# Benchmarks +frame-benchmarking = {workspace = true, optional = true} + [features] default = [ "std", @@ -115,7 +118,8 @@ std = [ "cumulus-primitives-timestamp/std", "cumulus-primitives-utility/std", "pallet-collator-selection/std", - "parachain-info/std" + "parachain-info/std", + "frame-benchmarking?/std", ] runtime-benchmarks = [ "did/runtime-benchmarks", @@ -126,5 +130,6 @@ runtime-benchmarks = [ "runtime-common/runtime-benchmarks", "frame-system/runtime-benchmarks", "frame-support/runtime-benchmarks", - "pallet-utility/runtime-benchmarks" + "pallet-utility/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", ] diff --git a/dip-template/runtimes/dip-provider/src/lib.rs b/dip-template/runtimes/dip-provider/src/lib.rs index a0f474b817..5d59f158cd 100644 --- a/dip-template/runtimes/dip-provider/src/lib.rs +++ b/dip-template/runtimes/dip-provider/src/lib.rs @@ -434,6 +434,30 @@ impl pallet_web3_names::Config for Runtime { type WeightInfo = (); } +#[cfg(feature = "runtime-benchmarks")] +mod benches { + frame_benchmarking::define_benchmarks!( + [frame_system, SystemBench::] + [cumulus_pallet_parachain_system, ParachainSystem] + [pallet_timestamp, Timestamp] + [pallet_sudo, Sudo] + [pallet_utility, Utility] + [pallet_balances, Balances] + [pallet_transaction_payment, TransactionPayment] + [pallet_authorship, Authorship] + [pallet_collator_selection, CollatorSelection] + [pallet_session, Session] + [pallet_aura, Aura] + [cumulus_pallet_aura_ext, AuraExt] + [did, Did] + [pallet_did_lookup, DidLookup] + [pallet_web3_names, Web3Names] + [pallet_deposit_storage, DepositStorage] + [pallet_dip_provider, DipProvider] + [frame_benchmarking::baseline, Baseline::] + ); +} + impl_runtime_apis! { impl sp_consensus_aura::AuraApi for Runtime { fn slot_duration() -> SlotDuration { diff --git a/pallets/pallet-deposit-storage/Cargo.toml b/pallets/pallet-deposit-storage/Cargo.toml index c686a9a5e5..216757536e 100644 --- a/pallets/pallet-deposit-storage/Cargo.toml +++ b/pallets/pallet-deposit-storage/Cargo.toml @@ -35,17 +35,17 @@ frame-benchmarking = {workspace = true, optional = true} pallet-balances = {workspace = true, optional = true} [features] -default = [ "std" ] +default = ["std"] std = [ - "frame-support/std", - "frame-system/std", - "kilt-support/std", - "log/std", - "pallet-dip-provider/std", - "parity-scale-codec/std", - "scale-info/std", - "sp-runtime/std", - "sp-std/std", + "frame-support/std", + "frame-system/std", + "kilt-support/std", + "log/std", + "pallet-dip-provider/std", + "parity-scale-codec/std", + "scale-info/std", + "sp-runtime/std", + "sp-std/std", "frame-benchmarking?/std", "pallet-balances?/std", ] @@ -56,7 +56,7 @@ runtime-benchmarks = [ "kilt-support/runtime-benchmarks", "pallet-dip-provider/runtime-benchmarks", "sp-runtime/runtime-benchmarks", - "frame-benchmarking", + "frame-benchmarking/runtime-benchmarks", "pallet-balances/runtime-benchmarks", ] diff --git a/pallets/pallet-deposit-storage/src/benchmarking.rs b/pallets/pallet-deposit-storage/src/benchmarking.rs index 1ced420c73..22bbe81953 100644 --- a/pallets/pallet-deposit-storage/src/benchmarking.rs +++ b/pallets/pallet-deposit-storage/src/benchmarking.rs @@ -28,7 +28,7 @@ use sp_runtime::SaturatedConversion; T::AccountId: Instanciate, T: Config + pallet_balances::Config, T::Namespace: Default -) ] +)] mod benchmarks { use sp_runtime::BoundedVec; diff --git a/pallets/pallet-deposit-storage/src/lib.rs b/pallets/pallet-deposit-storage/src/lib.rs index cdf624db7d..03b8b837af 100644 --- a/pallets/pallet-deposit-storage/src/lib.rs +++ b/pallets/pallet-deposit-storage/src/lib.rs @@ -19,7 +19,7 @@ #![cfg_attr(not(feature = "std"), no_std)] #![recursion_limit = "256"] -pub mod default_weights; +mod default_weights; mod deposit; pub mod traits; diff --git a/pallets/pallet-did-lookup/src/try_state.rs b/pallets/pallet-did-lookup/src/try_state.rs index 2160be005a..2ad1c0caf2 100644 --- a/pallets/pallet-did-lookup/src/try_state.rs +++ b/pallets/pallet-did-lookup/src/try_state.rs @@ -41,7 +41,6 @@ pub(crate) fn do_try_state() -> Result<(), TryRuntimeError> { linked_account_id, did_identifier )) ); - Ok(()) }, ) diff --git a/pallets/pallet-dip-consumer/src/benchmarking.rs b/pallets/pallet-dip-consumer/src/benchmarking.rs index 9c124e3193..78782b4d03 100644 --- a/pallets/pallet-dip-consumer/src/benchmarking.rs +++ b/pallets/pallet-dip-consumer/src/benchmarking.rs @@ -30,7 +30,7 @@ use kilt_support::{ T::Identifier: Instanciate, <::ProofVerifier as IdentityProofVerifier>::Proof: GetWorstCase>, ::RuntimeCall: From>, -) ] +)] mod benchmarks { use super::*; diff --git a/pallets/pallet-dip-consumer/src/lib.rs b/pallets/pallet-dip-consumer/src/lib.rs index b96ca92294..8a82e6ad51 100644 --- a/pallets/pallet-dip-consumer/src/lib.rs +++ b/pallets/pallet-dip-consumer/src/lib.rs @@ -20,7 +20,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -pub mod default_weights; +mod default_weights; pub mod identity; pub mod traits; @@ -138,6 +138,9 @@ pub mod pallet { details: proof_verification_result, }; + // TODO: Maybe find a nicer way to exclude the call dispatched from the + // benchmarks while making sure the call is actually dispatched and passes any + // filters the consumer proof verifier has set. #[cfg(not(feature = "runtime-benchmark"))] let _ = call.dispatch(did_origin.into()).map_err(|e| e.error)?; Ok(()) diff --git a/pallets/pallet-migration/src/mock.rs b/pallets/pallet-migration/src/mock.rs index 02efd367e6..e07fe2e905 100644 --- a/pallets/pallet-migration/src/mock.rs +++ b/pallets/pallet-migration/src/mock.rs @@ -375,9 +375,9 @@ pub mod runtime { } #[cfg(feature = "runtime-benchmarks")] - impl kilt_support::traits::GetWorstCase for TestSubjectId { + impl kilt_support::traits::GetWorstCase for TestSubjectId { // Only used for benchmark testing, not really relevant. - fn worst_case(_context: ()) -> Self { + fn worst_case(_context: Context) -> Self { crate::mock::TestSubjectId::default() } } diff --git a/pallets/public-credentials/src/mock.rs b/pallets/public-credentials/src/mock.rs index 8e2634d2d9..3afa5c3346 100644 --- a/pallets/public-credentials/src/mock.rs +++ b/pallets/public-credentials/src/mock.rs @@ -247,9 +247,9 @@ pub(crate) mod runtime { } #[cfg(feature = "runtime-benchmarks")] - impl kilt_support::traits::GetWorstCase for TestSubjectId { + impl kilt_support::traits::GetWorstCase for TestSubjectId { // Only used for benchmark testing, not really relevant. - fn worst_case(_context: ()) -> Self { + fn worst_case(_context: Context) -> Self { crate::mock::TestSubjectId::default() } } diff --git a/runtimes/common/Cargo.toml b/runtimes/common/Cargo.toml index c60a322556..cfba19e88b 100644 --- a/runtimes/common/Cargo.toml +++ b/runtimes/common/Cargo.toml @@ -11,14 +11,14 @@ repository.workspace = true version.workspace = true [dev-dependencies] -sp-io = { workspace = true, features = ["std"] } +sp-io = {workspace = true, features = ["std"]} [dependencies] # External dependencies kilt-asset-dids.workspace = true log.workspace = true -parity-scale-codec = { workspace = true, features = ["derive"] } -scale-info = { workspace = true, features = ["derive"] } +parity-scale-codec = {workspace = true, features = ["derive"]} +scale-info = {workspace = true, features = ["derive"]} smallvec.workspace = true attestation.workspace = true @@ -60,7 +60,7 @@ xcm-builder.workspace = true xcm-executor.workspace = true xcm.workspace = true -#benchmarking +#benchmarking frame-benchmarking = { workspace = true, optional = true } [features] @@ -84,7 +84,7 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", "xcm-executor/runtime-benchmarks", - "frame-benchmarking", + "frame-benchmarking/runtime-benchmarks", ] std = [ "cumulus-pallet-parachain-system/std", @@ -125,6 +125,7 @@ std = [ "xcm-builder/std", "xcm-executor/std", "xcm/std", + "frame-benchmarking?/std", ] try-runtime = [ "cumulus-pallet-parachain-system/try-runtime", diff --git a/runtimes/common/src/assets.rs b/runtimes/common/src/assets.rs index 1b3c71c461..21368e6ca3 100644 --- a/runtimes/common/src/assets.rs +++ b/runtimes/common/src/assets.rs @@ -104,8 +104,8 @@ mod benchmarks { } } - impl kilt_support::traits::GetWorstCase for AssetDid { - fn worst_case(_context: ()) -> Self { + impl kilt_support::traits::GetWorstCase for AssetDid { + fn worst_case(_context: Context) -> Self { // Returns the worst case for an AssetDID, which is represented by the longest // identifier according to the spec. Self::try_from( diff --git a/runtimes/common/src/dip/did.rs b/runtimes/common/src/dip/did.rs index 2f008d4823..4b6ca4d0e3 100644 --- a/runtimes/common/src/dip/did.rs +++ b/runtimes/common/src/dip/did.rs @@ -35,8 +35,8 @@ use kilt_support::{benchmark::IdentityContext, traits::GetWorstCase}; pub enum LinkedDidInfoProviderError { DidNotFound, DidDeleted, - Internal, TooManyLinkedAccounts, + Internal, } impl From for u16 { @@ -115,6 +115,7 @@ where .take(MAX_LINKED_ACCOUNTS.saturated_into()) .collect::>() .try_into() + // Should never happen since we checked above. .map_err(|_| LinkedDidInfoProviderError::TooManyLinkedAccounts)?; Ok(LinkedDidInfoOf { @@ -145,7 +146,7 @@ where use frame_benchmarking::{vec, Zero}; use frame_support::traits::fungible::Mutate; use sp_io::crypto::{ed25519_generate, sr25519_generate}; - use sp_runtime::{traits::Get, BoundedVec, KeyTypeId}; + use sp_runtime::{traits::Get, KeyTypeId}; use crate::constants::KILT; @@ -217,7 +218,9 @@ where LinkedDidInfoOf { did_details, - linked_accounts, + linked_accounts: linked_accounts + .try_into() + .expect("BoundedVec creation of linked accounts should not fail."), web3_name_details, } } diff --git a/runtimes/common/src/dip/merkle.rs b/runtimes/common/src/dip/merkle.rs index d8c5352533..5eb5829a8d 100644 --- a/runtimes/common/src/dip/merkle.rs +++ b/runtimes/common/src/dip/merkle.rs @@ -73,7 +73,6 @@ impl From for u16 { } pub mod v0 { - use super::*; type ProofLeafOf = RevealedDidMerkleProofLeaf< @@ -107,7 +106,6 @@ pub mod v0 { log::error!("Authentication key should be part of the public keys."); DidMerkleProofError::Internal })?; - let auth_leaf = ProofLeafOf::::DidKey( DidKeyMerkleKey( did_details.authentication_key, diff --git a/runtimes/peregrine/Cargo.toml b/runtimes/peregrine/Cargo.toml index 2e116941ce..e4ee385029 100644 --- a/runtimes/peregrine/Cargo.toml +++ b/runtimes/peregrine/Cargo.toml @@ -19,10 +19,10 @@ sp-io.workspace = true [dependencies] # External dependencies log.workspace = true -parity-scale-codec = { workspace = true, features = ["derive"] } -scale-info = { workspace = true, features = ["derive"] } +parity-scale-codec = {workspace = true, features = ["derive"]} +scale-info = {workspace = true, features = ["derive"]} -hex-literal = { workspace = true, optional = true } +hex-literal = {workspace = true, optional = true} # RPC & Runtime API frame-system-rpc-runtime-api.workspace = true @@ -101,12 +101,12 @@ xcm-executor.workspace = true xcm.workspace = true # Benchmarking dependencies -cumulus-pallet-session-benchmarking = { workspace = true, optional = true } -frame-benchmarking = { workspace = true, optional = true } -frame-system-benchmarking = { workspace = true, optional = true } +cumulus-pallet-session-benchmarking = {workspace = true, optional = true} +frame-benchmarking = {workspace = true, optional = true} +frame-system-benchmarking = {workspace = true, optional = true} # Runtime tests -frame-try-runtime = { workspace = true, optional = true } +frame-try-runtime = {workspace = true, optional = true} [features] default = ["std"] @@ -273,4 +273,7 @@ try-runtime = [ "public-credentials/try-runtime", "runtime-common/try-runtime", ] -with-tracing = ["frame-executive/with-tracing", "sp-io/with-tracing"] +with-tracing = [ + "frame-executive/with-tracing", + "sp-io/with-tracing", +] From 69ad8e4617bfba2cdc7bd9e22b1023335d72aa68 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Fri, 1 Dec 2023 17:26:21 +0100 Subject: [PATCH 64/71] Remove some TODOs and FIXMEs --- crates/kilt-dip-support/src/export/child.rs | 1 - dip-template/runtimes/dip-consumer/src/origin_adapter.rs | 3 +-- pallets/pallet-dip-consumer/src/lib.rs | 1 - 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/kilt-dip-support/src/export/child.rs b/crates/kilt-dip-support/src/export/child.rs index 6df44c2e49..619197a738 100644 --- a/crates/kilt-dip-support/src/export/child.rs +++ b/crates/kilt-dip-support/src/export/child.rs @@ -629,7 +629,6 @@ mod v0 { // 1.2 If so, extract the state root from the header let state_root_at_height = proof.relay_header.state_root; - // FIXME: Compilation error // 2. Verify relay chain proof let provider_parachain_header = ParachainHeadProofVerifier::::verify_proof_for_parachain_with_root( diff --git a/dip-template/runtimes/dip-consumer/src/origin_adapter.rs b/dip-template/runtimes/dip-consumer/src/origin_adapter.rs index d973367b33..ebde676e7a 100644 --- a/dip-template/runtimes/dip-consumer/src/origin_adapter.rs +++ b/dip-template/runtimes/dip-consumer/src/origin_adapter.rs @@ -35,8 +35,7 @@ impl EnsureOrigin for EnsureDipOriginAdapter { #[cfg(feature = "runtime-benchmarks")] fn try_successful_origin() -> Result { - // TODO: Replace with actual DIP origin upon benchmarking - Ok(RuntimeOrigin::root()) + EnsureDipOrigin::::try_successful_origin() } } diff --git a/pallets/pallet-dip-consumer/src/lib.rs b/pallets/pallet-dip-consumer/src/lib.rs index 8a82e6ad51..6c4955eb94 100644 --- a/pallets/pallet-dip-consumer/src/lib.rs +++ b/pallets/pallet-dip-consumer/src/lib.rs @@ -104,7 +104,6 @@ pub mod pallet { pub type Origin = DipOrigin<::Identifier, ::AccountId, VerificationResultOf>; - // TODO: Benchmarking #[pallet::call] impl Pallet { // TODO: Replace with a SignedExtra. From e64d943148ae445211561f364fee17e3f69e2fd2 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Mon, 4 Dec 2023 17:02:28 +0100 Subject: [PATCH 65/71] Fix features in node binaries --- dip-template/nodes/dip-consumer/Cargo.toml | 11 +++++ dip-template/nodes/dip-consumer/src/cli.rs | 3 ++ .../nodes/dip-consumer/src/command.rs | 41 +++++++++++++++++++ dip-template/nodes/dip-provider/Cargo.toml | 6 +++ dip-template/nodes/dip-provider/src/cli.rs | 3 ++ .../nodes/dip-provider/src/command.rs | 41 +++++++++++++++++++ 6 files changed, 105 insertions(+) diff --git a/dip-template/nodes/dip-consumer/Cargo.toml b/dip-template/nodes/dip-consumer/Cargo.toml index b48e55d0db..7ff397acc5 100644 --- a/dip-template/nodes/dip-consumer/Cargo.toml +++ b/dip-template/nodes/dip-consumer/Cargo.toml @@ -68,3 +68,14 @@ cumulus-relay-chain-interface.workspace = true [build-dependencies] substrate-build-script-utils.workspace = true + +[features] +runtime-benchmarks = [ + "frame-benchmarking-cli/runtime-benchmarks", + "dip-consumer-runtime-template/runtime-benchmarks", + # "frame-benchmarking/runtime-benchmarks", + # "polkadot-cli/runtime-benchmarks", + # "polkadot-primitives/runtime-benchmarks", + # "sc-service/runtime-benchmarks", + # "sp-runtime/runtime-benchmarks", +] diff --git a/dip-template/nodes/dip-consumer/src/cli.rs b/dip-template/nodes/dip-consumer/src/cli.rs index 5e5d10525a..da4f536121 100644 --- a/dip-template/nodes/dip-consumer/src/cli.rs +++ b/dip-template/nodes/dip-consumer/src/cli.rs @@ -25,6 +25,7 @@ use sc_service::Configuration; use crate::chain_spec::Extensions; +#[allow(clippy::large_enum_variant)] #[derive(Debug, clap::Subcommand)] pub enum Subcommand { BuildSpec(BuildSpecCmd), @@ -44,6 +45,8 @@ pub enum Subcommand { ExportGenesisState(ExportGenesisStateCommand), ExportGenesisWasm(ExportGenesisWasmCommand), + #[command(subcommand)] + Benchmark(frame_benchmarking_cli::BenchmarkCmd), } #[derive(Debug, clap::Parser)] diff --git a/dip-template/nodes/dip-consumer/src/command.rs b/dip-template/nodes/dip-consumer/src/command.rs index e560839502..36898a0190 100644 --- a/dip-template/nodes/dip-consumer/src/command.rs +++ b/dip-template/nodes/dip-consumer/src/command.rs @@ -19,6 +19,8 @@ use std::{fs::create_dir_all, net::SocketAddr}; use cumulus_primitives_core::ParaId; +use dip_consumer_runtime_template::Block; +use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE}; use log::{info, warn}; use sc_cli::{ ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, LoggerBuilder, @@ -189,6 +191,45 @@ pub fn run() -> Result<()> { cmd.run(&*spec) }) } + Some(Subcommand::Benchmark(cmd)) => { + let runner = cli.create_runner(cmd)?; + match cmd { + BenchmarkCmd::Pallet(cmd) => { + if cfg!(feature = "runtime-benchmarks") { + runner.sync_run(|config| cmd.run::(config)) + } else { + Err("Benchmarking wasn't enabled when building the node. \ + You can enable it with `--features runtime-benchmarks`." + .into()) + } + } + BenchmarkCmd::Block(cmd) => runner.sync_run(|config| { + let partials = new_partial(&config)?; + cmd.run(partials.client) + }), + #[cfg(not(feature = "runtime-benchmarks"))] + BenchmarkCmd::Storage(_) => { + return Err(sc_cli::Error::Input( + "Compile with --features=runtime-benchmarks \ + to enable storage benchmarks." + .into(), + ) + .into()) + } + #[cfg(feature = "runtime-benchmarks")] + BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| { + let partials = new_partial(&config)?; + let db = partials.backend.expose_db(); + let storage = partials.backend.expose_storage(); + cmd.run(config, partials.client.clone(), db, storage) + }), + BenchmarkCmd::Machine(cmd) => { + runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())) + } + #[allow(unreachable_patterns)] + _ => Err("Benchmarking sub-command unsupported".into()), + } + } None => { let runner = cli.create_runner(&cli.run.normalize())?; let collator_options = cli.run.collator_options(); diff --git a/dip-template/nodes/dip-provider/Cargo.toml b/dip-template/nodes/dip-provider/Cargo.toml index 0bc866dddf..584bca26ee 100644 --- a/dip-template/nodes/dip-provider/Cargo.toml +++ b/dip-template/nodes/dip-provider/Cargo.toml @@ -68,3 +68,9 @@ cumulus-relay-chain-interface.workspace = true [build-dependencies] substrate-build-script-utils.workspace = true + +[features] +runtime-benchmarks = [ + "frame-benchmarking-cli/runtime-benchmarks", + "dip-provider-runtime-template/runtime-benchmarks" +] diff --git a/dip-template/nodes/dip-provider/src/cli.rs b/dip-template/nodes/dip-provider/src/cli.rs index 5e5d10525a..da4f536121 100644 --- a/dip-template/nodes/dip-provider/src/cli.rs +++ b/dip-template/nodes/dip-provider/src/cli.rs @@ -25,6 +25,7 @@ use sc_service::Configuration; use crate::chain_spec::Extensions; +#[allow(clippy::large_enum_variant)] #[derive(Debug, clap::Subcommand)] pub enum Subcommand { BuildSpec(BuildSpecCmd), @@ -44,6 +45,8 @@ pub enum Subcommand { ExportGenesisState(ExportGenesisStateCommand), ExportGenesisWasm(ExportGenesisWasmCommand), + #[command(subcommand)] + Benchmark(frame_benchmarking_cli::BenchmarkCmd), } #[derive(Debug, clap::Parser)] diff --git a/dip-template/nodes/dip-provider/src/command.rs b/dip-template/nodes/dip-provider/src/command.rs index 6e508956e0..976c311898 100644 --- a/dip-template/nodes/dip-provider/src/command.rs +++ b/dip-template/nodes/dip-provider/src/command.rs @@ -19,6 +19,8 @@ use std::{fs::create_dir_all, net::SocketAddr}; use cumulus_primitives_core::ParaId; +use dip_provider_runtime_template::Block; +use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE}; use log::{info, warn}; use sc_cli::{ ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams, LoggerBuilder, @@ -189,6 +191,45 @@ pub fn run() -> Result<()> { cmd.run(&*spec) }) } + Some(Subcommand::Benchmark(cmd)) => { + let runner = cli.create_runner(cmd)?; + match cmd { + BenchmarkCmd::Pallet(cmd) => { + if cfg!(feature = "runtime-benchmarks") { + runner.sync_run(|config| cmd.run::(config)) + } else { + Err("Benchmarking wasn't enabled when building the node. \ + You can enable it with `--features runtime-benchmarks`." + .into()) + } + } + BenchmarkCmd::Block(cmd) => runner.sync_run(|config| { + let partials = new_partial(&config)?; + cmd.run(partials.client) + }), + #[cfg(not(feature = "runtime-benchmarks"))] + BenchmarkCmd::Storage(_) => { + return Err(sc_cli::Error::Input( + "Compile with --features=runtime-benchmarks \ + to enable storage benchmarks." + .into(), + ) + .into()) + } + #[cfg(feature = "runtime-benchmarks")] + BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| { + let partials = new_partial(&config)?; + let db = partials.backend.expose_db(); + let storage = partials.backend.expose_storage(); + cmd.run(config, partials.client.clone(), db, storage) + }), + BenchmarkCmd::Machine(cmd) => { + runner.sync_run(|config| cmd.run(&config, SUBSTRATE_REFERENCE_HARDWARE.clone())) + } + #[allow(unreachable_patterns)] + _ => Err("Benchmarking sub-command unsupported".into()), + } + } None => { let runner = cli.create_runner(&cli.run.normalize())?; let collator_options = cli.run.collator_options(); From 82ac447a05868115b3ae159fda0085d6ff4407c7 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Tue, 5 Dec 2023 11:14:36 +0100 Subject: [PATCH 66/71] Fix features --- Cargo.lock | 7 ++ dip-template/runtimes/dip-consumer/Cargo.toml | 16 +++++ dip-template/runtimes/dip-consumer/src/lib.rs | 65 +++++++++++++++++++ dip-template/runtimes/dip-provider/Cargo.toml | 12 ++++ dip-template/runtimes/dip-provider/src/dip.rs | 7 ++ dip-template/runtimes/dip-provider/src/lib.rs | 58 +++++++++++++++-- 6 files changed, 158 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 025a6ac684..4ed02506ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2433,15 +2433,19 @@ dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", + "cumulus-pallet-session-benchmarking", "cumulus-primitives-core", "cumulus-primitives-timestamp", "cumulus-primitives-utility", "did", "dip-provider-runtime-template", + "frame-benchmarking", "frame-executive", "frame-support", "frame-system", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", + "hex-literal 0.3.4", "kilt-dip-support", "pallet-aura", "pallet-authorship", @@ -2535,6 +2539,7 @@ dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", + "cumulus-pallet-session-benchmarking", "cumulus-primitives-core", "cumulus-primitives-timestamp", "cumulus-primitives-utility", @@ -2543,7 +2548,9 @@ dependencies = [ "frame-executive", "frame-support", "frame-system", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", + "hex-literal 0.3.4", "kilt-dip-support", "kilt-runtime-api-did", "kilt-runtime-api-dip-provider", diff --git a/dip-template/runtimes/dip-consumer/Cargo.toml b/dip-template/runtimes/dip-consumer/Cargo.toml index 078f172253..132a2cfc69 100644 --- a/dip-template/runtimes/dip-consumer/Cargo.toml +++ b/dip-template/runtimes/dip-consumer/Cargo.toml @@ -64,6 +64,12 @@ cumulus-primitives-utility.workspace = true pallet-collator-selection.workspace = true parachain-info.workspace = true +# Benchmarks +cumulus-pallet-session-benchmarking = {workspace = true, optional = true} +frame-benchmarking = {workspace = true, optional = true} +frame-system-benchmarking = {workspace = true, optional = true} +hex-literal = {workspace = true, optional = true} + [features] default = [ "std", @@ -118,8 +124,18 @@ runtime-benchmarks = [ "dip-provider-runtime-template/runtime-benchmarks", "kilt-dip-support/runtime-benchmarks", "pallet-dip-consumer/runtime-benchmarks", + "pallet-relay-store/runtime-benchmarks", "runtime-common/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-collator-selection/runtime-benchmarks", + "pallet-sudo/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", "pallet-utility/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "cumulus-pallet-session-benchmarking/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", + "frame-system-benchmarking/runtime-benchmarks", + "hex-literal" ] diff --git a/dip-template/runtimes/dip-consumer/src/lib.rs b/dip-template/runtimes/dip-consumer/src/lib.rs index 953b179b9b..d6b9ca53bd 100644 --- a/dip-template/runtimes/dip-consumer/src/lib.rs +++ b/dip-template/runtimes/dip-consumer/src/lib.rs @@ -358,6 +358,21 @@ impl pallet_postit::Config for Runtime { type Username = Web3Name; } +#[cfg(feature = "runtime-benchmarks")] +mod benches { + frame_benchmarking::define_benchmarks!( + [frame_system, SystemBench::] + [pallet_timestamp, Timestamp] + [pallet_sudo, Sudo] + [pallet_utility, Utility] + [pallet_balances, Balances] + [pallet_collator_selection, CollatorSelection] + [pallet_session, SessionBench::] + [pallet_dip_consumer, DipConsumer] + [pallet_relay_store, RelayStore] + ); +} + impl_runtime_apis! { impl sp_consensus_aura::AuraApi for Runtime { fn slot_duration() -> SlotDuration { @@ -501,4 +516,54 @@ impl_runtime_apis! { ParachainSystem::collect_collation_info(header) } } + + #[cfg(feature = "runtime-benchmarks")] + impl frame_benchmarking::Benchmark for Runtime { + fn benchmark_metadata(extra: bool) -> ( + Vec, + Vec, + ) { + use frame_benchmarking::{Benchmarking, BenchmarkList}; + use frame_support::traits::StorageInfoTrait; + use frame_system_benchmarking::Pallet as SystemBench; + use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + + let mut list = Vec::::new(); + list_benchmarks!(list, extra); + + let storage_info = AllPalletsWithSystem::storage_info(); + (list, storage_info) + } + + fn dispatch_benchmark( + config: frame_benchmarking::BenchmarkConfig + ) -> Result, sp_runtime::RuntimeString> { + use frame_benchmarking::{BenchmarkError, Benchmarking, BenchmarkBatch}; + + use frame_system_benchmarking::Pallet as SystemBench; + impl frame_system_benchmarking::Config for Runtime { + fn setup_set_code_requirements(code: &sp_std::vec::Vec) -> Result<(), BenchmarkError> { + ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32); + Ok(()) + } + + fn verify_set_code() { + System::assert_last_event(cumulus_pallet_parachain_system::Event::::ValidationFunctionStored.into()); + } + } + + use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + impl cumulus_pallet_session_benchmarking::Config for Runtime {} + + use frame_support::traits::WhitelistedStorageKeys; + let whitelist = AllPalletsWithSystem::whitelisted_storage_keys(); + + let mut batches = Vec::::new(); + let params = (&config, &whitelist); + add_benchmarks!(params, batches); + + if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } + Ok(batches) + } + } } diff --git a/dip-template/runtimes/dip-provider/Cargo.toml b/dip-template/runtimes/dip-provider/Cargo.toml index 18c9b8cd91..458fe47c7a 100644 --- a/dip-template/runtimes/dip-provider/Cargo.toml +++ b/dip-template/runtimes/dip-provider/Cargo.toml @@ -67,7 +67,10 @@ pallet-collator-selection.workspace = true parachain-info.workspace = true # Benchmarks +cumulus-pallet-session-benchmarking = {workspace = true, optional = true} frame-benchmarking = {workspace = true, optional = true} +frame-system-benchmarking = {workspace = true, optional = true} +hex-literal = {workspace = true, optional = true} [features] default = [ @@ -124,12 +127,21 @@ std = [ runtime-benchmarks = [ "did/runtime-benchmarks", "kilt-dip-support/runtime-benchmarks", + "pallet-deposit-storage/runtime-benchmarks", "pallet-did-lookup/runtime-benchmarks", "pallet-dip-provider/runtime-benchmarks", "pallet-web3-names/runtime-benchmarks", "runtime-common/runtime-benchmarks", "frame-system/runtime-benchmarks", "frame-support/runtime-benchmarks", + "pallet-balances/runtime-benchmarks", + "pallet-collator-selection/runtime-benchmarks", + "pallet-sudo/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", "pallet-utility/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "cumulus-pallet-session-benchmarking/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", + "frame-system-benchmarking/runtime-benchmarks", + "hex-literal" ] diff --git a/dip-template/runtimes/dip-provider/src/dip.rs b/dip-template/runtimes/dip-provider/src/dip.rs index d0c1f7220d..1982854081 100644 --- a/dip-template/runtimes/dip-provider/src/dip.rs +++ b/dip-template/runtimes/dip-provider/src/dip.rs @@ -72,6 +72,13 @@ pub mod deposit { DipProvider, } + #[cfg(feature = "runtime-benchmarks")] + impl Default for DepositNamespaces { + fn default() -> Self { + Self::DipProvider + } + } + pub struct DipProviderDepositNamespace; impl Get for DipProviderDepositNamespace { diff --git a/dip-template/runtimes/dip-provider/src/lib.rs b/dip-template/runtimes/dip-provider/src/lib.rs index 5d59f158cd..c701a9976c 100644 --- a/dip-template/runtimes/dip-provider/src/lib.rs +++ b/dip-template/runtimes/dip-provider/src/lib.rs @@ -438,23 +438,17 @@ impl pallet_web3_names::Config for Runtime { mod benches { frame_benchmarking::define_benchmarks!( [frame_system, SystemBench::] - [cumulus_pallet_parachain_system, ParachainSystem] [pallet_timestamp, Timestamp] [pallet_sudo, Sudo] [pallet_utility, Utility] [pallet_balances, Balances] - [pallet_transaction_payment, TransactionPayment] - [pallet_authorship, Authorship] [pallet_collator_selection, CollatorSelection] - [pallet_session, Session] - [pallet_aura, Aura] - [cumulus_pallet_aura_ext, AuraExt] + [pallet_session, SessionBench::] [did, Did] [pallet_did_lookup, DidLookup] [pallet_web3_names, Web3Names] [pallet_deposit_storage, DepositStorage] [pallet_dip_provider, DipProvider] - [frame_benchmarking::baseline, Baseline::] ); } @@ -702,4 +696,54 @@ impl_runtime_apis! { DidMerkleRootGenerator::::generate_proof(&identity_details, request.version, request.keys.iter(), request.should_include_web3_name, request.accounts.iter()).map_err(runtime_api::DipProofError::MerkleProof) } } + + #[cfg(feature = "runtime-benchmarks")] + impl frame_benchmarking::Benchmark for Runtime { + fn benchmark_metadata(extra: bool) -> ( + Vec, + Vec, + ) { + use frame_benchmarking::{Benchmarking, BenchmarkList}; + use frame_support::traits::StorageInfoTrait; + use frame_system_benchmarking::Pallet as SystemBench; + use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + + let mut list = Vec::::new(); + list_benchmarks!(list, extra); + + let storage_info = AllPalletsWithSystem::storage_info(); + (list, storage_info) + } + + fn dispatch_benchmark( + config: frame_benchmarking::BenchmarkConfig + ) -> Result, sp_runtime::RuntimeString> { + use frame_benchmarking::{BenchmarkError, Benchmarking, BenchmarkBatch}; + + use frame_system_benchmarking::Pallet as SystemBench; + impl frame_system_benchmarking::Config for Runtime { + fn setup_set_code_requirements(code: &sp_std::vec::Vec) -> Result<(), BenchmarkError> { + ParachainSystem::initialize_for_set_code_benchmark(code.len() as u32); + Ok(()) + } + + fn verify_set_code() { + System::assert_last_event(cumulus_pallet_parachain_system::Event::::ValidationFunctionStored.into()); + } + } + + use cumulus_pallet_session_benchmarking::Pallet as SessionBench; + impl cumulus_pallet_session_benchmarking::Config for Runtime {} + + use frame_support::traits::WhitelistedStorageKeys; + let whitelist = AllPalletsWithSystem::whitelisted_storage_keys(); + + let mut batches = Vec::::new(); + let params = (&config, &whitelist); + add_benchmarks!(params, batches); + + if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) } + Ok(batches) + } + } } From b7add42a247888bf7a34ae8f7f64ecc5fcc3563f Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Tue, 5 Dec 2023 14:16:30 +0100 Subject: [PATCH 67/71] Compiling --- Cargo.lock | 1 + crates/kilt-dip-support/Cargo.toml | 3 + crates/kilt-dip-support/src/did.rs | 94 ++++++++++++++- crates/kilt-dip-support/src/export/child.rs | 11 +- crates/kilt-dip-support/src/export/common.rs | 36 +++++- crates/kilt-dip-support/src/export/sibling.rs | 61 ++++++++-- crates/kilt-dip-support/src/lib.rs | 1 + crates/kilt-dip-support/src/merkle.rs | 114 +++++++++++++++++- crates/kilt-dip-support/src/state_proofs.rs | 59 ++++++++- crates/kilt-dip-support/src/utils.rs | 60 +++++++++ pallets/did/src/did_details.rs | 7 ++ support/src/benchmark.rs | 4 +- 12 files changed, 430 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4ed02506ab..bf8c5c35c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4565,6 +4565,7 @@ dependencies = [ "frame-system", "hash-db", "hex-literal 0.3.4", + "kilt-support", "log", "pallet-did-lookup", "pallet-dip-consumer", diff --git a/crates/kilt-dip-support/Cargo.toml b/crates/kilt-dip-support/Cargo.toml index 9f2bc2ab36..c238d8e526 100644 --- a/crates/kilt-dip-support/Cargo.toml +++ b/crates/kilt-dip-support/Cargo.toml @@ -17,6 +17,7 @@ log.workspace = true # Internal dependencies did.workspace = true +kilt-support = {workspace = true, optional = true} pallet-did-lookup.workspace = true pallet-dip-consumer.workspace = true pallet-dip-provider.workspace = true @@ -57,6 +58,7 @@ std = [ "hash-db/std", "log/std", "did/std", + "kilt-support/std", "pallet-did-lookup/std", "pallet-dip-consumer/std", "pallet-dip-provider/std", @@ -80,6 +82,7 @@ std = [ "parachain-info/std", ] runtime-benchmarks = [ + "kilt-support/runtime-benchmarks", "pallet-dip-consumer/runtime-benchmarks", "pallet-dip-provider/runtime-benchmarks", "rococo-runtime/runtime-benchmarks" diff --git a/crates/kilt-dip-support/src/did.rs b/crates/kilt-dip-support/src/did.rs index 7b16bcbb8e..f598614925 100644 --- a/crates/kilt-dip-support/src/did.rs +++ b/crates/kilt-dip-support/src/did.rs @@ -20,7 +20,6 @@ use did::{ did_details::{DidPublicKey, DidPublicKeyDetails, DidVerificationKey}, DidSignature, DidVerificationKeyRelationship, }; -use frame_support::ensure; use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_core::RuntimeDebug; @@ -44,6 +43,20 @@ pub struct TimeBoundDidSignature { pub block_number: BlockNumber, } +#[cfg(feature = "runtime-benchmarks")] +impl kilt_support::traits::GetWorstCase for TimeBoundDidSignature +where + DidSignature: kilt_support::traits::GetWorstCase, + BlockNumber: Default, +{ + fn worst_case(context: Context) -> Self { + Self { + signature: DidSignature::worst_case(context), + block_number: BlockNumber::default(), + } + } +} + pub enum RevealedDidKeysSignatureAndCallVerifierError { SignatureNotFresh, SignatureUnverifiable, @@ -121,6 +134,7 @@ impl< CallVerifier: DipCallOriginFilter, DidVerificationKeyRelationship)>, { + #[cfg(not(feature = "runtime-benchmarks"))] #[allow(clippy::result_unit_err)] pub(crate) fn verify_did_signature_for_call( call: &Call, @@ -131,6 +145,8 @@ impl< (DidVerificationKey, DidVerificationKeyRelationship), RevealedDidKeysSignatureAndCallVerifierError, > { + use frame_support::ensure; + let block_number = ContextProvider::block_number(); let is_signature_fresh = if let Some(blocks_ago_from_now) = block_number.checked_sub(&merkle_revealed_did_signature.did_signature.block_number) @@ -183,4 +199,80 @@ impl< .map_err(|_| RevealedDidKeysSignatureAndCallVerifierError::OriginCheckFailed)?; Ok((key.clone(), *relationship)) } + + #[cfg(feature = "runtime-benchmarks")] + #[allow(clippy::result_unit_err)] + pub(crate) fn verify_did_signature_for_call( + call: &Call, + submitter: &Submitter, + local_details: &mut Option, + merkle_revealed_did_signature: RevealedDidKeysAndSignature, + ) -> Result< + (DidVerificationKey, DidVerificationKeyRelationship), + RevealedDidKeysSignatureAndCallVerifierError, + > { + use sp_core::ed25519; + + let block_number = ContextProvider::block_number(); + // Computed but ignored + if let Some(blocks_ago_from_now) = + block_number.checked_sub(&merkle_revealed_did_signature.did_signature.block_number) + { + // False if the signature is too old. + blocks_ago_from_now <= ContextProvider::SIGNATURE_VALIDITY.into() + } else { + // Signature generated at a future time, not possible to verify. + false + }; + let encoded_payload = ( + call, + &local_details, + submitter, + &merkle_revealed_did_signature.did_signature.block_number, + ContextProvider::genesis_hash(), + ContextProvider::signed_extra(), + ) + .encode(); + // Only consider verification keys from the set of revealed keys. + let proof_verification_keys: Vec<(DidVerificationKey, DidVerificationKeyRelationship)> = + merkle_revealed_did_signature + .merkle_leaves + .borrow() + .iter() + .filter_map( + |RevealedDidKey { + relationship, + details: DidPublicKeyDetails { key, .. }, + .. + }| { + let DidPublicKey::PublicVerificationKey(key) = key else { + return None; + }; + if let Ok(vr) = DidVerificationKeyRelationship::try_from(*relationship) { + Some(Ok((key.clone(), vr))) + } else { + None + } + }, + ) + .collect::>()?; + let valid_signing_key = proof_verification_keys.iter().find(|(verification_key, _)| { + verification_key + .verify_signature(&encoded_payload, &merkle_revealed_did_signature.did_signature.signature) + .is_ok() + }); + let default = ( + DidVerificationKey::Ed25519(ed25519::Public::from_raw([0u8; 32])), + DidVerificationKeyRelationship::Authentication, + ); + let (key, relationship) = valid_signing_key.unwrap_or(&default); + if let Some(details) = local_details { + details.bump(); + } else { + *local_details = Some(DidLocalDetails::default()); + }; + // Ignore the result of this call + let _ = CallVerifier::check_call_origin_info(call, &(key.clone(), *relationship)); + Ok((key.clone(), *relationship)) + } } diff --git a/crates/kilt-dip-support/src/export/child.rs b/crates/kilt-dip-support/src/export/child.rs index 619197a738..4a148885cf 100644 --- a/crates/kilt-dip-support/src/export/child.rs +++ b/crates/kilt-dip-support/src/export/child.rs @@ -27,7 +27,7 @@ use parity_scale_codec::{Codec, Decode, Encode, HasCompact}; use scale_info::TypeInfo; use sp_core::{RuntimeDebug, U256}; use sp_runtime::traits::{AtLeast32BitUnsigned, Get, Hash, MaybeDisplay, Member, SimpleBitOps}; -use sp_std::{marker::PhantomData, vec::Vec}; +use sp_std::marker::PhantomData; use crate::{ did::RevealedDidKeysSignatureAndCallVerifierError, @@ -38,7 +38,7 @@ use crate::{ RelayChainStorageInfo, }, utils::OutputOf, - FrameSystemDidSignatureContext, ProviderParachainStateInfoViaProviderPallet, + BoundedBlindedValue, FrameSystemDidSignatureContext, ProviderParachainStateInfoViaProviderPallet, }; #[derive(Encode, Decode, PartialEq, Eq, RuntimeDebug, TypeInfo, Clone)] @@ -209,7 +209,7 @@ impl< type Proof = VersionedChildParachainDipStateProof< ::BlockNumber, ::Hasher, - Vec>, + BoundedBlindedValue, RevealedDidMerkleProofLeaf< KeyIdOf, KiltRuntime::AccountId, @@ -376,7 +376,7 @@ impl< type Proof = VersionedChildParachainDipStateProof< ::BlockNumber, ::Hasher, - Vec>, + BoundedBlindedValue, RevealedDidMerkleProofLeaf< ProviderDidKeyId, ProviderAccountId, @@ -460,6 +460,7 @@ mod v0 { ProviderParachainStateInfo, RelayChainStorageInfo, }, utils::OutputOf, + BoundedBlindedValue, }; #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)] @@ -592,7 +593,7 @@ mod v0 { type Proof = ChildParachainDipStateProof< ::BlockNumber, ::Hasher, - Vec>, + BoundedBlindedValue, RevealedDidMerkleProofLeaf< ProviderDidKeyId, ProviderAccountId, diff --git a/crates/kilt-dip-support/src/export/common.rs b/crates/kilt-dip-support/src/export/common.rs index d0eff66d68..fa98de6f16 100644 --- a/crates/kilt-dip-support/src/export/common.rs +++ b/crates/kilt-dip-support/src/export/common.rs @@ -24,14 +24,27 @@ pub mod v0 { use parity_scale_codec::{Decode, Encode}; use scale_info::TypeInfo; use sp_core::RuntimeDebug; - use sp_std::vec::Vec; - use crate::{did::TimeBoundDidSignature, merkle::DidMerkleProof}; + use crate::{did::TimeBoundDidSignature, merkle::DidMerkleProof, BoundedBlindedValue}; #[derive(Encode, Decode, PartialEq, Eq, PartialOrd, Ord, RuntimeDebug, TypeInfo, Clone)] pub struct ParachainRootStateProof { pub(crate) relay_block_height: RelayBlockHeight, - pub(crate) proof: Vec>, + pub(crate) proof: BoundedBlindedValue, + } + + #[cfg(feature = "runtime-benchmarks")] + impl kilt_support::traits::GetWorstCase + for ParachainRootStateProof + where + RelayBlockHeight: Default, + { + fn worst_case(context: Context) -> Self { + Self { + relay_block_height: RelayBlockHeight::default(), + proof: BoundedBlindedValue::worst_case(context), + } + } } #[derive(Encode, Decode, PartialEq, Eq, RuntimeDebug, TypeInfo, Clone)] @@ -39,4 +52,21 @@ pub mod v0 { pub(crate) leaves: DidMerkleProof, pub(crate) signature: TimeBoundDidSignature, } + + #[cfg(feature = "runtime-benchmarks")] + impl kilt_support::traits::GetWorstCase + for DipMerkleProofAndDidSignature + where + BlindedValues: kilt_support::traits::GetWorstCase, + Leaf: Default + Clone, + BlockNumber: Default, + Context: Clone, + { + fn worst_case(context: Context) -> Self { + Self { + leaves: DidMerkleProof::worst_case(context.clone()), + signature: TimeBoundDidSignature::worst_case(context), + } + } + } } diff --git a/crates/kilt-dip-support/src/export/sibling.rs b/crates/kilt-dip-support/src/export/sibling.rs index 5f82560104..0fd6ec989e 100644 --- a/crates/kilt-dip-support/src/export/sibling.rs +++ b/crates/kilt-dip-support/src/export/sibling.rs @@ -27,7 +27,7 @@ use parity_scale_codec::{Decode, Encode, HasCompact}; use scale_info::TypeInfo; use sp_core::{RuntimeDebug, U256}; use sp_runtime::traits::Get; -use sp_std::{marker::PhantomData, vec::Vec}; +use sp_std::marker::PhantomData; use crate::{ did::RevealedDidKeysSignatureAndCallVerifierError, @@ -35,7 +35,7 @@ use crate::{ state_proofs::{parachain::DipIdentityCommitmentProofVerifierError, relay_chain::ParachainHeadProofVerifierError}, traits::{self, Bump, DidSignatureVerifierContext, DipCallOriginFilter}, utils::OutputOf, - FrameSystemDidSignatureContext, ProviderParachainStateInfoViaProviderPallet, + BoundedBlindedValue, FrameSystemDidSignatureContext, ProviderParachainStateInfoViaProviderPallet, }; #[derive(Encode, Decode, PartialEq, Eq, RuntimeDebug, TypeInfo, Clone)] @@ -56,6 +56,26 @@ pub enum VersionedSiblingParachainDipStateProof< ), } +#[cfg(feature = "runtime-benchmarks")] +impl + kilt_support::traits::GetWorstCase + for VersionedSiblingParachainDipStateProof< + RelayBlockHeight, + DipMerkleProofBlindedValues, + DipMerkleProofRevealedLeaf, + LocalBlockNumber, + > where + RelayBlockHeight: Default, + DipMerkleProofBlindedValues: kilt_support::traits::GetWorstCase, + DipMerkleProofRevealedLeaf: Default + Clone, + LocalBlockNumber: Default, + Context: Clone, +{ + fn worst_case(context: Context) -> Self { + Self::V0(v0::SiblingParachainDipStateProof::worst_case(context)) + } +} + pub enum DipSiblingProviderStateProofVerifierError< ParachainHeadMerkleProofVerificationError, IdentityCommitmentMerkleProofVerificationError, @@ -183,7 +203,7 @@ impl< >; type Proof = VersionedSiblingParachainDipStateProof< RelayChainStateInfo::BlockNumber, - Vec>, + BoundedBlindedValue, RevealedDidMerkleProofLeaf< KeyIdOf, KiltRuntime::AccountId, @@ -336,7 +356,7 @@ impl< >; type Proof = VersionedSiblingParachainDipStateProof< RelayChainStateInfo::BlockNumber, - Vec>, + BoundedBlindedValue, RevealedDidMerkleProofLeaf< ProviderDidKeyId, ProviderAccountId, @@ -413,9 +433,34 @@ mod v0 { DipMerkleProofRevealedLeaf, LocalBlockNumber, > { - para_state_root: ParachainRootStateProof, - dip_identity_commitment: Vec>, - did: DipMerkleProofAndDidSignature, + pub(crate) para_state_root: ParachainRootStateProof, + pub(crate) dip_identity_commitment: BoundedBlindedValue, + pub(crate) did: + DipMerkleProofAndDidSignature, + } + + #[cfg(feature = "runtime-benchmarks")] + impl + kilt_support::traits::GetWorstCase + for SiblingParachainDipStateProof< + RelayBlockHeight, + DipMerkleProofBlindedValues, + DipMerkleProofRevealedLeaf, + LocalBlockNumber, + > where + DipMerkleProofBlindedValues: kilt_support::traits::GetWorstCase, + DipMerkleProofRevealedLeaf: Default + Clone, + RelayBlockHeight: Default, + LocalBlockNumber: Default, + Context: Clone, + { + fn worst_case(context: Context) -> Self { + Self { + para_state_root: ParachainRootStateProof::worst_case(context.clone()), + dip_identity_commitment: BoundedBlindedValue::worst_case(context.clone()), + did: DipMerkleProofAndDidSignature::worst_case(context), + } + } } #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)] @@ -518,7 +563,7 @@ mod v0 { >; type Proof = SiblingParachainDipStateProof< RelayChainStateInfo::BlockNumber, - Vec>, + BoundedBlindedValue, RevealedDidMerkleProofLeaf< ProviderDidKeyId, ProviderAccountId, diff --git a/crates/kilt-dip-support/src/lib.rs b/crates/kilt-dip-support/src/lib.rs index 0322801680..9d7a415616 100644 --- a/crates/kilt-dip-support/src/lib.rs +++ b/crates/kilt-dip-support/src/lib.rs @@ -34,3 +34,4 @@ pub use state_proofs::{ relay_chain::{ParachainHeadProofVerifier, ParachainHeadProofVerifierError, RelayStateRootsViaRelayStorePallet}, }; pub use traits::{FrameSystemDidSignatureContext, ProviderParachainStateInfoViaProviderPallet}; +pub use utils::BoundedBlindedValue; diff --git a/crates/kilt-dip-support/src/merkle.rs b/crates/kilt-dip-support/src/merkle.rs index 2f23c952e5..17a6940a74 100644 --- a/crates/kilt-dip-support/src/merkle.rs +++ b/crates/kilt-dip-support/src/merkle.rs @@ -16,10 +16,14 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use did::{did_details::DidPublicKeyDetails, DidVerificationKeyRelationship}; +use did::{ + did_details::{DidPublicKeyDetails, DidVerificationKey}, + DidVerificationKeyRelationship, +}; use frame_support::{traits::ConstU32, DefaultNoBound, RuntimeDebug}; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; +use sp_core::ed25519; use sp_runtime::{BoundedVec, SaturatedConversion}; use sp_std::{fmt::Debug, marker::PhantomData, vec::Vec}; use sp_trie::{verify_trie_proof, LayoutV1}; @@ -31,6 +35,20 @@ pub struct DidMerkleProof { pub revealed: Vec, } +#[cfg(feature = "runtime-benchmarks")] +impl kilt_support::traits::GetWorstCase for DidMerkleProof +where + BlindedValues: kilt_support::traits::GetWorstCase, + Leaf: Default + Clone, +{ + fn worst_case(context: Context) -> Self { + Self { + blinded: BlindedValues::worst_case(context), + revealed: sp_std::vec![Leaf::default(); 64], + } + } +} + #[derive(Clone, Copy, RuntimeDebug, Encode, Decode, PartialEq, Eq, TypeInfo, PartialOrd, Ord, MaxEncodedLen)] pub enum DidKeyRelationship { Encryption, @@ -119,6 +137,25 @@ pub enum RevealedDidMerkleProofLeaf, LinkedAccountMerkleValue), } +#[cfg(feature = "runtime-benchmarks")] +impl Default + for RevealedDidMerkleProofLeaf +where + KeyId: Default, + BlockNumber: Default, +{ + fn default() -> Self { + Self::DidKey( + (KeyId::default(), DidVerificationKeyRelationship::Authentication.into()).into(), + DidPublicKeyDetails { + key: DidVerificationKey::Ed25519(ed25519::Public::from_raw([0u8; 32])).into(), + block_number: BlockNumber::default(), + } + .into(), + ) + } +} + impl RevealedDidMerkleProofLeaf where @@ -259,7 +296,7 @@ impl< LinkedAccountId: Encode + Clone, Web3Name: Encode + Clone, { - #[allow(clippy::result_unit_err)] + #[cfg(not(feature = "runtime-benchmarks"))] #[allow(clippy::type_complexity)] pub(crate) fn verify_dip_merkle_proof( identity_commitment: &Hasher::Out, @@ -338,4 +375,77 @@ impl< linked_accounts, }) } + + #[cfg(feature = "runtime-benchmarks")] + #[allow(clippy::type_complexity)] + pub(crate) fn verify_dip_merkle_proof( + identity_commitment: &Hasher::Out, + proof: DidMerkleProof< + crate::BoundedBlindedValue, + RevealedDidMerkleProofLeaf, + >, + ) -> Result< + RevealedDidMerkleProofLeaves< + KeyId, + AccountId, + BlockNumber, + Web3Name, + LinkedAccountId, + MAX_REVEALED_KEYS_COUNT, + MAX_REVEALED_ACCOUNTS_COUNT, + >, + DidMerkleProofVerifierError, + > { + let proof_leaves = proof + .revealed + .iter() + .map(|leaf| (leaf.encoded_key(), Some(leaf.encoded_value()))) + .collect::, Option>)>>(); + // Ignore result + let _ = verify_trie_proof::, _, _, _>(identity_commitment, &proof.blinded, &proof_leaves); + + #[allow(clippy::type_complexity)] + let (did_keys, web3_name, linked_accounts): ( + BoundedVec, ConstU32>, + Option>, + BoundedVec>, + ) = proof.revealed.iter().try_fold( + ( + BoundedVec::with_bounded_capacity(MAX_REVEALED_KEYS_COUNT.saturated_into()), + None, + BoundedVec::with_bounded_capacity(MAX_REVEALED_ACCOUNTS_COUNT.saturated_into()), + ), + |(mut keys, web3_name, mut linked_accounts), leaf| match leaf { + RevealedDidMerkleProofLeaf::DidKey(key_id, key_value) => { + keys.try_push(RevealedDidKey { + id: key_id.0.clone(), + relationship: key_id.1, + details: key_value.0.clone(), + }) + .map_err(|_| DidMerkleProofVerifierError::TooManyRevealedKeys)?; + Ok::<_, DidMerkleProofVerifierError>((keys, web3_name, linked_accounts)) + } + RevealedDidMerkleProofLeaf::Web3Name(revealed_web3_name, details) => Ok(( + keys, + Some(RevealedWeb3Name { + web3_name: revealed_web3_name.0.clone(), + claimed_at: details.0.clone(), + }), + linked_accounts, + )), + RevealedDidMerkleProofLeaf::LinkedAccount(account_id, _) => { + linked_accounts + .try_push(account_id.0.clone()) + .map_err(|_| DidMerkleProofVerifierError::TooManyRevealedAccounts)?; + Ok::<_, DidMerkleProofVerifierError>((keys, web3_name, linked_accounts)) + } + }, + )?; + + Ok(RevealedDidMerkleProofLeaves { + did_keys, + web3_name, + linked_accounts, + }) + } } diff --git a/crates/kilt-dip-support/src/state_proofs.rs b/crates/kilt-dip-support/src/state_proofs.rs index 0156143ce9..87598b74d9 100644 --- a/crates/kilt-dip-support/src/state_proofs.rs +++ b/crates/kilt-dip-support/src/state_proofs.rs @@ -121,6 +121,7 @@ pub(super) mod relay_chain { RelayChainState::BlockNumber: Copy + Into + TryFrom + HasCompact, RelayChainState::Key: AsRef<[u8]>, { + #[cfg(not(features = "runtime-benchmarks"))] pub fn verify_proof_for_parachain_with_root( para_id: &RelayChainState::ParaId, root: &OutputOf<::Hasher>, @@ -143,6 +144,38 @@ pub(super) mod relay_chain { let mut unwrapped_head = &encoded_head[2..]; Header::decode(&mut unwrapped_head).map_err(|_| ParachainHeadProofVerifierError::HeaderDecode) } + + // Ignores any errors returned by the `read_proof_check` function and returns a + // default Header in case of failure. + #[cfg(features = "runtime-benchmarks")] + pub fn verify_proof_for_parachain_with_root( + para_id: &RelayChainState::ParaId, + root: &OutputOf<::Hasher>, + proof: impl IntoIterator>, + ) -> Result, ParachainHeadProofVerifierError> { + let parachain_storage_key = RelayChainState::parachain_head_storage_key(para_id); + let storage_proof = StorageProof::new(proof); + let revealed_leaves = + read_proof_check::(*root, storage_proof, [¶chain_storage_key].iter()) + .unwrap_or_default(); + let encoded_head = if let Some(Some(encoded_head)) = revealed_leaves.get(parachain_storage_key.as_ref()) { + encoded_head.clone() + } else { + vec![0u8; 3] + }; + let mut unwrapped_head = &encoded_head[2..]; + let header = Header::decode(&mut unwrapped_head).unwrap_or(Header { + number: U256::from(0u64) + .try_into() + .map_err(|_| "Block number should be created from a u64") + .unwrap(), + digest: Default::default(), + extrinsics_root: Default::default(), + parent_hash: Default::default(), + state_root: Default::default(), + }); + Ok(header) + } } // Relies on the `RelayChainState::state_root_for_block` to retrieve the state @@ -154,7 +187,6 @@ pub(super) mod relay_chain { RelayChainState::BlockNumber: Copy + Into + TryFrom + HasCompact, RelayChainState::Key: AsRef<[u8]>, { - #[allow(clippy::result_unit_err)] pub fn verify_proof_for_parachain( para_id: &RelayChainState::ParaId, relay_height: &RelayChainState::BlockNumber, @@ -296,6 +328,7 @@ pub(super) mod parachain { ParaInfo::Commitment: Decode, ParaInfo::Key: AsRef<[u8]>, { + #[cfg(not(features = "runtime-benchmarks"))] #[allow(clippy::result_unit_err)] pub fn verify_proof_for_identifier( identifier: &ParaInfo::Identifier, @@ -321,6 +354,30 @@ pub(super) mod parachain { ParaInfo::Commitment::decode(&mut &encoded_commitment[..]) .map_err(|_| DipIdentityCommitmentProofVerifierError::CommitmentDecode) } + + #[cfg(features = "runtime-benchmarks")] + pub fn verify_proof_for_identifier( + identifier: &ParaInfo::Identifier, + state_root: OutputOf, + proof: impl IntoIterator>, + ) -> Result { + let dip_commitment_storage_key = ParaInfo::dip_subject_storage_key(identifier, 0); + let storage_proof = StorageProof::new(proof); + let revealed_leaves = read_proof_check::( + state_root, + storage_proof, + [&dip_commitment_storage_key].iter(), + ) + .unwrap_or_default(); + let encoded_commitment = + if let Some(Some(encoded_commitment)) = revealed_leaves.get(dip_commitment_storage_key.as_ref()) { + encoded_commitment.clone() + } else { + Vec::default() + }; + let commitment = ParaInfo::Commitment::decode(&mut &encoded_commitment[..]).unwrap_or_default(); + Ok(commitment) + } } #[cfg(test)] diff --git a/crates/kilt-dip-support/src/utils.rs b/crates/kilt-dip-support/src/utils.rs index e382093b93..825826ce74 100644 --- a/crates/kilt-dip-support/src/utils.rs +++ b/crates/kilt-dip-support/src/utils.rs @@ -16,4 +16,64 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org +use parity_scale_codec::{Decode, Encode}; +use scale_info::TypeInfo; +use sp_core::RuntimeDebug; +use sp_std::vec::Vec; + pub type OutputOf = ::Output; + +#[derive(Encode, Decode, PartialEq, Eq, PartialOrd, Ord, RuntimeDebug, TypeInfo, Clone)] +pub struct BoundedBlindedValue(Vec>); + +impl BoundedBlindedValue { + pub fn into_inner(self) -> Vec> { + self.0 + } +} + +impl From for BoundedBlindedValue +where + C: Iterator>, +{ + fn from(value: C) -> Self { + Self(value.into_iter().collect()) + } +} + +impl sp_std::ops::Deref for BoundedBlindedValue { + type Target = Vec>; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl IntoIterator for BoundedBlindedValue { + type IntoIter = > as IntoIterator>::IntoIter; + type Item = > as IntoIterator>::Item; + + fn into_iter(self) -> Self::IntoIter { + self.0.into_iter() + } +} + +#[cfg(feature = "runtime-benchmarks")] +impl kilt_support::traits::GetWorstCase for BoundedBlindedValue +where + T: Default + Clone, +{ + fn worst_case(_context: Context) -> Self { + Self(sp_std::vec![sp_std::vec![T::default(); 128]; 64]) + } +} + +#[cfg(feature = "runtime-benchmarks")] +impl Default for BoundedBlindedValue +where + T: Default + Clone, +{ + fn default() -> Self { + Self(sp_std::vec![sp_std::vec![T::default(); 128]; 64]) + } +} diff --git a/pallets/did/src/did_details.rs b/pallets/did/src/did_details.rs index f7046b6ae4..586f41525c 100644 --- a/pallets/did/src/did_details.rs +++ b/pallets/did/src/did_details.rs @@ -191,6 +191,13 @@ impl From for DidSignature { } } +#[cfg(feature = "runtime-benchmarks")] +impl kilt_support::traits::GetWorstCase for DidSignature { + fn worst_case(_context: Context) -> Self { + Self::Sr25519(sp_core::sr25519::Signature::from_raw([0u8; 64])) + } +} + pub trait DidVerifiableIdentifier { /// Allows a verifiable identifier to verify a signature it produces and /// return the public key diff --git a/support/src/benchmark.rs b/support/src/benchmark.rs index 221a843a32..b194969126 100644 --- a/support/src/benchmark.rs +++ b/support/src/benchmark.rs @@ -14,7 +14,9 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -/// Manly used for the DIP benchmarking. The worst case can be created for the did and submitter. +/// Manly used for the DIP benchmarking. The worst case can be created for the +/// did and submitter. +#[derive(Clone)] pub struct IdentityContext { pub did: DidIdentifier, pub submitter: AccountId, From 8a44925c273644e8948a1b9dfbd3a9d5df364363 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Tue, 5 Dec 2023 15:01:33 +0100 Subject: [PATCH 68/71] Benchmarks working --- crates/kilt-dip-support/src/merkle.rs | 11 ++++---- crates/kilt-dip-support/src/state_proofs.rs | 26 ++++++++++++++----- dip-template/runtimes/dip-consumer/src/dip.rs | 6 +++++ 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/crates/kilt-dip-support/src/merkle.rs b/crates/kilt-dip-support/src/merkle.rs index 17a6940a74..68e30e9917 100644 --- a/crates/kilt-dip-support/src/merkle.rs +++ b/crates/kilt-dip-support/src/merkle.rs @@ -417,12 +417,12 @@ impl< ), |(mut keys, web3_name, mut linked_accounts), leaf| match leaf { RevealedDidMerkleProofLeaf::DidKey(key_id, key_value) => { - keys.try_push(RevealedDidKey { + // Ignore error, just discard anything in excess. + let _ = keys.try_push(RevealedDidKey { id: key_id.0.clone(), relationship: key_id.1, details: key_value.0.clone(), - }) - .map_err(|_| DidMerkleProofVerifierError::TooManyRevealedKeys)?; + }); Ok::<_, DidMerkleProofVerifierError>((keys, web3_name, linked_accounts)) } RevealedDidMerkleProofLeaf::Web3Name(revealed_web3_name, details) => Ok(( @@ -434,9 +434,8 @@ impl< linked_accounts, )), RevealedDidMerkleProofLeaf::LinkedAccount(account_id, _) => { - linked_accounts - .try_push(account_id.0.clone()) - .map_err(|_| DidMerkleProofVerifierError::TooManyRevealedAccounts)?; + // Ignore error, just discard anything in excess. + let _ = linked_accounts.try_push(account_id.0.clone()); Ok::<_, DidMerkleProofVerifierError>((keys, web3_name, linked_accounts)) } }, diff --git a/crates/kilt-dip-support/src/state_proofs.rs b/crates/kilt-dip-support/src/state_proofs.rs index 87598b74d9..019161c27f 100644 --- a/crates/kilt-dip-support/src/state_proofs.rs +++ b/crates/kilt-dip-support/src/state_proofs.rs @@ -121,7 +121,7 @@ pub(super) mod relay_chain { RelayChainState::BlockNumber: Copy + Into + TryFrom + HasCompact, RelayChainState::Key: AsRef<[u8]>, { - #[cfg(not(features = "runtime-benchmarks"))] + #[cfg(not(feature = "runtime-benchmarks"))] pub fn verify_proof_for_parachain_with_root( para_id: &RelayChainState::ParaId, root: &OutputOf<::Hasher>, @@ -147,7 +147,7 @@ pub(super) mod relay_chain { // Ignores any errors returned by the `read_proof_check` function and returns a // default Header in case of failure. - #[cfg(features = "runtime-benchmarks")] + #[cfg(feature = "runtime-benchmarks")] pub fn verify_proof_for_parachain_with_root( para_id: &RelayChainState::ParaId, root: &OutputOf<::Hasher>, @@ -161,7 +161,7 @@ pub(super) mod relay_chain { let encoded_head = if let Some(Some(encoded_head)) = revealed_leaves.get(parachain_storage_key.as_ref()) { encoded_head.clone() } else { - vec![0u8; 3] + sp_std::vec![0u8; 3] }; let mut unwrapped_head = &encoded_head[2..]; let header = Header::decode(&mut unwrapped_head).unwrap_or(Header { @@ -187,6 +187,7 @@ pub(super) mod relay_chain { RelayChainState::BlockNumber: Copy + Into + TryFrom + HasCompact, RelayChainState::Key: AsRef<[u8]>, { + #[cfg(not(feature = "runtime-benchmarks"))] pub fn verify_proof_for_parachain( para_id: &RelayChainState::ParaId, relay_height: &RelayChainState::BlockNumber, @@ -196,6 +197,16 @@ pub(super) mod relay_chain { .ok_or(ParachainHeadProofVerifierError::RelaychainStateRootNotFound)?; Self::verify_proof_for_parachain_with_root(para_id, &relay_state_root, proof) } + + #[cfg(feature = "runtime-benchmarks")] + pub fn verify_proof_for_parachain( + para_id: &RelayChainState::ParaId, + relay_height: &RelayChainState::BlockNumber, + proof: impl IntoIterator>, + ) -> Result, ParachainHeadProofVerifierError> { + let relay_state_root = RelayChainState::state_root_for_block(relay_height).unwrap_or_default(); + Self::verify_proof_for_parachain_with_root(para_id, &relay_state_root, proof) + } } pub struct RelayStateRootsViaRelayStorePallet(PhantomData); @@ -328,7 +339,7 @@ pub(super) mod parachain { ParaInfo::Commitment: Decode, ParaInfo::Key: AsRef<[u8]>, { - #[cfg(not(features = "runtime-benchmarks"))] + #[cfg(not(feature = "runtime-benchmarks"))] #[allow(clippy::result_unit_err)] pub fn verify_proof_for_identifier( identifier: &ParaInfo::Identifier, @@ -355,12 +366,15 @@ pub(super) mod parachain { .map_err(|_| DipIdentityCommitmentProofVerifierError::CommitmentDecode) } - #[cfg(features = "runtime-benchmarks")] + #[cfg(feature = "runtime-benchmarks")] pub fn verify_proof_for_identifier( identifier: &ParaInfo::Identifier, state_root: OutputOf, proof: impl IntoIterator>, - ) -> Result { + ) -> Result + where + ParaInfo::Commitment: Default, + { let dip_commitment_storage_key = ParaInfo::dip_subject_storage_key(identifier, 0); let storage_proof = StorageProof::new(proof); let revealed_leaves = read_proof_check::( diff --git a/dip-template/runtimes/dip-consumer/src/dip.rs b/dip-template/runtimes/dip-consumer/src/dip.rs index 2362c6f2b1..1ef3ca1158 100644 --- a/dip-template/runtimes/dip-consumer/src/dip.rs +++ b/dip-template/runtimes/dip-consumer/src/dip.rs @@ -55,6 +55,7 @@ impl pallet_dip_consumer::Config for Runtime { pub struct PreliminaryDipOriginFilter; impl Contains for PreliminaryDipOriginFilter { + #[cfg(not(feature = "runtime-benchmarks"))] fn contains(t: &RuntimeCall) -> bool { matches!( t, @@ -64,6 +65,11 @@ impl Contains for PreliminaryDipOriginFilter { | RuntimeCall::Utility(pallet_utility::Call::force_batch { .. }) ) } + + #[cfg(feature = "runtime-benchmarks")] + fn contains(_t: &RuntimeCall) -> bool { + true + } } fn derive_verification_key_relationship(call: &RuntimeCall) -> Option { From 1ccc2fe09ae26d049a66f86077d3e584e26411a5 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Tue, 5 Dec 2023 17:43:01 +0100 Subject: [PATCH 69/71] Compiling --- dip-template/runtimes/dip-provider/src/dip.rs | 53 ++++++++++++++++--- .../src/benchmarking.rs | 24 ++++----- pallets/pallet-deposit-storage/src/lib.rs | 4 +- pallets/pallet-deposit-storage/src/mock.rs | 2 + pallets/pallet-deposit-storage/src/traits.rs | 36 +++++++++++++ pallets/pallet-migration/Cargo.toml | 11 ++-- 6 files changed, 101 insertions(+), 29 deletions(-) diff --git a/dip-template/runtimes/dip-provider/src/dip.rs b/dip-template/runtimes/dip-provider/src/dip.rs index 1982854081..da759af441 100644 --- a/dip-template/runtimes/dip-provider/src/dip.rs +++ b/dip-template/runtimes/dip-provider/src/dip.rs @@ -62,7 +62,8 @@ pub mod deposit { use frame_support::traits::Get; use pallet_deposit_storage::{ - traits::DepositStorageHooks, DepositEntryOf, DepositKeyOf, FixedDepositCollectorViaDepositsPallet, + traits::{BenchmarkHooks, DepositStorageHooks}, + DepositEntryOf, DepositKeyOf, FixedDepositCollectorViaDepositsPallet, }; use parity_scale_codec::MaxEncodedLen; use sp_core::{ConstU128, RuntimeDebug}; @@ -72,13 +73,6 @@ pub mod deposit { DipProvider, } - #[cfg(feature = "runtime-benchmarks")] - impl Default for DepositNamespaces { - fn default() -> Self { - Self::DipProvider - } - } - pub struct DipProviderDepositNamespace; impl Get for DipProviderDepositNamespace { @@ -132,6 +126,47 @@ pub mod deposit { Ok(()) } } + + #[cfg(feature = "runtime-benchmarks")] + pub struct PalletDepositStorageBenchmarkHooks; + + #[cfg(feature = "runtime-benchmarks")] + impl BenchmarkHooks for PalletDepositStorageBenchmarkHooks { + fn pre_reclaim_deposit() -> ( + ::AccountId, + ::Namespace, + sp_runtime::BoundedVec::MaxKeyLength>, + ) { + let submitter = AccountId::from([100u8; 32]); + let namespace = DepositNamespaces::DipProvider; + let did_identifier = DidIdentifier::from([200u8; 32]); + let commitment_version = 0u16; + let key: DepositKeyOf = (did_identifier.clone(), 0) + .encode() + .try_into() + .expect("Should not fail to create a key for a DIP commitment."); + + pallet_dip_provider::IdentityCommitments::::insert( + &did_identifier, + commitment_version, + ::Hash::default(), + ); + + assert!( + pallet_dip_provider::IdentityCommitments::::get(did_identifier, commitment_version).is_some() + ); + + (submitter, namespace, key) + } + + fn post_reclaim_deposit() { + let did_identifier = DidIdentifier::from([200u8; 32]); + let commitment_version = 0u16; + assert!( + pallet_dip_provider::IdentityCommitments::::get(did_identifier, commitment_version).is_none() + ); + } + } } impl pallet_deposit_storage::Config for Runtime { @@ -143,6 +178,8 @@ impl pallet_deposit_storage::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeHoldReason = RuntimeHoldReason; type WeightInfo = (); + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHooks = deposit::PalletDepositStorageBenchmarkHooks; } impl pallet_dip_provider::Config for Runtime { diff --git a/pallets/pallet-deposit-storage/src/benchmarking.rs b/pallets/pallet-deposit-storage/src/benchmarking.rs index 22bbe81953..eb69d6a6fd 100644 --- a/pallets/pallet-deposit-storage/src/benchmarking.rs +++ b/pallets/pallet-deposit-storage/src/benchmarking.rs @@ -16,22 +16,19 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use crate::{Call, Config, DepositEntryOf, DepositKeyOf, Deposits, HoldReason, Pallet}; use frame_benchmarking::v2::*; -use frame_support::traits::fungible::Mutate; -use frame_system::RawOrigin; -use kilt_support::{traits::Instanciate, Deposit}; -use sp_runtime::SaturatedConversion; #[benchmarks( where - T::AccountId: Instanciate, T: Config + pallet_balances::Config, - T::Namespace: Default )] mod benchmarks { + use frame_support::traits::fungible::Mutate; + use frame_system::RawOrigin; + use kilt_support::Deposit; + use sp_runtime::SaturatedConversion; - use sp_runtime::BoundedVec; + use crate::{traits::BenchmarkHooks, Call, Config, DepositEntryOf, Deposits, HoldReason, Pallet}; use super::*; @@ -39,13 +36,7 @@ mod benchmarks { #[benchmark] fn reclaim_deposit() { - let submitter = T::AccountId::new(1); - - let origin = RawOrigin::Signed(submitter.clone()); - - let namespace: ::Namespace = Default::default(); - - let key: DepositKeyOf = BoundedVec::try_from(vec![1]).expect("Creation of key should not fail."); + let (submitter, namespace, key) = T::BenchmarkHooks::pre_reclaim_deposit(); assert!(Deposits::::get(&namespace, &key).is_none()); @@ -68,6 +59,7 @@ mod benchmarks { assert!(Deposits::::get(&namespace, &key).is_some()); + let origin = RawOrigin::Signed(submitter); let cloned_namespace = namespace.clone(); let cloned_key = key.clone(); @@ -75,6 +67,8 @@ mod benchmarks { Pallet::::reclaim_deposit(origin, cloned_namespace, cloned_key); assert!(Deposits::::get(&namespace, &key).is_none()); + + T::BenchmarkHooks::post_reclaim_deposit(); } #[cfg(test)] diff --git a/pallets/pallet-deposit-storage/src/lib.rs b/pallets/pallet-deposit-storage/src/lib.rs index 03b8b837af..bfc210f162 100644 --- a/pallets/pallet-deposit-storage/src/lib.rs +++ b/pallets/pallet-deposit-storage/src/lib.rs @@ -38,7 +38,7 @@ pub mod pallet { use crate::{ default_weights::WeightInfo, deposit::{free_deposit, reserve_deposit, DepositEntry}, - traits::DepositStorageHooks, + traits::{BenchmarkHooks, DepositStorageHooks}, }; use super::*; @@ -75,6 +75,8 @@ pub mod pallet { type Namespace: Parameter + MaxEncodedLen; type RuntimeEvent: From> + IsType<::RuntimeEvent>; type RuntimeHoldReason: From + Clone + PartialEq + Debug + FullCodec + MaxEncodedLen + TypeInfo; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHooks: BenchmarkHooks; type WeightInfo: WeightInfo; } diff --git a/pallets/pallet-deposit-storage/src/mock.rs b/pallets/pallet-deposit-storage/src/mock.rs index 7662457310..f53c2ae312 100644 --- a/pallets/pallet-deposit-storage/src/mock.rs +++ b/pallets/pallet-deposit-storage/src/mock.rs @@ -106,6 +106,8 @@ impl crate::Config for TestRuntime { type RuntimeHoldReason = RuntimeHoldReason; type MaxKeyLength = ConstU32<256>; type Namespace = DepositNamespaces; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHooks = (); type WeightInfo = (); } diff --git a/pallets/pallet-deposit-storage/src/traits.rs b/pallets/pallet-deposit-storage/src/traits.rs index f514eee108..b4e179937a 100644 --- a/pallets/pallet-deposit-storage/src/traits.rs +++ b/pallets/pallet-deposit-storage/src/traits.rs @@ -47,3 +47,39 @@ where Ok(()) } } + +// Could be expanded to include traits to set up stuff before all benchmarks, +// and before each benchmark case specifically. +#[cfg(feature = "runtime-benchmarks")] +pub trait BenchmarkHooks +where + Runtime: Config, +{ + fn pre_reclaim_deposit() -> ( + Runtime::AccountId, + Runtime::Namespace, + sp_runtime::BoundedVec, + ); + fn post_reclaim_deposit(); +} + +#[cfg(feature = "runtime-benchmarks")] +impl BenchmarkHooks for () +where + Runtime: Config, + Runtime::AccountId: From<[u8; 32]>, + Runtime::Namespace: Default, +{ + fn pre_reclaim_deposit() -> ( + Runtime::AccountId, + Runtime::Namespace, + sp_runtime::BoundedVec, + ) { + ( + Runtime::AccountId::from([100u8; 32]), + Runtime::Namespace::default(), + sp_runtime::BoundedVec::default(), + ) + } + fn post_reclaim_deposit() {} +} diff --git a/pallets/pallet-migration/Cargo.toml b/pallets/pallet-migration/Cargo.toml index 378b7baaa8..905b0d4a7a 100644 --- a/pallets/pallet-migration/Cargo.toml +++ b/pallets/pallet-migration/Cargo.toml @@ -20,12 +20,13 @@ frame-benchmarking = {workspace = true, features = ["std"]} pallet-aura = {workspace = true, features = ["std"]} pallet-timestamp = {workspace = true, features = ["std"]} sp-consensus-aura = {workspace = true, features = ["std"]} +sp-keystore = {workspace = true, features = ["std"]} pallet-session = {workspace = true, features = ["std"]} attestation = {workspace = true, features = ["mock"]} ctype = {workspace = true, features = ["mock"]} -delegation = {workspace = true, features = ["mock"]} -did = {workspace = true, features = ["mock"]} -public-credentials = {workspace = true, features = ["mock"]} +delegation = {workspace = true, features = ["mock"]} +did = {workspace = true, features = ["mock"]} +public-credentials = {workspace = true, features = ["mock"]} [dependencies] # Internal dependencies @@ -36,7 +37,7 @@ pallet-did-lookup.workspace = true pallet-web3-names.workspace = true parachain-staking.workspace = true public-credentials.workspace = true -runtime-common.workspace = true +runtime-common.workspace = true kilt-support.workspace = true ctype = {workspace = true, optional = true} @@ -69,7 +70,7 @@ runtime-benchmarks = [ "pallet-web3-names/runtime-benchmarks", "parachain-staking/runtime-benchmarks", "public-credentials/runtime-benchmarks", - "runtime-common/runtime-benchmarks", + "runtime-common/runtime-benchmarks", "ctype/runtime-benchmarks", "kilt-support/runtime-benchmarks", "pallet-balances/runtime-benchmarks", From 20b0d164a75309e8bb17d6240563edb298d64acc Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Wed, 6 Dec 2023 11:19:36 +0100 Subject: [PATCH 70/71] Weights --- Cargo.lock | 4 +- dip-template/runtimes/dip-consumer/Cargo.toml | 4 +- dip-template/runtimes/dip-consumer/src/dip.rs | 6 +- dip-template/runtimes/dip-consumer/src/lib.rs | 13 +- .../dip-consumer/src/weights/frame_system.rs | 193 +++ .../runtimes/dip-consumer/src/weights/mod.rs | 21 + .../src/weights/pallet_dip_consumer.rs | 83 ++ .../src/weights/pallet_relay_store.rs | 83 ++ dip-template/runtimes/dip-provider/Cargo.toml | 4 +- dip-template/runtimes/dip-provider/src/dip.rs | 6 +- dip-template/runtimes/dip-provider/src/lib.rs | 19 +- .../runtimes/dip-provider/src/weights/did.rs | 1217 +++++++++++++++++ .../dip-provider/src/weights/frame_system.rs | 193 +++ .../runtimes/dip-provider/src/weights/mod.rs | 24 + .../src/weights/pallet_deposit_storage.rs | 85 ++ .../src/weights/pallet_did_lookup.rs | 321 +++++ .../src/weights/pallet_dip_provider.rs | 125 ++ .../src/weights/pallet_web3_names.rs | 265 ++++ pallets/pallet-deposit-storage/src/lib.rs | 7 +- pallets/pallet-dip-consumer/src/lib.rs | 2 +- pallets/pallet-dip-provider/src/lib.rs | 1 + pallets/pallet-relay-store/src/lib.rs | 2 +- 22 files changed, 2636 insertions(+), 42 deletions(-) create mode 100644 dip-template/runtimes/dip-consumer/src/weights/frame_system.rs create mode 100644 dip-template/runtimes/dip-consumer/src/weights/mod.rs create mode 100644 dip-template/runtimes/dip-consumer/src/weights/pallet_dip_consumer.rs create mode 100644 dip-template/runtimes/dip-consumer/src/weights/pallet_relay_store.rs create mode 100644 dip-template/runtimes/dip-provider/src/weights/did.rs create mode 100644 dip-template/runtimes/dip-provider/src/weights/frame_system.rs create mode 100644 dip-template/runtimes/dip-provider/src/weights/mod.rs create mode 100644 dip-template/runtimes/dip-provider/src/weights/pallet_deposit_storage.rs create mode 100644 dip-template/runtimes/dip-provider/src/weights/pallet_did_lookup.rs create mode 100644 dip-template/runtimes/dip-provider/src/weights/pallet_dip_provider.rs create mode 100644 dip-template/runtimes/dip-provider/src/weights/pallet_web3_names.rs diff --git a/Cargo.lock b/Cargo.lock index bf8c5c35c2..741ea0e370 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2433,7 +2433,6 @@ dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", - "cumulus-pallet-session-benchmarking", "cumulus-primitives-core", "cumulus-primitives-timestamp", "cumulus-primitives-utility", @@ -2477,6 +2476,7 @@ dependencies = [ "sp-std", "sp-transaction-pool", "sp-version", + "sp-weights", "substrate-wasm-builder", ] @@ -2539,7 +2539,6 @@ dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", - "cumulus-pallet-session-benchmarking", "cumulus-primitives-core", "cumulus-primitives-timestamp", "cumulus-primitives-utility", @@ -2585,6 +2584,7 @@ dependencies = [ "sp-std", "sp-transaction-pool", "sp-version", + "sp-weights", "substrate-wasm-builder", ] diff --git a/dip-template/runtimes/dip-consumer/Cargo.toml b/dip-template/runtimes/dip-consumer/Cargo.toml index 132a2cfc69..ca55d7dcad 100644 --- a/dip-template/runtimes/dip-consumer/Cargo.toml +++ b/dip-template/runtimes/dip-consumer/Cargo.toml @@ -53,6 +53,7 @@ sp-session.workspace = true sp-std.workspace = true sp-transaction-pool.workspace = true sp-version.workspace = true +sp-weights.workspace = true # Cumulus cumulus-pallet-aura-ext.workspace = true @@ -65,7 +66,6 @@ pallet-collator-selection.workspace = true parachain-info.workspace = true # Benchmarks -cumulus-pallet-session-benchmarking = {workspace = true, optional = true} frame-benchmarking = {workspace = true, optional = true} frame-system-benchmarking = {workspace = true, optional = true} hex-literal = {workspace = true, optional = true} @@ -110,6 +110,7 @@ std = [ "sp-std/std", "sp-transaction-pool/std", "sp-version/std", + "sp-weights/std", "cumulus-pallet-aura-ext/std", "cumulus-pallet-dmp-queue/std", "cumulus-pallet-parachain-system/std", @@ -134,7 +135,6 @@ runtime-benchmarks = [ "pallet-timestamp/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "sp-runtime/runtime-benchmarks", - "cumulus-pallet-session-benchmarking/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", "frame-system-benchmarking/runtime-benchmarks", "hex-literal" diff --git a/dip-template/runtimes/dip-consumer/src/dip.rs b/dip-template/runtimes/dip-consumer/src/dip.rs index 1ef3ca1158..03ef8efd18 100644 --- a/dip-template/runtimes/dip-consumer/src/dip.rs +++ b/dip-template/runtimes/dip-consumer/src/dip.rs @@ -27,7 +27,7 @@ use pallet_dip_consumer::traits::IdentityProofVerifier; use sp_core::ConstU32; use sp_runtime::traits::BlakeTwo256; -use crate::{AccountId, DidIdentifier, Runtime, RuntimeCall, RuntimeOrigin}; +use crate::{weights, AccountId, DidIdentifier, Runtime, RuntimeCall, RuntimeOrigin}; pub type MerkleProofVerifierOutput = >::VerificationResult; pub type ProofVerifier = KiltVersionedSiblingProviderVerifier< @@ -49,7 +49,7 @@ impl pallet_dip_consumer::Config for Runtime { type ProofVerifier = ProofVerifier; type RuntimeCall = RuntimeCall; type RuntimeOrigin = RuntimeOrigin; - type WeightInfo = (); + type WeightInfo = weights::pallet_dip_consumer::WeightInfo; } pub struct PreliminaryDipOriginFilter; @@ -130,5 +130,5 @@ impl DipCallOriginFilter for DipCallFilter { impl pallet_relay_store::Config for Runtime { type MaxRelayBlocksStored = ConstU32<100>; - type WeightInfo = (); + type WeightInfo = weights::pallet_relay_store::WeightInfo; } diff --git a/dip-template/runtimes/dip-consumer/src/lib.rs b/dip-template/runtimes/dip-consumer/src/lib.rs index d6b9ca53bd..daf21c15fa 100644 --- a/dip-template/runtimes/dip-consumer/src/lib.rs +++ b/dip-template/runtimes/dip-consumer/src/lib.rs @@ -65,6 +65,7 @@ use sp_version::RuntimeVersion; mod dip; mod origin_adapter; +mod weights; pub use crate::{dip::*, origin_adapter::*}; #[cfg(any(feature = "std", test))] @@ -234,7 +235,7 @@ impl frame_system::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; type SS58Prefix = ConstU16; - type SystemWeightInfo = (); + type SystemWeightInfo = weights::frame_system::WeightInfo; type Version = Version; } @@ -362,12 +363,6 @@ impl pallet_postit::Config for Runtime { mod benches { frame_benchmarking::define_benchmarks!( [frame_system, SystemBench::] - [pallet_timestamp, Timestamp] - [pallet_sudo, Sudo] - [pallet_utility, Utility] - [pallet_balances, Balances] - [pallet_collator_selection, CollatorSelection] - [pallet_session, SessionBench::] [pallet_dip_consumer, DipConsumer] [pallet_relay_store, RelayStore] ); @@ -526,7 +521,6 @@ impl_runtime_apis! { use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; - use cumulus_pallet_session_benchmarking::Pallet as SessionBench; let mut list = Vec::::new(); list_benchmarks!(list, extra); @@ -552,9 +546,6 @@ impl_runtime_apis! { } } - use cumulus_pallet_session_benchmarking::Pallet as SessionBench; - impl cumulus_pallet_session_benchmarking::Config for Runtime {} - use frame_support::traits::WhitelistedStorageKeys; let whitelist = AllPalletsWithSystem::whitelisted_storage_keys(); diff --git a/dip-template/runtimes/dip-consumer/src/weights/frame_system.rs b/dip-template/runtimes/dip-consumer/src/weights/frame_system.rs new file mode 100644 index 0000000000..3c04d0f214 --- /dev/null +++ b/dip-template/runtimes/dip-consumer/src/weights/frame_system.rs @@ -0,0 +1,193 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `frame_system` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/release/dip-consumer-node-template +// benchmark +// pallet +// --template=.maintain/runtime-weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --pallet=frame-system +// --extrinsic=* +// --output=./dip-template/runtimes/dip-consumer/src/weights/frame_system.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `frame_system`. +pub struct WeightInfo(PhantomData); +impl frame_system::WeightInfo for WeightInfo { + /// The range of component `b` is `[0, 3932160]`. + fn remark(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_378_000 picoseconds. + Weight::from_parts(90_413_067, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 3 + .saturating_add(Weight::from_parts(196, 0).saturating_mul(b.into())) + } + /// The range of component `b` is `[0, 3932160]`. + fn remark_with_event(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_818_000 picoseconds. + Weight::from_parts(4_882_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 15 + .saturating_add(Weight::from_parts(1_874, 0).saturating_mul(b.into())) + } + /// Storage: `System::Digest` (r:1 w:1) + /// Proof: `System::Digest` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: UNKNOWN KEY `0x3a686561707061676573` (r:0 w:1) + /// Proof: UNKNOWN KEY `0x3a686561707061676573` (r:0 w:1) + fn set_heap_pages() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `1485` + // Minimum execution time: 5_882_000 picoseconds. + Weight::from_parts(6_631_000, 0) + .saturating_add(Weight::from_parts(0, 1485)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `ParachainSystem::ValidationData` (r:1 w:0) + /// Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::UpgradeRestrictionSignal` (r:1 w:0) + /// Proof: `ParachainSystem::UpgradeRestrictionSignal` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::PendingValidationCode` (r:1 w:1) + /// Proof: `ParachainSystem::PendingValidationCode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::NewValidationCode` (r:0 w:1) + /// Proof: `ParachainSystem::NewValidationCode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::DidSetValidationCode` (r:0 w:1) + /// Proof: `ParachainSystem::DidSetValidationCode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn set_code() -> Weight { + // Proof Size summary in bytes: + // Measured: `119` + // Estimated: `1604` + // Minimum execution time: 141_893_625_000 picoseconds. + Weight::from_parts(162_618_687_000, 0) + .saturating_add(Weight::from_parts(0, 1604)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `i` is `[0, 1000]`. + fn set_storage(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 2_512_000 picoseconds. + Weight::from_parts(2_972_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 7_153 + .saturating_add(Weight::from_parts(1_100_784, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) + } + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `i` is `[0, 1000]`. + fn kill_storage(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_526_000 picoseconds. + Weight::from_parts(67_203_020, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 8_216 + .saturating_add(Weight::from_parts(391_130, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) + } + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `p` is `[0, 1000]`. + fn kill_prefix(p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `73 + p * (69 ±0)` + // Estimated: `66 + p * (70 ±0)` + // Minimum execution time: 2_821_000 picoseconds. + Weight::from_parts(9_760_367, 0) + .saturating_add(Weight::from_parts(0, 66)) + // Standard Error: 14_170 + .saturating_add(Weight::from_parts(886_262, 0).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) + .saturating_add(Weight::from_parts(0, 70).saturating_mul(p.into())) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_set_heap_pages() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 1485 + ); + } + #[test] + fn test_set_code() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 1604 + ); + } + #[test] + fn test_kill_prefix() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 66 + ); + } +} diff --git a/dip-template/runtimes/dip-consumer/src/weights/mod.rs b/dip-template/runtimes/dip-consumer/src/weights/mod.rs new file mode 100644 index 0000000000..a0fbf6b5fa --- /dev/null +++ b/dip-template/runtimes/dip-consumer/src/weights/mod.rs @@ -0,0 +1,21 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +pub mod frame_system; +pub mod pallet_dip_consumer; +pub mod pallet_relay_store; diff --git a/dip-template/runtimes/dip-consumer/src/weights/pallet_dip_consumer.rs b/dip-template/runtimes/dip-consumer/src/weights/pallet_dip_consumer.rs new file mode 100644 index 0000000000..625c63b1c0 --- /dev/null +++ b/dip-template/runtimes/dip-consumer/src/weights/pallet_dip_consumer.rs @@ -0,0 +1,83 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `pallet_dip_consumer` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/release/dip-consumer-node-template +// benchmark +// pallet +// --template=.maintain/runtime-weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --pallet=pallet-dip-consumer +// --extrinsic=* +// --output=./dip-template/runtimes/dip-consumer/src/weights/pallet_dip_consumer.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_dip_consumer`. +pub struct WeightInfo(PhantomData); +impl pallet_dip_consumer::WeightInfo for WeightInfo { + /// Storage: `DipConsumer::IdentityEntries` (r:1 w:1) + /// Proof: `DipConsumer::IdentityEntries` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`) + /// Storage: `RelayStore::LatestRelayHeads` (r:1 w:0) + /// Proof: `RelayStore::LatestRelayHeads` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + /// Storage: `System::BlockHash` (r:1 w:0) + /// Proof: `System::BlockHash` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + fn dispatch_as() -> Weight { + // Proof Size summary in bytes: + // Measured: `66` + // Estimated: `3521` + // Minimum execution time: 88_110_000 picoseconds. + Weight::from_parts(89_742_000, 0) + .saturating_add(Weight::from_parts(0, 3521)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_dispatch_as() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 3521 + ); + } +} diff --git a/dip-template/runtimes/dip-consumer/src/weights/pallet_relay_store.rs b/dip-template/runtimes/dip-consumer/src/weights/pallet_relay_store.rs new file mode 100644 index 0000000000..ae83009997 --- /dev/null +++ b/dip-template/runtimes/dip-consumer/src/weights/pallet_relay_store.rs @@ -0,0 +1,83 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `pallet_relay_store` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/release/dip-consumer-node-template +// benchmark +// pallet +// --template=.maintain/runtime-weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --pallet=pallet-relay-store +// --extrinsic=* +// --output=./dip-template/runtimes/dip-consumer/src/weights/pallet_relay_store.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_relay_store`. +pub struct WeightInfo(PhantomData); +impl pallet_relay_store::WeightInfo for WeightInfo { + /// Storage: `ParachainSystem::ValidationData` (r:1 w:0) + /// Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `RelayStore::LatestBlockHeights` (r:1 w:1) + /// Proof: `RelayStore::LatestBlockHeights` (`max_values`: Some(1), `max_size`: Some(402), added: 897, mode: `MaxEncodedLen`) + /// Storage: `RelayStore::LatestRelayHeads` (r:0 w:2) + /// Proof: `RelayStore::LatestRelayHeads` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`) + fn on_finalize() -> Weight { + // Proof Size summary in bytes: + // Measured: `540` + // Estimated: `2025` + // Minimum execution time: 9_067_000 picoseconds. + Weight::from_parts(9_467_000, 0) + .saturating_add(Weight::from_parts(0, 2025)) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().writes(3)) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_on_finalize() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 2025 + ); + } +} diff --git a/dip-template/runtimes/dip-provider/Cargo.toml b/dip-template/runtimes/dip-provider/Cargo.toml index 458fe47c7a..d1f7c7bcde 100644 --- a/dip-template/runtimes/dip-provider/Cargo.toml +++ b/dip-template/runtimes/dip-provider/Cargo.toml @@ -55,6 +55,7 @@ sp-session.workspace = true sp-std.workspace = true sp-transaction-pool.workspace = true sp-version.workspace = true +sp-weights.workspace = true # Cumulus cumulus-pallet-aura-ext.workspace = true @@ -67,7 +68,6 @@ pallet-collator-selection.workspace = true parachain-info.workspace = true # Benchmarks -cumulus-pallet-session-benchmarking = {workspace = true, optional = true} frame-benchmarking = {workspace = true, optional = true} frame-system-benchmarking = {workspace = true, optional = true} hex-literal = {workspace = true, optional = true} @@ -114,6 +114,7 @@ std = [ "sp-std/std", "sp-transaction-pool/std", "sp-version/std", + "sp-weights/std", "cumulus-pallet-aura-ext/std", "cumulus-pallet-dmp-queue/std", "cumulus-pallet-parachain-system/std", @@ -140,7 +141,6 @@ runtime-benchmarks = [ "pallet-timestamp/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "sp-runtime/runtime-benchmarks", - "cumulus-pallet-session-benchmarking/runtime-benchmarks", "frame-benchmarking/runtime-benchmarks", "frame-system-benchmarking/runtime-benchmarks", "hex-literal" diff --git a/dip-template/runtimes/dip-provider/src/dip.rs b/dip-template/runtimes/dip-provider/src/dip.rs index da759af441..e1a27480d0 100644 --- a/dip-template/runtimes/dip-provider/src/dip.rs +++ b/dip-template/runtimes/dip-provider/src/dip.rs @@ -31,7 +31,7 @@ use sp_std::vec::Vec; use crate::{ deposit::{DepositHooks, DepositNamespaces}, - AccountId, Balances, DidIdentifier, Runtime, RuntimeEvent, RuntimeHoldReason, + weights, AccountId, Balances, DidIdentifier, Runtime, RuntimeEvent, RuntimeHoldReason, }; const MAX_LINKED_ACCOUNTS: u32 = 20; @@ -177,7 +177,7 @@ impl pallet_deposit_storage::Config for Runtime { type Namespace = DepositNamespaces; type RuntimeEvent = RuntimeEvent; type RuntimeHoldReason = RuntimeHoldReason; - type WeightInfo = (); + type WeightInfo = weights::pallet_deposit_storage::WeightInfo; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHooks = deposit::PalletDepositStorageBenchmarkHooks; } @@ -190,5 +190,5 @@ impl pallet_dip_provider::Config for Runtime { type IdentityProvider = LinkedDidInfoProvider; type ProviderHooks = deposit::DepositCollectorHooks; type RuntimeEvent = RuntimeEvent; - type WeightInfo = (); + type WeightInfo = weights::pallet_dip_provider::WeightInfo; } diff --git a/dip-template/runtimes/dip-provider/src/lib.rs b/dip-template/runtimes/dip-provider/src/lib.rs index c701a9976c..90e96c9a94 100644 --- a/dip-template/runtimes/dip-provider/src/lib.rs +++ b/dip-template/runtimes/dip-provider/src/lib.rs @@ -76,6 +76,7 @@ pub use sp_runtime::BuildStorage; use sp_version::NativeVersion; mod dip; +mod weights; pub use crate::dip::*; pub type AccountId = AccountId32; @@ -240,7 +241,7 @@ impl frame_system::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeOrigin = RuntimeOrigin; type SS58Prefix = ConstU16; - type SystemWeightInfo = (); + type SystemWeightInfo = weights::frame_system::WeightInfo; type Version = Version; } @@ -401,7 +402,7 @@ impl did::Config for Runtime { type RuntimeHoldReason = RuntimeHoldReason; type RuntimeOrigin = RuntimeOrigin; type ServiceEndpointDeposit = ConstU128; - type WeightInfo = (); + type WeightInfo = weights::did::WeightInfo; } impl pallet_did_lookup::Config for Runtime { @@ -413,7 +414,7 @@ impl pallet_did_lookup::Config for Runtime { type OriginSuccess = DidRawOrigin; type RuntimeEvent = RuntimeEvent; type RuntimeHoldReason = RuntimeHoldReason; - type WeightInfo = (); + type WeightInfo = weights::pallet_did_lookup::WeightInfo; } pub type Web3Name = AsciiWeb3Name; @@ -431,19 +432,13 @@ impl pallet_web3_names::Config for Runtime { type RuntimeHoldReason = RuntimeHoldReason; type Web3Name = Web3Name; type Web3NameOwner = DidIdentifier; - type WeightInfo = (); + type WeightInfo = weights::pallet_web3_names::WeightInfo; } #[cfg(feature = "runtime-benchmarks")] mod benches { frame_benchmarking::define_benchmarks!( [frame_system, SystemBench::] - [pallet_timestamp, Timestamp] - [pallet_sudo, Sudo] - [pallet_utility, Utility] - [pallet_balances, Balances] - [pallet_collator_selection, CollatorSelection] - [pallet_session, SessionBench::] [did, Did] [pallet_did_lookup, DidLookup] [pallet_web3_names, Web3Names] @@ -706,7 +701,6 @@ impl_runtime_apis! { use frame_benchmarking::{Benchmarking, BenchmarkList}; use frame_support::traits::StorageInfoTrait; use frame_system_benchmarking::Pallet as SystemBench; - use cumulus_pallet_session_benchmarking::Pallet as SessionBench; let mut list = Vec::::new(); list_benchmarks!(list, extra); @@ -732,9 +726,6 @@ impl_runtime_apis! { } } - use cumulus_pallet_session_benchmarking::Pallet as SessionBench; - impl cumulus_pallet_session_benchmarking::Config for Runtime {} - use frame_support::traits::WhitelistedStorageKeys; let whitelist = AllPalletsWithSystem::whitelisted_storage_keys(); diff --git a/dip-template/runtimes/dip-provider/src/weights/did.rs b/dip-template/runtimes/dip-provider/src/weights/did.rs new file mode 100644 index 0000000000..7557791b93 --- /dev/null +++ b/dip-template/runtimes/dip-provider/src/weights/did.rs @@ -0,0 +1,1217 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `did` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/release/dip-provider-node-template +// benchmark +// pallet +// --template=.maintain/runtime-weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --pallet=did +// --extrinsic=* +// --output=./dip-template/runtimes/dip-provider/src/weights/did.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `did`. +pub struct WeightInfo(PhantomData); +impl did::WeightInfo for WeightInfo { + /// Storage: Did DidBlacklist (r:1 w:0) + /// Proof: Did DidBlacklist (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:0 w:1) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: Did ServiceEndpoints (r:0 w:25) + /// Proof: Did ServiceEndpoints (max_values: None, max_size: Some(615), added: 3090, mode: MaxEncodedLen) + /// The range of component `n` is `[1, 10]`. + /// The range of component `c` is `[1, 25]`. + fn create_ed25519_keys(n: u32, c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1131` + // Estimated: `6204` + // Minimum execution time: 179_404_000 picoseconds. + Weight::from_parts(170_230_985, 0) + .saturating_add(Weight::from_parts(0, 6204)) + // Standard Error: 40_649 + .saturating_add(Weight::from_parts(296_994, 0).saturating_mul(n.into())) + // Standard Error: 15_716 + .saturating_add(Weight::from_parts(10_509_026, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + } + /// Storage: Did DidBlacklist (r:1 w:0) + /// Proof: Did DidBlacklist (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:0 w:1) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: Did ServiceEndpoints (r:0 w:25) + /// Proof: Did ServiceEndpoints (max_values: None, max_size: Some(615), added: 3090, mode: MaxEncodedLen) + /// The range of component `n` is `[1, 10]`. + /// The range of component `c` is `[1, 25]`. + fn create_sr25519_keys(n: u32, c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1131` + // Estimated: `6204` + // Minimum execution time: 181_049_000 picoseconds. + Weight::from_parts(161_298_980, 0) + .saturating_add(Weight::from_parts(0, 6204)) + // Standard Error: 36_193 + .saturating_add(Weight::from_parts(1_411_802, 0).saturating_mul(n.into())) + // Standard Error: 13_993 + .saturating_add(Weight::from_parts(11_432_937, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + } + /// Storage: Did DidBlacklist (r:1 w:0) + /// Proof: Did DidBlacklist (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:0 w:1) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: Did ServiceEndpoints (r:0 w:25) + /// Proof: Did ServiceEndpoints (max_values: None, max_size: Some(615), added: 3090, mode: MaxEncodedLen) + /// The range of component `n` is `[1, 10]`. + /// The range of component `c` is `[1, 25]`. + fn create_ecdsa_keys(n: u32, c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1131` + // Estimated: `6204` + // Minimum execution time: 164_997_000 picoseconds. + Weight::from_parts(143_724_779, 0) + .saturating_add(Weight::from_parts(0, 6204)) + // Standard Error: 46_012 + .saturating_add(Weight::from_parts(1_689_629, 0).saturating_mul(n.into())) + // Standard Error: 17_790 + .saturating_add(Weight::from_parts(9_993_575, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + } + /// Storage: Did DidEndpointsCount (r:1 w:1) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: Did ServiceEndpoints (r:25 w:25) + /// Proof: Did ServiceEndpoints (max_values: None, max_size: Some(615), added: 3090, mode: MaxEncodedLen) + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Did DidBlacklist (r:0 w:1) + /// Proof: Did DidBlacklist (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// The range of component `c` is `[1, 25]`. + fn delete(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `969 + c * (105 ±0)` + // Estimated: `5777 + c * (3090 ±0)` + // Minimum execution time: 53_190_000 picoseconds. + Weight::from_parts(54_199_033, 0) + .saturating_add(Weight::from_parts(0, 5777)) + // Standard Error: 4_988 + .saturating_add(Weight::from_parts(1_376_408, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) + .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 3090).saturating_mul(c.into())) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:1) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: Did ServiceEndpoints (r:25 w:25) + /// Proof: Did ServiceEndpoints (max_values: None, max_size: Some(615), added: 3090, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Did DidBlacklist (r:0 w:1) + /// Proof: Did DidBlacklist (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// The range of component `c` is `[1, 25]`. + fn reclaim_deposit(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `969 + c * (105 ±0)` + // Estimated: `5777 + c * (3090 ±0)` + // Minimum execution time: 55_729_000 picoseconds. + Weight::from_parts(56_557_707, 0) + .saturating_add(Weight::from_parts(0, 5777)) + // Standard Error: 4_643 + .saturating_add(Weight::from_parts(1_397_138, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) + .saturating_add(T::DbWeight::get().writes(5)) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 3090).saturating_mul(c.into())) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + fn submit_did_call_ed25519_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `352` + // Estimated: `5777` + // Minimum execution time: 76_132_000 picoseconds. + Weight::from_parts(76_814_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + fn submit_did_call_sr25519_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `352` + // Estimated: `5777` + // Minimum execution time: 77_295_000 picoseconds. + Weight::from_parts(78_438_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + fn submit_did_call_ecdsa_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `353` + // Estimated: `5777` + // Minimum execution time: 64_288_000 picoseconds. + Weight::from_parts(65_482_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn set_ed25519_authentication_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2170` + // Estimated: `5777` + // Minimum execution time: 67_708_000 picoseconds. + Weight::from_parts(70_147_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn set_sr25519_authentication_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2170` + // Estimated: `5777` + // Minimum execution time: 68_784_000 picoseconds. + Weight::from_parts(70_860_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn set_ecdsa_authentication_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2107` + // Estimated: `5777` + // Minimum execution time: 68_261_000 picoseconds. + Weight::from_parts(69_565_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn set_ed25519_delegation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2038` + // Estimated: `5777` + // Minimum execution time: 67_556_000 picoseconds. + Weight::from_parts(69_662_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn set_sr25519_delegation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2165` + // Estimated: `5777` + // Minimum execution time: 67_837_000 picoseconds. + Weight::from_parts(69_180_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn set_ecdsa_delegation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2173` + // Estimated: `5777` + // Minimum execution time: 68_540_000 picoseconds. + Weight::from_parts(69_956_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn remove_ed25519_delegation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2104` + // Estimated: `5777` + // Minimum execution time: 65_127_000 picoseconds. + Weight::from_parts(66_929_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn remove_sr25519_delegation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2104` + // Estimated: `5777` + // Minimum execution time: 64_797_000 picoseconds. + Weight::from_parts(65_517_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn remove_ecdsa_delegation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2173` + // Estimated: `5777` + // Minimum execution time: 65_807_000 picoseconds. + Weight::from_parts(67_122_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn set_ed25519_attestation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2105` + // Estimated: `5777` + // Minimum execution time: 68_688_000 picoseconds. + Weight::from_parts(69_835_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn set_sr25519_attestation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2137` + // Estimated: `5777` + // Minimum execution time: 67_241_000 picoseconds. + Weight::from_parts(68_767_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn set_ecdsa_attestation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2177` + // Estimated: `5777` + // Minimum execution time: 66_623_000 picoseconds. + Weight::from_parts(68_381_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn remove_ed25519_attestation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2137` + // Estimated: `5777` + // Minimum execution time: 64_750_000 picoseconds. + Weight::from_parts(67_215_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn remove_sr25519_attestation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2132` + // Estimated: `5777` + // Minimum execution time: 65_858_000 picoseconds. + Weight::from_parts(67_393_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn remove_ecdsa_attestation_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2112` + // Estimated: `5777` + // Minimum execution time: 64_552_000 picoseconds. + Weight::from_parts(66_076_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn add_ed25519_key_agreement_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2026` + // Estimated: `5777` + // Minimum execution time: 67_691_000 picoseconds. + Weight::from_parts(69_179_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn add_sr25519_key_agreement_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `1966` + // Estimated: `5777` + // Minimum execution time: 67_454_000 picoseconds. + Weight::from_parts(69_136_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn add_ecdsa_key_agreement_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2062` + // Estimated: `5777` + // Minimum execution time: 66_065_000 picoseconds. + Weight::from_parts(68_090_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn remove_ed25519_key_agreement_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2104` + // Estimated: `5777` + // Minimum execution time: 64_706_000 picoseconds. + Weight::from_parts(67_009_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn remove_sr25519_key_agreement_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2170` + // Estimated: `5777` + // Minimum execution time: 65_290_000 picoseconds. + Weight::from_parts(67_110_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn remove_ecdsa_key_agreement_key() -> Weight { + // Proof Size summary in bytes: + // Measured: `2107` + // Estimated: `5777` + // Minimum execution time: 65_011_000 picoseconds. + Weight::from_parts(67_020_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:1) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: Did ServiceEndpoints (r:1 w:1) + /// Proof: Did ServiceEndpoints (max_values: None, max_size: Some(615), added: 3090, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn add_service_endpoint() -> Weight { + // Proof Size summary in bytes: + // Measured: `1504` + // Estimated: `5777` + // Minimum execution time: 75_496_000 picoseconds. + Weight::from_parts(76_809_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did ServiceEndpoints (r:1 w:1) + /// Proof: Did ServiceEndpoints (max_values: None, max_size: Some(615), added: 3090, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:1) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn remove_service_endpoint() -> Weight { + // Proof Size summary in bytes: + // Measured: `2154` + // Estimated: `5777` + // Minimum execution time: 74_014_000 picoseconds. + Weight::from_parts(75_355_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: Did Did (r:1 w:0) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// The range of component `l` is `[1, 5242880]`. + fn signature_verification_sr25519(l: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1626` + // Estimated: `5777` + // Minimum execution time: 63_042_000 picoseconds. + Weight::from_parts(41_623_028, 0) + .saturating_add(Weight::from_parts(0, 5777)) + // Standard Error: 0 + .saturating_add(Weight::from_parts(4_301, 0).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(1)) + } + /// Storage: Did Did (r:1 w:0) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// The range of component `l` is `[1, 5242880]`. + fn signature_verification_ed25519(l: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1626` + // Estimated: `5777` + // Minimum execution time: 61_831_000 picoseconds. + Weight::from_parts(38_865_643, 0) + .saturating_add(Weight::from_parts(0, 5777)) + // Standard Error: 0 + .saturating_add(Weight::from_parts(2_522, 0).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(1)) + } + /// Storage: Did Did (r:1 w:0) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// The range of component `l` is `[1, 5242880]`. + fn signature_verification_ecdsa(l: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1627` + // Estimated: `5777` + // Minimum execution time: 50_295_000 picoseconds. + Weight::from_parts(27_300_442, 0) + .saturating_add(Weight::from_parts(0, 5777)) + // Standard Error: 0 + .saturating_add(Weight::from_parts(1_153, 0).saturating_mul(l.into())) + .saturating_add(T::DbWeight::get().reads(1)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn change_deposit_owner() -> Weight { + // Proof Size summary in bytes: + // Measured: `822` + // Estimated: `5777` + // Minimum execution time: 73_863_000 picoseconds. + Weight::from_parts(76_051_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:1 w:1) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn update_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `888` + // Estimated: `5777` + // Minimum execution time: 45_375_000 picoseconds. + Weight::from_parts(46_464_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + + /// Storage: Did Did (r:1 w:0) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + fn dispatch_as() -> Weight { + // Proof Size summary in bytes: + // Measured: `353` + // Estimated: `5777` + // Minimum execution time: 186_836_000 picoseconds. + Weight::from_parts(189_377_000, 0) + .saturating_add(Weight::from_parts(0, 5777)) + .saturating_add(T::DbWeight::get().reads(1)) + } + /// Storage: Did DidBlacklist (r:1 w:0) + /// Proof: Did DidBlacklist (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen) + /// Storage: Did Did (r:1 w:1) + /// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen) + /// Storage: Did DidEndpointsCount (r:1 w:0) + /// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen) + /// Storage: System Account (r:2 w:2) + /// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen) + /// Storage: Balances Holds (r:1 w:1) + /// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen) + fn create_from_account() -> Weight { + // Proof Size summary in bytes: + // Measured: `999` + // Estimated: `6204` + // Minimum execution time: 1_008_739_000 picoseconds. + Weight::from_parts(1_020_810_000, 0) + .saturating_add(Weight::from_parts(0, 6204)) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(4)) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_create_ed25519_keys() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 6204 + ); + } + #[test] + fn test_create_sr25519_keys() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 6204 + ); + } + #[test] + fn test_create_ecdsa_keys() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 6204 + ); + } + #[test] + fn test_delete() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_reclaim_deposit() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_submit_did_call_ed25519_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_submit_did_call_sr25519_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_submit_did_call_ecdsa_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_set_ed25519_authentication_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_set_sr25519_authentication_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_set_ecdsa_authentication_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_set_ed25519_delegation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_set_sr25519_delegation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_set_ecdsa_delegation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_remove_ed25519_delegation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_remove_sr25519_delegation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_remove_ecdsa_delegation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_set_ed25519_attestation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_set_sr25519_attestation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_set_ecdsa_attestation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_remove_ed25519_attestation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_remove_sr25519_attestation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_remove_ecdsa_attestation_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_add_ed25519_key_agreement_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_add_sr25519_key_agreement_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_add_ecdsa_key_agreement_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_remove_ed25519_key_agreement_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_remove_sr25519_key_agreement_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_remove_ecdsa_key_agreement_key() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_add_service_endpoint() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_remove_service_endpoint() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_signature_verification_sr25519() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_signature_verification_ed25519() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_signature_verification_ecdsa() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_change_deposit_owner() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_update_deposit() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + + #[test] + fn test_dispatch_as() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 5777 + ); + } + #[test] + fn test_create_from_account() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 6204 + ); + } +} diff --git a/dip-template/runtimes/dip-provider/src/weights/frame_system.rs b/dip-template/runtimes/dip-provider/src/weights/frame_system.rs new file mode 100644 index 0000000000..3e821789ca --- /dev/null +++ b/dip-template/runtimes/dip-provider/src/weights/frame_system.rs @@ -0,0 +1,193 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `frame_system` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/release/dip-provider-node-template +// benchmark +// pallet +// --template=.maintain/runtime-weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --pallet=frame-system +// --extrinsic=* +// --output=./dip-template/runtimes/dip-provider/src/weights/frame_system.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `frame_system`. +pub struct WeightInfo(PhantomData); +impl frame_system::WeightInfo for WeightInfo { + /// The range of component `b` is `[0, 3932160]`. + fn remark(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_320_000 picoseconds. + Weight::from_parts(1_367_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 0 + .saturating_add(Weight::from_parts(223, 0).saturating_mul(b.into())) + } + /// The range of component `b` is `[0, 3932160]`. + fn remark_with_event(b: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 4_819_000 picoseconds. + Weight::from_parts(4_960_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 1 + .saturating_add(Weight::from_parts(1_147, 0).saturating_mul(b.into())) + } + /// Storage: `System::Digest` (r:1 w:1) + /// Proof: `System::Digest` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: UNKNOWN KEY `0x3a686561707061676573` (r:0 w:1) + /// Proof: UNKNOWN KEY `0x3a686561707061676573` (r:0 w:1) + fn set_heap_pages() -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `1485` + // Minimum execution time: 2_633_000 picoseconds. + Weight::from_parts(2_766_000, 0) + .saturating_add(Weight::from_parts(0, 1485)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(2)) + } + /// Storage: `ParachainSystem::ValidationData` (r:1 w:0) + /// Proof: `ParachainSystem::ValidationData` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::UpgradeRestrictionSignal` (r:1 w:0) + /// Proof: `ParachainSystem::UpgradeRestrictionSignal` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::PendingValidationCode` (r:1 w:1) + /// Proof: `ParachainSystem::PendingValidationCode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::HostConfiguration` (r:1 w:0) + /// Proof: `ParachainSystem::HostConfiguration` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::NewValidationCode` (r:0 w:1) + /// Proof: `ParachainSystem::NewValidationCode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + /// Storage: `ParachainSystem::DidSetValidationCode` (r:0 w:1) + /// Proof: `ParachainSystem::DidSetValidationCode` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) + fn set_code() -> Weight { + // Proof Size summary in bytes: + // Measured: `119` + // Estimated: `1604` + // Minimum execution time: 89_656_515_000 picoseconds. + Weight::from_parts(92_710_625_000, 0) + .saturating_add(Weight::from_parts(0, 1604)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(3)) + } + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `i` is `[0, 1000]`. + fn set_storage(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_379_000 picoseconds. + Weight::from_parts(1_438_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 1_236 + .saturating_add(Weight::from_parts(591_504, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) + } + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `i` is `[0, 1000]`. + fn kill_storage(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `0` + // Estimated: `0` + // Minimum execution time: 1_377_000 picoseconds. + Weight::from_parts(1_419_000, 0) + .saturating_add(Weight::from_parts(0, 0)) + // Standard Error: 526 + .saturating_add(Weight::from_parts(413_184, 0).saturating_mul(i.into())) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) + } + /// Storage: `Skipped::Metadata` (r:0 w:0) + /// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `p` is `[0, 1000]`. + fn kill_prefix(p: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `64 + p * (69 ±0)` + // Estimated: `65 + p * (70 ±0)` + // Minimum execution time: 2_657_000 picoseconds. + Weight::from_parts(2_737_000, 0) + .saturating_add(Weight::from_parts(0, 65)) + // Standard Error: 793 + .saturating_add(Weight::from_parts(806_524, 0).saturating_mul(p.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into()))) + .saturating_add(Weight::from_parts(0, 70).saturating_mul(p.into())) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_set_heap_pages() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 1485 + ); + } + #[test] + fn test_set_code() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 1604 + ); + } + #[test] + fn test_kill_prefix() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 65 + ); + } +} diff --git a/dip-template/runtimes/dip-provider/src/weights/mod.rs b/dip-template/runtimes/dip-provider/src/weights/mod.rs new file mode 100644 index 0000000000..22be9a259b --- /dev/null +++ b/dip-template/runtimes/dip-provider/src/weights/mod.rs @@ -0,0 +1,24 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +pub mod did; +pub mod frame_system; +pub mod pallet_deposit_storage; +pub mod pallet_did_lookup; +pub mod pallet_dip_provider; +pub mod pallet_web3_names; diff --git a/dip-template/runtimes/dip-provider/src/weights/pallet_deposit_storage.rs b/dip-template/runtimes/dip-provider/src/weights/pallet_deposit_storage.rs new file mode 100644 index 0000000000..e675d6ec00 --- /dev/null +++ b/dip-template/runtimes/dip-provider/src/weights/pallet_deposit_storage.rs @@ -0,0 +1,85 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `pallet_deposit_storage` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/release/dip-provider-node-template +// benchmark +// pallet +// --template=.maintain/runtime-weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --pallet=pallet-deposit-storage +// --extrinsic=* +// --output=./dip-template/runtimes/dip-provider/src/weights/pallet_deposit_storage.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_deposit_storage`. +pub struct WeightInfo(PhantomData); +impl pallet_deposit_storage::WeightInfo for WeightInfo { + /// Storage: `DepositStorage::Deposits` (r:1 w:1) + /// Proof: `DepositStorage::Deposits` (`max_values`: None, `max_size`: Some(325), added: 2800, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `DipProvider::IdentityCommitments` (r:1 w:1) + /// Proof: `DipProvider::IdentityCommitments` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`) + fn reclaim_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `443` + // Estimated: `4414` + // Minimum execution time: 39_267_000 picoseconds. + Weight::from_parts(39_811_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_reclaim_deposit() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } +} diff --git a/dip-template/runtimes/dip-provider/src/weights/pallet_did_lookup.rs b/dip-template/runtimes/dip-provider/src/weights/pallet_did_lookup.rs new file mode 100644 index 0000000000..4a9366ad62 --- /dev/null +++ b/dip-template/runtimes/dip-provider/src/weights/pallet_did_lookup.rs @@ -0,0 +1,321 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `pallet_did_lookup` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/release/dip-provider-node-template +// benchmark +// pallet +// --template=.maintain/runtime-weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --pallet=pallet-did-lookup +// --extrinsic=* +// --output=./dip-template/runtimes/dip-provider/src/weights/pallet_did_lookup.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_did_lookup`. +pub struct WeightInfo(PhantomData); +impl pallet_did_lookup::WeightInfo for WeightInfo { + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedDids` (r:1 w:1) + /// Proof: `DidLookup::ConnectedDids` (`max_values`: None, `max_size`: Some(129), added: 2604, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:0 w:2) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + fn associate_account_multisig_sr25519() -> Weight { + // Proof Size summary in bytes: + // Measured: `390` + // Estimated: `4414` + // Minimum execution time: 115_816_000 picoseconds. + Weight::from_parts(150_087_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedDids` (r:1 w:1) + /// Proof: `DidLookup::ConnectedDids` (`max_values`: None, `max_size`: Some(129), added: 2604, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:0 w:2) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + fn associate_account_multisig_ed25519() -> Weight { + // Proof Size summary in bytes: + // Measured: `390` + // Estimated: `4414` + // Minimum execution time: 119_599_000 picoseconds. + Weight::from_parts(175_393_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedDids` (r:1 w:1) + /// Proof: `DidLookup::ConnectedDids` (`max_values`: None, `max_size`: Some(129), added: 2604, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:0 w:2) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + fn associate_account_multisig_ecdsa() -> Weight { + // Proof Size summary in bytes: + // Measured: `390` + // Estimated: `4414` + // Minimum execution time: 119_023_000 picoseconds. + Weight::from_parts(176_847_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedDids` (r:1 w:1) + /// Proof: `DidLookup::ConnectedDids` (`max_values`: None, `max_size`: Some(129), added: 2604, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:0 w:2) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + fn associate_eth_account() -> Weight { + // Proof Size summary in bytes: + // Measured: `377` + // Estimated: `4414` + // Minimum execution time: 115_485_000 picoseconds. + Weight::from_parts(170_435_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedDids` (r:1 w:1) + /// Proof: `DidLookup::ConnectedDids` (`max_values`: None, `max_size`: Some(129), added: 2604, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:0 w:2) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + fn associate_sender() -> Weight { + // Proof Size summary in bytes: + // Measured: `390` + // Estimated: `4414` + // Minimum execution time: 70_488_000 picoseconds. + Weight::from_parts(75_207_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `DidLookup::ConnectedDids` (r:1 w:1) + /// Proof: `DidLookup::ConnectedDids` (`max_values`: None, `max_size`: Some(129), added: 2604, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:0 w:1) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + fn remove_sender_association() -> Weight { + // Proof Size summary in bytes: + // Measured: `390` + // Estimated: `4414` + // Minimum execution time: 37_873_000 picoseconds. + Weight::from_parts(40_493_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `DidLookup::ConnectedDids` (r:1 w:1) + /// Proof: `DidLookup::ConnectedDids` (`max_values`: None, `max_size`: Some(129), added: 2604, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:0 w:1) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + fn remove_account_association() -> Weight { + // Proof Size summary in bytes: + // Measured: `390` + // Estimated: `4414` + // Minimum execution time: 38_071_000 picoseconds. + Weight::from_parts(39_343_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `DidLookup::ConnectedDids` (r:1 w:1) + /// Proof: `DidLookup::ConnectedDids` (`max_values`: None, `max_size`: Some(129), added: 2604, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:2 w:2) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + fn change_deposit_owner() -> Weight { + // Proof Size summary in bytes: + // Measured: `493` + // Estimated: `7838` + // Minimum execution time: 64_007_000 picoseconds. + Weight::from_parts(66_141_000, 0) + .saturating_add(Weight::from_parts(0, 7838)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `DidLookup::ConnectedDids` (r:1 w:1) + /// Proof: `DidLookup::ConnectedDids` (`max_values`: None, `max_size`: Some(129), added: 2604, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + fn update_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `390` + // Estimated: `4414` + // Minimum execution time: 58_458_000 picoseconds. + Weight::from_parts(59_907_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_associate_account_multisig_sr25519() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_associate_account_multisig_ed25519() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_associate_account_multisig_ecdsa() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_associate_eth_account() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_associate_sender() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_remove_sender_association() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_remove_account_association() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_change_deposit_owner() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 7838 + ); + } + #[test] + fn test_update_deposit() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } +} diff --git a/dip-template/runtimes/dip-provider/src/weights/pallet_dip_provider.rs b/dip-template/runtimes/dip-provider/src/weights/pallet_dip_provider.rs new file mode 100644 index 0000000000..ad46d99ebb --- /dev/null +++ b/dip-template/runtimes/dip-provider/src/weights/pallet_dip_provider.rs @@ -0,0 +1,125 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `pallet_dip_provider` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/release/dip-provider-node-template +// benchmark +// pallet +// --template=.maintain/runtime-weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --pallet=pallet-dip-provider +// --extrinsic=* +// --output=./dip-template/runtimes/dip-provider/src/weights/pallet_dip_provider.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_dip_provider`. +pub struct WeightInfo(PhantomData); +impl pallet_dip_provider::WeightInfo for WeightInfo { + /// Storage: `Did::Did` (r:1 w:0) + /// Proof: `Did::Did` (`max_values`: None, `max_size`: Some(1447), added: 3922, mode: `MaxEncodedLen`) + /// Storage: `Did::DidBlacklist` (r:1 w:0) + /// Proof: `Did::DidBlacklist` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Names` (r:1 w:0) + /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Owner` (r:1 w:0) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(133), added: 2608, mode: `MaxEncodedLen`) + /// Storage: `DidLookup::ConnectedAccounts` (r:21 w:0) + /// Proof: `DidLookup::ConnectedAccounts` (`max_values`: None, `max_size`: Some(97), added: 2572, mode: `MaxEncodedLen`) + /// Storage: `DipProvider::IdentityCommitments` (r:1 w:1) + /// Proof: `DipProvider::IdentityCommitments` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`) + /// Storage: `DepositStorage::Deposits` (r:1 w:1) + /// Proof: `DepositStorage::Deposits` (`max_values`: None, `max_size`: Some(325), added: 2800, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + fn commit_identity() -> Weight { + // Proof Size summary in bytes: + // Measured: `3190` + // Estimated: `55002` + // Minimum execution time: 236_589_000 picoseconds. + Weight::from_parts(266_691_000, 0) + .saturating_add(Weight::from_parts(0, 55002)) + .saturating_add(T::DbWeight::get().reads(29)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `DipProvider::IdentityCommitments` (r:1 w:1) + /// Proof: `DipProvider::IdentityCommitments` (`max_values`: None, `max_size`: Some(82), added: 2557, mode: `MaxEncodedLen`) + /// Storage: `DepositStorage::Deposits` (r:1 w:1) + /// Proof: `DepositStorage::Deposits` (`max_values`: None, `max_size`: Some(325), added: 2800, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + fn delete_identity_commitment() -> Weight { + // Proof Size summary in bytes: + // Measured: `498` + // Estimated: `4414` + // Minimum execution time: 51_471_000 picoseconds. + Weight::from_parts(56_814_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_commit_identity() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 55002 + ); + } + #[test] + fn test_delete_identity_commitment() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } +} diff --git a/dip-template/runtimes/dip-provider/src/weights/pallet_web3_names.rs b/dip-template/runtimes/dip-provider/src/weights/pallet_web3_names.rs new file mode 100644 index 0000000000..e489a91e52 --- /dev/null +++ b/dip-template/runtimes/dip-provider/src/weights/pallet_web3_names.rs @@ -0,0 +1,265 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 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 . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +//! Autogenerated weights for `pallet_web3_names` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-12-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K` +//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024 + +// Executed Command: +// ./target/release/dip-provider-node-template +// benchmark +// pallet +// --template=.maintain/runtime-weight-template.hbs +// --header=HEADER-GPL +// --wasm-execution=compiled +// --heap-pages=4096 +// --steps=50 +// --repeat=20 +// --pallet=pallet-web3-names +// --extrinsic=* +// --output=./dip-template/runtimes/dip-provider/src/weights/pallet_web3_names.rs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::Weight}; +use sp_std::marker::PhantomData; + +/// Weight functions for `pallet_web3_names`. +pub struct WeightInfo(PhantomData); +impl pallet_web3_names::WeightInfo for WeightInfo { + /// Storage: `Web3Names::Names` (r:1 w:1) + /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Owner` (r:1 w:1) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(133), added: 2608, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Banned` (r:1 w:0) + /// Proof: `Web3Names::Banned` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// The range of component `n` is `[3, 32]`. + fn claim(_n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `107` + // Estimated: `4414` + // Minimum execution time: 113_246_000 picoseconds. + Weight::from_parts(132_782_588, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `Web3Names::Names` (r:1 w:1) + /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Owner` (r:1 w:1) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(133), added: 2608, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + fn release_by_owner() -> Weight { + // Proof Size summary in bytes: + // Measured: `428` + // Estimated: `4414` + // Minimum execution time: 101_512_000 picoseconds. + Weight::from_parts(111_009_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `Web3Names::Owner` (r:1 w:1) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(133), added: 2608, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Names` (r:0 w:1) + /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) + /// The range of component `n` is `[3, 32]`. + fn reclaim_deposit(_n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `324 + n * (1 ±0)` + // Estimated: `4414` + // Minimum execution time: 36_756_000 picoseconds. + Weight::from_parts(94_263_229, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(4)) + } + /// Storage: `Web3Names::Banned` (r:1 w:1) + /// Proof: `Web3Names::Banned` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Owner` (r:1 w:1) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(133), added: 2608, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Names` (r:0 w:1) + /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) + /// The range of component `n` is `[3, 32]`. + fn ban(_n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `324 + n * (1 ±0)` + // Estimated: `4414` + // Minimum execution time: 36_341_000 picoseconds. + Weight::from_parts(44_569_163, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(4)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `Web3Names::Banned` (r:1 w:1) + /// Proof: `Web3Names::Banned` (`max_values`: None, `max_size`: Some(49), added: 2524, mode: `MaxEncodedLen`) + /// The range of component `n` is `[3, 32]`. + fn unban(_n: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `47 + n * (1 ±0)` + // Estimated: `3514` + // Minimum execution time: 8_620_000 picoseconds. + Weight::from_parts(9_336_817, 0) + .saturating_add(Weight::from_parts(0, 3514)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } + /// Storage: `Web3Names::Names` (r:1 w:0) + /// Proof: `Web3Names::Names` (`max_values`: None, `max_size`: Some(81), added: 2556, mode: `MaxEncodedLen`) + /// Storage: `Web3Names::Owner` (r:1 w:1) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(133), added: 2608, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:2 w:2) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:2 w:2) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + fn change_deposit_owner() -> Weight { + // Proof Size summary in bytes: + // Measured: `531` + // Estimated: `7838` + // Minimum execution time: 60_074_000 picoseconds. + Weight::from_parts(61_305_000, 0) + .saturating_add(Weight::from_parts(0, 7838)) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) + } + /// Storage: `Web3Names::Owner` (r:1 w:1) + /// Proof: `Web3Names::Owner` (`max_values`: None, `max_size`: Some(133), added: 2608, mode: `MaxEncodedLen`) + /// Storage: `System::Account` (r:1 w:1) + /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// Storage: `Balances::Holds` (r:1 w:1) + /// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(949), added: 3424, mode: `MaxEncodedLen`) + fn update_deposit() -> Weight { + // Proof Size summary in bytes: + // Measured: `357` + // Estimated: `4414` + // Minimum execution time: 55_049_000 picoseconds. + Weight::from_parts(55_580_000, 0) + .saturating_add(Weight::from_parts(0, 4414)) + .saturating_add(T::DbWeight::get().reads(3)) + .saturating_add(T::DbWeight::get().writes(3)) + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_claim() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_release_by_owner() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_reclaim_deposit() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_ban() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } + #[test] + fn test_unban() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 3514 + ); + } + #[test] + fn test_change_deposit_owner() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 7838 + ); + } + #[test] + fn test_update_deposit() { + assert!( + ::BlockWeights::get() + .per_class + .get(frame_support::dispatch::DispatchClass::Normal) + .max_extrinsic + .unwrap_or_else(::max_value) + .proof_size() + > 4414 + ); + } +} diff --git a/pallets/pallet-deposit-storage/src/lib.rs b/pallets/pallet-deposit-storage/src/lib.rs index bfc210f162..3e588696d0 100644 --- a/pallets/pallet-deposit-storage/src/lib.rs +++ b/pallets/pallet-deposit-storage/src/lib.rs @@ -29,9 +29,10 @@ mod mock; #[cfg(feature = "runtime-benchmarks")] mod benchmarking; -pub use deposit::FixedDepositCollectorViaDepositsPallet; -pub use pallet::*; -pub use traits::NoopDepositStorageHooks; +pub use crate::{ + default_weights::WeightInfo, deposit::FixedDepositCollectorViaDepositsPallet, pallet::*, + traits::NoopDepositStorageHooks, +}; #[frame_support::pallet] pub mod pallet { diff --git a/pallets/pallet-dip-consumer/src/lib.rs b/pallets/pallet-dip-consumer/src/lib.rs index 6c4955eb94..fcfa5c99da 100644 --- a/pallets/pallet-dip-consumer/src/lib.rs +++ b/pallets/pallet-dip-consumer/src/lib.rs @@ -32,7 +32,7 @@ pub mod benchmarking; mod origin; -pub use crate::{origin::*, pallet::*, traits::SuccessfulProofVerifier}; +pub use crate::{default_weights::WeightInfo, origin::*, pallet::*, traits::SuccessfulProofVerifier}; #[frame_support::pallet] pub mod pallet { diff --git a/pallets/pallet-dip-provider/src/lib.rs b/pallets/pallet-dip-provider/src/lib.rs index c6d00d5355..5026844d7c 100644 --- a/pallets/pallet-dip-provider/src/lib.rs +++ b/pallets/pallet-dip-provider/src/lib.rs @@ -30,6 +30,7 @@ mod benchmarking; mod mock; pub use crate::{ + default_weights::WeightInfo, pallet::*, traits::{DefaultIdentityCommitmentGenerator, DefaultIdentityProvider, NoopHooks}, }; diff --git a/pallets/pallet-relay-store/src/lib.rs b/pallets/pallet-relay-store/src/lib.rs index 26a66ebe4e..48b844108e 100644 --- a/pallets/pallet-relay-store/src/lib.rs +++ b/pallets/pallet-relay-store/src/lib.rs @@ -29,7 +29,7 @@ mod benchmarking; #[cfg(test)] mod mock; -pub use crate::pallet::*; +pub use crate::{default_weights::WeightInfo, pallet::*}; #[frame_support::pallet] pub mod pallet { From 3c5e579eab8143ce9a3bca1449419454018d173c Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Wed, 6 Dec 2023 11:37:11 +0100 Subject: [PATCH 71/71] Last fixes --- crates/kilt-dip-support/Cargo.toml | 2 +- crates/kilt-dip-support/src/export/child.rs | 1 - dip-template/nodes/dip-consumer/Cargo.toml | 5 ----- dip-template/runtimes/dip-provider/src/dip.rs | 4 ++-- pallets/pallet-deposit-storage/Cargo.toml | 2 -- pallets/pallet-deposit-storage/src/lib.rs | 6 +++--- pallets/pallet-dip-consumer/Cargo.toml | 2 -- pallets/pallet-dip-consumer/src/lib.rs | 1 - pallets/pallet-dip-provider/src/lib.rs | 2 +- pallets/pallet-relay-store/src/lib.rs | 2 +- 10 files changed, 8 insertions(+), 19 deletions(-) diff --git a/crates/kilt-dip-support/Cargo.toml b/crates/kilt-dip-support/Cargo.toml index c238d8e526..bbebdfa4f2 100644 --- a/crates/kilt-dip-support/Cargo.toml +++ b/crates/kilt-dip-support/Cargo.toml @@ -58,7 +58,7 @@ std = [ "hash-db/std", "log/std", "did/std", - "kilt-support/std", + "kilt-support?/std", "pallet-did-lookup/std", "pallet-dip-consumer/std", "pallet-dip-provider/std", diff --git a/crates/kilt-dip-support/src/export/child.rs b/crates/kilt-dip-support/src/export/child.rs index 4a148885cf..6fd215de33 100644 --- a/crates/kilt-dip-support/src/export/child.rs +++ b/crates/kilt-dip-support/src/export/child.rs @@ -460,7 +460,6 @@ mod v0 { ProviderParachainStateInfo, RelayChainStorageInfo, }, utils::OutputOf, - BoundedBlindedValue, }; #[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)] diff --git a/dip-template/nodes/dip-consumer/Cargo.toml b/dip-template/nodes/dip-consumer/Cargo.toml index 7ff397acc5..1f5435f436 100644 --- a/dip-template/nodes/dip-consumer/Cargo.toml +++ b/dip-template/nodes/dip-consumer/Cargo.toml @@ -73,9 +73,4 @@ substrate-build-script-utils.workspace = true runtime-benchmarks = [ "frame-benchmarking-cli/runtime-benchmarks", "dip-consumer-runtime-template/runtime-benchmarks", - # "frame-benchmarking/runtime-benchmarks", - # "polkadot-cli/runtime-benchmarks", - # "polkadot-primitives/runtime-benchmarks", - # "sc-service/runtime-benchmarks", - # "sp-runtime/runtime-benchmarks", ] diff --git a/dip-template/runtimes/dip-provider/src/dip.rs b/dip-template/runtimes/dip-provider/src/dip.rs index e1a27480d0..66f8ee88ec 100644 --- a/dip-template/runtimes/dip-provider/src/dip.rs +++ b/dip-template/runtimes/dip-provider/src/dip.rs @@ -170,6 +170,8 @@ pub mod deposit { } impl pallet_deposit_storage::Config for Runtime { + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHooks = deposit::PalletDepositStorageBenchmarkHooks; type CheckOrigin = EnsureSigned; type Currency = Balances; type DepositHooks = DepositHooks; @@ -178,8 +180,6 @@ impl pallet_deposit_storage::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeHoldReason = RuntimeHoldReason; type WeightInfo = weights::pallet_deposit_storage::WeightInfo; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHooks = deposit::PalletDepositStorageBenchmarkHooks; } impl pallet_dip_provider::Config for Runtime { diff --git a/pallets/pallet-deposit-storage/Cargo.toml b/pallets/pallet-deposit-storage/Cargo.toml index 216757536e..21f4ca1653 100644 --- a/pallets/pallet-deposit-storage/Cargo.toml +++ b/pallets/pallet-deposit-storage/Cargo.toml @@ -59,5 +59,3 @@ runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "pallet-balances/runtime-benchmarks", ] - -try-runtime = [ "kilt-support/try-runtime" ] diff --git a/pallets/pallet-deposit-storage/src/lib.rs b/pallets/pallet-deposit-storage/src/lib.rs index 3e588696d0..eeca637f53 100644 --- a/pallets/pallet-deposit-storage/src/lib.rs +++ b/pallets/pallet-deposit-storage/src/lib.rs @@ -39,7 +39,7 @@ pub mod pallet { use crate::{ default_weights::WeightInfo, deposit::{free_deposit, reserve_deposit, DepositEntry}, - traits::{BenchmarkHooks, DepositStorageHooks}, + traits::DepositStorageHooks, }; use super::*; @@ -70,14 +70,14 @@ pub mod pallet { #[pallet::constant] type MaxKeyLength: Get; + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHooks: crate::traits::BenchmarkHooks; type CheckOrigin: EnsureOrigin; type Currency: Mutate; type DepositHooks: DepositStorageHooks; type Namespace: Parameter + MaxEncodedLen; type RuntimeEvent: From> + IsType<::RuntimeEvent>; type RuntimeHoldReason: From + Clone + PartialEq + Debug + FullCodec + MaxEncodedLen + TypeInfo; - #[cfg(feature = "runtime-benchmarks")] - type BenchmarkHooks: BenchmarkHooks; type WeightInfo: WeightInfo; } diff --git a/pallets/pallet-dip-consumer/Cargo.toml b/pallets/pallet-dip-consumer/Cargo.toml index 6440849204..5217db0458 100644 --- a/pallets/pallet-dip-consumer/Cargo.toml +++ b/pallets/pallet-dip-consumer/Cargo.toml @@ -52,5 +52,3 @@ std = [ "frame-benchmarking?/std", "sp-runtime?/std", ] - -try-runtime = [ "kilt-support/try-runtime" ] diff --git a/pallets/pallet-dip-consumer/src/lib.rs b/pallets/pallet-dip-consumer/src/lib.rs index fcfa5c99da..ccdd1e0883 100644 --- a/pallets/pallet-dip-consumer/src/lib.rs +++ b/pallets/pallet-dip-consumer/src/lib.rs @@ -38,7 +38,6 @@ pub use crate::{default_weights::WeightInfo, origin::*, pallet::*, traits::Succe pub mod pallet { use super::*; - use default_weights::WeightInfo; use frame_support::{ dispatch::{Dispatchable, GetDispatchInfo}, pallet_prelude::*, diff --git a/pallets/pallet-dip-provider/src/lib.rs b/pallets/pallet-dip-provider/src/lib.rs index 5026844d7c..a3672eded9 100644 --- a/pallets/pallet-dip-provider/src/lib.rs +++ b/pallets/pallet-dip-provider/src/lib.rs @@ -20,7 +20,7 @@ #![cfg_attr(not(feature = "std"), no_std)] -pub mod default_weights; +mod default_weights; pub mod traits; #[cfg(feature = "runtime-benchmarks")] diff --git a/pallets/pallet-relay-store/src/lib.rs b/pallets/pallet-relay-store/src/lib.rs index 48b844108e..bebe071c46 100644 --- a/pallets/pallet-relay-store/src/lib.rs +++ b/pallets/pallet-relay-store/src/lib.rs @@ -39,7 +39,7 @@ pub mod pallet { use frame_system::pallet_prelude::*; use sp_core::H256; - use crate::{default_weights::WeightInfo, relay::RelayParentInfo}; + use crate::relay::RelayParentInfo; const STORAGE_VERSION: StorageVersion = StorageVersion::new(0);