From 26d5d890718f93533588e43ec2d9d0dbd6d1ff98 Mon Sep 17 00:00:00 2001 From: bgallois <benjamin@gallois.cc> Date: Mon, 13 May 2024 15:56:50 +0200 Subject: [PATCH] Fix #226 --- docs/api/runtime-calls.md | 122 +++++++++--------- docs/api/runtime-events.md | 10 +- pallets/distance/src/benchmarking.rs | 19 +-- pallets/distance/src/lib.rs | 52 ++++++-- pallets/distance/src/mock.rs | 3 +- pallets/duniter-account/src/lib.rs | 14 +- pallets/oneshot-account/src/benchmarking.rs | 35 +++-- pallets/oneshot-account/src/lib.rs | 82 +++++------- pallets/oneshot-account/src/mock.rs | 13 +- .../provide-randomness/src/benchmarking.rs | 20 +-- pallets/provide-randomness/src/lib.rs | 24 ++-- .../universal-dividend/src/benchmarking.rs | 17 +-- pallets/universal-dividend/src/lib.rs | 24 ++-- resources/metadata.scale | Bin 148106 -> 148216 bytes runtime/common/src/pallets_config.rs | 37 ++---- runtime/g1/src/lib.rs | 5 +- runtime/gdev/src/lib.rs | 5 +- runtime/gtest/src/lib.rs | 5 +- 18 files changed, 241 insertions(+), 246 deletions(-) diff --git a/docs/api/runtime-calls.md b/docs/api/runtime-calls.md index 011ff2ce4..68c737183 100644 --- a/docs/api/runtime-calls.md +++ b/docs/api/runtime-calls.md @@ -53,7 +53,7 @@ Anonymously schedule a task. <details><summary><code>cancel(when, index)</code></summary> -Taking 0.0239 % of a block. +Taking 0.0241 % of a block. ```rust when: BlockNumberFor<T> @@ -86,7 +86,7 @@ Schedule a named task. <details><summary><code>cancel_named(id)</code></summary> -Taking 0.0252 % of a block. +Taking 0.0253 % of a block. ```rust id: TaskName @@ -162,7 +162,7 @@ original `total_retries`. <details><summary><code>set_retry_named(id, retries, period)</code></summary> -Taking 0.0129 % of a block. +Taking 0.0127 % of a block. ```rust id: TaskName @@ -203,7 +203,7 @@ Removes the retry configuration of a task. <details><summary><code>cancel_retry_named(id)</code></summary> -Taking 0.0128 % of a block. +Taking 0.0127 % of a block. ```rust id: TaskName @@ -334,7 +334,7 @@ The dispatch origin for this call is `root`. <details><summary><code>force_adjust_total_issuance(direction, delta)</code></summary> -Taking 0.0039 % of a block. +Taking 0.0038 % of a block. ```rust direction: AdjustmentDirection @@ -359,7 +359,7 @@ Taking 0.0113 % of a block. ```rust dest: <T::Lookup as StaticLookup>::Source -value: <T::Currency as Currency<T::AccountId>>::Balance +value: BalanceOf<T> ``` </details> @@ -400,7 +400,7 @@ Taking 0.0269 % of a block. block_height: BlockNumberFor<T> dest: Account<<T::Lookup as StaticLookup>::Source> remaining_to: Account<<T::Lookup as StaticLookup>::Source> -balance: <T::Currency as Currency<T::AccountId>>::Balance +balance: BalanceOf<T> ``` </details> @@ -422,7 +422,7 @@ and the remaining amount to another account. <details><summary><code>invite_smith(receiver)</code></summary> -Taking 0.0239 % of a block. +Taking 0.0237 % of a block. ```rust receiver: T::IdtyIndex @@ -449,7 +449,7 @@ Accept an invitation (must have been invited first) <details><summary><code>certify_smith(receiver)</code></summary> -Taking 0.0287 % of a block. +Taking 0.0286 % of a block. ```rust receiver: T::IdtyIndex @@ -465,7 +465,7 @@ Certify an invited smith which can lead the certified to become a Smith <details><summary><code>go_offline()</code></summary> -Taking 0.0167 % of a block. +Taking 0.0165 % of a block. ```rust ``` @@ -478,7 +478,7 @@ ask to leave the set of validators two sessions after <details><summary><code>go_online()</code></summary> -Taking 0.0192 % of a block. +Taking 0.0188 % of a block. ```rust ``` @@ -491,7 +491,7 @@ ask to join the set of validators two sessions after <details><summary><code>set_session_keys(keys)</code></summary> -Taking 0.0254 % of a block. +Taking 0.0251 % of a block. ```rust keys: T::Keys @@ -562,7 +562,7 @@ The weight of this call is defined by the caller. <details><summary><code>note_preimage(bytes)</code></summary> -Taking 0.2893 % of a block. +Taking 0.2953 % of a block. ```rust bytes: Vec<u8> @@ -598,7 +598,7 @@ If `len` is provided, then it will be a much cheaper operation. <details><summary><code>request_preimage(hash)</code></summary> -Taking 0.0127 % of a block. +Taking 0.0126 % of a block. ```rust hash: T::Hash @@ -615,7 +615,7 @@ a user may have paid, and take the control of the preimage out of their hands. <details><summary><code>unrequest_preimage(hash)</code></summary> -Taking 0.0185 % of a block. +Taking 0.0186 % of a block. ```rust hash: T::Hash @@ -631,7 +631,7 @@ NOTE: THIS MUST NOT BE CALLED ON `hash` MORE TIMES THAN `request_preimage`. <details><summary><code>ensure_updated(hashes)</code></summary> -Taking 20.7987 % of a block. +Taking 21.073 % of a block. ```rust hashes: Vec<T::Hash> @@ -649,7 +649,7 @@ The caller pays no fee if at least 90% of pre-images were successfully updated. <details><summary><code>execute(proposal, length_bound)</code></summary> -Taking 0.0052 % of a block. +Taking 0.0051 % of a block. ```rust proposal: Box<<T as Config<I>>::Proposal> @@ -701,7 +701,7 @@ or put up for voting. <details><summary><code>vote(proposal, index, approve)</code></summary> -Taking 0.0125 % of a block. +Taking 0.0124 % of a block. ```rust proposal: T::Hash @@ -767,7 +767,7 @@ proposal. <details><summary><code>claim_uds()</code></summary> -Taking 0.022 % of a block. +Taking 0.0218 % of a block. ```rust ``` @@ -812,7 +812,7 @@ Transfer some liquid free balance to another account, in milliUD. <details><summary><code>create_identity(owner_key)</code></summary> -Taking 0.0906 % of a block. +Taking 0.0912 % of a block. ```rust owner_key: T::AccountId @@ -830,7 +830,7 @@ The origin must be allowed to create an identity. <details><summary><code>confirm_identity(idty_name)</code></summary> -Taking 0.0337 % of a block. +Taking 0.0338 % of a block. ```rust idty_name: IdtyName @@ -848,7 +848,7 @@ The identity must have been created using `create_identity` before it can be con <details><summary><code>change_owner_key(new_key, new_key_sig)</code></summary> -Taking 0.0429 % of a block. +Taking 0.0431 % of a block. ```rust new_key: T::AccountId @@ -869,7 +869,7 @@ The origin should be the old identity owner key. <details><summary><code>revoke_identity(idty_index, revocation_key, revocation_sig)</code></summary> -Taking 0.0413 % of a block. +Taking 0.0416 % of a block. ```rust idty_index: T::IdtyIndex @@ -938,7 +938,7 @@ Add a new certification. <details><summary><code>renew_cert(receiver)</code></summary> -Taking 0.03 % of a block. +Taking 0.0299 % of a block. ```rust receiver: T::IdtyIndex @@ -952,7 +952,7 @@ Renew an existing certification. <details><summary><code>del_cert(issuer, receiver)</code></summary> -Taking 0.0265 % of a block. +Taking 0.0263 % of a block. ```rust issuer: T::IdtyIndex @@ -967,7 +967,7 @@ remove a certification (only root) <details><summary><code>remove_all_certs_received_by(idty_index)</code></summary> -Taking 7.3619 % of a block. +Taking 7.395 % of a block. ```rust idty_index: T::IdtyIndex @@ -983,7 +983,7 @@ remove all certifications received by an identity (only root) <details><summary><code>request_distance_evaluation()</code></summary> -Taking 0.0327 % of a block. +Taking 0.0325 % of a block. ```rust ``` @@ -998,7 +998,7 @@ negative evaluation will result in slash for caller <details><summary><code>request_distance_evaluation_for(target)</code></summary> -Taking 0.0339 % of a block. +Taking 0.0336 % of a block. ```rust target: T::IdtyIndex @@ -1013,7 +1013,7 @@ only possible for unvalidated identity <details><summary><code>update_evaluation(computation_result)</code></summary> -Taking 0.0347 % of a block. +Taking 0.0346 % of a block. ```rust computation_result: ComputationResult @@ -1028,7 +1028,7 @@ this is called internally by validators (= inherent) <details><summary><code>force_update_evaluation(evaluator, computation_result)</code></summary> -Taking 0.0184 % of a block. +Taking 0.0183 % of a block. ```rust evaluator: <T as frame_system::Config>::AccountId @@ -1130,7 +1130,7 @@ The dispatch origin for this call must be _Signed_. <details><summary><code>as_multi_threshold_1(other_signatories, call)</code></summary> -Taking 0.0041 % of a block. +Taking 0.004 % of a block. ```rust other_signatories: Vec<T::AccountId> @@ -1298,7 +1298,7 @@ transaction for this dispatch. <details><summary><code>request(randomness_type, salt)</code></summary> -Taking 0.0418 % of a block. +Taking 0.042 % of a block. ```rust randomness_type: RandomnessType @@ -1315,7 +1315,7 @@ Request a randomness <details><summary><code>proxy(real, force_proxy_type, call)</code></summary> -Taking 0.0053 % of a block. +Taking 0.0052 % of a block. ```rust real: AccountIdLookupOf<T> @@ -1498,7 +1498,7 @@ Parameters: <details><summary><code>remove_announcement(real, call_hash)</code></summary> -Taking 0.0185 % of a block. +Taking 0.0186 % of a block. ```rust real: AccountIdLookupOf<T> @@ -1522,7 +1522,7 @@ Parameters: <details><summary><code>reject_announcement(delegate, call_hash)</code></summary> -Taking 0.0185 % of a block. +Taking 0.0186 % of a block. ```rust delegate: AccountIdLookupOf<T> @@ -1575,7 +1575,7 @@ Parameters: <details><summary><code>batch(calls)</code></summary> -Taking 0.1077 % of a block. +Taking 0.1039 % of a block. ```rust calls: Vec<<T as Config>::RuntimeCall> @@ -1606,7 +1606,7 @@ event is deposited. <details><summary><code>as_derivative(index, call)</code></summary> -Taking 0.0038 % of a block. +Taking 0.0037 % of a block. ```rust index: u16 @@ -1633,7 +1633,7 @@ The dispatch origin for this call must be _Signed_. <details><summary><code>batch_all(calls)</code></summary> -Taking 0.1127 % of a block. +Taking 0.1131 % of a block. ```rust calls: Vec<<T as Config>::RuntimeCall> @@ -1659,7 +1659,7 @@ includes bypassing `frame_system::Config::BaseCallFilter`). <details><summary><code>force_batch(calls)</code></summary> -Taking 0.1071 % of a block. +Taking 0.104 % of a block. ```rust calls: Vec<<T as Config>::RuntimeCall> @@ -1707,7 +1707,7 @@ The dispatch origin for this call must be _Root_. <details><summary><code>propose_spend(value, beneficiary)</code></summary> -Taking 0.0172 % of a block. +Taking 0.0174 % of a block. ```rust value: BalanceOf<T, I> @@ -1737,7 +1737,7 @@ Emits [`Event::Proposed`] if successful. <details><summary><code>spend_local(amount, beneficiary)</code></summary> -Taking 0.0036 % of a block. +Taking 0.0035 % of a block. ```rust amount: BalanceOf<T, I> @@ -1768,7 +1768,7 @@ Emits [`Event::SpendApproved`] if successful. <details><summary><code>remove_approval(proposal_id)</code></summary> -Taking 0.0108 % of a block. +Taking 0.0107 % of a block. ```rust proposal_id: ProposalIndex @@ -1802,7 +1802,7 @@ The original deposit will no longer be returned. <details><summary><code>spend(asset_kind, amount, beneficiary, valid_from)</code></summary> -Taking 0.0036 % of a block. +Taking 0.0035 % of a block. ```rust asset_kind: Box<T::AssetKind> @@ -1844,7 +1844,7 @@ Emits [`Event::AssetSpendApproved`] if successful. <details><summary><code>payout(index)</code></summary> -Taking 0.0263 % of a block. +Taking 0.0265 % of a block. ```rust index: SpendIndex @@ -1945,7 +1945,7 @@ There are **18** root calls from **8** pallets. <details><summary><code>set_heap_pages(pages)</code></summary> -Taking 0.0165 % of a block. +Taking 0.0166 % of a block. ```rust pages: u64 @@ -1959,7 +1959,7 @@ Set the number of pages in the WebAssembly environment's heap. <details><summary><code>set_code(code)</code></summary> -Taking 4.0113 % of a block. +Taking 3.2097 % of a block. ```rust code: Vec<u8> @@ -1990,7 +1990,7 @@ version! <details><summary><code>set_storage(items)</code></summary> -Taking 5.8851 % of a block. +Taking 6.0054 % of a block. ```rust items: Vec<KeyValue> @@ -2004,7 +2004,7 @@ Set some items of storage. <details><summary><code>kill_storage(keys)</code></summary> -Taking 5.8773 % of a block. +Taking 5.9992 % of a block. ```rust keys: Vec<Key> @@ -2018,7 +2018,7 @@ Kill some items from storage. <details><summary><code>kill_prefix(prefix, subkeys)</code></summary> -Taking 6.9458 % of a block. +Taking 7.0112 % of a block. ```rust prefix: Key @@ -2036,7 +2036,7 @@ the prefix we are removing to accurately calculate the weight of this function. <details><summary><code>authorize_upgrade(code_hash)</code></summary> -Taking 0.0101 % of a block. +Taking 0.01 % of a block. ```rust code_hash: T::Hash @@ -2074,7 +2074,7 @@ This call requires Root origin. <details><summary><code>apply_authorized_upgrade(code)</code></summary> -Taking 4.2016 % of a block. +Taking 3.461 % of a block. ```rust code: Vec<u8> @@ -2117,7 +2117,7 @@ not been enacted yet. <details><summary><code>force_transfer(source, dest, value)</code></summary> -Taking 0.0265 % of a block. +Taking 0.0266 % of a block. ```rust source: AccountIdLookupOf<T> @@ -2134,7 +2134,7 @@ may be specified. <details><summary><code>force_unreserve(who, amount)</code></summary> -Taking 0.0112 % of a block. +Taking 0.0111 % of a block. ```rust who: AccountIdLookupOf<T> @@ -2153,7 +2153,7 @@ Can only be called by ROOT. <details><summary><code>remove_member(member_id)</code></summary> -Taking 0.0701 % of a block. +Taking 0.0709 % of a block. ```rust member_id: T::MemberId @@ -2197,7 +2197,7 @@ Only callable by root. <details><summary><code>set_members(new_members, prime, old_count)</code></summary> -Taking 0.1657 % of a block. +Taking 0.1668 % of a block. ```rust new_members: Vec<T::AccountId> @@ -2236,7 +2236,7 @@ with other logic managing the member set. <details><summary><code>disapprove_proposal(proposal_hash)</code></summary> -Taking 0.0229 % of a block. +Taking 0.0231 % of a block. ```rust proposal_hash: T::Hash @@ -2261,7 +2261,7 @@ O(P) where P is the number of max proposals <details><summary><code>prune_item_identities_names(names)</code></summary> -Taking 5.9211 % of a block. +Taking 6.0421 % of a block. ```rust names: Vec<IdtyName> @@ -2277,7 +2277,7 @@ remove identity names from storage <details><summary><code>dispatch_as(as_origin, call)</code></summary> -Taking 0.0039 % of a block. +Taking 0.0038 % of a block. ```rust as_origin: Box<T::PalletsOrigin> @@ -2324,7 +2324,7 @@ Can be executed by every `origin`. <details><summary><code>remark_with_event(remark)</code></summary> -Taking 0.2052 % of a block. +Taking 0.2151 % of a block. ```rust remark: Vec<u8> @@ -2340,7 +2340,7 @@ Make some on-chain remark and emit event. <details><summary><code>set_keys(keys, proof)</code></summary> -Taking 0.0394 % of a block. +Taking 0.0395 % of a block. ```rust keys: T::Keys @@ -2363,7 +2363,7 @@ The dispatch origin of this function must be signed. <details><summary><code>purge_keys()</code></summary> -Taking 0.0347 % of a block. +Taking 0.0351 % of a block. ```rust ``` diff --git a/docs/api/runtime-events.md b/docs/api/runtime-events.md index 6b1404aa3..bde9aa35a 100644 --- a/docs/api/runtime-events.md +++ b/docs/api/runtime-events.md @@ -581,7 +581,7 @@ A oneshot account was created. ```rust account: T::AccountId -balance: <T::Currency as Currency<T::AccountId>>::Balance +balance: BalanceOf<T> creator: T::AccountId ``` @@ -595,10 +595,8 @@ A oneshot account was consumed. ```rust account: T::AccountId -dest1: (T::AccountId,<T::Currency as Currency<T::AccountId>>::Balance,) -dest2: Option< -(T::AccountId,<T::Currency as Currency<T::AccountId>>::Balance,) -> +dest1: (T::AccountId, BalanceOf<T>) +dest2: Option<(T::AccountId, BalanceOf<T>)> ``` </details> @@ -611,7 +609,7 @@ A withdrawal was executed on a oneshot account. ```rust account: T::AccountId -balance: <T::Currency as Currency<T::AccountId>>::Balance +balance: BalanceOf<T> ``` </details> diff --git a/pallets/distance/src/benchmarking.rs b/pallets/distance/src/benchmarking.rs index 91589bbb3..bf1a6a519 100644 --- a/pallets/distance/src/benchmarking.rs +++ b/pallets/distance/src/benchmarking.rs @@ -21,13 +21,9 @@ use super::*; use codec::Encode; use frame_benchmarking::v2::*; -use frame_support::traits::Get; -use frame_support::traits::OnInitialize; -use frame_support::traits::{Currency, OnFinalize}; +use frame_support::traits::{Get, OnFinalize, OnInitialize}; use frame_system::pallet_prelude::BlockNumberFor; use frame_system::RawOrigin; -use pallet_balances::Pallet as Balances; -use sp_runtime::traits::Bounded; use sp_runtime::Perbill; use crate::Pallet; @@ -35,7 +31,7 @@ use crate::Pallet; #[benchmarks( where T: pallet_balances::Config, - T::Balance: From<u64>, + BalanceOf<T>: From<u32>, BlockNumberFor<T>: From<u32>, )] mod benchmarks { @@ -63,8 +59,7 @@ mod benchmarks { let caller: T::AccountId = pallet_identity::Identities::<T>::get(idty) .unwrap() .owner_key; - let _ = - <Balances<T> as Currency<_>>::make_free_balance_be(&caller, T::Balance::max_value()); + let _ = T::Currency::set_balance(&caller, u32::MAX.into()); #[extrinsic_call] _(RawOrigin::Signed(caller.clone())); @@ -88,7 +83,7 @@ mod benchmarks { let caller: T::AccountId = pallet_identity::Identities::<T>::get(idty) .unwrap() .owner_key; - <Balances<T> as Currency<_>>::make_free_balance_be(&caller, T::Balance::max_value()); + T::Currency::set_balance(&caller, u32::MAX.into()); let target: T::IdtyIndex = 2u32; // set target status since targeted distance evaluation only allowed for unvalidated pallet_identity::Identities::<T>::mutate(target, |idty_val| { @@ -193,8 +188,7 @@ mod benchmarks { let caller: T::AccountId = pallet_identity::Identities::<T>::get(idty) .unwrap() .owner_key; - let _ = - <Balances<T> as Currency<_>>::make_free_balance_be(&caller, T::Balance::max_value()); + let _ = T::Currency::set_balance(&caller, u32::MAX.into()); Pallet::<T>::request_distance_evaluation(RawOrigin::Signed(caller.clone()).into())?; assert_has_event::<T>( Event::<T>::EvaluationRequested { @@ -237,8 +231,7 @@ mod benchmarks { let caller: T::AccountId = pallet_identity::Identities::<T>::get(idty) .unwrap() .owner_key; - let _ = - <Balances<T> as Currency<_>>::make_free_balance_be(&caller, T::Balance::max_value()); + let _ = T::Currency::set_balance(&caller, u32::MAX.into()); Pallet::<T>::request_distance_evaluation(RawOrigin::Signed(caller.clone()).into())?; assert_has_event::<T>( Event::<T>::EvaluationRequested { diff --git a/pallets/distance/src/lib.rs b/pallets/distance/src/lib.rs index 76d580b2d..06e58088f 100644 --- a/pallets/distance/src/lib.rs +++ b/pallets/distance/src/lib.rs @@ -34,14 +34,16 @@ pub use traits::*; pub use types::*; pub use weights::WeightInfo; -use frame_support::traits::StorageVersion; +use frame_support::traits::{ + fungible::{self, hold::Balanced, Mutate, MutateHold}, + tokens::Precision, + StorageVersion, +}; use sp_distance::{InherentError, INHERENT_IDENTIFIER}; use sp_inherents::{InherentData, InherentIdentifier}; -use sp_runtime::traits::One; -use sp_runtime::traits::Zero; +use sp_runtime::traits::{One, Zero}; use sp_runtime::Saturating; -use sp_std::convert::TryInto; -use sp_std::prelude::*; +use sp_std::{convert::TryInto, prelude::*}; type IdtyIndex = u32; @@ -53,9 +55,17 @@ pub const MAX_EVALUATORS_PER_SESSION: u32 = 100; #[frame_support::pallet()] pub mod pallet { use super::*; - use frame_support::{pallet_prelude::*, traits::ReservableCurrency}; + use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; use sp_runtime::Perbill; + pub type AccountIdOf<T> = <T as frame_system::Config>::AccountId; + pub type BalanceOf<T> = <<T as Config>::Currency as fungible::Inspect<AccountIdOf<T>>>::Balance; + + #[pallet::composite_enum] + pub enum HoldReason { + /// The funds are held as deposit for the distance evaluation. + DistanceHold, + } /// The current storage version. const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); @@ -71,12 +81,14 @@ pub mod pallet { + pallet_identity::Config<IdtyIndex = IdtyIndex> { /// Currency type used in this pallet (used for reserve/slash) - type Currency: ReservableCurrency<Self::AccountId>; + type Currency: Mutate<Self::AccountId> + + MutateHold<Self::AccountId, Reason = Self::RuntimeHoldReason> + + Balanced<Self::AccountId>; + /// Overarching hold reason. + type RuntimeHoldReason: From<HoldReason>; /// Amount reserved during evaluation #[pallet::constant] - type EvaluationPrice: Get< - <Self::Currency as frame_support::traits::Currency<Self::AccountId>>::Balance, - >; + type EvaluationPrice: Get<BalanceOf<Self>>; /// Evaluation period number of blocks. /// As the evaluation is done using 3 pools, /// the evaluation will take 3 * EvaluationPeriod. @@ -463,7 +475,11 @@ pub mod pallet { Error::<T>::QueueFull ); - T::Currency::reserve(who, <T as Config>::EvaluationPrice::get())?; + T::Currency::hold( + &HoldReason::DistanceHold.into(), + who, + <T as Config>::EvaluationPrice::get(), + )?; current_pool .evaluations @@ -559,9 +575,11 @@ pub mod pallet { if let Some(distance) = distance_result { if distance >= T::MinAccessibleReferees::get() { // Positive result, unreserve and apply - T::Currency::unreserve( + let _ = T::Currency::release( + &HoldReason::DistanceHold.into(), &requester, <T as Config>::EvaluationPrice::get(), + Precision::Exact, ); Self::do_valid_distance_status(idty, distance); weight = weight.saturating_add( @@ -572,7 +590,8 @@ pub mod pallet { ); } else { // Negative result, slash and deposit event - let _ = T::Currency::slash_reserved( + let _ = T::Currency::slash( + &HoldReason::DistanceHold.into(), &requester, <T as Config>::EvaluationPrice::get(), ); @@ -589,7 +608,12 @@ pub mod pallet { } } else { // No result, unreserve - T::Currency::unreserve(&requester, <T as Config>::EvaluationPrice::get()); + let _ = T::Currency::release( + &HoldReason::DistanceHold.into(), + &requester, + <T as Config>::EvaluationPrice::get(), + Precision::Exact, + ); weight = weight.saturating_add( <T as pallet::Config>::WeightInfo::do_evaluation_failure() .saturating_sub( diff --git a/pallets/distance/src/mock.rs b/pallets/distance/src/mock.rs index 5d6813516..7b2391ce4 100644 --- a/pallets/distance/src/mock.rs +++ b/pallets/distance/src/mock.rs @@ -210,7 +210,7 @@ impl pallet_balances::Config for Test { type ReserveIdentifier = [u8; 8]; type RuntimeEvent = RuntimeEvent; type RuntimeFreezeReason = (); - type RuntimeHoldReason = (); + type RuntimeHoldReason = RuntimeHoldReason; type WeightInfo = pallet_balances::weights::SubstrateWeight<Test>; } @@ -262,6 +262,7 @@ impl pallet_distance::Config for Test { type MinAccessibleReferees = MinAccessibleReferees; type OnValidDistanceStatus = (); type RuntimeEvent = RuntimeEvent; + type RuntimeHoldReason = RuntimeHoldReason; type WeightInfo = (); } diff --git a/pallets/duniter-account/src/lib.rs b/pallets/duniter-account/src/lib.rs index 346dab976..2e131264a 100644 --- a/pallets/duniter-account/src/lib.rs +++ b/pallets/duniter-account/src/lib.rs @@ -29,8 +29,7 @@ pub use types::*; pub use weights::WeightInfo; use frame_support::pallet_prelude::*; -use frame_support::traits::StoredMap; -use frame_support::traits::{Currency, StorageVersion}; +use frame_support::traits::{fungible, fungible::Credit, IsSubType, StorageVersion, StoredMap}; use frame_system::pallet_prelude::*; use pallet_quota::traits::RefundFee; use pallet_transaction_payment::OnChargeTransaction; @@ -42,8 +41,8 @@ pub mod pallet { use super::*; pub type IdtyIdOf<T> = <T as pallet_identity::Config>::IdtyIndex; pub type CurrencyOf<T> = pallet_balances::Pallet<T>; - pub type BalanceOf<T> = - <CurrencyOf<T> as Currency<<T as frame_system::Config>::AccountId>>::Balance; + type AccountIdOf<T> = <T as frame_system::Config>::AccountId; + pub type BalanceOf<T> = <CurrencyOf<T> as fungible::Inspect<AccountIdOf<T>>>::Balance; /// The current storage version. const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); @@ -290,14 +289,15 @@ where // allows pay fees with quota instead of currency if available impl<T: Config> OnChargeTransaction<T> for Pallet<T> where + T::RuntimeCall: IsSubType<Call<T>>, T::InnerOnChargeTransaction: OnChargeTransaction< T, - Balance = <CurrencyOf<T> as Currency<T::AccountId>>::Balance, - LiquidityInfo = Option<<CurrencyOf<T> as Currency<T::AccountId>>::NegativeImbalance>, + Balance = BalanceOf<T>, + LiquidityInfo = Option<Credit<T::AccountId, T::Currency>>, >, { type Balance = BalanceOf<T>; - type LiquidityInfo = Option<<CurrencyOf<T> as Currency<T::AccountId>>::NegativeImbalance>; + type LiquidityInfo = Option<Credit<T::AccountId, T::Currency>>; fn withdraw_fee( who: &T::AccountId, diff --git a/pallets/oneshot-account/src/benchmarking.rs b/pallets/oneshot-account/src/benchmarking.rs index fb389d414..ed38c4377 100644 --- a/pallets/oneshot-account/src/benchmarking.rs +++ b/pallets/oneshot-account/src/benchmarking.rs @@ -22,16 +22,19 @@ use super::*; use frame_benchmarking::v2::*; use frame_benchmarking::{account, whitelisted_caller}; use frame_support::pallet_prelude::IsType; +use frame_support::traits::fungible::Mutate; use frame_system::RawOrigin; use pallet_balances::Pallet as Balances; use crate::Pallet; +type BalanceOf<T> = <<T as Config>::Currency as fungible::Inspect<AccountIdOf<T>>>::Balance; + #[benchmarks( where T: pallet_balances::Config, T::Balance: From<u64>, - <T::Currency as Currency<T::AccountId>>::Balance: IsType<T::Balance>+From<T::Balance> + BalanceOf<T>: IsType<T::Balance>+From<T::Balance> )] mod benchmarks { use super::*; @@ -41,7 +44,10 @@ mod benchmarks { let existential_deposit = T::ExistentialDeposit::get(); let caller = whitelisted_caller(); let balance = existential_deposit.saturating_mul((2).into()); - let _ = T::Currency::make_free_balance_be(&caller, balance.into()); + let _ = <<T as pallet::Config>::Currency as Mutate<T::AccountId>>::set_balance( + &caller, + balance.into(), + ); let recipient: T::AccountId = account("recipient", 0, 1); let recipient_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient.clone()); @@ -66,16 +72,16 @@ mod benchmarks { let existential_deposit = T::ExistentialDeposit::get(); let caller: T::AccountId = whitelisted_caller(); let balance = existential_deposit.saturating_mul((2).into()); - OneshotAccounts::<T>::insert( - caller.clone(), - Into::<<T::Currency as Currency<T::AccountId>>::Balance>::into(balance), - ); + OneshotAccounts::<T>::insert(caller.clone(), Into::<BalanceOf<T>>::into(balance)); // Deposit into a normal account is more expensive than into a oneshot account // so we create the recipient account with an existential deposit. let recipient: T::AccountId = account("recipient", 0, 1); let recipient_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient.clone()); - let _ = T::Currency::make_free_balance_be(&recipient, existential_deposit.into()); + let _ = <<T as pallet::Config>::Currency as Mutate<T::AccountId>>::set_balance( + &recipient, + existential_deposit.into(), + ); #[extrinsic_call] _( @@ -96,20 +102,23 @@ mod benchmarks { let existential_deposit = T::ExistentialDeposit::get(); let caller: T::AccountId = whitelisted_caller(); let balance = existential_deposit.saturating_mul((2).into()); - OneshotAccounts::<T>::insert( - caller.clone(), - Into::<<T::Currency as Currency<T::AccountId>>::Balance>::into(balance), - ); + OneshotAccounts::<T>::insert(caller.clone(), Into::<BalanceOf<T>>::into(balance)); // Deposit into a normal account is more expensive than into a oneshot account // so we create the recipient accounts with an existential deposits. let recipient1: T::AccountId = account("recipient1", 0, 1); let recipient1_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient1.clone()); - let _ = T::Currency::make_free_balance_be(&recipient1, existential_deposit.into()); + let _ = <<T as pallet::Config>::Currency as Mutate<T::AccountId>>::set_balance( + &recipient1, + existential_deposit.into(), + ); let recipient2: T::AccountId = account("recipient2", 1, 1); let recipient2_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient2.clone()); - let _ = T::Currency::make_free_balance_be(&recipient2, existential_deposit.into()); + let _ = <<T as pallet::Config>::Currency as Mutate<T::AccountId>>::set_balance( + &recipient2, + existential_deposit.into(), + ); #[extrinsic_call] _( diff --git a/pallets/oneshot-account/src/lib.rs b/pallets/oneshot-account/src/lib.rs index 637debf4d..a22e897a9 100644 --- a/pallets/oneshot-account/src/lib.rs +++ b/pallets/oneshot-account/src/lib.rs @@ -29,14 +29,20 @@ pub use types::*; pub use weights::WeightInfo; use frame_support::pallet_prelude::*; +use frame_support::traits::fungible; use frame_support::traits::{ - Currency, ExistenceRequirement, Imbalance, IsSubType, WithdrawReasons, + fungible::{Balanced, Credit, Inspect}, + tokens::{Fortitude, Precision, Preservation}, + Imbalance, IsSubType, }; use frame_system::pallet_prelude::*; use pallet_transaction_payment::OnChargeTransaction; use sp_runtime::traits::{DispatchInfoOf, PostDispatchInfoOf, Saturating, StaticLookup, Zero}; use sp_std::convert::TryInto; +type AccountIdOf<T> = <T as frame_system::Config>::AccountId; +type BalanceOf<T> = <<T as Config>::Currency as fungible::Inspect<AccountIdOf<T>>>::Balance; + #[frame_support::pallet] pub mod pallet { use super::*; @@ -49,7 +55,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config + pallet_transaction_payment::Config { - type Currency: Currency<Self::AccountId>; + type Currency: fungible::Balanced<Self::AccountId> + fungible::Mutate<Self::AccountId>; type InnerOnChargeTransaction: OnChargeTransaction<Self>; type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>; /// Type representing the weight of this pallet @@ -60,13 +66,8 @@ pub mod pallet { #[pallet::storage] #[pallet::getter(fn oneshot_account)] - pub type OneshotAccounts<T: Config> = StorageMap< - _, - Blake2_128Concat, - T::AccountId, - <T::Currency as Currency<T::AccountId>>::Balance, - OptionQuery, - >; + pub type OneshotAccounts<T: Config> = + StorageMap<_, Blake2_128Concat, T::AccountId, BalanceOf<T>, OptionQuery>; // EVENTS // @@ -77,25 +78,19 @@ pub mod pallet { /// A oneshot account was created. OneshotAccountCreated { account: T::AccountId, - balance: <T::Currency as Currency<T::AccountId>>::Balance, + balance: BalanceOf<T>, creator: T::AccountId, }, /// A oneshot account was consumed. OneshotAccountConsumed { account: T::AccountId, - dest1: ( - T::AccountId, - <T::Currency as Currency<T::AccountId>>::Balance, - ), - dest2: Option<( - T::AccountId, - <T::Currency as Currency<T::AccountId>>::Balance, - )>, + dest1: (T::AccountId, BalanceOf<T>), + dest2: Option<(T::AccountId, BalanceOf<T>)>, }, /// A withdrawal was executed on a oneshot account. Withdraw { account: T::AccountId, - balance: <T::Currency as Currency<T::AccountId>>::Balance, + balance: BalanceOf<T>, }, } @@ -133,13 +128,13 @@ pub mod pallet { pub fn create_oneshot_account( origin: OriginFor<T>, dest: <T::Lookup as StaticLookup>::Source, - #[pallet::compact] value: <T::Currency as Currency<T::AccountId>>::Balance, + #[pallet::compact] value: BalanceOf<T>, ) -> DispatchResult { let transactor = ensure_signed(origin)?; let dest = T::Lookup::lookup(dest)?; ensure!( - value >= <T::Currency as Currency<T::AccountId>>::minimum_balance(), + value >= T::Currency::minimum_balance(), Error::<T>::ExistentialDeposit ); ensure!( @@ -147,11 +142,12 @@ pub mod pallet { Error::<T>::OneshotAccountAlreadyCreated ); - let _ = <T::Currency as Currency<T::AccountId>>::withdraw( + let _ = T::Currency::withdraw( &transactor, value, - WithdrawReasons::TRANSFER, - ExistenceRequirement::KeepAlive, + Precision::Exact, + Preservation::Preserve, + Fortitude::Polite, )?; OneshotAccounts::<T>::insert(&dest, value); Self::deposit_event(Event::OneshotAccountCreated { @@ -205,9 +201,8 @@ pub mod pallet { balance: value, creator: transactor.clone(), }); - } else { - let _ = - <T::Currency as Currency<T::AccountId>>::deposit_into_existing(&dest, value)?; + } else if frame_system::Pallet::<T>::providers(&dest) > 0 { + let _ = T::Currency::deposit(&dest, value, Precision::Exact)?; } OneshotAccounts::<T>::remove(&transactor); Self::deposit_event(Event::OneshotAccountConsumed { @@ -236,7 +231,7 @@ pub mod pallet { block_height: BlockNumberFor<T>, dest: Account<<T::Lookup as StaticLookup>::Source>, remaining_to: Account<<T::Lookup as StaticLookup>::Source>, - #[pallet::compact] balance: <T::Currency as Currency<T::AccountId>>::Balance, + #[pallet::compact] balance: BalanceOf<T>, ) -> DispatchResult { let transactor = ensure_signed(origin)?; @@ -271,12 +266,12 @@ pub mod pallet { Error::<T>::OneshotAccountAlreadyCreated ); ensure!( - balance1 >= <T::Currency as Currency<T::AccountId>>::minimum_balance(), + balance1 >= T::Currency::minimum_balance(), Error::<T>::ExistentialDeposit ); } else { ensure!( - !<T::Currency as Currency<T::AccountId>>::free_balance(&dest1).is_zero(), + !T::Currency::balance(&dest1).is_zero(), Error::<T>::DestAccountNotExist ); } @@ -286,7 +281,7 @@ pub mod pallet { Error::<T>::OneshotAccountAlreadyCreated ); ensure!( - balance2 >= <T::Currency as Currency<T::AccountId>>::minimum_balance(), + balance2 >= T::Currency::minimum_balance(), Error::<T>::ExistentialDeposit ); OneshotAccounts::<T>::insert(&dest2, balance2); @@ -295,10 +290,8 @@ pub mod pallet { balance: balance2, creator: transactor.clone(), }); - } else { - let _ = <T::Currency as Currency<T::AccountId>>::deposit_into_existing( - &dest2, balance2, - )?; + } else if frame_system::Pallet::<T>::providers(&dest2) > 0 { + let _ = T::Currency::deposit(&dest2, balance2, Precision::Exact)?; } if dest1_is_oneshot { OneshotAccounts::<T>::insert(&dest1, balance1); @@ -307,10 +300,8 @@ pub mod pallet { balance: balance1, creator: transactor.clone(), }); - } else { - let _ = <T::Currency as Currency<T::AccountId>>::deposit_into_existing( - &dest1, balance1, - )?; + } else if frame_system::Pallet::<T>::providers(&dest1) > 0 { + let _ = T::Currency::deposit(&dest1, balance1, Precision::Exact)?; } OneshotAccounts::<T>::remove(&transactor); Self::deposit_event(Event::OneshotAccountConsumed { @@ -329,12 +320,12 @@ where T::RuntimeCall: IsSubType<Call<T>>, T::InnerOnChargeTransaction: OnChargeTransaction< T, - Balance = <T::Currency as Currency<T::AccountId>>::Balance, - LiquidityInfo = Option<<T::Currency as Currency<T::AccountId>>::NegativeImbalance>, + Balance = BalanceOf<T>, + LiquidityInfo = Option<Credit<T::AccountId, T::Currency>>, >, { - type Balance = <T::Currency as Currency<T::AccountId>>::Balance; - type LiquidityInfo = Option<<T::Currency as Currency<T::AccountId>>::NegativeImbalance>; + type Balance = BalanceOf<T>; + type LiquidityInfo = Option<Credit<T::AccountId, T::Currency>>; fn withdraw_fee( who: &T::AccountId, @@ -359,10 +350,7 @@ where account: who.clone(), balance: fee, }); - // TODO - return Ok(Some( - <T::Currency as Currency<T::AccountId>>::NegativeImbalance::zero(), - )); + return Ok(Some(Imbalance::zero())); } } Err(TransactionValidityError::Invalid( diff --git a/pallets/oneshot-account/src/mock.rs b/pallets/oneshot-account/src/mock.rs index 8e83c61f0..451c5c154 100644 --- a/pallets/oneshot-account/src/mock.rs +++ b/pallets/oneshot-account/src/mock.rs @@ -14,12 +14,10 @@ // You should have received a copy of the GNU Affero General Public License // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. -#![allow(deprecated)] // TODO - use crate::{self as pallet_oneshot_account}; use frame_support::{parameter_types, traits::Everything, weights::IdentityFee}; use frame_system as system; -use pallet_transaction_payment::CurrencyAdapter; +use pallet_transaction_payment::FungibleAdapter; use sp_core::{ConstU32, H256}; use sp_runtime::{ traits::{BlakeTwo256, IdentityLookup}, @@ -107,16 +105,15 @@ impl pallet_transaction_payment::Config for Test { } impl pallet_oneshot_account::Config for Test { type Currency = Balances; - type InnerOnChargeTransaction = CurrencyAdapter<Balances, HandleFees>; + type InnerOnChargeTransaction = FungibleAdapter<Balances, HandleFees>; type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } pub struct HandleFees; -type NegativeImbalance = <Balances as frame_support::traits::Currency<u64>>::NegativeImbalance; -impl frame_support::traits::OnUnbalanced<NegativeImbalance> for HandleFees { - fn on_nonzero_unbalanced(_amount: NegativeImbalance) {} -} +type Imbalance = + frame_support::traits::fungible::Credit<<Test as frame_system::Config>::AccountId, Balances>; +impl frame_support::traits::OnUnbalanced<Imbalance> for HandleFees {} // Build genesis storage according to the mock runtime. #[allow(dead_code)] diff --git a/pallets/provide-randomness/src/benchmarking.rs b/pallets/provide-randomness/src/benchmarking.rs index b5cd3f11b..c0a4a9a55 100644 --- a/pallets/provide-randomness/src/benchmarking.rs +++ b/pallets/provide-randomness/src/benchmarking.rs @@ -19,14 +19,14 @@ use super::*; -use frame_benchmarking::v2::*; -use frame_benchmarking::whitelisted_caller; -use frame_support::ensure; -use frame_support::pallet_prelude::IsType; -use frame_support::sp_runtime::{traits::One, Saturating}; -use frame_support::traits::{Currency, Get, OnInitialize}; -use frame_system::pallet_prelude::BlockNumberFor; -use frame_system::RawOrigin; +use frame_benchmarking::{v2::*, whitelisted_caller}; +use frame_support::{ + ensure, + pallet_prelude::IsType, + sp_runtime::{traits::One, Saturating}, + traits::{fungible::Mutate, Get, OnInitialize}, +}; +use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin}; use sp_core::H256; use crate::Pallet; @@ -35,7 +35,7 @@ use crate::Pallet; where T: pallet_balances::Config, T::Balance: From<u64>, - <T::Currency as Currency<T::AccountId>>::Balance: IsType<T::Balance>, + BalanceOf<T>: IsType<T::Balance>, BlockNumberFor<T>: From<u32>, )] mod benchmarks { @@ -80,7 +80,7 @@ mod benchmarks { // Provide deposit let existential_deposit = T::ExistentialDeposit::get(); let balance = existential_deposit.saturating_mul((200).into()); - let _ = T::Currency::make_free_balance_be(&caller, balance.into()); + let _ = T::Currency::set_balance(&caller, balance.into()); // Set randomness parameters let random = RandomnessType::RandomnessFromOneEpochAgo; diff --git a/pallets/provide-randomness/src/lib.rs b/pallets/provide-randomness/src/lib.rs index b6c36c345..608197496 100644 --- a/pallets/provide-randomness/src/lib.rs +++ b/pallets/provide-randomness/src/lib.rs @@ -24,6 +24,10 @@ mod types; pub mod weights; use frame_support::pallet_prelude::Weight; +use frame_support::traits::{ + fungible::{self, Balanced, Credit}, + tokens::{Fortitude, Precision, Preservation}, +}; use sp_core::H256; use sp_std::prelude::*; @@ -46,17 +50,12 @@ impl OnFilledRandomness for () { pub mod pallet { use super::*; use frame_support::pallet_prelude::*; - use frame_support::traits::{ - Currency, ExistenceRequirement, OnUnbalanced, Randomness, StorageVersion, WithdrawReasons, - }; + use frame_support::traits::{OnUnbalanced, Randomness, StorageVersion}; use frame_system::pallet_prelude::*; use sp_core::H256; - pub type BalanceOf<T> = - <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance; - pub type NegativeImbalanceOf<T> = <<T as Config>::Currency as Currency< - <T as frame_system::Config>::AccountId, - >>::NegativeImbalance; + type AccountIdOf<T> = <T as frame_system::Config>::AccountId; + pub type BalanceOf<T> = <<T as Config>::Currency as fungible::Inspect<AccountIdOf<T>>>::Balance; /// The current storage version. const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); @@ -70,7 +69,7 @@ pub mod pallet { #[pallet::config] pub trait Config: frame_system::Config<Hash = H256> { // The currency - type Currency: Currency<Self::AccountId>; + type Currency: fungible::Balanced<Self::AccountId> + fungible::Mutate<Self::AccountId>; /// Get the current epoch index type GetCurrentEpochIndex: Get<u64>; /// Maximum number of not yet filled requests @@ -82,7 +81,7 @@ pub mod pallet { /// On filled randomness type OnFilledRandomness: OnFilledRandomness; /// Handler for the unbalanced reduction when the requestor pays fees. - type OnUnbalanced: OnUnbalanced<NegativeImbalanceOf<Self>>; + type OnUnbalanced: OnUnbalanced<Credit<Self::AccountId, Self::Currency>>; /// A safe source of randomness from the parent block type ParentBlockRandomness: Randomness<Option<H256>, BlockNumberFor<Self>>; /// A safe source of randomness from one epoch ago @@ -251,8 +250,9 @@ pub mod pallet { let imbalance = T::Currency::withdraw( requestor, T::RequestPrice::get(), - WithdrawReasons::FEE, - ExistenceRequirement::KeepAlive, + Precision::Exact, + Preservation::Preserve, + Fortitude::Polite, )?; T::OnUnbalanced::on_unbalanced(imbalance); Ok(()) diff --git a/pallets/universal-dividend/src/benchmarking.rs b/pallets/universal-dividend/src/benchmarking.rs index d9d0856ca..0f43c2721 100644 --- a/pallets/universal-dividend/src/benchmarking.rs +++ b/pallets/universal-dividend/src/benchmarking.rs @@ -18,15 +18,11 @@ #![allow(clippy::multiple_bound_locations)] use super::*; - use core::num::NonZeroU16; -use frame_benchmarking::v2::*; -use frame_benchmarking::{account, whitelisted_caller}; -use frame_support::pallet_prelude::IsType; -use frame_support::traits::StoredMap; +use frame_benchmarking::{account, v2::*, whitelisted_caller}; +use frame_support::{pallet_prelude::IsType, traits::StoredMap}; use frame_system::RawOrigin; use pallet_balances::Pallet as Balances; -use sp_runtime::traits::Bounded; use crate::Pallet; @@ -35,7 +31,7 @@ const ED_MULTIPLIER: u32 = 10; #[benchmarks( where T: pallet_balances::Config, T::Balance: From<u64>, - <T::Currency as Currency<T::AccountId>>::Balance: IsType<T::Balance> + BalanceOf<T>: IsType<T::Balance> )] mod benchmarks { use super::*; @@ -82,7 +78,7 @@ mod benchmarks { let existential_deposit = T::ExistentialDeposit::get(); let caller = whitelisted_caller(); let balance = existential_deposit.saturating_mul(ED_MULTIPLIER.into()); - let _ = T::Currency::make_free_balance_be(&caller, balance.into()); + let _ = T::Currency::set_balance(&caller, balance.into()); // Transfer `e - 1` existential deposits + 1 unit, which guarantees to create one account and reap this user. let recipient: T::AccountId = account("recipient", 0, 1); let recipient_lookup: <T::Lookup as StaticLookup>::Source = @@ -112,10 +108,7 @@ mod benchmarks { let recipient_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient.clone()); // Give the sender account max funds, thus a transfer will not kill account. - let _ = T::Currency::make_free_balance_be( - &caller, - <T::Currency as Currency<T::AccountId>>::Balance::max_value(), - ); + let _ = T::Currency::set_balance(&caller, u32::MAX.into()); let existential_deposit = T::ExistentialDeposit::get(); let transfer_amount = existential_deposit.saturating_mul(ED_MULTIPLIER.into()); let transfer_amount_ud = diff --git a/pallets/universal-dividend/src/lib.rs b/pallets/universal-dividend/src/lib.rs index 6c6f60da2..0b6360055 100644 --- a/pallets/universal-dividend/src/lib.rs +++ b/pallets/universal-dividend/src/lib.rs @@ -33,7 +33,11 @@ pub use pallet::*; pub use types::*; pub use weights::WeightInfo; -use frame_support::traits::{tokens::ExistenceRequirement, Currency, OnTimestampSet}; +use frame_support::traits::tokens::{Precision, Preservation}; +use frame_support::traits::{ + fungible::{self, Balanced, Mutate}, + OnTimestampSet, +}; use sp_arithmetic::{ per_things::Perbill, traits::{One, Saturating, Zero}, @@ -48,8 +52,8 @@ pub mod pallet { use frame_system::pallet_prelude::*; use sp_runtime::traits::Convert; - pub type BalanceOf<T> = - <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance; + type AccountIdOf<T> = <T as frame_system::Config>::AccountId; + pub type BalanceOf<T> = <<T as Config>::Currency as fungible::Inspect<AccountIdOf<T>>>::Balance; /// The current storage version. const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); @@ -64,7 +68,7 @@ pub mod pallet { // Moment into Balance converter type MomentIntoBalance: Convert<Self::Moment, BalanceOf<Self>>; // The currency - type Currency: Currency<Self::AccountId>; + type Currency: fungible::Balanced<Self::AccountId> + fungible::Mutate<Self::AccountId>; /// Maximum number of past UD revaluations to keep in storage. #[pallet::constant] type MaxPastReeval: Get<u32>; @@ -310,7 +314,7 @@ pub mod pallet { core::num::NonZeroU16::new(current_ud_index) .expect("unreachable because current_ud_index is never zero."), ); - let _ = T::Currency::deposit_creating(who, uds_total); + let _ = T::Currency::deposit(who, uds_total, Precision::Exact); Self::deposit_event(Event::UdsClaimed { count: uds_count, total: uds_total, @@ -329,7 +333,7 @@ pub mod pallet { origin: OriginFor<T>, dest: <T::Lookup as StaticLookup>::Source, value: BalanceOf<T>, - existence_requirement: ExistenceRequirement, + preservation: Preservation, ) -> DispatchResultWithPostInfo { let who = ensure_signed(origin)?; let dest = T::Lookup::lookup(dest)?; @@ -338,7 +342,7 @@ pub mod pallet { &who, &dest, value.saturating_mul(ud_amount) / T::UnitsPerUd::get(), - existence_requirement, + preservation, )?; Ok(().into()) } @@ -416,7 +420,7 @@ pub mod pallet { dest: <T::Lookup as StaticLookup>::Source, #[pallet::compact] value: BalanceOf<T>, ) -> DispatchResultWithPostInfo { - Self::do_transfer_ud(origin, dest, value, ExistenceRequirement::AllowDeath) + Self::do_transfer_ud(origin, dest, value, Preservation::Expendable) } /// Transfer some liquid free balance to another account, in milliUD. @@ -427,7 +431,7 @@ pub mod pallet { dest: <T::Lookup as StaticLookup>::Source, #[pallet::compact] value: BalanceOf<T>, ) -> DispatchResultWithPostInfo { - Self::do_transfer_ud(origin, dest, value, ExistenceRequirement::KeepAlive) + Self::do_transfer_ud(origin, dest, value, Preservation::Preserve) } } @@ -448,7 +452,7 @@ pub mod pallet { first_ud_index, PastReevals::<T>::get().into_iter(), ); - let _ = T::Currency::deposit_creating(who, uds_total); + let _ = T::Currency::deposit(who, uds_total, Precision::Exact); Self::deposit_event(Event::UdsAutoPaid { count: uds_count, total: uds_total, diff --git a/resources/metadata.scale b/resources/metadata.scale index a8e24383b2f1ae9d40710fe9d4b78344ce741442..a7d62dcf1ef7c1b04ff72729a9f83eb8693d861a 100644 GIT binary patch delta 3550 zcmeBb<^0jg$(Ea1lE}YyBin67UIVAZoW#83RR1)a5WC4jN~PWf8X;Czj>*aSrFkWu zDLM+s3N#rQMN(3WON^E<PVg@%$;{8Q!KZq%oN^GV4VxD#msU;oy1}>EV_q&Zn%uL6 zOO`XHPVe?)G!ltqmVsK#D8azN$dQ>6$vpkMC!=&dhe3KuYFT_yX<kWYZmLTVg!ahK zNeN0#EY8nkVB}B;C`!%DO-xT^VTfgB%qd9B$w@7VFMtYKSs^JFV^DC(EG_{B0SiMS zLU9UI5Jj;L14FDCGmj0Lff5kD29mLiEO0k4FfcGAGEdHPme4>|VF0rjqz|Mjm6?Ho zDU_KZb9$gBqoHUnGfOZ70}DeTGowUUYO+m;9Row|^gwq;iRtS-87(;rLCSNP8A`XC zdoe~aGgeNY<jZKnT+7TcIbK0}`V(J91*S&k$#dt*Z&&qW{Km-GI$b7!F@>=cVtg;u z_=!ly_f9_^z*x&U5oB^NGsD#B1woAB(^CQ&)fs0_?+Ij_z&w+gW3t0i(di~ZjMj{E zw-*F4a<VcmoPIu>QF{8+a7IhUrQ6SkGg>k+uAI&p#aO7nmYIQpg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xUwnA(^bGpDogG3heqZa3m%a%N&IoL(ltq{f`f zQo4P<08=v)sIoES6q#-z%#_U7IDL*VlN@8?^xeWtw-`I8PZMF1W9*&2RfK5|<J|2< zqD%)_7}riWkz$Hs+&H~oiYc9O>-6tZOl^!ir`Jg{^)l|A&LhL*%XoBqlnj$LBjd^G zZL&<08IMkvl4A;EJiEP6jwz9`{vwMx0}CV5NybK|t1Jp0&Kar6*?#$XQK?1w!KryE zsYN$gdK|!_!3C+wVW~yMnfZBlSp+P=Vj&e!k%ue-24E5Q)V$Q<%;Kjk1`rj#`9&p( zIhiGuFIfyUz$*Om^O93Pvh?VHc%0ecshQ~+C4X6_M=3B#u`;sud}WzlslcSlcysxD z1tvyD*69lrnd%uirz<EiIWTfgPgG)>z{oqj%#6uxyM;2-D<)<^R?+QhCQQ;y(;YOJ zY8WM_@6}+kU{sy{O@nDOqvrHgnoKT?y4&AtGOb}`mSr`ZK2MwJJhLOK;`9O?rYtT= zR&eXeku`Ao6CI|vBB87tB^9!)8c8|%$=UH4iNzTPk=vi@GVNw!Ox(WEfJuRoF?IVP zL#9L~=0b?Y{!EOe+sn+DidZ>hS$T3&^8_lVf3Rkfgz;*p3)(QHFm`S)vtfGA$lS}C XxIM#;DT0}C;`W1%OeT!XQ&|}RGddWs diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs index 6cbe9d6e9..4537936a8 100644 --- a/runtime/common/src/pallets_config.rs +++ b/runtime/common/src/pallets_config.rs @@ -108,7 +108,7 @@ macro_rules! pallets_config { type RuntimeEvent = RuntimeEvent; type WeightInfo = common_runtime::weights::pallet_duniter_account::WeightInfo<Runtime>; // does currency adapter in any case, but adds "refund with quota" feature - type InnerOnChargeTransaction = CurrencyAdapter<Balances, HandleFees>; + type InnerOnChargeTransaction = FungibleAdapter<Balances, HandleFees>; type Refund = Quota; } @@ -165,43 +165,27 @@ type MaxNominators = MaxNominators; // MONEY MANAGEMENT // impl pallet_balances::Config for Runtime { -type RuntimeHoldReason = (); -type RuntimeFreezeReason = (); + type RuntimeHoldReason = RuntimeHoldReason; + type RuntimeFreezeReason = (); type RuntimeEvent = RuntimeEvent; type MaxLocks = MaxLocks; type MaxReserves = frame_support::pallet_prelude::ConstU32<5>; type ReserveIdentifier = [u8; 8]; - /// The type for recording an account's balance. type Balance = Balance; - type DustRemoval = HandleDust; + type DustRemoval = HandleFees; type ExistentialDeposit = ExistentialDeposit; type AccountStore = Account; - type FreezeIdentifier = (); - type MaxFreezes = frame_support::pallet_prelude::ConstU32<0>; + type FreezeIdentifier = (); + type MaxFreezes = frame_support::pallet_prelude::ConstU32<0>; type WeightInfo = common_runtime::weights::pallet_balances::WeightInfo<Runtime>; } - // Take Dust from Balances and put it in the Treasury pot - pub struct HandleDust; type CreditOf = frame_support::traits::tokens::fungible::Credit<AccountId, Balances>; - impl frame_support::traits::OnUnbalanced<CreditOf> for HandleDust { - fn on_nonzero_unbalanced(amount: CreditOf) { - use frame_support::traits::Currency as _; - use frame_support::traits::Imbalance as _; - let imbalance = NegativeImbalance::new(amount.peek()); - Balances::resolve_creating(&Treasury::account_id(), imbalance); - } - } - - // fees are moved to the treasury pub struct HandleFees; - type NegativeImbalance = <Balances as frame_support::traits::Currency<AccountId>>::NegativeImbalance; - impl frame_support::traits::OnUnbalanced<NegativeImbalance> for HandleFees { - fn on_nonzero_unbalanced(amount: NegativeImbalance) { - use frame_support::traits::Currency as _; - + impl frame_support::traits::OnUnbalanced<CreditOf> for HandleFees { + fn on_nonzero_unbalanced(amount: CreditOf) { // fee is moved to treasury - Balances::resolve_creating(&Treasury::account_id(), amount); + let _ = Balances::deposit(&Treasury::account_id(), amount.peek(), frame_support::traits::tokens::Precision::Exact); // should move the tip to author // if let Some(author) = Authorship::author() { // Balances::resolve_creating(&author, amount); @@ -349,7 +333,7 @@ type RuntimeFreezeReason = (); type MaxRequests = frame_support::traits::ConstU32<100>; type RequestPrice = frame_support::traits::ConstU64<2_000>; type OnFilledRandomness = (); - type OnUnbalanced = Treasury; + type OnUnbalanced = HandleFees; type ParentBlockRandomness = pallet_babe::ParentBlockRandomness<Self>; type RandomnessFromOneEpochAgo = pallet_babe::RandomnessFromOneEpochAgo<Self>; type WeightInfo = common_runtime::weights::pallet_provide_randomness::WeightInfo<Runtime>; @@ -534,6 +518,7 @@ type RuntimeFreezeReason = (); type EvaluationPrice = frame_support::traits::ConstU64<1000>; type MaxRefereeDistance = frame_support::traits::ConstU32<5>; type MinAccessibleReferees = MinAccessibleReferees; + type RuntimeHoldReason = RuntimeHoldReason; type RuntimeEvent = RuntimeEvent; type WeightInfo = common_runtime::weights::pallet_distance::WeightInfo<Runtime>; type OnValidDistanceStatus = Wot; diff --git a/runtime/g1/src/lib.rs b/runtime/g1/src/lib.rs index 8129cbc2e..20c078caa 100644 --- a/runtime/g1/src/lib.rs +++ b/runtime/g1/src/lib.rs @@ -14,7 +14,6 @@ // You should have received a copy of the GNU Affero General Public License // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. -#![allow(deprecated)] // TODO #![cfg_attr(not(feature = "std"), no_std)] // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit = "256"] @@ -34,13 +33,15 @@ pub use common_runtime::{ constants::*, entities::*, handlers::*, AccountId, Address, Balance, BlockNumber, FullIdentificationOfImpl, GetCurrentEpochIndex, Hash, Header, IdtyIndex, Index, Signature, }; +use frame_support::traits::fungible::Balanced; +use frame_support::traits::Imbalance; pub use frame_system::Call as SystemCall; pub use pallet_balances::Call as BalancesCall; pub use pallet_identity::{IdtyStatus, IdtyValue}; pub use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use pallet_session::historical as session_historical; pub use pallet_timestamp::Call as TimestampCall; -use pallet_transaction_payment::CurrencyAdapter; +use pallet_transaction_payment::FungibleAdapter; pub use pallet_universal_dividend; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs index c662393b4..b7f63c3e3 100644 --- a/runtime/gdev/src/lib.rs +++ b/runtime/gdev/src/lib.rs @@ -14,7 +14,6 @@ // You should have received a copy of the GNU Affero General Public License // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. -#![allow(deprecated)] // TODO #![cfg_attr(not(feature = "std"), no_std)] // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit = "256"] @@ -34,13 +33,15 @@ pub use common_runtime::{ constants::*, entities::*, handlers::*, AccountId, Address, Balance, BlockNumber, FullIdentificationOfImpl, GetCurrentEpochIndex, Hash, Header, IdtyIndex, Index, Signature, }; +use frame_support::traits::fungible::Balanced; +use frame_support::traits::Imbalance; pub use frame_system::Call as SystemCall; pub use pallet_balances::Call as BalancesCall; pub use pallet_duniter_test_parameters::Parameters as GenesisParameters; pub use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use pallet_session::historical as session_historical; pub use pallet_timestamp::Call as TimestampCall; -use pallet_transaction_payment::CurrencyAdapter; +use pallet_transaction_payment::FungibleAdapter; pub use pallet_universal_dividend; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; diff --git a/runtime/gtest/src/lib.rs b/runtime/gtest/src/lib.rs index 385887b0b..9a39989c6 100644 --- a/runtime/gtest/src/lib.rs +++ b/runtime/gtest/src/lib.rs @@ -14,7 +14,6 @@ // You should have received a copy of the GNU Affero General Public License // along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>. -#![allow(deprecated)] // TODO #![cfg_attr(not(feature = "std"), no_std)] // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. #![recursion_limit = "256"] @@ -34,12 +33,14 @@ pub use common_runtime::{ constants::*, entities::*, handlers::*, AccountId, Address, Balance, BlockNumber, FullIdentificationOfImpl, GetCurrentEpochIndex, Hash, Header, IdtyIndex, Index, Signature, }; +use frame_support::traits::fungible::Balanced; +use frame_support::traits::Imbalance; pub use frame_system::Call as SystemCall; pub use pallet_balances::Call as BalancesCall; pub use pallet_im_online::sr25519::AuthorityId as ImOnlineId; use pallet_session::historical as session_historical; pub use pallet_timestamp::Call as TimestampCall; -use pallet_transaction_payment::CurrencyAdapter; +use pallet_transaction_payment::FungibleAdapter; pub use pallet_universal_dividend; #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; -- GitLab