Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Deprecate Currency: Companion for #12951 #6780

Merged
merged 20 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions node/test/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,10 +395,11 @@ pub fn construct_transfer_extrinsic(
dest: sp_keyring::AccountKeyring,
value: Balance,
) -> UncheckedExtrinsic {
let function = polkadot_test_runtime::RuntimeCall::Balances(pallet_balances::Call::transfer {
dest: MultiSigner::from(dest.public()).into_account().into(),
value,
});
let function =
polkadot_test_runtime::RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death {
dest: MultiSigner::from(dest.public()).into_account().into(),
value,
});

construct_extrinsic(client, function, origin, 0)
}
9 changes: 5 additions & 4 deletions node/test/service/tests/call-function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ async fn call_function_actually_work() {

let alice = run_validator_node(alice_config, None);

let function = polkadot_test_runtime::RuntimeCall::Balances(pallet_balances::Call::transfer {
dest: Charlie.to_account_id().into(),
value: 1,
});
let function =
polkadot_test_runtime::RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death {
dest: Charlie.to_account_id().into(),
value: 1,
});
let output = alice.send_extrinsic(function, Bob).await.unwrap();

let res = output.result;
Expand Down
4 changes: 4 additions & 0 deletions runtime/common/src/assigned_slots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,10 @@ mod tests {
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<1>;
}

