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 #2334

Merged
merged 16 commits into from
Mar 20, 2023
Merged
586 changes: 327 additions & 259 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ opt-level = 3
inherits = "release"
lto = true
codegen-units = 1

4 changes: 4 additions & 0 deletions pallets/collator-selection/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
}

pub struct Author4;
Expand Down
6 changes: 5 additions & 1 deletion pallets/xcmp-queue/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use cumulus_pallet_parachain_system::AnyRelayNumber;
use cumulus_primitives_core::{IsSystem, ParaId};
use frame_support::{
parameter_types,
traits::{Everything, Nothing, OriginTrait},
traits::{ConstU32, Everything, Nothing, OriginTrait},
};
use frame_system::EnsureRoot;
use sp_core::H256;
Expand Down Expand Up @@ -100,6 +100,10 @@ impl pallet_balances::Config for Test {
type MaxLocks = ();
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
}

impl cumulus_pallet_parachain_system::Config for Test {
Expand Down
4 changes: 4 additions & 0 deletions parachain-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ impl pallet_balances::Config for Runtime {
type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
}

parameter_types! {
Expand Down
14 changes: 9 additions & 5 deletions parachains/common/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
//! Taken from polkadot/runtime/common (at a21cd64) and adapted for parachains.

use frame_support::traits::{
fungibles::{self, Balanced, CreditOf},
fungibles::{self, Balanced, Credit},
Contains, ContainsPair, Currency, Get, Imbalance, OnUnbalanced,
};
use pallet_asset_tx_payment::HandleCredit;
Expand Down Expand Up @@ -75,7 +75,7 @@ where
R: pallet_authorship::Config + pallet_assets::Config<I>,
AccountIdOf<R>: From<polkadot_primitives::AccountId> + Into<polkadot_primitives::AccountId>,
{
fn handle_credit(credit: CreditOf<AccountIdOf<R>, pallet_assets::Pallet<R, I>>) {
fn handle_credit(credit: Credit<AccountIdOf<R>, pallet_assets::Pallet<R, I>>) {
if let Some(author) = pallet_authorship::Pallet::<R>::author() {
// In case of error: Will drop the result triggering the `OnDrop` of the imbalance.
let _ = pallet_assets::Pallet::<R, I>::resolve(&author, credit);
Expand Down Expand Up @@ -111,13 +111,13 @@ mod tests {
use super::*;
use frame_support::{
parameter_types,
traits::{FindAuthor, ValidatorRegistration},
traits::{ConstU32, FindAuthor, ValidatorRegistration},
PalletId,
};
use frame_system::{limits, EnsureRoot};
use pallet_collator_selection::IdentityCollator;
use polkadot_primitives::AccountId;
use sp_core::H256;
use sp_core::{ConstU64, H256};
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
Expand Down Expand Up @@ -179,12 +179,16 @@ mod tests {
type Balance = u64;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ();
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type MaxLocks = ();
type WeightInfo = ();
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<1>;
}

pub struct OneAuthor;
Expand Down
10 changes: 8 additions & 2 deletions parachains/runtimes/assets/statemine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ impl pallet_balances::Config for Runtime {
type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
}

parameter_types! {
Expand Down Expand Up @@ -1139,7 +1143,8 @@ mod tests {
use pallet_balances::WeightInfo;
let block = RuntimeBlockWeights::get().max_block;
let base = RuntimeBlockWeights::get().get(DispatchClass::Normal).base_extrinsic;
let transfer = base + weights::pallet_balances::WeightInfo::<Runtime>::transfer();
let transfer =
base + weights::pallet_balances::WeightInfo::<Runtime>::transfer_allow_death();

let fit = block.checked_div_per_component(&transfer).unwrap_or_default();
assert!(fit >= 1000, "{} should be at least 1000", fit);
Expand All @@ -1150,7 +1155,8 @@ mod tests {
fn sane_transfer_fee() {
use pallet_balances::WeightInfo;
let base = RuntimeBlockWeights::get().get(DispatchClass::Normal).base_extrinsic;
let transfer = base + weights::pallet_balances::WeightInfo::<Runtime>::transfer();
let transfer =
base + weights::pallet_balances::WeightInfo::<Runtime>::transfer_allow_death();

let fee: Balance = fee::WeightToFee::weight_to_fee(&transfer);
assert!(fee <= CENTS, "{} MILLICENTS should be at most 1000", fee / MILLICENTS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn transfer() -> Weight {
fn transfer_allow_death() -> Weight {
// Proof Size summary in bytes:
// Measured: `1178`
// Estimated: `2603`
Expand All @@ -73,7 +73,7 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
}
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn set_balance_creating() -> Weight {
fn force_set_balance_creating() -> Weight {
// Proof Size summary in bytes:
// Measured: `1174`
// Estimated: `2603`
Expand All @@ -85,7 +85,7 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
}
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn set_balance_killing() -> Weight {
fn force_set_balance_killing() -> Weight {
// Proof Size summary in bytes:
// Measured: `1174`
// Estimated: `2603`
Expand Down Expand Up @@ -121,6 +121,9 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
}
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn upgrade_accounts(_: u32) -> Weight {
Weight::from_parts(0, 0)
ggwpez marked this conversation as resolved.
Show resolved Hide resolved
}
fn force_unreserve() -> Weight {
// Proof Size summary in bytes:
// Measured: `1058`
Expand Down
10 changes: 8 additions & 2 deletions parachains/runtimes/assets/statemint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ impl pallet_balances::Config for Runtime {
type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
}

parameter_types! {
Expand Down Expand Up @@ -1091,7 +1095,8 @@ mod tests {
use pallet_balances::WeightInfo;
let block = RuntimeBlockWeights::get().max_block;
let base = RuntimeBlockWeights::get().get(DispatchClass::Normal).base_extrinsic;
let transfer = base + weights::pallet_balances::WeightInfo::<Runtime>::transfer();
let transfer =
base + weights::pallet_balances::WeightInfo::<Runtime>::transfer_allow_death();

let fit = block.checked_div_per_component(&transfer).unwrap_or_default();
assert!(fit >= 1000, "{} should be at least 1000", fit);
Expand All @@ -1102,7 +1107,8 @@ mod tests {
fn sane_transfer_fee() {
use pallet_balances::WeightInfo;
let base = RuntimeBlockWeights::get().get(DispatchClass::Normal).base_extrinsic;
let transfer = base + weights::pallet_balances::WeightInfo::<Runtime>::transfer();
let transfer =
base + weights::pallet_balances::WeightInfo::<Runtime>::transfer_allow_death();

let fee: Balance = fee::WeightToFee::weight_to_fee(&transfer);
assert!(fee <= CENTS, "{} MILLICENTS should be at most 1000", fee / MILLICENTS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn transfer() -> Weight {
fn transfer_allow_death() -> Weight {
// Proof Size summary in bytes:
// Measured: `1178`
// Estimated: `2603`
Expand All @@ -73,7 +73,7 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
}
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn set_balance_creating() -> Weight {
fn force_set_balance_creating() -> Weight {
// Proof Size summary in bytes:
// Measured: `1174`
// Estimated: `2603`
Expand All @@ -85,7 +85,7 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
}
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn set_balance_killing() -> Weight {
fn force_set_balance_killing() -> Weight {
// Proof Size summary in bytes:
// Measured: `1174`
// Estimated: `2603`
Expand Down Expand Up @@ -121,6 +121,9 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
}
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn upgrade_accounts(_: u32) -> Weight {
Weight::from_parts(0, 0)
}
fn force_unreserve() -> Weight {
// Proof Size summary in bytes:
// Measured: `1058`
Expand Down
4 changes: 4 additions & 0 deletions parachains/runtimes/assets/westmint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ impl pallet_balances::Config for Runtime {
type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
}

parameter_types! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn transfer() -> Weight {
fn transfer_allow_death() -> Weight {
// Proof Size summary in bytes:
// Measured: `1177`
// Estimated: `2603`
Expand All @@ -73,7 +73,7 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
}
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn set_balance_creating() -> Weight {
fn force_set_balance_creating() -> Weight {
// Proof Size summary in bytes:
// Measured: `1173`
// Estimated: `2603`
Expand All @@ -85,7 +85,7 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
}
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn set_balance_killing() -> Weight {
fn force_set_balance_killing() -> Weight {
// Proof Size summary in bytes:
// Measured: `1173`
// Estimated: `2603`
Expand Down Expand Up @@ -121,6 +121,9 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
}
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn upgrade_accounts(_: u32) -> Weight {
Weight::from_parts(0, 0)
}
fn force_unreserve() -> Weight {
// Proof Size summary in bytes:
// Measured: `1057`
Expand Down
4 changes: 4 additions & 0 deletions parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ impl pallet_balances::Config for Runtime {
type MaxLocks = ConstU32<50>;
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
}

parameter_types! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn transfer() -> Weight {
fn transfer_allow_death() -> Weight {
// Proof Size summary in bytes:
// Measured: `1314`
// Estimated: `2603`
Expand All @@ -73,7 +73,7 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
}
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn set_balance_creating() -> Weight {
fn force_set_balance_creating() -> Weight {
// Proof Size summary in bytes:
// Measured: `1348`
// Estimated: `2603`
Expand All @@ -85,7 +85,7 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
}
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn set_balance_killing() -> Weight {
fn force_set_balance_killing() -> Weight {
// Proof Size summary in bytes:
// Measured: `1348`
// Estimated: `2603`
Expand Down Expand Up @@ -121,6 +121,9 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
}
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn upgrade_accounts(_: u32) -> Weight {
Weight::from_parts(0, 0)
}
fn force_unreserve() -> Weight {
// Proof Size summary in bytes:
// Measured: `1232`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ impl pallet_balances::Config for Runtime {
type MaxLocks = ConstU32<50>;
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
}

parameter_types! {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn transfer() -> Weight {
fn transfer_allow_death() -> Weight {
// Proof Size summary in bytes:
// Measured: `1316`
// Estimated: `2603`
Expand All @@ -73,7 +73,7 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
}
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn set_balance_creating() -> Weight {
fn force_set_balance_creating() -> Weight {
// Proof Size summary in bytes:
// Measured: `1350`
// Estimated: `2603`
Expand All @@ -85,7 +85,7 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
}
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn set_balance_killing() -> Weight {
fn force_set_balance_killing() -> Weight {
// Proof Size summary in bytes:
// Measured: `1350`
// Estimated: `2603`
Expand Down Expand Up @@ -121,6 +121,9 @@ impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
}
/// Storage: System Account (r:1 w:1)
/// Proof: System Account (max_values: None, max_size: Some(128), added: 2603, mode: MaxEncodedLen)
fn upgrade_accounts(_: u32) -> Weight {
Weight::from_parts(0, 0)
}
fn force_unreserve() -> Weight {
// Proof Size summary in bytes:
// Measured: `1234`
Expand Down
4 changes: 4 additions & 0 deletions parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ impl pallet_balances::Config for Runtime {
type MaxLocks = ConstU32<50>;
type MaxReserves = ConstU32<50>;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
}

parameter_types! {
Expand Down
Loading