From e791b72fb0c5709cb428fc35f164e636b797ac4e Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Fri, 18 Mar 2022 10:47:58 +0100 Subject: [PATCH 01/30] fix: add did lookup pallet to DID authorization logic --- runtimes/peregrine/src/lib.rs | 1 + runtimes/spiritnet/src/lib.rs | 1 + runtimes/standalone/src/lib.rs | 1 + 3 files changed, 3 insertions(+) diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index cb4ea942c6..8834918881 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -927,6 +927,7 @@ 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::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[..]), #[cfg(not(feature = "runtime-benchmarks"))] diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index 6e6808d675..c548fbcb27 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -931,6 +931,7 @@ 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::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[..]), #[cfg(not(feature = "runtime-benchmarks"))] diff --git a/runtimes/standalone/src/lib.rs b/runtimes/standalone/src/lib.rs index f7f94bf3d5..2e05c60cdb 100644 --- a/runtimes/standalone/src/lib.rs +++ b/runtimes/standalone/src/lib.rs @@ -669,6 +669,7 @@ 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::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[..]), #[cfg(not(feature = "runtime-benchmarks"))] From 7f0c05be2d034c73e8c3ea09ad66911e14a9a6fa Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Fri, 18 Mar 2022 11:27:18 +0100 Subject: [PATCH 02/30] test: add unit tests for spiritnet and peregrine runtimes for correct DID verification key derivation --- runtimes/peregrine/src/tests.rs | 33 +++++++++++++++++++++++++++++++-- runtimes/spiritnet/src/tests.rs | 29 +++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/runtimes/peregrine/src/tests.rs b/runtimes/peregrine/src/tests.rs index 3a6fe68b8f..aceb6317de 100644 --- a/runtimes/peregrine/src/tests.rs +++ b/runtimes/peregrine/src/tests.rs @@ -22,10 +22,10 @@ use frame_support::{traits::Currency, BoundedVec}; use did::DeriveDidCallAuthorizationVerificationKeyRelationship; use pallet_treasury::BalanceOf; use pallet_web3_names::{Web3NameOf, Web3OwnershipOf}; -use runtime_common::constants::{ +use runtime_common::{constants::{ attestation::MAX_ATTESTATION_BYTE_LENGTH, did::MAX_DID_BYTE_LENGTH, did_lookup::MAX_CONNECTION_BYTE_LENGTH, web3_names::MAX_NAME_BYTE_LENGTH, MAX_INDICES_BYTE_LENGTH, -}; +}, AccountId, BlockNumber}; use super::{Call, Runtime}; @@ -121,6 +121,35 @@ fn test_derive_did_verification_relation_ctype() { ); } +#[test] +fn test_derive_did_key_web3name() { + assert_eq!( + Call::Web3Names(pallet_web3_names::Call::claim { + name: b"test-name".to_vec().try_into().unwrap() + }) + .derive_verification_key_relationship(), + Ok(did::DidVerificationKeyRelationship::Authentication) + ); + + assert_eq!( + Call::Web3Names(pallet_web3_names::Call::release_by_owner {}).derive_verification_key_relationship(), + Ok(did::DidVerificationKeyRelationship::Authentication) + ); +} + +#[test] +fn test_derive_did_key_lookup() { + assert_eq!(Call::DidLookup(pallet_did_lookup::Call::associate_account { + account: AccountId::new([1u8; 32]), + expiration: BlockNumber::default(), + proof: sp_runtime::MultiSignature::from(sp_core::ed25519::Signature([0; 64])), + }).derive_verification_key_relationship(), Ok(did::DidVerificationKeyRelationship::Authentication)); + + assert_eq!(Call::DidLookup(pallet_did_lookup::Call::remove_account_association { + account: AccountId::new([1u8; 32]), + }).derive_verification_key_relationship(), Ok(did::DidVerificationKeyRelationship::Authentication)); +} + #[test] fn test_derive_did_verification_relation_fail() { let c1 = Call::Ctype(ctype::Call::add { diff --git a/runtimes/spiritnet/src/tests.rs b/runtimes/spiritnet/src/tests.rs index 02a2e92fd9..3d099a89c9 100644 --- a/runtimes/spiritnet/src/tests.rs +++ b/runtimes/spiritnet/src/tests.rs @@ -121,6 +121,35 @@ fn test_derive_did_verification_relation_ctype() { ); } +#[test] +fn test_derive_did_key_web3name() { + assert_eq!( + Call::Web3Names(pallet_web3_names::Call::claim { + name: b"test-name".to_vec().try_into().unwrap() + }) + .derive_verification_key_relationship(), + Ok(did::DidVerificationKeyRelationship::Authentication) + ); + + assert_eq!( + Call::Web3Names(pallet_web3_names::Call::release_by_owner {}).derive_verification_key_relationship(), + Ok(did::DidVerificationKeyRelationship::Authentication) + ); +} + +#[test] +fn test_derive_did_key_lookup() { + assert_eq!(Call::DidLookup(pallet_did_lookup::Call::associate_account { + account: AccountId::new([1u8; 32]), + expiration: BlockNumber::default(), + proof: sp_runtime::MultiSignature::from(sp_core::ed25519::Signature([0; 64])), + }).derive_verification_key_relationship(), Ok(did::DidVerificationKeyRelationship::Authentication)); + + assert_eq!(Call::DidLookup(pallet_did_lookup::Call::remove_account_association { + account: AccountId::new([1u8; 32]), + }).derive_verification_key_relationship(), Ok(did::DidVerificationKeyRelationship::Authentication)); +} + #[test] fn test_derive_did_verification_relation_fail() { let c1 = Call::Ctype(ctype::Call::add { From de6e2e549642d04ffef08e2a6b88dec5cf3c1c99 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Fri, 18 Mar 2022 13:38:20 +0100 Subject: [PATCH 03/30] chore: clippy --- runtimes/peregrine/src/tests.rs | 33 ++++++++++++++++++++++----------- runtimes/spiritnet/src/tests.rs | 29 ++++++++++++++++++++--------- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/runtimes/peregrine/src/tests.rs b/runtimes/peregrine/src/tests.rs index aceb6317de..d9e3b1b699 100644 --- a/runtimes/peregrine/src/tests.rs +++ b/runtimes/peregrine/src/tests.rs @@ -22,10 +22,13 @@ use frame_support::{traits::Currency, BoundedVec}; use did::DeriveDidCallAuthorizationVerificationKeyRelationship; use pallet_treasury::BalanceOf; use pallet_web3_names::{Web3NameOf, Web3OwnershipOf}; -use runtime_common::{constants::{ +use runtime_common::constants::{ attestation::MAX_ATTESTATION_BYTE_LENGTH, did::MAX_DID_BYTE_LENGTH, did_lookup::MAX_CONNECTION_BYTE_LENGTH, web3_names::MAX_NAME_BYTE_LENGTH, MAX_INDICES_BYTE_LENGTH, -}, AccountId, BlockNumber}; +}; + +#[cfg(test)] +use runtime_common::{AccountId, BlockNumber}; use super::{Call, Runtime}; @@ -139,15 +142,23 @@ fn test_derive_did_key_web3name() { #[test] fn test_derive_did_key_lookup() { - assert_eq!(Call::DidLookup(pallet_did_lookup::Call::associate_account { - account: AccountId::new([1u8; 32]), - expiration: BlockNumber::default(), - proof: sp_runtime::MultiSignature::from(sp_core::ed25519::Signature([0; 64])), - }).derive_verification_key_relationship(), Ok(did::DidVerificationKeyRelationship::Authentication)); - - assert_eq!(Call::DidLookup(pallet_did_lookup::Call::remove_account_association { - account: AccountId::new([1u8; 32]), - }).derive_verification_key_relationship(), Ok(did::DidVerificationKeyRelationship::Authentication)); + assert_eq!( + Call::DidLookup(pallet_did_lookup::Call::associate_account { + account: AccountId::new([1u8; 32]), + expiration: BlockNumber::default(), + proof: sp_runtime::MultiSignature::from(sp_core::ed25519::Signature([0; 64])), + }) + .derive_verification_key_relationship(), + Ok(did::DidVerificationKeyRelationship::Authentication) + ); + + assert_eq!( + Call::DidLookup(pallet_did_lookup::Call::remove_account_association { + account: AccountId::new([1u8; 32]), + }) + .derive_verification_key_relationship(), + Ok(did::DidVerificationKeyRelationship::Authentication) + ); } #[test] diff --git a/runtimes/spiritnet/src/tests.rs b/runtimes/spiritnet/src/tests.rs index 3d099a89c9..d056ed6980 100644 --- a/runtimes/spiritnet/src/tests.rs +++ b/runtimes/spiritnet/src/tests.rs @@ -27,6 +27,9 @@ use runtime_common::constants::{ web3_names::MAX_NAME_BYTE_LENGTH, MAX_INDICES_BYTE_LENGTH, }; +#[cfg(test)] +use runtime_common::{AccountId, BlockNumber}; + use super::{Call, Runtime}; #[test] @@ -139,15 +142,23 @@ fn test_derive_did_key_web3name() { #[test] fn test_derive_did_key_lookup() { - assert_eq!(Call::DidLookup(pallet_did_lookup::Call::associate_account { - account: AccountId::new([1u8; 32]), - expiration: BlockNumber::default(), - proof: sp_runtime::MultiSignature::from(sp_core::ed25519::Signature([0; 64])), - }).derive_verification_key_relationship(), Ok(did::DidVerificationKeyRelationship::Authentication)); - - assert_eq!(Call::DidLookup(pallet_did_lookup::Call::remove_account_association { - account: AccountId::new([1u8; 32]), - }).derive_verification_key_relationship(), Ok(did::DidVerificationKeyRelationship::Authentication)); + assert_eq!( + Call::DidLookup(pallet_did_lookup::Call::associate_account { + account: AccountId::new([1u8; 32]), + expiration: BlockNumber::default(), + proof: sp_runtime::MultiSignature::from(sp_core::ed25519::Signature([0; 64])), + }) + .derive_verification_key_relationship(), + Ok(did::DidVerificationKeyRelationship::Authentication) + ); + + assert_eq!( + Call::DidLookup(pallet_did_lookup::Call::remove_account_association { + account: AccountId::new([1u8; 32]), + }) + .derive_verification_key_relationship(), + Ok(did::DidVerificationKeyRelationship::Authentication) + ); } #[test] From 80e9a4ea1a796c70850c1c70f151a62d8351d5b5 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Fri, 18 Mar 2022 13:53:21 +0100 Subject: [PATCH 04/30] feat: add additional map for reverse index --- pallets/pallet-did-lookup/src/lib.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pallets/pallet-did-lookup/src/lib.rs b/pallets/pallet-did-lookup/src/lib.rs index 81f81ea341..54b21b6164 100644 --- a/pallets/pallet-did-lookup/src/lib.rs +++ b/pallets/pallet-did-lookup/src/lib.rs @@ -70,7 +70,7 @@ pub mod pallet { /// The connection record type. pub(crate) type ConnectionRecordOf = ConnectionRecord, AccountIdOf, BalanceOf>; - pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); + pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); #[pallet::config] pub trait Config: frame_system::Config { @@ -108,7 +108,12 @@ pub mod pallet { /// Mapping from account identifiers to DIDs. #[pallet::storage] #[pallet::getter(fn connected_dids)] - pub type ConnectedDids = StorageMap<_, Blake2_128Concat, AccountIdOf, ConnectionRecordOf>; + pub type ConnectedDids = CountedStorageMap<_, Blake2_128Concat, AccountIdOf, ConnectionRecordOf>; + + /// Mapping from account identifiers to DIDs. + #[pallet::storage] + #[pallet::getter(fn connected_accounts)] + pub type ConnectedAccounts = StorageDoubleMap<_, Blake2_128Concat, DidIdentifierOf, Blake2_128Concat, AccountIdOf, ()>; #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] @@ -129,7 +134,7 @@ pub mod pallet { /// and the account ID. NotAuthorized, - /// The supplied proof of ownership was outdated and will not + /// The supplied proof of ownership was outdated. OutdatedProof, /// The account has insufficient funds and can't pay the fees or reserve @@ -298,6 +303,7 @@ pub mod pallet { kilt_support::free_deposit::, CurrencyOf>(&old_did.deposit); } }); + ConnectedAccounts::::insert(&did_identifier, &account, ()); Self::deposit_event(Event::AssociationEstablished(account, did_identifier)); Ok(()) @@ -305,6 +311,7 @@ pub mod pallet { pub(crate) fn remove_association(account: AccountIdOf) -> DispatchResult { if let Some(connection) = ConnectedDids::::take(&account) { + ConnectedAccounts::::remove(&connection.did, &account); kilt_support::free_deposit::, CurrencyOf>(&connection.deposit); Self::deposit_event(Event::AssociationRemoved(account, connection.did)); From 9bea6cfa6b23f656361ffd966024539643b4c9b5 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Fri, 18 Mar 2022 14:18:38 +0100 Subject: [PATCH 05/30] test: add unit tests --- pallets/pallet-did-lookup/src/lib.rs | 7 +++--- pallets/pallet-did-lookup/src/tests.rs | 32 +++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/pallets/pallet-did-lookup/src/lib.rs b/pallets/pallet-did-lookup/src/lib.rs index 54b21b6164..b37cf3c28d 100644 --- a/pallets/pallet-did-lookup/src/lib.rs +++ b/pallets/pallet-did-lookup/src/lib.rs @@ -298,9 +298,10 @@ pub mod pallet { CurrencyOf::::reserve(&record.deposit.owner, record.deposit.amount)?; ConnectedDids::::mutate(&account, |did_entry| { - if let Some(old_did) = did_entry.replace(record) { - Self::deposit_event(Event::::AssociationRemoved(account.clone(), old_did.did)); - kilt_support::free_deposit::, CurrencyOf>(&old_did.deposit); + if let Some(old_connection) = did_entry.replace(record) { + ConnectedAccounts::::remove(&old_connection.did, &account); + Self::deposit_event(Event::::AssociationRemoved(account.clone(), old_connection.did)); + kilt_support::free_deposit::, CurrencyOf>(&old_connection.deposit); } }); ConnectedAccounts::::insert(&did_identifier, &account, ()); diff --git a/pallets/pallet-did-lookup/src/tests.rs b/pallets/pallet-did-lookup/src/tests.rs index 48acdcd0e7..f960428722 100644 --- a/pallets/pallet-did-lookup/src/tests.rs +++ b/pallets/pallet-did-lookup/src/tests.rs @@ -26,7 +26,7 @@ use sp_runtime::{ MultiSignature, MultiSigner, }; -use crate::{mock::*, ConnectedDids, ConnectionRecord, Error}; +use crate::{mock::*, ConnectedDids, ConnectionRecord, Error, ConnectedAccounts}; #[test] fn test_add_association_sender() { @@ -46,6 +46,9 @@ fn test_add_association_sender() { } }) ); + assert!( + ConnectedAccounts::::get(DID_00, ACCOUNT_00).is_some() + ); assert_eq!( Balances::reserved_balance(ACCOUNT_00), ::Deposit::get() @@ -63,6 +66,12 @@ fn test_add_association_sender() { } }) ); + assert!( + ConnectedAccounts::::get(DID_00, ACCOUNT_00).is_none() + ); + assert!( + ConnectedAccounts::::get(DID_01, ACCOUNT_00).is_some() + ); assert_eq!( Balances::reserved_balance(ACCOUNT_00), ::Deposit::get() @@ -100,6 +109,9 @@ fn test_add_association_account() { } }) ); + assert!( + ConnectedAccounts::::get(DID_00, &account_hash_alice).is_some() + ); assert_eq!( Balances::reserved_balance(ACCOUNT_00), ::Deposit::get() @@ -123,6 +135,12 @@ fn test_add_association_account() { } }) ); + assert!( + ConnectedAccounts::::get(DID_00, &account_hash_alice).is_none() + ); + assert!( + ConnectedAccounts::::get(DID_01, &account_hash_alice).is_some() + ); assert_eq!( Balances::reserved_balance(ACCOUNT_00), ::Deposit::get() @@ -146,6 +164,12 @@ fn test_add_association_account() { } }) ); + assert!( + ConnectedAccounts::::get(DID_00, &account_hash_alice).is_none() + ); + assert!( + ConnectedAccounts::::get(DID_01, &account_hash_alice).is_some() + ); assert_eq!(Balances::reserved_balance(ACCOUNT_00), 0); assert_eq!( Balances::reserved_balance(ACCOUNT_01), @@ -211,6 +235,9 @@ fn test_remove_association_sender() { // remove association assert!(DidLookup::remove_sender_association(Origin::signed(ACCOUNT_00)).is_ok()); assert_eq!(ConnectedDids::::get(ACCOUNT_00), None); + assert!( + ConnectedAccounts::::get(DID_01, ACCOUNT_00).is_none() + ); assert_eq!(Balances::reserved_balance(ACCOUNT_00), 0); }); } @@ -241,6 +268,9 @@ fn test_remove_association_account() { ) .is_ok()); assert_eq!(ConnectedDids::::get(ACCOUNT_00), None); + assert!( + ConnectedAccounts::::get(DID_01, ACCOUNT_00).is_none() + ); assert_eq!(Balances::reserved_balance(ACCOUNT_01), 0); }); } From 5377124ede1d43fcfcc63b01f962f4afd04a577c Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Fri, 18 Mar 2022 14:22:53 +0100 Subject: [PATCH 06/30] chore: update benchmarks checks --- pallets/pallet-did-lookup/src/benchmarking.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pallets/pallet-did-lookup/src/benchmarking.rs b/pallets/pallet-did-lookup/src/benchmarking.rs index 13e4ba10d5..8df55c1004 100644 --- a/pallets/pallet-did-lookup/src/benchmarking.rs +++ b/pallets/pallet-did-lookup/src/benchmarking.rs @@ -57,10 +57,11 @@ benchmarks! { .into(); make_free_for_did::(&caller); - let origin = T::EnsureOrigin::generate_origin(caller, did); + let origin = T::EnsureOrigin::generate_origin(caller, did.clone()); }: _(origin, connected_acc_id, bn, sig) verify { assert!(ConnectedDids::::get(T::AccountId::from(connected_acc)).is_some()); + assert!(ConnectedAccounts::::get(did, T::AccountId::from(connected_acc)).is_some()); } associate_sender { @@ -68,10 +69,11 @@ benchmarks! { let did: T::DidIdentifier = account("did", 0, SEED); make_free_for_did::(&caller); - let origin = T::EnsureOrigin::generate_origin(caller.clone(), did); + let origin = T::EnsureOrigin::generate_origin(caller.clone(), did.clone()); }: _(origin) verify { assert!(ConnectedDids::::get(caller).is_some()); + assert!(ConnectedAccounts::::get(did, caller).is_some()); } remove_sender_association { @@ -79,12 +81,13 @@ benchmarks! { let did: T::DidIdentifier = account("did", 0, SEED); make_free_for_did::(&caller); - Pallet::::add_association(caller.clone(), did, caller.clone()).expect("should create association"); + Pallet::::add_association(caller.clone(), did.clone(), caller.clone()).expect("should create association"); let origin = RawOrigin::Signed(caller.clone()); }: _(origin) verify { assert!(ConnectedDids::::get(caller).is_none()); + assert!(ConnectedAccounts::::get(did, caller).is_none()); } remove_account_association { @@ -94,10 +97,12 @@ benchmarks! { Pallet::::add_association(caller.clone(), did.clone(), caller.clone()).expect("should create association"); - let origin = T::EnsureOrigin::generate_origin(caller.clone(), did); - }: _(origin, caller.clone()) + let origin = T::EnsureOrigin::generate_origin(caller.clone(), did.clone()); + let caller_clone = caller.clone(); + }: _(origin, caller_clone) verify { assert!(ConnectedDids::::get(caller).is_none()); + assert!(ConnectedAccounts::::get(did, caller).is_none()); } } From 8fd08ddab22cec2e952a0eb26d5adb3d84ab903a Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Fri, 18 Mar 2022 15:14:43 +0100 Subject: [PATCH 07/30] wip: runtime upgrade scripts --- runtimes/peregrine/src/lib.rs | 2 ++ runtimes/peregrine/src/migrations/mod.rs | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 runtimes/peregrine/src/migrations/mod.rs diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index 8834918881..8b535a15e8 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -67,6 +67,8 @@ mod tests; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; +mod migrations; + mod weights; impl_opaque_keys! { diff --git a/runtimes/peregrine/src/migrations/mod.rs b/runtimes/peregrine/src/migrations/mod.rs new file mode 100644 index 0000000000..038bf13ad0 --- /dev/null +++ b/runtimes/peregrine/src/migrations/mod.rs @@ -0,0 +1,22 @@ +use frame_support::traits::OnRuntimeUpgrade; +use sp_std::marker::PhantomData; + +pub struct LookupReverseIndexMigration(PhantomData); + +impl OnRuntimeUpgrade for LookupReverseIndexMigration { + + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result<(), &'static str> { + assert_eq!(DidLookup::::) + assert_eq!(DidLookup::::connected_accounts().iter().count(), 0); + } + + fn on_runtime_upgrade() -> frame_support::weights::Weight { + 0 + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade() -> Result<(), &'static str> { + Ok(()) + } +} From edc254ff707782caecede31a5c6519f1378ded0e Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Fri, 18 Mar 2022 16:24:05 +0100 Subject: [PATCH 08/30] wip: lookup pallet migration --- runtimes/peregrine/src/migrations/mod.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/runtimes/peregrine/src/migrations/mod.rs b/runtimes/peregrine/src/migrations/mod.rs index 038bf13ad0..3aa30f6069 100644 --- a/runtimes/peregrine/src/migrations/mod.rs +++ b/runtimes/peregrine/src/migrations/mod.rs @@ -1,22 +1,28 @@ +use crate::{DidLookup, Runtime}; use frame_support::traits::OnRuntimeUpgrade; use sp_std::marker::PhantomData; +// #[cfg(feature = "try-runtime")] +use frame_support::traits::GetStorageVersion; + pub struct LookupReverseIndexMigration(PhantomData); impl OnRuntimeUpgrade for LookupReverseIndexMigration { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result<(), &'static str> { - assert_eq!(DidLookup::::) + assert_eq!(DidLookup::on_chain_storage_version().saturating_add(1), DidLookup::on_chain_storage_version()); assert_eq!(DidLookup::::connected_accounts().iter().count(), 0); } fn on_runtime_upgrade() -> frame_support::weights::Weight { - 0 + // TODO: Populate the ConnectedAccounts map and set the new storage version + 0u64 } #[cfg(feature = "try-runtime")] fn post_upgrade() -> Result<(), &'static str> { + // TODO: Verify that the ConnectedAccounts map contains the same number of elements as the map and that the on-chain and runtime storage versions match. Ok(()) } } From ce702477eca4595c174f52dc89e0cb7993acdd7a Mon Sep 17 00:00:00 2001 From: Antonio Date: Wed, 16 Mar 2022 13:39:05 +0100 Subject: [PATCH 09/30] chore: update toolchain version to nightly 1.59 (#339) * chore: bump up toolchain to nightly 1.59 * chore: address Clippy warnings --- pallets/attestation/src/mock.rs | 19 +++++++++++++++++-- pallets/delegation/src/mock.rs | 12 +++--------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/pallets/attestation/src/mock.rs b/pallets/attestation/src/mock.rs index 51665c2b28..05d7eccf99 100644 --- a/pallets/attestation/src/mock.rs +++ b/pallets/attestation/src/mock.rs @@ -324,7 +324,22 @@ pub(crate) mod runtime { impl ExtBuilder { #[must_use] - pub fn with_ctypes(mut self, ctypes: Vec<(CtypeHashOf, CtypeCreatorOf)>) -> Self { + pub fn with_delegation_hierarchies( + mut self, + delegation_hierarchies: DelegationHierarchyInitialization, + ) -> Self { + self.delegation_hierarchies = delegation_hierarchies; + self + } + + #[must_use] + pub fn with_delegations(mut self, delegations: Vec<(TestDelegationNodeId, DelegationNode)>) -> Self { + self.delegations = delegations; + self + } + + #[must_use] + pub fn with_ctypes(mut self, ctypes: Vec<(TestCtypeHash, CtypeCreatorOf)>) -> Self { self.ctypes = ctypes; self } @@ -336,7 +351,7 @@ pub(crate) mod runtime { } #[must_use] - pub fn with_attestations(mut self, attestations: Vec<(ClaimHashOf, AttestationDetails)>) -> Self { + pub fn with_attestations(mut self, attestations: Vec<(TestClaimHash, AttestationDetails)>) -> Self { self.attestations = attestations; self } diff --git a/pallets/delegation/src/mock.rs b/pallets/delegation/src/mock.rs index b096f56a8f..e2dbc6fe23 100644 --- a/pallets/delegation/src/mock.rs +++ b/pallets/delegation/src/mock.rs @@ -464,20 +464,14 @@ pub(crate) mod runtime { } #[must_use] - pub fn with_ctypes(mut self, ctypes: Vec<(CtypeHashOf, SubjectId)>) -> Self { + pub fn with_ctypes(mut self, ctypes: Vec<(TestCtypeHash, SubjectId)>) -> Self { self.ctypes = ctypes; self } #[must_use] - pub fn with_delegations(mut self, delegations: Vec<(DelegationNodeIdOf, DelegationNode)>) -> Self { - self.delegations = delegations; - self - } - - #[must_use] - pub fn with_attestations(mut self, attestations: Vec<(ClaimHashOf, AttestationDetails)>) -> Self { - self.attestations = attestations; + pub fn with_delegations(mut self, delegations: Vec<(TestDelegationNodeId, DelegationNode)>) -> Self { + self.delegations_stored = delegations; self } From 53f4170262c12547fff3c8bbceb0772bd6c37214 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Mon, 21 Mar 2022 13:59:34 +0100 Subject: [PATCH 10/30] wip: benchmarks --- pallets/pallet-did-lookup/src/benchmarking.rs | 8 ++--- runtimes/peregrine/src/migrations/mod.rs | 34 ++++++++++++++----- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/pallets/pallet-did-lookup/src/benchmarking.rs b/pallets/pallet-did-lookup/src/benchmarking.rs index 8df55c1004..81a402731a 100644 --- a/pallets/pallet-did-lookup/src/benchmarking.rs +++ b/pallets/pallet-did-lookup/src/benchmarking.rs @@ -19,7 +19,7 @@ //! Benchmarking -use crate::{AccountIdOf, Call, Config, ConnectedDids, CurrencyOf, Pallet}; +use crate::{AccountIdOf, Call, Config, ConnectedAccounts, ConnectedDids, CurrencyOf, Pallet}; use codec::Encode; use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite}; @@ -72,7 +72,7 @@ benchmarks! { let origin = T::EnsureOrigin::generate_origin(caller.clone(), did.clone()); }: _(origin) verify { - assert!(ConnectedDids::::get(caller).is_some()); + assert!(ConnectedDids::::get(&caller).is_some()); assert!(ConnectedAccounts::::get(did, caller).is_some()); } @@ -86,7 +86,7 @@ benchmarks! { let origin = RawOrigin::Signed(caller.clone()); }: _(origin) verify { - assert!(ConnectedDids::::get(caller).is_none()); + assert!(ConnectedDids::::get(&caller).is_none()); assert!(ConnectedAccounts::::get(did, caller).is_none()); } @@ -101,7 +101,7 @@ benchmarks! { let caller_clone = caller.clone(); }: _(origin, caller_clone) verify { - assert!(ConnectedDids::::get(caller).is_none()); + assert!(ConnectedDids::::get(&caller).is_none()); assert!(ConnectedAccounts::::get(did, caller).is_none()); } } diff --git a/runtimes/peregrine/src/migrations/mod.rs b/runtimes/peregrine/src/migrations/mod.rs index 3aa30f6069..1e056a34f1 100644 --- a/runtimes/peregrine/src/migrations/mod.rs +++ b/runtimes/peregrine/src/migrations/mod.rs @@ -1,8 +1,8 @@ -use crate::{DidLookup, Runtime}; -use frame_support::traits::OnRuntimeUpgrade; +use crate::{DidLookup, Runtime, Weight}; +use frame_support::traits::{OnRuntimeUpgrade, StorageVersion as NewStorageVersion}; use sp_std::marker::PhantomData; -// #[cfg(feature = "try-runtime")] +#[cfg(feature = "try-runtime")] use frame_support::traits::GetStorageVersion; pub struct LookupReverseIndexMigration(PhantomData); @@ -11,18 +11,36 @@ impl OnRuntimeUpgrade for LookupReverseIndexMigration { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result<(), &'static str> { - assert_eq!(DidLookup::on_chain_storage_version().saturating_add(1), DidLookup::on_chain_storage_version()); + assert_ne!(DidLookup::on_chain_storage_version(), DidLookup::current_storage_version()); assert_eq!(DidLookup::::connected_accounts().iter().count(), 0); } fn on_runtime_upgrade() -> frame_support::weights::Weight { - // TODO: Populate the ConnectedAccounts map and set the new storage version - 0u64 + // Account for the new storage version written below. + let mut total_weight: Weight = Runtime::DbWeight::get().write(1); + + pallet_did_lookup::ConnectedDids::::iter().for_each(|(account, record)| { + pallet_did_lookup::ConnectedAccounts::::insert(record.did, account, ()); + // One read for the `ConnectedDids` entry, one write for the new `ConnectedAccounts` entry. + total_weight = total_weight.saturating_add(Runtime::DbWeight::get().reads_writes(1, 1)) + }); + + NewStorageVersion::new(DidLookup::current_storage_version()).put::(); + + total_weight } #[cfg(feature = "try-runtime")] fn post_upgrade() -> Result<(), &'static str> { - // TODO: Verify that the ConnectedAccounts map contains the same number of elements as the map and that the on-chain and runtime storage versions match. - Ok(()) + assert_eq!(DidLookup::on_chain_storage_version(), DidLookup::current_storage_version()); + + // Verify DID -> Account integrity. + pallet_did_lookup::ConnectedDids::::iter().for_each(|(account, record)| { + assert!(pallet_did_lookup::ConnectedAccounts::::contains_key(record.did, account)); + }); + // Verify Account -> DID integrity. + pallet_did_lookup::ConnectedAccounts::::iter().for_each(|(did, account, _)| { + assert!(pallet_did_lookup::ConnectedDids::::contains_key(did, account)); + }); } } From 9cd44d2c810cb27256b6fbecc4c6859ab7f01420 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Mon, 21 Mar 2022 14:23:37 +0100 Subject: [PATCH 11/30] bench: benchmark compiling --- runtimes/peregrine/src/migrations/mod.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/runtimes/peregrine/src/migrations/mod.rs b/runtimes/peregrine/src/migrations/mod.rs index 1e056a34f1..2a45aee997 100644 --- a/runtimes/peregrine/src/migrations/mod.rs +++ b/runtimes/peregrine/src/migrations/mod.rs @@ -1,5 +1,5 @@ use crate::{DidLookup, Runtime, Weight}; -use frame_support::traits::{OnRuntimeUpgrade, StorageVersion as NewStorageVersion}; +use frame_support::traits::OnRuntimeUpgrade; use sp_std::marker::PhantomData; #[cfg(feature = "try-runtime")] @@ -12,20 +12,22 @@ impl OnRuntimeUpgrade for LookupReverseIndexMigration { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result<(), &'static str> { assert_ne!(DidLookup::on_chain_storage_version(), DidLookup::current_storage_version()); - assert_eq!(DidLookup::::connected_accounts().iter().count(), 0); + assert_eq!(pallet_did_lookup::ConnectedAccounts::::iter().count(), 0); + + Ok(()) } fn on_runtime_upgrade() -> frame_support::weights::Weight { // Account for the new storage version written below. - let mut total_weight: Weight = Runtime::DbWeight::get().write(1); + let mut total_weight: Weight = ::DbWeight::get().writes(1); pallet_did_lookup::ConnectedDids::::iter().for_each(|(account, record)| { pallet_did_lookup::ConnectedAccounts::::insert(record.did, account, ()); // One read for the `ConnectedDids` entry, one write for the new `ConnectedAccounts` entry. - total_weight = total_weight.saturating_add(Runtime::DbWeight::get().reads_writes(1, 1)) + total_weight = total_weight.saturating_add(::DbWeight::get().reads_writes(1, 1)) }); - NewStorageVersion::new(DidLookup::current_storage_version()).put::(); + DidLookup::current_storage_version().put::(); total_weight } @@ -40,7 +42,10 @@ impl OnRuntimeUpgrade for LookupReverseIndexMigration { }); // Verify Account -> DID integrity. pallet_did_lookup::ConnectedAccounts::::iter().for_each(|(did, account, _)| { - assert!(pallet_did_lookup::ConnectedDids::::contains_key(did, account)); + let entry = pallet_did_lookup::ConnectedDids::::get(account).expect("Should find a record for the given account."); + assert_eq!(entry.did, did); }); + + Ok(()) } } From a73b61f0192b6304bc23d213bb7bb80ab90fcc41 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Mon, 21 Mar 2022 15:18:15 +0100 Subject: [PATCH 12/30] chore: try-runtime complete --- pallets/pallet-did-lookup/src/lib.rs | 3 +- pallets/pallet-did-lookup/src/tests.rs | 42 +++++-------------- runtimes/peregrine/src/migrations/mod.rs | 53 ++++++++++++++++++------ 3 files changed, 53 insertions(+), 45 deletions(-) diff --git a/pallets/pallet-did-lookup/src/lib.rs b/pallets/pallet-did-lookup/src/lib.rs index b37cf3c28d..463fd1632c 100644 --- a/pallets/pallet-did-lookup/src/lib.rs +++ b/pallets/pallet-did-lookup/src/lib.rs @@ -113,7 +113,8 @@ pub mod pallet { /// Mapping from account identifiers to DIDs. #[pallet::storage] #[pallet::getter(fn connected_accounts)] - pub type ConnectedAccounts = StorageDoubleMap<_, Blake2_128Concat, DidIdentifierOf, Blake2_128Concat, AccountIdOf, ()>; + pub type ConnectedAccounts = + StorageDoubleMap<_, Blake2_128Concat, DidIdentifierOf, Blake2_128Concat, AccountIdOf, ()>; #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] diff --git a/pallets/pallet-did-lookup/src/tests.rs b/pallets/pallet-did-lookup/src/tests.rs index f960428722..db8802a70b 100644 --- a/pallets/pallet-did-lookup/src/tests.rs +++ b/pallets/pallet-did-lookup/src/tests.rs @@ -26,7 +26,7 @@ use sp_runtime::{ MultiSignature, MultiSigner, }; -use crate::{mock::*, ConnectedDids, ConnectionRecord, Error, ConnectedAccounts}; +use crate::{mock::*, ConnectedAccounts, ConnectedDids, ConnectionRecord, Error}; #[test] fn test_add_association_sender() { @@ -46,9 +46,7 @@ fn test_add_association_sender() { } }) ); - assert!( - ConnectedAccounts::::get(DID_00, ACCOUNT_00).is_some() - ); + assert!(ConnectedAccounts::::get(DID_00, ACCOUNT_00).is_some()); assert_eq!( Balances::reserved_balance(ACCOUNT_00), ::Deposit::get() @@ -66,12 +64,8 @@ fn test_add_association_sender() { } }) ); - assert!( - ConnectedAccounts::::get(DID_00, ACCOUNT_00).is_none() - ); - assert!( - ConnectedAccounts::::get(DID_01, ACCOUNT_00).is_some() - ); + assert!(ConnectedAccounts::::get(DID_00, ACCOUNT_00).is_none()); + assert!(ConnectedAccounts::::get(DID_01, ACCOUNT_00).is_some()); assert_eq!( Balances::reserved_balance(ACCOUNT_00), ::Deposit::get() @@ -109,9 +103,7 @@ fn test_add_association_account() { } }) ); - assert!( - ConnectedAccounts::::get(DID_00, &account_hash_alice).is_some() - ); + assert!(ConnectedAccounts::::get(DID_00, &account_hash_alice).is_some()); assert_eq!( Balances::reserved_balance(ACCOUNT_00), ::Deposit::get() @@ -135,12 +127,8 @@ fn test_add_association_account() { } }) ); - assert!( - ConnectedAccounts::::get(DID_00, &account_hash_alice).is_none() - ); - assert!( - ConnectedAccounts::::get(DID_01, &account_hash_alice).is_some() - ); + assert!(ConnectedAccounts::::get(DID_00, &account_hash_alice).is_none()); + assert!(ConnectedAccounts::::get(DID_01, &account_hash_alice).is_some()); assert_eq!( Balances::reserved_balance(ACCOUNT_00), ::Deposit::get() @@ -164,12 +152,8 @@ fn test_add_association_account() { } }) ); - assert!( - ConnectedAccounts::::get(DID_00, &account_hash_alice).is_none() - ); - assert!( - ConnectedAccounts::::get(DID_01, &account_hash_alice).is_some() - ); + assert!(ConnectedAccounts::::get(DID_00, &account_hash_alice).is_none()); + assert!(ConnectedAccounts::::get(DID_01, &account_hash_alice).is_some()); assert_eq!(Balances::reserved_balance(ACCOUNT_00), 0); assert_eq!( Balances::reserved_balance(ACCOUNT_01), @@ -235,9 +219,7 @@ fn test_remove_association_sender() { // remove association assert!(DidLookup::remove_sender_association(Origin::signed(ACCOUNT_00)).is_ok()); assert_eq!(ConnectedDids::::get(ACCOUNT_00), None); - assert!( - ConnectedAccounts::::get(DID_01, ACCOUNT_00).is_none() - ); + assert!(ConnectedAccounts::::get(DID_01, ACCOUNT_00).is_none()); assert_eq!(Balances::reserved_balance(ACCOUNT_00), 0); }); } @@ -268,9 +250,7 @@ fn test_remove_association_account() { ) .is_ok()); assert_eq!(ConnectedDids::::get(ACCOUNT_00), None); - assert!( - ConnectedAccounts::::get(DID_01, ACCOUNT_00).is_none() - ); + assert!(ConnectedAccounts::::get(DID_01, ACCOUNT_00).is_none()); assert_eq!(Balances::reserved_balance(ACCOUNT_01), 0); }); } diff --git a/runtimes/peregrine/src/migrations/mod.rs b/runtimes/peregrine/src/migrations/mod.rs index 2a45aee997..0b75859976 100644 --- a/runtimes/peregrine/src/migrations/mod.rs +++ b/runtimes/peregrine/src/migrations/mod.rs @@ -1,3 +1,21 @@ +// 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 + use crate::{DidLookup, Runtime, Weight}; use frame_support::traits::OnRuntimeUpgrade; use sp_std::marker::PhantomData; @@ -8,24 +26,27 @@ use frame_support::traits::GetStorageVersion; pub struct LookupReverseIndexMigration(PhantomData); impl OnRuntimeUpgrade for LookupReverseIndexMigration { - #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result<(), &'static str> { - assert_ne!(DidLookup::on_chain_storage_version(), DidLookup::current_storage_version()); + assert!(DidLookup::on_chain_storage_version() < DidLookup::current_storage_version()); assert_eq!(pallet_did_lookup::ConnectedAccounts::::iter().count(), 0); Ok(()) } - fn on_runtime_upgrade() -> frame_support::weights::Weight { + fn on_runtime_upgrade() -> frame_support::weights::Weight { // Account for the new storage version written below. - let mut total_weight: Weight = ::DbWeight::get().writes(1); + let initial_weight = ::DbWeight::get().writes(1); - pallet_did_lookup::ConnectedDids::::iter().for_each(|(account, record)| { - pallet_did_lookup::ConnectedAccounts::::insert(record.did, account, ()); - // One read for the `ConnectedDids` entry, one write for the new `ConnectedAccounts` entry. - total_weight = total_weight.saturating_add(::DbWeight::get().reads_writes(1, 1)) - }); + let total_weight: Weight = pallet_did_lookup::ConnectedDids::::iter().fold( + initial_weight, + |total_weight, (account, record)| { + pallet_did_lookup::ConnectedAccounts::::insert(record.did, account, ()); + // One read for the `ConnectedDids` entry, one write for the new + // `ConnectedAccounts` entry. + total_weight.saturating_add(::DbWeight::get().reads_writes(1, 1)) + }, + ); DidLookup::current_storage_version().put::(); @@ -33,16 +54,22 @@ impl OnRuntimeUpgrade for LookupReverseIndexMigration { } #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - assert_eq!(DidLookup::on_chain_storage_version(), DidLookup::current_storage_version()); + fn post_upgrade() -> Result<(), &'static str> { + assert_eq!( + DidLookup::on_chain_storage_version(), + DidLookup::current_storage_version() + ); // Verify DID -> Account integrity. pallet_did_lookup::ConnectedDids::::iter().for_each(|(account, record)| { - assert!(pallet_did_lookup::ConnectedAccounts::::contains_key(record.did, account)); + assert!(pallet_did_lookup::ConnectedAccounts::::contains_key( + record.did, account + )); }); // Verify Account -> DID integrity. pallet_did_lookup::ConnectedAccounts::::iter().for_each(|(did, account, _)| { - let entry = pallet_did_lookup::ConnectedDids::::get(account).expect("Should find a record for the given account."); + let entry = pallet_did_lookup::ConnectedDids::::get(account) + .expect("Should find a record for the given account."); assert_eq!(entry.did, did); }); From 4077251a7d49acbf65c42c0f21c5288530be042c Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Mon, 21 Mar 2022 16:40:39 +0100 Subject: [PATCH 13/30] chore: update deps --- Cargo.lock | 273 ++++++++++++----------- runtimes/peregrine/src/lib.rs | 35 +-- runtimes/peregrine/src/migrations/mod.rs | 5 +- 3 files changed, 149 insertions(+), 164 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f49eee1cb2..858a8313f4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,7 +44,7 @@ checksum = "9e8b47f52ea9bae42228d07ec09eb676433d7c4ed1ebdf0f1d1c29ed446f1ab8" dependencies = [ "cfg-if 1.0.0", "cipher", - "cpufeatures 0.2.1", + "cpufeatures 0.2.2", "opaque-debug 0.3.0", ] @@ -99,9 +99,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.55" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "159bb86af3a200e19a068f4224eae4c8bb2d0fa054c7e5d1cacd5cef95e684cd" +checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27" [[package]] name = "approx" @@ -188,9 +188,9 @@ dependencies = [ [[package]] name = "async-global-executor" -version = "2.0.2" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9586ec52317f36de58453159d48351bc244bc24ced3effc1fce22f3d48664af6" +checksum = "c026b7e44f1316b567ee750fea85103f87fcb80792b860e979f221259796ca0a" dependencies = [ "async-channel", "async-executor", @@ -301,9 +301,9 @@ dependencies = [ [[package]] name = "async-task" -version = "4.1.0" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d306121baf53310a3fd342d88dc0824f6bbeace68347593658525565abee8" +checksum = "30696a84d817107fc028e049980e09d5e140e8da8f1caeb17e8e950658a3cea9" [[package]] name = "async-trait" @@ -667,9 +667,9 @@ checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" [[package]] name = "blocking" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046e47d4b2d391b1f6f8b407b1deb8dee56c1852ccd868becf2710f601b5f427" +checksum = "c6ccb65d468978a086b69884437ded69a90faab3bbe6e67f242173ea728acccc" dependencies = [ "async-channel", "async-task", @@ -1055,9 +1055,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.1.2" +version = "3.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5177fac1ab67102d8989464efd043c6ff44191b1557ec1ddd489b4f7e1447e77" +checksum = "d8c93436c21e4698bacadf42917db28b23017027a4deccb35dbe47a7e7840123" dependencies = [ "atty", "bitflags", @@ -1072,9 +1072,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "3.1.2" +version = "3.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01d42c94ce7c2252681b5fed4d3627cc807b13dfc033246bd05d5b252399000e" +checksum = "da95d038ede1a964ce99f49cbe27a7fb538d1da595e4b4f70b8c8f338d17bf16" dependencies = [ "heck 0.4.0", "proc-macro-error", @@ -1149,9 +1149,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" +checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" dependencies = [ "libc", ] @@ -1256,9 +1256,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.2" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e54ea8bc3fb1ee042f5aace6e3c6e025d3874866da222930f70ce62aceba0bfa" +checksum = "5aaa7bd5fb665c6864b5f963dd9097905c54125909c7aa94c9e18507cdbe6c53" dependencies = [ "cfg-if 1.0.0", "crossbeam-utils", @@ -1277,10 +1277,11 @@ dependencies = [ [[package]] name = "crossbeam-epoch" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c00d6d2ea26e8b151d99093005cb442fb9a37aeaca582a03ec70946f49ab5ed9" +checksum = "1145cf131a2c6ba0615079ab6a638f7e1973ac9c2634fcbeaaad6114246efe8c" dependencies = [ + "autocfg", "cfg-if 1.0.0", "crossbeam-utils", "lazy_static", @@ -1290,9 +1291,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.7" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e5bed1f1c269533fa816a0a5492b3545209a205ca1a54842be180eb63a16a6" +checksum = "0bf124c720b7686e3c2663cf54062ab0f68a88af2fb6a030e87e30bf721fcb38" dependencies = [ "cfg-if 1.0.0", "lazy_static", @@ -1345,9 +1346,9 @@ dependencies = [ [[package]] name = "ctor" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccc0a48a9b826acdf4028595adc9db92caea352f7af011a3034acd172a52a0aa" +checksum = "f877be4f7c9f246b183111634f75baa039715e3f46ce860677d3b19a69fb229c" dependencies = [ "quote", "syn", @@ -1397,7 +1398,7 @@ dependencies = [ [[package]] name = "cumulus-client-cli" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "clap", "sc-cli", @@ -1407,7 +1408,7 @@ dependencies = [ [[package]] name = "cumulus-client-collator" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "cumulus-client-consensus-common", "cumulus-client-network", @@ -1431,7 +1432,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-aura" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "async-trait", "cumulus-client-consensus-common", @@ -1460,7 +1461,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-common" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "async-trait", "cumulus-relay-chain-interface", @@ -1481,7 +1482,7 @@ dependencies = [ [[package]] name = "cumulus-client-consensus-relay-chain" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "async-trait", "cumulus-client-consensus-common", @@ -1505,7 +1506,7 @@ dependencies = [ [[package]] name = "cumulus-client-network" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "async-trait", "cumulus-relay-chain-interface", @@ -1530,7 +1531,7 @@ dependencies = [ [[package]] name = "cumulus-client-pov-recovery" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "cumulus-primitives-core", "cumulus-relay-chain-interface", @@ -1554,7 +1555,7 @@ dependencies = [ [[package]] name = "cumulus-client-service" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "cumulus-client-collator", "cumulus-client-consensus-common", @@ -1583,7 +1584,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-aura-ext" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "frame-executive", "frame-support", @@ -1601,7 +1602,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-parachain-system" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "cumulus-pallet-parachain-system-proc-macro", "cumulus-primitives-core", @@ -1631,7 +1632,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-parachain-system-proc-macro" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", @@ -1642,7 +1643,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-session-benchmarking" version = "3.0.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "frame-benchmarking", "frame-support", @@ -1656,7 +1657,7 @@ dependencies = [ [[package]] name = "cumulus-pallet-xcmp-queue" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -1674,7 +1675,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-core" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "frame-support", "parity-scale-codec", @@ -1690,7 +1691,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-parachain-inherent" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -1713,7 +1714,7 @@ dependencies = [ [[package]] name = "cumulus-primitives-timestamp" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "cumulus-primitives-core", "sp-inherents", @@ -1724,7 +1725,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-interface" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -1745,7 +1746,7 @@ dependencies = [ [[package]] name = "cumulus-relay-chain-local" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "async-trait", "cumulus-primitives-core", @@ -1773,7 +1774,7 @@ dependencies = [ [[package]] name = "cumulus-test-relay-sproof-builder" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "cumulus-primitives-core", "parity-scale-codec", @@ -1958,9 +1959,9 @@ dependencies = [ [[package]] name = "dirs-sys" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" dependencies = [ "libc", "redox_users", @@ -2023,15 +2024,15 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2626afccd7561a06cf1367e2950c4718ea04565e20fb5029b6c7d8ad09abcf" +checksum = "21e50f3adc76d6a43f5ed73b698a87d0760ca74617f60f7c3b879003536fdd28" [[package]] name = "ed25519" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eed12bbf7b5312f8da1c2722bc06d8c6b12c2d86a7fb35a194c7f3e6fc2bbe39" +checksum = "3d5c4b5e5959dc2c2b89918d8e2cc40fcdd623cef026ed09d2f0ee05199dc8e4" dependencies = [ "signature", ] @@ -2760,9 +2761,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.11" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9f1f717ddc7b2ba36df7e871fd88db79326551d3d6f1fc406fbfd28b582ff8e" +checksum = "62eeb471aa3e3c9197aa4bfeabfe02982f6dc96f750486c0bb0009ac58b26d2b" dependencies = [ "bytes 1.1.0", "fnv", @@ -2779,9 +2780,9 @@ dependencies = [ [[package]] name = "handlebars" -version = "4.2.1" +version = "4.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25546a65e5cf1f471f3438796fc634650b31d7fcde01d444c309aeb28b92e3a8" +checksum = "99d6a30320f094710245150395bc763ad23128d6a1ebbad7594dc4164b62c56b" dependencies = [ "log", "pest", @@ -3150,9 +3151,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" +checksum = "35e70ee094dc02fd9c13fdad4940090f22dbd6ac7c9e7094a46cf0232a50bc7c" [[package]] name = "itertools" @@ -3363,7 +3364,7 @@ dependencies = [ "soketto", "thiserror", "tokio", - "tokio-rustls 0.23.2", + "tokio-rustls 0.23.3", "tokio-util", "tracing", "webpki-roots 0.22.2", @@ -3769,9 +3770,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.119" +version = "0.2.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" +checksum = "efaa7b300f3b5fe8eb6bf21ce3895e1751d9665086af2d64b42f19701015ff4f" [[package]] name = "libloading" @@ -4165,7 +4166,7 @@ dependencies = [ "libp2p-core", "libp2p-swarm", "log", - "lru 0.7.2", + "lru 0.7.3", "rand 0.7.3", "smallvec", "unsigned-varint 0.7.1", @@ -4334,9 +4335,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.3" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66" +checksum = "6f35facd4a5673cb5a48822be2be1d4236c1c99cb4113cab7061ac720d5bf859" dependencies = [ "cc", "pkg-config", @@ -4413,9 +4414,9 @@ dependencies = [ [[package]] name = "lru" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "274353858935c992b13c0ca408752e2121da852d07dec7ce5f108c77dfa14d1f" +checksum = "fcb87f3080f6d1d69e8c564c0fcfde1d7aa8cc451ce40cae89479111f03bc0eb" dependencies = [ "hashbrown 0.11.2", ] @@ -4431,9 +4432,9 @@ dependencies = [ [[package]] name = "lz4" -version = "1.23.2" +version = "1.23.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aac20ed6991e01bf6a2e68cc73df2b389707403662a8ba89f68511fb340f724c" +checksum = "4edcb94251b1c375c459e5abe9fb0168c1c826c3370172684844f8f3f8d1a885" dependencies = [ "libc", "lz4-sys", @@ -4441,9 +4442,9 @@ dependencies = [ [[package]] name = "lz4-sys" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dca79aa95d8b3226213ad454d328369853be3a1382d89532a854f4d69640acae" +checksum = "d7be8908e2ed6f31c02db8a9fa962f03e36c53fbfde437363eae3306b85d7e17" dependencies = [ "cc", "libc", @@ -4686,9 +4687,9 @@ dependencies = [ [[package]] name = "mick-jaeger" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd2c2cc134e57461f0898b0e921f0a7819b5e3f3a4335b9aa390ce81a5f36fb9" +checksum = "69672161530e8aeca1d1400fbf3f1a1747ff60ea604265a4e906c2442df20532" dependencies = [ "futures 0.3.21", "rand 0.8.5", @@ -4732,14 +4733,15 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba272f85fa0b41fc91872be579b3bbe0f56b792aa361a380eb669469f68dafb2" +checksum = "52da4364ffb0e4fe33a9841a98a3f3014fb964045ce4f7a45a398243c8d6b0c9" dependencies = [ "libc", "log", "miow 0.3.7", "ntapi", + "wasi 0.11.0+wasi-snapshot-preview1", "winapi 0.3.9", ] @@ -5053,13 +5055,12 @@ checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" [[package]] name = "nom" -version = "7.1.0" +version = "7.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109" +checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" dependencies = [ "memchr", "minimal-lexical", - "version_check", ] [[package]] @@ -5091,6 +5092,16 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-format" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bafe4179722c2894288ee77a9f044f02811c86af699344c498b0840c698a2465" +dependencies = [ + "arrayvec 0.4.12", + "itoa 0.4.8", +] + [[package]] name = "num-integer" version = "0.1.44" @@ -5157,9 +5168,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" +checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9" [[package]] name = "opaque-debug" @@ -6354,7 +6365,7 @@ dependencies = [ [[package]] name = "parachain-info" version = "0.1.0" -source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#76479e7fef3af7c8828a44647847b01afd5fefe5" +source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.17#db11baacc325537be74ad34517fcb28ed9ded6c6" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -6393,9 +6404,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09aa6c5bb8070cf0456d9fc228b3022e900aae9092c48c9c45facf97422efc1d" +checksum = "865edee5b792f537356d9e55cbc138e7f4718dc881a7ea45a18b37bf61c21e3d" dependencies = [ "blake2-rfc", "crc32fast", @@ -6576,7 +6587,7 @@ dependencies = [ "cfg-if 1.0.0", "instant", "libc", - "redox_syscall 0.2.10", + "redox_syscall 0.2.11", "smallvec", "winapi 0.3.9", ] @@ -6589,7 +6600,7 @@ checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" dependencies = [ "cfg-if 1.0.0", "libc", - "redox_syscall 0.2.10", + "redox_syscall 0.2.11", "smallvec", "windows-sys", ] @@ -6869,7 +6880,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.17#de0e dependencies = [ "derive_more", "futures 0.3.21", - "lru 0.7.2", + "lru 0.7.3", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-network-protocol", @@ -6890,7 +6901,7 @@ version = "0.9.17" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.17#de0ecd4760b146ecf33f5e867d707d789e21e060" dependencies = [ "futures 0.3.21", - "lru 0.7.2", + "lru 0.7.3", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-network-protocol", @@ -6998,7 +7009,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.17#de0e dependencies = [ "derive_more", "futures 0.3.21", - "lru 0.7.2", + "lru 0.7.3", "parity-scale-codec", "polkadot-erasure-coding", "polkadot-node-network-protocol", @@ -7094,7 +7105,7 @@ dependencies = [ "futures 0.3.21", "futures-timer", "kvdb", - "lru 0.7.2", + "lru 0.7.3", "merlin", "parity-scale-codec", "polkadot-node-jaeger", @@ -7222,7 +7233,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.17#de0e dependencies = [ "futures 0.3.21", "kvdb", - "lru 0.7.2", + "lru 0.7.3", "parity-scale-codec", "polkadot-node-primitives", "polkadot-node-subsystem", @@ -7446,7 +7457,7 @@ dependencies = [ "derive_more", "futures 0.3.21", "itertools", - "lru 0.7.2", + "lru 0.7.3", "metered-channel", "parity-scale-codec", "pin-project 1.0.10", @@ -7472,7 +7483,7 @@ source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.17#de0e dependencies = [ "futures 0.3.21", "futures-timer", - "lru 0.7.2", + "lru 0.7.3", "parity-util-mem", "parking_lot 0.11.2", "polkadot-node-metrics", @@ -7818,7 +7829,7 @@ dependencies = [ "kusama-runtime", "kvdb", "kvdb-rocksdb", - "lru 0.7.2", + "lru 0.7.3", "pallet-babe", "pallet-im-online", "pallet-mmr-primitives", @@ -7954,7 +7965,7 @@ version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "048aeb476be11a4b6ca432ca569e375810de9294ae78f4774e78ea98a9246ede" dependencies = [ - "cpufeatures 0.2.1", + "cpufeatures 0.2.2", "opaque-debug 0.3.0", "universal-hash", ] @@ -7966,7 +7977,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8419d2b623c7c0896ff2d5d96e2cb4ede590fed28fcc34934f4c33c036e620a1" dependencies = [ "cfg-if 1.0.0", - "cpufeatures 0.2.1", + "cpufeatures 0.2.2", "opaque-debug 0.3.0", "universal-hash", ] @@ -8143,9 +8154,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" +checksum = "b4af2ec4714533fcdf07e886f17025ace8b997b9ce51204ee69b6da831c3da57" dependencies = [ "proc-macro2", ] @@ -8286,21 +8297,22 @@ checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "redox_syscall" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c" dependencies = [ "bitflags", ] [[package]] name = "redox_users" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +checksum = "7776223e2696f1aa4c6b0170e83212f47296a00424305117d013dfe86fb0fe55" dependencies = [ "getrandom 0.2.5", - "redox_syscall 0.2.10", + "redox_syscall 0.2.11", + "thiserror", ] [[package]] @@ -8349,9 +8361,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.5.4" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" dependencies = [ "aho-corasick", "memchr", @@ -9297,7 +9309,7 @@ dependencies = [ "linked-hash-map", "linked_hash_set", "log", - "lru 0.7.2", + "lru 0.7.3", "parity-scale-codec", "parking_lot 0.11.2", "pin-project 1.0.10", @@ -9334,7 +9346,7 @@ dependencies = [ "futures-timer", "libp2p", "log", - "lru 0.7.2", + "lru 0.7.3", "sc-network", "sp-runtime", "substrate-prometheus-endpoint", @@ -9896,7 +9908,7 @@ checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ "block-buffer 0.9.0", "cfg-if 1.0.0", - "cpufeatures 0.2.1", + "cpufeatures 0.2.2", "digest 0.9.0", "opaque-debug 0.3.0", ] @@ -9921,7 +9933,7 @@ checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ "block-buffer 0.9.0", "cfg-if 1.0.0", - "cpufeatures 0.2.1", + "cpufeatures 0.2.2", "digest 0.9.0", "opaque-debug 0.3.0", ] @@ -9933,7 +9945,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676" dependencies = [ "cfg-if 1.0.0", - "cpufeatures 0.2.1", + "cpufeatures 0.2.2", "digest 0.10.3", ] @@ -10196,7 +10208,7 @@ source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.17#22 dependencies = [ "futures 0.3.21", "log", - "lru 0.7.2", + "lru 0.7.3", "parity-scale-codec", "parking_lot 0.11.2", "sp-api", @@ -10887,11 +10899,12 @@ dependencies = [ [[package]] name = "ss58-registry" -version = "1.15.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f9799e6d412271cb2414597581128b03f3285f260ea49f5363d07df6a332b3e" +checksum = "7b84a70894df7a73666e0694f44b41a9571625e9546fb58a0818a565d2c7e084" dependencies = [ "Inflector", + "num-format", "proc-macro2", "quote", "serde", @@ -11064,9 +11077,9 @@ checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "syn" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" +checksum = "ea297be220d52398dcc07ce15a209fce436d361735ac1db700cab3b6cdfb9f54" dependencies = [ "proc-macro2", "quote", @@ -11106,25 +11119,25 @@ dependencies = [ "cfg-if 1.0.0", "fastrand", "libc", - "redox_syscall 0.2.10", + "redox_syscall 0.2.11", "remove_dir_all", "winapi 0.3.9", ] [[package]] name = "termcolor" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" dependencies = [ "winapi-util", ] [[package]] name = "textwrap" -version = "0.14.2" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80" +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" [[package]] name = "thiserror" @@ -11240,7 +11253,7 @@ dependencies = [ "bytes 1.1.0", "libc", "memchr", - "mio 0.8.0", + "mio 0.8.2", "num_cpus", "once_cell", "pin-project-lite 0.2.8", @@ -11274,9 +11287,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.23.2" +version = "0.23.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27d5f2b839802bd8267fa19b0530f5a08b9c08cd417976be2a65d130fe1c11b" +checksum = "4151fda0cf2798550ad0b34bcfc9b9dcc2a9d2471c895c68f3a8818e54f2389e" dependencies = [ "rustls 0.20.4", "tokio", @@ -11326,9 +11339,9 @@ checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" [[package]] name = "tracing" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6c650a8ef0cd2dd93736f033d21cbd1224c5a967aa0c258d00fcf7dafef9b9f" +checksum = "4a1bdf54a7c28a2bbf701e1d2233f6c77f473486b94bee4f9678da5a148dca7f" dependencies = [ "cfg-if 1.0.0", "pin-project-lite 0.2.8", @@ -11338,9 +11351,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.19" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8276d9a4a3a558d7b7ad5303ad50b53d58264641b82914b7ada36bd762e7a716" +checksum = "2e65ce065b4b5c53e73bb28912318cb8c9e9ad3921f1d669eb0e68b4c8143a2b" dependencies = [ "proc-macro2", "quote", @@ -11349,9 +11362,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.22" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03cfcb51380632a72d3111cb8d3447a8d908e577d31beeac006f836383d29a23" +checksum = "aa31669fa42c09c34d94d8165dd2012e8ff3c66aca50f3bb226b68f216f2706c" dependencies = [ "lazy_static", "valuable", @@ -11737,6 +11750,12 @@ version = "0.10.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + [[package]] name = "wasm-bindgen" version = "0.2.79" @@ -12179,9 +12198,9 @@ dependencies = [ [[package]] name = "which" -version = "4.2.4" +version = "4.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a5a7e487e921cf220206864a94a89b6c6905bfc19f1057fa26a4cb360e5c1d2" +checksum = "5c4fb54e6113b6a8772ee41c3404fb0301ac79604489467e0a9ce1f3e97c24ae" dependencies = [ "either", "lazy_static", @@ -12394,9 +12413,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.5.3" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50344758e2f40e3a1fcfc8f6f91aa57b5f8ebd8d27919fe6451f15aaaf9ee608" +checksum = "7eb5728b8afd3f280a869ce1d4c554ffaed35f45c231fc41bfbd0381bef50317" dependencies = [ "zeroize_derive", ] diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index 8b535a15e8..2307c8e1b2 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -28,7 +28,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ construct_runtime, parameter_types, - traits::{EnsureOneOf, InstanceFilter, OnRuntimeUpgrade, PrivilegeCmp}, + traits::{EnsureOneOf, InstanceFilter, PrivilegeCmp}, weights::{constants::RocksDbWeight, Weight}, }; use frame_system::EnsureRoot; @@ -979,40 +979,9 @@ pub type Executive = frame_executive::Executive< // Executes pallet hooks in reverse order of definition in construct_runtime // If we want to switch to AllPalletsWithSystem, we need to reorder the staking pallets AllPalletsReversedWithSystemFirst, - ( - SchedulerMigrationV3, - delegation::migrations::v3::DelegationMigrationV3, - did::migrations::v4::DidMigrationV4, - parachain_staking::migrations::v7::ParachainStakingMigrationV7, - ), + migrations::LookupReverseIndexMigration, >; -// Migration for scheduler pallet to move from a plain Call to a CallOrHash. -pub struct SchedulerMigrationV3; - -impl OnRuntimeUpgrade for SchedulerMigrationV3 { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - Scheduler::migrate_v1_to_v3() - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - Scheduler::pre_migrate_to_v3() - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - use frame_support::dispatch::GetStorageVersion; - - Scheduler::post_migrate_to_v3()?; - log::info!( - "Scheduler migrated to version {:?}", - Scheduler::current_storage_version() - ); - Ok(()) - } -} - impl_runtime_apis! { impl sp_api::Core for Runtime { fn version() -> RuntimeVersion { diff --git a/runtimes/peregrine/src/migrations/mod.rs b/runtimes/peregrine/src/migrations/mod.rs index 0b75859976..ab3575ad17 100644 --- a/runtimes/peregrine/src/migrations/mod.rs +++ b/runtimes/peregrine/src/migrations/mod.rs @@ -17,12 +17,9 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use crate::{DidLookup, Runtime, Weight}; -use frame_support::traits::OnRuntimeUpgrade; +use frame_support::traits::{GetStorageVersion, OnRuntimeUpgrade}; use sp_std::marker::PhantomData; -#[cfg(feature = "try-runtime")] -use frame_support::traits::GetStorageVersion; - pub struct LookupReverseIndexMigration(PhantomData); impl OnRuntimeUpgrade for LookupReverseIndexMigration { From 12b6f3364c921ae8d779edcc76b6fffef7bd0533 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Tue, 22 Mar 2022 09:26:35 +0100 Subject: [PATCH 14/30] chore: add migrations to Spiritnet runtime --- runtimes/peregrine/src/lib.rs | 1 - runtimes/spiritnet/src/lib.rs | 8 +-- runtimes/spiritnet/src/migrations/mod.rs | 75 ++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 7 deletions(-) create mode 100644 runtimes/spiritnet/src/migrations/mod.rs diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index 2307c8e1b2..4659e2ad36 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -68,7 +68,6 @@ mod tests; pub use sp_runtime::BuildStorage; mod migrations; - mod weights; impl_opaque_keys! { diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index c548fbcb27..59af3d2d98 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -67,6 +67,7 @@ mod tests; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; +mod migrations; mod weights; impl_opaque_keys! { @@ -981,12 +982,7 @@ pub type Executive = frame_executive::Executive< // Executes pallet hooks in reverse order of definition in construct_runtime // If we want to switch to AllPalletsWithSystem, we need to reorder the staking pallets AllPalletsReversedWithSystemFirst, - ( - SchedulerMigrationV3, - delegation::migrations::v3::DelegationMigrationV3, - did::migrations::v4::DidMigrationV4, - parachain_staking::migrations::v7::ParachainStakingMigrationV7, - ), + migrations::LookupReverseIndexMigration >; // Migration for scheduler pallet to move from a plain Call to a CallOrHash. diff --git a/runtimes/spiritnet/src/migrations/mod.rs b/runtimes/spiritnet/src/migrations/mod.rs new file mode 100644 index 0000000000..ab3575ad17 --- /dev/null +++ b/runtimes/spiritnet/src/migrations/mod.rs @@ -0,0 +1,75 @@ +// 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 + +use crate::{DidLookup, Runtime, Weight}; +use frame_support::traits::{GetStorageVersion, OnRuntimeUpgrade}; +use sp_std::marker::PhantomData; + +pub struct LookupReverseIndexMigration(PhantomData); + +impl OnRuntimeUpgrade for LookupReverseIndexMigration { + #[cfg(feature = "try-runtime")] + fn pre_upgrade() -> Result<(), &'static str> { + assert!(DidLookup::on_chain_storage_version() < DidLookup::current_storage_version()); + assert_eq!(pallet_did_lookup::ConnectedAccounts::::iter().count(), 0); + + Ok(()) + } + + fn on_runtime_upgrade() -> frame_support::weights::Weight { + // Account for the new storage version written below. + let initial_weight = ::DbWeight::get().writes(1); + + let total_weight: Weight = pallet_did_lookup::ConnectedDids::::iter().fold( + initial_weight, + |total_weight, (account, record)| { + pallet_did_lookup::ConnectedAccounts::::insert(record.did, account, ()); + // One read for the `ConnectedDids` entry, one write for the new + // `ConnectedAccounts` entry. + total_weight.saturating_add(::DbWeight::get().reads_writes(1, 1)) + }, + ); + + DidLookup::current_storage_version().put::(); + + total_weight + } + + #[cfg(feature = "try-runtime")] + fn post_upgrade() -> Result<(), &'static str> { + assert_eq!( + DidLookup::on_chain_storage_version(), + DidLookup::current_storage_version() + ); + + // Verify DID -> Account integrity. + pallet_did_lookup::ConnectedDids::::iter().for_each(|(account, record)| { + assert!(pallet_did_lookup::ConnectedAccounts::::contains_key( + record.did, account + )); + }); + // Verify Account -> DID integrity. + pallet_did_lookup::ConnectedAccounts::::iter().for_each(|(did, account, _)| { + let entry = pallet_did_lookup::ConnectedDids::::get(account) + .expect("Should find a record for the given account."); + assert_eq!(entry.did, did); + }); + + Ok(()) + } +} From b8e2f24572f3fc4d518e2766f9602f686e6dca20 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Tue, 22 Mar 2022 09:27:42 +0100 Subject: [PATCH 15/30] chore: add comment in lookup migration --- runtimes/peregrine/src/migrations/mod.rs | 1 + runtimes/spiritnet/src/migrations/mod.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/runtimes/peregrine/src/migrations/mod.rs b/runtimes/peregrine/src/migrations/mod.rs index ab3575ad17..2d760dda01 100644 --- a/runtimes/peregrine/src/migrations/mod.rs +++ b/runtimes/peregrine/src/migrations/mod.rs @@ -35,6 +35,7 @@ impl OnRuntimeUpgrade for LookupReverseIndexMigration { // Account for the new storage version written below. let initial_weight = ::DbWeight::get().writes(1); + // Origin was disabled, so there cannot be any existing links. But we check just to be sure. let total_weight: Weight = pallet_did_lookup::ConnectedDids::::iter().fold( initial_weight, |total_weight, (account, record)| { diff --git a/runtimes/spiritnet/src/migrations/mod.rs b/runtimes/spiritnet/src/migrations/mod.rs index ab3575ad17..7bf2e0e573 100644 --- a/runtimes/spiritnet/src/migrations/mod.rs +++ b/runtimes/spiritnet/src/migrations/mod.rs @@ -35,6 +35,7 @@ impl OnRuntimeUpgrade for LookupReverseIndexMigration { // Account for the new storage version written below. let initial_weight = ::DbWeight::get().writes(1); + // Origin was disabled, so there cannot be any existing links. But we check just to be sure.git let total_weight: Weight = pallet_did_lookup::ConnectedDids::::iter().fold( initial_weight, |total_weight, (account, record)| { From 52365ebbfeab392ebf49d76e7d5c15f5f03aea11 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Tue, 22 Mar 2022 09:55:44 +0100 Subject: [PATCH 16/30] chore: move migration into lookup pallet --- pallets/pallet-did-lookup/src/lib.rs | 1 + .../pallet-did-lookup/src/migrations.rs | 49 ++++++------ runtimes/peregrine/src/lib.rs | 3 +- runtimes/spiritnet/src/lib.rs | 31 +------- runtimes/spiritnet/src/migrations/mod.rs | 76 ------------------- 5 files changed, 28 insertions(+), 132 deletions(-) rename runtimes/peregrine/src/migrations/mod.rs => pallets/pallet-did-lookup/src/migrations.rs (50%) delete mode 100644 runtimes/spiritnet/src/migrations/mod.rs diff --git a/pallets/pallet-did-lookup/src/lib.rs b/pallets/pallet-did-lookup/src/lib.rs index 463fd1632c..9a02799694 100644 --- a/pallets/pallet-did-lookup/src/lib.rs +++ b/pallets/pallet-did-lookup/src/lib.rs @@ -26,6 +26,7 @@ mod connection_record; pub mod default_weights; +pub mod migrations; #[cfg(test)] mod tests; diff --git a/runtimes/peregrine/src/migrations/mod.rs b/pallets/pallet-did-lookup/src/migrations.rs similarity index 50% rename from runtimes/peregrine/src/migrations/mod.rs rename to pallets/pallet-did-lookup/src/migrations.rs index 2d760dda01..7f683736fe 100644 --- a/runtimes/peregrine/src/migrations/mod.rs +++ b/pallets/pallet-did-lookup/src/migrations.rs @@ -16,37 +16,39 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use crate::{DidLookup, Runtime, Weight}; -use frame_support::traits::{GetStorageVersion, OnRuntimeUpgrade}; +use crate::{Config, ConnectedAccounts, ConnectedDids, Pallet}; +use frame_support::{ + dispatch::Weight, + traits::{Get, GetStorageVersion, OnRuntimeUpgrade}, +}; use sp_std::marker::PhantomData; -pub struct LookupReverseIndexMigration(PhantomData); +pub struct LookupReverseIndexMigration(PhantomData); -impl OnRuntimeUpgrade for LookupReverseIndexMigration { +impl OnRuntimeUpgrade for LookupReverseIndexMigration { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result<(), &'static str> { - assert!(DidLookup::on_chain_storage_version() < DidLookup::current_storage_version()); - assert_eq!(pallet_did_lookup::ConnectedAccounts::::iter().count(), 0); + assert!(Pallet::::on_chain_storage_version() < Pallet::current_storage_version()); + assert_eq!(ConnectedAccounts::::iter().count(), 0); Ok(()) } fn on_runtime_upgrade() -> frame_support::weights::Weight { // Account for the new storage version written below. - let initial_weight = ::DbWeight::get().writes(1); + let initial_weight = T::DbWeight::get().writes(1); - // Origin was disabled, so there cannot be any existing links. But we check just to be sure. - let total_weight: Weight = pallet_did_lookup::ConnectedDids::::iter().fold( - initial_weight, - |total_weight, (account, record)| { - pallet_did_lookup::ConnectedAccounts::::insert(record.did, account, ()); + // Origin was disabled, so there cannot be any existing links. But we check just + // to be sure. + let total_weight: Weight = + ConnectedDids::::iter().fold(initial_weight, |total_weight, (account, record)| { + ConnectedAccounts::::insert(record.did, account, ()); // One read for the `ConnectedDids` entry, one write for the new // `ConnectedAccounts` entry. - total_weight.saturating_add(::DbWeight::get().reads_writes(1, 1)) - }, - ); + total_weight.saturating_add(T::DbWeight::get().reads_writes(1, 1)) + }); - DidLookup::current_storage_version().put::(); + Pallet::::current_storage_version().put::>(); total_weight } @@ -54,20 +56,17 @@ impl OnRuntimeUpgrade for LookupReverseIndexMigration { #[cfg(feature = "try-runtime")] fn post_upgrade() -> Result<(), &'static str> { assert_eq!( - DidLookup::on_chain_storage_version(), - DidLookup::current_storage_version() + Pallet::::on_chain_storage_version(), + Pallet::::current_storage_version() ); // Verify DID -> Account integrity. - pallet_did_lookup::ConnectedDids::::iter().for_each(|(account, record)| { - assert!(pallet_did_lookup::ConnectedAccounts::::contains_key( - record.did, account - )); + ConnectedDids::::iter().for_each(|(account, record)| { + assert!(ConnectedAccounts::::contains_key(record.did, account)); }); // Verify Account -> DID integrity. - pallet_did_lookup::ConnectedAccounts::::iter().for_each(|(did, account, _)| { - let entry = pallet_did_lookup::ConnectedDids::::get(account) - .expect("Should find a record for the given account."); + ConnectedAccounts::::iter().for_each(|(did, account, _)| { + let entry = ConnectedDids::::get(account).expect("Should find a record for the given account."); assert_eq!(entry.did, did); }); diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index 4659e2ad36..46a8df87a2 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -67,7 +67,6 @@ mod tests; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; -mod migrations; mod weights; impl_opaque_keys! { @@ -978,7 +977,7 @@ pub type Executive = frame_executive::Executive< // Executes pallet hooks in reverse order of definition in construct_runtime // If we want to switch to AllPalletsWithSystem, we need to reorder the staking pallets AllPalletsReversedWithSystemFirst, - migrations::LookupReverseIndexMigration, + pallet_did_lookup::migrations::LookupReverseIndexMigration, >; impl_runtime_apis! { diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index 59af3d2d98..80ccf938fa 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -28,7 +28,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::{ construct_runtime, parameter_types, - traits::{Contains, EnsureOneOf, InstanceFilter, OnRuntimeUpgrade, PrivilegeCmp}, + traits::{Contains, EnsureOneOf, InstanceFilter, PrivilegeCmp}, weights::{constants::RocksDbWeight, Weight}, }; use frame_system::EnsureRoot; @@ -67,7 +67,6 @@ mod tests; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; -mod migrations; mod weights; impl_opaque_keys! { @@ -982,35 +981,9 @@ pub type Executive = frame_executive::Executive< // Executes pallet hooks in reverse order of definition in construct_runtime // If we want to switch to AllPalletsWithSystem, we need to reorder the staking pallets AllPalletsReversedWithSystemFirst, - migrations::LookupReverseIndexMigration + pallet_did_lookup::migrations::LookupReverseIndexMigration, >; -// Migration for scheduler pallet to move from a plain Call to a CallOrHash. -pub struct SchedulerMigrationV3; - -impl OnRuntimeUpgrade for SchedulerMigrationV3 { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - Scheduler::migrate_v1_to_v3() - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - Scheduler::pre_migrate_to_v3() - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - use frame_support::dispatch::GetStorageVersion; - - Scheduler::post_migrate_to_v3()?; - log::info!( - "Scheduler migrated to version {:?}", - Scheduler::current_storage_version() - ); - Ok(()) - } -} - impl_runtime_apis! { impl sp_api::Core for Runtime { fn version() -> RuntimeVersion { diff --git a/runtimes/spiritnet/src/migrations/mod.rs b/runtimes/spiritnet/src/migrations/mod.rs deleted file mode 100644 index 7bf2e0e573..0000000000 --- a/runtimes/spiritnet/src/migrations/mod.rs +++ /dev/null @@ -1,76 +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 - -use crate::{DidLookup, Runtime, Weight}; -use frame_support::traits::{GetStorageVersion, OnRuntimeUpgrade}; -use sp_std::marker::PhantomData; - -pub struct LookupReverseIndexMigration(PhantomData); - -impl OnRuntimeUpgrade for LookupReverseIndexMigration { - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - assert!(DidLookup::on_chain_storage_version() < DidLookup::current_storage_version()); - assert_eq!(pallet_did_lookup::ConnectedAccounts::::iter().count(), 0); - - Ok(()) - } - - fn on_runtime_upgrade() -> frame_support::weights::Weight { - // Account for the new storage version written below. - let initial_weight = ::DbWeight::get().writes(1); - - // Origin was disabled, so there cannot be any existing links. But we check just to be sure.git - let total_weight: Weight = pallet_did_lookup::ConnectedDids::::iter().fold( - initial_weight, - |total_weight, (account, record)| { - pallet_did_lookup::ConnectedAccounts::::insert(record.did, account, ()); - // One read for the `ConnectedDids` entry, one write for the new - // `ConnectedAccounts` entry. - total_weight.saturating_add(::DbWeight::get().reads_writes(1, 1)) - }, - ); - - DidLookup::current_storage_version().put::(); - - total_weight - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - assert_eq!( - DidLookup::on_chain_storage_version(), - DidLookup::current_storage_version() - ); - - // Verify DID -> Account integrity. - pallet_did_lookup::ConnectedDids::::iter().for_each(|(account, record)| { - assert!(pallet_did_lookup::ConnectedAccounts::::contains_key( - record.did, account - )); - }); - // Verify Account -> DID integrity. - pallet_did_lookup::ConnectedAccounts::::iter().for_each(|(did, account, _)| { - let entry = pallet_did_lookup::ConnectedDids::::get(account) - .expect("Should find a record for the given account."); - assert_eq!(entry.did, did); - }); - - Ok(()) - } -} From 6a4445f559291fee6c1b5b714cf684a36f7ea747 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Tue, 22 Mar 2022 10:20:24 +0100 Subject: [PATCH 17/30] fix: add try-runtime feature to did lookup crate --- Cargo.lock | 1 + pallets/pallet-did-lookup/Cargo.toml | 7 +++++++ pallets/pallet-did-lookup/src/migrations.rs | 8 +++++++- runtimes/peregrine/Cargo.toml | 1 + runtimes/peregrine/src/lib.rs | 2 +- runtimes/spiritnet/Cargo.toml | 1 + runtimes/spiritnet/src/lib.rs | 2 +- runtimes/standalone/Cargo.toml | 1 + runtimes/standalone/src/lib.rs | 2 +- 9 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 858a8313f4..0877be2163 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5636,6 +5636,7 @@ dependencies = [ "frame-support", "frame-system", "kilt-support", + "log", "pallet-balances", "parity-scale-codec", "runtime-common", diff --git a/pallets/pallet-did-lookup/Cargo.toml b/pallets/pallet-did-lookup/Cargo.toml index e3185565cd..09a295278d 100644 --- a/pallets/pallet-did-lookup/Cargo.toml +++ b/pallets/pallet-did-lookup/Cargo.toml @@ -19,6 +19,7 @@ sp-keystore = {branch = "polkadot-v0.9.17", default-features = false, git = "htt [dependencies] codec = {default-features = false, features = ["derive"], package = "parity-scale-codec", version = "2.3.1"} +log = "0.4" scale-info = {version = "1.0", default-features = false, features = ["derive"]} # KILT @@ -49,7 +50,13 @@ std = [ "frame-benchmarking/std", "frame-support/std", "frame-system/std", + "log/std", "scale-info/std", "sp-runtime/std", "sp-std/std", ] + +try-runtime = [ + "frame-support/try-runtime", + "kilt-support/try-runtime", +] diff --git a/pallets/pallet-did-lookup/src/migrations.rs b/pallets/pallet-did-lookup/src/migrations.rs index 7f683736fe..66820b8d25 100644 --- a/pallets/pallet-did-lookup/src/migrations.rs +++ b/pallets/pallet-did-lookup/src/migrations.rs @@ -28,9 +28,11 @@ pub struct LookupReverseIndexMigration(PhantomData); impl OnRuntimeUpgrade for LookupReverseIndexMigration { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result<(), &'static str> { - assert!(Pallet::::on_chain_storage_version() < Pallet::current_storage_version()); + assert!(Pallet::::on_chain_storage_version() < Pallet::::current_storage_version()); assert_eq!(ConnectedAccounts::::iter().count(), 0); + log::info!("👥 DID lookup pallet to v{:?} passes PRE migrate checks ✅", Pallet::::current_storage_version()); + Ok(()) } @@ -50,6 +52,8 @@ impl OnRuntimeUpgrade for LookupReverseIndexMigration { Pallet::::current_storage_version().put::>(); + log::info!("👥 completed DID lookup pallet migration to v3 ✅",); + total_weight } @@ -70,6 +74,8 @@ impl OnRuntimeUpgrade for LookupReverseIndexMigration { assert_eq!(entry.did, did); }); + log::info!("👥 DID lookup pallet to v{:?} passes POST migrate checks ✅", Pallet::::current_storage_version()); + Ok(()) } } diff --git a/runtimes/peregrine/Cargo.toml b/runtimes/peregrine/Cargo.toml index 36fce11822..2b68f78ed1 100644 --- a/runtimes/peregrine/Cargo.toml +++ b/runtimes/peregrine/Cargo.toml @@ -209,6 +209,7 @@ try-runtime = [ "pallet-authorship/try-runtime", "pallet-balances/try-runtime", "pallet-collective/try-runtime", + "pallet-did-lookup/try-runtime", "pallet-democracy/try-runtime", "pallet-indices/try-runtime", "pallet-membership/try-runtime", diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index 46a8df87a2..93d835c44c 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -81,7 +81,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("mashnet-node"), impl_name: create_runtime_str!("mashnet-node"), authoring_version: 4, - spec_version: 10500, + spec_version: 10600, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, diff --git a/runtimes/spiritnet/Cargo.toml b/runtimes/spiritnet/Cargo.toml index bcd9c3a12a..67047c38da 100644 --- a/runtimes/spiritnet/Cargo.toml +++ b/runtimes/spiritnet/Cargo.toml @@ -210,6 +210,7 @@ try-runtime = [ "pallet-balances/try-runtime", "pallet-collective/try-runtime", "pallet-democracy/try-runtime", + "pallet-did-lookup/try-runtime", "pallet-indices/try-runtime", "pallet-membership/try-runtime", "pallet-preimage/try-runtime", diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index 80ccf938fa..e8f454ffee 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -81,7 +81,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("kilt-spiritnet"), impl_name: create_runtime_str!("kilt-spiritnet"), authoring_version: 1, - spec_version: 10500, + spec_version: 10600, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/runtimes/standalone/Cargo.toml b/runtimes/standalone/Cargo.toml index 9e3895ce73..33988492b9 100644 --- a/runtimes/standalone/Cargo.toml +++ b/runtimes/standalone/Cargo.toml @@ -152,6 +152,7 @@ try-runtime = [ "pallet-aura/try-runtime", "pallet-authorship/try-runtime", "pallet-balances/try-runtime", + "pallet-did-lookup/try-runtime", "pallet-grandpa/try-runtime", "pallet-indices/try-runtime", "pallet-proxy/try-runtime", diff --git a/runtimes/standalone/src/lib.rs b/runtimes/standalone/src/lib.rs index 2e05c60cdb..c37a5a0ebb 100644 --- a/runtimes/standalone/src/lib.rs +++ b/runtimes/standalone/src/lib.rs @@ -116,7 +116,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("mashnet-node"), impl_name: create_runtime_str!("mashnet-node"), authoring_version: 4, - spec_version: 10500, + spec_version: 10600, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From 08fc0c8af52cbdab5ce57fe9a2f78a7d03c482c8 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Tue, 22 Mar 2022 10:31:44 +0100 Subject: [PATCH 18/30] chore: fixes after rebase --- pallets/attestation/src/mock.rs | 19 ++----------------- pallets/delegation/src/mock.rs | 12 +++++++++--- pallets/pallet-did-lookup/src/lib.rs | 2 +- runtimes/peregrine/src/lib.rs | 2 +- runtimes/spiritnet/src/lib.rs | 2 +- runtimes/standalone/src/lib.rs | 2 +- 6 files changed, 15 insertions(+), 24 deletions(-) diff --git a/pallets/attestation/src/mock.rs b/pallets/attestation/src/mock.rs index 05d7eccf99..51665c2b28 100644 --- a/pallets/attestation/src/mock.rs +++ b/pallets/attestation/src/mock.rs @@ -324,22 +324,7 @@ pub(crate) mod runtime { impl ExtBuilder { #[must_use] - pub fn with_delegation_hierarchies( - mut self, - delegation_hierarchies: DelegationHierarchyInitialization, - ) -> Self { - self.delegation_hierarchies = delegation_hierarchies; - self - } - - #[must_use] - pub fn with_delegations(mut self, delegations: Vec<(TestDelegationNodeId, DelegationNode)>) -> Self { - self.delegations = delegations; - self - } - - #[must_use] - pub fn with_ctypes(mut self, ctypes: Vec<(TestCtypeHash, CtypeCreatorOf)>) -> Self { + pub fn with_ctypes(mut self, ctypes: Vec<(CtypeHashOf, CtypeCreatorOf)>) -> Self { self.ctypes = ctypes; self } @@ -351,7 +336,7 @@ pub(crate) mod runtime { } #[must_use] - pub fn with_attestations(mut self, attestations: Vec<(TestClaimHash, AttestationDetails)>) -> Self { + pub fn with_attestations(mut self, attestations: Vec<(ClaimHashOf, AttestationDetails)>) -> Self { self.attestations = attestations; self } diff --git a/pallets/delegation/src/mock.rs b/pallets/delegation/src/mock.rs index e2dbc6fe23..b096f56a8f 100644 --- a/pallets/delegation/src/mock.rs +++ b/pallets/delegation/src/mock.rs @@ -464,14 +464,20 @@ pub(crate) mod runtime { } #[must_use] - pub fn with_ctypes(mut self, ctypes: Vec<(TestCtypeHash, SubjectId)>) -> Self { + pub fn with_ctypes(mut self, ctypes: Vec<(CtypeHashOf, SubjectId)>) -> Self { self.ctypes = ctypes; self } #[must_use] - pub fn with_delegations(mut self, delegations: Vec<(TestDelegationNodeId, DelegationNode)>) -> Self { - self.delegations_stored = delegations; + pub fn with_delegations(mut self, delegations: Vec<(DelegationNodeIdOf, DelegationNode)>) -> Self { + self.delegations = delegations; + self + } + + #[must_use] + pub fn with_attestations(mut self, attestations: Vec<(ClaimHashOf, AttestationDetails)>) -> Self { + self.attestations = attestations; self } diff --git a/pallets/pallet-did-lookup/src/lib.rs b/pallets/pallet-did-lookup/src/lib.rs index 9a02799694..0fa0f5a63d 100644 --- a/pallets/pallet-did-lookup/src/lib.rs +++ b/pallets/pallet-did-lookup/src/lib.rs @@ -109,7 +109,7 @@ pub mod pallet { /// Mapping from account identifiers to DIDs. #[pallet::storage] #[pallet::getter(fn connected_dids)] - pub type ConnectedDids = CountedStorageMap<_, Blake2_128Concat, AccountIdOf, ConnectionRecordOf>; + pub type ConnectedDids = StorageMap<_, Blake2_128Concat, AccountIdOf, ConnectionRecordOf>; /// Mapping from account identifiers to DIDs. #[pallet::storage] diff --git a/runtimes/peregrine/src/lib.rs b/runtimes/peregrine/src/lib.rs index 93d835c44c..46a8df87a2 100644 --- a/runtimes/peregrine/src/lib.rs +++ b/runtimes/peregrine/src/lib.rs @@ -81,7 +81,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("mashnet-node"), impl_name: create_runtime_str!("mashnet-node"), authoring_version: 4, - spec_version: 10600, + spec_version: 10500, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, diff --git a/runtimes/spiritnet/src/lib.rs b/runtimes/spiritnet/src/lib.rs index e8f454ffee..80ccf938fa 100644 --- a/runtimes/spiritnet/src/lib.rs +++ b/runtimes/spiritnet/src/lib.rs @@ -81,7 +81,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("kilt-spiritnet"), impl_name: create_runtime_str!("kilt-spiritnet"), authoring_version: 1, - spec_version: 10600, + spec_version: 10500, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 1, diff --git a/runtimes/standalone/src/lib.rs b/runtimes/standalone/src/lib.rs index c37a5a0ebb..2e05c60cdb 100644 --- a/runtimes/standalone/src/lib.rs +++ b/runtimes/standalone/src/lib.rs @@ -116,7 +116,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("mashnet-node"), impl_name: create_runtime_str!("mashnet-node"), authoring_version: 4, - spec_version: 10600, + spec_version: 10500, impl_version: 0, apis: RUNTIME_API_VERSIONS, transaction_version: 2, From ae0275cf691fda75089427352eb48e405b6b63ad Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Tue, 22 Mar 2022 10:43:57 +0100 Subject: [PATCH 19/30] chore: fmt --- pallets/pallet-did-lookup/src/migrations.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pallets/pallet-did-lookup/src/migrations.rs b/pallets/pallet-did-lookup/src/migrations.rs index 66820b8d25..06715d10c1 100644 --- a/pallets/pallet-did-lookup/src/migrations.rs +++ b/pallets/pallet-did-lookup/src/migrations.rs @@ -31,7 +31,10 @@ impl OnRuntimeUpgrade for LookupReverseIndexMigration { assert!(Pallet::::on_chain_storage_version() < Pallet::::current_storage_version()); assert_eq!(ConnectedAccounts::::iter().count(), 0); - log::info!("👥 DID lookup pallet to v{:?} passes PRE migrate checks ✅", Pallet::::current_storage_version()); + log::info!( + "👥 DID lookup pallet to {:?} passes PRE migrate checks ✅", + Pallet::::current_storage_version() + ); Ok(()) } @@ -52,7 +55,10 @@ impl OnRuntimeUpgrade for LookupReverseIndexMigration { Pallet::::current_storage_version().put::>(); - log::info!("👥 completed DID lookup pallet migration to v3 ✅",); + log::info!( + "👥 completed DID lookup pallet migration to {:?} ✅", + Pallet::::current_storage_version() + ); total_weight } @@ -74,7 +80,10 @@ impl OnRuntimeUpgrade for LookupReverseIndexMigration { assert_eq!(entry.did, did); }); - log::info!("👥 DID lookup pallet to v{:?} passes POST migrate checks ✅", Pallet::::current_storage_version()); + log::info!( + "👥 DID lookup pallet to {:?} passes POST migrate checks ✅", + Pallet::::current_storage_version() + ); Ok(()) } From 0421c854b5dc1eb788b46c181e061523b3a023b5 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Wed, 23 Mar 2022 16:34:21 +0100 Subject: [PATCH 20/30] chore: ConnectedAccounts map comment --- pallets/pallet-did-lookup/src/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pallets/pallet-did-lookup/src/lib.rs b/pallets/pallet-did-lookup/src/lib.rs index 0fa0f5a63d..42d5c29fbf 100644 --- a/pallets/pallet-did-lookup/src/lib.rs +++ b/pallets/pallet-did-lookup/src/lib.rs @@ -111,7 +111,9 @@ pub mod pallet { #[pallet::getter(fn connected_dids)] pub type ConnectedDids = StorageMap<_, Blake2_128Concat, AccountIdOf, ConnectionRecordOf>; - /// Mapping from account identifiers to DIDs. + /// Mapping from (DID + account identifier) -> (). + /// The empty tuple is used as a sentinel value to simply indicate the + /// presence of a given tuple in the map. #[pallet::storage] #[pallet::getter(fn connected_accounts)] pub type ConnectedAccounts = From bb00c5d1397d05cdbe331d5c545e378df3c00860 Mon Sep 17 00:00:00 2001 From: kiltbot <> Date: Thu, 24 Mar 2022 11:29:37 +0100 Subject: [PATCH 21/30] cargo run --quiet --release -p kilt-parachain --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet-did-lookup --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=pallets/pallet-did-lookup/src/default_weights.rs --template=.maintain/weight-template.hbs --- .../pallet-did-lookup/src/default_weights.rs | 73 ++++++++++++------- 1 file changed, 46 insertions(+), 27 deletions(-) diff --git a/pallets/pallet-did-lookup/src/default_weights.rs b/pallets/pallet-did-lookup/src/default_weights.rs index dc0b878cc8..e634b779c2 100644 --- a/pallets/pallet-did-lookup/src/default_weights.rs +++ b/pallets/pallet-did-lookup/src/default_weights.rs @@ -19,8 +19,8 @@ //! Autogenerated weights for pallet_did_lookup //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2021-11-19, STEPS: {{cmd.steps}}\, REPEAT: {{cmd.repeat}}\, LOW RANGE: {{cmd.lowest_range_values}}\, HIGH RANGE: {{cmd.highest_range_values}}\ -//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128 +//! DATE: 2022-03-24, STEPS: {{cmd.steps}}\, REPEAT: {{cmd.repeat}}\, LOW RANGE: {{cmd.lowest_range_values}}\, HIGH RANGE: {{cmd.highest_range_values}}\ +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 // Executed Command: // target/release/kilt-parachain @@ -36,7 +36,6 @@ // --output=pallets/pallet-did-lookup/src/default_weights.rs // --template=.maintain/weight-template.hbs - #![cfg_attr(rustfmt, rustfmt_skip)] #![allow(unused_parens)] #![allow(unused_imports)] @@ -56,52 +55,72 @@ pub trait WeightInfo { /// Weights for pallet_did_lookup using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { + // Storage: System Account (r:1 w:1) // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) fn associate_account() -> Weight { - (74_292_000_u64) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + (94_624_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) } + // Storage: System Account (r:1 w:1) // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) fn associate_sender() -> Weight { - (17_673_000_u64) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + (36_138_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) } // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) fn remove_sender_association() -> Weight { - (19_086_000_u64) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + (35_334_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) } // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) fn remove_account_association() -> Weight { - (21_926_000_u64) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + (37_209_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) } } // For backwards compatibility and tests impl WeightInfo for () { + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) fn associate_account() -> Weight { - (74_292_000_u64) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + (94_624_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(2 as Weight)) + .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) fn associate_sender() -> Weight { - (17_673_000_u64) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + (36_138_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(2 as Weight)) + .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) fn remove_sender_association() -> Weight { - (19_086_000_u64) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + (35_334_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(2 as Weight)) + .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) fn remove_account_association() -> Weight { - (21_926_000_u64) - .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + (37_209_000 as Weight) + .saturating_add(RocksDbWeight::get().reads(2 as Weight)) + .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } } From c459a6b4a616167679fc65ef799fee2c8be12920 Mon Sep 17 00:00:00 2001 From: kiltbot <> Date: Thu, 24 Mar 2022 11:37:55 +0100 Subject: [PATCH 22/30] cargo run --quiet --release -p kilt-parachain --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet-did-lookup --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./runtimes/peregrine/src/weights/pallet_did-lookup.rs --template=.maintain/runtime-weight-template.hbs --- .../src/weights/pallet_did-lookup.rs | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 runtimes/peregrine/src/weights/pallet_did-lookup.rs diff --git a/runtimes/peregrine/src/weights/pallet_did-lookup.rs b/runtimes/peregrine/src/weights/pallet_did-lookup.rs new file mode 100644 index 0000000000..bc8045d995 --- /dev/null +++ b/runtimes/peregrine/src/weights/pallet_did-lookup.rs @@ -0,0 +1,82 @@ +// 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 pallet_did_lookup +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-03-24, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// target/release/kilt-parachain +// benchmark +// --chain=dev +// --steps=50 +// --repeat=20 +// --pallet=pallet-did-lookup +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=./runtimes/peregrine/src/weights/pallet_did-lookup.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; + +/// Weight functions for `pallet_did_lookup`. +pub struct WeightInfo(PhantomData); +impl pallet_did_lookup::WeightInfo for WeightInfo { + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) + fn associate_account() -> Weight { + (95_332_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) + fn associate_sender() -> Weight { + (36_891_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) + fn remove_sender_association() -> Weight { + (36_213_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) + fn remove_account_association() -> Weight { + (38_396_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } +} From f2d766afd58e2fff8bc147346c61ea312e3ae891 Mon Sep 17 00:00:00 2001 From: kiltbot <> Date: Thu, 24 Mar 2022 11:40:02 +0100 Subject: [PATCH 23/30] cargo run --quiet --release -p kilt-parachain --features=runtime-benchmarks -- benchmark --chain=spiritnet-dev --steps=50 --repeat=20 --pallet=pallet-did-lookup --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./runtimes/spiritnet/src/weights/pallet_did-lookup.rs --template=.maintain/runtime-weight-template.hbs --- .../src/weights/pallet_did-lookup.rs | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 runtimes/spiritnet/src/weights/pallet_did-lookup.rs diff --git a/runtimes/spiritnet/src/weights/pallet_did-lookup.rs b/runtimes/spiritnet/src/weights/pallet_did-lookup.rs new file mode 100644 index 0000000000..8374d9cafc --- /dev/null +++ b/runtimes/spiritnet/src/weights/pallet_did-lookup.rs @@ -0,0 +1,82 @@ +// 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 pallet_did_lookup +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2022-03-24, 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 +// --chain=spiritnet-dev +// --steps=50 +// --repeat=20 +// --pallet=pallet-did-lookup +// --extrinsic=* +// --execution=wasm +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=./runtimes/spiritnet/src/weights/pallet_did-lookup.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; + +/// Weight functions for `pallet_did_lookup`. +pub struct WeightInfo(PhantomData); +impl pallet_did_lookup::WeightInfo for WeightInfo { + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) + fn associate_account() -> Weight { + (95_016_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) + fn associate_sender() -> Weight { + (36_565_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) + fn remove_sender_association() -> Weight { + (35_199_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } + // Storage: DidLookup ConnectedDids (r:1 w:1) + // Storage: System Account (r:1 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:1) + fn remove_account_association() -> Weight { + (37_242_000 as Weight) + .saturating_add(T::DbWeight::get().reads(2 as Weight)) + .saturating_add(T::DbWeight::get().writes(3 as Weight)) + } +} From 8297e3688f22c5382c93654d00039778901a0bef Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Thu, 24 Mar 2022 13:19:59 +0100 Subject: [PATCH 24/30] bench: update benchmarks to include account replacement as worst case --- pallets/pallet-did-lookup/src/benchmarking.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pallets/pallet-did-lookup/src/benchmarking.rs b/pallets/pallet-did-lookup/src/benchmarking.rs index 81a402731a..ffb81d7531 100644 --- a/pallets/pallet-did-lookup/src/benchmarking.rs +++ b/pallets/pallet-did-lookup/src/benchmarking.rs @@ -48,6 +48,7 @@ benchmarks! { associate_account { let caller: T::AccountId = account("caller", 0, SEED); let did: T::DidIdentifier = account("did", 0, SEED); + let previous_did: T::DidIdentifier = account("prev", 0, SEED + 1); let connected_acc = sr25519_generate(KeyTypeId(*b"aura"), None); let connected_acc_id: T::AccountId = connected_acc.into(); let bn: ::BlockNumber = 500_u32.into(); @@ -57,22 +58,33 @@ benchmarks! { .into(); make_free_for_did::(&caller); + + // Add existing connected_acc -> previous_did connection that will be replaced + Pallet::::add_association(caller.clone(), previous_did.clone(), connected_acc_id.clone()).expect("should create previous association"); + assert!(ConnectedAccounts::::get(&previous_did, T::AccountId::from(connected_acc)).is_some()); let origin = T::EnsureOrigin::generate_origin(caller, did.clone()); }: _(origin, connected_acc_id, bn, sig) verify { assert!(ConnectedDids::::get(T::AccountId::from(connected_acc)).is_some()); + assert!(ConnectedAccounts::::get(&previous_did, T::AccountId::from(connected_acc)).is_none()); assert!(ConnectedAccounts::::get(did, T::AccountId::from(connected_acc)).is_some()); } associate_sender { let caller: T::AccountId = account("caller", 0, SEED); let did: T::DidIdentifier = account("did", 0, SEED); + let previous_did: T::DidIdentifier = account("prev", 0, SEED + 1); make_free_for_did::(&caller); + + // Add existing sender -> previous_did connection that will be replaced + Pallet::::add_association(caller.clone(), previous_did.clone(), caller.clone()).expect("should create previous association"); + assert!(ConnectedAccounts::::get(&previous_did, &caller).is_some()); let origin = T::EnsureOrigin::generate_origin(caller.clone(), did.clone()); }: _(origin) verify { assert!(ConnectedDids::::get(&caller).is_some()); + assert!(ConnectedAccounts::::get(previous_did, &caller).is_none()); assert!(ConnectedAccounts::::get(did, caller).is_some()); } From 54daad19c5a78966e328277cc036208cd8ccc047 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Thu, 24 Mar 2022 13:57:45 +0100 Subject: [PATCH 25/30] bench: fix InsufficientFunds error in benchmarks --- pallets/pallet-did-lookup/src/benchmarking.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pallets/pallet-did-lookup/src/benchmarking.rs b/pallets/pallet-did-lookup/src/benchmarking.rs index ffb81d7531..3f589d2154 100644 --- a/pallets/pallet-did-lookup/src/benchmarking.rs +++ b/pallets/pallet-did-lookup/src/benchmarking.rs @@ -31,8 +31,9 @@ use sp_runtime::{app_crypto::sr25519, KeyTypeId}; const SEED: u32 = 0; +// Free 2x deposit amount + existential deposit so that we can use this function to link an account two times to two different DIDs. fn make_free_for_did(account: &AccountIdOf) { - let balance = as Currency>>::minimum_balance() + ::Deposit::get(); + let balance = as Currency>>::minimum_balance() + ::Deposit::get() + ::Deposit::get(); as Currency>>::make_free_balance_be(account, balance); } From 2732dd3b9478802b2e03daf6d82d23912cfdcafc Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Thu, 24 Mar 2022 13:58:49 +0100 Subject: [PATCH 26/30] chore: fmt --- pallets/pallet-did-lookup/src/benchmarking.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pallets/pallet-did-lookup/src/benchmarking.rs b/pallets/pallet-did-lookup/src/benchmarking.rs index 3f589d2154..eb0fede07c 100644 --- a/pallets/pallet-did-lookup/src/benchmarking.rs +++ b/pallets/pallet-did-lookup/src/benchmarking.rs @@ -31,9 +31,12 @@ use sp_runtime::{app_crypto::sr25519, KeyTypeId}; const SEED: u32 = 0; -// Free 2x deposit amount + existential deposit so that we can use this function to link an account two times to two different DIDs. +// Free 2x deposit amount + existential deposit so that we can use this function +// to link an account two times to two different DIDs. fn make_free_for_did(account: &AccountIdOf) { - let balance = as Currency>>::minimum_balance() + ::Deposit::get() + ::Deposit::get(); + let balance = as Currency>>::minimum_balance() + + ::Deposit::get() + + ::Deposit::get(); as Currency>>::make_free_balance_be(account, balance); } From ef0ed6979a4600bbebb3240db0bc81d15e7e8a4e Mon Sep 17 00:00:00 2001 From: kiltbot <> Date: Thu, 24 Mar 2022 14:02:00 +0100 Subject: [PATCH 27/30] cargo run --quiet --release -p kilt-parachain --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet-did-lookup --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=pallets/pallet-did-lookup/src/default_weights.rs --template=.maintain/weight-template.hbs --- .../pallet-did-lookup/src/default_weights.rs | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/pallets/pallet-did-lookup/src/default_weights.rs b/pallets/pallet-did-lookup/src/default_weights.rs index e634b779c2..ec036e02ab 100644 --- a/pallets/pallet-did-lookup/src/default_weights.rs +++ b/pallets/pallet-did-lookup/src/default_weights.rs @@ -57,25 +57,25 @@ pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) // Storage: DidLookup ConnectedDids (r:1 w:1) - // Storage: DidLookup ConnectedAccounts (r:0 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:2) fn associate_account() -> Weight { - (94_624_000 as Weight) + (111_846_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) } // Storage: System Account (r:1 w:1) // Storage: DidLookup ConnectedDids (r:1 w:1) - // Storage: DidLookup ConnectedAccounts (r:0 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:2) fn associate_sender() -> Weight { - (36_138_000 as Weight) + (52_637_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) } // Storage: DidLookup ConnectedDids (r:1 w:1) // Storage: System Account (r:1 w:1) // Storage: DidLookup ConnectedAccounts (r:0 w:1) fn remove_sender_association() -> Weight { - (35_334_000 as Weight) + (35_370_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -83,7 +83,7 @@ impl WeightInfo for SubstrateWeight { // Storage: System Account (r:1 w:1) // Storage: DidLookup ConnectedAccounts (r:0 w:1) fn remove_account_association() -> Weight { - (37_209_000 as Weight) + (36_181_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -93,25 +93,25 @@ impl WeightInfo for SubstrateWeight { impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Storage: DidLookup ConnectedDids (r:1 w:1) - // Storage: DidLookup ConnectedAccounts (r:0 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:2) fn associate_account() -> Weight { - (94_624_000 as Weight) + (111_846_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } // Storage: System Account (r:1 w:1) // Storage: DidLookup ConnectedDids (r:1 w:1) - // Storage: DidLookup ConnectedAccounts (r:0 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:2) fn associate_sender() -> Weight { - (36_138_000 as Weight) + (52_637_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) - .saturating_add(RocksDbWeight::get().writes(3 as Weight)) + .saturating_add(RocksDbWeight::get().writes(4 as Weight)) } // Storage: DidLookup ConnectedDids (r:1 w:1) // Storage: System Account (r:1 w:1) // Storage: DidLookup ConnectedAccounts (r:0 w:1) fn remove_sender_association() -> Weight { - (35_334_000 as Weight) + (35_370_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } @@ -119,7 +119,7 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Storage: DidLookup ConnectedAccounts (r:0 w:1) fn remove_account_association() -> Weight { - (37_209_000 as Weight) + (36_181_000 as Weight) .saturating_add(RocksDbWeight::get().reads(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(3 as Weight)) } From 1f41720c02fa368d979fc9640938091c3b3ba364 Mon Sep 17 00:00:00 2001 From: Antonio Antonino Date: Thu, 24 Mar 2022 14:09:05 +0100 Subject: [PATCH 28/30] chore: update comments --- pallets/pallet-did-lookup/src/lib.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pallets/pallet-did-lookup/src/lib.rs b/pallets/pallet-did-lookup/src/lib.rs index 42d5c29fbf..9877c0d54e 100644 --- a/pallets/pallet-did-lookup/src/lib.rs +++ b/pallets/pallet-did-lookup/src/lib.rs @@ -162,8 +162,8 @@ pub mod pallet { /// /// # /// Weight: O(1) - /// - Reads: ConnectedDids + DID Origin Check - /// - Writes: ConnectedDids + /// - Reads: ConnectedDids + ConnectedAccounts + DID Origin Check + /// - Writes: ConnectedDids + ConnectedAccounts /// # #[pallet::weight(::WeightInfo::associate_account())] pub fn associate_account( @@ -205,8 +205,8 @@ pub mod pallet { /// /// # /// Weight: O(1) - /// - Reads: ConnectedDids + DID Origin Check - /// - Writes: ConnectedDids + /// - Reads: ConnectedDids + ConnectedAccounts + DID Origin Check + /// - Writes: ConnectedDids + ConnectedAccounts /// # #[pallet::weight(::WeightInfo::associate_sender())] pub fn associate_sender(origin: OriginFor) -> DispatchResult { @@ -231,8 +231,8 @@ pub mod pallet { /// /// # /// Weight: O(1) - /// - Reads: ConnectedDids - /// - Writes: ConnectedDids + /// - Reads: ConnectedDids + ConnectedAccounts + DID Origin Check + /// - Writes: ConnectedDids + ConnectedAccounts /// # #[pallet::weight(::WeightInfo::remove_sender_association())] pub fn remove_sender_association(origin: OriginFor) -> DispatchResult { @@ -249,8 +249,8 @@ pub mod pallet { /// /// # /// Weight: O(1) - /// - Reads: ConnectedDids + DID Origin Check - /// - Writes: ConnectedDids + /// - Reads: ConnectedDids + ConnectedAccounts + DID Origin Check + /// - Writes: ConnectedDids + ConnectedAccounts /// # #[pallet::weight(::WeightInfo::remove_account_association())] pub fn remove_account_association(origin: OriginFor, account: AccountIdOf) -> DispatchResult { From 05ceed41b51654198fd80aeb1a23f6cf847f0589 Mon Sep 17 00:00:00 2001 From: kiltbot <> Date: Thu, 24 Mar 2022 14:35:30 +0100 Subject: [PATCH 29/30] cargo run --quiet --release -p kilt-parachain --features=runtime-benchmarks -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet-did-lookup --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./runtimes/peregrine/src/weights/pallet_did-lookup.rs --template=.maintain/runtime-weight-template.hbs --- .../peregrine/src/weights/pallet_did-lookup.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/runtimes/peregrine/src/weights/pallet_did-lookup.rs b/runtimes/peregrine/src/weights/pallet_did-lookup.rs index bc8045d995..3071edb8c8 100644 --- a/runtimes/peregrine/src/weights/pallet_did-lookup.rs +++ b/runtimes/peregrine/src/weights/pallet_did-lookup.rs @@ -49,25 +49,25 @@ pub struct WeightInfo(PhantomData); impl pallet_did_lookup::WeightInfo for WeightInfo { // Storage: System Account (r:1 w:1) // Storage: DidLookup ConnectedDids (r:1 w:1) - // Storage: DidLookup ConnectedAccounts (r:0 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:2) fn associate_account() -> Weight { - (95_332_000 as Weight) + (114_124_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) } // Storage: System Account (r:1 w:1) // Storage: DidLookup ConnectedDids (r:1 w:1) - // Storage: DidLookup ConnectedAccounts (r:0 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:2) fn associate_sender() -> Weight { - (36_891_000 as Weight) + (55_985_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) } // Storage: DidLookup ConnectedDids (r:1 w:1) // Storage: System Account (r:1 w:1) // Storage: DidLookup ConnectedAccounts (r:0 w:1) fn remove_sender_association() -> Weight { - (36_213_000 as Weight) + (36_223_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -75,7 +75,7 @@ impl pallet_did_lookup::WeightInfo for WeightInfo { // Storage: System Account (r:1 w:1) // Storage: DidLookup ConnectedAccounts (r:0 w:1) fn remove_account_association() -> Weight { - (38_396_000 as Weight) + (39_356_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } From 7cd84a06f32e687fafce40689cb0fc7759cf024c Mon Sep 17 00:00:00 2001 From: kiltbot <> Date: Thu, 24 Mar 2022 14:39:15 +0100 Subject: [PATCH 30/30] cargo run --quiet --release -p kilt-parachain --features=runtime-benchmarks -- benchmark --chain=spiritnet-dev --steps=50 --repeat=20 --pallet=pallet-did-lookup --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./runtimes/spiritnet/src/weights/pallet_did-lookup.rs --template=.maintain/runtime-weight-template.hbs --- .../spiritnet/src/weights/pallet_did-lookup.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/runtimes/spiritnet/src/weights/pallet_did-lookup.rs b/runtimes/spiritnet/src/weights/pallet_did-lookup.rs index 8374d9cafc..9f3dad3192 100644 --- a/runtimes/spiritnet/src/weights/pallet_did-lookup.rs +++ b/runtimes/spiritnet/src/weights/pallet_did-lookup.rs @@ -49,25 +49,25 @@ pub struct WeightInfo(PhantomData); impl pallet_did_lookup::WeightInfo for WeightInfo { // Storage: System Account (r:1 w:1) // Storage: DidLookup ConnectedDids (r:1 w:1) - // Storage: DidLookup ConnectedAccounts (r:0 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:2) fn associate_account() -> Weight { - (95_016_000 as Weight) + (111_855_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) } // Storage: System Account (r:1 w:1) // Storage: DidLookup ConnectedDids (r:1 w:1) - // Storage: DidLookup ConnectedAccounts (r:0 w:1) + // Storage: DidLookup ConnectedAccounts (r:0 w:2) fn associate_sender() -> Weight { - (36_565_000 as Weight) + (53_834_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) - .saturating_add(T::DbWeight::get().writes(3 as Weight)) + .saturating_add(T::DbWeight::get().writes(4 as Weight)) } // Storage: DidLookup ConnectedDids (r:1 w:1) // Storage: System Account (r:1 w:1) // Storage: DidLookup ConnectedAccounts (r:0 w:1) fn remove_sender_association() -> Weight { - (35_199_000 as Weight) + (35_194_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) } @@ -75,7 +75,7 @@ impl pallet_did_lookup::WeightInfo for WeightInfo { // Storage: System Account (r:1 w:1) // Storage: DidLookup ConnectedAccounts (r:0 w:1) fn remove_account_association() -> Weight { - (37_242_000 as Weight) + (38_608_000 as Weight) .saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight)) }