impl parachains_configuration::Config for Test {
Expand Down
6 changes: 5 additions & 1 deletion runtime/common/src/auctions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ mod tests {
assert_noop, assert_ok, assert_storage_noop,
dispatch::DispatchError::BadOrigin,
ord_parameter_types, parameter_types,
traits::{EitherOfDiverse, OnFinalize, OnInitialize},
traits::{ConstU32, EitherOfDiverse, OnFinalize, OnInitialize},
};
use frame_system::{EnsureRoot, EnsureSignedBy};
use pallet_balances;
Expand Down Expand Up @@ -748,6 +748,10 @@ mod tests {
type MaxLocks = ();
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<1>;
}

#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Debug)]
Expand Down
6 changes: 5 additions & 1 deletion runtime/common/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ mod tests {
assert_err, assert_noop, assert_ok,
dispatch::{DispatchError::BadOrigin, GetDispatchInfo, Pays},
ord_parameter_types, parameter_types,
traits::{ExistenceRequirement, GenesisBuild, WithdrawReasons},
traits::{ConstU32, ExistenceRequirement, GenesisBuild, WithdrawReasons},
};
use pallet_balances;
use sp_runtime::{
Expand Down Expand Up @@ -786,6 +786,10 @@ mod tests {
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type WeightInfo = ();
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<1>;
}

parameter_types! {
Expand Down
8 changes: 6 additions & 2 deletions runtime/common/src/crowdloan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ mod tests {

use frame_support::{
assert_noop, assert_ok, parameter_types,
traits::{OnFinalize, OnInitialize},
traits::{ConstU32, OnFinalize, OnInitialize},
};
use primitives::Id as ParaId;
use sp_core::H256;
Expand Down Expand Up @@ -943,6 +943,10 @@ mod tests {
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type WeightInfo = ();
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<1>;
}

#[derive(Copy, Clone, Eq, PartialEq, Debug)]
Expand Down Expand Up @@ -1613,7 +1617,7 @@ mod tests {
let account_id = Crowdloan::fund_account_id(index);

// user sends the crowdloan funds trying to make an accounting error
assert_ok!(Balances::transfer(RuntimeOrigin::signed(1), account_id, 10));
assert_ok!(Balances::transfer_allow_death(RuntimeOrigin::signed(1), account_id, 10));

// overfunded now
assert_eq!(Balances::free_balance(&account_id), 110);
Expand Down
10 changes: 9 additions & 1 deletion runtime/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ pub fn era_payout(
mod tests {
use super::*;
use frame_support::{
dispatch::DispatchClass, parameter_types, traits::FindAuthor, weights::Weight, PalletId,
dispatch::DispatchClass,
parameter_types,
traits::{ConstU32, FindAuthor},
weights::Weight,
PalletId,
};
use frame_system::limits;
use primitives::AccountId;
Expand Down Expand Up @@ -182,6 +186,10 @@ mod tests {
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type WeightInfo = ();
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<1>;
}

parameter_types! {
Expand Down
6 changes: 5 additions & 1 deletion runtime/common/src/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::{
};
use frame_support::{
assert_noop, assert_ok, parameter_types,
traits::{Currency, GenesisBuild, OnFinalize, OnInitialize},
traits::{ConstU32, Currency, GenesisBuild, OnFinalize, OnInitialize},
weights::Weight,
PalletId,
};
Expand Down Expand Up @@ -178,6 +178,10 @@ impl pallet_balances::Config for Test {
type WeightInfo = ();
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<1>;
}

impl configuration::Config for Test {
Expand Down
6 changes: 5 additions & 1 deletion runtime/common/src/paras_registrar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ mod tests {
assert_noop, assert_ok,
error::BadOrigin,
parameter_types,
traits::{GenesisBuild, OnFinalize, OnInitialize},
traits::{ConstU32, GenesisBuild, OnFinalize, OnInitialize},
};
use frame_system::limits;
use pallet_balances::Error as BalancesError;
Expand Down Expand Up @@ -750,6 +750,10 @@ mod tests {
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type WeightInfo = ();
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<1>;
}

impl shared::Config for Test {}
Expand Down
4 changes: 4 additions & 0 deletions runtime/common/src/purchase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,10 @@ mod tests {
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type WeightInfo = ();
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<1>;
}

parameter_types! {
Expand Down
4 changes: 4 additions & 0 deletions runtime/common/src/slots/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,10 @@ mod tests {
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<1>;
}

parameter_types! {
Expand Down
37 changes: 32 additions & 5 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use runtime_common::{
prod_or_fast, slots, BalanceToU256, BlockHashCount, BlockLength, CurrencyToVote,
SlowAdjustingFeeUpdate, U256ToBalance,
};
use scale_info::TypeInfo;
use sp_std::{cmp::Ordering, collections::btree_map::BTreeMap, prelude::*};

use runtime_parachains::{
Expand Down Expand Up @@ -303,6 +304,10 @@ impl pallet_balances::Config for Runtime {
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
type FreezeIdentifier = ();
type MaxFreezes = ();
ggwpez marked this conversation as resolved.
Show resolved Hide resolved
type HoldIdentifier = HoldReason;
type MaxHolds = ConstU32<1>;
}

parameter_types! {
Expand Down Expand Up @@ -1236,18 +1241,20 @@ impl pallet_balances::Config<NisCounterpartInstance> for Runtime {
type ExistentialDeposit = ConstU128<10_000_000_000>; // One KTC cent
type AccountStore = StorageMapShim<
pallet_balances::Account<Runtime, NisCounterpartInstance>,
frame_system::Provider<Runtime>,
AccountId,
pallet_balances::AccountData<u128>,
>;
type MaxLocks = ConstU32<4>;
type MaxReserves = ConstU32<4>;
type ReserveIdentifier = [u8; 8];
type WeightInfo = weights::pallet_balances_nis_counterpart_balances::WeightInfo<Runtime>;
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<1>;
}

parameter_types! {
pub IgnoredIssuance: Balance = Treasury::pot();
pub const NisBasePeriod: BlockNumber = 7 * DAYS;
pub const MinBid: Balance = 100 * QUID;
pub MinReceipt: Perquintill = Perquintill::from_rational(1u64, 10_000_000u64);
Expand All @@ -1256,7 +1263,27 @@ parameter_types! {
pub const ThawThrottle: (Perquintill, BlockNumber) = (Perquintill::from_percent(25), 5);
pub storage NisTarget: Perquintill = Perquintill::zero();
pub const NisPalletId: PalletId = PalletId(*b"py/nis ");
pub const NisReserveId: [u8; 8] = *b"py/nis ";
pub const NisHoldReason: HoldReason = HoldReason::Nis(HoldReasonNis::NftReceipt);
}

/// A reason for placing a hold on funds.
#[derive(
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, MaxEncodedLen, Debug, TypeInfo,
)]
pub enum HoldReason {
/// Some reason of the NIS pallet.
#[codec(index = 38)]
Nis(HoldReasonNis),
}

/// A reason for the NIS pallet placing a hold on funds.
#[derive(
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, MaxEncodedLen, Debug, TypeInfo,
)]
pub enum HoldReasonNis {
/// The NIS Pallet has reserved it for a non-fungible receipt.
#[codec(index = 0)]
NftReceipt = 0,
}

impl pallet_nis::Config for Runtime {
Expand All @@ -1268,7 +1295,7 @@ impl pallet_nis::Config for Runtime {
type Counterpart = NisCounterpartBalances;
type CounterpartAmount = WithMaximumOf<ConstU128<21_000_000_000_000_000_000u128>>;
type Deficit = (); // Mint
type IgnoredIssuance = IgnoredIssuance;
type IgnoredIssuance = ();
type Target = NisTarget;
type PalletId = NisPalletId;
type QueueCount = ConstU32<500>;
Expand All @@ -1280,7 +1307,7 @@ impl pallet_nis::Config for Runtime {
type IntakePeriod = IntakePeriod;
type MaxIntakeWeight = MaxIntakeWeight;
type ThawThrottle = ThawThrottle;
type ReserveId = NisReserveId;
type HoldReason = NisHoldReason;
}

parameter_types! {
Expand Down
9 changes: 6 additions & 3 deletions runtime/kusama/src/weights/pallet_balances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use sp_std::marker::PhantomData;
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
// Storage: System Account (r:1 w:1)
fn transfer() -> Weight {
fn transfer_allow_death() -> Weight {
// Minimum execution time: 40_902 nanoseconds.
Weight::from_parts(41_638_000 as u64, 0)
.saturating_add(T::DbWeight::get().reads(1 as u64))
Expand All @@ -59,14 +59,14 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: System Account (r:1 w:1)
fn set_balance_creating() -> Weight {
fn force_set_balance_creating() -> Weight {
// Minimum execution time: 23_901 nanoseconds.
Weight::from_parts(24_238_000 as u64, 0)
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
// Storage: System Account (r:1 w:1)
fn set_balance_killing() -> Weight {
fn force_set_balance_killing() -> Weight {
// Minimum execution time: 26_402 nanoseconds.
Weight::from_parts(27_026_000 as u64, 0)
.saturating_add(T::DbWeight::get().reads(1 as u64))
Expand All @@ -93,4 +93,7 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(1 as u64))
.saturating_add(T::DbWeight::get().writes(1 as u64))
}
fn upgrade_accounts(_: u32) -> Weight {
Weight::from_parts(0, 0)
ggwpez marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
/// Storage: NisCounterpartBalances TotalIssuance (r:1 w:1)
/// Proof: NisCounterpartBalances TotalIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
fn transfer() -> Weight {
fn transfer_allow_death() -> Weight {
// Proof Size summary in bytes:
// Measured: `219`
// Estimated: `11258`
Expand Down Expand Up @@ -79,7 +79,7 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
/// Proof: NisCounterpartBalances Account (max_values: None, max_size: Some(112), added: 2587, mode: MaxEncodedLen)
/// Storage: NisCounterpartBalances TotalIssuance (r:1 w:1)
/// Proof: NisCounterpartBalances TotalIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
fn set_balance_creating() -> Weight {
fn force_set_balance_creating() -> Weight {
// Proof Size summary in bytes:
// Measured: `219`
// Estimated: `5078`
Expand All @@ -95,7 +95,7 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
/// Storage: NisCounterpartBalances TotalIssuance (r:1 w:1)
/// Proof: NisCounterpartBalances TotalIssuance (max_values: Some(1), max_size: Some(16), added: 511, mode: MaxEncodedLen)
fn set_balance_killing() -> Weight {
fn force_set_balance_killing() -> Weight {
// Proof Size summary in bytes:
// Measured: `393`
// Estimated: `8671`
Expand Down Expand Up @@ -147,4 +147,7 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
fn upgrade_accounts(_: u32) -> Weight {
Weight::from_parts(0, 0)
}
}
8 changes: 6 additions & 2 deletions runtime/parachains/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{

use frame_support::{
parameter_types,
traits::{GenesisBuild, ValidatorSet, ValidatorSetWithIdentification},
traits::{ConstU32, GenesisBuild, ValidatorSet, ValidatorSetWithIdentification},
weights::Weight,
};
use frame_support_test::TestRandomness;
Expand Down Expand Up @@ -113,7 +113,7 @@ impl frame_system::Config for Test {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}

parameter_types! {
Expand All @@ -130,6 +130,10 @@ impl pallet_balances::Config for Test {
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<1>;
}

parameter_types! {
Expand Down
4 changes: 4 additions & 0 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ impl pallet_balances::Config for Runtime {
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<1>;
gavofyork marked this conversation as resolved.
Show resolved Hide resolved
}

parameter_types! {
Expand Down
Loading