diff --git a/Cargo.lock b/Cargo.lock index d48744fc5..cda36b9c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10779,7 +10779,6 @@ dependencies = [ "frame-try-runtime", "hex-literal", "kilt-runtime-api-did", - "kilt-runtime-api-public-credentials", "kilt-runtime-api-staking", "kilt-support", "log", @@ -10809,7 +10808,6 @@ dependencies = [ "parachain-info", "parachain-staking", "parity-scale-codec", - "public-credentials", "runtime-common", "scale-info", "sp-api", diff --git a/runtimes/spiritnet/Cargo.toml b/runtimes/spiritnet/Cargo.toml index 389b1d2bb..802297525 100644 --- a/runtimes/spiritnet/Cargo.toml +++ b/runtimes/spiritnet/Cargo.toml @@ -26,7 +26,6 @@ hex-literal = {workspace = true, optional = true} # RPC & Runtime API frame-system-rpc-runtime-api.workspace = true kilt-runtime-api-did.workspace = true -kilt-runtime-api-public-credentials.workspace = true kilt-runtime-api-staking.workspace = true pallet-transaction-payment-rpc-runtime-api.workspace = true @@ -40,7 +39,6 @@ pallet-did-lookup.workspace = true pallet-inflation.workspace = true pallet-web3-names.workspace = true parachain-staking.workspace = true -public-credentials.workspace = true runtime-common.workspace = true # Substrate dependencies @@ -136,7 +134,6 @@ runtime-benchmarks = [ "pallet-vesting/runtime-benchmarks", "pallet-web3-names/runtime-benchmarks", "parachain-staking/runtime-benchmarks", - "public-credentials/runtime-benchmarks", "runtime-common/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "xcm-builder/runtime-benchmarks", @@ -162,7 +159,6 @@ std = [ "frame-system/std", "frame-try-runtime/std", "kilt-runtime-api-did/std", - "kilt-runtime-api-public-credentials/std", "kilt-runtime-api-staking/std", "kilt-support/std", "log/std", @@ -191,7 +187,6 @@ std = [ "pallet-xcm/std", "parachain-info/std", "parachain-staking/std", - "public-credentials/std", "runtime-common/std", "scale-info/std", "sp-api/std", @@ -248,6 +243,5 @@ try-runtime = [ "pallet-xcm/try-runtime", "parachain-info/try-runtime", "parachain-staking/try-runtime", - "public-credentials/try-runtime", "runtime-common/try-runtime", ] diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index 63d7a4069..6ba7c5b64 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -46,15 +46,11 @@ use sp_version::RuntimeVersion; use xcm_executor::XcmExecutor; use delegation::DelegationAc; -use kilt_support::traits::ItemFilter; pub use parachain_staking::InflationInfo; -pub use public_credentials; use runtime_common::{ - assets::{AssetDid, PublicCredentialsFilter}, authorization::{AuthorizationId, PalletAuthorize}, constants::{self, EXISTENTIAL_DEPOSIT, KILT}, - errors::PublicCredentialsApiError, fees::{ToAuthor, WeightToFee}, pallet_id, AccountId, AuthorityId, Balance, BlockHashCount, BlockLength, BlockNumber, BlockWeights, DidIdentifier, FeeSplit, Hash, Header, Index, Signature, SlowAdjustingFeeUpdate, @@ -670,23 +666,6 @@ impl pallet_utility::Config for Runtime { impl pallet_randomness_collective_flip::Config for Runtime {} -impl public_credentials::Config for Runtime { - type AccessControl = PalletAuthorize>; - type AttesterId = DidIdentifier; - type AuthorizationId = AuthorizationId<::DelegationNodeId>; - type CredentialId = Hash; - type CredentialHash = BlakeTwo256; - type Currency = Balances; - type Deposit = runtime_common::constants::public_credentials::Deposit; - type EnsureOrigin = did::EnsureDidOrigin; - type MaxEncodedClaimsLength = runtime_common::constants::public_credentials::MaxEncodedClaimsLength; - type MaxSubjectIdLength = runtime_common::constants::public_credentials::MaxSubjectIdLength; - type OriginSuccess = did::DidRawOrigin; - type Event = Event; - type SubjectId = runtime_common::assets::AssetDid; - type WeightInfo = weights::public_credentials::WeightInfo; -} - /// The type used to represent the kinds of proxying allowed. #[derive( Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen, scale_info::TypeInfo, @@ -738,7 +717,6 @@ impl InstanceFilter for ProxyType { // Excludes `ParachainSystem` | Call::Preimage(..) | Call::Proxy(..) - | Call::PublicCredentials(..) | Call::Scheduler(..) | Call::Session(..) | Call::System(..) @@ -810,15 +788,6 @@ impl InstanceFilter for ProxyType { // Excludes `ParachainSystem` | Call::Preimage(..) | Call::Proxy(..) - | Call::PublicCredentials( - // Excludes `reclaim_deposit` - public_credentials::Call::add { .. } - | public_credentials::Call::revoke { .. } - | public_credentials::Call::unrevoke { .. } - | public_credentials::Call::remove { .. } - | public_credentials::Call::update_deposit { .. } - | public_credentials::Call::change_deposit_owner { .. } - ) | Call::Scheduler(..) | Call::Session(..) // Excludes `Sudo` @@ -951,7 +920,6 @@ construct_runtime! { Inflation: pallet_inflation = 66, DidLookup: pallet_did_lookup = 67, Web3Names: pallet_web3_names = 68, - PublicCredentials: public_credentials = 69, // Parachains pallets. Start indices at 80 to leave room. @@ -999,7 +967,6 @@ impl did::DeriveDidCallAuthorizationVerificationKeyRelationship for Call { Call::Did(did::Call::create { .. }) => Err(did::RelationshipDeriveError::NotCallableByDid), Call::Did { .. } => Ok(did::DidVerificationKeyRelationship::Authentication), Call::Web3Names { .. } => Ok(did::DidVerificationKeyRelationship::Authentication), - Call::PublicCredentials { .. } => Ok(did::DidVerificationKeyRelationship::AssertionMethod), Call::DidLookup { .. } => Ok(did::DidVerificationKeyRelationship::Authentication), Call::Utility(pallet_utility::Call::batch { calls }) => single_key_relationship(&calls[..]), Call::Utility(pallet_utility::Call::batch_all { calls }) => single_key_relationship(&calls[..]), @@ -1249,23 +1216,6 @@ impl_runtime_apis! { } } - impl kilt_runtime_api_public_credentials::PublicCredentials, Hash, public_credentials::CredentialEntry::DelegationNodeId>>, PublicCredentialsFilter, PublicCredentialsApiError> for Runtime { - fn get_credential(credential_id: Hash) -> Option::DelegationNodeId>>> { - let subject = public_credentials::CredentialSubjects::::get(&credential_id)?; - public_credentials::Credentials::::get(&subject, &credential_id) - } - - fn get_credentials(subject: Vec, filter: Option>) -> Result::DelegationNodeId>>)>, PublicCredentialsApiError> { - let asset_did = AssetDid::try_from(subject).map_err(|_| PublicCredentialsApiError::InvalidSubjectId)?; - let credentials_prefix = public_credentials::Credentials::::iter_prefix(&asset_did); - if let Some(filter) = filter { - Ok(credentials_prefix.filter(|(_, entry)| filter.should_include(entry)).collect()) - } else { - Ok(credentials_prefix.collect()) - } - } - } - impl kilt_runtime_api_staking::Staking for Runtime { fn get_unclaimed_staking_rewards(account: &AccountId) -> Balance { ParachainStaking::get_unclaimed_staking_rewards(account) @@ -1317,7 +1267,6 @@ impl_runtime_apis! { list_benchmark!(list, extra, pallet_inflation, Inflation); list_benchmark!(list, extra, parachain_staking, ParachainStaking); list_benchmark!(list, extra, pallet_web3_names, Web3Names); - list_benchmark!(list, extra, public_credentials, PublicCredentials); let storage_info = AllPalletsWithSystem::storage_info(); @@ -1384,7 +1333,6 @@ impl_runtime_apis! { add_benchmark!(params, batches, pallet_inflation, Inflation); add_benchmark!(params, batches, parachain_staking, ParachainStaking); add_benchmark!(params, batches, pallet_web3_names, Web3Names); - add_benchmark!(params, batches, public_credentials, PublicCredentials); // No benchmarks for these pallets // add_benchmark!(params, batches, cumulus_pallet_parachain_system, ParachainSystem); diff --git a/runtimes/spiritnet/src/tests.rs b/runtimes/spiritnet/src/tests.rs index b3de86a09..ae7f54879 100644 --- a/runtimes/spiritnet/src/tests.rs +++ b/runtimes/spiritnet/src/tests.rs @@ -25,8 +25,7 @@ use pallet_web3_names::{Web3NameOf, Web3OwnershipOf}; use runtime_common::{ constants::{ attestation::MAX_ATTESTATION_BYTE_LENGTH, did::MAX_DID_BYTE_LENGTH, did_lookup::MAX_CONNECTION_BYTE_LENGTH, - public_credentials::MAX_PUBLIC_CREDENTIAL_STORAGE_LENGTH, web3_names::MAX_NAME_BYTE_LENGTH, - MAX_INDICES_BYTE_LENGTH, + web3_names::MAX_NAME_BYTE_LENGTH, MAX_INDICES_BYTE_LENGTH, }, AccountId, BlockNumber, }; @@ -101,20 +100,6 @@ fn indices_storage_sizes() { assert_eq!(size, MAX_INDICES_BYTE_LENGTH as usize) } -#[test] -fn public_credentials_storage_sizes() { - // Stored in Credentials - let credential_entry_max_size = public_credentials::CredentialEntryOf::::max_encoded_len(); - // Stored in CredentialsUnicityIndex - let subject_id_max_size = ::SubjectId::max_encoded_len(); - - // Each credential would have a different deposit, so no multiplier here - assert_eq!( - credential_entry_max_size + subject_id_max_size, - MAX_PUBLIC_CREDENTIAL_STORAGE_LENGTH as usize - ) -} - #[test] fn test_derive_did_verification_relation_ctype() { let c1 = Call::Ctype(ctype::Call::add { diff --git a/runtimes/spiritnet/src/weights/mod.rs b/runtimes/spiritnet/src/weights/mod.rs index a4e81bea0..29b65e432 100644 --- a/runtimes/spiritnet/src/weights/mod.rs +++ b/runtimes/spiritnet/src/weights/mod.rs @@ -39,4 +39,3 @@ pub mod pallet_utility; pub mod pallet_vesting; pub mod pallet_web3_names; pub mod parachain_staking; -pub mod public_credentials; diff --git a/runtimes/spiritnet/src/weights/public_credentials.rs b/runtimes/spiritnet/src/weights/public_credentials.rs deleted file mode 100644 index 7387a76f7..000000000 --- a/runtimes/spiritnet/src/weights/public_credentials.rs +++ /dev/null @@ -1,102 +0,0 @@ -// KILT Blockchain – https://botlabs.org -// Copyright (C) 2019-2022 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 public_credentials -//! -//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2022-10-26, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("spiritnet-dev"), DB CACHE: 1024 - -// Executed Command: -// ./target/release/kilt-parachain -// benchmark -// pallet -// --chain=spiritnet-dev -// --steps=50 -// --repeat=20 -// --pallet=public-credentials -// --extrinsic=* -// --execution=wasm -// --wasm-execution=compiled -// --heap-pages=4096 -// --output=./runtimes/spiritnet/src/weights/public_credentials.rs -// --template=.maintain/runtime-weight-template.hbs - -#![cfg_attr(rustfmt, rustfmt_skip)] -#![allow(unused_parens)] -#![allow(unused_imports)] -#![allow(clippy::unnecessary_cast)] - -use frame_support::{traits::Get, weights::Weight}; -use sp_std::marker::PhantomData; - -/// Weights for `public_credentials`. -pub struct WeightInfo(PhantomData); -impl public_credentials::WeightInfo for WeightInfo { - // Storage: Ctype Ctypes (r:1 w:0) - // Storage: PublicCredentials Credentials (r:1 w:1) - // Storage: System Account (r:1 w:1) - // Storage: PublicCredentials CredentialSubjects (r:0 w:1) - fn add(c: u32, ) -> Weight { - Weight::from_ref_time(72_520_000 as u64) - // Standard Error: 0 - .saturating_add(Weight::from_ref_time(2_000 as u64).saturating_mul(c as u64)) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) - } - // Storage: PublicCredentials CredentialSubjects (r:1 w:0) - // Storage: PublicCredentials Credentials (r:1 w:1) - fn revoke() -> Weight { - Weight::from_ref_time(44_494_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: PublicCredentials CredentialSubjects (r:1 w:0) - // Storage: PublicCredentials Credentials (r:1 w:1) - fn unrevoke() -> Weight { - Weight::from_ref_time(44_170_000 as u64) - .saturating_add(T::DbWeight::get().reads(2 as u64)) - .saturating_add(T::DbWeight::get().writes(1 as u64)) - } - // Storage: PublicCredentials CredentialSubjects (r:1 w:1) - // Storage: PublicCredentials Credentials (r:1 w:1) - // Storage: System Account (r:1 w:1) - fn remove() -> Weight { - Weight::from_ref_time(69_989_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) - } - // Storage: PublicCredentials CredentialSubjects (r:1 w:1) - // Storage: PublicCredentials Credentials (r:1 w:1) - // Storage: System Account (r:1 w:1) - fn reclaim_deposit() -> Weight { - Weight::from_ref_time(69_237_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) - } - fn change_deposit_owner() -> Weight { - Weight::from_ref_time(68_692_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) - } - fn update_deposit() -> Weight { - Weight::from_ref_time(68_692_000 as u64) - .saturating_add(T::DbWeight::get().reads(3 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) - } -}