diff --git a/Cargo.lock b/Cargo.lock index 0c6b1e9f21..d0dd8e8942 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7655,6 +7655,7 @@ dependencies = [ "frame-try-runtime", "hex-literal 0.3.4", "kilt-runtime-api-did", + "kilt-runtime-api-dip-provider", "kilt-runtime-api-public-credentials", "kilt-runtime-api-staking", "kilt-support", @@ -7665,7 +7666,9 @@ dependencies = [ "pallet-collective", "pallet-configuration", "pallet-democracy", + "pallet-deposit-storage", "pallet-did-lookup", + "pallet-dip-provider", "pallet-indices", "pallet-inflation", "pallet-membership", diff --git a/dip-template/runtimes/dip-provider/src/dip.rs b/dip-template/runtimes/dip-provider/src/dip.rs index a36cbd3944..5564abc13b 100644 --- a/dip-template/runtimes/dip-provider/src/dip.rs +++ b/dip-template/runtimes/dip-provider/src/dip.rs @@ -96,8 +96,11 @@ pub mod deposit { /// The additional logic to execute whenever a deposit is removed by its /// owner directly via the [`pallet_deposit_storage::Pallet`] pallet. - pub type DepositCollectorHooks = - FixedDepositCollectorViaDepositsPallet>; + pub type DepositCollectorHooks = FixedDepositCollectorViaDepositsPallet< + DipProviderDepositNamespace, + ConstU128, + (DidIdentifier, IdentityCommitmentVersion), + >; pub enum CommitmentDepositRemovalHookError { DecodeKey, diff --git a/pallets/pallet-deposit-storage/Cargo.toml b/pallets/pallet-deposit-storage/Cargo.toml index 21f4ca1653..1865c4ea8f 100644 --- a/pallets/pallet-deposit-storage/Cargo.toml +++ b/pallets/pallet-deposit-storage/Cargo.toml @@ -49,7 +49,6 @@ std = [ "frame-benchmarking?/std", "pallet-balances?/std", ] - runtime-benchmarks = [ "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", @@ -59,3 +58,4 @@ runtime-benchmarks = [ "frame-benchmarking/runtime-benchmarks", "pallet-balances/runtime-benchmarks", ] +try-runtime = [] diff --git a/pallets/pallet-deposit-storage/src/deposit.rs b/pallets/pallet-deposit-storage/src/deposit.rs index ef48f32f41..927300aad0 100644 --- a/pallets/pallet-deposit-storage/src/deposit.rs +++ b/pallets/pallet-deposit-storage/src/deposit.rs @@ -44,8 +44,8 @@ pub struct DepositEntry { /// Type implementing the [`DipProviderHooks`] hooks trait by taking a deposit /// whenever an identity commitment is stored, and releasing the deposit /// whenever an identity commitment is removed. -pub struct FixedDepositCollectorViaDepositsPallet( - PhantomData<(DepositsNamespace, FixedDepositAmount)>, +pub struct FixedDepositCollectorViaDepositsPallet( + PhantomData<(DepositsNamespace, FixedDepositAmount, DepositKey)>, ); pub enum FixedDepositCollectorViaDepositsPalletError { @@ -68,12 +68,13 @@ impl From for u16 { } } -impl DipProviderHooks - for FixedDepositCollectorViaDepositsPallet +impl DipProviderHooks + for FixedDepositCollectorViaDepositsPallet where Runtime: pallet_dip_provider::Config + Config, DepositsNamespace: Get, FixedDepositAmount: Get>, + DepositKey: From<(Runtime::Identifier, IdentityCommitmentVersion)> + Encode, { type Error = u16; @@ -84,14 +85,17 @@ where version: IdentityCommitmentVersion, ) -> Result<(), Self::Error> { let namespace = DepositsNamespace::get(); - let key = (identifier, version).encode().try_into().map_err(|_| { - log::error!( - "Failed to convert tuple ({:#?}, {version}) to BoundedVec with max length {}", - identifier, - Runtime::MaxKeyLength::get() - ); - FixedDepositCollectorViaDepositsPalletError::Internal - })?; + let key = DepositKey::from((identifier.clone(), version)) + .encode() + .try_into() + .map_err(|_| { + log::error!( + "Failed to convert tuple ({:#?}, {version}) to BoundedVec with max length {}", + identifier, + Runtime::MaxKeyLength::get() + ); + FixedDepositCollectorViaDepositsPalletError::Internal + })?; let deposit_entry = DepositEntry { deposit: Deposit { amount: FixedDepositAmount::get(), diff --git a/pallets/pallet-dip-consumer/Cargo.toml b/pallets/pallet-dip-consumer/Cargo.toml index 69695cfbee..ac4758d3f1 100644 --- a/pallets/pallet-dip-consumer/Cargo.toml +++ b/pallets/pallet-dip-consumer/Cargo.toml @@ -53,3 +53,5 @@ std = [ "frame-benchmarking?/std", "sp-runtime?/std", ] + +try-runtime = [] diff --git a/pallets/pallet-relay-store/Cargo.toml b/pallets/pallet-relay-store/Cargo.toml index 6cec553a96..724b327558 100644 --- a/pallets/pallet-relay-store/Cargo.toml +++ b/pallets/pallet-relay-store/Cargo.toml @@ -53,3 +53,4 @@ runtime-benchmarks = [ "frame-benchmarking", "sp-runtime/runtime-benchmarks", ] +try-runtime = [] diff --git a/runtimes/common/src/constants.rs b/runtimes/common/src/constants.rs index a37b989b58..0ad68f6c91 100644 --- a/runtimes/common/src/constants.rs +++ b/runtimes/common/src/constants.rs @@ -166,6 +166,22 @@ pub mod delegation { } } +pub mod deposit_storage { + // Keys is an enum with a single variant (DidIdentifier, + // IdentityCommitmentVersion) which is 32 + 2 = 34 bytes. Adding the + // discriminant byte, it totals to 35 bytes. + pub const MAX_DEPOSIT_PALLET_KEY_LENGTH: u32 = 35; +} + +pub mod dip_provider { + use super::*; + + pub const MAX_LINKED_ACCOUNTS: u32 = 10; + // Commitment are 32-byte hashes. + pub const MAX_COMMITMENT_BYTE_LENGTH: u32 = 32; + pub const COMMITMENT_DEPOSIT: Balance = deposit(1, MAX_COMMITMENT_BYTE_LENGTH); +} + pub mod staking { use super::*; diff --git a/runtimes/peregrine/Cargo.toml b/runtimes/peregrine/Cargo.toml index e4ee385029..288f22db56 100644 --- a/runtimes/peregrine/Cargo.toml +++ b/runtimes/peregrine/Cargo.toml @@ -36,9 +36,12 @@ attestation.workspace = true ctype.workspace = true delegation.workspace = true did.workspace = true +kilt-runtime-api-dip-provider.workspace = true kilt-support.workspace = true pallet-configuration.workspace = true +pallet-deposit-storage.workspace = true pallet-did-lookup.workspace = true +pallet-dip-provider.workspace = true pallet-inflation.workspace = true pallet-web3-names.workspace = true pallet-migration.workspace = true @@ -129,7 +132,9 @@ runtime-benchmarks = [ "pallet-collective/runtime-benchmarks", "pallet-configuration/runtime-benchmarks", "pallet-democracy/runtime-benchmarks", + "pallet-deposit-storage/runtime-benchmarks", "pallet-did-lookup/runtime-benchmarks", + "pallet-dip-provider/runtime-benchmarks", "pallet-indices/runtime-benchmarks", "pallet-inflation/runtime-benchmarks", "pallet-membership/runtime-benchmarks", @@ -175,6 +180,7 @@ std = [ "frame-system/std", "frame-try-runtime?/std", "kilt-runtime-api-did/std", + "kilt-runtime-api-dip-provider/std", "kilt-runtime-api-public-credentials/std", "kilt-runtime-api-staking/std", "kilt-support/std", @@ -186,7 +192,9 @@ std = [ "pallet-collective/std", "pallet-configuration/std", "pallet-democracy/std", + "pallet-deposit-storage/std", "pallet-did-lookup/std", + "pallet-dip-provider/std", "pallet-indices/std", "pallet-inflation/std", "pallet-membership/std", @@ -249,7 +257,9 @@ try-runtime = [ "pallet-collective/try-runtime", "pallet-configuration/try-runtime", "pallet-democracy/try-runtime", + "pallet-deposit-storage/try-runtime", "pallet-did-lookup/try-runtime", + "pallet-dip-provider/try-runtime", "pallet-indices/try-runtime", "pallet-inflation/try-runtime", "pallet-membership/try-runtime", diff --git a/runtimes/peregrine/src/dip/deposit.rs b/runtimes/peregrine/src/dip/deposit.rs new file mode 100644 index 0000000000..4276451390 --- /dev/null +++ b/runtimes/peregrine/src/dip/deposit.rs @@ -0,0 +1,149 @@ +// 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::{DidIdentifier, Runtime}; +use frame_support::traits::Get; +use pallet_deposit_storage::{ + traits::DepositStorageHooks, DepositEntryOf, DepositKeyOf, FixedDepositCollectorViaDepositsPallet, +}; +use pallet_dip_provider::IdentityCommitmentVersion; +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; +use runtime_common::constants::dip_provider::COMMITMENT_DEPOSIT; +use scale_info::TypeInfo; +use sp_core::{ConstU128, RuntimeDebug}; + +#[derive(Encode, Decode, MaxEncodedLen, TypeInfo, Clone, PartialEq, Eq, RuntimeDebug)] +pub enum DepositNamespace { + DipProvider, +} + +/// The namespace to use in the [`pallet_deposit_storage::Pallet`] to store +/// all deposits related to DIP commitments. +pub struct DipProviderDepositNamespace; + +impl Get for DipProviderDepositNamespace { + fn get() -> DepositNamespace { + DepositNamespace::DipProvider + } +} + +/// The various different keys that can be stored in the storage-tracking +/// pallet. +#[derive(Encode, Decode, MaxEncodedLen, TypeInfo, Clone, PartialEq, Eq, RuntimeDebug)] +pub enum DepositKey { + DipProvider { + identifier: DidIdentifier, + version: IdentityCommitmentVersion, + }, +} + +impl From<(DidIdentifier, IdentityCommitmentVersion)> for DepositKey { + fn from((identifier, version): (DidIdentifier, IdentityCommitmentVersion)) -> Self { + Self::DipProvider { identifier, version } + } +} + +/// The additional logic to execute whenever a deposit is removed by its +/// owner directly via the [`pallet_deposit_storage::Pallet`] pallet. +pub type DepositCollectorHooks = + FixedDepositCollectorViaDepositsPallet, DepositKey>; + +pub enum CommitmentDepositRemovalHookError { + DecodeKey, + Internal, +} + +impl From for u16 { + fn from(value: CommitmentDepositRemovalHookError) -> Self { + match value { + CommitmentDepositRemovalHookError::DecodeKey => 0, + CommitmentDepositRemovalHookError::Internal => u16::MAX, + } + } +} + +/// The logic to execute whenever an identity commitment is generated and +/// stored in the [`pallet_dip_provider::Pallet`] pallet. +/// +/// Upon storing and removing identity commitments, this hook will reserve +/// or release deposits from the [`pallet_deposit_storage::Pallet`] pallet. +pub struct DepositHooks; + +impl DepositStorageHooks for DepositHooks { + type Error = CommitmentDepositRemovalHookError; + + fn on_deposit_reclaimed( + _namespace: &::Namespace, + key: &DepositKeyOf, + deposit: DepositEntryOf, + ) -> Result<(), Self::Error> { + let DepositKey::DipProvider { identifier, version } = + DepositKey::decode(&mut &key[..]).map_err(|_| CommitmentDepositRemovalHookError::DecodeKey)?; + pallet_dip_provider::Pallet::::delete_identity_commitment_storage_entry( + &identifier, + // Deposit owner is the only one authorized to remove the deposit. + &deposit.deposit.owner, + version, + ) + .map_err(|_| { + log::error!( + "Should not fail to remove commitment for identifier {:#?} and version {version}", + identifier + ); + CommitmentDepositRemovalHookError::Internal + })?; + Ok(()) + } +} + +#[cfg(feature = "runtime-benchmarks")] +pub struct PalletDepositStorageBenchmarkHooks; + +#[cfg(feature = "runtime-benchmarks")] +impl pallet_deposit_storage::traits::BenchmarkHooks for PalletDepositStorageBenchmarkHooks { + fn pre_reclaim_deposit() -> ( + ::AccountId, + ::Namespace, + sp_runtime::BoundedVec::MaxKeyLength>, + ) { + let submitter = runtime_common::AccountId::from([100u8; 32]); + let namespace = DepositNamespace::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()); + } +} diff --git a/runtimes/peregrine/src/dip/mod.rs b/runtimes/peregrine/src/dip/mod.rs new file mode 100644 index 0000000000..522def8fda --- /dev/null +++ b/runtimes/peregrine/src/dip/mod.rs @@ -0,0 +1,69 @@ +// 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::{DidRawOrigin, EnsureDidOrigin}; +use frame_system::EnsureSigned; +use runtime_common::{ + constants::{deposit_storage::MAX_DEPOSIT_PALLET_KEY_LENGTH, dip_provider::MAX_LINKED_ACCOUNTS}, + dip::{did::LinkedDidInfoProvider, merkle::DidMerkleRootGenerator}, + AccountId, DidIdentifier, +}; +use sp_core::ConstU32; + +use crate::{ + dip::deposit::{DepositCollectorHooks, DepositHooks, DepositNamespace}, + Balances, Runtime, RuntimeEvent, RuntimeHoldReason, +}; + +pub(crate) mod deposit; +pub(crate) mod runtime_api; + +impl pallet_dip_provider::Config for Runtime { + // Only DID origins can submit the commitment identity tx, which will go through + // only if the DID in the origin matches the identifier specified in the tx. + type CommitOriginCheck = EnsureDidOrigin; + type CommitOrigin = DidRawOrigin; + type Identifier = DidIdentifier; + // The identity commitment is defined as the Merkle root of the linked identity + // info, as specified by the [`LinkedDidInfoProvider`]. + type IdentityCommitmentGenerator = DidMerkleRootGenerator; + // Identity info is defined as the collection of DID keys, linked accounts, and + // the optional web3name of a given DID subject. + type IdentityProvider = LinkedDidInfoProvider; + type ProviderHooks = DepositCollectorHooks; + type RuntimeEvent = RuntimeEvent; + // TODO: Change after benchmarks + type WeightInfo = (); +} + +impl pallet_deposit_storage::Config for Runtime { + #[cfg(feature = "runtime-benchmarks")] + type BenchmarkHooks = deposit::PalletDepositStorageBenchmarkHooks; + // Any signed origin can submit the tx, which will go through only if the + // deposit payer matches the signed origin. + type CheckOrigin = EnsureSigned; + // The balances pallet is used to reserve/unreserve tokens. + type Currency = Balances; + type DepositHooks = DepositHooks; + type MaxKeyLength = ConstU32; + type Namespace = DepositNamespace; + type RuntimeEvent = RuntimeEvent; + type RuntimeHoldReason = RuntimeHoldReason; + // TODO: Change after benchmarks + type WeightInfo = (); +} diff --git a/runtimes/peregrine/src/dip/runtime_api.rs b/runtimes/peregrine/src/dip/runtime_api.rs new file mode 100644 index 0000000000..dc240b612b --- /dev/null +++ b/runtimes/peregrine/src/dip/runtime_api.rs @@ -0,0 +1,54 @@ +// 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::KeyIdOf; +use pallet_did_lookup::linkable_account::LinkableAccountId; +use pallet_dip_provider::IdentityCommitmentVersion; +use parity_scale_codec::{Decode, Encode}; +use runtime_common::{ + dip::{did::LinkedDidInfoProviderError, merkle::DidMerkleProofError}, + DidIdentifier, +}; +use scale_info::TypeInfo; +use sp_std::vec::Vec; + +use crate::Runtime; + +/// Parameters for a DIP proof request. +#[derive(Encode, Decode, TypeInfo)] +pub struct DipProofRequest { + /// The subject identifier for which to generate the DIP proof. + pub(crate) identifier: DidIdentifier, + /// The DIP version. + pub(crate) version: IdentityCommitmentVersion, + /// The DID key IDs of the subject's DID Document to reveal in the DIP + /// proof. + pub(crate) keys: Vec>, + /// The list of accounts linked to the subject's DID to reveal in the + /// DIP proof. + pub(crate) accounts: Vec, + /// A flag indicating whether the web3name claimed by the DID subject + /// should revealed in the DIP proof. + pub(crate) should_include_web3_name: bool, +} + +#[derive(Encode, Decode, TypeInfo)] +pub enum DipProofError { + IdentityProvider(LinkedDidInfoProviderError), + MerkleProof(DidMerkleProofError), +} diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index f92550a3a1..fcf76aa168 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -59,6 +59,7 @@ use runtime_common::{ assets::{AssetDid, PublicCredentialsFilter}, authorization::{AuthorizationId, PalletAuthorize}, constants::{self, UnvestedFundsAllowedWithdrawReasons, EXISTENTIAL_DEPOSIT, KILT}, + dip::merkle::{CompleteMerkleProof, DidMerkleProofOf, DidMerkleRootGenerator}, errors::PublicCredentialsApiError, fees::{ToAuthor, WeightToFee}, pallet_id, AccountId, AuthorityId, Balance, BlockHashCount, BlockLength, BlockNumber, BlockWeights, DidIdentifier, @@ -78,6 +79,7 @@ pub use sp_runtime::BuildStorage; #[cfg(test)] mod tests; +mod dip; mod weights; mod xcm_config; @@ -777,8 +779,10 @@ impl InstanceFilter for ProxyType { | RuntimeCall::Ctype(..) | RuntimeCall::Delegation(..) | RuntimeCall::Democracy(..) + | RuntimeCall::DepositStorage(..) | RuntimeCall::Did(..) | RuntimeCall::DidLookup(..) + | RuntimeCall::DipProvider(..) | RuntimeCall::Indices( // Excludes `force_transfer`, and `transfer` pallet_indices::Call::claim { .. } @@ -830,6 +834,7 @@ impl InstanceFilter for ProxyType { | delegation::Call::change_deposit_owner { .. } ) | RuntimeCall::Democracy(..) + // Excludes `DepositStorage` | RuntimeCall::Did( // Excludes `reclaim_deposit` did::Call::add_key_agreement_key { .. } @@ -856,6 +861,7 @@ impl InstanceFilter for ProxyType { | pallet_did_lookup::Call::update_deposit { .. } | pallet_did_lookup::Call::change_deposit_owner { .. } ) + | RuntimeCall::DipProvider(..) | RuntimeCall::Indices(..) | RuntimeCall::Multisig(..) | RuntimeCall::ParachainStaking(..) @@ -1008,6 +1014,8 @@ construct_runtime! { Web3Names: pallet_web3_names = 68, PublicCredentials: public_credentials = 69, Migration: pallet_migration = 70, + DipProvider: pallet_dip_provider = 71, + DepositStorage: pallet_deposit_storage = 72, // Parachains pallets. Start indices at 80 to leave room. @@ -1051,6 +1059,7 @@ impl did::DeriveDidCallAuthorizationVerificationKeyRelationship for RuntimeCall RuntimeCall::Attestation { .. } => Ok(did::DidVerificationKeyRelationship::AssertionMethod), RuntimeCall::Ctype { .. } => Ok(did::DidVerificationKeyRelationship::AssertionMethod), RuntimeCall::Delegation { .. } => Ok(did::DidVerificationKeyRelationship::CapabilityDelegation), + RuntimeCall::DipProvider { .. } => Ok(did::DidVerificationKeyRelationship::Authentication), // DID creation is not allowed through the DID proxy. RuntimeCall::Did(did::Call::create { .. }) => Err(did::RelationshipDeriveError::NotCallableByDid), RuntimeCall::Did { .. } => Ok(did::DidVerificationKeyRelationship::Authentication), @@ -1147,6 +1156,8 @@ mod benches { [public_credentials, PublicCredentials] [pallet_xcm, PolkadotXcm] [pallet_migration, Migration] + [pallet_dip_provider, DipProvider] + [pallet_deposit_storage, DepositStorage] [frame_benchmarking::baseline, Baseline::] ); } @@ -1413,6 +1424,16 @@ impl_runtime_apis! { } } + impl kilt_runtime_api_dip_provider::DipProvider>, dip::runtime_api::DipProofError> for Runtime { + fn generate_proof(request: dip::runtime_api::DipProofRequest) -> Result>, dip::runtime_api::DipProofError> { + use pallet_dip_provider::traits::IdentityProvider; + + let identity_details = pallet_dip_provider::IdentityProviderOf::::retrieve(&request.identifier).map_err(dip::runtime_api::DipProofError::IdentityProvider)?; + + DidMerkleRootGenerator::::generate_proof(&identity_details, request.version, request.keys.iter(), request.should_include_web3_name, request.accounts.iter()).map_err(dip::runtime_api::DipProofError::MerkleProof) + } + } + #[cfg(feature = "runtime-benchmarks")] impl frame_benchmarking::Benchmark for Runtime { fn benchmark_metadata(extra: bool) -> ( diff --git a/runtimes/peregrine/src/tests.rs b/runtimes/peregrine/src/tests.rs index 5eab813d96..14670bf679 100644 --- a/runtimes/peregrine/src/tests.rs +++ b/runtimes/peregrine/src/tests.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::{traits::Currency, BoundedVec}; +use pallet_dip_provider::IdentityCommitmentOf; use parity_scale_codec::MaxEncodedLen; use did::DeriveDidCallAuthorizationVerificationKeyRelationship; @@ -26,8 +27,10 @@ use pallet_web3_names::{Web3NameOf, Web3OwnershipOf}; use runtime_common::{ constants::{ attestation::MAX_ATTESTATION_BYTE_LENGTH, + deposit_storage::MAX_DEPOSIT_PALLET_KEY_LENGTH, did::{MAX_KEY_LENGTH, MAX_SERVICE_ENDPOINT_BYTE_LENGTH}, did_lookup::MAX_CONNECTION_BYTE_LENGTH, + dip_provider::MAX_COMMITMENT_BYTE_LENGTH, public_credentials::MAX_PUBLIC_CREDENTIAL_STORAGE_LENGTH, web3_names::MAX_NAME_BYTE_LENGTH, MAX_INDICES_BYTE_LENGTH, @@ -35,6 +38,8 @@ use runtime_common::{ AccountId, BlockNumber, }; +use crate::dip::deposit::DepositKey; + use super::{Runtime, RuntimeCall}; #[test] @@ -118,6 +123,19 @@ fn public_credentials_storage_sizes() { ) } +#[test] +fn pallet_deposit_storage_max_key_length() { + assert_eq!(DepositKey::max_encoded_len(), MAX_DEPOSIT_PALLET_KEY_LENGTH as usize) +} + +#[test] +fn pallet_dip_provider_commitment_max_length() { + assert_eq!( + IdentityCommitmentOf::::max_encoded_len(), + MAX_COMMITMENT_BYTE_LENGTH as usize + ) +} + #[test] fn test_derive_did_verification_relation_ctype() { let c1 = RuntimeCall::Ctype(ctype::Call::add {