diff --git a/Cargo.lock b/Cargo.lock index 026013d64fba35d21049e887629ccba08a889855..45eec7591be68d97f01a4d9ff35c8bb629a5cf9f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6603,7 +6603,6 @@ dependencies = [ "maplit", "pallet-balances", "pallet-identity", - "pallet-provide-randomness", "pallet-quota", "pallet-transaction-payment", "pallet-treasury", diff --git a/docs/api/runtime-events.md b/docs/api/runtime-events.md index 71abd3323f1538d626c6f8f8ffa739b70cc86511..0787b7f5f8ee5e5b077eb6c9eacd18f93aa018e5 100644 --- a/docs/api/runtime-events.md +++ b/docs/api/runtime-events.md @@ -1,6 +1,6 @@ # Runtime events -There are **129** events from **35** pallets. +There are **128** events from **35** pallets. <ul> <li>System - 0 @@ -112,20 +112,7 @@ balance: T::Balance <li> <details> <summary> -<code>RandomIdAssigned(who, random_id)</code> - 1</summary> -A random ID has been assigned to the account. - -```rust -who: T::AccountId -random_id: H256 -``` - -</details> -</li> -<li> -<details> -<summary> -<code>AccountLinked(who, identity)</code> - 2</summary> +<code>AccountLinked(who, identity)</code> - 1</summary> account linked to identity ```rust @@ -138,7 +125,7 @@ identity: IdtyIdOf<T> <li> <details> <summary> -<code>AccountUnlinked()</code> - 3</summary> +<code>AccountUnlinked()</code> - 2</summary> The account was unlinked from its identity. ```rust diff --git a/live-tests/tests/sanity_gdev.rs b/live-tests/tests/sanity_gdev.rs index 814af07860f50a9ac52f2a6e9dc0d01752dd0fa9..86cec2524db03228691c8a5b48dc5dfa4ffda3fb 100644 --- a/live-tests/tests/sanity_gdev.rs +++ b/live-tests/tests/sanity_gdev.rs @@ -235,10 +235,10 @@ mod verifier { if account_id.as_slice() != TREASURY_ACCOUNT_ID { // Rule 4: If the account is not a "special account", - // it should have a random id or a consumer + // it should have a consumer self.assert( - account_info.data.random_id.is_some() || account_info.consumers > 0, - format!("Account {} has no random_id nor consumer.", account_id), + account_info.consumers > 0, + format!("Account {} has no consumer.", account_id), ); } } diff --git a/node/src/chain_spec/gen_genesis_data.rs b/node/src/chain_spec/gen_genesis_data.rs index ba2609e03f305f23f455b9b8190b678c6c284fdd..b6ce08e5f022bac5bb6ef8d3ac5c5011802c3bd8 100644 --- a/node/src/chain_spec/gen_genesis_data.rs +++ b/node/src/chain_spec/gen_genesis_data.rs @@ -25,7 +25,7 @@ use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId; use sp_consensus_babe::AuthorityId as BabeId; use sp_consensus_grandpa::AuthorityId as GrandpaId; use sp_core::crypto::AccountId32; -use sp_core::{blake2_256, ed25519, sr25519, Decode, Encode, H256}; +use sp_core::{ed25519, sr25519, Decode, Encode}; use sp_runtime::traits::{IdentifyAccount, Verify}; use sp_runtime::{MultiSignature, Perbill}; use std::collections::{BTreeMap, HashMap}; @@ -1162,7 +1162,6 @@ fn v1_wallets_to_v2_accounts( accounts.insert( owner_key.clone(), GenesisAccountData { - random_id: H256(blake2_256(&(balance, &owner_key).encode())), balance, idty_id: None, }, @@ -1425,7 +1424,6 @@ fn feed_identities( accounts.insert( identity.owner_key.clone(), GenesisAccountData { - random_id: H256(blake2_256(&(identity.index, &identity.owner_key).encode())), balance: identity.balance, idty_id: Some(identity.index), }, @@ -1747,9 +1745,6 @@ where ( owner_key.clone(), GenesisAccountData { - random_id: H256(blake2_256( - &(i as u32 + idty_index_start, owner_key).encode(), - )), // Should be sufficient for the overhead benchmark balance: initial_idty_balance, idty_id: Some(i as u32 + idty_index_start), diff --git a/pallets/README.md b/pallets/README.md index 4e229119e7a0cb4fb333f433b3eb374d1ae87b32..e25c7907f787bcd0919f56e8379242874624bd07 100644 --- a/pallets/README.md +++ b/pallets/README.md @@ -8,7 +8,7 @@ These pallets are at the core of Duniter/Äž1 currency - **`authority-members`** Duniter authorities are not selected with staking but through a smith web of trust. - **`certification`** Certifications are the "edges" of Duniter's dynamic directed graph. They mean the acceptation of a Licence. -- **`duniter-account`** Duniter customized the `AccountData` defined in the `Balances` pallet to introduce a `RandomId`. +- **`duniter-account`** Duniter customized the `AccountData` defined in the `Balances` pallet to introduce a `linked_idty`. - **`duniter-wot`** Merges identities, membership, certifications and distance pallets to implement Duniter Web of Trust. - **`distance`** Publishes median of distance computation results provided by inherents coming from `distance-oracle` workers. - **`identity`** Identities are the "nodes" of Duniter's dynamic directed graph. They are one-to-one mapping to human being. diff --git a/pallets/duniter-account/Cargo.toml b/pallets/duniter-account/Cargo.toml index 8e1dca7dc499963b0fbcce19c5ff1ffc341b5ee6..304f5f33155b2751faf52c079df0c1cf5e05ccc9 100644 --- a/pallets/duniter-account/Cargo.toml +++ b/pallets/duniter-account/Cargo.toml @@ -17,7 +17,6 @@ runtime-benchmarks = [ 'frame-system/runtime-benchmarks', 'sp-runtime/runtime-benchmarks', 'pallet-identity/runtime-benchmarks', - 'pallet-provide-randomness/runtime-benchmarks', 'pallet-treasury/runtime-benchmarks', 'pallet-quota/runtime-benchmarks', 'pallet-balances/runtime-benchmarks', @@ -30,7 +29,6 @@ std = [ 'pallet-balances/std', 'pallet-transaction-payment/std', 'pallet-identity/std', - 'pallet-provide-randomness/std', 'pallet-treasury/std', 'pallet-quota/std', 'serde/std', @@ -46,7 +44,6 @@ try-runtime = [ 'frame-system/try-runtime', 'sp-runtime/try-runtime', 'pallet-identity/try-runtime', - 'pallet-provide-randomness/try-runtime', 'pallet-treasury/try-runtime', 'pallet-quota/try-runtime', 'pallet-balances/try-runtime', @@ -57,7 +54,6 @@ try-runtime = [ # local pallet-quota = { path = "../quota", default-features = false } pallet-identity = { path = "../identity", default-features = false } -pallet-provide-randomness = { path = "../provide-randomness", default-features = false } # crates.io codec = { package = 'parity-scale-codec', version = "3.6.9", default-features = false, features = ["derive"] } diff --git a/pallets/duniter-account/README.md b/pallets/duniter-account/README.md index 5d9e73b1432fb840b2c58869fe9cceb175cc0290..185e37ce5496a348698d413f9166637a41a22692 100644 --- a/pallets/duniter-account/README.md +++ b/pallets/duniter-account/README.md @@ -1,12 +1,6 @@ # Duniter account pallet -Duniter customizes the `AccountData` of the `Balances` Substrate pallet. In particular, it adds the fields `random_id` and `linked_idty`. - -## RandomID - -The RandomId field was added with the idea to provide a unique id that can not be controlled by user to serve as a basis for robust identification. The discussion is available on the forum. - -https://forum.duniter.org/t/la-solution-pour-des-identicones-securisees-le-random-id/9126 +Duniter customizes the `AccountData` of the `Balances` Substrate pallet. In particular, it adds the field `linked_idty`. ## Account creation fee diff --git a/pallets/duniter-account/src/benchmarking.rs b/pallets/duniter-account/src/benchmarking.rs index 27a839e1a714503c4c3f01dd940f1cec48576771..b5594e7d2b4c235d40bf0c736fe5baaa8cc5d1ba 100644 --- a/pallets/duniter-account/src/benchmarking.rs +++ b/pallets/duniter-account/src/benchmarking.rs @@ -21,14 +21,9 @@ use super::*; use frame_benchmarking::{account, benchmarks, whitelisted_caller}; use frame_support::sp_runtime::{traits::One, Saturating}; use frame_support::traits::{Currency, Get}; -use pallet_provide_randomness::OnFilledRandomness; use crate::Pallet; -fn assert_has_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) { - frame_system::Pallet::<T>::assert_has_event(generic_event.into()); -} - fn create_pending_accounts<T: Config>( i: u32, is_balance: bool, @@ -72,19 +67,4 @@ benchmarks! { on_initialize_no_balance { let i in 0 .. T::MaxNewAccountsPerBlock::get() => create_pending_accounts::<T>(i, false, false)?; }: { Pallet::<T>::on_initialize(BlockNumberFor::<T>::one()); } - on_filled_randomness_pending { - let caller: T::AccountId = whitelisted_caller(); - let randomness = H256(T::AccountIdToSalt::convert(caller.clone())); - let request_id = pallet_provide_randomness::Pallet::<T>::force_request(pallet_provide_randomness::RandomnessType::RandomnessFromTwoEpochsAgo, randomness); - PendingRandomIdAssignments::<T>::insert(request_id, caller.clone()); - }: { Pallet::<T>::on_filled_randomness(request_id, randomness); } - verify { - assert_has_event::<T>(Event::<T>::RandomIdAssigned { who: caller, random_id: randomness }.into()); - } - on_filled_randomness_no_pending { - let caller: T::AccountId = whitelisted_caller(); - let randomness = H256(T::AccountIdToSalt::convert(caller.clone())); - let request_id = pallet_provide_randomness::Pallet::<T>::force_request(pallet_provide_randomness::RandomnessType::RandomnessFromTwoEpochsAgo, randomness); - assert!(!PendingRandomIdAssignments::<T>::contains_key(request_id)); - }: { Pallet::<T>::on_filled_randomness(request_id, randomness); } } diff --git a/pallets/duniter-account/src/lib.rs b/pallets/duniter-account/src/lib.rs index 05f0c69e357a234e3a26e2315a05c0d644f21ed2..596554ec7b4a1749722617b9d19563806540a09b 100644 --- a/pallets/duniter-account/src/lib.rs +++ b/pallets/duniter-account/src/lib.rs @@ -32,10 +32,8 @@ use frame_support::pallet_prelude::*; use frame_support::traits::{Currency, ExistenceRequirement, StorageVersion}; use frame_support::traits::{OnUnbalanced, StoredMap}; use frame_system::pallet_prelude::*; -use pallet_provide_randomness::RequestId; use pallet_quota::traits::RefundFee; use pallet_transaction_payment::OnChargeTransaction; -use sp_core::H256; use sp_runtime::traits::{Convert, DispatchInfoOf, PostDispatchInfoOf, Saturating}; use sp_std::fmt::Debug; @@ -61,7 +59,6 @@ pub mod pallet { pub trait Config: frame_system::Config<AccountData = AccountData<Self::Balance, IdtyIdOf<Self>>> + pallet_balances::Config - + pallet_provide_randomness::Config<Currency = pallet_balances::Pallet<Self>> + pallet_transaction_payment::Config + pallet_treasury::Config<Currency = pallet_balances::Pallet<Self>> + pallet_quota::Config @@ -75,6 +72,8 @@ pub mod pallet { type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>; /// Type representing the weight of this pallet type WeightInfo: WeightInfo; + /// Handler for the unbalanced reduction when the requestor pays fees. + type OnUnbalanced: OnUnbalanced<pallet_balances::NegativeImbalance<Self>>; /// wrapped type type InnerOnChargeTransaction: OnChargeTransaction<Self>; /// type implementing refund behavior @@ -83,11 +82,6 @@ pub mod pallet { // STORAGE // - #[pallet::storage] - #[pallet::getter(fn pending_random_id_assignments)] - pub type PendingRandomIdAssignments<T: Config> = - StorageMap<_, Twox64Concat, RequestId, T::AccountId, OptionQuery>; - #[pallet::storage] #[pallet::getter(fn pending_new_accounts)] pub type PendingNewAccounts<T: Config> = @@ -120,7 +114,6 @@ pub mod pallet { frame_system::Account::<T>::mutate( pallet_treasury::Pallet::<T>::account_id(), |account| { - account.data.random_id = None; account.data.free = self.treasury_balance; account.providers = 1; }, @@ -139,20 +132,11 @@ pub mod pallet { ); // Classic accounts - for ( - account_id, - GenesisAccountData { - random_id, - balance, - idty_id, - }, - ) in &self.accounts - { + for (account_id, GenesisAccountData { balance, idty_id }) in &self.accounts { // if the balance is below existential deposit, the account must be an identity assert!(balance >= &T::ExistentialDeposit::get() || idty_id.is_some()); // mutate account frame_system::Account::<T>::mutate(account_id, |account| { - account.data.random_id = Some(*random_id); account.data.free = *balance; if idty_id.is_some() { account.data.linked_idty = *idty_id; @@ -179,8 +163,6 @@ pub mod pallet { who: T::AccountId, balance: T::Balance, }, - /// A random ID has been assigned to the account. - RandomIdAssigned { who: T::AccountId, random_id: H256 }, /// account linked to identity AccountLinked { who: T::AccountId, @@ -243,11 +225,6 @@ pub mod pallet { { if frame_system::Pallet::<T>::sufficients(&account_id) > 0 { // If the account is self-sufficient, it is exempt from account creation fees - let request_id = pallet_provide_randomness::Pallet::<T>::force_request( - pallet_provide_randomness::RandomnessType::RandomnessFromTwoEpochsAgo, - H256(T::AccountIdToSalt::convert(account_id.clone())), - ); - PendingRandomIdAssignments::<T>::insert(request_id, account_id); total_weight += <T as pallet::Config>::WeightInfo::on_initialize_sufficient( T::MaxNewAccountsPerBlock::get(), ); @@ -258,11 +235,7 @@ pub mod pallet { if account_data.free >= T::ExistentialDeposit::get() + price { // The account can pay the new account price, we should: // 1. Withdraw the "new account price" amount - // 2. Increment consumers to prevent the destruction of the account before - // the random id is assigned - // 3. Manage the funds collected - // 4. Submit random id generation request - // 5. Save the id of the random generation request. + // 2. Manage the funds collected let res = <pallet_balances::Pallet<T> as Currency<T::AccountId>>::withdraw( &account_id, price, @@ -274,18 +247,7 @@ pub mod pallet { "Cannot fail because we checked that the free balance was sufficient" ); if let Ok(imbalance) = res { - let res = - frame_system::Pallet::<T>::inc_consumers_without_limit(&account_id); - debug_assert!( - res.is_ok(), - "Cannot fail because any account with funds should have providers" - ); T::OnUnbalanced::on_unbalanced(imbalance); - let request_id = pallet_provide_randomness::Pallet::<T>::force_request( - pallet_provide_randomness::RandomnessType::RandomnessFromTwoEpochsAgo, - H256(T::AccountIdToSalt::convert(account_id.clone())), - ); - PendingRandomIdAssignments::<T>::insert(request_id, account_id); total_weight += <T as pallet::Config>::WeightInfo::on_initialize_with_balance( T::MaxNewAccountsPerBlock::get(), @@ -332,28 +294,6 @@ where } } -// implement on filled randomness -impl<T> pallet_provide_randomness::OnFilledRandomness for Pallet<T> -where - T: Config, -{ - fn on_filled_randomness(request_id: RequestId, randomness: H256) -> Weight { - if let Some(account_id) = PendingRandomIdAssignments::<T>::take(request_id) { - frame_system::Account::<T>::mutate(&account_id, |account| { - account.consumers = account.consumers.saturating_sub(1); - account.data.random_id = Some(randomness); - }); - Self::deposit_event(Event::RandomIdAssigned { - who: account_id, - random_id: randomness, - }); - <T as pallet::Config>::WeightInfo::on_filled_randomness_pending() - } else { - <T as pallet::Config>::WeightInfo::on_filled_randomness_no_pending() - } - } -} - // implement accountdata storedmap impl<T, AccountId, Balance> frame_support::traits::StoredMap<AccountId, pallet_balances::AccountData<Balance>> for Pallet<T> @@ -378,8 +318,7 @@ where + scale_info::TypeInfo, T: Config + frame_system::Config<AccountId = AccountId, AccountData = AccountData<Balance, IdtyIdOf<T>>> - + pallet_balances::Config<Balance = Balance> - + pallet_provide_randomness::Config, + + pallet_balances::Config<Balance = Balance>, { fn get(k: &AccountId) -> pallet_balances::AccountData<Balance> { frame_system::Account::<T>::get(k).data.into() @@ -399,7 +338,7 @@ where let result = f(&mut some_data)?; let is_providing = some_data.is_some(); match (was_providing, is_providing) { - // the account has just been created, increment its provider and request a random_id + // the account has just been created, increment its provider (false, true) => { frame_system::Pallet::<T>::inc_providers(account_id); PendingNewAccounts::<T>::insert(account_id, ()); diff --git a/pallets/duniter-account/src/types.rs b/pallets/duniter-account/src/types.rs index 77553c4db3c34a3e6e7520b302a78c7b6368a570..c44cb08734204b753a4fe1852b86c337d2de0160 100644 --- a/pallets/duniter-account/src/types.rs +++ b/pallets/duniter-account/src/types.rs @@ -17,15 +17,11 @@ use codec::{Decode, Encode, MaxEncodedLen}; use frame_support::pallet_prelude::*; use scale_info::TypeInfo; -use sp_core::H256; use sp_runtime::traits::Zero; // see `struct AccountData` for details in substrate code #[derive(Clone, Decode, Encode, Eq, MaxEncodedLen, PartialEq, RuntimeDebug, TypeInfo)] // Default, pub struct AccountData<Balance, IdtyId> { - /// A random identifier that can not be chosen by the user - // this intends to be used as a robust identification system - pub(super) random_id: Option<H256>, // see Substrate AccountData pub(super) free: Balance, // see Substrate AccountData @@ -43,7 +39,6 @@ impl<Balance: Zero, IdtyId> Default for AccountData<Balance, IdtyId> { fn default() -> Self { Self { linked_idty: None, - random_id: None, free: Balance::zero(), reserved: Balance::zero(), fee_frozen: Balance::zero(), @@ -89,7 +84,6 @@ impl<Balance: Zero, IdtyId> From<AccountData<Balance, IdtyId>> )] #[serde(deny_unknown_fields)] pub struct GenesisAccountData<Balance, IdtyId> { - pub random_id: H256, pub balance: Balance, pub idty_id: Option<IdtyId>, } diff --git a/pallets/duniter-account/src/weights.rs b/pallets/duniter-account/src/weights.rs index d8ccf6bb58cbb363ba0c5a885bdc9f008b06295d..f4bbe1588187b65fdaf20824e26883ca88dcf7dc 100644 --- a/pallets/duniter-account/src/weights.rs +++ b/pallets/duniter-account/src/weights.rs @@ -23,8 +23,6 @@ pub trait WeightInfo { fn on_initialize_sufficient(i: u32) -> Weight; fn on_initialize_with_balance(i: u32) -> Weight; fn on_initialize_no_balance(i: u32) -> Weight; - fn on_filled_randomness_pending() -> Weight; - fn on_filled_randomness_no_pending() -> Weight; fn unlink_identity() -> Weight; } @@ -43,13 +41,7 @@ impl WeightInfo for () { } // Storage: Account PendingNewAccounts (r:1 w:0) - // Storage: ProvideRandomness RequestIdProvider (r:1 w:1) - // Storage: ProvideRandomness RequestsIds (r:1 w:1) - // Storage: ProvideRandomness CounterForRequestsIds (r:1 w:1) // Storage: Babe EpochIndex (r:1 w:0) - // Storage: ProvideRandomness NexEpochHookIn (r:1 w:0) - // Storage: ProvideRandomness RequestsReadyAtEpoch (r:1 w:1) - // Storage: Account PendingRandomIdAssignments (r:0 w:1) /// The range of component `i` is `[0, 1]`. fn on_initialize_sufficient(i: u32) -> Weight { // Minimum execution time: 12_958 nanoseconds. @@ -62,13 +54,7 @@ impl WeightInfo for () { } // Storage: Account PendingNewAccounts (r:1 w:0) - // Storage: ProvideRandomness RequestIdProvider (r:1 w:1) - // Storage: ProvideRandomness RequestsIds (r:1 w:1) - // Storage: ProvideRandomness CounterForRequestsIds (r:1 w:1) // Storage: Babe EpochIndex (r:1 w:0) - // Storage: ProvideRandomness NexEpochHookIn (r:1 w:0) - // Storage: ProvideRandomness RequestsReadyAtEpoch (r:1 w:1) - // Storage: Account PendingRandomIdAssignments (r:0 w:1) /// The range of component `i` is `[0, 1]`. fn on_initialize_with_balance(i: u32) -> Weight { // Minimum execution time: 12_965 nanoseconds. @@ -90,19 +76,4 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(i as u64))) } - - // Storage: Account PendingRandomIdAssignments (r:1 w:1) - fn on_filled_randomness_pending() -> Weight { - // Minimum execution time: 66_963 nanoseconds. - Weight::from_parts(69_757_000 as u64, 0) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().writes(1 as u64)) - } - - // Storage: Account PendingRandomIdAssignments (r:1 w:0) - fn on_filled_randomness_no_pending() -> Weight { - // Minimum execution time: 16_088 nanoseconds. - Weight::from_parts(27_963_000 as u64, 0) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - } } diff --git a/resources/metadata.scale b/resources/metadata.scale index f963c977883e0d240b34d87f1b77b461ffcdee71..26b30e4664d0ced1c6e5a8bb586ccfd1ace71403 100644 Binary files a/resources/metadata.scale and b/resources/metadata.scale differ diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs index d1893985c5523820fca3bd790bb3593d615661fb..a2262503e2e80118c9eb6c8b474e3aa9a7e03186 100644 --- a/runtime/common/src/pallets_config.rs +++ b/runtime/common/src/pallets_config.rs @@ -108,6 +108,7 @@ type RuntimeTask = (); // does currency adapter in any case, but adds "refund with quota" feature type InnerOnChargeTransaction = CurrencyAdapter<Balances, HandleFees>; type Refund = Quota; + type OnUnbalanced = Treasury; } // QUOTA // @@ -347,7 +348,7 @@ type RuntimeFreezeReason = (); type GetCurrentEpochIndex = GetCurrentEpochIndex<Self>; type MaxRequests = frame_support::traits::ConstU32<100>; type RequestPrice = frame_support::traits::ConstU64<2_000>; - type OnFilledRandomness = Account; + type OnFilledRandomness = (); type OnUnbalanced = Treasury; type ParentBlockRandomness = pallet_babe::ParentBlockRandomness<Self>; type RandomnessFromOneEpochAgo = pallet_babe::RandomnessFromOneEpochAgo<Self>; diff --git a/runtime/common/src/weights/pallet_duniter_account.rs b/runtime/common/src/weights/pallet_duniter_account.rs index 797603e6655d168ef4d66eff1396b14bc32d27fb..3dcee20a0ce4fbcf476231f238cfcf5f6992db3c 100644 --- a/runtime/common/src/weights/pallet_duniter_account.rs +++ b/runtime/common/src/weights/pallet_duniter_account.rs @@ -61,20 +61,8 @@ impl<T: frame_system::Config> pallet_duniter_account::WeightInfo for WeightInfo< } /// Storage: `Account::PendingNewAccounts` (r:1 w:1) /// Proof: `Account::PendingNewAccounts` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `ProvideRandomness::RequestIdProvider` (r:1 w:1) - /// Proof: `ProvideRandomness::RequestIdProvider` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ProvideRandomness::RequestsIds` (r:1 w:1) - /// Proof: `ProvideRandomness::RequestsIds` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `ProvideRandomness::CounterForRequestsIds` (r:1 w:1) - /// Proof: `ProvideRandomness::CounterForRequestsIds` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Babe::EpochIndex` (r:1 w:0) /// Proof: `Babe::EpochIndex` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) - /// Storage: `ProvideRandomness::NexEpochHookIn` (r:1 w:0) - /// Proof: `ProvideRandomness::NexEpochHookIn` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ProvideRandomness::RequestsReadyAtEpoch` (r:1 w:1) - /// Proof: `ProvideRandomness::RequestsReadyAtEpoch` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Account::PendingRandomIdAssignments` (r:0 w:1) - /// Proof: `Account::PendingRandomIdAssignments` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `i` is `[0, 1]`. fn on_initialize_sufficient(i: u32, ) -> Weight { // Proof Size summary in bytes: @@ -94,20 +82,8 @@ impl<T: frame_system::Config> pallet_duniter_account::WeightInfo for WeightInfo< /// Proof: `Account::PendingNewAccounts` (`max_values`: None, `max_size`: None, mode: `Measured`) /// Storage: `System::Account` (r:1 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(126), added: 2601, mode: `MaxEncodedLen`) - /// Storage: `ProvideRandomness::RequestIdProvider` (r:1 w:1) - /// Proof: `ProvideRandomness::RequestIdProvider` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ProvideRandomness::RequestsIds` (r:1 w:1) - /// Proof: `ProvideRandomness::RequestsIds` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `ProvideRandomness::CounterForRequestsIds` (r:1 w:1) - /// Proof: `ProvideRandomness::CounterForRequestsIds` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Babe::EpochIndex` (r:1 w:0) /// Proof: `Babe::EpochIndex` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`) - /// Storage: `ProvideRandomness::NexEpochHookIn` (r:1 w:0) - /// Proof: `ProvideRandomness::NexEpochHookIn` (`max_values`: Some(1), `max_size`: None, mode: `Measured`) - /// Storage: `ProvideRandomness::RequestsReadyAtEpoch` (r:1 w:1) - /// Proof: `ProvideRandomness::RequestsReadyAtEpoch` (`max_values`: None, `max_size`: None, mode: `Measured`) - /// Storage: `Account::PendingRandomIdAssignments` (r:0 w:1) - /// Proof: `Account::PendingRandomIdAssignments` (`max_values`: None, `max_size`: None, mode: `Measured`) /// The range of component `i` is `[0, 1]`. fn on_initialize_with_balance(i: u32, ) -> Weight { // Proof Size summary in bytes: @@ -139,27 +115,4 @@ impl<T: frame_system::Config> pallet_duniter_account::WeightInfo for WeightInfo< .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) .saturating_add(Weight::from_parts(0, 74).saturating_mul(i.into())) } - /// Storage: `Account::PendingRandomIdAssignments` (r:1 w:1) - /// Proof: `Account::PendingRandomIdAssignments` (`max_values`: None, `max_size`: None, mode: `Measured`) - fn on_filled_randomness_pending() -> Weight { - // Proof Size summary in bytes: - // Measured: `116` - // Estimated: `3581` - // Minimum execution time: 20_089_000 picoseconds. - Weight::from_parts(21_261_000, 0) - .saturating_add(Weight::from_parts(0, 3581)) - .saturating_add(T::DbWeight::get().reads(1)) - .saturating_add(T::DbWeight::get().writes(1)) - } - /// Storage: `Account::PendingRandomIdAssignments` (r:1 w:0) - /// Proof: `Account::PendingRandomIdAssignments` (`max_values`: None, `max_size`: None, mode: `Measured`) - fn on_filled_randomness_no_pending() -> Weight { - // Proof Size summary in bytes: - // Measured: `42` - // Estimated: `3507` - // Minimum execution time: 4_511_000 picoseconds. - Weight::from_parts(4_829_000, 0) - .saturating_add(Weight::from_parts(0, 3507)) - .saturating_add(T::DbWeight::get().reads(1)) - } } diff --git a/runtime/gdev/tests/common/mod.rs b/runtime/gdev/tests/common/mod.rs index 249653ec218918ba9566cc79368c602509889012..95933e5250558e7b62f57f20be6a9584942ce5d6 100644 --- a/runtime/gdev/tests/common/mod.rs +++ b/runtime/gdev/tests/common/mod.rs @@ -73,7 +73,6 @@ impl ExtBuilder { get_account_id_from_seed::<sr25519::Public>(NAMES[i]), GenesisAccountData { balance: 0, - random_id: H256([i as u8; 32]), idty_id: Some(i as u32 + 1), }, ) @@ -123,7 +122,6 @@ impl ExtBuilder { self.initial_accounts .entry(account_id.clone()) .or_insert(GenesisAccountData { - random_id: H256(account_id.into()), ..Default::default() }) .balance = balance; diff --git a/runtime/gdev/tests/integration_tests.rs b/runtime/gdev/tests/integration_tests.rs index 4624094d431f677308915f2a3e2ca1175f0ca226..bd6332369059e9660de2b2ec78a310a47cd2c59b 100644 --- a/runtime/gdev/tests/integration_tests.rs +++ b/runtime/gdev/tests/integration_tests.rs @@ -1056,42 +1056,25 @@ fn test_create_new_account() { // 100 initial + 300 deposit assert_eq!(Balances::free_balance(Treasury::account_id()), 400); - // A random id request should be registered - assert_eq!( - Account::pending_random_id_assignments(0), - Some(AccountKeyring::Eve.to_account_id()) - ); - - // We can't remove the account until the random id is assigned run_to_block(4); - // can not remove using transfer - assert_noop!( - Balances::transfer_allow_death( - frame_system::RawOrigin::Signed(AccountKeyring::Eve.to_account_id()).into(), - MultiAddress::Id(AccountKeyring::Alice.to_account_id()), - 200 - ), - sp_runtime::DispatchError::ConsumerRemaining, - ); + // can remove an account using transfer + assert_ok!(Balances::transfer_allow_death( + frame_system::RawOrigin::Signed(AccountKeyring::Eve.to_account_id()).into(), + MultiAddress::Id(AccountKeyring::Alice.to_account_id()), + 200 + )); + // Account reaped assert_eq!( Balances::free_balance(AccountKeyring::Eve.to_account_id()), - 200 - ); - // can not remove using transfer_all either - assert_noop!( - Balances::transfer_all( - frame_system::RawOrigin::Signed(AccountKeyring::Eve.to_account_id()).into(), - MultiAddress::Id(AccountKeyring::Alice.to_account_id()), - false - ), - sp_runtime::DispatchError::ConsumerRemaining, + 0 ); - // Transfer failed, so free_balance remains the same assert_eq!( - Balances::free_balance(AccountKeyring::Eve.to_account_id()), - 200 + frame_system::Pallet::<Runtime>::get(&AccountKeyring::Eve.to_account_id()), + pallet_duniter_account::AccountData::default() ); - // TODO detail account removal + System::assert_has_event(RuntimeEvent::System(frame_system::Event::KilledAccount { + account: AccountKeyring::Eve.to_account_id(), + })); }); } @@ -1118,12 +1101,6 @@ fn test_create_new_idty() { run_to_block(3); let events = System::events(); assert_eq!(events.len(), 0); - - // A random id request should be registered - assert_eq!( - Account::pending_random_id_assignments(0), - Some(AccountKeyring::Eve.to_account_id()) - ); }); } @@ -1156,25 +1133,19 @@ fn test_create_new_idty_without_founds() { let events = System::events(); assert_eq!(events.len(), 0); - // Deposit some founds on the identity account, - // this should trigger the random id assignemt + // Deposit some founds on the identity account assert_ok!(Balances::transfer_allow_death( frame_system::RawOrigin::Signed(AccountKeyring::Alice.to_account_id()).into(), MultiAddress::Id(AccountKeyring::Eve.to_account_id()), 200 )); - // At next block, nothing should be preleved, - // and a random id request should be registered + // At next block, nothing should be preleved run_to_block(4); assert_eq!( Balances::free_balance(AccountKeyring::Eve.to_account_id()), 200 ); - assert_eq!( - Account::pending_random_id_assignments(0), - Some(AccountKeyring::Eve.to_account_id()) - ); }); }