From c1906eb28f1239dfe1bd6ef86e0ebf01f3a542e5 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 26 Apr 2023 12:58:58 +0200 Subject: [PATCH 01/40] first draft --- pallets/did/src/lib.rs | 55 ++++++++++++++++++++++++++++++++++++++++ pallets/did/src/mock.rs | 10 +++++++- pallets/did/src/tests.rs | 3 +-- 3 files changed, 65 insertions(+), 3 deletions(-) diff --git a/pallets/did/src/lib.rs b/pallets/did/src/lib.rs index 61f102273..0ee6c46d5 100644 --- a/pallets/did/src/lib.rs +++ b/pallets/did/src/lib.rs @@ -463,6 +463,15 @@ pub mod pallet { } } + #[pallet::hooks] + impl Hooks> for Pallet { + #[cfg(feature = "try-runtime")] + fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { + do_try_state()?; + Ok(()) + } + } + #[pallet::call] impl Pallet { /// Store a new DID on chain, after verifying that the creation @@ -1227,6 +1236,52 @@ pub mod pallet { Ok(()) } + + #[cfg(any(feature = "try-runtime", test))] + pub fn do_try_state() -> DispatchResult { + Did::::iter().try_for_each( + |(did_subject, did_details): (DidIdentifierOf, DidDetails)| -> DispatchResult { + let service_endpoints_count: usize = ServiceEndpoints::::iter_prefix(&did_subject).count(); + + ensure!( + service_endpoints_count == DidEndpointsCount::::get(&did_subject).saturated_into::(), + DispatchError::Other("Storage Error: amount of endpoints are not matching!") + ); + + ensure!( + did_details.key_agreement_keys.len() + > ::MaxTotalKeyAgreementKeys::get().saturated_into::(), + DispatchError::Other("Storage Error: amount of endpoints are not matching!") + ); + + ensure!( + service_endpoints_count + < ::MaxNumberOfServicesPerDid::get().saturated_into::(), + DispatchError::Other("Stoarge Error: amount of endpoints is to high!") + ); + + ensure!( + !DidBlacklist::::contains_key(did_subject), + DispatchError::Other("Deleted DID is still in storage!") + ); + + Ok(()) + }, + )?; + + DidBlacklist::::iter_keys().try_for_each(|deleted_did_subject| -> DispatchResult { + let service_endpoints_count = ServiceEndpoints::::iter_prefix(&deleted_did_subject).count(); + + ensure!( + service_endpoints_count == 0, + DispatchError::Other("Deleted service enpoints are still in storage!") + ); + + Ok(()) + })?; + + Ok(()) + } } struct DidDepositCollector(PhantomData); diff --git a/pallets/did/src/mock.rs b/pallets/did/src/mock.rs index f5e539d57..20247e11c 100644 --- a/pallets/did/src/mock.rs +++ b/pallets/did/src/mock.rs @@ -40,7 +40,8 @@ use crate::{ RelationshipDeriveError, }, service_endpoints::DidEndpoint, - utils as crate_utils, AccountIdOf, Config, CurrencyOf, DidBlacklist, DidEndpointsCount, KeyIdOf, ServiceEndpoints, + utils as crate_utils, AccountIdOf, Config, CurrencyOf, DidBlacklist, DidEndpointsCount, KeyIdOf, Pallet, + ServiceEndpoints, }; #[cfg(not(feature = "runtime-benchmarks"))] use crate::{DidRawOrigin, EnsureDidOrigin}; @@ -499,6 +500,13 @@ impl ExtBuilder { ext } + pub fn build_and_execute_with_sanity_tests(self, ext: Option, test: impl FnOnce() -> ()) { + self.build(ext).execute_with(|| { + test(); + Pallet::::do_try_state().unwrap(); + }) + } + #[cfg(feature = "runtime-benchmarks")] pub fn build_with_keystore(self) -> sp_io::TestExternalities { let mut ext = self.build(None); diff --git a/pallets/did/src/tests.rs b/pallets/did/src/tests.rs index 804fde603..0602dab41 100644 --- a/pallets/did/src/tests.rs +++ b/pallets/did/src/tests.rs @@ -697,8 +697,7 @@ fn check_invalid_service_id_character_did_creation() { + <::Currency as Currency>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::create( RuntimeOrigin::signed(ACCOUNT_00), From f392dfabefb71278748687dd3699a080903d704b Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 26 Apr 2023 13:49:38 +0200 Subject: [PATCH 02/40] did finished --- pallets/did/src/lib.rs | 17 ++- pallets/did/src/tests.rs | 258 +++++++++++++-------------------------- 2 files changed, 93 insertions(+), 182 deletions(-) diff --git a/pallets/did/src/lib.rs b/pallets/did/src/lib.rs index 0ee6c46d5..9874ed2d0 100644 --- a/pallets/did/src/lib.rs +++ b/pallets/did/src/lib.rs @@ -1245,24 +1245,24 @@ pub mod pallet { ensure!( service_endpoints_count == DidEndpointsCount::::get(&did_subject).saturated_into::(), - DispatchError::Other("Storage Error: amount of endpoints are not matching!") + DispatchError::Other("Test") ); ensure!( did_details.key_agreement_keys.len() - > ::MaxTotalKeyAgreementKeys::get().saturated_into::(), - DispatchError::Other("Storage Error: amount of endpoints are not matching!") + <= ::MaxTotalKeyAgreementKeys::get().saturated_into::(), + DispatchError::Other("Test") ); ensure!( service_endpoints_count - < ::MaxNumberOfServicesPerDid::get().saturated_into::(), - DispatchError::Other("Stoarge Error: amount of endpoints is to high!") + <= ::MaxNumberOfServicesPerDid::get().saturated_into::(), + DispatchError::Other("Test") ); ensure!( !DidBlacklist::::contains_key(did_subject), - DispatchError::Other("Deleted DID is still in storage!") + DispatchError::Other("Test") ); Ok(()) @@ -1272,10 +1272,7 @@ pub mod pallet { DidBlacklist::::iter_keys().try_for_each(|deleted_did_subject| -> DispatchResult { let service_endpoints_count = ServiceEndpoints::::iter_prefix(&deleted_did_subject).count(); - ensure!( - service_endpoints_count == 0, - DispatchError::Other("Deleted service enpoints are still in storage!") - ); + ensure!(service_endpoints_count == 0, DispatchError::Other("Test")); Ok(()) })?; diff --git a/pallets/did/src/tests.rs b/pallets/did/src/tests.rs index 0602dab41..a0578ac07 100644 --- a/pallets/did/src/tests.rs +++ b/pallets/did/src/tests.rs @@ -53,8 +53,7 @@ fn check_successful_simple_ed25519_creation() { + <::Currency as Currency>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::create( RuntimeOrigin::signed(ACCOUNT_00), Box::new(details), @@ -95,8 +94,7 @@ fn check_successful_simple_sr25519_creation() { + <::Currency as Currency>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::create( RuntimeOrigin::signed(ACCOUNT_00), Box::new(details), @@ -137,8 +135,7 @@ fn check_successful_simple_ecdsa_creation() { + <::Currency as Currency>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::create( RuntimeOrigin::signed(ACCOUNT_00), Box::new(details), @@ -198,8 +195,7 @@ fn check_successful_complete_creation() { + <::Currency as Currency>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::create( RuntimeOrigin::signed(ACCOUNT_00), Box::new(details.clone()), @@ -287,8 +283,7 @@ fn check_duplicate_did_creation() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .with_dids(vec![(alice_did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::create( RuntimeOrigin::signed(ACCOUNT_00), @@ -317,8 +312,7 @@ fn check_unauthorised_submitter_did_creation_error() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .with_dids(vec![(alice_did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( // Use ACCOUNT_00 to submit the transaction Did::create( @@ -365,8 +359,7 @@ fn check_did_already_deleted_creation() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .with_deleted_dids(vec![alice_did]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::create( RuntimeOrigin::signed(ACCOUNT_00), @@ -394,8 +387,7 @@ fn check_invalid_signature_format_did_creation() { + <::Currency as Currency>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::create( RuntimeOrigin::signed(ACCOUNT_00), @@ -421,8 +413,7 @@ fn check_invalid_signature_did_creation() { + <::Currency as Currency>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::create( RuntimeOrigin::signed(ACCOUNT_00), @@ -448,8 +439,7 @@ fn check_swapped_did_subject_did_creation() { + <::Currency as Currency>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::create( RuntimeOrigin::signed(ACCOUNT_00), @@ -512,8 +502,7 @@ fn check_max_limit_service_endpoints_count_did_creation() { + <::Currency as Currency>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::create( RuntimeOrigin::signed(ACCOUNT_00), @@ -724,8 +713,7 @@ fn check_invalid_service_type_character_did_creation() { + <::Currency as Currency>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::create( RuntimeOrigin::signed(ACCOUNT_00), @@ -752,8 +740,7 @@ fn check_invalid_service_url_character_did_creation() { + <::Currency as Currency>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::create( RuntimeOrigin::signed(ACCOUNT_00), @@ -780,8 +767,7 @@ fn check_successful_authentication_key_update() { // Update authentication key. The old one should be removed. ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); assert_ok!(Did::set_authentication_key( RuntimeOrigin::signed(alice_did.clone()), @@ -821,8 +807,7 @@ fn check_successful_authentication_key_max_public_keys_update() { // Update authentication key. The old one should be removed. ExtBuilder::default() .with_dids(vec![(alice_did.clone(), did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); assert_ok!(Did::set_authentication_key( RuntimeOrigin::signed(alice_did.clone()), @@ -859,8 +844,7 @@ fn check_reused_key_authentication_key_update() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); assert_ok!(Did::set_authentication_key( RuntimeOrigin::signed(alice_did.clone()), @@ -910,8 +894,7 @@ fn check_max_keys_authentication_key_update_error() { // public keys is already present. ExtBuilder::default() .with_dids(vec![(alice_did.clone(), did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); assert_noop!( Did::set_authentication_key( @@ -959,8 +942,7 @@ fn check_successful_delegation_key_update() { // Update delegation key. The old one should be removed. ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); assert_ok!(Did::set_delegation_key( RuntimeOrigin::signed(alice_did.clone()), @@ -1002,8 +984,7 @@ fn check_successful_delegation_key_max_public_keys_update() { // Update delegation key. The old one should be removed. ExtBuilder::default() .with_dids(vec![(alice_did.clone(), did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); assert_ok!(Did::set_delegation_key( RuntimeOrigin::signed(alice_did.clone()), @@ -1038,8 +1019,7 @@ fn check_reused_key_delegation_key_update() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); assert_ok!(Did::set_delegation_key( RuntimeOrigin::signed(alice_did.clone()), @@ -1081,8 +1061,7 @@ fn check_max_public_keys_delegation_key_addition_error() { // Update delegation key. The old one should be removed. ExtBuilder::default() .with_dids(vec![(alice_did.clone(), did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); assert_noop!( Did::set_delegation_key( @@ -1117,8 +1096,7 @@ fn check_max_public_keys_reused_key_delegation_key_update_error() { // as authentication key. ExtBuilder::default() .with_dids(vec![(alice_did.clone(), did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); assert_noop!( Did::set_delegation_key( @@ -1162,8 +1140,7 @@ fn check_successful_delegation_key_deletion() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::remove_delegation_key(RuntimeOrigin::signed(alice_did.clone()))); let new_did_details = Did::get_did(&alice_did).expect("ALICE_DID should be present on chain."); @@ -1187,8 +1164,7 @@ fn check_successful_reused_delegation_key_deletion() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details.clone())]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::remove_delegation_key(RuntimeOrigin::signed(alice_did.clone()))); let new_did_details = Did::get_did(&alice_did).expect("ALICE_DID should be present on chain."); @@ -1224,8 +1200,7 @@ fn check_key_not_present_delegation_key_deletion_error() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::remove_delegation_key(RuntimeOrigin::signed(alice_did.clone())), did::Error::::VerificationKeyNotFound @@ -1248,8 +1223,7 @@ fn check_successful_attestation_key_update() { // Update attestation key. The old one should be removed. ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); assert_ok!(Did::set_attestation_key( RuntimeOrigin::signed(alice_did.clone()), @@ -1290,8 +1264,7 @@ fn check_successful_attestation_key_max_public_keys_update() { // Update attestation key. The old one should be removed. ExtBuilder::default() .with_dids(vec![(alice_did.clone(), did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); assert_ok!(Did::set_attestation_key( RuntimeOrigin::signed(alice_did.clone()), @@ -1325,8 +1298,7 @@ fn check_reused_key_attestation_key_update() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); assert_ok!(Did::set_attestation_key( RuntimeOrigin::signed(alice_did.clone()), @@ -1368,8 +1340,7 @@ fn check_max_public_keys_attestation_key_addition_error() { // Update attestation key. The old one should be removed. ExtBuilder::default() .with_dids(vec![(alice_did.clone(), did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); assert_noop!( Did::set_attestation_key( @@ -1404,8 +1375,7 @@ fn check_max_public_keys_reused_key_attestation_key_update_error() { // as authentication key. ExtBuilder::default() .with_dids(vec![(alice_did.clone(), did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); assert_noop!( Did::set_attestation_key( @@ -1449,8 +1419,7 @@ fn check_successful_attestation_key_deletion() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::remove_attestation_key(RuntimeOrigin::signed(alice_did.clone()))); let new_did_details = Did::get_did(&alice_did).expect("ALICE_DID should be present on chain."); @@ -1474,8 +1443,7 @@ fn check_successful_reused_attestation_key_deletion() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details.clone())]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::remove_attestation_key(RuntimeOrigin::signed(alice_did.clone()))); let new_did_details = Did::get_did(&alice_did).expect("ALICE_DID should be present on chain."); assert!(new_did_details.attestation_key.is_none()); @@ -1510,8 +1478,7 @@ fn check_key_not_present_attestation_key_deletion_error() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::remove_attestation_key(RuntimeOrigin::signed(alice_did.clone())), did::Error::::VerificationKeyNotFound @@ -1531,8 +1498,7 @@ fn check_successful_key_agreement_key_addition() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); assert_ok!(Did::add_key_agreement_key( RuntimeOrigin::signed(alice_did.clone()), @@ -1571,8 +1537,7 @@ fn check_max_public_keys_key_agreement_key_addition_error() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { System::set_block_number(new_block_number); assert_noop!( Did::add_key_agreement_key(RuntimeOrigin::signed(alice_did.clone()), new_key_agreement_key,), @@ -1610,8 +1575,7 @@ fn check_successful_key_agreement_key_deletion() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::remove_key_agreement_key( RuntimeOrigin::signed(alice_did.clone()), generate_key_id(&old_enc_key.into()), @@ -1654,8 +1618,7 @@ fn check_key_not_found_key_agreement_key_deletion_error() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::remove_key_agreement_key( RuntimeOrigin::signed(alice_did.clone()), @@ -1678,8 +1641,7 @@ fn check_service_addition_no_prior_service_successful() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::add_service_endpoint( RuntimeOrigin::signed(alice_did.clone()), new_service_endpoint.clone() @@ -1715,8 +1677,7 @@ fn check_service_addition_one_from_full_successful() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) .with_endpoints(vec![(alice_did.clone(), old_service_endpoints)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::add_service_endpoint( RuntimeOrigin::signed(alice_did.clone()), new_service_endpoint.clone() @@ -1760,8 +1721,7 @@ fn check_service_already_present_addition_error() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) .with_endpoints(vec![(alice_did.clone(), vec![service_endpoint.clone()])]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::add_service_endpoint(RuntimeOrigin::signed(alice_did.clone()), service_endpoint), did::Error::::ServiceAlreadyExists @@ -1788,8 +1748,7 @@ fn check_max_services_count_addition_error() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) .with_endpoints(vec![(alice_did.clone(), old_service_endpoints)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::add_service_endpoint(RuntimeOrigin::signed(alice_did.clone()), new_service_endpoint), did::Error::::MaxNumberOfServicesExceeded @@ -1816,8 +1775,7 @@ fn check_max_service_id_length_addition_error() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::add_service_endpoint(RuntimeOrigin::signed(alice_did.clone()), new_service_endpoint), did::Error::::MaxServiceIdLengthExceeded @@ -1947,8 +1905,7 @@ fn check_invalid_service_id_character_addition_error() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::add_service_endpoint(RuntimeOrigin::signed(alice_did.clone()), new_service_details), did::Error::::InvalidServiceEncoding @@ -1966,8 +1923,7 @@ fn check_invalid_service_type_character_addition_error() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::add_service_endpoint(RuntimeOrigin::signed(alice_did.clone()), new_service_details), did::Error::::InvalidServiceEncoding @@ -1985,8 +1941,7 @@ fn check_invalid_service_url_character_addition_error() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::add_service_endpoint(RuntimeOrigin::signed(alice_did.clone()), new_service_details), did::Error::::InvalidServiceEncoding @@ -2008,8 +1963,7 @@ fn check_service_deletion_successful() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) .with_endpoints(vec![(alice_did.clone(), vec![old_service_endpoint.clone()])]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::remove_service_endpoint( RuntimeOrigin::signed(alice_did.clone()), old_service_endpoint.id @@ -2033,8 +1987,7 @@ fn check_service_not_present_deletion_error() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::remove_service_endpoint( RuntimeOrigin::signed(alice_did.clone()), @@ -2063,8 +2016,7 @@ fn check_successful_deletion_no_endpoints() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .with_dids(vec![(alice_did.clone(), did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_eq!(did::pallet::DidEndpointsCount::::get(&alice_did), 0); assert_eq!( Balances::reserved_balance(ACCOUNT_00), @@ -2111,8 +2063,7 @@ fn check_successful_deletion_with_endpoints() { .with_balances(vec![(ACCOUNT_00, balance)]) .with_dids(vec![(alice_did.clone(), did_details)]) .with_endpoints(vec![(alice_did.clone(), vec![service_endpoint])]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_eq!(did::pallet::DidEndpointsCount::::get(&alice_did), 1); assert_eq!( Balances::reserved_balance(ACCOUNT_00), @@ -2151,8 +2102,7 @@ fn check_did_not_present_deletion() { + <::Currency as Currency>>::minimum_balance(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::delete(RuntimeOrigin::signed(alice_did), 0), did::Error::::NotFound @@ -2178,8 +2128,7 @@ fn check_service_count_too_small_deletion_error() { .with_balances(vec![(ACCOUNT_00, balance)]) .with_dids(vec![(alice_did.clone(), did_details)]) .with_endpoints(vec![(alice_did.clone(), vec![service_endpoint])]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::delete(RuntimeOrigin::signed(alice_did.clone()), 0), did::Error::::MaxStoredEndpointsCountExceeded @@ -2206,8 +2155,7 @@ fn check_successful_reclaiming() { .with_balances(vec![(ACCOUNT_00, balance)]) .with_dids(vec![(alice_did.clone(), did_details)]) .with_endpoints(vec![(alice_did.clone(), vec![old_service_endpoint])]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_eq!(did::pallet::DidEndpointsCount::::get(&alice_did), 1); assert_eq!( Balances::reserved_balance(ACCOUNT_00), @@ -2254,8 +2202,7 @@ fn unauthorized_reclaiming() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .with_dids(vec![(alice_did.clone(), did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_eq!( Balances::reserved_balance(ACCOUNT_00), ::Deposit::get() @@ -2285,8 +2232,7 @@ fn check_service_count_too_small_reclaim_error() { .with_balances(vec![(ACCOUNT_00, balance)]) .with_dids(vec![(alice_did.clone(), did_details)]) .with_endpoints(vec![(alice_did.clone(), vec![service_endpoint])]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::reclaim_deposit(RuntimeOrigin::signed(ACCOUNT_00.clone()), alice_did.clone(), 0), did::Error::::MaxStoredEndpointsCountExceeded @@ -2337,8 +2283,7 @@ fn check_too_small_tx_counter_after_wrap_call_error() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::submit_did_call( RuntimeOrigin::signed(caller), @@ -2368,8 +2313,7 @@ fn check_too_small_tx_counter_call_error() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::submit_did_call( RuntimeOrigin::signed(caller), @@ -2398,8 +2342,7 @@ fn check_equal_tx_counter_call_error() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::submit_did_call( RuntimeOrigin::signed(caller), @@ -2428,8 +2371,7 @@ fn check_too_large_tx_counter_call_error() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::submit_did_call( RuntimeOrigin::signed(caller), @@ -2458,8 +2400,7 @@ fn check_tx_block_number_too_low_error() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { // System block number 1 past the max block the operation was allowed for. System::set_block_number(call_operation.operation.block_number + MaxBlocksTxValidity::get() + 1); assert_noop!( @@ -2500,8 +2441,7 @@ fn check_tx_block_number_too_high_error() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { // System block number is still too low, meaning that the block number used in // the operation was too high. System::set_block_number(call_operation.operation.block_number - MaxBlocksTxValidity::get() - 1); @@ -2534,8 +2474,7 @@ fn check_verification_key_not_present_call_error() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::submit_did_call( RuntimeOrigin::signed(caller), @@ -2564,8 +2503,7 @@ fn check_invalid_signature_format_call_error() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::submit_did_call( RuntimeOrigin::signed(caller), @@ -2592,8 +2530,7 @@ fn check_bad_submitter_error() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::submit_did_call( RuntimeOrigin::signed(caller), @@ -2622,8 +2559,7 @@ fn check_invalid_signature_call_error() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::submit_did_call( RuntimeOrigin::signed(caller), @@ -2654,8 +2590,7 @@ fn check_call_attestation_key_successful() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::submit_did_call( RuntimeOrigin::signed(caller), Box::new(call_operation.operation), @@ -2687,8 +2622,7 @@ fn check_call_attestation_key_error() { ::Hashing::hash(&get_attestation_key_test_input()[..]), did, )]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_err!( Did::submit_did_call( RuntimeOrigin::signed(caller), @@ -2719,8 +2653,7 @@ fn check_call_delegation_key_successful() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::submit_did_call( RuntimeOrigin::signed(caller), Box::new(call_operation.operation), @@ -2752,8 +2685,7 @@ fn check_call_delegation_key_error() { ::Hashing::hash(&get_delegation_key_test_input()[..]), did, )]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_err!( Did::submit_did_call( RuntimeOrigin::signed(caller), @@ -2782,8 +2714,7 @@ fn check_call_authentication_key_successful() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::submit_did_call( RuntimeOrigin::signed(caller), Box::new(call_operation.operation), @@ -2813,8 +2744,7 @@ fn check_call_authentication_key_error() { ::Hashing::hash(&get_authentication_key_test_input()[..]), did, )]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_err!( Did::submit_did_call( RuntimeOrigin::signed(caller), @@ -2868,8 +2798,7 @@ fn check_authentication_successful_operation_verification() { ExtBuilder::default() .with_dids(vec![(did, mock_did.clone())]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::verify_did_operation_signature_and_increase_nonce( &call_operation, &did::DidSignature::from(signature) @@ -2895,8 +2824,7 @@ fn check_attestation_successful_operation_verification() { ExtBuilder::default() .with_dids(vec![(did, mock_did.clone())]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::verify_did_operation_signature_and_increase_nonce( &call_operation, &did::DidSignature::from(signature) @@ -2925,8 +2853,7 @@ fn check_delegation_successful_operation_verification() { ExtBuilder::default() .with_dids(vec![(did, mock_did.clone())]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::verify_did_operation_signature_and_increase_nonce( &call_operation, &did::DidSignature::from(signature) @@ -2972,8 +2899,7 @@ fn check_tx_counter_wrap_operation_verification() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_ok!(Did::verify_did_operation_signature_and_increase_nonce( &call_operation, &did::DidSignature::from(signature) @@ -3002,8 +2928,7 @@ fn check_smaller_counter_operation_verification() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::verify_did_operation_signature_and_increase_nonce( &call_operation, @@ -3031,8 +2956,7 @@ fn check_equal_counter_operation_verification() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::verify_did_operation_signature_and_increase_nonce( &call_operation, @@ -3060,8 +2984,7 @@ fn check_too_large_counter_operation_verification() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::verify_did_operation_signature_and_increase_nonce( &call_operation, @@ -3085,8 +3008,7 @@ fn check_verification_key_not_present_operation_verification() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::verify_did_operation_signature_and_increase_nonce( &call_operation, @@ -3114,8 +3036,7 @@ fn check_invalid_signature_format_operation_verification() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::verify_did_operation_signature_and_increase_nonce( &call_operation, @@ -3141,8 +3062,7 @@ fn check_invalid_signature_operation_verification() { ExtBuilder::default() .with_dids(vec![(did, mock_did)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::verify_did_operation_signature_and_increase_nonce( &call_operation, @@ -3171,8 +3091,7 @@ fn test_change_deposit_owner() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance), (alice_did.clone(), balance)]) .with_dids(vec![(alice_did.clone(), did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_eq!( Balances::reserved_balance(ACCOUNT_00), ::Deposit::get() @@ -3201,8 +3120,7 @@ fn test_change_deposit_owner_insufficient_balance() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, balance)]) .with_dids(vec![(alice_did.clone(), did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::change_deposit_owner(RuntimeOrigin::signed(alice_did.clone())), pallet_balances::Error::::InsufficientBalance @@ -3221,8 +3139,7 @@ fn test_change_deposit_owner_not_found() { ExtBuilder::default() .with_balances(vec![(alice_did.clone(), balance)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::change_deposit_owner(RuntimeOrigin::signed(alice_did.clone())), crate::Error::::NotFound @@ -3243,8 +3160,7 @@ fn test_change_deposit_owner_not_authorized() { ExtBuilder::default() .with_balances(vec![(alice_did, balance), (bob_did.clone(), balance)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_noop!( Did::change_deposit_owner(RuntimeOrigin::signed(bob_did.clone())), crate::Error::::NotFound @@ -3268,8 +3184,7 @@ fn test_update_deposit() { ExtBuilder::default() .with_balances(vec![(alice_did.clone(), balance)]) .with_dids(vec![(alice_did.clone(), did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_eq!( Balances::reserved_balance(alice_did.clone()), ::Deposit::get() * 2 @@ -3313,8 +3228,7 @@ fn test_update_deposit_unauthorized() { ExtBuilder::default() .with_balances(vec![(alice_did.clone(), balance)]) .with_dids(vec![(alice_did.clone(), did_details)]) - .build(None) - .execute_with(|| { + .build_and_execute_with_sanity_tests(None, || { assert_eq!( Balances::reserved_balance(alice_did.clone()), ::Deposit::get() * 2 From b7bbd01e114f482fc7222a13ecc18a2af394be1e Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 26 Apr 2023 14:52:06 +0200 Subject: [PATCH 03/40] did finished --- pallets/did/src/tests.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pallets/did/src/tests.rs b/pallets/did/src/tests.rs index a0578ac07..55ada156e 100644 --- a/pallets/did/src/tests.rs +++ b/pallets/did/src/tests.rs @@ -1775,7 +1775,8 @@ fn check_max_service_id_length_addition_error() { ExtBuilder::default() .with_dids(vec![(alice_did.clone(), old_did_details)]) - .build_and_execute_with_sanity_tests(None, || { + .build(None) + .execute_with(|| { assert_noop!( Did::add_service_endpoint(RuntimeOrigin::signed(alice_did.clone()), new_service_endpoint), did::Error::::MaxServiceIdLengthExceeded From b8c3f41e1e7173a98b429231bcb916b7c0b56ad7 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 27 Apr 2023 09:13:13 +0200 Subject: [PATCH 04/40] attestation ctype --- pallets/attestation/src/lib.rs | 25 ++++++++++- pallets/attestation/src/mock.rs | 9 +++- pallets/attestation/src/tests.rs | 72 +++++++++++--------------------- 3 files changed, 55 insertions(+), 51 deletions(-) diff --git a/pallets/attestation/src/lib.rs b/pallets/attestation/src/lib.rs index f3d827d7d..fe7a9592c 100644 --- a/pallets/attestation/src/lib.rs +++ b/pallets/attestation/src/lib.rs @@ -148,7 +148,13 @@ pub mod pallet { pub struct Pallet(_); #[pallet::hooks] - impl Hooks> for Pallet {} + impl Hooks> for Pallet { + #[cfg(feature = "try-runtime")] + fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { + do_try_state()?; + Ok(()) + } + } /// Attestations stored on chain. /// @@ -256,7 +262,7 @@ pub mod pallet { ); // Check for validity of the delegation node if specified. - authorization + authorization // !TODO! .as_ref() .map(|ac| ac.can_attest(&who, &ctype_hash, &claim_hash)) .transpose()?; @@ -465,6 +471,21 @@ pub mod pallet { ExternalAttestations::::remove(authorization_id, claim_hash); } } + #[cfg(any(feature = "try-runtime", test))] + pub fn do_try_state() -> DispatchResult { + Attestations::::iter().try_for_each(|(claim_hash, attestation_details)| -> DispatchResult { + if let Some(authorization_id) = attestation_details.authorization_id { + ensure!( + ExternalAttestations::::contains_key(authorization_id, claim_hash), + DispatchError::Other("Test") + ); + } else { + return Ok(()); + } + Ok(()) + })?; + Ok(()) + } } struct AttestationStorageDepositCollector(PhantomData); diff --git a/pallets/attestation/src/mock.rs b/pallets/attestation/src/mock.rs index ab9eced08..db7866c61 100644 --- a/pallets/attestation/src/mock.rs +++ b/pallets/attestation/src/mock.rs @@ -34,7 +34,7 @@ use kilt_support::deposit::Deposit; use crate::{ pallet::AuthorizationIdOf, AccountIdOf, AttestationAccessControl, AttestationDetails, AttesterOf, BalanceOf, - ClaimHashOf, Config, CurrencyOf, + ClaimHashOf, Config, CurrencyOf, Pallet, }; #[cfg(test)] @@ -385,6 +385,13 @@ pub(crate) mod runtime { ext } + pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce() -> ()) { + self.build().execute_with(|| { + test(); + Pallet::::do_try_state().unwrap(); + }) + } + #[cfg(feature = "runtime-benchmarks")] pub fn build_with_keystore(self) -> sp_io::TestExternalities { let mut ext = self.build(); diff --git a/pallets/attestation/src/tests.rs b/pallets/attestation/src/tests.rs index 96d136ca1..4c1ad729b 100644 --- a/pallets/attestation/src/tests.rs +++ b/pallets/attestation/src/tests.rs @@ -41,8 +41,7 @@ fn test_attest_without_authorization() { ExtBuilder::default() .with_ctypes(vec![(ctype_hash, attester.clone())]) .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(Attestation::add( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), claim_hash, @@ -72,8 +71,7 @@ fn test_attest_authorized() { ExtBuilder::default() .with_ctypes(vec![(ctype, attester.clone())]) .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(Attestation::add( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), claim_hash, @@ -105,8 +103,7 @@ fn test_attest_unauthorized() { ExtBuilder::default() .with_ctypes(vec![(ctype, attester.clone())]) .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( Attestation::add( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), @@ -127,8 +124,7 @@ fn test_attest_ctype_not_found() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Attestation::add( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), @@ -151,8 +147,7 @@ fn test_attest_already_exists() { .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) .with_ctypes(vec![(attestation.ctype_hash, attester.clone())]) .with_attestations(vec![(claim_hash, attestation.clone())]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Attestation::add( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), @@ -178,8 +173,7 @@ fn test_revoke_remove() { .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) .with_ctypes(vec![(attestation.ctype_hash, revoker.clone())]) .with_attestations(vec![(claim_hash, attestation)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(Attestation::revoke( DoubleOrigin(ACCOUNT_00, revoker.clone()).into(), claim_hash, @@ -214,8 +208,7 @@ fn test_authorized_revoke() { .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) .with_ctypes(vec![(attestation.ctype_hash, attester)]) .with_attestations(vec![(claim_hash, attestation)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(Attestation::revoke( DoubleOrigin(ACCOUNT_00, revoker.clone()).into(), claim_hash, @@ -245,8 +238,7 @@ fn test_unauthorized_revoke() { .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) .with_ctypes(vec![(attestation.ctype_hash, attester)]) .with_attestations(vec![(claim_hash, attestation)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Attestation::revoke(DoubleOrigin(ACCOUNT_00, evil).into(), claim_hash, authorization_info), DispatchError::Other("Unauthorized") @@ -264,8 +256,7 @@ fn test_revoke_not_found() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) .with_ctypes(vec![(attestation.ctype_hash, revoker.clone())]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Attestation::revoke( DoubleOrigin(ACCOUNT_00, revoker.clone()).into(), @@ -291,8 +282,7 @@ fn test_already_revoked() { .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) .with_ctypes(vec![(attestation.ctype_hash, revoker.clone())]) .with_attestations(vec![(claim_hash, attestation)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Attestation::revoke( DoubleOrigin(ACCOUNT_00, revoker.clone()).into(), @@ -318,8 +308,7 @@ fn test_remove() { .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) .with_ctypes(vec![(attestation.ctype_hash, attester.clone())]) .with_attestations(vec![(claim_hash, attestation)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(Attestation::remove( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), claim_hash, @@ -342,8 +331,7 @@ fn test_remove_authorized() { .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) .with_ctypes(vec![(attestation.ctype_hash, revoker.clone())]) .with_attestations(vec![(claim_hash, attestation)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(Attestation::remove( DoubleOrigin(ACCOUNT_00, revoker.clone()).into(), claim_hash, @@ -366,8 +354,7 @@ fn test_remove_unauthorized() { .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) .with_ctypes(vec![(attestation.ctype_hash, attester)]) .with_attestations(vec![(claim_hash, attestation)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Attestation::remove( DoubleOrigin(ACCOUNT_00, evil.clone()).into(), @@ -388,8 +375,7 @@ fn test_remove_not_found() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) .with_ctypes(vec![(attestation.ctype_hash, attester.clone())]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); assert_noop!( Attestation::remove(DoubleOrigin(ACCOUNT_00, attester.clone()).into(), claim_hash, None), @@ -413,8 +399,7 @@ fn test_reclaim_deposit() { .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) .with_ctypes(vec![(attestation.ctype_hash, attester)]) .with_attestations(vec![(claim_hash, attestation)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); assert_ok!(Attestation::reclaim_deposit( RuntimeOrigin::signed(ACCOUNT_00), @@ -439,8 +424,7 @@ fn test_reclaim_deposit_authorization() { .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) .with_ctypes(vec![(attestation.ctype_hash, attester)]) .with_attestations(vec![(claim_hash, attestation)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); assert_ok!(Attestation::reclaim_deposit( RuntimeOrigin::signed(ACCOUNT_00), @@ -461,8 +445,7 @@ fn test_reclaim_unauthorized() { .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) .with_ctypes(vec![(attestation.ctype_hash, attester)]) .with_attestations(vec![(claim_hash, attestation)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Attestation::reclaim_deposit(RuntimeOrigin::signed(ACCOUNT_01), claim_hash), attestation::Error::::NotAuthorized, @@ -479,8 +462,7 @@ fn test_reclaim_deposit_not_found() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) .with_ctypes(vec![(attestation.ctype_hash, attester)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Attestation::reclaim_deposit(RuntimeOrigin::signed(ACCOUNT_01), claim_hash), attestation::Error::::NotFound, @@ -506,8 +488,7 @@ fn test_change_deposit_owner() { ]) .with_ctypes(vec![(attestation.ctype_hash, attester.clone())]) .with_attestations(vec![(claim_hash, attestation)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); assert_ok!(Attestation::change_deposit_owner( DoubleOrigin(ACCOUNT_01, attester).into(), @@ -539,8 +520,7 @@ fn test_change_deposit_owner_insufficient_balance() { .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) .with_ctypes(vec![(attestation.ctype_hash, attester.clone())]) .with_attestations(vec![(claim_hash, attestation)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); assert_noop!( Attestation::change_deposit_owner(DoubleOrigin(ACCOUNT_01, attester).into(), claim_hash), @@ -560,8 +540,7 @@ fn test_change_deposit_owner_unauthorized() { .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) .with_ctypes(vec![(attestation.ctype_hash, attester)]) .with_attestations(vec![(claim_hash, attestation)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Attestation::change_deposit_owner(DoubleOrigin(ACCOUNT_00, evil_actor).into(), claim_hash), attestation::Error::::NotAuthorized, @@ -578,8 +557,7 @@ fn test_change_deposit_owner_not_found() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) .with_ctypes(vec![(attestation.ctype_hash, attester.clone())]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Attestation::change_deposit_owner(DoubleOrigin(ACCOUNT_00, attester).into(), claim_hash), attestation::Error::::NotFound, @@ -602,8 +580,7 @@ fn test_update_deposit() { .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) .with_ctypes(vec![(attestation.ctype_hash, attester)]) .with_attestations(vec![(claim_hash, attestation)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( Balances::reserved_balance(ACCOUNT_00), ::Deposit::get() * 2 @@ -642,8 +619,7 @@ fn test_update_deposit_unauthorized() { .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 100)]) .with_ctypes(vec![(attestation.ctype_hash, attester)]) .with_attestations(vec![(claim_hash, attestation)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( Balances::reserved_balance(ACCOUNT_00), ::Deposit::get() * 2 From f6e4eee39f782d7551cbfa254b7284644e624558 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 27 Apr 2023 12:21:47 +0200 Subject: [PATCH 05/40] delegation --- pallets/delegation/src/lib.rs | 69 +++++++++++++++- pallets/delegation/src/mock.rs | 9 ++- pallets/delegation/src/tests.rs | 135 +++++++++++--------------------- 3 files changed, 120 insertions(+), 93 deletions(-) diff --git a/pallets/delegation/src/lib.rs b/pallets/delegation/src/lib.rs index 2aa33a3e4..10fe44c86 100644 --- a/pallets/delegation/src/lib.rs +++ b/pallets/delegation/src/lib.rs @@ -87,7 +87,7 @@ use frame_support::{ use kilt_support::traits::StorageDepositCollector; use parity_scale_codec::Encode; use sp_runtime::{traits::Hash, DispatchError}; -use sp_std::{marker::PhantomData, vec::Vec}; +use sp_std::{marker::PhantomData, vec::Vec, vec}; #[frame_support::pallet] pub mod pallet { @@ -286,6 +286,15 @@ pub mod pallet { MaxChildrenExceeded, } + #[pallet::hooks] + impl Hooks> for Pallet { + #[cfg(feature = "try-runtime")] + fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { + do_try_state()?; + Ok(()) + } + } + #[pallet::call] impl Pallet { /// Create a new delegation root associated with a given CType hash. @@ -409,7 +418,7 @@ pub mod pallet { Self::calculate_delegation_creation_hash(&delegation_id, &hierarchy_root_id, &parent_id, &permissions); // Verify that the hash root signature is correct. - DelegationSignatureVerificationOf::::verify(&delegate, &hash_root.encode(), &delegate_signature) + DelegationSignatureVerificationOf::::verify(&delegate, &hash_root.encode(), &delegate_signature) // !TODO! .map_err(|err| match err { SignatureVerificationError::SignerInformationNotPresent => Error::::DelegateNotFound, SignatureVerificationError::SignatureInvalid => Error::::InvalidDelegateSignature, @@ -965,6 +974,62 @@ pub mod pallet { removals = removals.saturating_add(1); Ok((removals, consumed_weight)) } + + #[cfg(any(feature = "try-runtime", test))] + pub fn do_try_state() -> DispatchResult { + + fn get_merged_subtree(node: DelegationNode) -> Vec> { + let mut nodes_to_explore = vec![node]; + let mut children: Vec> = Vec::new(); + while nodes_to_explore.is_empty() { + let current_node = nodes_to_explore.pop().unwrap(); + let child_nodes : Vec> = current_node + .children + .iter() + .filter_map(|child_id| DelegationNodes::::get(child_id)) + .collect(); + nodes_to_explore.extend(child_nodes.clone()); + children.extend(child_nodes); + } + + children + } + + + DelegationNodes::::iter().try_for_each( + |(delegation_node_id, delegation_details): (DelegationNodeIdOf, DelegationNode)| -> DispatchResult { + let hierachy_id = delegation_details.hierarchy_root_id; + + // check if node is in part of a delegation hierachy. + ensure!( + DelegationHierarchies::::contains_key(hierachy_id), + DispatchError::Other("Test") + ); + + let children_count = DelegationNodes::::iter_values() + .filter(|delegation_node : &DelegationNode | delegation_node.children.contains(&delegation_node_id)) + .count(); + + match delegation_details.parent { + // If node is a leaf or intermediate node, check if the node occures only once. Otherwise we have cylces. + Some(_) => ensure!(children_count <= 1 , DispatchError::Other("Test")), + // if parent is None, check that the root is not the children + // from another node. + _ => ensure!(children_count == 0 , DispatchError::Other("Test")) + }; + + // if a node is revoked, his subtree should be revoked as well. + if delegation_details.details.revoked { + let is_subtree_revoked = get_merged_subtree::(delegation_details).iter().map(|child : &DelegationNode| {child.details.revoked }).fold(true, |acc, x| acc && x); + ensure!(is_subtree_revoked, DispatchError::Other("Test") ); + } + + Ok(()) + }, + )?; + Ok(()) + } + } struct DelegationDepositCollector(PhantomData); diff --git a/pallets/delegation/src/mock.rs b/pallets/delegation/src/mock.rs index 8278353f3..331566f8a 100644 --- a/pallets/delegation/src/mock.rs +++ b/pallets/delegation/src/mock.rs @@ -27,7 +27,7 @@ use kilt_support::deposit::Deposit; use crate::{ self as delegation, AccountIdOf, Config, CurrencyOf, DelegationDetails, DelegationHierarchyDetails, DelegationNode, - DelegatorIdOf, Permissions, + DelegatorIdOf, Pallet, Permissions, }; #[cfg(test)] @@ -513,6 +513,13 @@ pub(crate) mod runtime { ext } + pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce() -> ()) { + self.build().execute_with(|| { + test(); + Pallet::::do_try_state().unwrap(); + }) + } + #[cfg(feature = "runtime-benchmarks")] pub fn build_with_keystore(self) -> sp_io::TestExternalities { let mut ext = self.build(); diff --git a/pallets/delegation/src/tests.rs b/pallets/delegation/src/tests.rs index 32f17f62b..f3885b833 100644 --- a/pallets/delegation/src/tests.rs +++ b/pallets/delegation/src/tests.rs @@ -38,8 +38,7 @@ fn create_root_delegation_successful() { ExtBuilder::default() .with_ctypes(vec![(operation.ctype_hash, creator.clone())]) .with_balances(vec![(ACCOUNT_00, ::Deposit::get())]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // Create root hierarchy assert_ok!(Delegation::create_hierarchy( DoubleOrigin(ACCOUNT_00, creator.clone()).into(), @@ -85,8 +84,7 @@ fn duplicate_create_root_delegation_error() { ACCOUNT_00, )]) .with_balances(vec![(ACCOUNT_00, ::Deposit::get())]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Delegation::create_hierarchy( DoubleOrigin(ACCOUNT_00, creator.clone()).into(), @@ -141,8 +139,7 @@ fn create_delegation_direct_root_successful() { (ACCOUNT_00, ::Deposit::get()), (ACCOUNT_01, ::Deposit::get()), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // Create delegation to root let delegation_id = delegation_id_from_seed::(DELEGATION_ID_SEED_1); let delegation_node = @@ -217,8 +214,7 @@ fn create_delegation_with_parent_successful() { (ACCOUNT_00, ::Deposit::get()), (ACCOUNT_01, ::Deposit::get()), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // Create sub-delegation let delegation_id = delegation_id_from_seed::(DELEGATION_ID_SEED_2); let delegation_node = @@ -305,8 +301,7 @@ fn create_delegation_direct_root_revoked_error() { ACCOUNT_00, )]) .with_balances(vec![(ACCOUNT_00, ::Deposit::get())]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { let _ = Delegation::revoke_delegation( DoubleOrigin(ACCOUNT_00, creator.clone()).into(), operation.hierarchy_id, @@ -367,8 +362,7 @@ fn create_delegation_with_parent_revoked_error() { (ACCOUNT_00, ::Deposit::get()), (ACCOUNT_01, ::Deposit::get()), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { let _ = Delegation::revoke_delegation( DoubleOrigin(ACCOUNT_00, creator.clone()).into(), operation.parent_id, @@ -413,8 +407,7 @@ fn invalid_delegate_signature_create_delegation_error() { ACCOUNT_00, )]) .with_balances(vec![(ACCOUNT_00, ::Deposit::get())]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Delegation::add_delegation( DoubleOrigin(ACCOUNT_00, creator.clone()).into(), @@ -464,8 +457,7 @@ fn duplicate_delegation_create_delegation_error() { (ACCOUNT_00, ::Deposit::get()), (ACCOUNT_01, ::Deposit::get()), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Delegation::add_delegation( DoubleOrigin(ACCOUNT_00, creator.clone()).into(), @@ -505,8 +497,7 @@ fn parent_not_existing_create_delegation_error() { ExtBuilder::default() .with_ctypes(vec![(hierarchy_details.ctype_hash, creator.clone())]) .with_balances(vec![(ACCOUNT_00, ::Deposit::get())]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Delegation::add_delegation( DoubleOrigin(ACCOUNT_00, creator.clone()).into(), @@ -561,8 +552,7 @@ fn not_owner_of_parent_create_delegation_error() { )]) .with_delegations(vec![(parent_id, parent_node)]) .with_balances(vec![(ACCOUNT_00, ::Deposit::get())]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Delegation::add_delegation( DoubleOrigin(ACCOUNT_00, creator.clone()).into(), @@ -613,8 +603,7 @@ fn unauthorised_delegation_create_delegation_error() { )]) .with_balances(vec![(ACCOUNT_00, ::Deposit::get())]) .with_delegations(vec![(parent_id, parent_node)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Delegation::add_delegation( DoubleOrigin(ACCOUNT_00, creator.clone()).into(), @@ -649,8 +638,7 @@ fn empty_revoke_root_successful() { ACCOUNT_00, )]) .with_balances(vec![(ACCOUNT_00, ::Deposit::get())]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(Delegation::revoke_delegation( DoubleOrigin(ACCOUNT_00, revoker.clone()).into(), operation.id, @@ -697,8 +685,7 @@ fn list_hierarchy_revoke_and_remove_root_successful() { ACCOUNT_00, )]) .with_delegations(vec![(parent_id, parent_node), (delegation_id, delegation_node)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert!(Delegation::delegation_hierarchies(hierarchy_root_id).is_some()); assert_eq!( Balances::reserved_balance(ACCOUNT_00), @@ -784,8 +771,7 @@ fn tree_hierarchy_revoke_and_remove_root_successful() { (delegation1_id, delegation1_node), (delegation2_id, delegation2_node), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // Revoke root assert_ok!(Delegation::revoke_delegation( DoubleOrigin(ACCOUNT_00, revoker.clone()).into(), @@ -866,8 +852,7 @@ fn max_max_revocations_revoke_and_remove_successful() { ACCOUNT_00, )]) .with_delegations(vec![(parent_id, parent_node), (delegation_id, delegation_node)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // Revoke root assert_ok!(Delegation::revoke_delegation( DoubleOrigin(ACCOUNT_00, revoker.clone()).into(), @@ -964,8 +949,7 @@ fn different_root_creator_revoke_and_remove_root_error() { ]) .with_ctypes(vec![(hierarchy_details.ctype_hash, owner.clone())]) .with_delegation_hierarchies(vec![(hierarchy_root_id, hierarchy_details, owner, ACCOUNT_00)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Delegation::revoke_delegation( DoubleOrigin(ACCOUNT_00, unauthorized.clone()).into(), @@ -1014,8 +998,7 @@ fn too_small_max_revocations_revoke_and_remove_root_error() { ACCOUNT_00, )]) .with_delegations(vec![(delegation_id, delegation_node)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Delegation::revoke_delegation( DoubleOrigin(ACCOUNT_00, revoker.clone()).into(), @@ -1075,8 +1058,7 @@ fn exact_children_max_revocations_revoke_and_remove_root_error() { (delegation2_id, delegation2_node), (delegation3_id, delegation3_node), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); // Should not revoke root because tree traversal steps are insufficient @@ -1194,8 +1176,7 @@ fn direct_owner_revoke_and_remove_delegation_successful() { ACCOUNT_00, )]) .with_delegations(vec![(parent_id, parent_node), (delegation_id, delegation_node)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // Revoke direct child of hierarchy root assert_ok!(Delegation::revoke_delegation( DoubleOrigin(ACCOUNT_00, revoker.clone()).into(), @@ -1279,8 +1260,7 @@ fn parent_owner_revoke_delegation_successful() { ACCOUNT_00, )]) .with_delegations(vec![(parent_id, parent_node), (delegation_id, delegation_node)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // Parent should not be able to remove the child delegation directly assert_eq!( Balances::reserved_balance(ACCOUNT_00), @@ -1354,8 +1334,7 @@ fn delegation_not_found_revoke_and_remove_delegation_error() { revoker.clone(), ACCOUNT_00, )]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Delegation::revoke_delegation( DoubleOrigin(ACCOUNT_00, revoker.clone()).into(), @@ -1396,8 +1375,7 @@ fn not_delegating_revoke_and_remove_delegation_error() { .with_ctypes(vec![(hierarchy_details.ctype_hash, owner.clone())]) .with_delegation_hierarchies(vec![(hierarchy_root_id, hierarchy_details, owner, ACCOUNT_00)]) .with_delegations(vec![(delegation_id, delegation_node)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Delegation::revoke_delegation( DoubleOrigin(ACCOUNT_01, revoker.clone()).into(), @@ -1451,8 +1429,7 @@ fn parent_too_far_revoke_and_remove_delegation_error() { .with_ctypes(vec![(hierarchy_details.ctype_hash, owner.clone())]) .with_delegation_hierarchies(vec![(hierarchy_root_id, hierarchy_details, owner, ACCOUNT_00)]) .with_delegations(vec![(parent_id, parent_node), (delegation_id, delegation_node)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Delegation::revoke_delegation( DoubleOrigin(ACCOUNT_01, intermediate.clone()).into(), @@ -1520,8 +1497,7 @@ fn too_many_revocations_revoke_delegation_error() { (ACCOUNT_00, ::Deposit::get()), (ACCOUNT_01, ::Deposit::get()), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Delegation::revoke_delegation( DoubleOrigin(ACCOUNT_00, revoker.clone()).into(), @@ -1560,8 +1536,7 @@ fn direct_owner_reclaim_deposit_delegation_successful() { .with_ctypes(vec![(hierarchy_details.ctype_hash, revoker.clone())]) .with_delegation_hierarchies(vec![(hierarchy_root_id, hierarchy_details, revoker, ACCOUNT_00)]) .with_delegations(vec![(parent_id, parent_node), (delegation_id, delegation_node)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // Revoke direct child of hierarchy root assert_ok!(Delegation::reclaim_deposit( RuntimeOrigin::signed(ACCOUNT_00), @@ -1605,8 +1580,7 @@ fn parent_owner_reclaim_deposit_error() { .with_ctypes(vec![(hierarchy_details.ctype_hash, revoker.clone())]) .with_delegation_hierarchies(vec![(hierarchy_root_id, hierarchy_details, revoker, ACCOUNT_00)]) .with_delegations(vec![(parent_id, parent_node), (delegation_id, delegation_node)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // Parent should not be able to claim the deposit for the child delegation // directly assert_eq!( @@ -1639,8 +1613,7 @@ fn delegation_not_found_reclaim_deposit_error() { .with_balances(vec![(ACCOUNT_00, ::Deposit::get())]) .with_ctypes(vec![(hierarchy_details.ctype_hash, revoker.clone())]) .with_delegation_hierarchies(vec![(hierarchy_root_id, hierarchy_details, revoker, ACCOUNT_00)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Delegation::reclaim_deposit( RuntimeOrigin::signed(ACCOUNT_00), @@ -1666,8 +1639,7 @@ fn max_removals_too_large_reclaim_deposit_error() { .with_balances(vec![(ACCOUNT_00, ::Deposit::get())]) .with_ctypes(vec![(hierarchy_details.ctype_hash, revoker.clone())]) .with_delegation_hierarchies(vec![(hierarchy_root_id, hierarchy_details, revoker, ACCOUNT_00)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Delegation::reclaim_deposit( RuntimeOrigin::signed(ACCOUNT_00), @@ -1707,8 +1679,7 @@ fn is_delegating_direct_not_revoked() { (ACCOUNT_01, ::Deposit::get()), (ACCOUNT_02, ::Deposit::get()), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( Delegation::is_delegating(&user_3, &delegation_id, max_parent_checks), Ok((true, max_parent_checks)) @@ -1742,8 +1713,7 @@ fn is_delegating_direct_not_revoked_max_parent_checks_value() { (ACCOUNT_01, ::Deposit::get()), (ACCOUNT_02, ::Deposit::get()), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( Delegation::is_delegating(&user_3, &delegation_id, max_parent_checks), Ok((true, 0u32)) @@ -1779,8 +1749,7 @@ fn is_delegating_direct_revoked() { (ACCOUNT_01, ::Deposit::get()), (ACCOUNT_02, ::Deposit::get()), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( Delegation::is_delegating(&user_3, &delegation_id, max_parent_checks), Ok((false, 0)) @@ -1816,8 +1785,7 @@ fn is_delegating_direct_revoked_max_parent_checks_value() { (ACCOUNT_01, ::Deposit::get()), (ACCOUNT_02, ::Deposit::get()), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( Delegation::is_delegating(&user_3, &delegation_id, max_parent_checks), Ok((false, 0)) @@ -1852,8 +1820,7 @@ fn is_delegating_max_parent_not_revoked() { (ACCOUNT_01, ::Deposit::get()), (ACCOUNT_02, ::Deposit::get()), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( Delegation::is_delegating(&user_2, &delegation_id, max_parent_checks), Ok((true, max_parent_checks - 1)) @@ -1890,8 +1857,7 @@ fn is_delegating_max_parent_revoked() { (ACCOUNT_01, ::Deposit::get()), (ACCOUNT_02, ::Deposit::get()), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( Delegation::is_delegating(&user_2, &delegation_id, max_parent_checks), Ok((false, max_parent_checks - 2)) @@ -1926,8 +1892,7 @@ fn is_delegating_root_owner_not_revoked() { (ACCOUNT_01, ::Deposit::get()), (ACCOUNT_02, ::Deposit::get()), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( Delegation::is_delegating(&user_1, &delegation_id, max_parent_checks), Ok((true, max_parent_checks - 2)) @@ -1961,8 +1926,7 @@ fn is_delegating_root_owner_revoked() { (ACCOUNT_01, ::Deposit::get()), (ACCOUNT_02, ::Deposit::get()), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // First revoke the hierarchy, then test is_delegating. let _ = Delegation::revoke_delegation( DoubleOrigin(ACCOUNT_00, user_1.clone()).into(), @@ -2029,8 +1993,7 @@ fn is_delegating_root_after_max_limit() { (ACCOUNT_01, ::Deposit::get()), (ACCOUNT_02, ::Deposit::get()), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Delegation::is_delegating(&user_1, &delegation_id, max_parent_checks), Error::::MaxSearchDepthReached @@ -2055,8 +2018,7 @@ fn remove_single_hierarchy() { creator.clone(), ACCOUNT_00, )]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert!(Delegation::delegation_hierarchies(hierarchy_root_id).is_some()); assert!(Delegation::delegation_nodes(hierarchy_root_id).is_some()); assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); @@ -2126,8 +2088,7 @@ fn remove_children_gas_runs_out() { (delegation3_id, delegation3_node), (delegation4_id, delegation4_node), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(Balances::reserved_balance(ACCOUNT_00), ::Deposit::get()); assert_eq!( Balances::reserved_balance(ACCOUNT_01), @@ -2205,8 +2166,7 @@ fn test_change_deposit_owner() { .with_ctypes(vec![(hierarchy_details.ctype_hash, root_owner.clone())]) .with_delegation_hierarchies(vec![(hierarchy_root_id, hierarchy_details, root_owner, ACCOUNT_00)]) .with_delegations(vec![(parent_id, parent_node), (delegation_id, delegation_node)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( Balances::reserved_balance(ACCOUNT_00), ::Deposit::get() * 3 @@ -2249,8 +2209,7 @@ fn test_change_deposit_owner_insufficient_balance() { .with_ctypes(vec![(hierarchy_details.ctype_hash, root_owner.clone())]) .with_delegation_hierarchies(vec![(hierarchy_root_id, hierarchy_details, root_owner, ACCOUNT_00)]) .with_delegations(vec![(parent_id, parent_node), (delegation_id, delegation_node)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( Balances::reserved_balance(ACCOUNT_00), ::Deposit::get() * 3 @@ -2290,8 +2249,7 @@ fn test_change_deposit_owner_unauthorized() { ACCOUNT_00, )]) .with_delegations(vec![(parent_id, parent_node), (delegation_id, delegation_node)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Delegation::change_deposit_owner(DoubleOrigin(ACCOUNT_01, root_owner).into(), delegation_id), Error::::AccessDenied @@ -2320,8 +2278,7 @@ fn test_change_deposit_owner_not_found() { .with_ctypes(vec![(hierarchy_details.ctype_hash, root_owner.clone())]) .with_delegation_hierarchies(vec![(hierarchy_root_id, hierarchy_details, root_owner, ACCOUNT_00)]) .with_delegations(vec![(parent_id, parent_node)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Delegation::change_deposit_owner(DoubleOrigin(ACCOUNT_01, delegate).into(), delegation_id), Error::::DelegationNotFound @@ -2353,8 +2310,7 @@ fn test_update_deposit() { .with_ctypes(vec![(hierarchy_details.ctype_hash, root_owner.clone())]) .with_delegation_hierarchies(vec![(hierarchy_root_id, hierarchy_details, root_owner, ACCOUNT_00)]) .with_delegations(vec![(parent_id, parent_node), (delegation_id, delegation_node)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( Balances::reserved_balance(ACCOUNT_00), ::Deposit::get() * 3 @@ -2395,8 +2351,7 @@ fn test_update_deposit_unauthorized() { .with_ctypes(vec![(hierarchy_details.ctype_hash, root_owner.clone())]) .with_delegation_hierarchies(vec![(hierarchy_root_id, hierarchy_details, root_owner, ACCOUNT_00)]) .with_delegations(vec![(parent_id, parent_node), (delegation_id, delegation_node)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( Balances::reserved_balance(ACCOUNT_00), ::Deposit::get() * 3 From e676a1a62bfd35eb4fc9af4fb5adf85c91513f81 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 27 Apr 2023 14:55:19 +0200 Subject: [PATCH 06/40] did-lookup --- pallets/pallet-did-lookup/src/lib.rs | 26 ++++++++++++- pallets/pallet-did-lookup/src/mock.rs | 9 ++++- pallets/pallet-did-lookup/src/tests.rs | 54 +++++++++----------------- runtime-api/did/src/lib.rs | 1 + 4 files changed, 52 insertions(+), 38 deletions(-) diff --git a/pallets/pallet-did-lookup/src/lib.rs b/pallets/pallet-did-lookup/src/lib.rs index 1b571d913..5e1f1f55a 100644 --- a/pallets/pallet-did-lookup/src/lib.rs +++ b/pallets/pallet-did-lookup/src/lib.rs @@ -190,6 +190,15 @@ pub mod pallet { } } + #[pallet::hooks] + impl Hooks> for Pallet { + #[cfg(feature = "try-runtime")] + fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { + do_try_state()?; + Ok(()) + } + } + #[pallet::call] impl Pallet where @@ -224,7 +233,7 @@ pub mod pallet { pub fn associate_account( origin: OriginFor, req: AssociateAccountRequest, - expiration: ::BlockNumber, + expiration: ::BlockNumber, // !TODO! why expiration ) -> DispatchResult { let source = ::EnsureOrigin::ensure_origin(origin)?; let did_identifier = source.subject(); @@ -267,6 +276,8 @@ pub mod pallet { #[pallet::call_index(1)] #[pallet::weight(::WeightInfo::associate_sender())] pub fn associate_sender(origin: OriginFor) -> DispatchResult { + // !TODO! difference between associate_sender und associate_account. difference + // between assert! und ensure! let source = ::EnsureOrigin::ensure_origin(origin)?; ensure!( @@ -421,6 +432,19 @@ pub mod pallet { Err(Error::::NotFound.into()) } } + + #[cfg(any(feature = "try-runtime", test))] + pub fn do_try_state() -> DispatchResult { + ConnectedDids::::iter().try_for_each(|(account, record)| -> DispatchResult { + let is_in_connected_accounts = ConnectedAccounts::::contains_key(record.did, account); + + ensure!(is_in_connected_accounts, DispatchError::Other("Test")); + + Ok(()) + })?; + + Ok(()) + } } struct LinkableAccountDepositCollector(PhantomData); diff --git a/pallets/pallet-did-lookup/src/mock.rs b/pallets/pallet-did-lookup/src/mock.rs index 34e72d41e..9eaac2b75 100644 --- a/pallets/pallet-did-lookup/src/mock.rs +++ b/pallets/pallet-did-lookup/src/mock.rs @@ -29,7 +29,7 @@ use sp_runtime::{ use crate::{ self as pallet_did_lookup, linkable_account::LinkableAccountId, AccountIdOf, BalanceOf, Config, ConnectedAccounts, - ConnectedDids, ConnectionRecord, CurrencyOf, DidIdentifierOf, + ConnectedDids, ConnectionRecord, CurrencyOf, DidIdentifierOf, Pallet, }; pub(crate) type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -199,6 +199,13 @@ impl ExtBuilder { ext } + pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce() -> ()) { + self.build().execute_with(|| { + test(); + Pallet::::do_try_state().unwrap(); + }) + } + #[cfg(feature = "runtime-benchmarks")] pub fn build_with_keystore(self) -> sp_io::TestExternalities { let mut ext = self.build(); diff --git a/pallets/pallet-did-lookup/src/tests.rs b/pallets/pallet-did-lookup/src/tests.rs index 9713c6efe..bd97aa2df 100644 --- a/pallets/pallet-did-lookup/src/tests.rs +++ b/pallets/pallet-did-lookup/src/tests.rs @@ -42,8 +42,7 @@ fn test_add_association_sender() { (ACCOUNT_00, ::Deposit::get() * 50), (ACCOUNT_01, ::Deposit::get() * 50), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // new association. No overwrite assert!(DidLookup::associate_sender(mock_origin::DoubleOrigin(ACCOUNT_00, DID_00).into()).is_ok()); assert_eq!( @@ -90,8 +89,7 @@ fn test_add_association_account() { (ACCOUNT_00, ::Deposit::get() * 50), (ACCOUNT_01, ::Deposit::get() * 50), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { let pair_alice = sr25519::Pair::from_seed(b"Alice "); let expire_at: BlockNumber = 500; let account_hash_alice = MultiSigner::from(pair_alice.public()).into_account(); @@ -194,8 +192,7 @@ fn test_add_eth_association() { (ACCOUNT_00, ::Deposit::get() * 50), (ACCOUNT_01, ::Deposit::get() * 50), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { let expire_at: BlockNumber = 500; let eth_pair = ecdsa::Pair::generate().0; let eth_account = AccountId20(eth_pair.public().to_eth_address().unwrap()); @@ -239,8 +236,7 @@ fn test_add_association_account_invalid_signature() { (ACCOUNT_00, ::Deposit::get() * 50), (ACCOUNT_01, ::Deposit::get() * 50), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { let pair_alice = sr25519::Pair::from_seed(b"Alice "); let account_hash_alice = MultiSigner::from(pair_alice.public()).into_account(); let expire_at: BlockNumber = 500; @@ -265,8 +261,7 @@ fn test_add_association_account_expired() { (ACCOUNT_00, ::Deposit::get() * 50), (ACCOUNT_01, ::Deposit::get() * 50), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { let pair_alice = sr25519::Pair::from_seed(b"Alice "); let account_hash_alice = MultiSigner::from(pair_alice.public()).into_account(); let expire_at: BlockNumber = 2; @@ -294,8 +289,7 @@ fn test_remove_association_sender() { (ACCOUNT_01, ::Deposit::get() * 50), ]) .with_connections(vec![(ACCOUNT_00, DID_01, LINKABLE_ACCOUNT_00)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // remove association assert!(DidLookup::remove_sender_association(RuntimeOrigin::signed(ACCOUNT_00)).is_ok()); assert_eq!(ConnectedDids::::get(LinkableAccountId::from(ACCOUNT_00)), None); @@ -311,8 +305,7 @@ fn test_remove_association_sender_not_found() { (ACCOUNT_00, ::Deposit::get() * 50), (ACCOUNT_01, ::Deposit::get() * 50), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( DidLookup::remove_sender_association(RuntimeOrigin::signed(ACCOUNT_00)), Error::::NotFound @@ -328,8 +321,7 @@ fn test_remove_association_account() { (ACCOUNT_01, ::Deposit::get() * 50), ]) .with_connections(vec![(ACCOUNT_01, DID_01, LINKABLE_ACCOUNT_00)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert!(DidLookup::remove_account_association( mock_origin::DoubleOrigin(ACCOUNT_00, DID_01).into(), LinkableAccountId::from(ACCOUNT_00.clone()) @@ -348,8 +340,7 @@ fn test_remove_association_account_not_found() { (ACCOUNT_00, ::Deposit::get() * 50), (ACCOUNT_01, ::Deposit::get() * 50), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(ConnectedDids::::get(LinkableAccountId::from(ACCOUNT_00)), None); assert_noop!( @@ -370,8 +361,7 @@ fn test_remove_association_account_not_authorized() { (ACCOUNT_01, ::Deposit::get() * 50), ]) .with_connections(vec![(ACCOUNT_01, DID_01, LINKABLE_ACCOUNT_00)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( DidLookup::remove_account_association( mock_origin::DoubleOrigin(ACCOUNT_01, DID_00).into(), @@ -394,8 +384,7 @@ fn test_reclaim_deposit() { (ACCOUNT_01, ::Deposit::get() * 50), ]) .with_connections(vec![(ACCOUNT_01, DID_01, LINKABLE_ACCOUNT_00)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(DidLookup::reclaim_deposit( RuntimeOrigin::signed(ACCOUNT_01), ACCOUNT_00.into() @@ -412,8 +401,7 @@ fn test_reclaim_deposit_not_authorized() { (ACCOUNT_01, ::Deposit::get() * 50), ]) .with_connections(vec![(ACCOUNT_01, DID_01, LINKABLE_ACCOUNT_00)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( DidLookup::reclaim_deposit(RuntimeOrigin::signed(ACCOUNT_00), ACCOUNT_00.into()), Error::::NotAuthorized @@ -436,8 +424,7 @@ fn test_change_deposit_owner() { (ACCOUNT_01, ::Deposit::get() * 50), ]) .with_connections(vec![(ACCOUNT_00, DID_00, LINKABLE_ACCOUNT_00)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(DidLookup::change_deposit_owner( mock_origin::DoubleOrigin(ACCOUNT_01, DID_00).into(), ACCOUNT_00.into() @@ -455,8 +442,7 @@ fn test_change_deposit_owner_insufficient_balance() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 50)]) .with_connections(vec![(ACCOUNT_00, DID_00, LINKABLE_ACCOUNT_00)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( DidLookup::change_deposit_owner( mock_origin::DoubleOrigin(ACCOUNT_01, DID_00).into(), @@ -471,8 +457,7 @@ fn test_change_deposit_owner_insufficient_balance() { fn test_change_deposit_owner_not_found() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 50)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( DidLookup::change_deposit_owner( mock_origin::DoubleOrigin(ACCOUNT_01, DID_00).into(), @@ -488,8 +473,7 @@ fn test_change_deposit_owner_not_authorized() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, ::Deposit::get() * 50)]) .with_connections(vec![(ACCOUNT_00, DID_00, LINKABLE_ACCOUNT_00)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( DidLookup::change_deposit_owner( mock_origin::DoubleOrigin(ACCOUNT_01, DID_01).into(), @@ -507,8 +491,7 @@ fn test_update_deposit() { (ACCOUNT_00, ::Deposit::get() * 50), (ACCOUNT_01, ::Deposit::get() * 50), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { insert_raw_connection::( ACCOUNT_00, DID_00, @@ -537,8 +520,7 @@ fn test_update_deposit_unauthorized() { (ACCOUNT_00, ::Deposit::get() * 50), (ACCOUNT_01, ::Deposit::get() * 50), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { insert_raw_connection::( ACCOUNT_00, DID_00, diff --git a/runtime-api/did/src/lib.rs b/runtime-api/did/src/lib.rs index 291e77960..f3b4aa8f2 100644 --- a/runtime-api/did/src/lib.rs +++ b/runtime-api/did/src/lib.rs @@ -30,6 +30,7 @@ pub use service_endpoint::*; #[derive(Encode, Decode, TypeInfo, Eq, PartialEq)] pub struct DidLinkedInfo< + // !TODO! sicherstellen. Json für DID document. DidIdentifier, AccountId, LinkableAccountId, From 3f721befb59bbf1b81005537114e84f0af77bbc6 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 27 Apr 2023 16:13:51 +0200 Subject: [PATCH 07/40] web3name --- pallets/pallet-web3-names/src/lib.rs | 34 ++++++++++++++++- pallets/pallet-web3-names/src/mock.rs | 9 ++++- pallets/pallet-web3-names/src/tests.rs | 51 +++++++++----------------- 3 files changed, 58 insertions(+), 36 deletions(-) diff --git a/pallets/pallet-web3-names/src/lib.rs b/pallets/pallet-web3-names/src/lib.rs index 40f431ee2..a3e931b17 100644 --- a/pallets/pallet-web3-names/src/lib.rs +++ b/pallets/pallet-web3-names/src/lib.rs @@ -175,7 +175,13 @@ pub mod pallet { } #[pallet::hooks] - impl Hooks> for Pallet {} + impl Hooks> for Pallet { + #[cfg(feature = "try-runtime")] + fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { + do_try_state()?; + Ok(()) + } + } #[pallet::call] impl Pallet { @@ -496,6 +502,32 @@ pub mod pallet { fn unban_name(name: &Web3NameOf) { Banned::::remove(name); } + + #[cfg(any(feature = "try-runtime", test))] + pub fn do_try_state() -> DispatchResult { + // check if for each owner there is a name stored. + Owner::::iter().try_for_each( + |(w3n, ownership): (Web3NameOf, Web3OwnershipOf)| -> DispatchResult { + ensure!( + Names::::contains_key(ownership.owner.clone()), + DispatchError::Other("Test") + ); + + ensure!( + Names::::get(ownership.owner).unwrap() == w3n, + DispatchError::Other("Test") + ); + Ok(()) + }, + )?; + // a banned name should have no owner. + Banned::::iter_keys().try_for_each(|banned_w3n| -> DispatchResult { + ensure!(!Owner::::contains_key(banned_w3n), DispatchError::Other("Test")); + Ok(()) + })?; + + Ok(()) + } } struct Web3NameStorageDepositCollector(PhantomData); diff --git a/pallets/pallet-web3-names/src/mock.rs b/pallets/pallet-web3-names/src/mock.rs index bc6bf4b35..d41fc34b5 100644 --- a/pallets/pallet-web3-names/src/mock.rs +++ b/pallets/pallet-web3-names/src/mock.rs @@ -62,7 +62,7 @@ pub(crate) mod runtime { MultiSignature, }; - use crate::{self as pallet_web3_names, web3_name::AsciiWeb3Name}; + use crate::{self as pallet_web3_names, web3_name::AsciiWeb3Name, Pallet}; type Index = u64; type BlockNumber = u64; @@ -235,6 +235,13 @@ pub(crate) mod runtime { ext } + pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce() -> ()) { + self.build().execute_with(|| { + test(); + Pallet::::do_try_state().unwrap(); + }) + } + #[cfg(feature = "runtime-benchmarks")] pub fn build_with_keystore(self) -> sp_io::TestExternalities { let mut ext = self.build(); diff --git a/pallets/pallet-web3-names/src/tests.rs b/pallets/pallet-web3-names/src/tests.rs index 355b3d60b..a69f2c087 100644 --- a/pallets/pallet-web3-names/src/tests.rs +++ b/pallets/pallet-web3-names/src/tests.rs @@ -33,8 +33,7 @@ fn claiming_successful() { let initial_balance: Balance = 100; ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, initial_balance)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert!(Names::::get(&DID_00).is_none()); assert!(Owner::::get(&web3_name_00).is_none()); assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); @@ -108,8 +107,7 @@ fn claiming_invalid() { ]; ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, 100)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { for too_short_input in too_short_web3_names.iter() { assert_noop!( Pallet::::claim( @@ -134,8 +132,7 @@ fn claiming_banned() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, 100)]) .with_banned_web3_names(vec![web3_name_00.clone()]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Pallet::::claim(mock_origin::DoubleOrigin(ACCOUNT_00, DID_00).into(), web3_name_00.0), Error::::Banned @@ -148,8 +145,7 @@ fn claiming_not_enough_funds() { let web3_name_00 = get_web3_name(WEB3_NAME_00_INPUT); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, Web3NameDeposit::get() - 1)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Pallet::::claim(mock_origin::DoubleOrigin(ACCOUNT_00, DID_00).into(), web3_name_00.0), Error::::InsufficientFunds @@ -167,8 +163,7 @@ fn releasing_by_owner_successful() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, initial_balance)]) .with_web3_names(vec![(DID_00, web3_name_00.clone(), ACCOUNT_00)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(Pallet::::release_by_owner( // Submitter != deposit payer, owner == name owner mock_origin::DoubleOrigin(ACCOUNT_01, DID_00).into(), @@ -189,8 +184,7 @@ fn releasing_by_payer_successful() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, initial_balance)]) .with_web3_names(vec![(DID_00, web3_name_00.clone(), ACCOUNT_00)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(Pallet::::reclaim_deposit( // Submitter == deposit payer RawOrigin::Signed(ACCOUNT_00).into(), @@ -228,8 +222,7 @@ fn releasing_not_authorized() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, 100)]) .with_web3_names(vec![(DID_00, web3_name_00.clone(), ACCOUNT_00)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // Fail to claim by different payer assert_noop!( Pallet::::reclaim_deposit(RawOrigin::Signed(ACCOUNT_01).into(), web3_name_00.clone().0), @@ -243,8 +236,7 @@ fn releasing_banned() { let web3_name_00 = get_web3_name(WEB3_NAME_00_INPUT); ExtBuilder::default() .with_banned_web3_names(vec![(web3_name_00)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Pallet::::release_by_owner(mock_origin::DoubleOrigin(ACCOUNT_00, DID_00).into()), // A banned name will be removed from the map of used names, so it will be considered not @@ -265,8 +257,7 @@ fn banning_successful() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, initial_balance)]) .with_web3_names(vec![(DID_00, web3_name_00.clone(), ACCOUNT_00)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // Ban a claimed name assert_ok!(Pallet::::ban(RawOrigin::Root.into(), web3_name_00.clone().0)); @@ -290,8 +281,7 @@ fn banning_already_banned() { let web3_name_00 = get_web3_name(WEB3_NAME_00_INPUT); ExtBuilder::default() .with_banned_web3_names(vec![web3_name_00.clone()]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Pallet::::ban(RawOrigin::Root.into(), web3_name_00.clone().0), Error::::AlreadyBanned @@ -328,8 +318,7 @@ fn unbanning_successful() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, 100)]) .with_banned_web3_names(vec![web3_name_00.clone()]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(Pallet::::unban(RawOrigin::Root.into(), web3_name_00.clone().0)); // Test that claiming is possible again @@ -356,8 +345,7 @@ fn unbanning_unauthorized_origin() { let web3_name_00 = get_web3_name(WEB3_NAME_00_INPUT); ExtBuilder::default() .with_banned_web3_names(vec![web3_name_00.clone()]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // Signer origin assert_noop!( Pallet::::unban(RawOrigin::Signed(ACCOUNT_00).into(), web3_name_00.clone().0), @@ -384,8 +372,7 @@ fn test_change_deposit_owner() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, initial_balance), (ACCOUNT_01, initial_balance)]) .with_web3_names(vec![(DID_00, web3_name_00.clone(), ACCOUNT_00)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(Pallet::::change_deposit_owner( mock_origin::DoubleOrigin(ACCOUNT_01, DID_00).into(), )); @@ -410,8 +397,7 @@ fn test_change_deposit_owner_insufficient_balance() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, initial_balance)]) .with_web3_names(vec![(DID_00, web3_name_00, ACCOUNT_00)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Pallet::::change_deposit_owner(mock_origin::DoubleOrigin(ACCOUNT_01, DID_00).into()), pallet_balances::Error::::InsufficientBalance @@ -426,8 +412,7 @@ fn test_change_deposit_owner_not_found() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, initial_balance)]) .with_web3_names(vec![(DID_00, web3_name_00, ACCOUNT_00)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( Pallet::::change_deposit_owner(mock_origin::DoubleOrigin(ACCOUNT_00, DID_01).into()), Error::::NotFound @@ -441,8 +426,7 @@ fn test_update_deposit() { let initial_balance: Balance = ::Deposit::get() * 100; ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, initial_balance)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { insert_raw_w3n::( ACCOUNT_00, DID_00, @@ -477,8 +461,7 @@ fn test_update_deposit_unauthorized() { let initial_balance: Balance = ::Deposit::get() * 100; ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, initial_balance)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { insert_raw_w3n::( ACCOUNT_00, DID_00, From fba90ddaa8c34a5912bf90c07751201e799229f6 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 28 Apr 2023 10:50:00 +0200 Subject: [PATCH 08/40] public credentials --- pallets/attestation/src/mock.rs | 4 +- pallets/delegation/src/lib.rs | 12 ++-- pallets/public-credentials/src/lib.rs | 34 ++++++++++ pallets/public-credentials/src/mock.rs | 9 ++- pallets/public-credentials/src/tests.rs | 90 +++++++++---------------- 5 files changed, 79 insertions(+), 70 deletions(-) diff --git a/pallets/attestation/src/mock.rs b/pallets/attestation/src/mock.rs index db7866c61..bb63cd065 100644 --- a/pallets/attestation/src/mock.rs +++ b/pallets/attestation/src/mock.rs @@ -34,7 +34,7 @@ use kilt_support::deposit::Deposit; use crate::{ pallet::AuthorizationIdOf, AccountIdOf, AttestationAccessControl, AttestationDetails, AttesterOf, BalanceOf, - ClaimHashOf, Config, CurrencyOf, Pallet, + ClaimHashOf, Config, CurrencyOf, }; #[cfg(test)] @@ -180,6 +180,8 @@ pub(crate) mod runtime { use ctype::{CtypeCreatorOf, CtypeEntryOf}; use kilt_support::mock::{mock_origin, SubjectId}; + use crate::Pallet; + use super::*; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; diff --git a/pallets/delegation/src/lib.rs b/pallets/delegation/src/lib.rs index 10fe44c86..d35f56040 100644 --- a/pallets/delegation/src/lib.rs +++ b/pallets/delegation/src/lib.rs @@ -87,7 +87,7 @@ use frame_support::{ use kilt_support::traits::StorageDepositCollector; use parity_scale_codec::Encode; use sp_runtime::{traits::Hash, DispatchError}; -use sp_std::{marker::PhantomData, vec::Vec, vec}; +use sp_std::{marker::PhantomData, vec, vec::Vec}; #[frame_support::pallet] pub mod pallet { @@ -977,13 +977,12 @@ pub mod pallet { #[cfg(any(feature = "try-runtime", test))] pub fn do_try_state() -> DispatchResult { - - fn get_merged_subtree(node: DelegationNode) -> Vec> { + fn get_merged_subtree(node: DelegationNode) -> Vec> { let mut nodes_to_explore = vec![node]; let mut children: Vec> = Vec::new(); while nodes_to_explore.is_empty() { let current_node = nodes_to_explore.pop().unwrap(); - let child_nodes : Vec> = current_node + let child_nodes: Vec> = current_node .children .iter() .filter_map(|child_id| DelegationNodes::::get(child_id)) @@ -991,11 +990,10 @@ pub mod pallet { nodes_to_explore.extend(child_nodes.clone()); children.extend(child_nodes); } - + children } - DelegationNodes::::iter().try_for_each( |(delegation_node_id, delegation_details): (DelegationNodeIdOf, DelegationNode)| -> DispatchResult { let hierachy_id = delegation_details.hierarchy_root_id; @@ -1023,13 +1021,11 @@ pub mod pallet { let is_subtree_revoked = get_merged_subtree::(delegation_details).iter().map(|child : &DelegationNode| {child.details.revoked }).fold(true, |acc, x| acc && x); ensure!(is_subtree_revoked, DispatchError::Other("Test") ); } - Ok(()) }, )?; Ok(()) } - } struct DelegationDepositCollector(PhantomData); diff --git a/pallets/public-credentials/src/lib.rs b/pallets/public-credentials/src/lib.rs index 73f10438b..123720c33 100644 --- a/pallets/public-credentials/src/lib.rs +++ b/pallets/public-credentials/src/lib.rs @@ -229,6 +229,15 @@ pub mod pallet { Internal, } + #[pallet::hooks] + impl Hooks> for Pallet { + #[cfg(feature = "try-runtime")] + fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { + do_try_state()?; + Ok(()) + } + } + #[pallet::call] impl Pallet { /// Register a new public credential on chain. @@ -585,6 +594,31 @@ pub mod pallet { } }) } + + #[cfg(any(feature = "try-runtime", test))] + pub fn do_try_state() -> DispatchResult { + // check if for each owner there is a name stored. + Credentials::::iter().try_for_each(|(subject_id, credential_id, entry)| -> DispatchResult { + ensure!( + CredentialSubjects::::contains_key(&credential_id), + DispatchError::Other("Test") + ); + + ensure!( + CredentialSubjects::::get(&credential_id).unwrap() == subject_id, + DispatchError::Other("Test") + ); + + ensure!( + ctype::Ctypes::::contains_key(entry.ctype_hash), + DispatchError::Other("Test") + ); + + Ok(()) + })?; + + Ok(()) + } } struct PublicCredentialDepositCollector(PhantomData); diff --git a/pallets/public-credentials/src/mock.rs b/pallets/public-credentials/src/mock.rs index b3bfa4f0b..c5965e460 100644 --- a/pallets/public-credentials/src/mock.rs +++ b/pallets/public-credentials/src/mock.rs @@ -113,7 +113,7 @@ pub(crate) mod runtime { use ctype::{CtypeCreatorOf, CtypeEntryOf, CtypeHashOf}; - use crate::{Config, CredentialEntryOf, Error, InputSubjectIdOf, PublicCredentialsAccessControl}; + use crate::{Config, CredentialEntryOf, Error, InputSubjectIdOf, Pallet, PublicCredentialsAccessControl}; pub(crate) type BlockNumber = u64; pub(crate) type Balance = u128; @@ -443,6 +443,13 @@ pub(crate) mod runtime { ext } + pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce() -> ()) { + self.build().execute_with(|| { + test(); + Pallet::::do_try_state().unwrap(); + }) + } + #[cfg(feature = "runtime-benchmarks")] pub(crate) fn build_with_keystore(self) -> sp_io::TestExternalities { let mut ext = self.build(); diff --git a/pallets/public-credentials/src/tests.rs b/pallets/public-credentials/src/tests.rs index e804b2359..477c721ae 100644 --- a/pallets/public-credentials/src/tests.rs +++ b/pallets/public-credentials/src/tests.rs @@ -49,8 +49,7 @@ fn add_successful_without_authorization() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, (deposit) * 2)]) .with_ctypes(vec![(ctype_hash_1, attester.clone()), (ctype_hash_2, attester.clone())]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // Check for 0 reserved deposit assert!(Balances::reserved_balance(ACCOUNT_00).is_zero()); @@ -125,8 +124,7 @@ fn add_successful_with_authorization() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_ctypes(vec![(ctype_hash, attester.clone())]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(PublicCredentials::add( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), Box::new(new_credential.clone()) @@ -161,8 +159,7 @@ fn add_unauthorized() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_ctypes(vec![(ctype_hash, attester.clone())]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::add( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), @@ -187,8 +184,7 @@ fn add_ctype_not_existing() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::add( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), @@ -214,8 +210,7 @@ fn add_invalid_subject() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_ctypes(vec![(ctype_hash, attester.clone())]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::add( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), @@ -242,8 +237,7 @@ fn add_not_enough_balance() { // One less than the minimum required .with_balances(vec![(ACCOUNT_00, deposit - 1)]) .with_ctypes(vec![(ctype_hash, attester.clone())]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::add( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), @@ -267,8 +261,7 @@ fn revoke_successful() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(PublicCredentials::revoke( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), credential_id, @@ -308,8 +301,7 @@ fn revoke_same_attester_wrong_ac() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(PublicCredentials::revoke( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), credential_id, @@ -337,8 +329,7 @@ fn revoke_unauthorized() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::revoke( DoubleOrigin(ACCOUNT_00, wrong_submitter).into(), @@ -363,8 +354,7 @@ fn revoke_ac_not_found() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::revoke( DoubleOrigin(ACCOUNT_00, wrong_submitter.clone()).into(), @@ -384,8 +374,7 @@ fn revoke_credential_not_found() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::revoke(DoubleOrigin(ACCOUNT_00, attester.clone()).into(), credential_id, None,), Error::::NotFound @@ -407,8 +396,7 @@ fn unrevoke_successful() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(PublicCredentials::unrevoke( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), credential_id, @@ -449,8 +437,7 @@ fn unrevoke_same_attester_wrong_ac() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(PublicCredentials::unrevoke( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), credential_id, @@ -479,8 +466,7 @@ fn unrevoke_unauthorized() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::unrevoke( DoubleOrigin(ACCOUNT_00, wrong_submitter).into(), @@ -506,8 +492,7 @@ fn unrevoke_ac_not_found() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::unrevoke( DoubleOrigin(ACCOUNT_00, wrong_submitter.clone()).into(), @@ -527,8 +512,7 @@ fn unrevoke_credential_not_found() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::unrevoke(DoubleOrigin(ACCOUNT_00, attester.clone()).into(), credential_id, None,), Error::::NotFound @@ -549,8 +533,7 @@ fn remove_successful() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(PublicCredentials::remove( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), credential_id, @@ -585,8 +568,7 @@ fn remove_same_attester_wrong_ac() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(PublicCredentials::remove( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), credential_id, @@ -612,8 +594,7 @@ fn remove_unauthorized() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::remove( DoubleOrigin(ACCOUNT_00, wrong_submitter).into(), @@ -638,8 +619,7 @@ fn remove_ac_not_found() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::remove( DoubleOrigin(ACCOUNT_00, wrong_submitter.clone()).into(), @@ -659,8 +639,7 @@ fn remove_credential_not_found() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::remove(DoubleOrigin(ACCOUNT_00, attester.clone()).into(), credential_id, None,), Error::::NotFound @@ -681,8 +660,7 @@ fn reclaim_deposit_successful() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(PublicCredentials::reclaim_deposit( RuntimeOrigin::signed(ACCOUNT_00), credential_id @@ -715,8 +693,7 @@ fn reclaim_deposit_credential_not_found() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::reclaim_deposit(RuntimeOrigin::signed(ACCOUNT_00), credential_id), Error::::NotFound @@ -735,8 +712,7 @@ fn reclaim_deposit_unauthorized() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::reclaim_deposit(RuntimeOrigin::signed(ACCOUNT_01), credential_id), Error::::NotAuthorized @@ -766,8 +742,7 @@ fn test_change_deposit_owner() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit), (ACCOUNT_01, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(PublicCredentials::change_deposit_owner( DoubleOrigin(ACCOUNT_01, attester.clone()).into(), credential_id @@ -794,8 +769,7 @@ fn test_change_deposit_owner_not_found() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit), (ACCOUNT_01, deposit)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::change_deposit_owner( DoubleOrigin(ACCOUNT_01, attester.clone()).into(), @@ -827,8 +801,7 @@ fn test_change_deposit_owner_unauthorized() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit), (ACCOUNT_01, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::change_deposit_owner(DoubleOrigin(ACCOUNT_01, evil.clone()).into(), credential_id), Error::::NotAuthorized @@ -858,8 +831,7 @@ fn test_update_deposit() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit_old)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(PublicCredentials::update_deposit( RuntimeOrigin::signed(ACCOUNT_00), credential_id @@ -884,8 +856,7 @@ fn test_update_deposit_not_found() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::update_deposit(RuntimeOrigin::signed(ACCOUNT_01), credential_id), Error::::NotFound @@ -904,8 +875,7 @@ fn test_update_deposit_unauthorized() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::update_deposit(RuntimeOrigin::signed(ACCOUNT_01), credential_id), Error::::NotAuthorized From 6d65710fcf8e3fd58165535631c46a21e30224e0 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 28 Apr 2023 10:54:46 +0200 Subject: [PATCH 09/40] bug --- pallets/delegation/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/delegation/src/lib.rs b/pallets/delegation/src/lib.rs index d35f56040..effd30ea1 100644 --- a/pallets/delegation/src/lib.rs +++ b/pallets/delegation/src/lib.rs @@ -980,7 +980,7 @@ pub mod pallet { fn get_merged_subtree(node: DelegationNode) -> Vec> { let mut nodes_to_explore = vec![node]; let mut children: Vec> = Vec::new(); - while nodes_to_explore.is_empty() { + while !nodes_to_explore.is_empty() { let current_node = nodes_to_explore.pop().unwrap(); let child_nodes: Vec> = current_node .children From 0b3c2811caf0d60fad4d7f00ae1e62c7b8ae1f39 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 28 Apr 2023 10:56:29 +0200 Subject: [PATCH 10/40] comments --- pallets/delegation/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/delegation/src/lib.rs b/pallets/delegation/src/lib.rs index effd30ea1..5e518d331 100644 --- a/pallets/delegation/src/lib.rs +++ b/pallets/delegation/src/lib.rs @@ -1009,7 +1009,7 @@ pub mod pallet { .count(); match delegation_details.parent { - // If node is a leaf or intermediate node, check if the node occures only once. Otherwise we have cylces. + // If node is a leaf or intermediate, check if it occures only once. Otherwise we have cylces. Some(_) => ensure!(children_count <= 1 , DispatchError::Other("Test")), // if parent is None, check that the root is not the children // from another node. @@ -1019,7 +1019,7 @@ pub mod pallet { // if a node is revoked, his subtree should be revoked as well. if delegation_details.details.revoked { let is_subtree_revoked = get_merged_subtree::(delegation_details).iter().map(|child : &DelegationNode| {child.details.revoked }).fold(true, |acc, x| acc && x); - ensure!(is_subtree_revoked, DispatchError::Other("Test") ); + ensure!(is_subtree_revoked, DispatchError::Other("Test")); } Ok(()) }, From ca72f477e850d0b888d767ccc9822fc63ceca580 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 28 Apr 2023 12:48:19 +0200 Subject: [PATCH 11/40] public credentials --- pallets/public-credentials/src/tests.rs | 82 +++++++++++++++++++------ 1 file changed, 62 insertions(+), 20 deletions(-) diff --git a/pallets/public-credentials/src/tests.rs b/pallets/public-credentials/src/tests.rs index 477c721ae..b60a1dfed 100644 --- a/pallets/public-credentials/src/tests.rs +++ b/pallets/public-credentials/src/tests.rs @@ -254,13 +254,16 @@ fn add_not_enough_balance() { fn revoke_successful() { let attester = sr25519_did_from_seed(&ALICE_SEED); let subject_id: ::SubjectId = SUBJECT_ID_00; - let new_credential = generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), None, None); + let ctype_hash_1 = get_ctype_hash::(true); + let new_credential = + generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), Some(ctype_hash_1), None); let credential_id: CredentialIdOf = CredentialIdOf::::default(); let deposit: Balance = ::Deposit::get(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) + .with_ctypes(vec![(ctype_hash_1, attester.clone())]) .build_and_execute_with_sanity_tests(|| { assert_ok!(PublicCredentials::revoke( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), @@ -293,7 +296,9 @@ fn revoke_same_attester_wrong_ac() { let attester = sr25519_did_from_seed(&ALICE_SEED); let wrong_submitter = sr25519_did_from_seed(&BOB_SEED); let subject_id: ::SubjectId = SUBJECT_ID_00; - let mut new_credential = generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), None, None); + let ctype_hash_1 = get_ctype_hash::(true); + let mut new_credential = + generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), Some(ctype_hash_1), None); new_credential.authorization_id = Some(attester.clone()); let credential_id: CredentialIdOf = CredentialIdOf::::default(); let deposit: Balance = ::Deposit::get(); @@ -301,6 +306,7 @@ fn revoke_same_attester_wrong_ac() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) + .with_ctypes(vec![(ctype_hash_1, attester.clone())]) .build_and_execute_with_sanity_tests(|| { assert_ok!(PublicCredentials::revoke( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), @@ -319,9 +325,11 @@ fn revoke_same_attester_wrong_ac() { #[test] fn revoke_unauthorized() { let attester = sr25519_did_from_seed(&ALICE_SEED); + let ctype_hash_1 = get_ctype_hash::(true); let wrong_submitter = sr25519_did_from_seed(&BOB_SEED); let subject_id: ::SubjectId = SUBJECT_ID_00; - let mut new_credential = generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), None, None); + let mut new_credential = + generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), Some(ctype_hash_1), None); new_credential.authorization_id = Some(attester.clone()); let credential_id: CredentialIdOf = CredentialIdOf::::default(); let deposit: Balance = ::Deposit::get(); @@ -329,6 +337,7 @@ fn revoke_unauthorized() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) + .with_ctypes(vec![(ctype_hash_1, attester.clone())]) .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::revoke( @@ -345,15 +354,18 @@ fn revoke_unauthorized() { fn revoke_ac_not_found() { let attester = sr25519_did_from_seed(&ALICE_SEED); let wrong_submitter = sr25519_did_from_seed(&BOB_SEED); + let ctype_hash_1 = get_ctype_hash::(true); let subject_id: ::SubjectId = SUBJECT_ID_00; - let mut new_credential = generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), None, None); - new_credential.authorization_id = Some(attester); + let mut new_credential = + generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), Some(ctype_hash_1), None); + new_credential.authorization_id = Some(attester.clone()); let credential_id: CredentialIdOf = CredentialIdOf::::default(); let deposit: Balance = ::Deposit::get(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) + .with_ctypes(vec![(ctype_hash_1, attester)]) .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::revoke( @@ -388,7 +400,9 @@ fn revoke_credential_not_found() { fn unrevoke_successful() { let attester = sr25519_did_from_seed(&ALICE_SEED); let subject_id: ::SubjectId = SUBJECT_ID_00; - let mut new_credential = generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), None, None); + let ctype_hash_1 = get_ctype_hash::(true); + let mut new_credential = + generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), Some(ctype_hash_1), None); new_credential.revoked = true; let credential_id: CredentialIdOf = CredentialIdOf::::default(); let deposit: Balance = ::Deposit::get(); @@ -396,6 +410,7 @@ fn unrevoke_successful() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) + .with_ctypes(vec![(ctype_hash_1, attester.clone())]) .build_and_execute_with_sanity_tests(|| { assert_ok!(PublicCredentials::unrevoke( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), @@ -427,8 +442,10 @@ fn unrevoke_successful() { fn unrevoke_same_attester_wrong_ac() { let attester = sr25519_did_from_seed(&ALICE_SEED); let wrong_submitter = sr25519_did_from_seed(&BOB_SEED); + let ctype_hash_1 = get_ctype_hash::(true); let subject_id: ::SubjectId = SUBJECT_ID_00; - let mut new_credential = generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), None, None); + let mut new_credential = + generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), Some(ctype_hash_1), None); new_credential.revoked = true; new_credential.authorization_id = Some(attester.clone()); let credential_id: CredentialIdOf = CredentialIdOf::::default(); @@ -437,6 +454,7 @@ fn unrevoke_same_attester_wrong_ac() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) + .with_ctypes(vec![(ctype_hash_1, attester.clone())]) .build_and_execute_with_sanity_tests(|| { assert_ok!(PublicCredentials::unrevoke( DoubleOrigin(ACCOUNT_00, attester.clone()).into(), @@ -456,8 +474,10 @@ fn unrevoke_same_attester_wrong_ac() { fn unrevoke_unauthorized() { let attester = sr25519_did_from_seed(&ALICE_SEED); let wrong_submitter = sr25519_did_from_seed(&BOB_SEED); + let ctype_hash_1 = get_ctype_hash::(true); let subject_id: ::SubjectId = SUBJECT_ID_00; - let mut new_credential = generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), None, None); + let mut new_credential = + generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), Some(ctype_hash_1), None); new_credential.revoked = true; new_credential.authorization_id = Some(attester.clone()); let credential_id: CredentialIdOf = CredentialIdOf::::default(); @@ -465,6 +485,7 @@ fn unrevoke_unauthorized() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) + .with_ctypes(vec![(ctype_hash_1, attester.clone())]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) .build_and_execute_with_sanity_tests(|| { assert_noop!( @@ -482,16 +503,19 @@ fn unrevoke_unauthorized() { fn unrevoke_ac_not_found() { let attester = sr25519_did_from_seed(&ALICE_SEED); let wrong_submitter = sr25519_did_from_seed(&BOB_SEED); + let ctype_hash_1 = get_ctype_hash::(true); let subject_id: ::SubjectId = SUBJECT_ID_00; - let mut new_credential = generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), None, None); + let mut new_credential = + generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), Some(ctype_hash_1), None); new_credential.revoked = true; - new_credential.authorization_id = Some(attester); + new_credential.authorization_id = Some(attester.clone()); let credential_id: CredentialIdOf = CredentialIdOf::::default(); let deposit: Balance = ::Deposit::get(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) + .with_ctypes(vec![(ctype_hash_1, attester)]) .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::unrevoke( @@ -586,7 +610,9 @@ fn remove_unauthorized() { let attester = sr25519_did_from_seed(&ALICE_SEED); let wrong_submitter = sr25519_did_from_seed(&BOB_SEED); let subject_id: ::SubjectId = SUBJECT_ID_00; - let mut new_credential = generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), None, None); + let ctype_hash_1 = get_ctype_hash::(true); + let mut new_credential = + generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), Some(ctype_hash_1), None); new_credential.authorization_id = Some(attester.clone()); let credential_id: CredentialIdOf = CredentialIdOf::::default(); let deposit: Balance = ::Deposit::get(); @@ -594,6 +620,7 @@ fn remove_unauthorized() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) + .with_ctypes(vec![(ctype_hash_1, attester.clone())]) .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::remove( @@ -610,15 +637,18 @@ fn remove_unauthorized() { fn remove_ac_not_found() { let attester = sr25519_did_from_seed(&ALICE_SEED); let wrong_submitter = sr25519_did_from_seed(&BOB_SEED); + let ctype_hash_1 = get_ctype_hash::(true); let subject_id: ::SubjectId = SUBJECT_ID_00; - let mut new_credential = generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), None, None); - new_credential.authorization_id = Some(attester); + let mut new_credential = + generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), Some(ctype_hash_1), None); + new_credential.authorization_id = Some(attester.clone()); let credential_id: CredentialIdOf = CredentialIdOf::::default(); let deposit: Balance = ::Deposit::get(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) + .with_ctypes(vec![(ctype_hash_1, attester)]) .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::remove( @@ -705,13 +735,16 @@ fn reclaim_deposit_credential_not_found() { fn reclaim_deposit_unauthorized() { let attester = sr25519_did_from_seed(&ALICE_SEED); let subject_id: ::SubjectId = SUBJECT_ID_00; - let new_credential = generate_base_credential_entry::(ACCOUNT_00, 0, attester, None, None); + let ctype_hash_1 = get_ctype_hash::(true); + let new_credential = + generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), Some(ctype_hash_1), None); let credential_id: CredentialIdOf = CredentialIdOf::::default(); let deposit: Balance = ::Deposit::get(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) + .with_ctypes(vec![(ctype_hash_1, attester)]) .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::reclaim_deposit(RuntimeOrigin::signed(ACCOUNT_01), credential_id), @@ -727,11 +760,12 @@ fn test_change_deposit_owner() { let attester = sr25519_did_from_seed(&ALICE_SEED); let subject_id: ::SubjectId = SUBJECT_ID_00; let deposit: Balance = ::Deposit::get(); + let ctype_hash_1 = get_ctype_hash::(true); let new_credential = generate_base_credential_entry::( ACCOUNT_00, 0, attester.clone(), - None, + Some(ctype_hash_1), Some(Deposit { owner: ACCOUNT_00, amount: deposit, @@ -742,6 +776,7 @@ fn test_change_deposit_owner() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit), (ACCOUNT_01, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) + .with_ctypes(vec![(ctype_hash_1, attester.clone())]) .build_and_execute_with_sanity_tests(|| { assert_ok!(PublicCredentials::change_deposit_owner( DoubleOrigin(ACCOUNT_01, attester.clone()).into(), @@ -785,12 +820,13 @@ fn test_change_deposit_owner_unauthorized() { let attester = sr25519_did_from_seed(&ALICE_SEED); let evil = sr25519_did_from_seed(&BOB_SEED); let subject_id: ::SubjectId = SUBJECT_ID_00; + let ctype_hash_1 = get_ctype_hash::(true); let deposit: Balance = ::Deposit::get(); let new_credential = generate_base_credential_entry::( ACCOUNT_00, 0, - attester, - None, + attester.clone(), + Some(ctype_hash_1), Some(Deposit { owner: ACCOUNT_00, amount: deposit, @@ -801,6 +837,7 @@ fn test_change_deposit_owner_unauthorized() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit), (ACCOUNT_01, deposit)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) + .with_ctypes(vec![(ctype_hash_1, attester)]) .build_and_execute_with_sanity_tests(|| { assert_noop!( PublicCredentials::change_deposit_owner(DoubleOrigin(ACCOUNT_01, evil.clone()).into(), credential_id), @@ -816,11 +853,12 @@ fn test_update_deposit() { let attester = sr25519_did_from_seed(&ALICE_SEED); let subject_id: ::SubjectId = SUBJECT_ID_00; let deposit_old: Balance = MILLI_UNIT * 10; + let ctype_hash_1 = get_ctype_hash::(true); let new_credential = generate_base_credential_entry::( ACCOUNT_00, 0, - attester, - None, + attester.clone(), + Some(ctype_hash_1), Some(Deposit { owner: ACCOUNT_00, amount: deposit_old, @@ -831,6 +869,7 @@ fn test_update_deposit() { ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit_old)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) + .with_ctypes(vec![(ctype_hash_1, attester)]) .build_and_execute_with_sanity_tests(|| { assert_ok!(PublicCredentials::update_deposit( RuntimeOrigin::signed(ACCOUNT_00), @@ -867,13 +906,16 @@ fn test_update_deposit_not_found() { #[test] fn test_update_deposit_unauthorized() { let attester = sr25519_did_from_seed(&ALICE_SEED); + let ctype_hash_1 = get_ctype_hash::(true); let subject_id: ::SubjectId = SUBJECT_ID_00; - let new_credential = generate_base_credential_entry::(ACCOUNT_00, 0, attester, None, None); + let new_credential = + generate_base_credential_entry::(ACCOUNT_00, 0, attester.clone(), Some(ctype_hash_1), None); let credential_id: CredentialIdOf = CredentialIdOf::::default(); let deposit: Balance = ::Deposit::get(); ExtBuilder::default() .with_balances(vec![(ACCOUNT_00, deposit)]) + .with_ctypes(vec![(ctype_hash_1, attester)]) .with_public_credentials(vec![(subject_id, credential_id, new_credential)]) .build_and_execute_with_sanity_tests(|| { assert_noop!( From 8e78c9ed5189650ad95a23b1ffb695f76512d84e Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Tue, 2 May 2023 08:30:45 +0200 Subject: [PATCH 12/40] fmt --- pallets/attestation/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/pallets/attestation/src/lib.rs b/pallets/attestation/src/lib.rs index fe7a9592c..d7a4885b1 100644 --- a/pallets/attestation/src/lib.rs +++ b/pallets/attestation/src/lib.rs @@ -471,6 +471,7 @@ pub mod pallet { ExternalAttestations::::remove(authorization_id, claim_hash); } } + #[cfg(any(feature = "try-runtime", test))] pub fn do_try_state() -> DispatchResult { Attestations::::iter().try_for_each(|(claim_hash, attestation_details)| -> DispatchResult { From 1ff6584259118d6bd4defd74df2fd4fa187e6056 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Tue, 2 May 2023 10:40:46 +0200 Subject: [PATCH 13/40] fix: do_try_state --- pallets/attestation/src/lib.rs | 2 +- pallets/delegation/src/lib.rs | 2 +- pallets/did/src/lib.rs | 2 +- pallets/pallet-did-lookup/src/lib.rs | 3 ++- pallets/pallet-web3-names/src/lib.rs | 2 +- pallets/public-credentials/src/lib.rs | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pallets/attestation/src/lib.rs b/pallets/attestation/src/lib.rs index d7a4885b1..278df6724 100644 --- a/pallets/attestation/src/lib.rs +++ b/pallets/attestation/src/lib.rs @@ -151,7 +151,7 @@ pub mod pallet { impl Hooks> for Pallet { #[cfg(feature = "try-runtime")] fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { - do_try_state()?; + Self::do_try_state()?; Ok(()) } } diff --git a/pallets/delegation/src/lib.rs b/pallets/delegation/src/lib.rs index 5e518d331..785f26a54 100644 --- a/pallets/delegation/src/lib.rs +++ b/pallets/delegation/src/lib.rs @@ -290,7 +290,7 @@ pub mod pallet { impl Hooks> for Pallet { #[cfg(feature = "try-runtime")] fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { - do_try_state()?; + Self::do_try_state()?; Ok(()) } } diff --git a/pallets/did/src/lib.rs b/pallets/did/src/lib.rs index 9874ed2d0..8ee6ef184 100644 --- a/pallets/did/src/lib.rs +++ b/pallets/did/src/lib.rs @@ -467,7 +467,7 @@ pub mod pallet { impl Hooks> for Pallet { #[cfg(feature = "try-runtime")] fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { - do_try_state()?; + Self::do_try_state()?; Ok(()) } } diff --git a/pallets/pallet-did-lookup/src/lib.rs b/pallets/pallet-did-lookup/src/lib.rs index 5e1f1f55a..ceee8c561 100644 --- a/pallets/pallet-did-lookup/src/lib.rs +++ b/pallets/pallet-did-lookup/src/lib.rs @@ -194,7 +194,8 @@ pub mod pallet { impl Hooks> for Pallet { #[cfg(feature = "try-runtime")] fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { - do_try_state()?; + #[cfg(feature = "try-runtime")] + Self::do_try_state()?; Ok(()) } } diff --git a/pallets/pallet-web3-names/src/lib.rs b/pallets/pallet-web3-names/src/lib.rs index a3e931b17..f04695cb9 100644 --- a/pallets/pallet-web3-names/src/lib.rs +++ b/pallets/pallet-web3-names/src/lib.rs @@ -178,7 +178,7 @@ pub mod pallet { impl Hooks> for Pallet { #[cfg(feature = "try-runtime")] fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { - do_try_state()?; + Self::do_try_state()?; Ok(()) } } diff --git a/pallets/public-credentials/src/lib.rs b/pallets/public-credentials/src/lib.rs index 123720c33..b729b6937 100644 --- a/pallets/public-credentials/src/lib.rs +++ b/pallets/public-credentials/src/lib.rs @@ -233,7 +233,7 @@ pub mod pallet { impl Hooks> for Pallet { #[cfg(feature = "try-runtime")] fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { - do_try_state()?; + Self::do_try_state()?; Ok(()) } } From cd2291f84d98e5df79bd61e26a2c37cc90929a13 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Tue, 2 May 2023 14:03:06 +0200 Subject: [PATCH 14/40] fix test --- pallets/delegation/src/lib.rs | 6 +++--- pallets/parachain-staking/src/inflation.rs | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pallets/delegation/src/lib.rs b/pallets/delegation/src/lib.rs index 785f26a54..a9f46fee7 100644 --- a/pallets/delegation/src/lib.rs +++ b/pallets/delegation/src/lib.rs @@ -979,13 +979,13 @@ pub mod pallet { pub fn do_try_state() -> DispatchResult { fn get_merged_subtree(node: DelegationNode) -> Vec> { let mut nodes_to_explore = vec![node]; - let mut children: Vec> = Vec::new(); + let mut children: Vec> = vec![]; while !nodes_to_explore.is_empty() { let current_node = nodes_to_explore.pop().unwrap(); let child_nodes: Vec> = current_node .children .iter() - .filter_map(|child_id| DelegationNodes::::get(child_id)) + .filter_map(DelegationNodes::::get) .collect(); nodes_to_explore.extend(child_nodes.clone()); children.extend(child_nodes); @@ -1018,7 +1018,7 @@ pub mod pallet { // if a node is revoked, his subtree should be revoked as well. if delegation_details.details.revoked { - let is_subtree_revoked = get_merged_subtree::(delegation_details).iter().map(|child : &DelegationNode| {child.details.revoked }).fold(true, |acc, x| acc && x); + let is_subtree_revoked = get_merged_subtree::(delegation_details).iter().map(|child : &DelegationNode| {child.details.revoked }).all(|x| !x); ensure!(is_subtree_revoked, DispatchError::Other("Test")); } Ok(()) diff --git a/pallets/parachain-staking/src/inflation.rs b/pallets/parachain-staking/src/inflation.rs index d3ab9913d..542a86135 100644 --- a/pallets/parachain-staking/src/inflation.rs +++ b/pallets/parachain-staking/src/inflation.rs @@ -134,6 +134,8 @@ impl InflationInfo { /// Check whether the annual reward rate is approx. the per_block reward /// rate multiplied with the number of blocks per year pub fn is_valid(&self, blocks_per_year: u64) -> bool { + // !TODO! why only bigger? -> blocks_per_year has to get bigger -> more blocks + // in less seconds. self.collator.reward_rate.annual >= Perquintill::from_parts( self.collator From 866f7014b905b658da558a453b30b02451d958a8 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Tue, 2 May 2023 14:04:21 +0200 Subject: [PATCH 15/40] clippy --- pallets/attestation/src/mock.rs | 2 +- pallets/delegation/src/mock.rs | 2 +- pallets/did/src/mock.rs | 2 +- pallets/pallet-did-lookup/src/mock.rs | 2 +- pallets/pallet-web3-names/src/mock.rs | 2 +- pallets/public-credentials/src/mock.rs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pallets/attestation/src/mock.rs b/pallets/attestation/src/mock.rs index bb63cd065..aa2e6cc7c 100644 --- a/pallets/attestation/src/mock.rs +++ b/pallets/attestation/src/mock.rs @@ -387,7 +387,7 @@ pub(crate) mod runtime { ext } - pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce() -> ()) { + pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce()) { self.build().execute_with(|| { test(); Pallet::::do_try_state().unwrap(); diff --git a/pallets/delegation/src/mock.rs b/pallets/delegation/src/mock.rs index 331566f8a..fde1c39ea 100644 --- a/pallets/delegation/src/mock.rs +++ b/pallets/delegation/src/mock.rs @@ -513,7 +513,7 @@ pub(crate) mod runtime { ext } - pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce() -> ()) { + pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce()) { self.build().execute_with(|| { test(); Pallet::::do_try_state().unwrap(); diff --git a/pallets/did/src/mock.rs b/pallets/did/src/mock.rs index 20247e11c..7efd5befe 100644 --- a/pallets/did/src/mock.rs +++ b/pallets/did/src/mock.rs @@ -500,7 +500,7 @@ impl ExtBuilder { ext } - pub fn build_and_execute_with_sanity_tests(self, ext: Option, test: impl FnOnce() -> ()) { + pub fn build_and_execute_with_sanity_tests(self, ext: Option, test: impl FnOnce()) { self.build(ext).execute_with(|| { test(); Pallet::::do_try_state().unwrap(); diff --git a/pallets/pallet-did-lookup/src/mock.rs b/pallets/pallet-did-lookup/src/mock.rs index 9eaac2b75..6d9a1b767 100644 --- a/pallets/pallet-did-lookup/src/mock.rs +++ b/pallets/pallet-did-lookup/src/mock.rs @@ -199,7 +199,7 @@ impl ExtBuilder { ext } - pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce() -> ()) { + pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce()) { self.build().execute_with(|| { test(); Pallet::::do_try_state().unwrap(); diff --git a/pallets/pallet-web3-names/src/mock.rs b/pallets/pallet-web3-names/src/mock.rs index d41fc34b5..f103b4f44 100644 --- a/pallets/pallet-web3-names/src/mock.rs +++ b/pallets/pallet-web3-names/src/mock.rs @@ -235,7 +235,7 @@ pub(crate) mod runtime { ext } - pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce() -> ()) { + pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce()) { self.build().execute_with(|| { test(); Pallet::::do_try_state().unwrap(); diff --git a/pallets/public-credentials/src/mock.rs b/pallets/public-credentials/src/mock.rs index c5965e460..c0dea1a22 100644 --- a/pallets/public-credentials/src/mock.rs +++ b/pallets/public-credentials/src/mock.rs @@ -443,7 +443,7 @@ pub(crate) mod runtime { ext } - pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce() -> ()) { + pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce()) { self.build().execute_with(|| { test(); Pallet::::do_try_state().unwrap(); From 4a3ef47ee4d1875b076c785ca9ac1e60dffd1fa0 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Tue, 2 May 2023 17:01:09 +0200 Subject: [PATCH 16/40] first draft for staking --- pallets/parachain-staking/src/lib.rs | 39 ++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index 2d8d4c71a..5afc01b63 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -511,6 +511,12 @@ pub mod pallet { } post_weight } + + #[cfg(feature = "try-runtime")] + fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { + Self::do_try_state()?; + Ok(()) + } } /// The maximum number of collator candidates selected at each round. @@ -1272,7 +1278,7 @@ pub mod pallet { ); // we don't unlock immediately - Self::prep_unstake(&collator, less, false)?; + Self::prep_unstake(&collator, less, false)?; // if we prepare unstake let n = if state.is_active() { Self::update_top_candidates( @@ -1652,6 +1658,7 @@ pub mod pallet { #[pallet::weight(::WeightInfo::claim_rewards())] pub fn claim_rewards(origin: OriginFor) -> DispatchResult { let target = ensure_signed(origin)?; + // !TODO! not update before? // reset rewards let rewards = Rewards::::take(&target); @@ -1738,6 +1745,7 @@ pub mod pallet { // delegator reward rate should be 6% in 2nd year and 0% afterwards let d_reward_rate = if year == T::BlockNumber::one() { + // !TODO! set delegation to zero? Perquintill::from_percent(6) } else { Perquintill::zero() @@ -1757,6 +1765,33 @@ pub mod pallet { } impl Pallet { + // #[cfg(any(feature = "try-runtime", test))] + pub fn do_try_state() -> DispatchResult { + CandidatePool::::iter().try_for_each( + |(key, candidate): ( + T::AccountId, + Candidate, T::MaxDelegatorsPerCollator>, + )| + -> DispatchResult { + let sum_delegations: BalanceOf = candidate + .delegators + .into_iter() + .fold(Zero::zero(), |acc, stake| acc + stake.amount); // maybe sum? + + // total stake should be the sum of delegators stake + colator stake. + ensure!( + sum_delegations.saturating_add(candidate.stake) == candidate.total, + DispatchError::Other("Tests") + ); + + // delegators should be in delegator pool. + + Ok(()) + }, + )?; + Ok(()) + } + /// Check whether an account is currently delegating. pub fn is_delegator(acc: &T::AccountId) -> bool { DelegatorState::::get(acc).is_some() @@ -2374,7 +2409,7 @@ pub mod pallet { collators: total_collators, .. } = TotalCollatorStake::::get(); - let staking_rate = Perquintill::from_rational(total_collators, total_issuance); + let staking_rate = Perquintill::from_rational(total_collators, total_issuance); // why staking rate? InflationConfig::::get() .collator From 2ecc68675df79e733849dd31b2439fcaa0e01671 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 3 May 2023 09:40:39 +0200 Subject: [PATCH 17/40] first draft for staking --- pallets/parachain-staking/src/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index 5afc01b63..44a3b156b 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -1784,6 +1784,11 @@ pub mod pallet { DispatchError::Other("Tests") ); + candidate + .delegators + .into_iter() + .filter_map(|delegator_stake| delegator_stake.owner); + // delegators should be in delegator pool. Ok(()) From b6538d28fd951e897f5fb9ca411626fa1b5a3613 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 3 May 2023 17:01:42 +0200 Subject: [PATCH 18/40] staking pallet --- pallets/parachain-staking/src/lib.rs | 140 +++++++++++++++-- pallets/parachain-staking/src/mock.rs | 7 + pallets/parachain-staking/src/set.rs | 4 + pallets/parachain-staking/src/tests.rs | 207 +++++++++---------------- 4 files changed, 208 insertions(+), 150 deletions(-) diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index 44a3b156b..961752dd1 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -1765,18 +1765,14 @@ pub mod pallet { } impl Pallet { - // #[cfg(any(feature = "try-runtime", test))] + #[cfg(any(feature = "try-runtime", test))] pub fn do_try_state() -> DispatchResult { - CandidatePool::::iter().try_for_each( - |(key, candidate): ( - T::AccountId, - Candidate, T::MaxDelegatorsPerCollator>, - )| - -> DispatchResult { + CandidatePool::::iter_values().try_for_each( + |candidate: Candidate, _>| -> DispatchResult { let sum_delegations: BalanceOf = candidate .delegators - .into_iter() - .fold(Zero::zero(), |acc, stake| acc + stake.amount); // maybe sum? + .iter() + .fold(Zero::zero(), |acc, stake| acc.saturating_add(stake.amount)); // total stake should be the sum of delegators stake + colator stake. ensure!( @@ -1784,16 +1780,136 @@ pub mod pallet { DispatchError::Other("Tests") ); + // Min required stake should be set + ensure!( + candidate.stake >= T::MinCollatorCandidateStake::get(), + DispatchError::Other("Tests") + ); + + // delegators should be in delegator pool. + let are_delegator_present = candidate + .delegators + .iter() + .map(|delegator_stake| DelegatorState::::get(&delegator_stake.owner).is_some()) + .all(|x| x); + ensure!(are_delegator_present, DispatchError::Other("Tests")); + + // each delegator should not exceed the [MaxDelegationsPerRound] candidate .delegators - .into_iter() - .filter_map(|delegator_stake| delegator_stake.owner); + .iter() + .try_for_each(|delegator_stake| -> DispatchResult { + Self::get_delegation_counter(&delegator_stake.owner)?; + Ok(()) + })?; - // delegators should be in delegator pool. + // check min and max stake for each candidate + ensure!( + candidate.stake <= MaxCollatorCandidateStake::::get(), + DispatchError::Other("Tests") + ); + + ensure!( + candidate.stake >= T::MinCollatorStake::get(), + DispatchError::Other("Tests") + ); + + // delegators should have the min required stake. + candidate + .delegators + .iter() + .try_for_each(|delegator_stake| -> DispatchResult { + ensure!( + delegator_stake.amount >= T::MinDelegatorStake::get(), + DispatchError::Other("Tests") + ); + Ok(()) + })?; Ok(()) }, )?; + + // check if enough collators are set. + ensure!( + CandidatePool::::count() >= T::MinCollators::get(), + DispatchError::Other("Tests") + ); + + let top_candidates = TopCandidates::::get(); + + // check if enough top candidates are set. + ensure!( + top_candidates.len() >= T::MinRequiredCollators::get().saturated_into(), + DispatchError::Other("Tests") + ); + + top_candidates.iter().try_for_each(|stake| -> DispatchResult { + // top candidates should be part of the candidate pool. + ensure!( + CandidatePool::::contains_key(stake.clone().owner), + DispatchError::Other("Tests") + ); + + // an account can not be candidate and delegator. + ensure!( + DelegatorState::::get(&stake.owner).is_none(), + DispatchError::Other("Tests") + ); + + // a top candidate should be active. + ensure!( + Self::is_active_candidate(&stake.owner).unwrap(), + DispatchError::Other("Tests") + ); + + Ok(()) + })?; + + // each locked fund should have a collator or delegator. + Unstaking::::iter_keys().try_for_each(|who| -> DispatchResult { + let is_candidate = CandidatePool::::contains_key(&who); + let is_delegator = DelegatorState::::contains_key(&who); + ensure!(is_candidate || is_delegator, DispatchError::Other("Tests")); + Ok(()) + })?; + + // the total fund has to be the sum over the first [MaxSelectedCandidates] of + // [TopCandidates]. + + let top_n = MaxSelectedCandidates::::get().saturated_into::(); + + let total_collator_delegator_stake = TotalCollatorStake::::get(); + + let total_fund_from_collators = top_candidates + .iter() + .take(top_n) + .filter(|x| x.amount >= T::MinCollatorStake::get()) + .fold(Zero::zero(), |acc: BalanceOf, stake| { + acc.saturating_add(stake.amount) + }); + + let total_fund = top_candidates + .iter() + .take(top_n) + .filter(|x| x.amount >= T::MinCollatorStake::get()) + .filter_map(|stake| CandidatePool::::get(&stake.owner)) + .fold(Zero::zero(), |acc: BalanceOf, candidate| { + acc.saturating_add(candidate.total) + }); + + let delegator_fund = total_fund.saturating_sub(total_fund_from_collators); + + ensure!( + total_collator_delegator_stake.collators == total_fund_from_collators, + DispatchError::Other("Tests") + ); + + ensure!( + total_collator_delegator_stake.delegators == delegator_fund, + DispatchError::Other("Tests") + ); + Ok(()) } diff --git a/pallets/parachain-staking/src/mock.rs b/pallets/parachain-staking/src/mock.rs index 65a9569e5..826943f99 100644 --- a/pallets/parachain-staking/src/mock.rs +++ b/pallets/parachain-staking/src/mock.rs @@ -343,6 +343,13 @@ impl ExtBuilder { ext.execute_with(|| System::set_block_number(1)); ext } + + pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce()) { + self.build().execute_with(|| { + test(); + Pallet::::do_try_state().unwrap(); + }) + } } /// Compare whether the difference of both sides is at most `precision * left`. diff --git a/pallets/parachain-staking/src/set.rs b/pallets/parachain-staking/src/set.rs index d6d0f496b..12dddebb2 100644 --- a/pallets/parachain-staking/src/set.rs +++ b/pallets/parachain-staking/src/set.rs @@ -41,6 +41,10 @@ impl> OrderedSet { Self(BoundedVec::default()) } + pub fn iter(&self) -> sp_std::slice::Iter<'_, T> { + self.0.iter() + } + /// Creates an ordered set from a `BoundedVec`. /// /// The vector will be sorted reversily (from greatest to lowest) and diff --git a/pallets/parachain-staking/src/tests.rs b/pallets/parachain-staking/src/tests.rs index fd1b59144..d9727547c 100644 --- a/pallets/parachain-staking/src/tests.rs +++ b/pallets/parachain-staking/src/tests.rs @@ -59,8 +59,7 @@ fn should_select_collators_genesis_session() { (11, 20), ]) .with_collators(vec![(1, 20), (2, 20)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( StakePallet::new_session(0) .expect("first session must return new collators") @@ -92,8 +91,7 @@ fn genesis() { ]) .with_collators(vec![(1, 500), (2, 200)]) .with_delegators(vec![(3, 1, 100), (4, 1, 100), (5, 2, 100), (6, 2, 100)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert!(System::events().is_empty()); // Collators @@ -209,8 +207,7 @@ fn genesis() { ]) .with_collators(vec![(1, 20), (2, 20), (3, 20), (4, 20), (5, 10)]) .with_delegators(vec![(6, 1, 10), (7, 1, 10), (8, 2, 10), (9, 2, 10), (10, 1, 10)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert!(System::events().is_empty()); assert_eq!(CandidatePool::::count(), 5); @@ -277,8 +274,7 @@ fn join_collator_candidates() { ]) .with_collators(vec![(1, 500), (2, 200)]) .with_delegators(vec![(3, 1, 100), (4, 1, 100), (5, 2, 100), (6, 2, 100)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(CandidatePool::::count(), 2); assert_eq!( StakePallet::total_collator_stake(), @@ -350,8 +346,7 @@ fn collator_exit_executes_after_delay() { ]) .with_collators(vec![(1, 500), (2, 200), (7, 100)]) .with_delegators(vec![(3, 1, 100), (4, 1, 100), (5, 2, 100), (6, 2, 100)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(CandidatePool::::count(), 3); assert_eq!( StakePallet::total_collator_stake(), @@ -426,8 +421,7 @@ fn collator_selection_chooses_top_candidates() { (9, 33), ]) .with_collators(vec![(1, 100), (2, 90), (3, 80), (4, 70), (5, 60), (6, 50)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(StakePallet::selected_candidates().into_inner(), vec![1, 2]); assert_eq!( StakePallet::total_collator_stake(), @@ -499,8 +493,7 @@ fn exit_queue_with_events() { ]) .with_collators(vec![(1, 100), (2, 90), (3, 80), (4, 70), (5, 60), (6, 50)]) .with_inflation(100, 15, 40, 10, BLOCKS_PER_ROUND) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(CandidatePool::::count(), 6); assert_eq!(StakePallet::selected_candidates().into_inner(), vec![1, 2]); assert_ok!(StakePallet::set_max_selected_candidates(RuntimeOrigin::root(), 5)); @@ -596,8 +589,7 @@ fn execute_leave_candidates_with_delay() { ]) .with_delegators(vec![(11, 1, 110), (12, 1, 120), (13, 2, 130), (14, 2, 140)]) .with_inflation(100, 15, 40, 10, BLOCKS_PER_ROUND) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(CandidatePool::::count(), 10); assert_eq!( StakePallet::total_collator_stake(), @@ -866,8 +858,7 @@ fn multiple_delegations() { .with_collators(vec![(1, 20), (2, 20), (3, 20), (4, 20), (5, 10)]) .with_delegators(vec![(6, 1, 10), (7, 1, 10), (8, 2, 10), (9, 2, 10), (10, 1, 10)]) .set_blocks_per_round(5) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(StakePallet::set_max_selected_candidates(RuntimeOrigin::root(), 5)); roll_to( 8, @@ -1031,8 +1022,7 @@ fn should_update_total_stake() { .with_collators(vec![(1, 20), (2, 20), (3, 20), (4, 20), (5, 10)]) .with_delegators(vec![(7, 1, 10), (8, 2, 10), (9, 2, 10)]) .set_blocks_per_round(5) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { let mut old_stake = StakePallet::total_collator_stake(); assert_eq!( old_stake, @@ -1167,8 +1157,7 @@ fn collators_bond() { .with_collators(vec![(1, 20), (2, 20), (3, 20), (4, 20), (5, 10)]) .with_delegators(vec![(6, 1, 10), (7, 1, 10), (8, 2, 10), (9, 2, 10), (10, 1, 10)]) .set_blocks_per_round(5) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { roll_to(4, vec![]); assert_noop!( StakePallet::candidate_stake_more(RuntimeOrigin::signed(6), 50), @@ -1254,8 +1243,7 @@ fn delegators_bond() { .with_collators(vec![(1, 20), (2, 20), (3, 20), (4, 20), (5, 10)]) .with_delegators(vec![(6, 1, 10), (7, 1, 10), (8, 2, 10), (9, 2, 10)]) .set_blocks_per_round(5) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { roll_to(4, vec![]); assert_noop!( StakePallet::join_delegators(RuntimeOrigin::signed(6), 2, 50), @@ -1309,8 +1297,7 @@ fn should_leave_delegators() { .with_balances(vec![(1, 100), (2, 100)]) .with_collators(vec![(1, 100)]) .with_delegators(vec![(2, 1, 100)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(StakePallet::leave_delegators(RuntimeOrigin::signed(2))); assert!(StakePallet::delegator_state(2).is_none()); assert!(!StakePallet::candidate_pool(1) @@ -1349,8 +1336,7 @@ fn round_transitions() { .with_collators(vec![(1, 20)]) .with_delegators(vec![(2, 1, 10), (3, 1, 10)]) .with_inflation(col_max, col_rewards, d_max, d_rewards, 5) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(inflation, StakePallet::inflation_config()); roll_to(5, vec![]); let init = vec![Event::NewRound(5, 1)]; @@ -1379,8 +1365,7 @@ fn round_transitions() { .with_collators(vec![(1, 20)]) .with_delegators(vec![(2, 1, 10), (3, 1, 10)]) .with_inflation(col_max, col_rewards, d_max, d_rewards, 5) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(inflation, StakePallet::inflation_config()); // Default round every 5 blocks, but MinBlocksPerRound is 3 and we set it to min // 3 blocks @@ -1409,8 +1394,7 @@ fn round_transitions() { .with_collators(vec![(1, 20)]) .with_delegators(vec![(2, 1, 10), (3, 1, 10)]) .with_inflation(col_max, col_rewards, d_max, d_rewards, 5) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // Default round every 5 blocks, but MinBlocksPerRound is 3 and we set it to min // 3 blocks assert_eq!(inflation, StakePallet::inflation_config()); @@ -1458,8 +1442,7 @@ fn coinbase_rewards_few_blocks_detailed_check() { (5, 2, 16_000_000 * DECIMALS), ]) .with_inflation(10, 15, 40, 15, 5) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { let inflation = StakePallet::inflation_config(); let total_issuance = ::Currency::total_issuance(); assert_eq!(total_issuance, 160_000_000 * DECIMALS); @@ -1544,8 +1527,7 @@ fn delegator_should_not_receive_rewards_after_revoking() { .with_collators(vec![(1, 10_000_000 * DECIMALS)]) .with_delegators(vec![(2, 1, 10_000_000 * DECIMALS)]) .with_inflation(10, 15, 40, 15, 5) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(StakePallet::leave_delegators(RuntimeOrigin::signed(2))); let authors: Vec> = (1u64..100u64).map(|_| Some(1u64)).collect(); assert_eq!(Balances::usable_balance(1), Balance::zero()); @@ -1565,8 +1547,7 @@ fn delegator_should_not_receive_rewards_after_revoking() { .with_collators(vec![(1, 10_000_000 * DECIMALS)]) .with_delegators(vec![(2, 1, 10_000_000 * DECIMALS), (3, 1, 10_000_000 * DECIMALS)]) .with_inflation(10, 15, 40, 15, 5) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(StakePallet::leave_delegators(RuntimeOrigin::signed(3))); let authors: Vec> = (1u64..100u64).map(|_| Some(1u64)).collect(); assert_eq!(Balances::usable_balance(1), Balance::zero()); @@ -1597,8 +1578,7 @@ fn coinbase_rewards_many_blocks_simple_check() { (5, 2, 16_000_000 * DECIMALS), ]) .with_inflation(10, 15, 40, 15, 5) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { let inflation = StakePallet::inflation_config(); let total_issuance = ::Currency::total_issuance(); assert_eq!(total_issuance, 160_000_000 * DECIMALS); @@ -1691,8 +1671,7 @@ fn should_not_reward_delegators_below_min_stake() { .with_collators(vec![(1, 10 * DECIMALS), (2, 10 * DECIMALS)]) .with_delegators(vec![(3, 2, 10 * DECIMALS)]) .with_inflation(10, 15, 40, 15, 5) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // impossible but lets assume it happened let mut state = StakePallet::candidate_pool(1).expect("CollatorState cannot be missing"); let delegator_stake_below_min = ::MinDelegatorStake::get() - 1; @@ -1727,8 +1706,7 @@ fn should_deny_low_delegator_stake() { .with_balances(vec![(1, 10 * DECIMALS), (2, 10 * DECIMALS), (3, 10 * DECIMALS), (4, 1)]) .with_collators(vec![(1, 10 * DECIMALS), (2, 10 * DECIMALS)]) .with_delegators(vec![(4, 2, 1)]) - .build() - .execute_with(|| {}); + .build_and_execute_with_sanity_tests(|| {}); } #[test] @@ -1737,8 +1715,7 @@ fn should_deny_low_collator_stake() { ExtBuilder::default() .with_balances(vec![(1, 10 * DECIMALS), (2, 5)]) .with_collators(vec![(1, 10 * DECIMALS), (2, 5)]) - .build() - .execute_with(|| {}); + .build_and_execute_with_sanity_tests(|| {}); } #[test] @@ -1747,8 +1724,7 @@ fn should_deny_duplicate_collators() { ExtBuilder::default() .with_balances(vec![(1, 10 * DECIMALS)]) .with_collators(vec![(1, 10 * DECIMALS), (1, 10 * DECIMALS)]) - .build() - .execute_with(|| {}); + .build_and_execute_with_sanity_tests(|| {}); } #[test] @@ -1781,8 +1757,7 @@ fn reach_max_top_candidates() { (9, 10), (10, 10), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( StakePallet::top_candidates().len().saturated_into::(), ::MaxTopCandidates::get() @@ -1851,8 +1826,7 @@ fn should_estimate_current_session_progress() { (9, 10), (10, 10), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( StakePallet::estimate_current_session_progress(10).0.unwrap(), Permill::from_percent(10) @@ -1905,8 +1879,7 @@ fn should_estimate_next_session_rotation() { (9, 10), (10, 10), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(StakePallet::estimate_next_session_rotation(10).0.unwrap(), 100); assert_eq!(StakePallet::estimate_next_session_rotation(20).0.unwrap(), 100); assert_eq!(StakePallet::estimate_next_session_rotation(30).0.unwrap(), 100); @@ -1944,8 +1917,7 @@ fn should_end_session_when_appropriate() { (9, 10), (10, 10), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert!(!StakePallet::should_end_session(10)); assert!(!StakePallet::should_end_session(20)); assert!(!StakePallet::should_end_session(30)); @@ -1959,8 +1931,7 @@ fn set_max_selected_candidates_safe_guards() { ExtBuilder::default() .with_balances(vec![(1, 10)]) .with_collators(vec![(1, 10)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_noop!( StakePallet::set_max_selected_candidates( RuntimeOrigin::root(), @@ -2007,8 +1978,7 @@ fn set_max_selected_candidates_total_stake() { (17, 7, 27), (18, 8, 28), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( StakePallet::total_collator_stake(), TotalStake { @@ -2060,8 +2030,7 @@ fn update_inflation() { ExtBuilder::default() .with_balances(vec![(1, 10)]) .with_collators(vec![(1, 10)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { let mut invalid_inflation = InflationInfo { collator: StakingInfo { max_rate: Perquintill::one(), @@ -2124,8 +2093,7 @@ fn unlock_unstaked() { .with_balances(vec![(1, 10), (2, 100)]) .with_collators(vec![(1, 10)]) .with_delegators(vec![(2, 1, 100)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(StakePallet::leave_delegators(RuntimeOrigin::signed(2))); let mut unstaking: BoundedBTreeMap, ::MaxUnstakeRequests> = BoundedBTreeMap::new(); @@ -2182,8 +2150,7 @@ fn unlock_unstaked() { .with_balances(vec![(1, 10), (2, 100)]) .with_collators(vec![(1, 10)]) .with_delegators(vec![(2, 1, 10)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(StakePallet::leave_delegators(RuntimeOrigin::signed(2))); let mut unstaking: BoundedBTreeMap, ::MaxUnstakeRequests> = BoundedBTreeMap::new(); @@ -2242,8 +2209,7 @@ fn unlock_unstaked() { .with_balances(vec![(1, 10), (2, 100)]) .with_collators(vec![(1, 10)]) .with_delegators(vec![(2, 1, 100)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_ok!(StakePallet::leave_delegators(RuntimeOrigin::signed(2))); let mut unstaking: BoundedBTreeMap, ::MaxUnstakeRequests> = BoundedBTreeMap::new(); @@ -2304,8 +2270,7 @@ fn unlock_unstaked() { .with_balances(vec![(1, 200), (2, 200)]) .with_collators(vec![(1, 200)]) .with_delegators(vec![(2, 1, 200)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // should be able to decrease more often than MaxUnstakeRequests because it's // the same block and thus unstaking is increased at block 3 instead of having // multiple entries for the same block @@ -2433,8 +2398,7 @@ fn kick_candidate_with_full_unstaking() { ExtBuilder::default() .with_balances(vec![(1, 200), (2, 200), (3, 300)]) .with_collators(vec![(1, 200), (2, 200), (3, 200)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { let max_unstake_reqs: usize = ::MaxUnstakeRequests::get() .saturating_sub(1) .saturated_into(); @@ -2471,8 +2435,7 @@ fn kick_delegator_with_full_unstaking() { .with_balances(vec![(1, 200), (2, 200), (3, 200), (4, 200), (5, 420), (6, 200)]) .with_collators(vec![(1, 200)]) .with_delegators(vec![(2, 1, 200), (3, 1, 200), (4, 1, 200), (5, 1, 200)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { let max_unstake_reqs: usize = ::MaxUnstakeRequests::get() .saturating_sub(1) .saturated_into(); @@ -2512,8 +2475,7 @@ fn candidate_leaves() { .with_balances(balances) .with_collators(vec![(1, 100), (2, 100)]) .with_delegators(vec![(12, 1, 100), (13, 1, 10)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( StakePallet::top_candidates() .into_iter() @@ -2669,8 +2631,7 @@ fn adjust_reward_rates() { .with_collators(vec![(1, 10_000_000 * DECIMALS)]) .with_delegators(vec![(2, 1, 40_000_000 * DECIMALS)]) .with_inflation(10, 10, 40, 8, 5) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { let inflation_0 = StakePallet::inflation_config(); let num_of_years = 3 * ::BLOCKS_PER_YEAR; // 1 authors every block @@ -2751,8 +2712,7 @@ fn increase_max_candidate_stake() { ExtBuilder::default() .with_balances(vec![(1, 200_000_000 * DECIMALS)]) .with_collators(vec![(1, max_stake)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(StakePallet::max_candidate_stake(), max_stake); assert_noop!( StakePallet::candidate_stake_more(RuntimeOrigin::signed(1), 1), @@ -2779,8 +2739,7 @@ fn decrease_max_candidate_stake() { .with_balances(vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)]) .with_collators(vec![(1, 100), (2, 90), (3, 40)]) .with_delegators(vec![(4, 2, 10), (5, 3, 20)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(StakePallet::selected_candidates().into_inner(), vec![1, 2]); assert_eq!( StakePallet::top_candidates(), @@ -2839,8 +2798,7 @@ fn exceed_delegations_per_round() { .with_balances(vec![(1, 100), (2, 100)]) .with_collators(vec![(1, 100)]) .with_delegators(vec![(2, 1, 100)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // leave and re-join to set counter to 2 (= MaxDelegationsPerRound) assert_ok!(StakePallet::leave_delegators(RuntimeOrigin::signed(2))); assert_ok!(StakePallet::join_delegators(RuntimeOrigin::signed(2), 1, 100)); @@ -2888,8 +2846,7 @@ fn force_remove_candidate() { .with_balances(vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100), (6, 100)]) .with_collators(vec![(1, 100), (2, 100), (3, 100)]) .with_delegators(vec![(4, 1, 50), (5, 1, 50)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(CandidatePool::::count(), 3); assert_ok!(StakePallet::join_delegators(RuntimeOrigin::signed(6), 2, 50)); assert_eq!(StakePallet::selected_candidates().into_inner(), vec![1, 2]); @@ -2963,8 +2920,7 @@ fn prioritize_collators() { (7, 200), ]) .with_collators(vec![(2, 100), (3, 100)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( StakePallet::top_candidates(), OrderedSet::from_sorted_set( @@ -3150,8 +3106,7 @@ fn prioritize_delegators() { ]) .with_collators(vec![(1, 100), (2, 100), (3, 100)]) .with_delegators(vec![(4, 2, 100), (7, 2, 100), (6, 2, 100)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(StakePallet::selected_candidates().into_inner(), vec![2, 1]); assert_eq!( StakePallet::candidate_pool(2).unwrap().delegators, @@ -3246,8 +3201,7 @@ fn authorities_per_round() { (11, 100 * stake), ]) .with_collators(vec![(1, stake), (2, stake), (3, stake), (4, stake)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(StakePallet::selected_candidates().into_inner(), vec![1, 2]); // reward 1 once per round let authors: Vec> = (0u64..=100) @@ -3291,8 +3245,7 @@ fn force_new_round() { ExtBuilder::default() .with_balances(vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100), (6, 100)]) .with_collators(vec![(1, 100), (2, 100), (3, 100), (4, 100)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { let mut round = RoundInfo { current: 0, first: 0, @@ -3370,8 +3323,7 @@ fn replace_lowest_delegator() { .with_balances(vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100), (6, 100)]) .with_collators(vec![(1, 100)]) .with_delegators(vec![(2, 1, 51), (3, 1, 51), (4, 1, 51), (5, 1, 50)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( StakePallet::candidate_pool(1).unwrap().delegators.len() as u32, ::MaxDelegatorsPerCollator::get() @@ -3413,8 +3365,7 @@ fn network_reward_multiple_blocks() { ExtBuilder::default() .with_balances(collators.clone()) .with_collators(collators) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!(max_stake, StakePallet::max_candidate_stake()); let total_collator_stake = max_stake.saturating_mul(::MinCollators::get().into()); assert_eq!(total_collator_stake, StakePallet::total_collator_stake().collators); @@ -3486,8 +3437,7 @@ fn network_reward_increase_max_candidate_stake() { ExtBuilder::default() .with_balances(collators.clone()) .with_collators(collators) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { let network_reward_start = ::NetworkRewardStart::get(); let total_issuance = ::Currency::total_issuance(); System::set_block_number(network_reward_start); @@ -3527,8 +3477,7 @@ fn network_reward_increase_max_collator_count() { ExtBuilder::default() .with_balances(collators.clone()) .with_collators(collators) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { let network_reward_start = ::NetworkRewardStart::get(); let total_issuance = ::Currency::total_issuance(); System::set_block_number(network_reward_start); @@ -3563,8 +3512,7 @@ fn update_total_stake_collators_stay() { .with_balances(vec![(1, 200), (2, 200), (3, 200), (4, 200)]) .with_collators(vec![(1, 100), (2, 50)]) .with_delegators(vec![(3, 1, 100), (4, 2, 50)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( StakePallet::total_collator_stake(), TotalStake { @@ -3623,8 +3571,7 @@ fn update_total_stake_displace_collators() { ]) .with_collators(vec![(1, 10), (2, 20), (3, 30), (4, 40)]) .with_delegators(vec![(5, 1, 50), (6, 2, 50), (7, 3, 55), (8, 4, 55)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( StakePallet::total_collator_stake(), TotalStake { @@ -3672,8 +3619,7 @@ fn update_total_stake_new_collators() { .with_balances(vec![(1, 100), (2, 100), (3, 100), (4, 100)]) .with_collators(vec![(1, 100)]) .with_delegators(vec![(4, 1, 100)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( StakePallet::total_collator_stake(), TotalStake { @@ -3724,8 +3670,7 @@ fn update_total_stake_no_collator_changes() { ]) .with_collators(vec![(1, 10), (2, 20), (3, 30), (4, 40)]) .with_delegators(vec![(5, 1, 50), (6, 2, 50), (7, 3, 55), (8, 4, 55)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { assert_eq!( StakePallet::total_collator_stake(), TotalStake { @@ -3774,8 +3719,7 @@ fn rewards_candidate_stake_more() { .with_balances(vec![(1, 2 * DECIMALS), (2, DECIMALS), (3, DECIMALS)]) .with_collators(vec![(1, DECIMALS)]) .with_delegators(vec![(2, 1, DECIMALS), (3, 1, DECIMALS)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // note once to set counter to 1 StakePallet::note_author(1); assert_eq!(StakePallet::blocks_authored(1), 1); @@ -3812,8 +3756,7 @@ fn rewards_candidate_stake_less() { .with_balances(vec![(1, 2 * DECIMALS), (2, DECIMALS), (3, DECIMALS)]) .with_collators(vec![(1, 2 * DECIMALS)]) .with_delegators(vec![(2, 1, DECIMALS), (3, 1, DECIMALS)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // note once to set counter to 1 StakePallet::note_author(1); assert_eq!(StakePallet::blocks_authored(1), 1); @@ -3856,8 +3799,7 @@ fn rewards_candidate_leave_network() { ]) .with_collators(vec![(1, 2 * DECIMALS), (4, DECIMALS), (5, DECIMALS)]) .with_delegators(vec![(2, 1, DECIMALS), (3, 1, DECIMALS)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // init does not increment rewards assert_ok!(StakePallet::init_leave_candidates(RuntimeOrigin::signed(1))); @@ -3924,8 +3866,7 @@ fn rewards_force_remove_candidate() { ]) .with_collators(vec![(1, DECIMALS), (4, DECIMALS), (5, DECIMALS)]) .with_delegators(vec![(2, 1, DECIMALS), (3, 1, DECIMALS)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // init does not increment rewards StakePallet::note_author(1); StakePallet::note_author(2); @@ -3969,8 +3910,7 @@ fn blocks_rewarded_join_delegators() { ExtBuilder::default() .with_balances(vec![(1, 100), (2, 100)]) .with_collators(vec![(1, 100)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // note once to set counter to 1 StakePallet::note_author(1); assert_eq!(StakePallet::blocks_authored(1), 1); @@ -3988,8 +3928,7 @@ fn rewards_delegator_stake_more() { .with_balances(vec![(1, DECIMALS), (2, DECIMALS), (3, 2 * DECIMALS)]) .with_collators(vec![(1, DECIMALS)]) .with_delegators(vec![(2, 1, DECIMALS), (3, 1, DECIMALS)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // note once to set counter to 1 StakePallet::note_author(1); assert_eq!(StakePallet::blocks_authored(1), 1); @@ -4020,8 +3959,7 @@ fn rewards_delegator_stake_less() { .with_balances(vec![(1, DECIMALS), (2, DECIMALS), (3, 2 * DECIMALS)]) .with_collators(vec![(1, DECIMALS)]) .with_delegators(vec![(2, 1, DECIMALS), (3, 1, 2 * DECIMALS)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // note once to set counter to 1 StakePallet::note_author(1); assert_eq!(StakePallet::blocks_authored(1), 1); @@ -4064,8 +4002,7 @@ fn rewards_delegator_replaced() { (4, 1, 2 * DECIMALS), (5, 1, DECIMALS), ]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // note once to set counter to 1 StakePallet::note_author(1); assert_eq!(StakePallet::blocks_authored(1), 1); @@ -4087,8 +4024,7 @@ fn rewards_delegator_leaves() { .with_balances(vec![(1, DECIMALS), (2, DECIMALS), (3, DECIMALS)]) .with_collators(vec![(1, DECIMALS)]) .with_delegators(vec![(2, 1, DECIMALS), (3, 1, DECIMALS)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // note collator once to set their counter to 1 StakePallet::note_author(1); assert_eq!(StakePallet::blocks_authored(1), 1); @@ -4124,8 +4060,7 @@ fn rewards_set_inflation() { ]) .with_collators(vec![(1, DECIMALS), (2, DECIMALS)]) .with_delegators(vec![(3, 1, DECIMALS), (4, 1, DECIMALS), (5, 2, DECIMALS)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // note collators StakePallet::note_author(1); StakePallet::note_author(1); @@ -4159,8 +4094,7 @@ fn rewards_yearly_inflation_adjustment() { ]) .with_collators(vec![(1, DECIMALS), (2, DECIMALS)]) .with_delegators(vec![(3, 1, DECIMALS), (4, 1, DECIMALS), (5, 2, DECIMALS)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // init counter and go to next year StakePallet::note_author(1); StakePallet::note_author(2); @@ -4193,8 +4127,7 @@ fn rewards_incrementing_and_claiming() { .with_balances(vec![(1, DECIMALS), (2, DECIMALS), (3, DECIMALS)]) .with_collators(vec![(1, DECIMALS)]) .with_delegators(vec![(2, 1, DECIMALS), (3, 1, DECIMALS)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { // claiming should not be possible with zero counters (1..=3).for_each(|id| { assert_noop!( @@ -4270,8 +4203,7 @@ fn api_get_unclaimed_staking_rewards() { .with_balances(vec![(1, stake), (2, stake), (3, 100 * stake)]) .with_collators(vec![(1, stake), (3, 2 * stake)]) .with_delegators(vec![(2, 1, stake)]) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { let inflation_config = StakePallet::inflation_config(); // Increment rewards of 1 and 2 @@ -4321,8 +4253,7 @@ fn api_get_staking_rates() { .with_collators(vec![(1, stake), (2, stake)]) .with_delegators(vec![(3, 1, stake)]) .with_inflation(25, 10, 25, 8, ::BLOCKS_PER_YEAR) - .build() - .execute_with(|| { + .build_and_execute_with_sanity_tests(|| { let mut rates = StakingRates { collator_staking_rate: Perquintill::from_percent(50), collator_reward_rate: Perquintill::from_percent(5), From 5507a093de001abe9d78d30d70ef599e4ca34261 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 4 May 2023 15:28:22 +0200 Subject: [PATCH 19/40] staking pallet --- pallets/parachain-staking/src/lib.rs | 60 +++++--- pallets/parachain-staking/src/tests.rs | 191 +++++++++++++++---------- 2 files changed, 156 insertions(+), 95 deletions(-) diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index 961752dd1..9a0d8782f 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -139,6 +139,7 @@ pub mod pallet { use super::*; pub use crate::inflation::{InflationInfo, RewardRate, StakingInfo}; + use core::cmp::Ordering; use frame_support::{ assert_ok, pallet_prelude::*, @@ -1799,7 +1800,19 @@ pub mod pallet { .delegators .iter() .try_for_each(|delegator_stake| -> DispatchResult { - Self::get_delegation_counter(&delegator_stake.owner)?; + let last_delegation = LastDelegation::::get(&delegator_stake.owner); + let round = Round::::get(); + let counter = if last_delegation.round < round.current { + 0u32 + } else { + last_delegation.counter + }; + + ensure!( + counter <= T::MaxDelegationsPerRound::get(), + DispatchError::Other("Tests") + ); + Ok(()) })?; @@ -1866,14 +1879,6 @@ pub mod pallet { Ok(()) })?; - // each locked fund should have a collator or delegator. - Unstaking::::iter_keys().try_for_each(|who| -> DispatchResult { - let is_candidate = CandidatePool::::contains_key(&who); - let is_delegator = DelegatorState::::contains_key(&who); - ensure!(is_candidate || is_delegator, DispatchError::Other("Tests")); - Ok(()) - })?; - // the total fund has to be the sum over the first [MaxSelectedCandidates] of // [TopCandidates]. @@ -1881,12 +1886,19 @@ pub mod pallet { let total_collator_delegator_stake = TotalCollatorStake::::get(); - let total_fund_from_collators = top_candidates + let mut collator_details: Vec, T::MaxDelegatorsPerCollator>> = + top_candidates + .iter() + .filter_map(|stake| CandidatePool::::get(&stake.owner)) + .collect(); + + collator_details.sort_by(|a, b| b.total.cmp(&a.total)); + + let total_fund_from_top_collators = collator_details .iter() .take(top_n) - .filter(|x| x.amount >= T::MinCollatorStake::get()) - .fold(Zero::zero(), |acc: BalanceOf, stake| { - acc.saturating_add(stake.amount) + .fold(Zero::zero(), |acc: BalanceOf, details| { + acc.saturating_add(details.stake) }); let total_fund = top_candidates @@ -1898,10 +1910,10 @@ pub mod pallet { acc.saturating_add(candidate.total) }); - let delegator_fund = total_fund.saturating_sub(total_fund_from_collators); + let delegator_fund = total_fund.saturating_sub(total_fund_from_top_collators); ensure!( - total_collator_delegator_stake.collators == total_fund_from_collators, + total_collator_delegator_stake.collators == total_fund_from_top_collators, DispatchError::Other("Tests") ); @@ -2058,14 +2070,20 @@ pub mod pallet { } (false, true) => { // candidate pushed out the least staked collator which is now at position - // min(max_selected_top_candidates, top_candidates - 1) in TopCandidates - let old_col_idx = max_selected_candidates.min(top_candidates.len().saturating_sub(1)); + let (drop_self, drop_delegators) = match max_selected_candidates.cmp(&top_candidates.len()) { + // top candidates are not full + Ordering::Greater => (BalanceOf::::zero(), BalanceOf::::zero()), + // top candidates are full. the collator with the lowest stake is at index old_col_idx + _ => { + // we can unwrap here without problems, since we compared + // [max_selected_candidates] with [top_candidates] length, but lets be + // safe. + Self::get_top_candidate_stake_at(&top_candidates, max_selected_candidates) + .unwrap_or((BalanceOf::::zero(), BalanceOf::::zero())) + } + }; // get amount to subtract from TotalCollatorStake - let (drop_self, drop_delegators) = - Self::get_top_candidate_stake_at(&top_candidates, old_col_idx) - // default to zero if candidate DNE, e.g. TopCandidates is not full - .unwrap_or((BalanceOf::::zero(), BalanceOf::::zero())); Self::update_total_stake_by(new_self, new_delegators, drop_self, drop_delegators); } _ => {} diff --git a/pallets/parachain-staking/src/tests.rs b/pallets/parachain-staking/src/tests.rs index d9727547c..3ba58ab7c 100644 --- a/pallets/parachain-staking/src/tests.rs +++ b/pallets/parachain-staking/src/tests.rs @@ -1294,8 +1294,8 @@ fn delegators_bond() { #[test] fn should_leave_delegators() { ExtBuilder::default() - .with_balances(vec![(1, 100), (2, 100)]) - .with_collators(vec![(1, 100)]) + .with_balances(vec![(1, 100), (2, 100), (3, 100)]) + .with_collators(vec![(1, 100), (3, 10)]) .with_delegators(vec![(2, 1, 100)]) .build_and_execute_with_sanity_tests(|| { assert_ok!(StakePallet::leave_delegators(RuntimeOrigin::signed(2))); @@ -1332,8 +1332,16 @@ fn round_transitions() { // round_immediately_jumps_if_current_duration_exceeds_new_blocks_per_round // change from 5 bpr to 3 in block 5 -> 8 should be new round ExtBuilder::default() - .with_balances(vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100), (6, 100)]) - .with_collators(vec![(1, 20)]) + .with_balances(vec![ + (1, 100), + (2, 100), + (3, 100), + (4, 100), + (5, 100), + (6, 100), + (7, 100), + ]) + .with_collators(vec![(1, 20), (7, 10)]) .with_delegators(vec![(2, 1, 10), (3, 1, 10)]) .with_inflation(col_max, col_rewards, d_max, d_rewards, 5) .build_and_execute_with_sanity_tests(|| { @@ -1361,8 +1369,16 @@ fn round_transitions() { // passes // change from 5 bpr to 3 in block 6 -> 8 should be new round ExtBuilder::default() - .with_balances(vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100), (6, 100)]) - .with_collators(vec![(1, 20)]) + .with_balances(vec![ + (1, 100), + (2, 100), + (3, 100), + (4, 100), + (5, 100), + (6, 100), + (7, 100), + ]) + .with_collators(vec![(1, 20), (7, 10)]) .with_delegators(vec![(2, 1, 10), (3, 1, 10)]) .with_inflation(col_max, col_rewards, d_max, d_rewards, 5) .build_and_execute_with_sanity_tests(|| { @@ -1390,8 +1406,16 @@ fn round_transitions() { // round_immediately_jumps_if_current_duration_exceeds_new_blocks_per_round // change from 5 bpr (blocks_per_round) to 3 in block 7 -> 8 should be new round ExtBuilder::default() - .with_balances(vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100), (6, 100)]) - .with_collators(vec![(1, 20)]) + .with_balances(vec![ + (1, 100), + (2, 100), + (3, 100), + (4, 100), + (5, 100), + (6, 100), + (7, 100), + ]) + .with_collators(vec![(1, 20), (7, 10)]) .with_delegators(vec![(2, 1, 10), (3, 1, 10)]) .with_inflation(col_max, col_rewards, d_max, d_rewards, 5) .build_and_execute_with_sanity_tests(|| { @@ -1523,8 +1547,8 @@ fn coinbase_rewards_few_blocks_detailed_check() { fn delegator_should_not_receive_rewards_after_revoking() { // test edge case of 1 delegator ExtBuilder::default() - .with_balances(vec![(1, 10_000_000 * DECIMALS), (2, 10_000_000 * DECIMALS)]) - .with_collators(vec![(1, 10_000_000 * DECIMALS)]) + .with_balances(vec![(1, 10_000_000 * DECIMALS), (2, 10_000_000 * DECIMALS), (3, 100)]) + .with_collators(vec![(1, 10_000_000 * DECIMALS), (3, 10)]) .with_delegators(vec![(2, 1, 10_000_000 * DECIMALS)]) .with_inflation(10, 15, 40, 15, 5) .build_and_execute_with_sanity_tests(|| { @@ -1543,8 +1567,9 @@ fn delegator_should_not_receive_rewards_after_revoking() { (1, 10_000_000 * DECIMALS), (2, 10_000_000 * DECIMALS), (3, 10_000_000 * DECIMALS), + (4, 100), ]) - .with_collators(vec![(1, 10_000_000 * DECIMALS)]) + .with_collators(vec![(1, 10_000_000 * DECIMALS), (4, 10)]) .with_delegators(vec![(2, 1, 10_000_000 * DECIMALS), (3, 1, 10_000_000 * DECIMALS)]) .with_inflation(10, 15, 40, 15, 5) .build_and_execute_with_sanity_tests(|| { @@ -1671,7 +1696,8 @@ fn should_not_reward_delegators_below_min_stake() { .with_collators(vec![(1, 10 * DECIMALS), (2, 10 * DECIMALS)]) .with_delegators(vec![(3, 2, 10 * DECIMALS)]) .with_inflation(10, 15, 40, 15, 5) - .build_and_execute_with_sanity_tests(|| { + .build() + .execute_with(|| { // impossible but lets assume it happened let mut state = StakePallet::candidate_pool(1).expect("CollatorState cannot be missing"); let delegator_stake_below_min = ::MinDelegatorStake::get() - 1; @@ -1929,8 +1955,8 @@ fn should_end_session_when_appropriate() { #[test] fn set_max_selected_candidates_safe_guards() { ExtBuilder::default() - .with_balances(vec![(1, 10)]) - .with_collators(vec![(1, 10)]) + .with_balances(vec![(1, 10), (2, 100)]) + .with_collators(vec![(1, 10), (2, 10)]) .build_and_execute_with_sanity_tests(|| { assert_noop!( StakePallet::set_max_selected_candidates( @@ -2028,8 +2054,8 @@ fn set_max_selected_candidates_total_stake() { #[test] fn update_inflation() { ExtBuilder::default() - .with_balances(vec![(1, 10)]) - .with_collators(vec![(1, 10)]) + .with_balances(vec![(1, 10), (2, 100)]) + .with_collators(vec![(1, 10), (2, 10)]) .build_and_execute_with_sanity_tests(|| { let mut invalid_inflation = InflationInfo { collator: StakingInfo { @@ -2090,8 +2116,8 @@ fn unlock_unstaked() { // should remove first entry in unstaking BoundedBTreeMap when staking in block // 2 should still have 100 locked until unlocking ExtBuilder::default() - .with_balances(vec![(1, 10), (2, 100)]) - .with_collators(vec![(1, 10)]) + .with_balances(vec![(1, 10), (2, 100), (3, 100)]) + .with_collators(vec![(1, 10), (3, 10)]) .with_delegators(vec![(2, 1, 100)]) .build_and_execute_with_sanity_tests(|| { assert_ok!(StakePallet::leave_delegators(RuntimeOrigin::signed(2))); @@ -2147,8 +2173,8 @@ fn unlock_unstaked() { // should remove first entry in unstaking BoundedBTreeMap when staking in block // 2 should still have 90 locked until unlocking in block 4 ExtBuilder::default() - .with_balances(vec![(1, 10), (2, 100)]) - .with_collators(vec![(1, 10)]) + .with_balances(vec![(1, 10), (2, 100), (10, 100)]) + .with_collators(vec![(1, 10), (10, 10)]) .with_delegators(vec![(2, 1, 10)]) .build_and_execute_with_sanity_tests(|| { assert_ok!(StakePallet::leave_delegators(RuntimeOrigin::signed(2))); @@ -2206,8 +2232,8 @@ fn unlock_unstaked() { // should have 100 locked until unlocking in block 3, then 10 // should have 10 locked until further unlocking in block 4 ExtBuilder::default() - .with_balances(vec![(1, 10), (2, 100)]) - .with_collators(vec![(1, 10)]) + .with_balances(vec![(1, 10), (2, 100), (3, 199)]) + .with_collators(vec![(1, 10), (3, 10)]) .with_delegators(vec![(2, 1, 100)]) .build_and_execute_with_sanity_tests(|| { assert_ok!(StakePallet::leave_delegators(RuntimeOrigin::signed(2))); @@ -2267,8 +2293,8 @@ fn unlock_unstaked() { // should have 100 locked until unlocking in block 3, then 10 // should have 10 locked until further unlocking in block 4 ExtBuilder::default() - .with_balances(vec![(1, 200), (2, 200)]) - .with_collators(vec![(1, 200)]) + .with_balances(vec![(1, 200), (2, 200), (3, 100)]) + .with_collators(vec![(1, 200), (3, 10)]) .with_delegators(vec![(2, 1, 200)]) .build_and_execute_with_sanity_tests(|| { // should be able to decrease more often than MaxUnstakeRequests because it's @@ -2432,8 +2458,16 @@ fn kick_candidate_with_full_unstaking() { #[test] fn kick_delegator_with_full_unstaking() { ExtBuilder::default() - .with_balances(vec![(1, 200), (2, 200), (3, 200), (4, 200), (5, 420), (6, 200)]) - .with_collators(vec![(1, 200)]) + .with_balances(vec![ + (1, 200), + (2, 200), + (3, 200), + (4, 200), + (5, 420), + (6, 200), + (7, 100), + ]) + .with_collators(vec![(1, 200), (7, 10)]) .with_delegators(vec![(2, 1, 200), (3, 1, 200), (4, 1, 200), (5, 1, 200)]) .build_and_execute_with_sanity_tests(|| { let max_unstake_reqs: usize = ::MaxUnstakeRequests::get() @@ -2627,8 +2661,8 @@ fn candidate_leaves() { #[test] fn adjust_reward_rates() { ExtBuilder::default() - .with_balances(vec![(1, 10_000_000 * DECIMALS), (2, 90_000_000 * DECIMALS)]) - .with_collators(vec![(1, 10_000_000 * DECIMALS)]) + .with_balances(vec![(1, 10_000_000 * DECIMALS), (2, 90_000_000 * DECIMALS), (3, 100)]) + .with_collators(vec![(1, 10_000_000 * DECIMALS), (3, 10)]) .with_delegators(vec![(2, 1, 40_000_000 * DECIMALS)]) .with_inflation(10, 10, 40, 8, 5) .build_and_execute_with_sanity_tests(|| { @@ -2710,8 +2744,8 @@ fn adjust_reward_rates() { fn increase_max_candidate_stake() { let max_stake = 160_000_000 * DECIMALS; ExtBuilder::default() - .with_balances(vec![(1, 200_000_000 * DECIMALS)]) - .with_collators(vec![(1, max_stake)]) + .with_balances(vec![(1, 200_000_000 * DECIMALS), (3, 100)]) + .with_collators(vec![(1, max_stake), (3, 10)]) .build_and_execute_with_sanity_tests(|| { assert_eq!(StakePallet::max_candidate_stake(), max_stake); assert_noop!( @@ -2754,9 +2788,9 @@ fn decrease_max_candidate_stake() { ) ); - assert_ok!(StakePallet::set_max_candidate_stake(RuntimeOrigin::root(), 50)); - assert_eq!(StakePallet::max_candidate_stake(), 50); - assert_eq!(last_event(), StakeEvent::MaxCandidateStakeChanged(50)); + assert_ok!(StakePallet::set_max_candidate_stake(RuntimeOrigin::root(), 100)); + assert_eq!(StakePallet::max_candidate_stake(), 100); + assert_eq!(last_event(), StakeEvent::MaxCandidateStakeChanged(100)); // check collator states, nothing changed assert_eq!( @@ -2795,8 +2829,8 @@ fn decrease_max_candidate_stake() { #[test] fn exceed_delegations_per_round() { ExtBuilder::default() - .with_balances(vec![(1, 100), (2, 100)]) - .with_collators(vec![(1, 100)]) + .with_balances(vec![(1, 100), (2, 100), (3, 100)]) + .with_collators(vec![(1, 100), (3, 10)]) .with_delegators(vec![(2, 1, 100)]) .build_and_execute_with_sanity_tests(|| { // leave and re-join to set counter to 2 (= MaxDelegationsPerRound) @@ -3320,8 +3354,16 @@ fn force_new_round() { #[test] fn replace_lowest_delegator() { ExtBuilder::default() - .with_balances(vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100), (6, 100)]) - .with_collators(vec![(1, 100)]) + .with_balances(vec![ + (1, 100), + (2, 100), + (3, 100), + (4, 100), + (5, 100), + (6, 100), + (7, 100), + ]) + .with_collators(vec![(1, 100), (7, 10)]) .with_delegators(vec![(2, 1, 51), (3, 1, 51), (4, 1, 51), (5, 1, 50)]) .build_and_execute_with_sanity_tests(|| { assert_eq!( @@ -3581,18 +3623,18 @@ fn update_total_stake_displace_collators() { ); // 4 is pushed out by staking less - assert_ok!(StakePallet::candidate_stake_less(RuntimeOrigin::signed(4), 30)); + assert_ok!(StakePallet::candidate_stake_less(RuntimeOrigin::signed(4), 30)); // vec![(1, 10), (2, 20), (3, 30), (4, 10)] assert_eq!( - StakePallet::total_collator_stake(), + StakePallet::total_collator_stake(), // collators: 50, delegators 105 TotalStake { collators: 50, delegators: 105 } ); - assert_ok!(StakePallet::delegator_stake_less(RuntimeOrigin::signed(8), 45)); + assert_ok!(StakePallet::delegator_stake_less(RuntimeOrigin::signed(8), 45)); // vec![(5, 1, 50), (6, 2, 50), (7, 3, 55), (8, 4, 10)] // 3 is pushed out by delegator staking less - assert_ok!(StakePallet::delegator_stake_less(RuntimeOrigin::signed(7), 45)); + assert_ok!(StakePallet::delegator_stake_less(RuntimeOrigin::signed(7), 45)); // vec![(5, 1, 50), (6, 2, 50), (7, 3, 10), (8, 4, 10)] assert_eq!( StakePallet::total_collator_stake(), TotalStake { @@ -3716,13 +3758,13 @@ fn update_total_stake_no_collator_changes() { #[test] fn rewards_candidate_stake_more() { ExtBuilder::default() - .with_balances(vec![(1, 2 * DECIMALS), (2, DECIMALS), (3, DECIMALS)]) - .with_collators(vec![(1, DECIMALS)]) + .with_balances(vec![(1, 2 * DECIMALS), (2, DECIMALS), (3, DECIMALS), (4, 100)]) + .with_collators(vec![(1, DECIMALS), (4, 10)]) .with_delegators(vec![(2, 1, DECIMALS), (3, 1, DECIMALS)]) .build_and_execute_with_sanity_tests(|| { // note once to set counter to 1 StakePallet::note_author(1); - assert_eq!(StakePallet::blocks_authored(1), 1); + assert_eq!(StakePallet::blocks_authored(1), 2); assert!(StakePallet::blocks_authored(2).is_zero()); assert!(StakePallet::blocks_authored(3).is_zero()); (1..=3).for_each(|id| { @@ -3753,13 +3795,13 @@ fn rewards_candidate_stake_more() { #[test] fn rewards_candidate_stake_less() { ExtBuilder::default() - .with_balances(vec![(1, 2 * DECIMALS), (2, DECIMALS), (3, DECIMALS)]) - .with_collators(vec![(1, 2 * DECIMALS)]) + .with_balances(vec![(1, 2 * DECIMALS), (2, DECIMALS), (3, DECIMALS), (4, 100)]) + .with_collators(vec![(1, 2 * DECIMALS), (4, 10)]) .with_delegators(vec![(2, 1, DECIMALS), (3, 1, DECIMALS)]) .build_and_execute_with_sanity_tests(|| { // note once to set counter to 1 StakePallet::note_author(1); - assert_eq!(StakePallet::blocks_authored(1), 1); + assert_eq!(StakePallet::blocks_authored(1), 2); assert!(StakePallet::blocks_authored(2).is_zero()); assert!(StakePallet::blocks_authored(3).is_zero()); (1..=3).for_each(|id| { @@ -3908,12 +3950,12 @@ fn rewards_force_remove_candidate() { #[test] fn blocks_rewarded_join_delegators() { ExtBuilder::default() - .with_balances(vec![(1, 100), (2, 100)]) - .with_collators(vec![(1, 100)]) + .with_balances(vec![(1, 1000), (2, 100), (3, 100)]) + .with_collators(vec![(1, 1000), (3, 10)]) .build_and_execute_with_sanity_tests(|| { // note once to set counter to 1 StakePallet::note_author(1); - assert_eq!(StakePallet::blocks_authored(1), 1); + assert_eq!(StakePallet::blocks_authored(1), 2); assert!(StakePallet::blocks_rewarded(1).is_zero()); assert_ok!(StakePallet::join_delegators(RuntimeOrigin::signed(2), 1, 100)); // delegator's rewarded counter should equal of collator's authored counter upon @@ -3925,13 +3967,13 @@ fn blocks_rewarded_join_delegators() { #[test] fn rewards_delegator_stake_more() { ExtBuilder::default() - .with_balances(vec![(1, DECIMALS), (2, DECIMALS), (3, 2 * DECIMALS)]) - .with_collators(vec![(1, DECIMALS)]) + .with_balances(vec![(1, DECIMALS), (2, DECIMALS), (3, 2 * DECIMALS), (4, 100)]) + .with_collators(vec![(1, DECIMALS), (4, 10)]) .with_delegators(vec![(2, 1, DECIMALS), (3, 1, DECIMALS)]) .build_and_execute_with_sanity_tests(|| { // note once to set counter to 1 StakePallet::note_author(1); - assert_eq!(StakePallet::blocks_authored(1), 1); + assert_eq!(StakePallet::blocks_authored(1), 2); assert!(StakePallet::blocks_rewarded(2).is_zero()); assert!(StakePallet::blocks_rewarded(3).is_zero()); (1..=3).for_each(|id| { @@ -3941,14 +3983,14 @@ fn rewards_delegator_stake_more() { // stake less to trigger reward incrementing just for 3 assert_ok!(StakePallet::delegator_stake_more(RuntimeOrigin::signed(3), DECIMALS)); // 1 should still have counter 1 but no rewards - assert_eq!(StakePallet::blocks_authored(1), 1); + assert_eq!(StakePallet::blocks_authored(1), 2); assert!(StakePallet::blocks_rewarded(1).is_zero()); assert!(StakePallet::rewards(1).is_zero()); // 2 should still have neither rewards nor counter assert!(StakePallet::blocks_rewarded(2).is_zero()); assert!(StakePallet::rewards(2).is_zero()); // 3 should have rewards and the same counter as 1 - assert_eq!(StakePallet::blocks_rewarded(3), 1); + assert_eq!(StakePallet::blocks_rewarded(3), 2); assert!(!StakePallet::rewards(3).is_zero()); }); } @@ -3956,13 +3998,13 @@ fn rewards_delegator_stake_more() { #[test] fn rewards_delegator_stake_less() { ExtBuilder::default() - .with_balances(vec![(1, DECIMALS), (2, DECIMALS), (3, 2 * DECIMALS)]) - .with_collators(vec![(1, DECIMALS)]) + .with_balances(vec![(1, DECIMALS), (2, DECIMALS), (3, 2 * DECIMALS), (7, 100)]) + .with_collators(vec![(1, DECIMALS), (7, 10)]) .with_delegators(vec![(2, 1, DECIMALS), (3, 1, 2 * DECIMALS)]) .build_and_execute_with_sanity_tests(|| { // note once to set counter to 1 StakePallet::note_author(1); - assert_eq!(StakePallet::blocks_authored(1), 1); + assert_eq!(StakePallet::blocks_authored(1), 2); assert!(StakePallet::blocks_rewarded(2).is_zero()); assert!(StakePallet::blocks_rewarded(3).is_zero()); (1..=3).for_each(|id| { @@ -3972,14 +4014,14 @@ fn rewards_delegator_stake_less() { // stake less to trigger reward incrementing just for 3 assert_ok!(StakePallet::delegator_stake_less(RuntimeOrigin::signed(3), DECIMALS)); // 1 should still have counter 1 but no rewards - assert_eq!(StakePallet::blocks_authored(1), 1); + assert_eq!(StakePallet::blocks_authored(1), 2); assert!(StakePallet::blocks_rewarded(1).is_zero()); assert!(StakePallet::rewards(1).is_zero()); // 2 should still have neither rewards nor counter assert!(StakePallet::blocks_rewarded(2).is_zero()); assert!(StakePallet::rewards(2).is_zero()); // 3 should have rewards and the same counter as 1 - assert_eq!(StakePallet::blocks_rewarded(3), 1); + assert_eq!(StakePallet::blocks_rewarded(3), 2); assert!(!StakePallet::rewards(3).is_zero()); }); } @@ -3994,8 +4036,9 @@ fn rewards_delegator_replaced() { (4, 2 * DECIMALS), (5, 2 * DECIMALS), (6, 2 * DECIMALS), + (7, 100), ]) - .with_collators(vec![(1, 2 * DECIMALS)]) + .with_collators(vec![(1, 2 * DECIMALS), (7, 10)]) .with_delegators(vec![ (2, 1, 2 * DECIMALS), (3, 1, 2 * DECIMALS), @@ -4005,29 +4048,29 @@ fn rewards_delegator_replaced() { .build_and_execute_with_sanity_tests(|| { // note once to set counter to 1 StakePallet::note_author(1); - assert_eq!(StakePallet::blocks_authored(1), 1); + assert_eq!(StakePallet::blocks_authored(1), 2); // 6 kicks 5 assert_ok!(StakePallet::join_delegators(RuntimeOrigin::signed(6), 1, 2 * DECIMALS)); // 5 should have rewards and counter updated assert!(!StakePallet::rewards(5).is_zero()); - assert_eq!(StakePallet::blocks_rewarded(5), 1); + assert_eq!(StakePallet::blocks_rewarded(5), 2); // 6 should not have rewards but same counter as former collator assert!(StakePallet::rewards(6).is_zero()); - assert_eq!(StakePallet::blocks_rewarded(6), 1); + assert_eq!(StakePallet::blocks_rewarded(6), 2); }); } #[test] fn rewards_delegator_leaves() { ExtBuilder::default() - .with_balances(vec![(1, DECIMALS), (2, DECIMALS), (3, DECIMALS)]) - .with_collators(vec![(1, DECIMALS)]) + .with_balances(vec![(1, DECIMALS), (2, DECIMALS), (3, DECIMALS), (4, 100)]) + .with_collators(vec![(1, DECIMALS), (4, 10)]) .with_delegators(vec![(2, 1, DECIMALS), (3, 1, DECIMALS)]) .build_and_execute_with_sanity_tests(|| { // note collator once to set their counter to 1 StakePallet::note_author(1); - assert_eq!(StakePallet::blocks_authored(1), 1); + assert_eq!(StakePallet::blocks_authored(1), 2); assert!(StakePallet::blocks_rewarded(2).is_zero()); assert!(StakePallet::blocks_rewarded(3).is_zero()); (1..=3).for_each(|id| { @@ -4124,12 +4167,12 @@ fn rewards_yearly_inflation_adjustment() { #[test] fn rewards_incrementing_and_claiming() { ExtBuilder::default() - .with_balances(vec![(1, DECIMALS), (2, DECIMALS), (3, DECIMALS)]) - .with_collators(vec![(1, DECIMALS)]) + .with_balances(vec![(1, DECIMALS), (2, DECIMALS), (3, DECIMALS), (4, 100)]) + .with_collators(vec![(1, DECIMALS), (4, 10)]) .with_delegators(vec![(2, 1, DECIMALS), (3, 1, DECIMALS)]) .build_and_execute_with_sanity_tests(|| { // claiming should not be possible with zero counters - (1..=3).for_each(|id| { + (1..=4).for_each(|id| { assert_noop!( StakePallet::claim_rewards(RuntimeOrigin::signed(id)), Error::::RewardsNotFound, @@ -4138,11 +4181,11 @@ fn rewards_incrementing_and_claiming() { // note once to set counter to 1 StakePallet::note_author(1); - assert_eq!(StakePallet::blocks_authored(1), 1); + assert_eq!(StakePallet::blocks_authored(1), 2); assert!(StakePallet::blocks_rewarded(2).is_zero()); // claiming should not be possible before incrementing rewards - (1..=3).for_each(|id| { + (1..=4).for_each(|id| { assert_noop!( StakePallet::claim_rewards(RuntimeOrigin::signed(id)), Error::::RewardsNotFound @@ -4151,7 +4194,7 @@ fn rewards_incrementing_and_claiming() { // increment rewards for 2 and match counter to collator assert_ok!(StakePallet::increment_delegator_rewards(RuntimeOrigin::signed(2))); - assert_eq!(StakePallet::blocks_rewarded(2), 1); + assert_eq!(StakePallet::blocks_rewarded(2), 2); let rewards_2 = StakePallet::rewards(2); assert!(!rewards_2.is_zero()); assert!(StakePallet::blocks_rewarded(3).is_zero()); @@ -4177,7 +4220,7 @@ fn rewards_incrementing_and_claiming() { // incrementing again should not change anything because collator has not // authored blocks since last inc assert_ok!(StakePallet::increment_delegator_rewards(RuntimeOrigin::signed(2))); - assert_eq!(StakePallet::blocks_rewarded(2), 1); + assert_eq!(StakePallet::blocks_rewarded(2), 2); // claim for 2 to move rewards into balance assert_ok!(StakePallet::claim_rewards(RuntimeOrigin::signed(2))); assert!(Balances::free_balance(2) > DECIMALS); From be07f97a17a6c0199d1fefe7cf38311693d39ae0 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 4 May 2023 15:31:57 +0200 Subject: [PATCH 20/40] fmt --- pallets/delegation/src/lib.rs | 2 +- pallets/pallet-did-lookup/src/lib.rs | 4 +--- pallets/parachain-staking/src/inflation.rs | 2 -- pallets/parachain-staking/src/lib.rs | 2 -- runtime-api/did/src/lib.rs | 1 - 5 files changed, 2 insertions(+), 9 deletions(-) diff --git a/pallets/delegation/src/lib.rs b/pallets/delegation/src/lib.rs index a9f46fee7..8092cc9fc 100644 --- a/pallets/delegation/src/lib.rs +++ b/pallets/delegation/src/lib.rs @@ -418,7 +418,7 @@ pub mod pallet { Self::calculate_delegation_creation_hash(&delegation_id, &hierarchy_root_id, &parent_id, &permissions); // Verify that the hash root signature is correct. - DelegationSignatureVerificationOf::::verify(&delegate, &hash_root.encode(), &delegate_signature) // !TODO! + DelegationSignatureVerificationOf::::verify(&delegate, &hash_root.encode(), &delegate_signature) .map_err(|err| match err { SignatureVerificationError::SignerInformationNotPresent => Error::::DelegateNotFound, SignatureVerificationError::SignatureInvalid => Error::::InvalidDelegateSignature, diff --git a/pallets/pallet-did-lookup/src/lib.rs b/pallets/pallet-did-lookup/src/lib.rs index ceee8c561..95379ad35 100644 --- a/pallets/pallet-did-lookup/src/lib.rs +++ b/pallets/pallet-did-lookup/src/lib.rs @@ -234,7 +234,7 @@ pub mod pallet { pub fn associate_account( origin: OriginFor, req: AssociateAccountRequest, - expiration: ::BlockNumber, // !TODO! why expiration + expiration: ::BlockNumber, ) -> DispatchResult { let source = ::EnsureOrigin::ensure_origin(origin)?; let did_identifier = source.subject(); @@ -277,8 +277,6 @@ pub mod pallet { #[pallet::call_index(1)] #[pallet::weight(::WeightInfo::associate_sender())] pub fn associate_sender(origin: OriginFor) -> DispatchResult { - // !TODO! difference between associate_sender und associate_account. difference - // between assert! und ensure! let source = ::EnsureOrigin::ensure_origin(origin)?; ensure!( diff --git a/pallets/parachain-staking/src/inflation.rs b/pallets/parachain-staking/src/inflation.rs index 542a86135..d3ab9913d 100644 --- a/pallets/parachain-staking/src/inflation.rs +++ b/pallets/parachain-staking/src/inflation.rs @@ -134,8 +134,6 @@ impl InflationInfo { /// Check whether the annual reward rate is approx. the per_block reward /// rate multiplied with the number of blocks per year pub fn is_valid(&self, blocks_per_year: u64) -> bool { - // !TODO! why only bigger? -> blocks_per_year has to get bigger -> more blocks - // in less seconds. self.collator.reward_rate.annual >= Perquintill::from_parts( self.collator diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index 9a0d8782f..6c406d6e6 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -1659,7 +1659,6 @@ pub mod pallet { #[pallet::weight(::WeightInfo::claim_rewards())] pub fn claim_rewards(origin: OriginFor) -> DispatchResult { let target = ensure_signed(origin)?; - // !TODO! not update before? // reset rewards let rewards = Rewards::::take(&target); @@ -1746,7 +1745,6 @@ pub mod pallet { // delegator reward rate should be 6% in 2nd year and 0% afterwards let d_reward_rate = if year == T::BlockNumber::one() { - // !TODO! set delegation to zero? Perquintill::from_percent(6) } else { Perquintill::zero() diff --git a/runtime-api/did/src/lib.rs b/runtime-api/did/src/lib.rs index f3b4aa8f2..291e77960 100644 --- a/runtime-api/did/src/lib.rs +++ b/runtime-api/did/src/lib.rs @@ -30,7 +30,6 @@ pub use service_endpoint::*; #[derive(Encode, Decode, TypeInfo, Eq, PartialEq)] pub struct DidLinkedInfo< - // !TODO! sicherstellen. Json für DID document. DidIdentifier, AccountId, LinkableAccountId, From b29ef0217bc2e194aeb0abe4d55aaf8fd229d71f Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 4 May 2023 15:33:34 +0200 Subject: [PATCH 21/40] fmt --- pallets/attestation/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/attestation/src/lib.rs b/pallets/attestation/src/lib.rs index 278df6724..86118af92 100644 --- a/pallets/attestation/src/lib.rs +++ b/pallets/attestation/src/lib.rs @@ -262,7 +262,7 @@ pub mod pallet { ); // Check for validity of the delegation node if specified. - authorization // !TODO! + authorization .as_ref() .map(|ac| ac.can_attest(&who, &ctype_hash, &claim_hash)) .transpose()?; From 0ba13643383d76de4569e142a9f175e7a85e2778 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 4 May 2023 16:21:39 +0200 Subject: [PATCH 22/40] fix wrong test --- pallets/delegation/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/delegation/src/lib.rs b/pallets/delegation/src/lib.rs index 8092cc9fc..0e480e1b0 100644 --- a/pallets/delegation/src/lib.rs +++ b/pallets/delegation/src/lib.rs @@ -1018,7 +1018,7 @@ pub mod pallet { // if a node is revoked, his subtree should be revoked as well. if delegation_details.details.revoked { - let is_subtree_revoked = get_merged_subtree::(delegation_details).iter().map(|child : &DelegationNode| {child.details.revoked }).all(|x| !x); + let is_subtree_revoked = get_merged_subtree::(delegation_details).iter().map(|child : &DelegationNode| {child.details.revoked }).all(|x| x); ensure!(is_subtree_revoked, DispatchError::Other("Test")); } Ok(()) From 0a5dd8c993e239d555e43cf8205fe3dc8881261c Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 4 May 2023 16:24:16 +0200 Subject: [PATCH 23/40] clippy --- pallets/delegation/src/mock.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/delegation/src/mock.rs b/pallets/delegation/src/mock.rs index fde1c39ea..eddc8ca41 100644 --- a/pallets/delegation/src/mock.rs +++ b/pallets/delegation/src/mock.rs @@ -27,7 +27,7 @@ use kilt_support::deposit::Deposit; use crate::{ self as delegation, AccountIdOf, Config, CurrencyOf, DelegationDetails, DelegationHierarchyDetails, DelegationNode, - DelegatorIdOf, Pallet, Permissions, + DelegatorIdOf, Permissions, }; #[cfg(test)] @@ -169,7 +169,7 @@ where #[cfg(test)] pub(crate) mod runtime { - use crate::{BalanceOf, DelegateSignatureTypeOf, DelegationAc, DelegationNodeIdOf}; + use crate::{BalanceOf, DelegateSignatureTypeOf, DelegationAc, DelegationNodeIdOf, Pallet}; use super::*; From da193f8aab3e950890a00b9f01b2ddf7d7dd1828 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 5 May 2023 12:36:56 +0200 Subject: [PATCH 24/40] refactor --- pallets/parachain-staking/src/lib.rs | 31 +++++++--------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index 6c406d6e6..2e606a068 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -1882,43 +1882,28 @@ pub mod pallet { let top_n = MaxSelectedCandidates::::get().saturated_into::(); - let total_collator_delegator_stake = TotalCollatorStake::::get(); + let total_stake = TotalCollatorStake::::get(); - let mut collator_details: Vec, T::MaxDelegatorsPerCollator>> = - top_candidates - .iter() - .filter_map(|stake| CandidatePool::::get(&stake.owner)) - .collect(); - - collator_details.sort_by(|a, b| b.total.cmp(&a.total)); - - let total_fund_from_top_collators = collator_details + let collator_delegator_stake = top_candidates .iter() .take(top_n) .fold(Zero::zero(), |acc: BalanceOf, details| { - acc.saturating_add(details.stake) + acc.saturating_add(details.amount) }); - let total_fund = top_candidates + let collator_stake = top_candidates .iter() .take(top_n) - .filter(|x| x.amount >= T::MinCollatorStake::get()) .filter_map(|stake| CandidatePool::::get(&stake.owner)) .fold(Zero::zero(), |acc: BalanceOf, candidate| { - acc.saturating_add(candidate.total) + acc.saturating_add(candidate.stake) }); - let delegator_fund = total_fund.saturating_sub(total_fund_from_top_collators); + let delegator_state = collator_delegator_stake.saturating_sub(collator_stake); - ensure!( - total_collator_delegator_stake.collators == total_fund_from_top_collators, - DispatchError::Other("Tests") - ); + ensure!(total_stake.collators == collator_stake, DispatchError::Other("Tests")); - ensure!( - total_collator_delegator_stake.delegators == delegator_fund, - DispatchError::Other("Tests") - ); + ensure!(total_stake.delegators == delegator_state, DispatchError::Other("Tests")); Ok(()) } From ecd05bcb4984710042bd85c79ee6fec6e620e9a0 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Mon, 8 May 2023 15:12:30 +0200 Subject: [PATCH 25/40] fix test --- Cargo.lock | 1306 ++++++++++++++++++------------- pallets/delegation/src/lib.rs | 8 +- pallets/delegation/src/tests.rs | 3 +- 3 files changed, 747 insertions(+), 570 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 27664447b..8350b99b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -42,7 +42,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -51,18 +51,18 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b613b8e1e3cf911a086f53f03bf286f52fd7a7258e4fa606f0ef220d39d8877" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "rand_core 0.6.4", ] [[package]] name = "aead" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c192eb8f11fc081b0fe4259ba5af04217d4e0faddd02417310a927911abd7c8" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" dependencies = [ "crypto-common", - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -119,7 +119,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "82e1366e0c69c9f927b1fa5ce2c7bf9eafc8f9268c0b9800729e8b267612447c" dependencies = [ - "aead 0.5.1", + "aead 0.5.2", "aes 0.8.2", "cipher 0.4.4", "ctr 0.9.2", @@ -153,7 +153,7 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.9", "once_cell", "version_check", ] @@ -165,7 +165,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", - "getrandom 0.2.8", + "getrandom 0.2.9", "once_cell", "version_check", ] @@ -179,11 +179,20 @@ dependencies = [ "memchr", ] +[[package]] +name = "aho-corasick" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +dependencies = [ + "memchr", +] + [[package]] name = "always-assert" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbf688625d06217d5b1bb0ea9d9c44a1635fd0ee3534466388d18203174f4d11" +checksum = "4436e0292ab1bb631b42973c61205e704475fe8126af845c8d923c0996328127" [[package]] name = "android_system_properties" @@ -203,11 +212,60 @@ dependencies = [ "winapi", ] +[[package]] +name = "anstream" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is-terminal", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" + +[[package]] +name = "anstyle-parse" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys 0.48.0", +] + +[[package]] +name = "anstyle-wincon" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +dependencies = [ + "anstyle", + "windows-sys 0.48.0", +] + [[package]] name = "anyhow" -version = "1.0.70" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" [[package]] name = "approx" @@ -232,15 +290,15 @@ checksum = "f52f63c5c1316a16a4b35eaac8b76a98248961a533f061684cb2a7cb0eafb6c6" [[package]] name = "array-bytes" -version = "6.0.0" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22f72e9d6fac4bc80778ea470b20197b88d28c292bb7d60c3fb099280003cd19" +checksum = "d9b1c5a481ec30a5abd8dfbd94ab5cf1bb4e9a66be7f1b3b322f2f1170c200fd" [[package]] name = "arrayref" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" [[package]] name = "arrayvec" @@ -267,7 +325,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.20", + "time 0.3.21", ] [[package]] @@ -283,7 +341,7 @@ dependencies = [ "num-traits", "rusticata-macros", "thiserror", - "time 0.3.20", + "time 0.3.21", ] [[package]] @@ -323,9 +381,9 @@ dependencies = [ [[package]] name = "asn1_der" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e22d1f4b888c298a027c99dc9048015fac177587de20fc30232a057dfbe24a21" +checksum = "155a5a185e42c6b77ac7b88a15143d930a9e9727a5b7b77eed417404ab15c247" [[package]] name = "assert_matches" @@ -335,22 +393,22 @@ checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" [[package]] name = "async-io" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c374dda1ed3e7d8f0d9ba58715f924862c63eae6849c92d3a18e7fbde9e2794" +checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" dependencies = [ "async-lock", "autocfg", + "cfg-if", "concurrent-queue", "futures-lite", - "libc", "log", "parking", "polling", + "rustix 0.37.19", "slab", "socket2", "waker-fn", - "windows-sys 0.42.0", ] [[package]] @@ -364,13 +422,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.67" +version = "0.1.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86ea188f25f0255d8f92797797c97ebf5631fa88178beb1a46fdf5622c9a00e4" +checksum = "b9ccdd8f2a161be9bd5c023df56f1b2a0bd1d83872ae53b71a84a12c9bf6e842" dependencies = [ "proc-macro2", "quote", - "syn 2.0.2", + "syn 2.0.15", ] [[package]] @@ -388,9 +446,9 @@ dependencies = [ [[package]] name = "atomic-waker" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "debc29dde2e69f9e47506b525f639ed42300fc014a3e007832592448fa8e4599" +checksum = "1181e1e0d1fce796a03db1ae795d67167da795f9cf4a39c37589e85ef57f26d3" [[package]] name = "attestation" @@ -440,7 +498,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide", + "miniz_oxide 0.6.2", "object 0.30.3", "rustc-demangle", ] @@ -493,7 +551,7 @@ dependencies = [ [[package]] name = "beefy-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -527,7 +585,7 @@ dependencies = [ [[package]] name = "beefy-gadget-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "beefy-gadget", "futures", @@ -546,7 +604,7 @@ dependencies = [ [[package]] name = "binary-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "hash-db", "log", @@ -567,7 +625,7 @@ version = "0.64.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" dependencies = [ - "bitflags 1.3.2", + "bitflags", "cexpr", "clang-sys", "lazy_static", @@ -587,12 +645,6 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitflags" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487f1e0fcbe47deb8b0574e646def1c903389d95241dd1bbcc6ce4a715dfc0c1" - [[package]] name = "bitvec" version = "1.0.1" @@ -668,7 +720,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -677,7 +729,7 @@ version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -707,9 +759,9 @@ checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" [[package]] name = "bounded-collections" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a071c348a5ef6da1d3a87166b408170b46002382b1dda83992b5c2208cefb370" +checksum = "e3888522b497857eb606bf51695988dba7096941822c1bcf676e3a929a9ae7a0" dependencies = [ "log", "parity-scale-codec", @@ -753,9 +805,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "9b1ce199063694f33ffb7dd4e0ee620741495c32833cde5aa08f02a0bf96f0c8" [[package]] name = "byte-slice-cast" @@ -939,7 +991,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -948,7 +1000,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ee52072ec15386f770805afd189a01c8841be8696bed250fa2f13c4c0d6dfb7" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -972,9 +1024,9 @@ dependencies = [ [[package]] name = "clang-sys" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77ed9a53e5d4d9c573ae844bfac6872b159cb1d1585a83b29e7a64b7eef7332a" +checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f" dependencies = [ "glob", "libc", @@ -983,40 +1035,45 @@ dependencies = [ [[package]] name = "clap" -version = "4.1.11" +version = "4.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42dfd32784433290c51d92c438bb72ea5063797fc3cc9a21a8c4346bebbb2098" +checksum = "34d21f9bf1b425d2968943631ec91202fe5e837264063503708b83013f8fc938" dependencies = [ - "bitflags 2.0.2", + "clap_builder", "clap_derive", - "clap_lex", - "is-terminal", "once_cell", +] + +[[package]] +name = "clap_builder" +version = "4.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "914c8c79fb560f238ef6429439a30023c862f7a28e688c58f7203f12b29970bd" +dependencies = [ + "anstream", + "anstyle", + "bitflags", + "clap_lex", "strsim", - "termcolor", ] [[package]] name = "clap_derive" -version = "4.1.9" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fddf67631444a3a3e3e5ac51c36a5e01335302de677bd78759eaa90ab1f46644" +checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4" dependencies = [ "heck", - "proc-macro-error", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.15", ] [[package]] name = "clap_lex" -version = "0.3.3" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "033f6b7a4acb1f358c742aaca805c939ee73b4c6209ae4318ec7aca81c42e646" -dependencies = [ - "os_str_bytes", -] +checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" [[package]] name = "coarsetime" @@ -1040,6 +1097,12 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "colorchoice" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" + [[package]] name = "comfy-table" version = "6.1.4" @@ -1053,9 +1116,9 @@ dependencies = [ [[package]] name = "concurrent-queue" -version = "2.1.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c278839b831783b70278b14df4d45e1beb1aad306c07bb796637de9a0e323e8e" +checksum = "62ec6771ecfa0762d24683ee5a32ad78487a3d3afdc0fb8cae19d2c5deb50b7c" dependencies = [ "crossbeam-utils", ] @@ -1090,9 +1153,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" [[package]] name = "core2" @@ -1124,27 +1187,27 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.5" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" dependencies = [ "libc", ] [[package]] name = "cranelift-bforest" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7379abaacee0f14abf3204a7606118f0465785252169d186337bcb75030815a" +checksum = "2bc42ba2e232e5b20ff7dc299a812d53337dadce9a7e39a238e6a5cb82d2e57b" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9489fa336927df749631f1008007ced2871068544f40a202ce6d93fbf2366a7b" +checksum = "253531aca9b6f56103c9420369db3263e784df39aa1c90685a1f69cfbba0623e" dependencies = [ "arrayvec 0.7.2", "bumpalo", @@ -1163,33 +1226,33 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05bbb67da91ec721ed57cef2f7c5ef7728e1cd9bde9ffd3ef8601022e73e3239" +checksum = "72f2154365e2bff1b1b8537a7181591fdff50d8e27fa6e40d5c69c3bad0ca7c8" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418ecb2f36032f6665dc1a5e2060a143dbab41d83b784882e97710e890a7a16d" +checksum = "687e14e3f5775248930e0d5a84195abef8b829958e9794bf8d525104993612b4" [[package]] name = "cranelift-entity" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cf583f7b093f291005f9fb1323e2c37f6ee4c7909e39ce016b2e8360d461705" +checksum = "f42ea692c7b450ad18b8c9889661505d51c09ec4380cf1c2d278dbb2da22cae1" dependencies = [ "serde", ] [[package]] name = "cranelift-frontend" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b66bf9e916f57fbbd0f7703ec6286f4624866bf45000111627c70d272c8dda1" +checksum = "8483c2db6f45fe9ace984e5adc5d058102227e4c62e5aa2054e16b0275fd3a6e" dependencies = [ "cranelift-codegen", "log", @@ -1199,15 +1262,15 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "649782a39ce99798dd6b4029e2bb318a2fbeaade1b4fa25330763c10c65bc358" +checksum = "e9793158837678902446c411741d87b43f57dadfb944f2440db4287cda8cbd59" [[package]] name = "cranelift-native" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "937e021e089c51f9749d09e7ad1c4f255c2f8686cb8c3df63a34b3ec9921bc41" +checksum = "72668c7755f2b880665cb422c8ad2d56db58a88b9bebfef0b73edc2277c13c49" dependencies = [ "cranelift-codegen", "libc", @@ -1216,9 +1279,9 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.93.1" +version = "0.93.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d850cf6775477747c9dfda9ae23355dd70512ffebc70cf82b85a5b111ae668b5" +checksum = "3852ce4b088b44ac4e29459573943009a70d1b192c8d77ef949b4e814f656fc1" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -1256,9 +1319,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c" +checksum = "a33c2bf77f2df06183c3aa30d1e96c0695a313d4f9c453cc3762a6db39f99200" dependencies = [ "cfg-if", "crossbeam-utils", @@ -1319,7 +1382,7 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef2b4b23cddf68b89b8f8069890e8c270d54e2d5fe1b143820234805e4cb17ef" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "rand_core 0.6.4", "subtle", "zeroize", @@ -1331,7 +1394,7 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "rand_core 0.6.4", "typenum", ] @@ -1342,7 +1405,7 @@ version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "subtle", ] @@ -1352,7 +1415,7 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "subtle", ] @@ -1810,7 +1873,7 @@ name = "cumulus-relay-chain-minimal-node" version = "0.1.0" source = "git+https://github.com/paritytech/cumulus?branch=polkadot-v0.9.39#d6eef144421ef5c3f339f681484d06bb729dfa82" dependencies = [ - "array-bytes 6.0.0", + "array-bytes 6.1.0", "async-trait", "cumulus-primitives-core", "cumulus-relay-chain-interface", @@ -1929,9 +1992,9 @@ dependencies = [ [[package]] name = "cxx" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c00419335c41018365ddf7e4d5f1c12ee3659ddcf3e01974650ba1de73d038" +checksum = "f61f1b6389c3fe1c316bf8a4dccc90a38208354b330925bce1f74a6c4756eb93" dependencies = [ "cc", "cxxbridge-flags", @@ -1941,9 +2004,9 @@ dependencies = [ [[package]] name = "cxx-build" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb8307ad413a98fff033c8545ecf133e3257747b3bae935e7602aab8aa92d4ca" +checksum = "12cee708e8962df2aeb38f594aae5d827c022b6460ac71a7a3e2c3c2aae5a07b" dependencies = [ "cc", "codespan-reporting", @@ -1951,24 +2014,24 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.2", + "syn 2.0.15", ] [[package]] name = "cxxbridge-flags" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edc52e2eb08915cb12596d29d55f0b5384f00d697a646dbd269b6ecb0fbd9d31" +checksum = "7944172ae7e4068c533afbb984114a56c46e9ccddda550499caa222902c7f7bb" [[package]] name = "cxxbridge-macro" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "631569015d0d8d54e6c241733f944042623ab6df7bc3be7466874b05fcdb1c5f" +checksum = "2345488264226bf682893e25de0769f3360aac9957980ec49361b083ddaa5bc5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.2", + "syn 2.0.15", ] [[package]] @@ -2037,7 +2100,7 @@ name = "delegation" version = "1.11.0-dev" dependencies = [ "attestation", - "bitflags 1.3.2", + "bitflags", "ctype", "frame-benchmarking", "frame-support", @@ -2202,7 +2265,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -2259,13 +2322,13 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bf95dc3f046b9da4f2d51833c0d3547d8564ef6910f5c1ed130306a75b92886" +checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.15", ] [[package]] @@ -2379,7 +2442,7 @@ dependencies = [ "der", "digest 0.10.6", "ff", - "generic-array 0.14.6", + "generic-array 0.14.7", "group", "hkdf", "pem-rfc7468", @@ -2404,22 +2467,22 @@ dependencies = [ [[package]] name = "enumflags2" -version = "0.7.5" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e75d4cd21b95383444831539909fbb14b9dc3fdceb2a6f5d36577329a1f55ccb" +checksum = "c041f5090df68b32bcd905365fd51769c8b9d553fe87fde0b683534f10c01bd2" dependencies = [ "enumflags2_derive", ] [[package]] name = "enumflags2_derive" -version = "0.7.4" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f58dc3c5e468259f19f2d46304a6b28f1c3d034442e14b322d2b850e36f6d5ae" +checksum = "5e9a1f9f7d83e59740248a6e14ecf93929ade55027844dfcea78beafccc15745" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.15", ] [[package]] @@ -2430,7 +2493,7 @@ checksum = "48016319042fb7c87b78d2993084a831793a897a5cd1a2a67cab9d1eeb4b7d76" dependencies = [ "proc-macro2", "quote", - "syn 2.0.2", + "syn 2.0.15", ] [[package]] @@ -2467,13 +2530,13 @@ checksum = "e48c92028aaa870e83d51c64e5d4e0b6981b360c522198c23959f219a4e1b15b" [[package]] name = "errno" -version = "0.2.8" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", - "winapi", + "windows-sys 0.48.0", ] [[package]] @@ -2593,9 +2656,9 @@ dependencies = [ [[package]] name = "fiat-crypto" -version = "0.1.19" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93ace6ec7cc19c8ed33a32eaa9ea692d7faea05006b5356b9e2b668ec4bc3955" +checksum = "e825f6987101665dea6ec934c09ec6d721de7bc1bf92248e1d5810c8cd636b77" [[package]] name = "file-per-thread-logger" @@ -2609,14 +2672,14 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a3de6e8d11b22ff9edc6d916f890800597d60f8b2da1caf2955c274638d6412" +checksum = "5cbc844cecaee9d4443931972e1289c8ff485cb4cc2767cb03ca139ed6885153" dependencies = [ "cfg-if", "libc", - "redox_syscall", - "windows-sys 0.45.0", + "redox_syscall 0.2.16", + "windows-sys 0.48.0", ] [[package]] @@ -2655,13 +2718,13 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flate2" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" +checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", "libz-sys", - "miniz_oxide", + "miniz_oxide 0.7.1", ] [[package]] @@ -2682,7 +2745,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "parity-scale-codec", ] @@ -2705,7 +2768,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-support", "frame-support-procedural", @@ -2730,7 +2793,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "Inflector", "array-bytes 4.2.0", @@ -2777,7 +2840,7 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2788,7 +2851,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -2805,7 +2868,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-support", "frame-system", @@ -2821,9 +2884,9 @@ dependencies = [ [[package]] name = "frame-metadata" -version = "15.0.0" +version = "15.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df6bb8542ef006ef0de09a5c4420787d79823c0ed7924225822362fd2bf2ff2d" +checksum = "878babb0b136e731cc77ec2fd883ff02745ff21e6fb662729953d44923df009c" dependencies = [ "cfg-if", "parity-scale-codec", @@ -2834,7 +2897,7 @@ dependencies = [ [[package]] name = "frame-remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "futures", "log", @@ -2850,9 +2913,9 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ - "bitflags 1.3.2", + "bitflags", "frame-metadata", "frame-support-procedural", "impl-trait-for-tuples", @@ -2882,7 +2945,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "Inflector", "cfg-expr", @@ -2897,7 +2960,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -2909,7 +2972,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "proc-macro2", "quote", @@ -2919,7 +2982,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-support", "log", @@ -2937,7 +3000,7 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -2952,7 +3015,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "parity-scale-codec", "sp-api", @@ -2961,7 +3024,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-support", "parity-scale-codec", @@ -2994,9 +3057,9 @@ checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" [[package]] name = "futures" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "531ac96c6ff5fd7c62263c5e3c67a603af4fcaee2e1a0ae5565ba3a11e69e549" +checksum = "23342abe12aba583913b2e62f22225ff9c950774065e4bfb61a19cd9770fec40" dependencies = [ "futures-channel", "futures-core", @@ -3009,9 +3072,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "164713a5a0dcc3e7b4b1ed7d3b433cabc18025386f9339346e8daf15963cf7ac" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" dependencies = [ "futures-core", "futures-sink", @@ -3019,15 +3082,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86d7a0c1aa76363dac491de0ee99faf6941128376f1cf96f07db7603b7de69dd" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" [[package]] name = "futures-executor" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1997dd9df74cdac935c76252744c1ed5794fac083242ea4fe77ef3ed60ba0f83" +checksum = "ccecee823288125bd88b4d7f565c9e58e41858e47ab72e8ea2d64e93624386e0" dependencies = [ "futures-core", "futures-task", @@ -3037,15 +3100,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d422fa3cbe3b40dca574ab087abb5bc98258ea57eea3fd6f1fa7162c778b91" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" [[package]] name = "futures-lite" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" +checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" dependencies = [ "fastrand", "futures-core", @@ -3058,13 +3121,13 @@ dependencies = [ [[package]] name = "futures-macro" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eb14ed937631bd8b8b8977f2c198443447a8355b6e3ca599f38c975e5a963b6" +checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.15", ] [[package]] @@ -3080,15 +3143,15 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec93083a4aecafb2a80a885c9de1f0ccae9dbd32c2bb54b0c3a65690e0b8d2f2" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" [[package]] name = "futures-task" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd65540d33b37b16542a0438c12e6aeead10d4ac5d05bd3f805b8f35ab592879" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" [[package]] name = "futures-timer" @@ -3098,9 +3161,9 @@ checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" [[package]] name = "futures-util" -version = "0.3.27" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ef6b17e481503ec85211fed8f39d1970f128935ca1f814cd32ac4a6842e84ab" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" dependencies = [ "futures-channel", "futures-core", @@ -3134,9 +3197,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.14.6" +version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", @@ -3165,9 +3228,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +checksum = "c85e1d9ab2eadba7e5040d4e09cbd6d072b76a557ad64e797c2cb9d4da21d7e4" dependencies = [ "cfg-if", "libc", @@ -3223,7 +3286,7 @@ version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" dependencies = [ - "aho-corasick", + "aho-corasick 0.7.20", "bstr", "fnv", "log", @@ -3243,9 +3306,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.16" +version = "0.3.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d" +checksum = "17f8a914c2987b688368b5138aa05321db91f4090cf26118185672ad588bce21" dependencies = [ "bytes", "fnv", @@ -3394,7 +3457,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" dependencies = [ "digest 0.9.0", - "generic-array 0.14.6", + "generic-array 0.14.7", "hmac 0.8.1", ] @@ -3457,9 +3520,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.25" +version = "0.14.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899" +checksum = "ab302d72a6f11a3b910431ff93aae7e773078c769f0a3ef15fb9ec692ed147d4" dependencies = [ "bytes", "futures-channel", @@ -3496,16 +3559,16 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.53" +version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +checksum = "0722cd7114b7de04316e7ea5456a0bbb20e4adb46fd27a3697adb812cff0f37c" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", - "winapi", + "windows 0.48.0", ] [[package]] @@ -3557,9 +3620,9 @@ dependencies = [ [[package]] name = "if-watch" -version = "3.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba7abdbb86e485125dad06c2691e1e393bf3b08c7b743b43aa162a00fd39062e" +checksum = "a9465340214b296cd17a0009acdb890d6160010b8adf8f78a00d0d7ab270f79f" dependencies = [ "async-io", "core-foundation", @@ -3571,7 +3634,7 @@ dependencies = [ "rtnetlink", "system-configuration", "tokio", - "windows", + "windows 0.34.0", ] [[package]] @@ -3605,9 +3668,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", "hashbrown 0.12.3", @@ -3620,7 +3683,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", ] [[package]] @@ -3668,13 +3731,13 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd6da19f25979c7270e70fa95ab371ec3b701cd0eefc47667a09785b3c59155" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ "hermit-abi 0.3.1", "libc", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -3697,20 +3760,20 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.7.1" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30e22bd8629359895450b59ea7a776c850561b96a3b1d31321c1949d9e6c9146" +checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" [[package]] name = "is-terminal" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8687c819457e979cc940d09cb16e42a1bf70aa6b60a549de6d3a62a0ee90c69e" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", - "rustix", - "windows-sys 0.45.0", + "rustix 0.37.19", + "windows-sys 0.48.0", ] [[package]] @@ -3884,9 +3947,9 @@ dependencies = [ [[package]] name = "keccak" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3afef3b6eff9ce9d8ff9b3601125eec7f0c8cbac7abd14f355d053fa56c98768" +checksum = "8f6d5ed8676d904364de097082f4e7d240b571b67989ced0240f08b7f966f940" dependencies = [ "cpufeatures", ] @@ -4174,9 +4237,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.140" +version = "0.2.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" [[package]] name = "libloading" @@ -4209,7 +4272,7 @@ dependencies = [ "bytes", "futures", "futures-timer", - "getrandom 0.2.8", + "getrandom 0.2.9", "instant", "libp2p-core 0.38.0", "libp2p-dns", @@ -4270,9 +4333,9 @@ dependencies = [ [[package]] name = "libp2p-core" -version = "0.39.1" +version = "0.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7f8b7d65c070a5a1b5f8f0510648189da08f787b8963f8e21219e0710733af" +checksum = "3c1df63c0b582aa434fb09b2d86897fa2b419ffeccf934b36f87fcedc8e835c2" dependencies = [ "either", "fnv", @@ -4281,7 +4344,7 @@ dependencies = [ "instant", "libp2p-identity", "log", - "multiaddr 0.17.0", + "multiaddr 0.17.1", "multihash 0.17.0", "multistream-select", "once_cell", @@ -4333,19 +4396,18 @@ dependencies = [ [[package]] name = "libp2p-identity" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff6c9cb71e2333d31f18e7556b9a5f1d0a2e013effc9325e36f436be65fe7bd2" +checksum = "9e2d584751cecb2aabaa56106be6be91338a60a0f4e420cf2af639204f596fc1" dependencies = [ "bs58", "ed25519-dalek", "log", - "multiaddr 0.17.0", + "multiaddr 0.17.1", "multihash 0.17.0", - "prost", - "prost-build", "quick-protobuf", "rand 0.8.5", + "sha2 0.10.6", "thiserror", "zeroize", ] @@ -4565,7 +4627,7 @@ checksum = "ff08d13d0dc66e5e9ba6279c1de417b84fa0d0adc3b03e5732928c180ec02781" dependencies = [ "futures", "futures-rustls", - "libp2p-core 0.39.1", + "libp2p-core 0.39.2", "libp2p-identity", "rcgen 0.10.0", "ring", @@ -4719,9 +4781,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.8" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf" +checksum = "56ee889ecc9568871456d42f603d6a0ce59ff328d291063a45cbdf0036baf6db" dependencies = [ "cc", "pkg-config", @@ -4767,6 +4829,12 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +[[package]] +name = "linux-raw-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f" + [[package]] name = "lock_api" version = "0.4.9" @@ -4962,10 +5030,11 @@ checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5" [[package]] name = "matrixmultiply" -version = "0.3.2" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add85d4dd35074e6fedc608f8c8f513a3548619a9024b751949ef0e8e45a4d84" +checksum = "090126dc04f95dc0d1c1c91f61bdd474b3930ca064c1edc8a849da2c6cbe1e77" dependencies = [ + "autocfg", "rawpointer", ] @@ -4986,11 +5055,11 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memfd" -version = "0.6.2" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b20a59d985586e4a5aef64564ac77299f8586d8be6cf9106a5a40207e8908efb" +checksum = "ffc89ccdc6e10d6907450f753537ebc5c5d3460d2e4e62ea74bd571db62c0f9e" dependencies = [ - "rustix", + "rustix 0.37.19", ] [[package]] @@ -5083,6 +5152,15 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" +dependencies = [ + "adler", +] + [[package]] name = "mio" version = "0.8.6" @@ -5098,7 +5176,7 @@ dependencies = [ [[package]] name = "mmr-gadget" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "futures", "log", @@ -5117,7 +5195,7 @@ dependencies = [ [[package]] name = "mmr-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "anyhow", "jsonrpsee", @@ -5132,9 +5210,9 @@ dependencies = [ [[package]] name = "mockall" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50e4a1c770583dac7ab5e2f6c139153b783a53a1bbee9729613f193e59828326" +checksum = "4c84490118f2ee2d74570d114f3d0493cbf02790df303d2707606c3e14e07c96" dependencies = [ "cfg-if", "downcast", @@ -5147,9 +5225,9 @@ dependencies = [ [[package]] name = "mockall_derive" -version = "0.11.3" +version = "0.11.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "832663583d5fa284ca8810bf7015e46c9fff9622d3cf34bd1eea5003fec06dd0" +checksum = "22ce75669015c4f47b289fd4d4f56e894e4c96003ffdf3ac51313126f94c6cbb" dependencies = [ "cfg-if", "proc-macro2", @@ -5177,13 +5255,14 @@ dependencies = [ [[package]] name = "multiaddr" -version = "0.17.0" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b53e0cc5907a5c216ba6584bf74be8ab47d6d6289f72793b2dddbf15dc3bf8c" +checksum = "2b36f567c7099511fa8612bbbb52dda2419ce0bdbacf31714e3a5ffdb766d3bd" dependencies = [ "arrayref", "byteorder", "data-encoding", + "log", "multibase", "multihash 0.17.0", "percent-encoding", @@ -5228,9 +5307,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835d6ff01d610179fbce3de1694d007e500bf33a7f29689838941d6bf783ae40" dependencies = [ "core2", - "digest 0.10.6", "multihash-derive", - "sha2 0.10.6", "unsigned-varint", ] @@ -5329,7 +5406,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9ea4302b9759a7a88242299225ea3688e63c85ea136371bb6cf94fd674efaab" dependencies = [ "anyhow", - "bitflags 1.3.2", + "bitflags", "byteorder", "libc", "netlink-packet-core", @@ -5382,7 +5459,7 @@ version = "0.24.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" dependencies = [ - "bitflags 1.3.2", + "bitflags", "cfg-if", "libc", "memoffset 0.6.5", @@ -5394,7 +5471,7 @@ version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a" dependencies = [ - "bitflags 1.3.2", + "bitflags", "cfg-if", "libc", "memoffset 0.7.1", @@ -5599,12 +5676,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "os_str_bytes" -version = "6.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" - [[package]] name = "p256" version = "0.11.1" @@ -5640,7 +5711,7 @@ dependencies = [ [[package]] name = "pallet-aura" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-support", "frame-system", @@ -5656,7 +5727,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-support", "frame-system", @@ -5672,7 +5743,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-support", "frame-system", @@ -5686,7 +5757,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -5710,7 +5781,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5730,7 +5801,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -5745,7 +5816,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-support", "frame-system", @@ -5764,7 +5835,7 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "array-bytes 4.2.0", "binary-merkle-tree", @@ -5788,7 +5859,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -5806,7 +5877,7 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -5825,7 +5896,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -5842,7 +5913,7 @@ dependencies = [ [[package]] name = "pallet-conviction-voting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "assert_matches", "frame-benchmarking", @@ -5859,7 +5930,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -5904,7 +5975,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5927,7 +5998,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-support-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5940,7 +6011,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -5958,7 +6029,7 @@ dependencies = [ [[package]] name = "pallet-fast-unstake" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -5976,7 +6047,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -5999,7 +6070,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "enumflags2", "frame-benchmarking", @@ -6015,7 +6086,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -6035,7 +6106,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -6068,7 +6139,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -6085,7 +6156,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -6102,7 +6173,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -6118,7 +6189,7 @@ dependencies = [ [[package]] name = "pallet-nis" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -6134,7 +6205,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-support", "frame-system", @@ -6151,7 +6222,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-benchmarking" version = "1.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6171,7 +6242,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-runtime-api" version = "1.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "pallet-nomination-pools", "parity-scale-codec", @@ -6182,7 +6253,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-support", "frame-system", @@ -6199,7 +6270,7 @@ dependencies = [ [[package]] name = "pallet-offences-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6223,7 +6294,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -6240,7 +6311,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -6255,7 +6326,7 @@ dependencies = [ [[package]] name = "pallet-ranked-collective" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -6273,7 +6344,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -6288,7 +6359,7 @@ dependencies = [ [[package]] name = "pallet-referenda" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "assert_matches", "frame-benchmarking", @@ -6307,7 +6378,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -6324,7 +6395,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-support", "frame-system", @@ -6345,7 +6416,7 @@ dependencies = [ [[package]] name = "pallet-session-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -6361,7 +6432,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-support", "frame-system", @@ -6375,7 +6446,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6398,7 +6469,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -6409,7 +6480,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "log", "sp-arithmetic", @@ -6418,7 +6489,7 @@ dependencies = [ [[package]] name = "pallet-staking-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "parity-scale-codec", "sp-api", @@ -6427,7 +6498,7 @@ dependencies = [ [[package]] name = "pallet-state-trie-migration" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -6444,7 +6515,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-support", "frame-system", @@ -6458,7 +6529,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -6476,7 +6547,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -6495,7 +6566,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-support", "frame-system", @@ -6511,7 +6582,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -6527,7 +6598,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -6539,7 +6610,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -6556,7 +6627,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -6572,7 +6643,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -6605,7 +6676,7 @@ dependencies = [ [[package]] name = "pallet-whitelist" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-benchmarking", "frame-support", @@ -6696,9 +6767,9 @@ dependencies = [ [[package]] name = "parity-db" -version = "0.4.4" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df89dd8311063c54ae4e03d9aeb597b04212a57e82c339344130a9cad9b3e2d9" +checksum = "bd4572a52711e2ccff02b4973ec7e4a5b5c23387ebbfbd6cd42b34755714cefc" dependencies = [ "blake2", "crc32fast", @@ -6716,9 +6787,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "637935964ff85a605d114591d4d2c13c5d1ba2806dae97cea6bf180238a749ac" +checksum = "5ddb756ca205bd108aee3c62c6d3c994e1df84a59b9d6d4a5ea42ee1fd5a9a28" dependencies = [ "arrayvec 0.7.2", "bitvec", @@ -6755,9 +6826,9 @@ checksum = "e1ad0aff30c1da14b1254fcb2af73e1fa9a28670e584a626f53a369d0e157304" [[package]] name = "parking" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" +checksum = "14f2252c834a40ed9bb5422029649578e63aa341ac401f74e719dd1afda8394e" [[package]] name = "parking_lot" @@ -6789,7 +6860,7 @@ dependencies = [ "cfg-if", "instant", "libc", - "redox_syscall", + "redox_syscall 0.2.16", "smallvec", "winapi", ] @@ -6802,7 +6873,7 @@ checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" dependencies = [ "cfg-if", "libc", - "redox_syscall", + "redox_syscall 0.2.16", "smallvec", "windows-sys 0.45.0", ] @@ -6942,9 +7013,9 @@ dependencies = [ [[package]] name = "pest" -version = "2.5.6" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cbd939b234e95d72bc393d51788aec68aeeb5d51e748ca08ff3aad58cb722f7" +checksum = "e68e84bfb01f0507134eac1e9b410a12ba379d064eab48c50ba4ce329a527b70" dependencies = [ "thiserror", "ucd-trie", @@ -6952,9 +7023,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.5.6" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a81186863f3d0a27340815be8f2078dd8050b14cd71913db9fbda795e5f707d7" +checksum = "6b79d4c71c865a25a4322296122e3924d30bc8ee0834c8bfc8b95f7f054afbfb" dependencies = [ "pest", "pest_generator", @@ -6962,22 +7033,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.5.6" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75a1ef20bf3193c15ac345acb32e26b3dc3223aff4d77ae4fc5359567683796b" +checksum = "6c435bf1076437b851ebc8edc3a18442796b30f1728ffea6262d59bbe28b077e" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.15", ] [[package]] name = "pest_meta" -version = "2.5.6" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e3b284b1f13a20dc5ebc90aff59a51b8d7137c221131b52a7260c08cbc1cc80" +checksum = "745a452f8eb71e39ffd8ee32b3c5f51d03845f99786fa9b68db6ff509c505411" dependencies = [ "once_cell", "pest", @@ -7044,9 +7115,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "platforms" @@ -8027,7 +8098,7 @@ name = "polkadot-runtime-parachains" version = "0.9.39-1" source = "git+https://github.com/paritytech/polkadot?branch=release-v0.9.39#c22e1c4173bf6966f5d1980f4299f7abe836f0c1" dependencies = [ - "bitflags 1.3.2", + "bitflags", "bitvec", "derive_more", "frame-benchmarking", @@ -8207,18 +8278,18 @@ dependencies = [ [[package]] name = "polling" -version = "2.6.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e1f879b2998099c2d69ab9605d145d5b661195627eccc680002c4918a7fb6fa" +checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ "autocfg", - "bitflags 1.3.2", + "bitflags", "cfg-if", "concurrent-queue", "libc", "log", "pin-project-lite 0.2.9", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -8367,9 +8438,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.52" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ "unicode-ident", ] @@ -8413,9 +8484,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48e50df39172a3e7eb17e14642445da64996989bc212b583015435d39a58537" +checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ "bytes", "prost-derive", @@ -8423,9 +8494,9 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c828f93f5ca4826f97fedcbd3f9a536c16b12cff3dbbb4a007f932bbad95b12" +checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" dependencies = [ "bytes", "heck", @@ -8458,9 +8529,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ea9b0f8cbe5e15a8a042d030bd96668db28ecb567ec37d691971ff5731d2b1b" +checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" dependencies = [ "anyhow", "itertools", @@ -8471,9 +8542,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "379119666929a1afd7a043aa6cf96fa67a6dce9af60c88095a4686dbce4c9c88" +checksum = "213622a1460818959ac1181aaeb2dc9c7f63df720db7d788b3e24eacd1983e13" dependencies = [ "prost", ] @@ -8534,9 +8605,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4ced82a24bb281af338b9e8f94429b6eca01b4e66d899f40031f074e74c9" +checksum = "67c10f662eee9c94ddd7135043e544f3c82fa839a1e7b865911331961b53186c" dependencies = [ "bytes", "rand 0.8.5", @@ -8624,7 +8695,7 @@ version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.9", ] [[package]] @@ -8681,7 +8752,7 @@ checksum = "6413f3de1edee53342e6138e75b56d32e7bc6e332b3bd62d497b1929d4cfbcdd" dependencies = [ "pem", "ring", - "time 0.3.20", + "time 0.3.21", "x509-parser 0.13.2", "yasna", ] @@ -8694,7 +8765,7 @@ checksum = "ffbe84efe2f38dea12e9bfc1f65377fdf03e53a18cb3b995faedf7934c7e785b" dependencies = [ "pem", "ring", - "time 0.3.20", + "time 0.3.21", "yasna", ] @@ -8704,7 +8775,16 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" dependencies = [ - "bitflags 1.3.2", + "bitflags", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags", ] [[package]] @@ -8713,8 +8793,8 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ - "getrandom 0.2.8", - "redox_syscall", + "getrandom 0.2.9", + "redox_syscall 0.2.16", "thiserror", ] @@ -8748,7 +8828,7 @@ checksum = "8d2275aab483050ab2a7364c1a46604865ee7d6906684e08db0f090acf74f9e7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.2", + "syn 2.0.15", ] [[package]] @@ -8765,13 +8845,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.1" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" dependencies = [ - "aho-corasick", + "aho-corasick 1.0.1", "memchr", - "regex-syntax", + "regex-syntax 0.7.1", ] [[package]] @@ -8780,14 +8860,20 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" dependencies = [ - "regex-syntax", + "regex-syntax 0.6.29", ] [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" [[package]] name = "region" @@ -8795,7 +8881,7 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" dependencies = [ - "bitflags 1.3.2", + "bitflags", "libc", "mach", "winapi", @@ -9047,9 +9133,9 @@ dependencies = [ [[package]] name = "rustc-demangle" -version = "0.1.21" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustc-hash" @@ -9083,18 +9169,32 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.10" +version = "0.36.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fe885c3a125aa45213b68cc1472a49880cb5923dc23f522ad2791b882228778" +checksum = "3a38f9520be93aba504e8ca974197f46158de5dcaa9fa04b57c57cd6a679d658" dependencies = [ - "bitflags 1.3.2", + "bitflags", "errno", "io-lifetimes", "libc", - "linux-raw-sys", + "linux-raw-sys 0.1.4", "windows-sys 0.45.0", ] +[[package]] +name = "rustix" +version = "0.37.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys 0.3.7", + "windows-sys 0.48.0", +] + [[package]] name = "rustls" version = "0.19.1" @@ -9185,7 +9285,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "log", "sp-core", @@ -9196,7 +9296,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "async-trait", "futures", @@ -9223,7 +9323,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "futures", "futures-timer", @@ -9246,7 +9346,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -9262,7 +9362,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "memmap2", "sc-chain-spec-derive", @@ -9277,7 +9377,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -9288,7 +9388,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "array-bytes 4.2.0", "chrono", @@ -9328,7 +9428,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "fnv", "futures", @@ -9354,7 +9454,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "hash-db", "kvdb", @@ -9380,7 +9480,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "async-trait", "futures", @@ -9405,7 +9505,7 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "async-trait", "futures", @@ -9434,7 +9534,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "async-trait", "fork-tree", @@ -9473,7 +9573,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "futures", "jsonrpsee", @@ -9495,7 +9595,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "fork-tree", "parity-scale-codec", @@ -9508,7 +9608,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "async-trait", "futures", @@ -9531,7 +9631,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "lru 0.8.1", "parity-scale-codec", @@ -9555,7 +9655,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", @@ -9568,7 +9668,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "log", "sc-allocator", @@ -9581,14 +9681,14 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "anyhow", "cfg-if", "libc", "log", "once_cell", - "rustix", + "rustix 0.36.13", "sc-allocator", "sc-executor-common", "sp-runtime-interface", @@ -9599,7 +9699,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "ahash 0.8.3", "array-bytes 4.2.0", @@ -9639,7 +9739,7 @@ dependencies = [ [[package]] name = "sc-finality-grandpa-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "finality-grandpa", "futures", @@ -9659,7 +9759,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "ansi_term", "futures", @@ -9674,7 +9774,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -9689,7 +9789,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -9732,7 +9832,7 @@ dependencies = [ [[package]] name = "sc-network-bitswap" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "cid", "futures", @@ -9751,10 +9851,10 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "async-trait", - "bitflags 1.3.2", + "bitflags", "bytes", "futures", "futures-timer", @@ -9777,7 +9877,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "ahash 0.8.3", "futures", @@ -9795,7 +9895,7 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "array-bytes 4.2.0", "futures", @@ -9816,7 +9916,7 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -9848,7 +9948,7 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "array-bytes 4.2.0", "futures", @@ -9867,7 +9967,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "array-bytes 4.2.0", "bytes", @@ -9897,7 +9997,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "futures", "libp2p", @@ -9910,7 +10010,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -9919,7 +10019,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "futures", "jsonrpsee", @@ -9949,7 +10049,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -9968,7 +10068,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "http", "jsonrpsee", @@ -9983,7 +10083,7 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "array-bytes 4.2.0", "futures", @@ -10009,7 +10109,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "async-trait", "directories", @@ -10075,7 +10175,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "log", "parity-scale-codec", @@ -10086,7 +10186,7 @@ dependencies = [ [[package]] name = "sc-storage-monitor" version = "0.1.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "clap", "futures", @@ -10102,7 +10202,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -10121,7 +10221,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "futures", "libc", @@ -10140,7 +10240,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "chrono", "futures", @@ -10159,7 +10259,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "ansi_term", "atty", @@ -10190,7 +10290,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -10201,7 +10301,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "async-trait", "futures", @@ -10228,7 +10328,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "async-trait", "futures", @@ -10242,7 +10342,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "backtrace", "futures", @@ -10255,9 +10355,9 @@ dependencies = [ [[package]] name = "scale-info" -version = "2.3.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "001cf62ece89779fd16105b5f515ad0e5cedcd5440d3dd806bb067978e7c3608" +checksum = "dfdef77228a4c05dc94211441595746732131ad7f6530c6c18f045da7b7ab937" dependencies = [ "bitvec", "cfg-if", @@ -10269,9 +10369,9 @@ dependencies = [ [[package]] name = "scale-info-derive" -version = "2.3.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "303959cf613a6f6efd19ed4b4ad5bf79966a13352716299ad532cfb115f4205c" +checksum = "53012eae69e5aa5c14671942a5dd47de59d4cdcff8532a6dd0e081faf1119482" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -10369,7 +10469,7 @@ checksum = "3be24c1842290c45df0a7bf069e0c268a747ad05a192f2fd7dcfdbc1cba40928" dependencies = [ "base16ct", "der", - "generic-array 0.14.6", + "generic-array 0.14.7", "pkcs8", "subtle", "zeroize", @@ -10408,7 +10508,7 @@ version = "2.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" dependencies = [ - "bitflags 1.3.2", + "bitflags", "core-foundation", "core-foundation-sys", "libc", @@ -10451,29 +10551,29 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.157" +version = "1.0.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707de5fcf5df2b5788fca98dd7eab490bc2fd9b7ef1404defc462833b83f25ca" +checksum = "71b2f6e1ab5c2b98c05f0f35b236b22e8df7ead6ffbf51d7808da7f8817e7ab6" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.157" +version = "1.0.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78997f4555c22a7971214540c4a661291970619afd56de19f77e0de86296e1e5" +checksum = "a2a0814352fd64b58489904a44ea8d90cb1a91dcb6b4f5ebabc32c8318e93cb6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.2", + "syn 2.0.15", ] [[package]] name = "serde_json" -version = "1.0.94" +version = "1.0.96" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c533a59c9d8a93a09c6ab31f0fd5e5f4dd1b8fc9434804029839884765d04ea" +checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1" dependencies = [ "itoa", "ryu", @@ -10542,9 +10642,9 @@ dependencies = [ [[package]] name = "sha3" -version = "0.10.6" +version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" dependencies = [ "digest 0.10.6", "keccak", @@ -10586,9 +10686,9 @@ dependencies = [ [[package]] name = "simba" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50582927ed6f77e4ac020c057f37a268fc6aebc29225050365aacbb9deeeddc4" +checksum = "061507c94fc6ab4ba1c9a0305018408e312e17c041eb63bef8aa726fa33aceae" dependencies = [ "approx", "num-complex", @@ -10614,9 +10714,9 @@ dependencies = [ [[package]] name = "slice-group-by" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec" +checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" [[package]] name = "slot-range-helper" @@ -10698,7 +10798,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "hash-db", "log", @@ -10716,7 +10816,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "blake2", "proc-macro-crate", @@ -10728,7 +10828,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "parity-scale-codec", "scale-info", @@ -10741,7 +10841,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "integer-sqrt", "num-traits", @@ -10755,7 +10855,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "parity-scale-codec", "scale-info", @@ -10768,7 +10868,7 @@ dependencies = [ [[package]] name = "sp-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "lazy_static", "parity-scale-codec", @@ -10787,7 +10887,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "parity-scale-codec", "sp-api", @@ -10799,7 +10899,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "futures", "log", @@ -10817,7 +10917,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "async-trait", "futures", @@ -10835,7 +10935,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "async-trait", "parity-scale-codec", @@ -10853,7 +10953,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "async-trait", "merlin", @@ -10876,7 +10976,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "parity-scale-codec", "scale-info", @@ -10888,7 +10988,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "parity-scale-codec", "scale-info", @@ -10901,11 +11001,11 @@ dependencies = [ [[package]] name = "sp-core" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "array-bytes 4.2.0", "base58", - "bitflags 1.3.2", + "bitflags", "blake2", "bounded-collections", "dyn-clonable", @@ -10944,7 +11044,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "blake2", "byteorder", @@ -10958,7 +11058,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "proc-macro2", "quote", @@ -10969,7 +11069,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -10978,7 +11078,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "proc-macro2", "quote", @@ -10988,7 +11088,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "environmental", "parity-scale-codec", @@ -10999,7 +11099,7 @@ dependencies = [ [[package]] name = "sp-finality-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "finality-grandpa", "log", @@ -11017,7 +11117,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -11032,7 +11132,7 @@ dependencies = [ [[package]] name = "sp-io" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "bytes", "ed25519", @@ -11057,7 +11157,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "lazy_static", "sp-core", @@ -11068,7 +11168,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "async-trait", "futures", @@ -11085,7 +11185,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "thiserror", "zstd", @@ -11094,7 +11194,7 @@ dependencies = [ [[package]] name = "sp-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "ckb-merkle-mountain-range", "log", @@ -11112,7 +11212,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "parity-scale-codec", "scale-info", @@ -11126,7 +11226,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "sp-api", "sp-core", @@ -11136,7 +11236,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "backtrace", "lazy_static", @@ -11146,7 +11246,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "rustc-hash", "serde", @@ -11156,7 +11256,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "either", "hash256-std-hasher", @@ -11178,7 +11278,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -11196,7 +11296,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "Inflector", "proc-macro-crate", @@ -11208,7 +11308,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "parity-scale-codec", "scale-info", @@ -11222,7 +11322,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "parity-scale-codec", "scale-info", @@ -11234,7 +11334,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.13.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "hash-db", "log", @@ -11254,12 +11354,12 @@ dependencies = [ [[package]] name = "sp-std" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" [[package]] name = "sp-storage" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "impl-serde", "parity-scale-codec", @@ -11272,7 +11372,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "async-trait", "futures-timer", @@ -11287,7 +11387,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "6.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "parity-scale-codec", "sp-std", @@ -11299,7 +11399,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "sp-api", "sp-runtime", @@ -11308,7 +11408,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "async-trait", "log", @@ -11324,7 +11424,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "ahash 0.8.3", "hash-db", @@ -11347,7 +11447,7 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "impl-serde", "parity-scale-codec", @@ -11364,7 +11464,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -11375,7 +11475,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "7.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -11389,7 +11489,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "4.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "parity-scale-codec", "scale-info", @@ -11497,9 +11597,9 @@ dependencies = [ [[package]] name = "ss58-registry" -version = "1.39.0" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecf0bd63593ef78eca595a7fc25e9a443ca46fe69fd472f8f09f5245cdcd769d" +checksum = "eb47a8ad42e5fc72d5b1eb104a5546937eaf39843499948bb666d6e93c62423b" dependencies = [ "Inflector", "num-format", @@ -11540,7 +11640,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a2a1c578e98c1c16fc3b8ec1328f7659a500737d7a0c6d625e73e830ff9c1f6" dependencies = [ - "bitflags 1.3.2", + "bitflags", "cfg_aliases", "libc", "parking_lot 0.11.2", @@ -11638,7 +11738,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "platforms 2.0.0", ] @@ -11646,7 +11746,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "frame-system-rpc-runtime-api", "futures", @@ -11665,7 +11765,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "hyper", "log", @@ -11677,7 +11777,7 @@ dependencies = [ [[package]] name = "substrate-rpc-client" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "async-trait", "jsonrpsee", @@ -11690,7 +11790,7 @@ dependencies = [ [[package]] name = "substrate-state-trie-migration-rpc" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "jsonrpsee", "log", @@ -11709,7 +11809,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "ansi_term", "build-helper", @@ -11751,9 +11851,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.2" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59d3276aee1fa0c33612917969b5172b5be2db051232a6e4826f1a1a9191b045" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" dependencies = [ "proc-macro2", "quote", @@ -11778,7 +11878,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d75182f12f490e953596550b65ee31bda7c8e043d9386174b353bda50838c3fd" dependencies = [ - "bitflags 1.3.2", + "bitflags", "core-foundation", "system-configuration-sys", ] @@ -11801,21 +11901,21 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "target-lexicon" -version = "0.12.6" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ae9980cab1db3fceee2f6c6f643d5d8de2997c58ee8d25fb0cc8a9e9e7348e5" +checksum = "fd1ba337640d60c3e96bc6f0638a939b9c9a7f2c316a1598c279828b3d1dc8c5" [[package]] name = "tempfile" -version = "3.4.0" +version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95" +checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", - "rustix", - "windows-sys 0.42.0", + "redox_syscall 0.3.5", + "rustix 0.37.19", + "windows-sys 0.45.0", ] [[package]] @@ -11861,7 +11961,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.2", + "syn 2.0.15", ] [[package]] @@ -11936,9 +12036,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.20" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" +checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc" dependencies = [ "itoa", "serde", @@ -11948,15 +12048,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.8" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" +checksum = "372950940a5f07bf38dbe211d7283c9e6d7327df53794992d293e534c733d09b" dependencies = [ "time-core", ] @@ -12007,14 +12107,13 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.26.0" +version = "1.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03201d01c3c27a29c8a5cee5b55a93ddae1ccf6f08f65365c2c918f8c1b76f64" +checksum = "c3c786bf8134e5a3a166db9b29ab8f48134739014a3eca7bc6bfa95d673b136f" dependencies = [ "autocfg", "bytes", "libc", - "memchr", "mio", "num_cpus", "parking_lot 0.12.1", @@ -12022,18 +12121,18 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] name = "tokio-macros" -version = "1.8.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8" +checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.15", ] [[package]] @@ -12049,9 +12148,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.12" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" +checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" dependencies = [ "futures-core", "pin-project-lite 0.2.9", @@ -12061,9 +12160,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.7" +version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" +checksum = "806fe8c2c87eccc8b3267cbae29ed3ab2d0bd37fca70ab622e46aaa9375ddb7d" dependencies = [ "bytes", "futures-core", @@ -12091,9 +12190,9 @@ checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622" [[package]] name = "toml_edit" -version = "0.19.7" +version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc18466501acd8ac6a3f615dd29a3438f8ca6bb3b19537138b3106e575621274" +checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" dependencies = [ "indexmap", "toml_datetime", @@ -12117,7 +12216,7 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f873044bf02dd1e8239e9c1293ea39dad76dc594ec16185d0a1bf31d8dc8d858" dependencies = [ - "bitflags 1.3.2", + "bitflags", "bytes", "futures-core", "futures-util", @@ -12156,13 +12255,13 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +checksum = "0f57e3ca2a01450b1a921183a9c9cbfda207fd822cef4ccb00a65402cbba7a74" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.15", ] [[package]] @@ -12329,7 +12428,7 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#1837f423b494254e1d27834b1c9da34b2c0c2375" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.39#8c4b84520cee2d7de53cc33cb67605ce4efefba8" dependencies = [ "async-trait", "clap", @@ -12426,9 +12525,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.12" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d502c968c6a838ead8e69b2ee18ec708802f99db92a0d156705ec9ef801993b" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" @@ -12463,7 +12562,7 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" dependencies = [ - "generic-array 0.14.6", + "generic-array 0.14.7", "subtle", ] @@ -12506,13 +12605,19 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "uuid" -version = "1.3.0" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79" +checksum = "4dad5567ad0cf5b760e5665964bec1b47dfd077ba8a2544b513f3556d3d239a2" dependencies = [ - "getrandom 0.2.8", + "getrandom 0.2.9", ] [[package]] @@ -12769,9 +12874,9 @@ dependencies = [ [[package]] name = "wasmtime" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6e89f9819523447330ffd70367ef4a18d8c832e24e8150fe054d1d912841632" +checksum = "76a222f5fa1e14b2cefc286f1b68494d7a965f4bf57ec04c59bb62673d639af6" dependencies = [ "anyhow", "bincode", @@ -12797,18 +12902,18 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd3a5e46c198032da934469f3a6e48649d1f9142438e4fd4617b68a35644b8a" +checksum = "4407a7246e7d2f3d8fb1cf0c72fda8dbafdb6dd34d555ae8bea0e5ae031089cc" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-cache" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b389ae9b678b9c3851091a4804f4182d688d27aff7abc9aa37fa7be37d8ecffa" +checksum = "5ceb3adf61d654be0be67fffdce42447b0880481348785be5fe40b5dd7663a4c" dependencies = [ "anyhow", "base64 0.13.1", @@ -12816,7 +12921,7 @@ dependencies = [ "directories-next", "file-per-thread-logger", "log", - "rustix", + "rustix 0.36.13", "serde", "sha2 0.10.6", "toml", @@ -12826,9 +12931,9 @@ dependencies = [ [[package]] name = "wasmtime-cranelift" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b2c92a08c0db6efffd88fdc97d7aa9c7c63b03edb0971dbca745469f820e8c" +checksum = "3c366bb8647e01fd08cb5589976284b00abfded5529b33d7e7f3f086c68304a4" dependencies = [ "anyhow", "cranelift-codegen", @@ -12847,9 +12952,9 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a6db9fc52985ba06ca601f2ff0ff1f526c5d724c7ac267b47326304b0c97883" +checksum = "47b8b50962eae38ee319f7b24900b7cf371f03eebdc17400c1dc8575fc10c9a7" dependencies = [ "anyhow", "cranelift-entity", @@ -12866,9 +12971,9 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b77e3a52cd84d0f7f18554afa8060cfe564ccac61e3b0802d3fd4084772fa5f6" +checksum = "ffaed4f9a234ba5225d8e64eac7b4a5d13b994aeb37353cde2cbeb3febda9eaa" dependencies = [ "addr2line 0.17.0", "anyhow", @@ -12890,20 +12995,20 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0245e8a9347017c7185a72e215218a802ff561545c242953c11ba00fccc930f" +checksum = "eed41cbcbf74ce3ff6f1d07d1b707888166dc408d1a880f651268f4f7c9194b2" dependencies = [ "object 0.29.0", "once_cell", - "rustix", + "rustix 0.36.13", ] [[package]] name = "wasmtime-jit-icache-coherence" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67d412e9340ab1c83867051d8d1d7c90aa8c9afc91da086088068e2734e25064" +checksum = "43a28ae1e648461bfdbb79db3efdaee1bca5b940872e4175390f465593a2e54c" dependencies = [ "cfg-if", "libc", @@ -12912,9 +13017,9 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d594e791b5fdd4dbaf8cf7ae62f2e4ff85018ce90f483ca6f42947688e48827d" +checksum = "e704b126e4252788ccfc3526d4d4511d4b23c521bf123e447ac726c14545217b" dependencies = [ "anyhow", "cc", @@ -12927,7 +13032,7 @@ dependencies = [ "memoffset 0.6.5", "paste", "rand 0.8.5", - "rustix", + "rustix 0.36.13", "wasmtime-asm-macros", "wasmtime-environ", "wasmtime-jit-debug", @@ -12936,9 +13041,9 @@ dependencies = [ [[package]] name = "wasmtime-types" -version = "6.0.1" +version = "6.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6688d6f96d4dbc1f89fab626c56c1778936d122b5f4ae7a57c2eb42b8d982e2" +checksum = "83e5572c5727c1ee7e8f28717aaa8400e4d22dcbd714ea5457d85b5005206568" dependencies = [ "cranelift-entity", "serde", @@ -13011,7 +13116,7 @@ dependencies = [ "sha2 0.10.6", "stun", "thiserror", - "time 0.3.20", + "time 0.3.21", "tokio", "turn", "url", @@ -13121,18 +13226,15 @@ dependencies = [ [[package]] name = "webrtc-media" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee2a3c157a040324e5049bcbd644ffc9079e6738fa2cfab2bcff64e5cc4c00d7" +checksum = "f72e1650a8ae006017d1a5280efb49e2610c19ccc3c0905b03b648aee9554991" dependencies = [ "byteorder", "bytes", - "derive_builder", - "displaydoc", "rand 0.8.5", "rtp", "thiserror", - "webrtc-util", ] [[package]] @@ -13183,7 +13285,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93f1db1727772c05cf7a2cfece52c3aca8045ca1e176cd517d323489aa3c6d87" dependencies = [ "async-trait", - "bitflags 1.3.2", + "bitflags", "bytes", "cc", "ipnet", @@ -13374,18 +13476,27 @@ dependencies = [ "windows_x86_64_msvc 0.34.0", ] +[[package]] +name = "windows" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" +dependencies = [ + "windows-targets 0.48.0", +] + [[package]] name = "windows-sys" version = "0.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" dependencies = [ - "windows_aarch64_gnullvm", + "windows_aarch64_gnullvm 0.42.2", "windows_aarch64_msvc 0.42.2", "windows_i686_gnu 0.42.2", "windows_i686_msvc 0.42.2", "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm", + "windows_x86_64_gnullvm 0.42.2", "windows_x86_64_msvc 0.42.2", ] @@ -13395,7 +13506,16 @@ version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" dependencies = [ - "windows-targets", + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.0", ] [[package]] @@ -13404,21 +13524,42 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ - "windows_aarch64_gnullvm", + "windows_aarch64_gnullvm 0.42.2", "windows_aarch64_msvc 0.42.2", "windows_i686_gnu 0.42.2", "windows_i686_msvc 0.42.2", "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm", + "windows_x86_64_gnullvm 0.42.2", "windows_x86_64_msvc 0.42.2", ] +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", +] + [[package]] name = "windows_aarch64_gnullvm" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + [[package]] name = "windows_aarch64_msvc" version = "0.34.0" @@ -13431,6 +13572,12 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + [[package]] name = "windows_i686_gnu" version = "0.34.0" @@ -13443,6 +13590,12 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + [[package]] name = "windows_i686_msvc" version = "0.34.0" @@ -13455,6 +13608,12 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + [[package]] name = "windows_x86_64_gnu" version = "0.34.0" @@ -13467,12 +13626,24 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + [[package]] name = "windows_x86_64_gnullvm" version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + [[package]] name = "windows_x86_64_msvc" version = "0.34.0" @@ -13485,11 +13656,17 @@ version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + [[package]] name = "winnow" -version = "0.3.6" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d020b441f92996c80d94ae9166e8501e59c7bb56121189dc9eab3bd8216966" +checksum = "61de7bac303dc551fe038e2b3cef0f571087a47571ea6e79a87692ac99b99699" dependencies = [ "memchr", ] @@ -13550,7 +13727,7 @@ dependencies = [ "ring", "rusticata-macros", "thiserror", - "time 0.3.20", + "time 0.3.21", ] [[package]] @@ -13568,7 +13745,7 @@ dependencies = [ "oid-registry 0.6.1", "rusticata-macros", "thiserror", - "time 0.3.20", + "time 0.3.21", ] [[package]] @@ -13655,32 +13832,31 @@ dependencies = [ [[package]] name = "yasna" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aed2e7a52e3744ab4d0c05c20aa065258e84c49fd4226f5191b2ed29712710b4" +checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" dependencies = [ - "time 0.3.20", + "time 0.3.21", ] [[package]] name = "zeroize" -version = "1.5.7" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" dependencies = [ "zeroize_derive", ] [[package]] name = "zeroize_derive" -version = "1.3.3" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44bf07cb3e50ea2003396695d58bf46bc9887a1f362260446fad6bc4e79bd36c" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", - "synstructure", + "syn 2.0.15", ] [[package]] @@ -13704,9 +13880,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.7+zstd.1.5.4" +version = "2.0.8+zstd.1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94509c3ba2fe55294d752b79842c530ccfab760192521df74a081a78d2b3c7f5" +checksum = "5556e6ee25d32df2586c098bbfa278803692a20d0ab9565e049480d52707ec8c" dependencies = [ "cc", "libc", diff --git a/pallets/delegation/src/lib.rs b/pallets/delegation/src/lib.rs index 0e480e1b0..bf7ee44fe 100644 --- a/pallets/delegation/src/lib.rs +++ b/pallets/delegation/src/lib.rs @@ -1001,7 +1001,7 @@ pub mod pallet { // check if node is in part of a delegation hierachy. ensure!( DelegationHierarchies::::contains_key(hierachy_id), - DispatchError::Other("Test") + DispatchError::Other("Test1") ); let children_count = DelegationNodes::::iter_values() @@ -1010,16 +1010,16 @@ pub mod pallet { match delegation_details.parent { // If node is a leaf or intermediate, check if it occures only once. Otherwise we have cylces. - Some(_) => ensure!(children_count <= 1 , DispatchError::Other("Test")), + Some(_) => ensure!(children_count <= 1 , DispatchError::Other("Test2")), // if parent is None, check that the root is not the children // from another node. - _ => ensure!(children_count == 0 , DispatchError::Other("Test")) + _ => ensure!(children_count == 0 , DispatchError::Other("Test3")) }; // if a node is revoked, his subtree should be revoked as well. if delegation_details.details.revoked { let is_subtree_revoked = get_merged_subtree::(delegation_details).iter().map(|child : &DelegationNode| {child.details.revoked }).all(|x| x); - ensure!(is_subtree_revoked, DispatchError::Other("Test")); + ensure!(is_subtree_revoked, DispatchError::Other("Test4")); } Ok(()) }, diff --git a/pallets/delegation/src/tests.rs b/pallets/delegation/src/tests.rs index f3885b833..7fc4c7850 100644 --- a/pallets/delegation/src/tests.rs +++ b/pallets/delegation/src/tests.rs @@ -1843,7 +1843,8 @@ fn is_delegating_max_parent_revoked() { parent_node.details.revoked = true; let delegation_id = delegation_id_from_seed::(DELEGATION_ID_SEED_2); - let delegation_node = generate_base_delegation_node(hierarchy_root_id, user_3, Some(parent_id), ACCOUNT_01); + let mut delegation_node = generate_base_delegation_node(hierarchy_root_id, user_3, Some(parent_id), ACCOUNT_01); + delegation_node.details.revoked = true; let max_parent_checks = 2u32; From 0ed097125d2235241671b9233958fb645df73204 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Tue, 9 May 2023 17:05:59 +0200 Subject: [PATCH 26/40] first fixes --- pallets/attestation/src/lib.rs | 13 +++---- pallets/delegation/src/lib.rs | 46 +++++++++++------------- pallets/did/src/lib.rs | 12 +++---- pallets/pallet-did-lookup/src/lib.rs | 17 ++++----- pallets/pallet-web3-names/src/lib.rs | 10 +++--- pallets/parachain-staking/src/lib.rs | 50 ++++++++++++++------------- pallets/public-credentials/src/lib.rs | 10 +++--- 7 files changed, 72 insertions(+), 86 deletions(-) diff --git a/pallets/attestation/src/lib.rs b/pallets/attestation/src/lib.rs index 86118af92..dbee418b2 100644 --- a/pallets/attestation/src/lib.rs +++ b/pallets/attestation/src/lib.rs @@ -473,19 +473,16 @@ pub mod pallet { } #[cfg(any(feature = "try-runtime", test))] - pub fn do_try_state() -> DispatchResult { - Attestations::::iter().try_for_each(|(claim_hash, attestation_details)| -> DispatchResult { + pub fn do_try_state() -> Result<(), &'static str> { + Attestations::::iter().try_for_each(|(claim_hash, attestation_details)| -> Result<(), &'static str> { if let Some(authorization_id) = attestation_details.authorization_id { ensure!( - ExternalAttestations::::contains_key(authorization_id, claim_hash), + ExternalAttestations::::get(authorization_id, claim_hash), DispatchError::Other("Test") - ); - } else { - return Ok(()); + ) } Ok(()) - })?; - Ok(()) + }) } } diff --git a/pallets/delegation/src/lib.rs b/pallets/delegation/src/lib.rs index bf7ee44fe..685147723 100644 --- a/pallets/delegation/src/lib.rs +++ b/pallets/delegation/src/lib.rs @@ -87,7 +87,7 @@ use frame_support::{ use kilt_support::traits::StorageDepositCollector; use parity_scale_codec::Encode; use sp_runtime::{traits::Hash, DispatchError}; -use sp_std::{marker::PhantomData, vec, vec::Vec}; +use sp_std::{marker::PhantomData, vec::Vec}; #[frame_support::pallet] pub mod pallet { @@ -976,32 +976,29 @@ pub mod pallet { } #[cfg(any(feature = "try-runtime", test))] - pub fn do_try_state() -> DispatchResult { - fn get_merged_subtree(node: DelegationNode) -> Vec> { - let mut nodes_to_explore = vec![node]; - let mut children: Vec> = vec![]; - while !nodes_to_explore.is_empty() { - let current_node = nodes_to_explore.pop().unwrap(); - let child_nodes: Vec> = current_node - .children - .iter() - .filter_map(DelegationNodes::::get) - .collect(); + pub fn do_try_state() -> Result<(), &'static str> { + + + fn get_merged_subtree(node: DelegationNode) -> sp_std::vec::Vec> { + let mut nodes_to_explore = sp_std::vec::Vec::from([node]); + let mut children = sp_std::vec::Vec::new(); + while let Some(current_node) = nodes_to_explore.pop() { + let child_nodes = current_node.children.iter().filter_map(DelegationNodes::::get); nodes_to_explore.extend(child_nodes.clone()); children.extend(child_nodes); } - children } DelegationNodes::::iter().try_for_each( - |(delegation_node_id, delegation_details): (DelegationNodeIdOf, DelegationNode)| -> DispatchResult { - let hierachy_id = delegation_details.hierarchy_root_id; + |(delegation_node_id, delegation_details): (DelegationNodeIdOf, DelegationNode)| -> Result<(), &'static str> { + let hierarchy_id = delegation_details.hierarchy_root_id; + - // check if node is in part of a delegation hierachy. + // check if node is in part of a delegation hierarchy. ensure!( - DelegationHierarchies::::contains_key(hierachy_id), - DispatchError::Other("Test1") + DelegationHierarchies::::contains_key(hierarchy_id), + DispatchError::Other("Test") ); let children_count = DelegationNodes::::iter_values() @@ -1009,22 +1006,21 @@ pub mod pallet { .count(); match delegation_details.parent { - // If node is a leaf or intermediate, check if it occures only once. Otherwise we have cylces. - Some(_) => ensure!(children_count <= 1 , DispatchError::Other("Test2")), + // If node is a leaf or intermediate, check if it occurs only once. Otherwise we have cycles. + Some(_) => ensure!(children_count <= 1 , DispatchError::Other("Test")), // if parent is None, check that the root is not the children // from another node. - _ => ensure!(children_count == 0 , DispatchError::Other("Test3")) + _ => ensure!(children_count == 0 , DispatchError::Other("Test")) }; // if a node is revoked, his subtree should be revoked as well. if delegation_details.details.revoked { - let is_subtree_revoked = get_merged_subtree::(delegation_details).iter().map(|child : &DelegationNode| {child.details.revoked }).all(|x| x); - ensure!(is_subtree_revoked, DispatchError::Other("Test4")); + let is_subtree_revoked = get_merged_subtree::(delegation_details).iter().map(|child : &DelegationNode| child.details.revoked).all(|x| x); + ensure!(is_subtree_revoked, DispatchError::Other("Test")); } Ok(()) }, - )?; - Ok(()) + ) } } diff --git a/pallets/did/src/lib.rs b/pallets/did/src/lib.rs index 8ee6ef184..c3db7f6e3 100644 --- a/pallets/did/src/lib.rs +++ b/pallets/did/src/lib.rs @@ -1238,10 +1238,10 @@ pub mod pallet { } #[cfg(any(feature = "try-runtime", test))] - pub fn do_try_state() -> DispatchResult { + pub fn do_try_state() -> Result<(), &'static str> { Did::::iter().try_for_each( - |(did_subject, did_details): (DidIdentifierOf, DidDetails)| -> DispatchResult { - let service_endpoints_count: usize = ServiceEndpoints::::iter_prefix(&did_subject).count(); + |(did_subject, did_details): (DidIdentifierOf, DidDetails)| -> Result<(), &'static str> { + let service_endpoints_count = ServiceEndpoints::::iter_prefix(&did_subject).count(); ensure!( service_endpoints_count == DidEndpointsCount::::get(&did_subject).saturated_into::(), @@ -1269,15 +1269,13 @@ pub mod pallet { }, )?; - DidBlacklist::::iter_keys().try_for_each(|deleted_did_subject| -> DispatchResult { + DidBlacklist::::iter_keys().try_for_each(|deleted_did_subject| -> Result<(), &'static str> { let service_endpoints_count = ServiceEndpoints::::iter_prefix(&deleted_did_subject).count(); ensure!(service_endpoints_count == 0, DispatchError::Other("Test")); Ok(()) - })?; - - Ok(()) + }) } } diff --git a/pallets/pallet-did-lookup/src/lib.rs b/pallets/pallet-did-lookup/src/lib.rs index 95379ad35..0b4d4ece5 100644 --- a/pallets/pallet-did-lookup/src/lib.rs +++ b/pallets/pallet-did-lookup/src/lib.rs @@ -194,7 +194,6 @@ pub mod pallet { impl Hooks> for Pallet { #[cfg(feature = "try-runtime")] fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { - #[cfg(feature = "try-runtime")] Self::do_try_state()?; Ok(()) } @@ -433,16 +432,14 @@ pub mod pallet { } #[cfg(any(feature = "try-runtime", test))] - pub fn do_try_state() -> DispatchResult { - ConnectedDids::::iter().try_for_each(|(account, record)| -> DispatchResult { - let is_in_connected_accounts = ConnectedAccounts::::contains_key(record.did, account); - - ensure!(is_in_connected_accounts, DispatchError::Other("Test")); - + pub fn do_try_state() -> Result<(), &'static str> { + ConnectedDids::::iter().try_for_each(|(account, record)| -> Result<(), &'static str> { + ensure!( + ConnectedAccounts::::contains_key(record.did, account), + DispatchError::Other("Test") + ); Ok(()) - })?; - - Ok(()) + }) } } diff --git a/pallets/pallet-web3-names/src/lib.rs b/pallets/pallet-web3-names/src/lib.rs index f04695cb9..e7e05af01 100644 --- a/pallets/pallet-web3-names/src/lib.rs +++ b/pallets/pallet-web3-names/src/lib.rs @@ -504,10 +504,10 @@ pub mod pallet { } #[cfg(any(feature = "try-runtime", test))] - pub fn do_try_state() -> DispatchResult { + pub fn do_try_state() -> Result<(), &'static str> { // check if for each owner there is a name stored. Owner::::iter().try_for_each( - |(w3n, ownership): (Web3NameOf, Web3OwnershipOf)| -> DispatchResult { + |(w3n, ownership): (Web3NameOf, Web3OwnershipOf)| -> Result<(), &'static str> { ensure!( Names::::contains_key(ownership.owner.clone()), DispatchError::Other("Test") @@ -521,12 +521,10 @@ pub mod pallet { }, )?; // a banned name should have no owner. - Banned::::iter_keys().try_for_each(|banned_w3n| -> DispatchResult { + Banned::::iter_keys().try_for_each(|banned_w3n| -> Result<(), &'static str> { ensure!(!Owner::::contains_key(banned_w3n), DispatchError::Other("Test")); Ok(()) - })?; - - Ok(()) + }) } } diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index 2e606a068..e6032cca9 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -1279,7 +1279,7 @@ pub mod pallet { ); // we don't unlock immediately - Self::prep_unstake(&collator, less, false)?; // if we prepare unstake + Self::prep_unstake(&collator, less, false)?; let n = if state.is_active() { Self::update_top_candidates( @@ -1765,9 +1765,9 @@ pub mod pallet { impl Pallet { #[cfg(any(feature = "try-runtime", test))] - pub fn do_try_state() -> DispatchResult { + pub fn do_try_state() -> Result<(), &'static str> { CandidatePool::::iter_values().try_for_each( - |candidate: Candidate, _>| -> DispatchResult { + |candidate: Candidate, _>| -> Result<(), &'static str> { let sum_delegations: BalanceOf = candidate .delegators .iter() @@ -1797,7 +1797,7 @@ pub mod pallet { candidate .delegators .iter() - .try_for_each(|delegator_stake| -> DispatchResult { + .try_for_each(|delegator_stake| -> Result<(), &'static str> { let last_delegation = LastDelegation::::get(&delegator_stake.owner); let round = Round::::get(); let counter = if last_delegation.round < round.current { @@ -1829,7 +1829,7 @@ pub mod pallet { candidate .delegators .iter() - .try_for_each(|delegator_stake| -> DispatchResult { + .try_for_each(|delegator_stake| -> Result<(), &'static str> { ensure!( delegator_stake.amount >= T::MinDelegatorStake::get(), DispatchError::Other("Tests") @@ -1855,27 +1855,29 @@ pub mod pallet { DispatchError::Other("Tests") ); - top_candidates.iter().try_for_each(|stake| -> DispatchResult { - // top candidates should be part of the candidate pool. - ensure!( - CandidatePool::::contains_key(stake.clone().owner), - DispatchError::Other("Tests") - ); + top_candidates + .iter() + .try_for_each(|stake| -> Result<(), &'static str> { + // top candidates should be part of the candidate pool. + ensure!( + CandidatePool::::contains_key(&stake.owner), + DispatchError::Other("Tests") + ); - // an account can not be candidate and delegator. - ensure!( - DelegatorState::::get(&stake.owner).is_none(), - DispatchError::Other("Tests") - ); + // an account can not be candidate and delegator. + ensure!( + DelegatorState::::get(&stake.owner).is_none(), + DispatchError::Other("Tests") + ); - // a top candidate should be active. - ensure!( - Self::is_active_candidate(&stake.owner).unwrap(), - DispatchError::Other("Tests") - ); + // a top candidate should be active. + ensure!( + Self::is_active_candidate(&stake.owner).unwrap(), + DispatchError::Other("Tests") + ); - Ok(()) - })?; + Ok(()) + })?; // the total fund has to be the sum over the first [MaxSelectedCandidates] of // [TopCandidates]. @@ -2531,7 +2533,7 @@ pub mod pallet { collators: total_collators, .. } = TotalCollatorStake::::get(); - let staking_rate = Perquintill::from_rational(total_collators, total_issuance); // why staking rate? + let staking_rate = Perquintill::from_rational(total_collators, total_issuance); InflationConfig::::get() .collator diff --git a/pallets/public-credentials/src/lib.rs b/pallets/public-credentials/src/lib.rs index b729b6937..30abee2ca 100644 --- a/pallets/public-credentials/src/lib.rs +++ b/pallets/public-credentials/src/lib.rs @@ -596,16 +596,16 @@ pub mod pallet { } #[cfg(any(feature = "try-runtime", test))] - pub fn do_try_state() -> DispatchResult { + pub fn do_try_state() -> Result<(), &'static str> { // check if for each owner there is a name stored. - Credentials::::iter().try_for_each(|(subject_id, credential_id, entry)| -> DispatchResult { + Credentials::::iter().try_for_each(|(subject_id, credential_id, entry)| -> Result<(), &'static str> { ensure!( CredentialSubjects::::contains_key(&credential_id), DispatchError::Other("Test") ); ensure!( - CredentialSubjects::::get(&credential_id).unwrap() == subject_id, + CredentialSubjects::::get(&credential_id) == Some(subject_id), DispatchError::Other("Test") ); @@ -615,9 +615,7 @@ pub mod pallet { ); Ok(()) - })?; - - Ok(()) + }) } } From f61632b7096c114c1543e6d3b30bb40013005ba9 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 10 May 2023 14:21:34 +0200 Subject: [PATCH 27/40] refactor --- pallets/attestation/src/lib.rs | 2 +- pallets/delegation/src/lib.rs | 8 +- pallets/did/src/lib.rs | 15 +- pallets/pallet-did-lookup/src/lib.rs | 2 +- pallets/pallet-web3-names/src/lib.rs | 22 +-- pallets/parachain-staking/src/lib.rs | 148 +------------------ pallets/parachain-staking/src/try_state.rs | 159 +++++++++++++++++++++ pallets/public-credentials/src/lib.rs | 32 +++-- 8 files changed, 207 insertions(+), 181 deletions(-) create mode 100644 pallets/parachain-staking/src/try_state.rs diff --git a/pallets/attestation/src/lib.rs b/pallets/attestation/src/lib.rs index dbee418b2..5553dfa61 100644 --- a/pallets/attestation/src/lib.rs +++ b/pallets/attestation/src/lib.rs @@ -478,7 +478,7 @@ pub mod pallet { if let Some(authorization_id) = attestation_details.authorization_id { ensure!( ExternalAttestations::::get(authorization_id, claim_hash), - DispatchError::Other("Test") + "Unknown external attestation" ) } Ok(()) diff --git a/pallets/delegation/src/lib.rs b/pallets/delegation/src/lib.rs index 685147723..2f6df7d99 100644 --- a/pallets/delegation/src/lib.rs +++ b/pallets/delegation/src/lib.rs @@ -998,7 +998,7 @@ pub mod pallet { // check if node is in part of a delegation hierarchy. ensure!( DelegationHierarchies::::contains_key(hierarchy_id), - DispatchError::Other("Test") + "Unknown hierarchy" ); let children_count = DelegationNodes::::iter_values() @@ -1007,16 +1007,16 @@ pub mod pallet { match delegation_details.parent { // If node is a leaf or intermediate, check if it occurs only once. Otherwise we have cycles. - Some(_) => ensure!(children_count <= 1 , DispatchError::Other("Test")), + Some(_) => ensure!(children_count <= 1 , "Cycles detected"), // if parent is None, check that the root is not the children // from another node. - _ => ensure!(children_count == 0 , DispatchError::Other("Test")) + _ => ensure!(children_count == 0 , "Root node is intermediate") }; // if a node is revoked, his subtree should be revoked as well. if delegation_details.details.revoked { let is_subtree_revoked = get_merged_subtree::(delegation_details).iter().map(|child : &DelegationNode| child.details.revoked).all(|x| x); - ensure!(is_subtree_revoked, DispatchError::Other("Test")); + ensure!(is_subtree_revoked, "Subtree not revoked"); } Ok(()) }, diff --git a/pallets/did/src/lib.rs b/pallets/did/src/lib.rs index c3db7f6e3..fde6262f8 100644 --- a/pallets/did/src/lib.rs +++ b/pallets/did/src/lib.rs @@ -1245,25 +1245,22 @@ pub mod pallet { ensure!( service_endpoints_count == DidEndpointsCount::::get(&did_subject).saturated_into::(), - DispatchError::Other("Test") + "Unequal service endpoint" ); ensure!( did_details.key_agreement_keys.len() <= ::MaxTotalKeyAgreementKeys::get().saturated_into::(), - DispatchError::Other("Test") + "Exceeded key agreements" ); ensure!( service_endpoints_count <= ::MaxNumberOfServicesPerDid::get().saturated_into::(), - DispatchError::Other("Test") + "Exceeded service endpoints" ); - ensure!( - !DidBlacklist::::contains_key(did_subject), - DispatchError::Other("Test") - ); + ensure!(!DidBlacklist::::contains_key(did_subject), "Blacklisted did"); Ok(()) }, @@ -1271,9 +1268,7 @@ pub mod pallet { DidBlacklist::::iter_keys().try_for_each(|deleted_did_subject| -> Result<(), &'static str> { let service_endpoints_count = ServiceEndpoints::::iter_prefix(&deleted_did_subject).count(); - - ensure!(service_endpoints_count == 0, DispatchError::Other("Test")); - + ensure!(service_endpoints_count == 0, "Blacklisted did contains services"); Ok(()) }) } diff --git a/pallets/pallet-did-lookup/src/lib.rs b/pallets/pallet-did-lookup/src/lib.rs index 0b4d4ece5..87204304c 100644 --- a/pallets/pallet-did-lookup/src/lib.rs +++ b/pallets/pallet-did-lookup/src/lib.rs @@ -436,7 +436,7 @@ pub mod pallet { ConnectedDids::::iter().try_for_each(|(account, record)| -> Result<(), &'static str> { ensure!( ConnectedAccounts::::contains_key(record.did, account), - DispatchError::Other("Test") + "Did lookup: Connected accounts is not matching with connected did." ); Ok(()) }) diff --git a/pallets/pallet-web3-names/src/lib.rs b/pallets/pallet-web3-names/src/lib.rs index e7e05af01..9ec5f8da2 100644 --- a/pallets/pallet-web3-names/src/lib.rs +++ b/pallets/pallet-web3-names/src/lib.rs @@ -508,21 +508,23 @@ pub mod pallet { // check if for each owner there is a name stored. Owner::::iter().try_for_each( |(w3n, ownership): (Web3NameOf, Web3OwnershipOf)| -> Result<(), &'static str> { - ensure!( - Names::::contains_key(ownership.owner.clone()), - DispatchError::Other("Test") - ); - - ensure!( - Names::::get(ownership.owner).unwrap() == w3n, - DispatchError::Other("Test") - ); + ensure!(Names::::contains_key(ownership.owner.clone()), "W3n unknown"); + ensure!(Names::::get(ownership.owner) == Some(w3n), "Unequal w3n"); + Ok(()) + }, + )?; + + // check for each name there is an owner. + Names::::iter().try_for_each( + |(w3n_owner, w3n): (Web3NameOwnerOf, Web3NameOf)| -> Result<(), &'static str> { + ensure!(Owner::::contains_key(&w3n), "Owner unknown"); + ensure!(Owner::::get(w3n).unwrap().owner == w3n_owner, "Unequal owner"); Ok(()) }, )?; // a banned name should have no owner. Banned::::iter_keys().try_for_each(|banned_w3n| -> Result<(), &'static str> { - ensure!(!Owner::::contains_key(banned_w3n), DispatchError::Other("Test")); + ensure!(!Owner::::contains_key(banned_w3n), "W3n: Banned name is owned."); Ok(()) }) } diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index e6032cca9..a01c6672d 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -125,6 +125,9 @@ pub(crate) mod mock; #[cfg(test)] pub(crate) mod tests; +#[cfg(any(feature = "try-runtime", test))] +mod try_state; + pub mod api; mod inflation; mod set; @@ -1766,148 +1769,9 @@ pub mod pallet { impl Pallet { #[cfg(any(feature = "try-runtime", test))] pub fn do_try_state() -> Result<(), &'static str> { - CandidatePool::::iter_values().try_for_each( - |candidate: Candidate, _>| -> Result<(), &'static str> { - let sum_delegations: BalanceOf = candidate - .delegators - .iter() - .fold(Zero::zero(), |acc, stake| acc.saturating_add(stake.amount)); - - // total stake should be the sum of delegators stake + colator stake. - ensure!( - sum_delegations.saturating_add(candidate.stake) == candidate.total, - DispatchError::Other("Tests") - ); - - // Min required stake should be set - ensure!( - candidate.stake >= T::MinCollatorCandidateStake::get(), - DispatchError::Other("Tests") - ); - - // delegators should be in delegator pool. - let are_delegator_present = candidate - .delegators - .iter() - .map(|delegator_stake| DelegatorState::::get(&delegator_stake.owner).is_some()) - .all(|x| x); - ensure!(are_delegator_present, DispatchError::Other("Tests")); - - // each delegator should not exceed the [MaxDelegationsPerRound] - candidate - .delegators - .iter() - .try_for_each(|delegator_stake| -> Result<(), &'static str> { - let last_delegation = LastDelegation::::get(&delegator_stake.owner); - let round = Round::::get(); - let counter = if last_delegation.round < round.current { - 0u32 - } else { - last_delegation.counter - }; - - ensure!( - counter <= T::MaxDelegationsPerRound::get(), - DispatchError::Other("Tests") - ); - - Ok(()) - })?; - - // check min and max stake for each candidate - ensure!( - candidate.stake <= MaxCollatorCandidateStake::::get(), - DispatchError::Other("Tests") - ); - - ensure!( - candidate.stake >= T::MinCollatorStake::get(), - DispatchError::Other("Tests") - ); - - // delegators should have the min required stake. - candidate - .delegators - .iter() - .try_for_each(|delegator_stake| -> Result<(), &'static str> { - ensure!( - delegator_stake.amount >= T::MinDelegatorStake::get(), - DispatchError::Other("Tests") - ); - Ok(()) - })?; - - Ok(()) - }, - )?; - - // check if enough collators are set. - ensure!( - CandidatePool::::count() >= T::MinCollators::get(), - DispatchError::Other("Tests") - ); - - let top_candidates = TopCandidates::::get(); - - // check if enough top candidates are set. - ensure!( - top_candidates.len() >= T::MinRequiredCollators::get().saturated_into(), - DispatchError::Other("Tests") - ); - - top_candidates - .iter() - .try_for_each(|stake| -> Result<(), &'static str> { - // top candidates should be part of the candidate pool. - ensure!( - CandidatePool::::contains_key(&stake.owner), - DispatchError::Other("Tests") - ); - - // an account can not be candidate and delegator. - ensure!( - DelegatorState::::get(&stake.owner).is_none(), - DispatchError::Other("Tests") - ); - - // a top candidate should be active. - ensure!( - Self::is_active_candidate(&stake.owner).unwrap(), - DispatchError::Other("Tests") - ); - - Ok(()) - })?; - - // the total fund has to be the sum over the first [MaxSelectedCandidates] of - // [TopCandidates]. - - let top_n = MaxSelectedCandidates::::get().saturated_into::(); - - let total_stake = TotalCollatorStake::::get(); - - let collator_delegator_stake = top_candidates - .iter() - .take(top_n) - .fold(Zero::zero(), |acc: BalanceOf, details| { - acc.saturating_add(details.amount) - }); - - let collator_stake = top_candidates - .iter() - .take(top_n) - .filter_map(|stake| CandidatePool::::get(&stake.owner)) - .fold(Zero::zero(), |acc: BalanceOf, candidate| { - acc.saturating_add(candidate.stake) - }); - - let delegator_state = collator_delegator_stake.saturating_sub(collator_stake); - - ensure!(total_stake.collators == collator_stake, DispatchError::Other("Tests")); - - ensure!(total_stake.delegators == delegator_state, DispatchError::Other("Tests")); - - Ok(()) + crate::try_state::validate_candiate_pool::()?; + crate::try_state::validate_top_candidates::()?; + crate::try_state::validate_stake::() } /// Check whether an account is currently delegating. diff --git a/pallets/parachain-staking/src/try_state.rs b/pallets/parachain-staking/src/try_state.rs new file mode 100644 index 000000000..b28ab1de3 --- /dev/null +++ b/pallets/parachain-staking/src/try_state.rs @@ -0,0 +1,159 @@ +use frame_support::{ensure, traits::Get}; +use sp_runtime::{traits::Zero, SaturatedConversion, Saturating}; + +use crate::{ + types::{BalanceOf, Candidate}, + CandidatePool, Config, DelegatorState, LastDelegation, MaxCollatorCandidateStake, MaxSelectedCandidates, Pallet, + Round, TopCandidates, TotalCollatorStake, +}; + +pub fn validate_candiate_pool() -> Result<(), &'static str> { + // check if enough collators are set. + ensure!( + CandidatePool::::count() >= T::MinCollators::get(), + "Staking: Not enough collators are present." + ); + + CandidatePool::::iter_values().try_for_each( + |candidate: Candidate, _>| -> Result<(), &'static str> { + let sum_delegations: BalanceOf = candidate + .delegators + .iter() + .fold(Zero::zero(), |acc, stake| acc.saturating_add(stake.amount)); + + // total stake should be the sum of delegators stake + colator stake. + ensure!( + sum_delegations.saturating_add(candidate.stake) == candidate.total, + "Staking: Total stake of a collator can not be reconstructed." + ); + + // Min required stake should be set + ensure!( + candidate.stake >= T::MinCollatorCandidateStake::get(), + "Staking: Insufficient stake from a collator." + ); + + // delegators should be in delegator pool. + let are_delegator_present = candidate + .delegators + .iter() + .map(|delegator_stake| DelegatorState::::get(&delegator_stake.owner).is_some()) + .all(|x| x); + ensure!(are_delegator_present, "Staking: Delegator is not present"); + + // each delegator should not exceed the [MaxDelegationsPerRound] + candidate + .delegators + .iter() + .try_for_each(|delegator_stake| -> Result<(), &'static str> { + let last_delegation = LastDelegation::::get(&delegator_stake.owner); + let round = Round::::get(); + let counter = if last_delegation.round < round.current { + 0u32 + } else { + last_delegation.counter + }; + + ensure!( + counter <= T::MaxDelegationsPerRound::get(), + "Staking: Exceeded delegations per round by a collator." + ); + + Ok(()) + })?; + + // check min and max stake for each candidate + ensure!( + candidate.stake <= MaxCollatorCandidateStake::::get(), + "Staking: Exceeded stake by a collator." + ); + + ensure!( + candidate.stake >= T::MinCollatorStake::get(), + "Staking: Lag behind stake by a collator." + ); + + // delegators should have the min required stake. + candidate + .delegators + .iter() + .try_for_each(|delegator_stake| -> Result<(), &'static str> { + ensure!( + delegator_stake.amount >= T::MinDelegatorStake::get(), + "Staking: Lag behind stake of a delegator" + ); + Ok(()) + })?; + + Ok(()) + }, + ) +} + +pub fn validate_top_candidates() -> Result<(), &'static str> { + let top_candidates = TopCandidates::::get(); + + // check if enough top candidates are set. + ensure!( + top_candidates.len() >= T::MinRequiredCollators::get().saturated_into(), + "Insufficient collators" + ); + + top_candidates.iter().try_for_each(|stake| -> Result<(), &'static str> { + // top candidates should be part of the candidate pool. + ensure!(CandidatePool::::contains_key(&stake.owner), "Unknown candidate"); + + // an account can not be candidate and delegator. + ensure!( + DelegatorState::::get(&stake.owner).is_none(), + "Account is candidate and delegator." + ); + + // a top candidate should be active. + ensure!( + Pallet::::is_active_candidate(&stake.owner).unwrap(), + "Inactive candidate" + ); + + Ok(()) + }) +} + +pub fn validate_stake() -> Result<(), &'static str> { + // the total fund has to be the sum over the first [MaxSelectedCandidates] of + // [TopCandidates]. + + let top_candidates = TopCandidates::::get(); + let top_n = MaxSelectedCandidates::::get().saturated_into::(); + + let total_stake = TotalCollatorStake::::get(); + + let collator_delegator_stake = top_candidates + .iter() + .take(top_n) + .fold(Zero::zero(), |acc: BalanceOf, details| { + acc.saturating_add(details.amount) + }); + + let collator_stake = top_candidates + .iter() + .take(top_n) + .filter_map(|stake| CandidatePool::::get(&stake.owner)) + .fold(Zero::zero(), |acc: BalanceOf, candidate| { + acc.saturating_add(candidate.stake) + }); + + let delegator_state = collator_delegator_stake.saturating_sub(collator_stake); + + ensure!( + total_stake.collators == collator_stake, + "Total collator stake not matching." + ); + + ensure!( + total_stake.delegators == delegator_state, + "Total delegator stake is not matching." + ); + + Ok(()) +} diff --git a/pallets/public-credentials/src/lib.rs b/pallets/public-credentials/src/lib.rs index 30abee2ca..8787ee1c5 100644 --- a/pallets/public-credentials/src/lib.rs +++ b/pallets/public-credentials/src/lib.rs @@ -597,23 +597,29 @@ pub mod pallet { #[cfg(any(feature = "try-runtime", test))] pub fn do_try_state() -> Result<(), &'static str> { - // check if for each owner there is a name stored. - Credentials::::iter().try_for_each(|(subject_id, credential_id, entry)| -> Result<(), &'static str> { - ensure!( - CredentialSubjects::::contains_key(&credential_id), - DispatchError::Other("Test") - ); + Credentials::::iter().try_for_each( + |(subject_id, credential_id, entry)| -> Result<(), &'static str> { + ensure!( + CredentialSubjects::::contains_key(&credential_id), + "Unknown credential subject" + ); - ensure!( - CredentialSubjects::::get(&credential_id) == Some(subject_id), - DispatchError::Other("Test") - ); + ensure!( + CredentialSubjects::::get(&credential_id) == Some(subject_id), + "Unequal credential subject" + ); + + ensure!(ctype::Ctypes::::contains_key(entry.ctype_hash), "Unknown ctype"); + Ok(()) + }, + )?; + + CredentialSubjects::::iter().try_for_each(|(credential_id, subject_id)| -> Result<(), &'static str> { ensure!( - ctype::Ctypes::::contains_key(entry.ctype_hash), - DispatchError::Other("Test") + Credentials::::contains_key(subject_id, credential_id), + "Unknown credential" ); - Ok(()) }) } From a646f743cd95e283c3d6d05f39a9bc625fe8532d Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 10 May 2023 16:21:00 +0200 Subject: [PATCH 28/40] 3 test are failing --- pallets/delegation/src/lib.rs | 31 ++++++++++++++++++++-------- pallets/delegation/src/tests.rs | 2 +- pallets/pallet-did-lookup/src/lib.rs | 13 ++++++++++-- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/pallets/delegation/src/lib.rs b/pallets/delegation/src/lib.rs index 2f6df7d99..592106df9 100644 --- a/pallets/delegation/src/lib.rs +++ b/pallets/delegation/src/lib.rs @@ -977,8 +977,6 @@ pub mod pallet { #[cfg(any(feature = "try-runtime", test))] pub fn do_try_state() -> Result<(), &'static str> { - - fn get_merged_subtree(node: DelegationNode) -> sp_std::vec::Vec> { let mut nodes_to_explore = sp_std::vec::Vec::from([node]); let mut children = sp_std::vec::Vec::new(); @@ -991,9 +989,8 @@ pub mod pallet { } DelegationNodes::::iter().try_for_each( - |(delegation_node_id, delegation_details): (DelegationNodeIdOf, DelegationNode)| -> Result<(), &'static str> { + |(delegation_node_id, delegation_details)| -> Result<(), &'static str> { let hierarchy_id = delegation_details.hierarchy_root_id; - // check if node is in part of a delegation hierarchy. ensure!( @@ -1001,21 +998,37 @@ pub mod pallet { "Unknown hierarchy" ); - let children_count = DelegationNodes::::iter_values() - .filter(|delegation_node : &DelegationNode | delegation_node.children.contains(&delegation_node_id)) + delegation_details + .children + .iter() + .try_for_each(|child_node| -> Result<(), &'static str> { + ensure!( + DelegationNodes::::contains_key(child_node), + "Unknown delegation node" + ); + Ok(()) + })?; + + let parent_count = DelegationNodes::::iter_values() + .filter(|delegation_node: &DelegationNode| { + delegation_node.children.contains(&delegation_node_id) + }) .count(); match delegation_details.parent { // If node is a leaf or intermediate, check if it occurs only once. Otherwise we have cycles. - Some(_) => ensure!(children_count <= 1 , "Cycles detected"), + Some(_) => ensure!(parent_count <= 1, "Cycles detected"), // if parent is None, check that the root is not the children // from another node. - _ => ensure!(children_count == 0 , "Root node is intermediate") + _ => ensure!(parent_count == 0, "Root node is intermediate"), }; // if a node is revoked, his subtree should be revoked as well. if delegation_details.details.revoked { - let is_subtree_revoked = get_merged_subtree::(delegation_details).iter().map(|child : &DelegationNode| child.details.revoked).all(|x| x); + let is_subtree_revoked = get_merged_subtree::(delegation_details) + .iter() + .map(|child: &DelegationNode| child.details.revoked) + .all(|x| x); ensure!(is_subtree_revoked, "Subtree not revoked"); } Ok(()) diff --git a/pallets/delegation/src/tests.rs b/pallets/delegation/src/tests.rs index 7fc4c7850..f83e859c8 100644 --- a/pallets/delegation/src/tests.rs +++ b/pallets/delegation/src/tests.rs @@ -1241,7 +1241,7 @@ fn parent_owner_revoke_delegation_successful() { let delegation_id = delegation_id_from_seed::(DELEGATION_ID_SEED_2); let delegation_node = - generate_base_delegation_node(hierarchy_root_id, delegate.clone(), Some(parent_id), ACCOUNT_01); + generate_base_delegation_node(hierarchy_root_id, delegate.clone(), Some(hierarchy_root_id), ACCOUNT_01); let mut operation = generate_base_delegation_revocation_operation(delegation_id); operation.max_parent_checks = 1u32; diff --git a/pallets/pallet-did-lookup/src/lib.rs b/pallets/pallet-did-lookup/src/lib.rs index 87204304c..d9cbdc26f 100644 --- a/pallets/pallet-did-lookup/src/lib.rs +++ b/pallets/pallet-did-lookup/src/lib.rs @@ -436,10 +436,19 @@ pub mod pallet { ConnectedDids::::iter().try_for_each(|(account, record)| -> Result<(), &'static str> { ensure!( ConnectedAccounts::::contains_key(record.did, account), - "Did lookup: Connected accounts is not matching with connected did." + "Unknown account" ); Ok(()) - }) + })?; + + ConnectedAccounts::::iter().try_for_each( + |(did_identifier, linked_account_id, _)| -> Result<(), &'static str> { + let connected_did = ConnectedDids::::get(linked_account_id); + ensure!(connected_did.is_some(), "Unknown did"); + ensure!(connected_did.unwrap().did == did_identifier, "Unequal did"); + Ok(()) + }, + ) } } From 06da8c5df64b7fa89ff9a4ba0fd14942c8947b49 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Wed, 10 May 2023 16:28:36 +0200 Subject: [PATCH 29/40] refactor --- pallets/delegation/src/lib.rs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/pallets/delegation/src/lib.rs b/pallets/delegation/src/lib.rs index 592106df9..375ece961 100644 --- a/pallets/delegation/src/lib.rs +++ b/pallets/delegation/src/lib.rs @@ -998,17 +998,6 @@ pub mod pallet { "Unknown hierarchy" ); - delegation_details - .children - .iter() - .try_for_each(|child_node| -> Result<(), &'static str> { - ensure!( - DelegationNodes::::contains_key(child_node), - "Unknown delegation node" - ); - Ok(()) - })?; - let parent_count = DelegationNodes::::iter_values() .filter(|delegation_node: &DelegationNode| { delegation_node.children.contains(&delegation_node_id) From 33ef40ce7865bbf79e17cb9ca3fc9274949e7e0b Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 11 May 2023 10:24:10 +0200 Subject: [PATCH 30/40] neutral lang --- pallets/delegation/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/delegation/src/lib.rs b/pallets/delegation/src/lib.rs index 375ece961..1c3aa9fdf 100644 --- a/pallets/delegation/src/lib.rs +++ b/pallets/delegation/src/lib.rs @@ -1012,7 +1012,7 @@ pub mod pallet { _ => ensure!(parent_count == 0, "Root node is intermediate"), }; - // if a node is revoked, his subtree should be revoked as well. + // if a node is revoked, the subtree should be revoked as well. if delegation_details.details.revoked { let is_subtree_revoked = get_merged_subtree::(delegation_details) .iter() From c4b8d05a5f80b544c1a676840f1495272c702cc6 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Thu, 11 May 2023 14:21:28 +0200 Subject: [PATCH 31/40] refactor files --- pallets/attestation/src/lib.rs | 19 ++---- pallets/attestation/src/mock.rs | 4 +- pallets/attestation/src/try_state.rs | 30 ++++++++++ pallets/delegation/src/lib.rs | 53 ++--------------- pallets/delegation/src/mock.rs | 4 +- pallets/delegation/src/try_state.rs | 65 +++++++++++++++++++++ pallets/did/src/lib.rs | 42 ++----------- pallets/did/src/mock.rs | 5 +- pallets/did/src/try_state.rs | 57 ++++++++++++++++++ pallets/pallet-did-lookup/src/lib.rs | 26 ++------- pallets/pallet-did-lookup/src/mock.rs | 4 +- pallets/pallet-did-lookup/src/try_state.rs | 38 ++++++++++++ pallets/pallet-web3-names/src/lib.rs | 32 ++-------- pallets/pallet-web3-names/src/mock.rs | 4 +- pallets/pallet-web3-names/src/try_state.rs | 46 +++++++++++++++ pallets/parachain-staking/src/lib.rs | 10 +--- pallets/parachain-staking/src/mock.rs | 2 +- pallets/parachain-staking/src/try_state.rs | 30 +++++++++- pallets/public-credentials/src/lib.rs | 35 ++--------- pallets/public-credentials/src/mock.rs | 4 +- pallets/public-credentials/src/try_state.rs | 47 +++++++++++++++ 21 files changed, 348 insertions(+), 209 deletions(-) create mode 100644 pallets/attestation/src/try_state.rs create mode 100644 pallets/delegation/src/try_state.rs create mode 100644 pallets/did/src/try_state.rs create mode 100644 pallets/pallet-did-lookup/src/try_state.rs create mode 100644 pallets/pallet-web3-names/src/try_state.rs create mode 100644 pallets/public-credentials/src/try_state.rs diff --git a/pallets/attestation/src/lib.rs b/pallets/attestation/src/lib.rs index 5553dfa61..5771e1c15 100644 --- a/pallets/attestation/src/lib.rs +++ b/pallets/attestation/src/lib.rs @@ -70,6 +70,9 @@ pub mod mock; #[cfg(feature = "runtime-benchmarks")] pub mod benchmarking; +#[cfg(any(feature = "try-runtime", test))] +mod try_state; + mod access_control; #[cfg(test)] mod tests; @@ -151,8 +154,7 @@ pub mod pallet { impl Hooks> for Pallet { #[cfg(feature = "try-runtime")] fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { - Self::do_try_state()?; - Ok(()) + crate::try_state::do_try_state::() } } @@ -471,19 +473,6 @@ pub mod pallet { ExternalAttestations::::remove(authorization_id, claim_hash); } } - - #[cfg(any(feature = "try-runtime", test))] - pub fn do_try_state() -> Result<(), &'static str> { - Attestations::::iter().try_for_each(|(claim_hash, attestation_details)| -> Result<(), &'static str> { - if let Some(authorization_id) = attestation_details.authorization_id { - ensure!( - ExternalAttestations::::get(authorization_id, claim_hash), - "Unknown external attestation" - ) - } - Ok(()) - }) - } } struct AttestationStorageDepositCollector(PhantomData); diff --git a/pallets/attestation/src/mock.rs b/pallets/attestation/src/mock.rs index aa2e6cc7c..d6c73394a 100644 --- a/pallets/attestation/src/mock.rs +++ b/pallets/attestation/src/mock.rs @@ -180,8 +180,6 @@ pub(crate) mod runtime { use ctype::{CtypeCreatorOf, CtypeEntryOf}; use kilt_support::mock::{mock_origin, SubjectId}; - use crate::Pallet; - use super::*; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -390,7 +388,7 @@ pub(crate) mod runtime { pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce()) { self.build().execute_with(|| { test(); - Pallet::::do_try_state().unwrap(); + crate::try_state::do_try_state::().expect("TODO"); }) } diff --git a/pallets/attestation/src/try_state.rs b/pallets/attestation/src/try_state.rs new file mode 100644 index 000000000..f31cdb5f2 --- /dev/null +++ b/pallets/attestation/src/try_state.rs @@ -0,0 +1,30 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::ensure; + +use crate::{Attestations, Config, ExternalAttestations}; + +pub(crate) fn do_try_state() -> Result<(), &'static str> { + Attestations::::iter().try_for_each(|(claim_hash, attestation_details)| -> Result<(), &'static str> { + if let Some(authorization_id) = attestation_details.authorization_id { + ensure!(ExternalAttestations::::get(authorization_id, claim_hash), "test") + } + Ok(()) + }) +} diff --git a/pallets/delegation/src/lib.rs b/pallets/delegation/src/lib.rs index 1c3aa9fdf..7f09d4675 100644 --- a/pallets/delegation/src/lib.rs +++ b/pallets/delegation/src/lib.rs @@ -76,6 +76,9 @@ pub mod benchmarking; #[cfg(test)] mod tests; +#[cfg(any(feature = "try-runtime", test))] +mod try_state; + pub use crate::{access_control::DelegationAc, default_weights::WeightInfo, delegation_hierarchy::*, pallet::*}; use frame_support::{ @@ -290,8 +293,7 @@ pub mod pallet { impl Hooks> for Pallet { #[cfg(feature = "try-runtime")] fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { - Self::do_try_state()?; - Ok(()) + crate::try_state::do_try_state::() } } @@ -977,52 +979,7 @@ pub mod pallet { #[cfg(any(feature = "try-runtime", test))] pub fn do_try_state() -> Result<(), &'static str> { - fn get_merged_subtree(node: DelegationNode) -> sp_std::vec::Vec> { - let mut nodes_to_explore = sp_std::vec::Vec::from([node]); - let mut children = sp_std::vec::Vec::new(); - while let Some(current_node) = nodes_to_explore.pop() { - let child_nodes = current_node.children.iter().filter_map(DelegationNodes::::get); - nodes_to_explore.extend(child_nodes.clone()); - children.extend(child_nodes); - } - children - } - - DelegationNodes::::iter().try_for_each( - |(delegation_node_id, delegation_details)| -> Result<(), &'static str> { - let hierarchy_id = delegation_details.hierarchy_root_id; - - // check if node is in part of a delegation hierarchy. - ensure!( - DelegationHierarchies::::contains_key(hierarchy_id), - "Unknown hierarchy" - ); - - let parent_count = DelegationNodes::::iter_values() - .filter(|delegation_node: &DelegationNode| { - delegation_node.children.contains(&delegation_node_id) - }) - .count(); - - match delegation_details.parent { - // If node is a leaf or intermediate, check if it occurs only once. Otherwise we have cycles. - Some(_) => ensure!(parent_count <= 1, "Cycles detected"), - // if parent is None, check that the root is not the children - // from another node. - _ => ensure!(parent_count == 0, "Root node is intermediate"), - }; - - // if a node is revoked, the subtree should be revoked as well. - if delegation_details.details.revoked { - let is_subtree_revoked = get_merged_subtree::(delegation_details) - .iter() - .map(|child: &DelegationNode| child.details.revoked) - .all(|x| x); - ensure!(is_subtree_revoked, "Subtree not revoked"); - } - Ok(()) - }, - ) + crate::try_state::do_try_state::() } } diff --git a/pallets/delegation/src/mock.rs b/pallets/delegation/src/mock.rs index eddc8ca41..bddaf71fb 100644 --- a/pallets/delegation/src/mock.rs +++ b/pallets/delegation/src/mock.rs @@ -169,7 +169,7 @@ where #[cfg(test)] pub(crate) mod runtime { - use crate::{BalanceOf, DelegateSignatureTypeOf, DelegationAc, DelegationNodeIdOf, Pallet}; + use crate::{BalanceOf, DelegateSignatureTypeOf, DelegationAc, DelegationNodeIdOf}; use super::*; @@ -516,7 +516,7 @@ pub(crate) mod runtime { pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce()) { self.build().execute_with(|| { test(); - Pallet::::do_try_state().unwrap(); + crate::try_state::do_try_state::().expect("TODO"); }) } diff --git a/pallets/delegation/src/try_state.rs b/pallets/delegation/src/try_state.rs new file mode 100644 index 000000000..88e99c2e0 --- /dev/null +++ b/pallets/delegation/src/try_state.rs @@ -0,0 +1,65 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use crate::{Config, DelegationHierarchies, DelegationNode, DelegationNodes}; +use frame_support::ensure; + +pub(crate) fn do_try_state() -> Result<(), &'static str> { + DelegationNodes::::iter().try_for_each(|(delegation_node_id, delegation_details)| -> Result<(), &'static str> { + let hierarchy_id = delegation_details.hierarchy_root_id; + + // check if node is in part of a delegation hierarchy. + ensure!( + DelegationHierarchies::::contains_key(hierarchy_id), + "Unknown hierarchy" + ); + + let parent_count = DelegationNodes::::iter_values() + .filter(|delegation_node: &DelegationNode| delegation_node.children.contains(&delegation_node_id)) + .count(); + + match delegation_details.parent { + // If node is a leaf or intermediate, check if it occurs only once. Otherwise we have cycles. + Some(_) => ensure!(parent_count <= 1, "Cycles detected"), + // if parent is None, check that the root is not the children + // from another node. + _ => ensure!(parent_count == 0, "Root node is intermediate"), + }; + + // if a node is revoked, the subtree should be revoked as well. + if delegation_details.details.revoked { + let is_subtree_revoked = get_merged_subtree::(delegation_details) + .iter() + .map(|child: &DelegationNode| child.details.revoked) + .all(|x| x); + ensure!(is_subtree_revoked, "Subtree not revoked"); + } + Ok(()) + }) +} + +fn get_merged_subtree(node: DelegationNode) -> sp_std::vec::Vec> { + let mut nodes_to_explore = sp_std::vec::Vec::from([node]); + let mut children = sp_std::vec::Vec::new(); + while let Some(current_node) = nodes_to_explore.pop() { + let child_nodes = current_node.children.iter().filter_map(DelegationNodes::::get); + nodes_to_explore.extend(child_nodes.clone()); + children.extend(child_nodes); + } + children +} diff --git a/pallets/did/src/lib.rs b/pallets/did/src/lib.rs index fde6262f8..ebcebc418 100644 --- a/pallets/did/src/lib.rs +++ b/pallets/did/src/lib.rs @@ -96,6 +96,9 @@ mod mock_utils; #[cfg(test)] mod tests; +#[cfg(any(feature = "try-runtime", test))] +mod try_state; + mod signature; mod utils; @@ -467,8 +470,7 @@ pub mod pallet { impl Hooks> for Pallet { #[cfg(feature = "try-runtime")] fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { - Self::do_try_state()?; - Ok(()) + crate::try_state::do_try_state::() } } @@ -1236,42 +1238,6 @@ pub mod pallet { Ok(()) } - - #[cfg(any(feature = "try-runtime", test))] - pub fn do_try_state() -> Result<(), &'static str> { - Did::::iter().try_for_each( - |(did_subject, did_details): (DidIdentifierOf, DidDetails)| -> Result<(), &'static str> { - let service_endpoints_count = ServiceEndpoints::::iter_prefix(&did_subject).count(); - - ensure!( - service_endpoints_count == DidEndpointsCount::::get(&did_subject).saturated_into::(), - "Unequal service endpoint" - ); - - ensure!( - did_details.key_agreement_keys.len() - <= ::MaxTotalKeyAgreementKeys::get().saturated_into::(), - "Exceeded key agreements" - ); - - ensure!( - service_endpoints_count - <= ::MaxNumberOfServicesPerDid::get().saturated_into::(), - "Exceeded service endpoints" - ); - - ensure!(!DidBlacklist::::contains_key(did_subject), "Blacklisted did"); - - Ok(()) - }, - )?; - - DidBlacklist::::iter_keys().try_for_each(|deleted_did_subject| -> Result<(), &'static str> { - let service_endpoints_count = ServiceEndpoints::::iter_prefix(&deleted_did_subject).count(); - ensure!(service_endpoints_count == 0, "Blacklisted did contains services"); - Ok(()) - }) - } } struct DidDepositCollector(PhantomData); diff --git a/pallets/did/src/mock.rs b/pallets/did/src/mock.rs index 7efd5befe..d607360fc 100644 --- a/pallets/did/src/mock.rs +++ b/pallets/did/src/mock.rs @@ -40,8 +40,7 @@ use crate::{ RelationshipDeriveError, }, service_endpoints::DidEndpoint, - utils as crate_utils, AccountIdOf, Config, CurrencyOf, DidBlacklist, DidEndpointsCount, KeyIdOf, Pallet, - ServiceEndpoints, + utils as crate_utils, AccountIdOf, Config, CurrencyOf, DidBlacklist, DidEndpointsCount, KeyIdOf, ServiceEndpoints, }; #[cfg(not(feature = "runtime-benchmarks"))] use crate::{DidRawOrigin, EnsureDidOrigin}; @@ -503,7 +502,7 @@ impl ExtBuilder { pub fn build_and_execute_with_sanity_tests(self, ext: Option, test: impl FnOnce()) { self.build(ext).execute_with(|| { test(); - Pallet::::do_try_state().unwrap(); + crate::try_state::do_try_state::().expect("TODO"); }) } diff --git a/pallets/did/src/try_state.rs b/pallets/did/src/try_state.rs new file mode 100644 index 000000000..a3e0865d7 --- /dev/null +++ b/pallets/did/src/try_state.rs @@ -0,0 +1,57 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::ensure; +use sp_core::Get; +use sp_runtime::SaturatedConversion; + +use crate::{did_details::DidDetails, Config, Did, DidBlacklist, DidEndpointsCount, DidIdentifierOf, ServiceEndpoints}; + +pub fn do_try_state() -> Result<(), &'static str> { + Did::::iter().try_for_each( + |(did_subject, did_details): (DidIdentifierOf, DidDetails)| -> Result<(), &'static str> { + let service_endpoints_count = ServiceEndpoints::::iter_prefix(&did_subject).count(); + + ensure!( + service_endpoints_count == DidEndpointsCount::::get(&did_subject).saturated_into::(), + "Unequal service endpoint" + ); + + ensure!( + did_details.key_agreement_keys.len() + <= (::MaxTotalKeyAgreementKeys::get()).saturated_into::(), + "Exceeded key agreements" + ); + + ensure!( + service_endpoints_count <= ::MaxNumberOfServicesPerDid::get().saturated_into::(), + "Exceeded service endpoints" + ); + + ensure!(!DidBlacklist::::contains_key(did_subject), "Blacklisted did"); + + Ok(()) + }, + )?; + + DidBlacklist::::iter_keys().try_for_each(|deleted_did_subject| -> Result<(), &'static str> { + let service_endpoints_count = ServiceEndpoints::::iter_prefix(&deleted_did_subject).count(); + ensure!(service_endpoints_count == 0, "Blacklisted did contains services"); + Ok(()) + }) +} diff --git a/pallets/pallet-did-lookup/src/lib.rs b/pallets/pallet-did-lookup/src/lib.rs index d9cbdc26f..c71e59462 100644 --- a/pallets/pallet-did-lookup/src/lib.rs +++ b/pallets/pallet-did-lookup/src/lib.rs @@ -39,6 +39,9 @@ mod tests; #[cfg(all(test, feature = "std"))] mod mock; +#[cfg(any(feature = "try-runtime", test))] +mod try_state; + #[cfg(feature = "runtime-benchmarks")] mod benchmarking; @@ -194,8 +197,7 @@ pub mod pallet { impl Hooks> for Pallet { #[cfg(feature = "try-runtime")] fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { - Self::do_try_state()?; - Ok(()) + crate::try_state::do_try_state::() } } @@ -430,26 +432,6 @@ pub mod pallet { Err(Error::::NotFound.into()) } } - - #[cfg(any(feature = "try-runtime", test))] - pub fn do_try_state() -> Result<(), &'static str> { - ConnectedDids::::iter().try_for_each(|(account, record)| -> Result<(), &'static str> { - ensure!( - ConnectedAccounts::::contains_key(record.did, account), - "Unknown account" - ); - Ok(()) - })?; - - ConnectedAccounts::::iter().try_for_each( - |(did_identifier, linked_account_id, _)| -> Result<(), &'static str> { - let connected_did = ConnectedDids::::get(linked_account_id); - ensure!(connected_did.is_some(), "Unknown did"); - ensure!(connected_did.unwrap().did == did_identifier, "Unequal did"); - Ok(()) - }, - ) - } } struct LinkableAccountDepositCollector(PhantomData); diff --git a/pallets/pallet-did-lookup/src/mock.rs b/pallets/pallet-did-lookup/src/mock.rs index 6d9a1b767..48237ca6e 100644 --- a/pallets/pallet-did-lookup/src/mock.rs +++ b/pallets/pallet-did-lookup/src/mock.rs @@ -29,7 +29,7 @@ use sp_runtime::{ use crate::{ self as pallet_did_lookup, linkable_account::LinkableAccountId, AccountIdOf, BalanceOf, Config, ConnectedAccounts, - ConnectedDids, ConnectionRecord, CurrencyOf, DidIdentifierOf, Pallet, + ConnectedDids, ConnectionRecord, CurrencyOf, DidIdentifierOf, }; pub(crate) type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; @@ -202,7 +202,7 @@ impl ExtBuilder { pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce()) { self.build().execute_with(|| { test(); - Pallet::::do_try_state().unwrap(); + crate::try_state::do_try_state::().expect("TODO"); }) } diff --git a/pallets/pallet-did-lookup/src/try_state.rs b/pallets/pallet-did-lookup/src/try_state.rs new file mode 100644 index 000000000..ecba397e7 --- /dev/null +++ b/pallets/pallet-did-lookup/src/try_state.rs @@ -0,0 +1,38 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::ensure; + +use crate::{Config, ConnectedAccounts, ConnectedDids}; + +pub(crate) fn do_try_state() -> Result<(), &'static str> { + ConnectedDids::::iter().try_for_each(|(account, record)| -> Result<(), &'static str> { + ensure!( + ConnectedAccounts::::contains_key(record.did, account), + "Unknown account" + ); + Ok(()) + })?; + + ConnectedAccounts::::iter().try_for_each(|(did_identifier, linked_account_id, _)| -> Result<(), &'static str> { + let connected_did = ConnectedDids::::get(linked_account_id); + ensure!(connected_did.is_some(), "Unknown did"); + ensure!(connected_did.unwrap().did == did_identifier, "Unequal did"); + Ok(()) + }) +} diff --git a/pallets/pallet-web3-names/src/lib.rs b/pallets/pallet-web3-names/src/lib.rs index 9ec5f8da2..d6ed7c4a1 100644 --- a/pallets/pallet-web3-names/src/lib.rs +++ b/pallets/pallet-web3-names/src/lib.rs @@ -28,6 +28,9 @@ mod default_weights; #[cfg(any(test, feature = "runtime-benchmarks"))] mod mock; +#[cfg(any(test, feature = "try-runtime"))] +mod try_state; + #[cfg(test)] mod tests; @@ -178,8 +181,7 @@ pub mod pallet { impl Hooks> for Pallet { #[cfg(feature = "try-runtime")] fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { - Self::do_try_state()?; - Ok(()) + crate::try_state::do_try_state::() } } @@ -502,32 +504,6 @@ pub mod pallet { fn unban_name(name: &Web3NameOf) { Banned::::remove(name); } - - #[cfg(any(feature = "try-runtime", test))] - pub fn do_try_state() -> Result<(), &'static str> { - // check if for each owner there is a name stored. - Owner::::iter().try_for_each( - |(w3n, ownership): (Web3NameOf, Web3OwnershipOf)| -> Result<(), &'static str> { - ensure!(Names::::contains_key(ownership.owner.clone()), "W3n unknown"); - ensure!(Names::::get(ownership.owner) == Some(w3n), "Unequal w3n"); - Ok(()) - }, - )?; - - // check for each name there is an owner. - Names::::iter().try_for_each( - |(w3n_owner, w3n): (Web3NameOwnerOf, Web3NameOf)| -> Result<(), &'static str> { - ensure!(Owner::::contains_key(&w3n), "Owner unknown"); - ensure!(Owner::::get(w3n).unwrap().owner == w3n_owner, "Unequal owner"); - Ok(()) - }, - )?; - // a banned name should have no owner. - Banned::::iter_keys().try_for_each(|banned_w3n| -> Result<(), &'static str> { - ensure!(!Owner::::contains_key(banned_w3n), "W3n: Banned name is owned."); - Ok(()) - }) - } } struct Web3NameStorageDepositCollector(PhantomData); diff --git a/pallets/pallet-web3-names/src/mock.rs b/pallets/pallet-web3-names/src/mock.rs index f103b4f44..eb1389f60 100644 --- a/pallets/pallet-web3-names/src/mock.rs +++ b/pallets/pallet-web3-names/src/mock.rs @@ -62,7 +62,7 @@ pub(crate) mod runtime { MultiSignature, }; - use crate::{self as pallet_web3_names, web3_name::AsciiWeb3Name, Pallet}; + use crate::{self as pallet_web3_names, web3_name::AsciiWeb3Name}; type Index = u64; type BlockNumber = u64; @@ -238,7 +238,7 @@ pub(crate) mod runtime { pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce()) { self.build().execute_with(|| { test(); - Pallet::::do_try_state().unwrap(); + crate::try_state::do_try_state::().expect("TODO"); }) } diff --git a/pallets/pallet-web3-names/src/try_state.rs b/pallets/pallet-web3-names/src/try_state.rs new file mode 100644 index 000000000..d935c8826 --- /dev/null +++ b/pallets/pallet-web3-names/src/try_state.rs @@ -0,0 +1,46 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::ensure; + +use crate::{Banned, Config, Names, Owner, Web3NameOf, Web3NameOwnerOf, Web3OwnershipOf}; + +pub fn do_try_state() -> Result<(), &'static str> { + // check if for each owner there is a name stored. + Owner::::iter().try_for_each( + |(w3n, ownership): (Web3NameOf, Web3OwnershipOf)| -> Result<(), &'static str> { + ensure!(Names::::contains_key(ownership.owner.clone()), "W3n unknown"); + ensure!(Names::::get(ownership.owner) == Some(w3n), "Unequal w3n"); + Ok(()) + }, + )?; + + // check for each name there is an owner. + Names::::iter().try_for_each( + |(w3n_owner, w3n): (Web3NameOwnerOf, Web3NameOf)| -> Result<(), &'static str> { + ensure!(Owner::::contains_key(&w3n), "Owner unknown"); + ensure!(Owner::::get(w3n).unwrap().owner == w3n_owner, "Unequal owner"); + Ok(()) + }, + )?; + // a banned name should have no owner. + Banned::::iter_keys().try_for_each(|banned_w3n| -> Result<(), &'static str> { + ensure!(!Owner::::contains_key(banned_w3n), "W3n: Banned name is owned."); + Ok(()) + }) +} diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index a01c6672d..b1a241890 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -518,8 +518,7 @@ pub mod pallet { #[cfg(feature = "try-runtime")] fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { - Self::do_try_state()?; - Ok(()) + crate::try_state::do_try_state::() } } @@ -1767,13 +1766,6 @@ pub mod pallet { } impl Pallet { - #[cfg(any(feature = "try-runtime", test))] - pub fn do_try_state() -> Result<(), &'static str> { - crate::try_state::validate_candiate_pool::()?; - crate::try_state::validate_top_candidates::()?; - crate::try_state::validate_stake::() - } - /// Check whether an account is currently delegating. pub fn is_delegator(acc: &T::AccountId) -> bool { DelegatorState::::get(acc).is_some() diff --git a/pallets/parachain-staking/src/mock.rs b/pallets/parachain-staking/src/mock.rs index 826943f99..438588ac2 100644 --- a/pallets/parachain-staking/src/mock.rs +++ b/pallets/parachain-staking/src/mock.rs @@ -347,7 +347,7 @@ impl ExtBuilder { pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce()) { self.build().execute_with(|| { test(); - Pallet::::do_try_state().unwrap(); + crate::try_state::do_try_state::().expect("TODO"); }) } } diff --git a/pallets/parachain-staking/src/try_state.rs b/pallets/parachain-staking/src/try_state.rs index b28ab1de3..37d11e8a2 100644 --- a/pallets/parachain-staking/src/try_state.rs +++ b/pallets/parachain-staking/src/try_state.rs @@ -1,3 +1,21 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + use frame_support::{ensure, traits::Get}; use sp_runtime::{traits::Zero, SaturatedConversion, Saturating}; @@ -7,7 +25,13 @@ use crate::{ Round, TopCandidates, TotalCollatorStake, }; -pub fn validate_candiate_pool() -> Result<(), &'static str> { +pub(crate) fn do_try_state() -> Result<(), &'static str> { + validate_candiate_pool::()?; + validate_top_candidates::()?; + validate_stake::() +} + +fn validate_candiate_pool() -> Result<(), &'static str> { // check if enough collators are set. ensure!( CandidatePool::::count() >= T::MinCollators::get(), @@ -90,7 +114,7 @@ pub fn validate_candiate_pool() -> Result<(), &'static str> { ) } -pub fn validate_top_candidates() -> Result<(), &'static str> { +fn validate_top_candidates() -> Result<(), &'static str> { let top_candidates = TopCandidates::::get(); // check if enough top candidates are set. @@ -119,7 +143,7 @@ pub fn validate_top_candidates() -> Result<(), &'static str> { }) } -pub fn validate_stake() -> Result<(), &'static str> { +fn validate_stake() -> Result<(), &'static str> { // the total fund has to be the sum over the first [MaxSelectedCandidates] of // [TopCandidates]. diff --git a/pallets/public-credentials/src/lib.rs b/pallets/public-credentials/src/lib.rs index 8787ee1c5..8b3f5c844 100644 --- a/pallets/public-credentials/src/lib.rs +++ b/pallets/public-credentials/src/lib.rs @@ -39,8 +39,11 @@ mod benchmarking; #[cfg(any(test, feature = "runtime-benchmarks"))] mod mock; + #[cfg(test)] mod tests; +#[cfg(any(test, feature = "try-runtime"))] +mod try_state; pub use crate::{ access_control::AccessControl as PublicCredentialsAccessControl, credentials::*, default_weights::WeightInfo, @@ -233,8 +236,7 @@ pub mod pallet { impl Hooks> for Pallet { #[cfg(feature = "try-runtime")] fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { - Self::do_try_state()?; - Ok(()) + crate::try_state::do_try_state::() } } @@ -594,35 +596,6 @@ pub mod pallet { } }) } - - #[cfg(any(feature = "try-runtime", test))] - pub fn do_try_state() -> Result<(), &'static str> { - Credentials::::iter().try_for_each( - |(subject_id, credential_id, entry)| -> Result<(), &'static str> { - ensure!( - CredentialSubjects::::contains_key(&credential_id), - "Unknown credential subject" - ); - - ensure!( - CredentialSubjects::::get(&credential_id) == Some(subject_id), - "Unequal credential subject" - ); - - ensure!(ctype::Ctypes::::contains_key(entry.ctype_hash), "Unknown ctype"); - - Ok(()) - }, - )?; - - CredentialSubjects::::iter().try_for_each(|(credential_id, subject_id)| -> Result<(), &'static str> { - ensure!( - Credentials::::contains_key(subject_id, credential_id), - "Unknown credential" - ); - Ok(()) - }) - } } struct PublicCredentialDepositCollector(PhantomData); diff --git a/pallets/public-credentials/src/mock.rs b/pallets/public-credentials/src/mock.rs index c0dea1a22..bf0c6fec1 100644 --- a/pallets/public-credentials/src/mock.rs +++ b/pallets/public-credentials/src/mock.rs @@ -113,7 +113,7 @@ pub(crate) mod runtime { use ctype::{CtypeCreatorOf, CtypeEntryOf, CtypeHashOf}; - use crate::{Config, CredentialEntryOf, Error, InputSubjectIdOf, Pallet, PublicCredentialsAccessControl}; + use crate::{Config, CredentialEntryOf, Error, InputSubjectIdOf, PublicCredentialsAccessControl}; pub(crate) type BlockNumber = u64; pub(crate) type Balance = u128; @@ -446,7 +446,7 @@ pub(crate) mod runtime { pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce()) { self.build().execute_with(|| { test(); - Pallet::::do_try_state().unwrap(); + crate::try_state::do_try_state::().expect("TODO"); }) } diff --git a/pallets/public-credentials/src/try_state.rs b/pallets/public-credentials/src/try_state.rs new file mode 100644 index 000000000..f4d1ba6ce --- /dev/null +++ b/pallets/public-credentials/src/try_state.rs @@ -0,0 +1,47 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + +use frame_support::ensure; + +use crate::{Config, CredentialSubjects, Credentials}; + +pub(crate) fn do_try_state() -> Result<(), &'static str> { + Credentials::::iter().try_for_each(|(subject_id, credential_id, entry)| -> Result<(), &'static str> { + ensure!( + CredentialSubjects::::contains_key(&credential_id), + "Unknown credential subject" + ); + + ensure!( + CredentialSubjects::::get(&credential_id) == Some(subject_id), + "Unequal credential subject" + ); + + ensure!(ctype::Ctypes::::contains_key(entry.ctype_hash), "Unknown ctype"); + + Ok(()) + })?; + + CredentialSubjects::::iter().try_for_each(|(credential_id, subject_id)| -> Result<(), &'static str> { + ensure!( + Credentials::::contains_key(subject_id, credential_id), + "Unknown credential" + ); + Ok(()) + }) +} From afd17552e96147c40ad26c4f73508b024f038f3f Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 12 May 2023 10:38:15 +0200 Subject: [PATCH 32/40] refactor --- pallets/attestation/src/lib.rs | 6 +++++- pallets/attestation/src/mock.rs | 2 +- pallets/attestation/src/try_state.rs | 5 ++++- pallets/delegation/src/mock.rs | 2 +- pallets/delegation/src/try_state.rs | 12 +++++++----- pallets/did/src/mock.rs | 2 +- pallets/did/src/try_state.rs | 4 ++-- pallets/pallet-did-lookup/src/mock.rs | 2 +- pallets/pallet-web3-names/src/mock.rs | 2 +- pallets/pallet-web3-names/src/try_state.rs | 5 ++--- pallets/parachain-staking/src/mock.rs | 2 +- pallets/parachain-staking/src/try_state.rs | 20 ++++++++++---------- pallets/public-credentials/src/mock.rs | 2 +- pallets/public-credentials/src/try_state.rs | 5 ----- 14 files changed, 37 insertions(+), 34 deletions(-) diff --git a/pallets/attestation/src/lib.rs b/pallets/attestation/src/lib.rs index 5771e1c15..2c49395a3 100644 --- a/pallets/attestation/src/lib.rs +++ b/pallets/attestation/src/lib.rs @@ -154,7 +154,11 @@ pub mod pallet { impl Hooks> for Pallet { #[cfg(feature = "try-runtime")] fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { - crate::try_state::do_try_state::() + let p = scale_info::prelude::format!("asdf"); + let q = p.as_str(); + Err(q) + + //crate::try_state::do_try_state::() } } diff --git a/pallets/attestation/src/mock.rs b/pallets/attestation/src/mock.rs index d6c73394a..75e027447 100644 --- a/pallets/attestation/src/mock.rs +++ b/pallets/attestation/src/mock.rs @@ -388,7 +388,7 @@ pub(crate) mod runtime { pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce()) { self.build().execute_with(|| { test(); - crate::try_state::do_try_state::().expect("TODO"); + crate::try_state::do_try_state::().expect("Sanity test for attestation failed."); }) } diff --git a/pallets/attestation/src/try_state.rs b/pallets/attestation/src/try_state.rs index f31cdb5f2..e28debf41 100644 --- a/pallets/attestation/src/try_state.rs +++ b/pallets/attestation/src/try_state.rs @@ -23,7 +23,10 @@ use crate::{Attestations, Config, ExternalAttestations}; pub(crate) fn do_try_state() -> Result<(), &'static str> { Attestations::::iter().try_for_each(|(claim_hash, attestation_details)| -> Result<(), &'static str> { if let Some(authorization_id) = attestation_details.authorization_id { - ensure!(ExternalAttestations::::get(authorization_id, claim_hash), "test") + ensure!( + ExternalAttestations::::get(authorization_id, claim_hash), + "Unknown external attestation" + ) } Ok(()) }) diff --git a/pallets/delegation/src/mock.rs b/pallets/delegation/src/mock.rs index bddaf71fb..47bf9e74f 100644 --- a/pallets/delegation/src/mock.rs +++ b/pallets/delegation/src/mock.rs @@ -516,7 +516,7 @@ pub(crate) mod runtime { pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce()) { self.build().execute_with(|| { test(); - crate::try_state::do_try_state::().expect("TODO"); + crate::try_state::do_try_state::().expect("Sanity test for delegation failed."); }) } diff --git a/pallets/delegation/src/try_state.rs b/pallets/delegation/src/try_state.rs index 88e99c2e0..6b5d060c6 100644 --- a/pallets/delegation/src/try_state.rs +++ b/pallets/delegation/src/try_state.rs @@ -33,13 +33,15 @@ pub(crate) fn do_try_state() -> Result<(), &'static str> { .filter(|delegation_node: &DelegationNode| delegation_node.children.contains(&delegation_node_id)) .count(); - match delegation_details.parent { - // If node is a leaf or intermediate, check if it occurs only once. Otherwise we have cycles. - Some(_) => ensure!(parent_count <= 1, "Cycles detected"), + if delegation_details.parent.is_some() { + // If node is a leaf or intermediate, check if it occurs only once. Otherwise we + // have cycles. + ensure!(parent_count <= 1, "Cycles detected"); + } else { // if parent is None, check that the root is not the children // from another node. - _ => ensure!(parent_count == 0, "Root node is intermediate"), - }; + ensure!(parent_count == 0, "Root node is intermediate"); + } // if a node is revoked, the subtree should be revoked as well. if delegation_details.details.revoked { diff --git a/pallets/did/src/mock.rs b/pallets/did/src/mock.rs index d607360fc..7f0770ff4 100644 --- a/pallets/did/src/mock.rs +++ b/pallets/did/src/mock.rs @@ -502,7 +502,7 @@ impl ExtBuilder { pub fn build_and_execute_with_sanity_tests(self, ext: Option, test: impl FnOnce()) { self.build(ext).execute_with(|| { test(); - crate::try_state::do_try_state::().expect("TODO"); + crate::try_state::do_try_state::().expect("Sanity test for did failed."); }) } diff --git a/pallets/did/src/try_state.rs b/pallets/did/src/try_state.rs index a3e0865d7..5f52fc62e 100644 --- a/pallets/did/src/try_state.rs +++ b/pallets/did/src/try_state.rs @@ -22,14 +22,14 @@ use sp_runtime::SaturatedConversion; use crate::{did_details::DidDetails, Config, Did, DidBlacklist, DidEndpointsCount, DidIdentifierOf, ServiceEndpoints}; -pub fn do_try_state() -> Result<(), &'static str> { +pub(crate) fn do_try_state() -> Result<(), &'static str> { Did::::iter().try_for_each( |(did_subject, did_details): (DidIdentifierOf, DidDetails)| -> Result<(), &'static str> { let service_endpoints_count = ServiceEndpoints::::iter_prefix(&did_subject).count(); ensure!( service_endpoints_count == DidEndpointsCount::::get(&did_subject).saturated_into::(), - "Unequal service endpoint" + "Unequal service endpoint count" ); ensure!( diff --git a/pallets/pallet-did-lookup/src/mock.rs b/pallets/pallet-did-lookup/src/mock.rs index 48237ca6e..2d6bf355f 100644 --- a/pallets/pallet-did-lookup/src/mock.rs +++ b/pallets/pallet-did-lookup/src/mock.rs @@ -202,7 +202,7 @@ impl ExtBuilder { pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce()) { self.build().execute_with(|| { test(); - crate::try_state::do_try_state::().expect("TODO"); + crate::try_state::do_try_state::().expect("Sanity test for did lookup failed."); }) } diff --git a/pallets/pallet-web3-names/src/mock.rs b/pallets/pallet-web3-names/src/mock.rs index eb1389f60..5a8135bab 100644 --- a/pallets/pallet-web3-names/src/mock.rs +++ b/pallets/pallet-web3-names/src/mock.rs @@ -238,7 +238,7 @@ pub(crate) mod runtime { pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce()) { self.build().execute_with(|| { test(); - crate::try_state::do_try_state::().expect("TODO"); + crate::try_state::do_try_state::().expect("Sanity test for w3n failed."); }) } diff --git a/pallets/pallet-web3-names/src/try_state.rs b/pallets/pallet-web3-names/src/try_state.rs index d935c8826..e8a83dfd6 100644 --- a/pallets/pallet-web3-names/src/try_state.rs +++ b/pallets/pallet-web3-names/src/try_state.rs @@ -24,7 +24,6 @@ pub fn do_try_state() -> Result<(), &'static str> { // check if for each owner there is a name stored. Owner::::iter().try_for_each( |(w3n, ownership): (Web3NameOf, Web3OwnershipOf)| -> Result<(), &'static str> { - ensure!(Names::::contains_key(ownership.owner.clone()), "W3n unknown"); ensure!(Names::::get(ownership.owner) == Some(w3n), "Unequal w3n"); Ok(()) }, @@ -33,14 +32,14 @@ pub fn do_try_state() -> Result<(), &'static str> { // check for each name there is an owner. Names::::iter().try_for_each( |(w3n_owner, w3n): (Web3NameOwnerOf, Web3NameOf)| -> Result<(), &'static str> { - ensure!(Owner::::contains_key(&w3n), "Owner unknown"); + ensure!(Owner::::contains_key(&w3n), "Unknown Owner"); ensure!(Owner::::get(w3n).unwrap().owner == w3n_owner, "Unequal owner"); Ok(()) }, )?; // a banned name should have no owner. Banned::::iter_keys().try_for_each(|banned_w3n| -> Result<(), &'static str> { - ensure!(!Owner::::contains_key(banned_w3n), "W3n: Banned name is owned."); + ensure!(!Owner::::contains_key(banned_w3n), "Banned name is owned"); Ok(()) }) } diff --git a/pallets/parachain-staking/src/mock.rs b/pallets/parachain-staking/src/mock.rs index 438588ac2..ea50a31fd 100644 --- a/pallets/parachain-staking/src/mock.rs +++ b/pallets/parachain-staking/src/mock.rs @@ -347,7 +347,7 @@ impl ExtBuilder { pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce()) { self.build().execute_with(|| { test(); - crate::try_state::do_try_state::().expect("TODO"); + crate::try_state::do_try_state::().expect("Sanity test for parachain staking failed."); }) } } diff --git a/pallets/parachain-staking/src/try_state.rs b/pallets/parachain-staking/src/try_state.rs index 37d11e8a2..a09199ee0 100644 --- a/pallets/parachain-staking/src/try_state.rs +++ b/pallets/parachain-staking/src/try_state.rs @@ -35,7 +35,7 @@ fn validate_candiate_pool() -> Result<(), &'static str> { // check if enough collators are set. ensure!( CandidatePool::::count() >= T::MinCollators::get(), - "Staking: Not enough collators are present." + "Insufficient collators" ); CandidatePool::::iter_values().try_for_each( @@ -48,13 +48,13 @@ fn validate_candiate_pool() -> Result<(), &'static str> { // total stake should be the sum of delegators stake + colator stake. ensure!( sum_delegations.saturating_add(candidate.stake) == candidate.total, - "Staking: Total stake of a collator can not be reconstructed." + "Corrupted collator stake" ); // Min required stake should be set ensure!( candidate.stake >= T::MinCollatorCandidateStake::get(), - "Staking: Insufficient stake from a collator." + "Insufficient collator stake" ); // delegators should be in delegator pool. @@ -63,7 +63,7 @@ fn validate_candiate_pool() -> Result<(), &'static str> { .iter() .map(|delegator_stake| DelegatorState::::get(&delegator_stake.owner).is_some()) .all(|x| x); - ensure!(are_delegator_present, "Staking: Delegator is not present"); + ensure!(are_delegator_present, "Unknown delegator"); // each delegator should not exceed the [MaxDelegationsPerRound] candidate @@ -80,7 +80,7 @@ fn validate_candiate_pool() -> Result<(), &'static str> { ensure!( counter <= T::MaxDelegationsPerRound::get(), - "Staking: Exceeded delegations per round by a collator." + "Exceeded delegations per round" ); Ok(()) @@ -89,12 +89,12 @@ fn validate_candiate_pool() -> Result<(), &'static str> { // check min and max stake for each candidate ensure!( candidate.stake <= MaxCollatorCandidateStake::::get(), - "Staking: Exceeded stake by a collator." + "Exceeded collator stake" ); ensure!( candidate.stake >= T::MinCollatorStake::get(), - "Staking: Lag behind stake by a collator." + "Insufficient collator stake" ); // delegators should have the min required stake. @@ -104,7 +104,7 @@ fn validate_candiate_pool() -> Result<(), &'static str> { .try_for_each(|delegator_stake| -> Result<(), &'static str> { ensure!( delegator_stake.amount >= T::MinDelegatorStake::get(), - "Staking: Lag behind stake of a delegator" + "Insufficient delegator stake" ); Ok(()) })?; @@ -171,12 +171,12 @@ fn validate_stake() -> Result<(), &'static str> { ensure!( total_stake.collators == collator_stake, - "Total collator stake not matching." + "Corrupted total collator stake" ); ensure!( total_stake.delegators == delegator_state, - "Total delegator stake is not matching." + "Corrupted total delegator stake" ); Ok(()) diff --git a/pallets/public-credentials/src/mock.rs b/pallets/public-credentials/src/mock.rs index bf0c6fec1..c94e32488 100644 --- a/pallets/public-credentials/src/mock.rs +++ b/pallets/public-credentials/src/mock.rs @@ -446,7 +446,7 @@ pub(crate) mod runtime { pub fn build_and_execute_with_sanity_tests(self, test: impl FnOnce()) { self.build().execute_with(|| { test(); - crate::try_state::do_try_state::().expect("TODO"); + crate::try_state::do_try_state::().expect("Sanity test for public credential failed."); }) } diff --git a/pallets/public-credentials/src/try_state.rs b/pallets/public-credentials/src/try_state.rs index f4d1ba6ce..c55951aa8 100644 --- a/pallets/public-credentials/src/try_state.rs +++ b/pallets/public-credentials/src/try_state.rs @@ -22,11 +22,6 @@ use crate::{Config, CredentialSubjects, Credentials}; pub(crate) fn do_try_state() -> Result<(), &'static str> { Credentials::::iter().try_for_each(|(subject_id, credential_id, entry)| -> Result<(), &'static str> { - ensure!( - CredentialSubjects::::contains_key(&credential_id), - "Unknown credential subject" - ); - ensure!( CredentialSubjects::::get(&credential_id) == Some(subject_id), "Unequal credential subject" From 0aa08f99dec75da45ec57f47f8cd50ae20cb0163 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 12 May 2023 10:56:14 +0200 Subject: [PATCH 33/40] remove debugging flags --- pallets/attestation/src/lib.rs | 6 +----- pallets/delegation/src/lib.rs | 5 ----- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/pallets/attestation/src/lib.rs b/pallets/attestation/src/lib.rs index 2c49395a3..5771e1c15 100644 --- a/pallets/attestation/src/lib.rs +++ b/pallets/attestation/src/lib.rs @@ -154,11 +154,7 @@ pub mod pallet { impl Hooks> for Pallet { #[cfg(feature = "try-runtime")] fn try_state(_n: BlockNumberFor) -> Result<(), &'static str> { - let p = scale_info::prelude::format!("asdf"); - let q = p.as_str(); - Err(q) - - //crate::try_state::do_try_state::() + crate::try_state::do_try_state::() } } diff --git a/pallets/delegation/src/lib.rs b/pallets/delegation/src/lib.rs index 7f09d4675..118df1a9d 100644 --- a/pallets/delegation/src/lib.rs +++ b/pallets/delegation/src/lib.rs @@ -976,11 +976,6 @@ pub mod pallet { removals = removals.saturating_add(1); Ok((removals, consumed_weight)) } - - #[cfg(any(feature = "try-runtime", test))] - pub fn do_try_state() -> Result<(), &'static str> { - crate::try_state::do_try_state::() - } } struct DelegationDepositCollector(PhantomData); From dc5fe263668f5bfb633b3063d2429647ebeeb429 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Fri, 12 May 2023 16:13:02 +0200 Subject: [PATCH 34/40] draft for error messages --- pallets/attestation/Cargo.toml | 1 + pallets/attestation/src/try_state.rs | 9 ++++++-- pallets/delegation/src/try_state.rs | 31 +++++++++++++++++++++++----- pallets/did/src/try_state.rs | 21 ++++++++++++++----- support/src/lib.rs | 3 +++ support/src/test.rs | 5 +++++ 6 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 support/src/test.rs diff --git a/pallets/attestation/Cargo.toml b/pallets/attestation/Cargo.toml index d1ca80fbb..70da38c9f 100644 --- a/pallets/attestation/Cargo.toml +++ b/pallets/attestation/Cargo.toml @@ -78,4 +78,5 @@ std = [ try-runtime = [ "frame-support/try-runtime", "frame-system/try-runtime", + "kilt-support/try-runtime" ] diff --git a/pallets/attestation/src/try_state.rs b/pallets/attestation/src/try_state.rs index e28debf41..b40c1cbd4 100644 --- a/pallets/attestation/src/try_state.rs +++ b/pallets/attestation/src/try_state.rs @@ -17,6 +17,8 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use frame_support::ensure; +use kilt_support::test::convert_error_message; +use scale_info::prelude::format; use crate::{Attestations, Config, ExternalAttestations}; @@ -24,8 +26,11 @@ pub(crate) fn do_try_state() -> Result<(), &'static str> { Attestations::::iter().try_for_each(|(claim_hash, attestation_details)| -> Result<(), &'static str> { if let Some(authorization_id) = attestation_details.authorization_id { ensure!( - ExternalAttestations::::get(authorization_id, claim_hash), - "Unknown external attestation" + ExternalAttestations::::get(&authorization_id, claim_hash), + convert_error_message(format!( + "External attestation with authorization_id: {:?} and claim_hash {:?} does not exist", + authorization_id, claim_hash + )) ) } Ok(()) diff --git a/pallets/delegation/src/try_state.rs b/pallets/delegation/src/try_state.rs index 6b5d060c6..054da4272 100644 --- a/pallets/delegation/src/try_state.rs +++ b/pallets/delegation/src/try_state.rs @@ -16,8 +16,11 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use crate::{Config, DelegationHierarchies, DelegationNode, DelegationNodes}; use frame_support::ensure; +use kilt_support::test::convert_error_message; +use scale_info::prelude::format; + +use crate::{Config, DelegationHierarchies, DelegationNode, DelegationNodes}; pub(crate) fn do_try_state() -> Result<(), &'static str> { DelegationNodes::::iter().try_for_each(|(delegation_node_id, delegation_details)| -> Result<(), &'static str> { @@ -26,7 +29,7 @@ pub(crate) fn do_try_state() -> Result<(), &'static str> { // check if node is in part of a delegation hierarchy. ensure!( DelegationHierarchies::::contains_key(hierarchy_id), - "Unknown hierarchy" + convert_error_message(format!("Delegation hierarchy {:?} not found", hierarchy_id)) ); let parent_count = DelegationNodes::::iter_values() @@ -36,11 +39,23 @@ pub(crate) fn do_try_state() -> Result<(), &'static str> { if delegation_details.parent.is_some() { // If node is a leaf or intermediate, check if it occurs only once. Otherwise we // have cycles. - ensure!(parent_count <= 1, "Cycles detected"); + ensure!( + parent_count <= 1, + convert_error_message(format!( + "Delegation with cycles detected. Node {:?} in hierarchy {:?} has two or more parents.", + delegation_node_id, hierarchy_id + )) + ); } else { // if parent is None, check that the root is not the children // from another node. - ensure!(parent_count == 0, "Root node is intermediate"); + ensure!( + parent_count == 0, + convert_error_message(format!( + "Root node {:?} is child from other delegation nodes", + delegation_node_id + )) + ); } // if a node is revoked, the subtree should be revoked as well. @@ -49,7 +64,13 @@ pub(crate) fn do_try_state() -> Result<(), &'static str> { .iter() .map(|child: &DelegationNode| child.details.revoked) .all(|x| x); - ensure!(is_subtree_revoked, "Subtree not revoked"); + ensure!( + is_subtree_revoked, + convert_error_message(format!( + "Revoked delegation node {:?} has an unrevoked subtree.", + delegation_node_id + )) + ); } Ok(()) }) diff --git a/pallets/did/src/try_state.rs b/pallets/did/src/try_state.rs index 5f52fc62e..8e38e6289 100644 --- a/pallets/did/src/try_state.rs +++ b/pallets/did/src/try_state.rs @@ -17,6 +17,8 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use frame_support::ensure; +use kilt_support::test::convert_error_message; +use scale_info::prelude::format; use sp_core::Get; use sp_runtime::SaturatedConversion; @@ -29,21 +31,24 @@ pub(crate) fn do_try_state() -> Result<(), &'static str> { ensure!( service_endpoints_count == DidEndpointsCount::::get(&did_subject).saturated_into::(), - "Unequal service endpoint count" + convert_error_message(format!("DID {:?} has not matching service endpoints.", did_subject)) ); ensure!( did_details.key_agreement_keys.len() <= (::MaxTotalKeyAgreementKeys::get()).saturated_into::(), - "Exceeded key agreements" + convert_error_message(format!("DID {:?} has to many key agreement keys.", did_subject,)) ); ensure!( service_endpoints_count <= ::MaxNumberOfServicesPerDid::get().saturated_into::(), - "Exceeded service endpoints" + convert_error_message(format!("DID {:?} has to many service endpoints.", did_subject)) ); - ensure!(!DidBlacklist::::contains_key(did_subject), "Blacklisted did"); + ensure!( + !DidBlacklist::::contains_key(did_subject), + convert_error_message(format!("DID {:?} is blacklisted.", did_subject)) + ); Ok(()) }, @@ -51,7 +56,13 @@ pub(crate) fn do_try_state() -> Result<(), &'static str> { DidBlacklist::::iter_keys().try_for_each(|deleted_did_subject| -> Result<(), &'static str> { let service_endpoints_count = ServiceEndpoints::::iter_prefix(&deleted_did_subject).count(); - ensure!(service_endpoints_count == 0, "Blacklisted did contains services"); + ensure!( + service_endpoints_count == 0, + convert_error_message(format!( + "Blacklisted DID {:?} has service endpoints.", + deleted_did_subject, + )) + ); Ok(()) }) } diff --git a/support/src/lib.rs b/support/src/lib.rs index 722a00a0f..efb9742cc 100644 --- a/support/src/lib.rs +++ b/support/src/lib.rs @@ -20,6 +20,9 @@ pub mod deposit; pub use deposit::{free_deposit, reserve_deposit}; +#[cfg(any(feature = "try-runtime", test))] +pub mod test; + #[cfg(any(feature = "runtime-benchmarks", feature = "mock"))] pub mod mock; pub mod signature; diff --git a/support/src/test.rs b/support/src/test.rs new file mode 100644 index 000000000..ab75b0570 --- /dev/null +++ b/support/src/test.rs @@ -0,0 +1,5 @@ +use scale_info::prelude::{boxed::Box, string::String}; + +pub fn convert_error_message(error_message: String) -> &'static str { + Box::leak(error_message.into_boxed_str()) +} From 5e5ae5343709bfab886e91ba2baa7c9e67f5d6e2 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Mon, 15 May 2023 12:44:02 +0200 Subject: [PATCH 35/40] fmt error messages --- Cargo.lock | 1 + pallets/did/src/try_state.rs | 12 +-- pallets/pallet-did-lookup/src/try_state.rs | 16 ++-- pallets/pallet-web3-names/src/try_state.rs | 21 +++++- pallets/parachain-staking/Cargo.toml | 2 + pallets/parachain-staking/src/try_state.rs | 82 ++++++++++++--------- pallets/public-credentials/src/try_state.rs | 18 +++-- support/src/test.rs | 18 +++++ 8 files changed, 115 insertions(+), 55 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 00bd81f5e..293a5fef2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6748,6 +6748,7 @@ dependencies = [ "frame-support", "frame-system", "kilt-runtime-api-staking", + "kilt-support", "log", "pallet-aura", "pallet-authorship", diff --git a/pallets/did/src/try_state.rs b/pallets/did/src/try_state.rs index 8e38e6289..822e99808 100644 --- a/pallets/did/src/try_state.rs +++ b/pallets/did/src/try_state.rs @@ -31,23 +31,23 @@ pub(crate) fn do_try_state() -> Result<(), &'static str> { ensure!( service_endpoints_count == DidEndpointsCount::::get(&did_subject).saturated_into::(), - convert_error_message(format!("DID {:?} has not matching service endpoints.", did_subject)) + convert_error_message(format!("Did {:?} has not matching service endpoints.", did_subject)) ); ensure!( did_details.key_agreement_keys.len() <= (::MaxTotalKeyAgreementKeys::get()).saturated_into::(), - convert_error_message(format!("DID {:?} has to many key agreement keys.", did_subject,)) + convert_error_message(format!("Did {:?} has to many key agreement keys.", did_subject,)) ); ensure!( service_endpoints_count <= ::MaxNumberOfServicesPerDid::get().saturated_into::(), - convert_error_message(format!("DID {:?} has to many service endpoints.", did_subject)) + convert_error_message(format!("Did {:?} has to many service endpoints.", did_subject)) ); ensure!( - !DidBlacklist::::contains_key(did_subject), - convert_error_message(format!("DID {:?} is blacklisted.", did_subject)) + !DidBlacklist::::contains_key(&did_subject), + convert_error_message(format!("Did {:?} is blacklisted.", did_subject)) ); Ok(()) @@ -59,7 +59,7 @@ pub(crate) fn do_try_state() -> Result<(), &'static str> { ensure!( service_endpoints_count == 0, convert_error_message(format!( - "Blacklisted DID {:?} has service endpoints.", + "Blacklisted did {:?} has service endpoints.", deleted_did_subject, )) ); diff --git a/pallets/pallet-did-lookup/src/try_state.rs b/pallets/pallet-did-lookup/src/try_state.rs index ecba397e7..c3670ad9b 100644 --- a/pallets/pallet-did-lookup/src/try_state.rs +++ b/pallets/pallet-did-lookup/src/try_state.rs @@ -17,22 +17,28 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use frame_support::ensure; +use kilt_support::test::convert_error_message; +use scale_info::prelude::format; use crate::{Config, ConnectedAccounts, ConnectedDids}; pub(crate) fn do_try_state() -> Result<(), &'static str> { ConnectedDids::::iter().try_for_each(|(account, record)| -> Result<(), &'static str> { ensure!( - ConnectedAccounts::::contains_key(record.did, account), - "Unknown account" + ConnectedAccounts::::contains_key(&record.did, &account), + convert_error_message(format!("Account {:?} with did {:?} not found", record.did, account)) ); Ok(()) })?; ConnectedAccounts::::iter().try_for_each(|(did_identifier, linked_account_id, _)| -> Result<(), &'static str> { - let connected_did = ConnectedDids::::get(linked_account_id); - ensure!(connected_did.is_some(), "Unknown did"); - ensure!(connected_did.unwrap().did == did_identifier, "Unequal did"); + ensure!( + ConnectedDids::::get(&linked_account_id).expect("Unknown did").did == did_identifier, + convert_error_message(format!( + "Linked Account {:?} for did {:?} not match", + linked_account_id, did_identifier + )) + ); Ok(()) }) } diff --git a/pallets/pallet-web3-names/src/try_state.rs b/pallets/pallet-web3-names/src/try_state.rs index e8a83dfd6..6b92c626b 100644 --- a/pallets/pallet-web3-names/src/try_state.rs +++ b/pallets/pallet-web3-names/src/try_state.rs @@ -17,6 +17,8 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use frame_support::ensure; +use kilt_support::test::convert_error_message; +use scale_info::prelude::format; use crate::{Banned, Config, Names, Owner, Web3NameOf, Web3NameOwnerOf, Web3OwnershipOf}; @@ -24,7 +26,13 @@ pub fn do_try_state() -> Result<(), &'static str> { // check if for each owner there is a name stored. Owner::::iter().try_for_each( |(w3n, ownership): (Web3NameOf, Web3OwnershipOf)| -> Result<(), &'static str> { - ensure!(Names::::get(ownership.owner) == Some(w3n), "Unequal w3n"); + ensure!( + Names::::get(&ownership.owner) == Some(w3n.clone()), + convert_error_message(format!( + "Owned w3n from owner {:?} does not match with saved w3n {:?}", + ownership.owner, w3n + )) + ); Ok(()) }, )?; @@ -32,14 +40,19 @@ pub fn do_try_state() -> Result<(), &'static str> { // check for each name there is an owner. Names::::iter().try_for_each( |(w3n_owner, w3n): (Web3NameOwnerOf, Web3NameOf)| -> Result<(), &'static str> { - ensure!(Owner::::contains_key(&w3n), "Unknown Owner"); - ensure!(Owner::::get(w3n).unwrap().owner == w3n_owner, "Unequal owner"); + ensure!( + Owner::::get(&w3n).expect("Unknown w3n").owner == w3n_owner, + convert_error_message(format!("Owner {:?} with w3n {:?} not found", w3n_owner, w3n)) + ); Ok(()) }, )?; // a banned name should have no owner. Banned::::iter_keys().try_for_each(|banned_w3n| -> Result<(), &'static str> { - ensure!(!Owner::::contains_key(banned_w3n), "Banned name is owned"); + ensure!( + !Owner::::contains_key(&banned_w3n), + convert_error_message(format!("Owner contains banned name {:?}", banned_w3n)) + ); Ok(()) }) } diff --git a/pallets/parachain-staking/Cargo.toml b/pallets/parachain-staking/Cargo.toml index f7a38f53c..7bf64c3aa 100644 --- a/pallets/parachain-staking/Cargo.toml +++ b/pallets/parachain-staking/Cargo.toml @@ -26,6 +26,7 @@ serde = {workspace = true, optional = true} # Internal dependencies kilt-runtime-api-staking.workspace = true +kilt-support.workspace = true # Substrate dependencies frame-support.workspace = true @@ -72,4 +73,5 @@ try-runtime = [ "pallet-authorship/try-runtime", "pallet-balances/try-runtime", "pallet-session/try-runtime", + "kilt-support/try-runtime" ] diff --git a/pallets/parachain-staking/src/try_state.rs b/pallets/parachain-staking/src/try_state.rs index a09199ee0..d3cb7b17d 100644 --- a/pallets/parachain-staking/src/try_state.rs +++ b/pallets/parachain-staking/src/try_state.rs @@ -17,6 +17,8 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use frame_support::{ensure, traits::Get}; +use kilt_support::test::convert_error_message; +use scale_info::prelude::format; use sp_runtime::{traits::Zero, SaturatedConversion, Saturating}; use crate::{ @@ -35,7 +37,11 @@ fn validate_candiate_pool() -> Result<(), &'static str> { // check if enough collators are set. ensure!( CandidatePool::::count() >= T::MinCollators::get(), - "Insufficient collators" + convert_error_message(format!( + "Insufficient collators. Collators count: {:?}. Min required collators: {:?}", + CandidatePool::::count(), + T::MinCollators::get() + )) ); CandidatePool::::iter_values().try_for_each( @@ -46,26 +52,18 @@ fn validate_candiate_pool() -> Result<(), &'static str> { .fold(Zero::zero(), |acc, stake| acc.saturating_add(stake.amount)); // total stake should be the sum of delegators stake + colator stake. + let stake_total = sum_delegations.saturating_add(candidate.stake); ensure!( - sum_delegations.saturating_add(candidate.stake) == candidate.total, - "Corrupted collator stake" + stake_total == candidate.total, + convert_error_message(format!("Total stake of collator {:?} does not match", candidate.id)) ); // Min required stake should be set ensure!( candidate.stake >= T::MinCollatorCandidateStake::get(), - "Insufficient collator stake" + convert_error_message(format!("Stake of collator {:?} insufficient", candidate.id)) ); - // delegators should be in delegator pool. - let are_delegator_present = candidate - .delegators - .iter() - .map(|delegator_stake| DelegatorState::::get(&delegator_stake.owner).is_some()) - .all(|x| x); - ensure!(are_delegator_present, "Unknown delegator"); - - // each delegator should not exceed the [MaxDelegationsPerRound] candidate .delegators .iter() @@ -77,10 +75,23 @@ fn validate_candiate_pool() -> Result<(), &'static str> { } else { last_delegation.counter }; - + // each delegator should not exceed the [MaxDelegationsPerRound] ensure!( counter <= T::MaxDelegationsPerRound::get(), - "Exceeded delegations per round" + convert_error_message(format!( + "Exceeded delegations per round. Delegator: {:?}", + delegator_stake.owner + )) + ); + + ensure!( + delegator_stake.amount >= T::MinDelegatorStake::get(), + convert_error_message(format!("Delegator {:?} insufficient stake", delegator_stake.owner)) + ); + + ensure!( + DelegatorState::::get(&delegator_stake.owner).is_some(), + convert_error_message(format!("Unknown delegator {:?}", delegator_stake.owner)) ); Ok(()) @@ -89,26 +100,14 @@ fn validate_candiate_pool() -> Result<(), &'static str> { // check min and max stake for each candidate ensure!( candidate.stake <= MaxCollatorCandidateStake::::get(), - "Exceeded collator stake" + convert_error_message(format!("Candidate {:?} exceeded stake", candidate.id)) ); ensure!( candidate.stake >= T::MinCollatorStake::get(), - "Insufficient collator stake" + convert_error_message(format!("Candidate {:?} insufficient stake", candidate.id)) ); - // delegators should have the min required stake. - candidate - .delegators - .iter() - .try_for_each(|delegator_stake| -> Result<(), &'static str> { - ensure!( - delegator_stake.amount >= T::MinDelegatorStake::get(), - "Insufficient delegator stake" - ); - Ok(()) - })?; - Ok(()) }, ) @@ -120,23 +119,30 @@ fn validate_top_candidates() -> Result<(), &'static str> { // check if enough top candidates are set. ensure!( top_candidates.len() >= T::MinRequiredCollators::get().saturated_into(), - "Insufficient collators" + convert_error_message(format!( + "Not enough candidates are set. Candidate count: {:?}. Required: {:?}", + top_candidates.len(), + T::MinRequiredCollators::get() + )) ); top_candidates.iter().try_for_each(|stake| -> Result<(), &'static str> { // top candidates should be part of the candidate pool. - ensure!(CandidatePool::::contains_key(&stake.owner), "Unknown candidate"); + ensure!( + CandidatePool::::contains_key(&stake.owner), + convert_error_message(format!("Unknown candidate {:?} in top candidates.", stake.owner)) + ); // an account can not be candidate and delegator. ensure!( DelegatorState::::get(&stake.owner).is_none(), - "Account is candidate and delegator." + convert_error_message(format!("Account {:?} is delegator and candidate.", stake.owner)) ); // a top candidate should be active. ensure!( Pallet::::is_active_candidate(&stake.owner).unwrap(), - "Inactive candidate" + convert_error_message(format!("Top candidate {:?} is inactive", stake.owner)) ); Ok(()) @@ -171,12 +177,18 @@ fn validate_stake() -> Result<(), &'static str> { ensure!( total_stake.collators == collator_stake, - "Corrupted total collator stake" + convert_error_message(format!( + "Corrupted total collator stake. Saved total stake: {:?}. Calculated stake: {:?}", + total_stake.collators, collator_stake + )) ); ensure!( total_stake.delegators == delegator_state, - "Corrupted total delegator stake" + convert_error_message(format!( + "Corrupted total delegator stake. Saved total stake: {:?}. Calculated stake: {:?}", + total_stake.delegators, delegator_state + )) ); Ok(()) diff --git a/pallets/public-credentials/src/try_state.rs b/pallets/public-credentials/src/try_state.rs index c55951aa8..077e1ee67 100644 --- a/pallets/public-credentials/src/try_state.rs +++ b/pallets/public-credentials/src/try_state.rs @@ -17,25 +17,33 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use frame_support::ensure; +use kilt_support::test::convert_error_message; +use scale_info::prelude::format; use crate::{Config, CredentialSubjects, Credentials}; pub(crate) fn do_try_state() -> Result<(), &'static str> { Credentials::::iter().try_for_each(|(subject_id, credential_id, entry)| -> Result<(), &'static str> { ensure!( - CredentialSubjects::::get(&credential_id) == Some(subject_id), - "Unequal credential subject" + CredentialSubjects::::get(&credential_id) == Some(subject_id.clone()), + convert_error_message(format!( + "Credential subject does not match. Credential id: {:?}. Subject id: {:?}", + credential_id, subject_id + )) ); - ensure!(ctype::Ctypes::::contains_key(entry.ctype_hash), "Unknown ctype"); + ensure!( + ctype::Ctypes::::contains_key(&entry.ctype_hash), + convert_error_message(format!("Unknown Ctype: {:?}", entry.ctype_hash)) + ); Ok(()) })?; CredentialSubjects::::iter().try_for_each(|(credential_id, subject_id)| -> Result<(), &'static str> { ensure!( - Credentials::::contains_key(subject_id, credential_id), - "Unknown credential" + Credentials::::contains_key(subject_id, &credential_id), + convert_error_message(format!("Unknown credential {:?}", credential_id)) ); Ok(()) }) diff --git a/support/src/test.rs b/support/src/test.rs index ab75b0570..3b595a848 100644 --- a/support/src/test.rs +++ b/support/src/test.rs @@ -1,3 +1,21 @@ +// KILT Blockchain – https://botlabs.org +// Copyright (C) 2019-2023 BOTLabs GmbH + +// The KILT Blockchain is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The KILT Blockchain is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +// If you feel like getting in touch with us, you can do so at info@botlabs.org + use scale_info::prelude::{boxed::Box, string::String}; pub fn convert_error_message(error_message: String) -> &'static str { From 5662cb0059606c4a88c5d7298ce31c40c8c43963 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Mon, 15 May 2023 12:55:56 +0200 Subject: [PATCH 36/40] refactor --- pallets/parachain-staking/src/try_state.rs | 75 ++++++++++++---------- 1 file changed, 41 insertions(+), 34 deletions(-) diff --git a/pallets/parachain-staking/src/try_state.rs b/pallets/parachain-staking/src/try_state.rs index d3cb7b17d..e4a18c6b7 100644 --- a/pallets/parachain-staking/src/try_state.rs +++ b/pallets/parachain-staking/src/try_state.rs @@ -22,7 +22,8 @@ use scale_info::prelude::format; use sp_runtime::{traits::Zero, SaturatedConversion, Saturating}; use crate::{ - types::{BalanceOf, Candidate}, + set::OrderedSet, + types::{BalanceOf, Candidate, Stake}, CandidatePool, Config, DelegatorState, LastDelegation, MaxCollatorCandidateStake, MaxSelectedCandidates, Pallet, Round, TopCandidates, TotalCollatorStake, }; @@ -64,38 +65,7 @@ fn validate_candiate_pool() -> Result<(), &'static str> { convert_error_message(format!("Stake of collator {:?} insufficient", candidate.id)) ); - candidate - .delegators - .iter() - .try_for_each(|delegator_stake| -> Result<(), &'static str> { - let last_delegation = LastDelegation::::get(&delegator_stake.owner); - let round = Round::::get(); - let counter = if last_delegation.round < round.current { - 0u32 - } else { - last_delegation.counter - }; - // each delegator should not exceed the [MaxDelegationsPerRound] - ensure!( - counter <= T::MaxDelegationsPerRound::get(), - convert_error_message(format!( - "Exceeded delegations per round. Delegator: {:?}", - delegator_stake.owner - )) - ); - - ensure!( - delegator_stake.amount >= T::MinDelegatorStake::get(), - convert_error_message(format!("Delegator {:?} insufficient stake", delegator_stake.owner)) - ); - - ensure!( - DelegatorState::::get(&delegator_stake.owner).is_some(), - convert_error_message(format!("Unknown delegator {:?}", delegator_stake.owner)) - ); - - Ok(()) - })?; + validate_delegators::(candidate.delegators)?; // check min and max stake for each candidate ensure!( @@ -149,10 +119,47 @@ fn validate_top_candidates() -> Result<(), &'static str> { }) } +fn validate_delegators( + delegators: OrderedSet>, T::MaxDelegatorsPerCollator>, +) -> Result<(), &'static str> { + delegators + .iter() + .try_for_each(|delegator_stake| -> Result<(), &'static str> { + let last_delegation = LastDelegation::::get(&delegator_stake.owner); + let round = Round::::get(); + let counter = if last_delegation.round < round.current { + 0u32 + } else { + last_delegation.counter + }; + + // each delegator should not exceed the [MaxDelegationsPerRound] + ensure!( + counter <= T::MaxDelegationsPerRound::get(), + convert_error_message(format!( + "Exceeded delegations per round. Delegator: {:?}", + delegator_stake.owner + )) + ); + + // each delegator should have the min required stake + ensure!( + delegator_stake.amount >= T::MinDelegatorStake::get(), + convert_error_message(format!("Delegator {:?} insufficient stake", delegator_stake.owner)) + ); + + ensure!( + DelegatorState::::get(&delegator_stake.owner).is_some(), + convert_error_message(format!("Unknown delegator {:?}", delegator_stake.owner)) + ); + + Ok(()) + }) +} + fn validate_stake() -> Result<(), &'static str> { // the total fund has to be the sum over the first [MaxSelectedCandidates] of // [TopCandidates]. - let top_candidates = TopCandidates::::get(); let top_n = MaxSelectedCandidates::::get().saturated_into::(); From 85cb9114e445dcc903a90b49643737bb81321e0b Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Tue, 16 May 2023 09:12:03 +0200 Subject: [PATCH 37/40] fixed tests --- pallets/attestation/Cargo.toml | 2 +- pallets/ctype/Cargo.toml | 2 +- pallets/delegation/Cargo.toml | 2 +- pallets/did/Cargo.toml | 1 + pallets/pallet-did-lookup/Cargo.toml | 2 +- pallets/pallet-web3-names/Cargo.toml | 2 +- pallets/parachain-staking/Cargo.toml | 1 + pallets/public-credentials/Cargo.toml | 3 ++- pallets/public-credentials/src/try_state.rs | 3 +-- 9 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pallets/attestation/Cargo.toml b/pallets/attestation/Cargo.toml index 70da38c9f..9b83cca7b 100644 --- a/pallets/attestation/Cargo.toml +++ b/pallets/attestation/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dev-dependencies] ctype = {workspace = true, features = ["mock"]} -kilt-support = {workspace = true, features = ["mock"]} +kilt-support = {workspace = true, features = ["mock", "try-runtime"]} pallet-balances = {workspace = true, features = ["std"]} serde.workspace = true diff --git a/pallets/ctype/Cargo.toml b/pallets/ctype/Cargo.toml index deb7e2be4..555640af6 100644 --- a/pallets/ctype/Cargo.toml +++ b/pallets/ctype/Cargo.toml @@ -14,7 +14,7 @@ description = "Enables adding CTypes." targets = ["x86_64-unknown-linux-gnu"] [dev-dependencies] -kilt-support = {workspace = true, features = ["mock"]} +kilt-support = {workspace = true, features = ["mock", "try-runtime"]} pallet-balances = {workspace = true, features = ["std"]} sp-core = {workspace = true, features = ["std"]} sp-keystore = {workspace = true, features = ["std"]} diff --git a/pallets/delegation/Cargo.toml b/pallets/delegation/Cargo.toml index 552c3ef50..a2df28e94 100644 --- a/pallets/delegation/Cargo.toml +++ b/pallets/delegation/Cargo.toml @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dev-dependencies] attestation = {workspace = true, features = ["mock"]} ctype = {workspace = true, features = ["mock"]} -kilt-support = {workspace = true, features = ["mock"]} +kilt-support = {workspace = true, features = ["mock", "try-runtime"]} # Substrate dependencies pallet-balances = {workspace = true, features = ["std"]} diff --git a/pallets/did/Cargo.toml b/pallets/did/Cargo.toml index 05ebda75d..2ec102139 100644 --- a/pallets/did/Cargo.toml +++ b/pallets/did/Cargo.toml @@ -17,6 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"] env_logger.workspace = true ctype = {workspace = true, features = ["mock"]} +kilt-support = {workspace = true, features = ["mock", "try-runtime"]} frame-benchmarking = {workspace = true, features = ["std"]} pallet-balances = {workspace = true, features = ["std"]} diff --git a/pallets/pallet-did-lookup/Cargo.toml b/pallets/pallet-did-lookup/Cargo.toml index 654144e31..323b369d1 100644 --- a/pallets/pallet-did-lookup/Cargo.toml +++ b/pallets/pallet-did-lookup/Cargo.toml @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dev-dependencies] env_logger.workspace = true -kilt-support = {workspace = true, features = ["mock"]} +kilt-support = {workspace = true, features = ["mock", "try-runtime"]} pallet-balances = {workspace = true, features = ["std"]} sp-core = {workspace = true, features = ["std"]} diff --git a/pallets/pallet-web3-names/Cargo.toml b/pallets/pallet-web3-names/Cargo.toml index 2706a25dd..844bd1fc2 100644 --- a/pallets/pallet-web3-names/Cargo.toml +++ b/pallets/pallet-web3-names/Cargo.toml @@ -14,7 +14,7 @@ description = "Unique Web3 nicknames for KILT DIDs." targets = ["x86_64-unknown-linux-gnu"] [dev-dependencies] -kilt-support = {workspace = true, features = ["mock"]} +kilt-support = {workspace = true, features = ["mock", "try-runtime"]} pallet-balances = {workspace = true, features = ["std"]} sp-core = {workspace = true, features = ["std"]} diff --git a/pallets/parachain-staking/Cargo.toml b/pallets/parachain-staking/Cargo.toml index 7bf64c3aa..7eea424f0 100644 --- a/pallets/parachain-staking/Cargo.toml +++ b/pallets/parachain-staking/Cargo.toml @@ -11,6 +11,7 @@ name = "parachain-staking" description = "Parachain parachain-staking pallet for collator delegation and selection as well as reward distribution" [dev-dependencies] +kilt-support = {workspace = true, features = ["mock", "try-runtime"]} pallet-aura = {workspace = true, features = ["std"]} pallet-timestamp = {workspace = true, features = ["std"]} sp-consensus-aura = {workspace = true, features = ["std"]} diff --git a/pallets/public-credentials/Cargo.toml b/pallets/public-credentials/Cargo.toml index 2a3791f95..506c5589e 100644 --- a/pallets/public-credentials/Cargo.toml +++ b/pallets/public-credentials/Cargo.toml @@ -12,7 +12,7 @@ description = "Enables adding and revoking public credentials." [dev-dependencies] ctype = {workspace = true, features = ["mock"]} -kilt-support = {workspace = true, features = ["mock"]} +kilt-support = {workspace = true, features = ["mock", "try-runtime"]} pallet-balances = {workspace = true, features = ["std"]} sp-io = {workspace = true, features = ["std"]} @@ -62,4 +62,5 @@ std = [ try-runtime = [ "frame-support/try-runtime", "frame-system/try-runtime", + "kilt-support/try-runtime" ] diff --git a/pallets/public-credentials/src/try_state.rs b/pallets/public-credentials/src/try_state.rs index 077e1ee67..62bd1664c 100644 --- a/pallets/public-credentials/src/try_state.rs +++ b/pallets/public-credentials/src/try_state.rs @@ -16,12 +16,11 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org +use crate::{Config, CredentialSubjects, Credentials}; use frame_support::ensure; use kilt_support::test::convert_error_message; use scale_info::prelude::format; -use crate::{Config, CredentialSubjects, Credentials}; - pub(crate) fn do_try_state() -> Result<(), &'static str> { Credentials::::iter().try_for_each(|(subject_id, credential_id, entry)| -> Result<(), &'static str> { ensure!( From 3d49caa972c206caefdbbe8d4b7e37d67f3516bc Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Tue, 16 May 2023 14:40:05 +0200 Subject: [PATCH 38/40] refactor error messages --- Cargo.lock | 1 + pallets/attestation/src/try_state.rs | 4 +- pallets/delegation/src/try_state.rs | 12 ++-- pallets/did/src/try_state.rs | 27 +++++-- pallets/pallet-did-lookup/src/try_state.rs | 6 +- pallets/pallet-web3-names/src/try_state.rs | 8 +-- pallets/parachain-staking/src/try_state.rs | 79 ++++++++++++++------- pallets/public-credentials/src/try_state.rs | 10 +-- support/Cargo.toml | 1 + support/src/lib.rs | 2 +- support/src/{test.rs => test_utils.rs} | 8 ++- 11 files changed, 102 insertions(+), 56 deletions(-) rename support/src/{test.rs => test_utils.rs} (80%) diff --git a/Cargo.lock b/Cargo.lock index 293a5fef2..ea8941a93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4070,6 +4070,7 @@ version = "1.11.0-dev" dependencies = [ "frame-support", "frame-system", + "log", "parity-scale-codec", "scale-info", "serde", diff --git a/pallets/attestation/src/try_state.rs b/pallets/attestation/src/try_state.rs index b40c1cbd4..a7af6c2ec 100644 --- a/pallets/attestation/src/try_state.rs +++ b/pallets/attestation/src/try_state.rs @@ -17,7 +17,7 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use frame_support::ensure; -use kilt_support::test::convert_error_message; +use kilt_support::test_utils::log_and_return_error_message; use scale_info::prelude::format; use crate::{Attestations, Config, ExternalAttestations}; @@ -27,7 +27,7 @@ pub(crate) fn do_try_state() -> Result<(), &'static str> { if let Some(authorization_id) = attestation_details.authorization_id { ensure!( ExternalAttestations::::get(&authorization_id, claim_hash), - convert_error_message(format!( + log_and_return_error_message(format!( "External attestation with authorization_id: {:?} and claim_hash {:?} does not exist", authorization_id, claim_hash )) diff --git a/pallets/delegation/src/try_state.rs b/pallets/delegation/src/try_state.rs index 054da4272..c3d340abf 100644 --- a/pallets/delegation/src/try_state.rs +++ b/pallets/delegation/src/try_state.rs @@ -17,7 +17,7 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use frame_support::ensure; -use kilt_support::test::convert_error_message; +use kilt_support::test_utils::log_and_return_error_message; use scale_info::prelude::format; use crate::{Config, DelegationHierarchies, DelegationNode, DelegationNodes}; @@ -29,7 +29,7 @@ pub(crate) fn do_try_state() -> Result<(), &'static str> { // check if node is in part of a delegation hierarchy. ensure!( DelegationHierarchies::::contains_key(hierarchy_id), - convert_error_message(format!("Delegation hierarchy {:?} not found", hierarchy_id)) + log_and_return_error_message(format!("Delegation hierarchy {:?} not found", hierarchy_id)) ); let parent_count = DelegationNodes::::iter_values() @@ -40,8 +40,8 @@ pub(crate) fn do_try_state() -> Result<(), &'static str> { // If node is a leaf or intermediate, check if it occurs only once. Otherwise we // have cycles. ensure!( - parent_count <= 1, - convert_error_message(format!( + parent_count == 1, + log_and_return_error_message(format!( "Delegation with cycles detected. Node {:?} in hierarchy {:?} has two or more parents.", delegation_node_id, hierarchy_id )) @@ -51,7 +51,7 @@ pub(crate) fn do_try_state() -> Result<(), &'static str> { // from another node. ensure!( parent_count == 0, - convert_error_message(format!( + log_and_return_error_message(format!( "Root node {:?} is child from other delegation nodes", delegation_node_id )) @@ -66,7 +66,7 @@ pub(crate) fn do_try_state() -> Result<(), &'static str> { .all(|x| x); ensure!( is_subtree_revoked, - convert_error_message(format!( + log_and_return_error_message(format!( "Revoked delegation node {:?} has an unrevoked subtree.", delegation_node_id )) diff --git a/pallets/did/src/try_state.rs b/pallets/did/src/try_state.rs index 822e99808..4efaaffef 100644 --- a/pallets/did/src/try_state.rs +++ b/pallets/did/src/try_state.rs @@ -17,7 +17,7 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use frame_support::ensure; -use kilt_support::test::convert_error_message; +use kilt_support::test_utils::log_and_return_error_message; use scale_info::prelude::format; use sp_core::Get; use sp_runtime::SaturatedConversion; @@ -31,23 +31,38 @@ pub(crate) fn do_try_state() -> Result<(), &'static str> { ensure!( service_endpoints_count == DidEndpointsCount::::get(&did_subject).saturated_into::(), - convert_error_message(format!("Did {:?} has not matching service endpoints.", did_subject)) + log_and_return_error_message(format!( + "Did {:?} has not matching service endpoints. In [ServiceEndpoints]: {:?} in [DidEndpointsCount]: {:?}", + did_subject, + service_endpoints_count, + DidEndpointsCount::::get(&did_subject) + )) ); ensure!( did_details.key_agreement_keys.len() <= (::MaxTotalKeyAgreementKeys::get()).saturated_into::(), - convert_error_message(format!("Did {:?} has to many key agreement keys.", did_subject,)) + log_and_return_error_message(format!( + "Did {:?} has to many key agreement keys. Allowed: {:?} found: {:?}", + did_subject, + ::MaxTotalKeyAgreementKeys::get(), + did_details.key_agreement_keys.len() + )) ); ensure!( service_endpoints_count <= ::MaxNumberOfServicesPerDid::get().saturated_into::(), - convert_error_message(format!("Did {:?} has to many service endpoints.", did_subject)) + log_and_return_error_message(format!( + "Did {:?} has to many service endpoints. Allowed: {:?} found: {:?}", + did_subject, + ::MaxNumberOfServicesPerDid::get(), + service_endpoints_count + )) ); ensure!( !DidBlacklist::::contains_key(&did_subject), - convert_error_message(format!("Did {:?} is blacklisted.", did_subject)) + log_and_return_error_message(format!("Did {:?} is blacklisted.", did_subject)) ); Ok(()) @@ -58,7 +73,7 @@ pub(crate) fn do_try_state() -> Result<(), &'static str> { let service_endpoints_count = ServiceEndpoints::::iter_prefix(&deleted_did_subject).count(); ensure!( service_endpoints_count == 0, - convert_error_message(format!( + log_and_return_error_message(format!( "Blacklisted did {:?} has service endpoints.", deleted_did_subject, )) diff --git a/pallets/pallet-did-lookup/src/try_state.rs b/pallets/pallet-did-lookup/src/try_state.rs index c3670ad9b..280eeadf8 100644 --- a/pallets/pallet-did-lookup/src/try_state.rs +++ b/pallets/pallet-did-lookup/src/try_state.rs @@ -17,7 +17,7 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use frame_support::ensure; -use kilt_support::test::convert_error_message; +use kilt_support::test_utils::log_and_return_error_message; use scale_info::prelude::format; use crate::{Config, ConnectedAccounts, ConnectedDids}; @@ -26,7 +26,7 @@ pub(crate) fn do_try_state() -> Result<(), &'static str> { ConnectedDids::::iter().try_for_each(|(account, record)| -> Result<(), &'static str> { ensure!( ConnectedAccounts::::contains_key(&record.did, &account), - convert_error_message(format!("Account {:?} with did {:?} not found", record.did, account)) + log_and_return_error_message(format!("Account {:?} with did {:?} not found", record.did, account)) ); Ok(()) })?; @@ -34,7 +34,7 @@ pub(crate) fn do_try_state() -> Result<(), &'static str> { ConnectedAccounts::::iter().try_for_each(|(did_identifier, linked_account_id, _)| -> Result<(), &'static str> { ensure!( ConnectedDids::::get(&linked_account_id).expect("Unknown did").did == did_identifier, - convert_error_message(format!( + log_and_return_error_message(format!( "Linked Account {:?} for did {:?} not match", linked_account_id, did_identifier )) diff --git a/pallets/pallet-web3-names/src/try_state.rs b/pallets/pallet-web3-names/src/try_state.rs index 6b92c626b..6ebcf611d 100644 --- a/pallets/pallet-web3-names/src/try_state.rs +++ b/pallets/pallet-web3-names/src/try_state.rs @@ -17,7 +17,7 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use frame_support::ensure; -use kilt_support::test::convert_error_message; +use kilt_support::test_utils::log_and_return_error_message; use scale_info::prelude::format; use crate::{Banned, Config, Names, Owner, Web3NameOf, Web3NameOwnerOf, Web3OwnershipOf}; @@ -28,7 +28,7 @@ pub fn do_try_state() -> Result<(), &'static str> { |(w3n, ownership): (Web3NameOf, Web3OwnershipOf)| -> Result<(), &'static str> { ensure!( Names::::get(&ownership.owner) == Some(w3n.clone()), - convert_error_message(format!( + log_and_return_error_message(format!( "Owned w3n from owner {:?} does not match with saved w3n {:?}", ownership.owner, w3n )) @@ -42,7 +42,7 @@ pub fn do_try_state() -> Result<(), &'static str> { |(w3n_owner, w3n): (Web3NameOwnerOf, Web3NameOf)| -> Result<(), &'static str> { ensure!( Owner::::get(&w3n).expect("Unknown w3n").owner == w3n_owner, - convert_error_message(format!("Owner {:?} with w3n {:?} not found", w3n_owner, w3n)) + log_and_return_error_message(format!("Owner {:?} with w3n {:?} not found", w3n_owner, w3n)) ); Ok(()) }, @@ -51,7 +51,7 @@ pub fn do_try_state() -> Result<(), &'static str> { Banned::::iter_keys().try_for_each(|banned_w3n| -> Result<(), &'static str> { ensure!( !Owner::::contains_key(&banned_w3n), - convert_error_message(format!("Owner contains banned name {:?}", banned_w3n)) + log_and_return_error_message(format!("Owner contains banned name {:?}", banned_w3n)) ); Ok(()) }) diff --git a/pallets/parachain-staking/src/try_state.rs b/pallets/parachain-staking/src/try_state.rs index e4a18c6b7..feb6e991b 100644 --- a/pallets/parachain-staking/src/try_state.rs +++ b/pallets/parachain-staking/src/try_state.rs @@ -17,9 +17,12 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org use frame_support::{ensure, traits::Get}; -use kilt_support::test::convert_error_message; +use kilt_support::test_utils::log_and_return_error_message; use scale_info::prelude::format; -use sp_runtime::{traits::Zero, SaturatedConversion, Saturating}; +use sp_runtime::{ + traits::{CheckedAdd, Zero}, + SaturatedConversion, Saturating, +}; use crate::{ set::OrderedSet, @@ -30,6 +33,7 @@ use crate::{ pub(crate) fn do_try_state() -> Result<(), &'static str> { validate_candiate_pool::()?; + validate_delegators::()?; validate_top_candidates::()?; validate_stake::() } @@ -38,7 +42,7 @@ fn validate_candiate_pool() -> Result<(), &'static str> { // check if enough collators are set. ensure!( CandidatePool::::count() >= T::MinCollators::get(), - convert_error_message(format!( + log_and_return_error_message(format!( "Insufficient collators. Collators count: {:?}. Min required collators: {:?}", CandidatePool::::count(), T::MinCollators::get() @@ -53,29 +57,37 @@ fn validate_candiate_pool() -> Result<(), &'static str> { .fold(Zero::zero(), |acc, stake| acc.saturating_add(stake.amount)); // total stake should be the sum of delegators stake + colator stake. - let stake_total = sum_delegations.saturating_add(candidate.stake); + let stake_total = sum_delegations.checked_add(&candidate.stake); ensure!( - stake_total == candidate.total, - convert_error_message(format!("Total stake of collator {:?} does not match", candidate.id)) + stake_total == Some(candidate.total), + log_and_return_error_message(format!( + "Total stake of collator {:?} does not match. Saved stake: {:?}. Calculated stake: {:?}", + candidate.id, candidate.stake, stake_total + )) ); // Min required stake should be set ensure!( candidate.stake >= T::MinCollatorCandidateStake::get(), - convert_error_message(format!("Stake of collator {:?} insufficient", candidate.id)) + log_and_return_error_message(format!( + "Stake of collator {:?} insufficient. Required stake: {:?}. Owned Stake: {:?} ", + candidate.id, + T::MinCollatorCandidateStake::get(), + candidate.stake + )) ); - validate_delegators::(candidate.delegators)?; + validate_delegators_from_collator::(candidate.delegators)?; // check min and max stake for each candidate ensure!( candidate.stake <= MaxCollatorCandidateStake::::get(), - convert_error_message(format!("Candidate {:?} exceeded stake", candidate.id)) - ); - - ensure!( - candidate.stake >= T::MinCollatorStake::get(), - convert_error_message(format!("Candidate {:?} insufficient stake", candidate.id)) + log_and_return_error_message(format!( + "Candidate {:?} exceeded stake. Allowed stake: {:?}. Owned Stake: {:?}", + candidate.id, + MaxCollatorCandidateStake::::get(), + candidate.stake + )) ); Ok(()) @@ -89,7 +101,7 @@ fn validate_top_candidates() -> Result<(), &'static str> { // check if enough top candidates are set. ensure!( top_candidates.len() >= T::MinRequiredCollators::get().saturated_into(), - convert_error_message(format!( + log_and_return_error_message(format!( "Not enough candidates are set. Candidate count: {:?}. Required: {:?}", top_candidates.len(), T::MinRequiredCollators::get() @@ -100,26 +112,26 @@ fn validate_top_candidates() -> Result<(), &'static str> { // top candidates should be part of the candidate pool. ensure!( CandidatePool::::contains_key(&stake.owner), - convert_error_message(format!("Unknown candidate {:?} in top candidates.", stake.owner)) + log_and_return_error_message(format!("Unknown candidate {:?} in top candidates.", stake.owner)) ); // an account can not be candidate and delegator. ensure!( DelegatorState::::get(&stake.owner).is_none(), - convert_error_message(format!("Account {:?} is delegator and candidate.", stake.owner)) + log_and_return_error_message(format!("Account {:?} is delegator and candidate.", stake.owner)) ); // a top candidate should be active. ensure!( Pallet::::is_active_candidate(&stake.owner).unwrap(), - convert_error_message(format!("Top candidate {:?} is inactive", stake.owner)) + log_and_return_error_message(format!("Top candidate {:?} is inactive", stake.owner)) ); Ok(()) }) } -fn validate_delegators( +fn validate_delegators_from_collator( delegators: OrderedSet>, T::MaxDelegatorsPerCollator>, ) -> Result<(), &'static str> { delegators @@ -136,21 +148,26 @@ fn validate_delegators( // each delegator should not exceed the [MaxDelegationsPerRound] ensure!( counter <= T::MaxDelegationsPerRound::get(), - convert_error_message(format!( - "Exceeded delegations per round. Delegator: {:?}", - delegator_stake.owner + log_and_return_error_message(format!( + "Delegator {:?} exceeded delegations per round. Allowed delegations {:?}. Confirmed delegations {:?}", + delegator_stake.owner, T::MaxDelegationsPerRound::get(), counter )) ); // each delegator should have the min required stake ensure!( delegator_stake.amount >= T::MinDelegatorStake::get(), - convert_error_message(format!("Delegator {:?} insufficient stake", delegator_stake.owner)) + log_and_return_error_message(format!( + "Delegator {:?} insufficient stake. Required stake: {:?}. Owned stake: {:?}", + delegator_stake.owner, + T::MinDelegatorStake::get(), + delegator_stake.amount + )) ); ensure!( DelegatorState::::get(&delegator_stake.owner).is_some(), - convert_error_message(format!("Unknown delegator {:?}", delegator_stake.owner)) + log_and_return_error_message(format!("Unknown delegator {:?}", delegator_stake.owner)) ); Ok(()) @@ -184,7 +201,7 @@ fn validate_stake() -> Result<(), &'static str> { ensure!( total_stake.collators == collator_stake, - convert_error_message(format!( + log_and_return_error_message(format!( "Corrupted total collator stake. Saved total stake: {:?}. Calculated stake: {:?}", total_stake.collators, collator_stake )) @@ -192,7 +209,7 @@ fn validate_stake() -> Result<(), &'static str> { ensure!( total_stake.delegators == delegator_state, - convert_error_message(format!( + log_and_return_error_message(format!( "Corrupted total delegator stake. Saved total stake: {:?}. Calculated stake: {:?}", total_stake.delegators, delegator_state )) @@ -200,3 +217,13 @@ fn validate_stake() -> Result<(), &'static str> { Ok(()) } + +fn validate_delegators() -> Result<(), &'static str> { + DelegatorState::::iter_values().try_for_each(|delegator_details| -> Result<(), &'static str> { + ensure!( + CandidatePool::::contains_key(&delegator_details.owner), + log_and_return_error_message(format!("Collator {:?} not found", delegator_details.owner)) + ); + Ok(()) + }) +} diff --git a/pallets/public-credentials/src/try_state.rs b/pallets/public-credentials/src/try_state.rs index 62bd1664c..749bd2de2 100644 --- a/pallets/public-credentials/src/try_state.rs +++ b/pallets/public-credentials/src/try_state.rs @@ -18,22 +18,22 @@ use crate::{Config, CredentialSubjects, Credentials}; use frame_support::ensure; -use kilt_support::test::convert_error_message; +use kilt_support::test_utils::log_and_return_error_message; use scale_info::prelude::format; pub(crate) fn do_try_state() -> Result<(), &'static str> { Credentials::::iter().try_for_each(|(subject_id, credential_id, entry)| -> Result<(), &'static str> { ensure!( CredentialSubjects::::get(&credential_id) == Some(subject_id.clone()), - convert_error_message(format!( + log_and_return_error_message(format!( "Credential subject does not match. Credential id: {:?}. Subject id: {:?}", credential_id, subject_id )) ); ensure!( - ctype::Ctypes::::contains_key(&entry.ctype_hash), - convert_error_message(format!("Unknown Ctype: {:?}", entry.ctype_hash)) + ctype::Ctypes::::contains_key(entry.ctype_hash), + log_and_return_error_message(format!("Unknown Ctype: {:?}", entry.ctype_hash)) ); Ok(()) @@ -42,7 +42,7 @@ pub(crate) fn do_try_state() -> Result<(), &'static str> { CredentialSubjects::::iter().try_for_each(|(credential_id, subject_id)| -> Result<(), &'static str> { ensure!( Credentials::::contains_key(subject_id, &credential_id), - convert_error_message(format!("Unknown credential {:?}", credential_id)) + log_and_return_error_message(format!("Unknown credential {:?}", credential_id)) ); Ok(()) }) diff --git a/support/Cargo.toml b/support/Cargo.toml index bb7fe9015..5a606fa9f 100644 --- a/support/Cargo.toml +++ b/support/Cargo.toml @@ -17,6 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"] # External dependencies parity-scale-codec = {workspace = true, features = ["derive"]} scale-info = {workspace = true, features = ["derive"]} +log = {workspace = true} # Substrate dependencies frame-support.workspace = true diff --git a/support/src/lib.rs b/support/src/lib.rs index efb9742cc..2f5a06dae 100644 --- a/support/src/lib.rs +++ b/support/src/lib.rs @@ -21,7 +21,7 @@ pub mod deposit; pub use deposit::{free_deposit, reserve_deposit}; #[cfg(any(feature = "try-runtime", test))] -pub mod test; +pub mod test_utils; #[cfg(any(feature = "runtime-benchmarks", feature = "mock"))] pub mod mock; diff --git a/support/src/test.rs b/support/src/test_utils.rs similarity index 80% rename from support/src/test.rs rename to support/src/test_utils.rs index 3b595a848..1876c12ea 100644 --- a/support/src/test.rs +++ b/support/src/test_utils.rs @@ -16,8 +16,10 @@ // If you feel like getting in touch with us, you can do so at info@botlabs.org -use scale_info::prelude::{boxed::Box, string::String}; +use scale_info::prelude::string::String; -pub fn convert_error_message(error_message: String) -> &'static str { - Box::leak(error_message.into_boxed_str()) +/// logges the error message +pub fn log_and_return_error_message(error_message: String) -> &'static str { + log::error!("{}", error_message); + "Sanity test error" } From 7c4cf6d12b58cf958876d024099f022e427d95af Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Tue, 16 May 2023 14:43:01 +0200 Subject: [PATCH 39/40] comments --- support/src/test_utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/src/test_utils.rs b/support/src/test_utils.rs index 1876c12ea..d4c9f3c90 100644 --- a/support/src/test_utils.rs +++ b/support/src/test_utils.rs @@ -18,7 +18,7 @@ use scale_info::prelude::string::String; -/// logges the error message +/// logges the error message and returns "Sanity test error" pub fn log_and_return_error_message(error_message: String) -> &'static str { log::error!("{}", error_message); "Sanity test error" From 3daa93952b31b58a8d40bc26b7831cc8ac3ebea3 Mon Sep 17 00:00:00 2001 From: Adel Golghalyani Date: Tue, 16 May 2023 14:43:32 +0200 Subject: [PATCH 40/40] comments --- support/src/test_utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/src/test_utils.rs b/support/src/test_utils.rs index d4c9f3c90..d0bfffed6 100644 --- a/support/src/test_utils.rs +++ b/support/src/test_utils.rs @@ -18,7 +18,7 @@ use scale_info::prelude::string::String; -/// logges the error message and returns "Sanity test error" +/// Logs the error message and returns "Sanity test error" pub fn log_and_return_error_message(error_message: String) -> &'static str { log::error!("{}", error_message); "Sanity test error"