Deprecate Currency: Companion for #12951 (#6780)

* Some renames

* Fix

* Fix build for new APIs

* Remove diener

* Fixes

* Fixes

* Fix integration tests

* Fixes

* fix nis issuance

* Update Cargo.toml

* Polkadot doesn't have freezes/holds yet

* No networks use freezes/holds

* update lockfile for {"substrate"}

* Fix tests

There are more failing tests; just starting with the easy ones.
Reserved balance does not count towards ED anymore, therefore reducing
all the reserves by ED (1).

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fixes for Polkadot pallets

* Fix parachains benchmarks

* Update Substrate

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: parity-processbot <>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Gavin Wood
2023-03-20 13:20:22 +00:00
committed by GitHub
parent 67035d6436
commit 2e656dcd6e
33 changed files with 481 additions and 305 deletions
+186 -186
View File
File diff suppressed because it is too large Load Diff
+5 -4
View File
@@ -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)
}
@@ -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;
@@ -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 {
+29 -23
View File
@@ -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;
@@ -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)]
@@ -1412,24 +1416,25 @@ mod tests {
let para_2 = ParaId::from(2_u32);
// Make a bid and reserve a balance
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), para_1, 1, 1, 4, 10));
assert_eq!(Balances::reserved_balance(1), 10);
assert_eq!(ReservedAmounts::<Test>::get((1, para_1)), Some(10));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), para_1, 1, 1, 4, 9));
assert_eq!(Balances::reserved_balance(1), 9);
assert_eq!(ReservedAmounts::<Test>::get((1, para_1)), Some(9));
assert_eq!(Balances::reserved_balance(2), 0);
assert_eq!(ReservedAmounts::<Test>::get((2, para_2)), None);
// Bigger bid, reserves new balance and returns funds
assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), para_2, 1, 1, 4, 20));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), para_2, 1, 1, 4, 19));
assert_eq!(Balances::reserved_balance(1), 0);
assert_eq!(ReservedAmounts::<Test>::get((1, para_1)), None);
assert_eq!(Balances::reserved_balance(2), 20);
assert_eq!(ReservedAmounts::<Test>::get((2, para_2)), Some(20));
assert_eq!(Balances::reserved_balance(2), 19);
assert_eq!(ReservedAmounts::<Test>::get((2, para_2)), Some(19));
});
}
#[test]
fn initialize_winners_in_ending_period_works() {
new_test_ext().execute_with(|| {
assert_eq!(<Test as pallet_balances::Config>::ExistentialDeposit::get(), 1);
run_to_block(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 9, 1));
let para_1 = ParaId::from(1_u32);
@@ -1437,16 +1442,16 @@ mod tests {
let para_3 = ParaId::from(3_u32);
// Make bids
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), para_1, 1, 1, 4, 10));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), para_2, 1, 3, 4, 20));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), para_1, 1, 1, 4, 9));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), para_2, 1, 3, 4, 19));
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::StartingPeriod
);
let mut winning = [None; SlotRange::SLOT_RANGE_COUNT];
winning[SlotRange::ZeroThree as u8 as usize] = Some((1, para_1, 10));
winning[SlotRange::TwoThree as u8 as usize] = Some((2, para_2, 20));
winning[SlotRange::ZeroThree as u8 as usize] = Some((1, para_1, 9));
winning[SlotRange::TwoThree as u8 as usize] = Some((2, para_2, 19));
assert_eq!(Auctions::winning(0), Some(winning));
run_to_block(9);
@@ -1468,14 +1473,14 @@ mod tests {
AuctionStatus::<u32>::EndingPeriod(1, 0)
);
assert_eq!(Auctions::winning(1), Some(winning));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 3, 4, 30));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 3, 4, 29));
run_to_block(12);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::EndingPeriod(2, 0)
);
winning[SlotRange::TwoThree as u8 as usize] = Some((3, para_3, 30));
winning[SlotRange::TwoThree as u8 as usize] = Some((3, para_3, 29));
assert_eq!(Auctions::winning(2), Some(winning));
});
}
@@ -1542,6 +1547,7 @@ mod tests {
#[test]
fn less_winning_samples_work() {
new_test_ext().execute_with(|| {
assert_eq!(<Test as pallet_balances::Config>::ExistentialDeposit::get(), 1);
EndingPeriod::set(30);
SampleLength::set(10);
@@ -1552,16 +1558,16 @@ mod tests {
let para_3 = ParaId::from(3_u32);
// Make bids
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), para_1, 1, 11, 14, 10));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), para_2, 1, 13, 14, 20));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), para_1, 1, 11, 14, 9));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), para_2, 1, 13, 14, 19));
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::StartingPeriod
);
let mut winning = [None; SlotRange::SLOT_RANGE_COUNT];
winning[SlotRange::ZeroThree as u8 as usize] = Some((1, para_1, 10));
winning[SlotRange::TwoThree as u8 as usize] = Some((2, para_2, 20));
winning[SlotRange::ZeroThree as u8 as usize] = Some((1, para_1, 9));
winning[SlotRange::TwoThree as u8 as usize] = Some((2, para_2, 19));
assert_eq!(Auctions::winning(0), Some(winning));
run_to_block(9);
@@ -1578,8 +1584,8 @@ mod tests {
assert_eq!(Auctions::winning(0), Some(winning));
// New bids update the current winning
assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 14, 14, 30));
winning[SlotRange::ThreeThree as u8 as usize] = Some((3, para_3, 30));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 14, 14, 29));
winning[SlotRange::ThreeThree as u8 as usize] = Some((3, para_3, 29));
assert_eq!(Auctions::winning(0), Some(winning));
run_to_block(20);
@@ -1590,8 +1596,8 @@ mod tests {
assert_eq!(Auctions::winning(1), Some(winning));
run_to_block(25);
// Overbid mid sample
assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 13, 14, 30));
winning[SlotRange::TwoThree as u8 as usize] = Some((3, para_3, 30));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 13, 14, 29));
winning[SlotRange::TwoThree as u8 as usize] = Some((3, para_3, 29));
assert_eq!(Auctions::winning(1), Some(winning));
run_to_block(30);
@@ -1611,8 +1617,8 @@ mod tests {
assert_eq!(
leases(),
vec![
((3.into(), 13), LeaseData { leaser: 3, amount: 30 }),
((3.into(), 14), LeaseData { leaser: 3, amount: 30 }),
((3.into(), 13), LeaseData { leaser: 3, amount: 29 }),
((3.into(), 14), LeaseData { leaser: 3, amount: 29 }),
]
);
});
+9 -4
View File
@@ -717,13 +717,14 @@ 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::{
testing::Header,
traits::{BlakeTwo256, Identity, IdentityLookup},
transaction_validity::TransactionLongevity,
TokenError,
};
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
@@ -786,6 +787,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! {
@@ -1206,7 +1211,7 @@ mod tests {
180,
ExistenceRequirement::AllowDeath
),
pallet_balances::Error::<Test, _>::LiquidityRestrictions,
TokenError::Frozen,
);
});
}
@@ -1294,6 +1299,8 @@ mod tests {
#[test]
fn claiming_while_vested_doesnt_work() {
new_test_ext().execute_with(|| {
CurrencyOf::<Test>::make_free_balance_be(&69, total_claims());
assert_eq!(Balances::free_balance(69), total_claims());
// A user is already vested
assert_ok!(<Test as Config>::VestingSchedule::add_vesting_schedule(
&69,
@@ -1301,8 +1308,6 @@ mod tests {
100,
10
));
CurrencyOf::<Test>::make_free_balance_be(&69, total_claims());
assert_eq!(Balances::free_balance(69), total_claims());
assert_ok!(Claims::mint_claim(
RuntimeOrigin::root(),
eth(&bob()),
+13 -5
View File
@@ -419,6 +419,7 @@ pub mod pallet {
let deposit = T::SubmissionDeposit::get();
frame_system::Pallet::<T>::inc_providers(&Self::fund_account_id(fund_index));
CurrencyOf::<T>::reserve(&depositor, deposit)?;
Funds::<T>::insert(
@@ -575,6 +576,7 @@ pub mod pallet {
// can take care of that.
debug_assert!(Self::contribution_iterator(fund.fund_index).count().is_zero());
frame_system::Pallet::<T>::dec_providers(&Self::fund_account_id(fund.fund_index))?;
CurrencyOf::<T>::unreserve(&fund.depositor, fund.deposit);
Funds::<T>::remove(index);
Self::deposit_event(Event::<T>::Dissolved { para_id: index });
@@ -861,7 +863,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;
@@ -943,6 +945,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)]
@@ -987,9 +993,10 @@ mod tests {
let fund = Funds::<Test>::get(para).unwrap();
let account_id = Crowdloan::fund_account_id(fund.fund_index);
if winner {
let ed = <Test as pallet_balances::Config>::ExistentialDeposit::get();
let free_balance = Balances::free_balance(&account_id);
Balances::reserve(&account_id, free_balance)
.expect("should be able to reserve free balance");
Balances::reserve(&account_id, free_balance - ed)
.expect("should be able to reserve free balance minus ED");
} else {
let reserved_balance = Balances::reserved_balance(&account_id);
Balances::unreserve(&account_id, reserved_balance);
@@ -1613,7 +1620,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);
@@ -1782,6 +1789,7 @@ mod tests {
#[test]
fn withdraw_from_finished_works() {
new_test_ext().execute_with(|| {
assert_eq!(<Test as pallet_balances::Config>::ExistentialDeposit::get(), 1);
let para = new_para();
let index = NextFundIndex::<Test>::get();
let account_id = Crowdloan::fund_account_id(index);
@@ -1793,7 +1801,7 @@ mod tests {
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(2), para, 100, None));
assert_ok!(Crowdloan::contribute(RuntimeOrigin::signed(3), para, 50, None));
// simulate the reserving of para's funds. this actually happens in the Slots pallet.
assert_ok!(Balances::reserve(&account_id, 150));
assert_ok!(Balances::reserve(&account_id, 149));
run_to_block(19);
assert_noop!(
+11 -3
View File
@@ -102,11 +102,15 @@ 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;
use sp_core::H256;
use sp_core::{ConstU64, H256};
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
@@ -176,12 +180,16 @@ mod tests {
type Balance = u64;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ();
type ExistentialDeposit = ConstU64<1>;
type AccountStore = System;
type MaxLocks = ();
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
type WeightInfo = ();
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<1>;
type MaxFreezes = ConstU32<1>;
}
parameter_types! {
@@ -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,
};
@@ -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<0>;
type MaxFreezes = ConstU32<0>;
}
impl configuration::Config for Test {
@@ -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;
@@ -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 {}
+9 -4
View File
@@ -485,11 +485,10 @@ mod tests {
ord_parameter_types, parameter_types,
traits::{Currency, WithdrawReasons},
};
use pallet_balances::Error as BalancesError;
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, Dispatchable, IdentifyAccount, Identity, IdentityLookup, Verify},
MultiSignature,
ArithmeticError, MultiSignature,
};
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
@@ -554,6 +553,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! {
@@ -815,6 +818,7 @@ mod tests {
);
// Account with vesting
Balances::make_free_balance_be(&alice(), 100);
assert_ok!(<Test as Config>::VestingSchedule::add_vesting_schedule(
&alice(),
100,
@@ -1127,6 +1131,7 @@ mod tests {
// Wrong Origin
assert_noop!(Purchase::payout(RuntimeOrigin::signed(alice()), alice(),), BadOrigin);
// Account with Existing Vesting Schedule
Balances::make_free_balance_be(&bob(), 100);
assert_ok!(
<Test as Config>::VestingSchedule::add_vesting_schedule(&bob(), 100, 1, 50,)
);
@@ -1163,8 +1168,8 @@ mod tests {
Permill::zero(),
));
assert_noop!(
Purchase::payout(RuntimeOrigin::signed(payment_account()), alice(),),
BalancesError::<Test, _>::InsufficientBalance
Purchase::payout(RuntimeOrigin::signed(payment_account()), alice()),
ArithmeticError::Underflow
);
});
}
+7 -3
View File
@@ -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! {
@@ -844,9 +848,9 @@ mod tests {
// max_num different people are reserved for leases to Para ID 1
for i in 1u32..=max_num {
let j: u64 = i.into();
assert_ok!(Slots::lease_out(1.into(), &j, j * 10, i * i, i));
assert_eq!(Slots::deposit_held(1.into(), &j), j * 10);
assert_eq!(Balances::reserved_balance(j), j * 10);
assert_ok!(Slots::lease_out(1.into(), &j, j * 10 - 1, i * i, i));
assert_eq!(Slots::deposit_held(1.into(), &j), j * 10 - 1);
assert_eq!(Balances::reserved_balance(j), j * 10 - 1);
}
assert_ok!(Slots::clear_all_leases(RuntimeOrigin::root(), 1.into()));
+32 -5
View File
@@ -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::{
@@ -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 = ();
type HoldIdentifier = HoldReason;
type MaxHolds = ConstU32<1>;
}
parameter_types! {
@@ -1236,7 +1241,6 @@ 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>,
>;
@@ -1244,10 +1248,13 @@ impl pallet_balances::Config<NisCounterpartInstance> for Runtime {
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<0>;
type MaxFreezes = ConstU32<0>;
}
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);
@@ -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 {
@@ -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>;
@@ -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! {
@@ -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))
@@ -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))
@@ -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)
}
}
@@ -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`
@@ -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`
@@ -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`
@@ -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)
}
}
@@ -69,6 +69,7 @@ where
<T as frame_system::Config>::RuntimeOrigin: From<crate::Origin>,
{
let config = Configuration::<T>::config();
let ed = T::Currency::minimum_balance();
let deposit: BalanceOf<T> = config.hrmp_sender_deposit.unique_saturated_into();
let capacity = config.hrmp_channel_max_capacity;
let message_size = config.hrmp_channel_max_message_size;
@@ -83,10 +84,10 @@ where
// Make both a parachain if they are already not.
if !Paras::<T>::is_parachain(sender) {
register_parachain_with_balance::<T>(sender, deposit);
register_parachain_with_balance::<T>(sender, deposit + ed);
}
if !Paras::<T>::is_parachain(recipient) {
register_parachain_with_balance::<T>(recipient, deposit);
register_parachain_with_balance::<T>(recipient, deposit + ed);
}
assert_ok!(Hrmp::<T>::hrmp_init_open_channel(
@@ -147,9 +148,10 @@ frame_benchmarking::benchmarks! {
let recipient_id: ParaId = 2u32.into();
// make sure para is registered, and has enough balance.
let ed = T::Currency::minimum_balance();
let deposit: BalanceOf<T> = Configuration::<T>::config().hrmp_sender_deposit.unique_saturated_into();
register_parachain_with_balance::<T>(sender_id, deposit);
register_parachain_with_balance::<T>(recipient_id, deposit);
register_parachain_with_balance::<T>(sender_id, deposit + ed);
register_parachain_with_balance::<T>(recipient_id, deposit + ed);
let capacity = Configuration::<T>::config().hrmp_channel_max_capacity;
let message_size = Configuration::<T>::config().hrmp_channel_max_message_size;
@@ -302,12 +304,13 @@ frame_benchmarking::benchmarks! {
let recipient_id: ParaId = 2u32.into();
// make sure para is registered, and has enough balance.
let ed = T::Currency::minimum_balance();
let sender_deposit: BalanceOf<T> =
Configuration::<T>::config().hrmp_sender_deposit.unique_saturated_into();
let recipient_deposit: BalanceOf<T> =
Configuration::<T>::config().hrmp_recipient_deposit.unique_saturated_into();
register_parachain_with_balance::<T>(sender_id, sender_deposit);
register_parachain_with_balance::<T>(recipient_id, recipient_deposit);
register_parachain_with_balance::<T>(sender_id, sender_deposit + ed);
register_parachain_with_balance::<T>(recipient_id, recipient_deposit + ed);
let capacity = Configuration::<T>::config().hrmp_channel_max_capacity;
let message_size = Configuration::<T>::config().hrmp_channel_max_message_size;
+7 -3
View File
@@ -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;
@@ -113,11 +113,11 @@ 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! {
pub static ExistentialDeposit: u64 = 0;
pub static ExistentialDeposit: u64 = 1;
}
impl pallet_balances::Config for Test {
@@ -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<0>;
type MaxFreezes = ConstU32<0>;
}
parameter_types! {
+4
View File
@@ -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<0>;
type MaxFreezes = ConstU32<0>;
}
parameter_types! {
@@ -47,7 +47,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: `0`
// Estimated: `3593`
@@ -71,7 +71,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: `174`
// Estimated: `3593`
@@ -83,7 +83,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: `174`
// Estimated: `3593`
@@ -129,4 +129,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)
}
}
+32 -5
View File
@@ -34,6 +34,7 @@ use runtime_common::{
paras_registrar, paras_sudo_wrapper, prod_or_fast, slots, BlockHashCount, BlockLength,
SlowAdjustingFeeUpdate,
};
use scale_info::TypeInfo;
use sp_std::{cmp::Ordering, collections::btree_map::BTreeMap, prelude::*};
use runtime_parachains::{
@@ -281,6 +282,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 = ConstU32<1>;
type HoldIdentifier = HoldReason;
type MaxHolds = ConstU32<1>;
}
parameter_types! {
@@ -1169,7 +1174,6 @@ impl pallet_balances::Config<NisCounterpartInstance> for Runtime {
type ExistentialDeposit = ConstU128<10_000_000_000>; // One RTC cent
type AccountStore = StorageMapShim<
pallet_balances::Account<Runtime, NisCounterpartInstance>,
frame_system::Provider<Runtime>,
AccountId,
pallet_balances::AccountData<u128>,
>;
@@ -1177,10 +1181,13 @@ impl pallet_balances::Config<NisCounterpartInstance> for Runtime {
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<0>;
type MaxFreezes = ConstU32<0>;
}
parameter_types! {
pub IgnoredIssuance: Balance = Treasury::pot();
pub const NisBasePeriod: BlockNumber = 30 * DAYS;
pub const MinBid: Balance = 100 * UNITS;
pub MinReceipt: Perquintill = Perquintill::from_rational(1u64, 10_000_000u64);
@@ -1189,7 +1196,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 {
@@ -1201,7 +1228,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<300>;
@@ -1213,7 +1240,7 @@ impl pallet_nis::Config for Runtime {
type IntakePeriod = IntakePeriod;
type MaxIntakeWeight = MaxIntakeWeight;
type ThawThrottle = ThawThrottle;
type ReserveId = NisReserveId;
type HoldReason = NisHoldReason;
}
parameter_types! {
@@ -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_106 nanoseconds.
Weight::from_parts(40_750_000 as u64, 0)
.saturating_add(T::DbWeight::get().reads(1 as u64))
@@ -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_902 nanoseconds.
Weight::from_parts(24_338_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_492 nanoseconds.
Weight::from_parts(26_866_000 as u64, 0)
.saturating_add(T::DbWeight::get().reads(1 as u64))
@@ -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)
}
}
@@ -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`
@@ -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`
@@ -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`
@@ -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)
}
}
+5 -1
View File
@@ -56,7 +56,7 @@ use runtime_common::{
claims, impl_runtime_weights, paras_sudo_wrapper, BlockHashCount, BlockLength,
SlowAdjustingFeeUpdate,
};
use sp_core::OpaqueMetadata;
use sp_core::{ConstU32, OpaqueMetadata};
use sp_mmr_primitives as mmr;
use sp_runtime::{
create_runtime_str,
@@ -217,6 +217,10 @@ impl pallet_balances::Config for Runtime {
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type WeightInfo = ();
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
}
parameter_types! {
+4
View File
@@ -258,6 +258,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<0>;
type MaxFreezes = ConstU32<0>;
}
parameter_types! {
@@ -47,7 +47,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: `0`
// Estimated: `3593`
@@ -71,7 +71,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: `174`
// Estimated: `3593`
@@ -83,7 +83,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: `174`
// Estimated: `3593`
@@ -129,4 +129,8 @@ 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)
}
}
@@ -20,7 +20,7 @@ use crate::{fungible as xcm_balances_benchmark, mock::*};
use frame_benchmarking::BenchmarkError;
use frame_support::{
parameter_types,
traits::{Everything, Nothing},
traits::{ConstU32, Everything, Nothing},
weights::Weight,
};
use sp_core::H256;
@@ -77,7 +77,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! {
@@ -94,6 +94,10 @@ impl pallet_balances::Config for Test {
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = ();
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
}
parameter_types! {
+5 -1
View File
@@ -17,7 +17,7 @@
use codec::Encode;
use frame_support::{
construct_runtime, parameter_types,
traits::{Everything, Nothing},
traits::{ConstU32, Everything, Nothing},
weights::Weight,
};
use polkadot_parachain::primitives::Id as ParaId;
@@ -242,6 +242,10 @@ impl pallet_balances::Config for Test {
type WeightInfo = ();
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
}
parameter_types! {
@@ -16,7 +16,12 @@
//! Adapters to work with `frame_support::traits::tokens::fungibles` through XCM.
use frame_support::traits::{tokens::fungibles, Contains, Get};
use frame_support::traits::{
tokens::{
fungibles, Fortitude::Polite, Precision::Exact, Preservation::Preserve, Provenance::Minted,
},
Contains, Get,
};
use sp_std::{marker::PhantomData, prelude::*, result};
use xcm::latest::prelude::*;
use xcm_executor::traits::{Convert, Error as MatchError, MatchesFungibles, TransactAsset};
@@ -26,7 +31,7 @@ pub struct FungiblesTransferAdapter<Assets, Matcher, AccountIdConverter, Account
PhantomData<(Assets, Matcher, AccountIdConverter, AccountId)>,
);
impl<
Assets: fungibles::Transfer<AccountId>,
Assets: fungibles::Mutate<AccountId>,
Matcher: MatchesFungibles<Assets::AssetId, Assets::Balance>,
AccountIdConverter: Convert<MultiLocation, AccountId>,
AccountId: Clone, // can't get away without it since Currency is generic over it.
@@ -49,7 +54,7 @@ impl<
.map_err(|()| MatchError::AccountIdConversionFailed)?;
let dest = AccountIdConverter::convert_ref(to)
.map_err(|()| MatchError::AccountIdConversionFailed)?;
Assets::transfer(asset_id, &source, &dest, amount, true)
Assets::transfer(asset_id, &source, &dest, amount, Preserve)
.map_err(|e| XcmError::FailedToTransactAsset(e.into()))?;
Ok(what.clone().into())
}
@@ -153,14 +158,14 @@ impl<
{
fn can_accrue_checked(asset_id: Assets::AssetId, amount: Assets::Balance) -> XcmResult {
let checking_account = CheckingAccount::get();
Assets::can_deposit(asset_id, &checking_account, amount, true)
Assets::can_deposit(asset_id, &checking_account, amount, Minted)
.into_result()
.map_err(|_| XcmError::NotDepositable)
}
fn can_reduce_checked(asset_id: Assets::AssetId, amount: Assets::Balance) -> XcmResult {
let checking_account = CheckingAccount::get();
Assets::can_withdraw(asset_id, &checking_account, amount)
.into_result()
.into_result(false)
.map_err(|_| XcmError::NotWithdrawable)
.map(|_| ())
}
@@ -171,7 +176,7 @@ impl<
}
fn reduce_checked(asset_id: Assets::AssetId, amount: Assets::Balance) {
let checking_account = CheckingAccount::get();
let ok = Assets::burn_from(asset_id, &checking_account, amount).is_ok();
let ok = Assets::burn_from(asset_id, &checking_account, amount, Exact, Polite).is_ok();
debug_assert!(ok, "`can_reduce_checked` must have returned `true` immediately prior; qed");
}
}
@@ -280,7 +285,8 @@ impl<
let who = AccountIdConverter::convert_ref(who)
.map_err(|()| MatchError::AccountIdConversionFailed)?;
Assets::mint_into(asset_id, &who, amount)
.map_err(|e| XcmError::FailedToTransactAsset(e.into()))
.map_err(|e| XcmError::FailedToTransactAsset(e.into()))?;
Ok(())
}
fn withdraw_asset(
@@ -297,7 +303,7 @@ impl<
let (asset_id, amount) = Matcher::matches_fungibles(what)?;
let who = AccountIdConverter::convert_ref(who)
.map_err(|()| MatchError::AccountIdConversionFailed)?;
Assets::burn_from(asset_id, &who, amount)
Assets::burn_from(asset_id, &who, amount, Exact, Polite)
.map_err(|e| XcmError::FailedToTransactAsset(e.into()))?;
Ok(what.clone().into())
}
@@ -312,7 +318,7 @@ pub struct FungiblesAdapter<
CheckingAccount,
>(PhantomData<(Assets, Matcher, AccountIdConverter, AccountId, CheckAsset, CheckingAccount)>);
impl<
Assets: fungibles::Mutate<AccountId> + fungibles::Transfer<AccountId>,
Assets: fungibles::Mutate<AccountId>,
Matcher: MatchesFungibles<Assets::AssetId, Assets::Balance>,
AccountIdConverter: Convert<MultiLocation, AccountId>,
AccountId: Clone, // can't get away without it since Currency is generic over it.
+5 -1
View File
@@ -16,7 +16,7 @@
use frame_support::{
construct_runtime, parameter_types,
traits::{Everything, Nothing},
traits::{ConstU32, Everything, Nothing},
weights::Weight,
};
use parity_scale_codec::Encode;
@@ -116,6 +116,10 @@ impl pallet_balances::Config for Runtime {
type WeightInfo = ();
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
}
impl shared::Config for Runtime {}
@@ -22,7 +22,7 @@ use frame_support::{
traits::{EnsureOrigin, EnsureOriginWithArg, Everything, EverythingBut, Nothing},
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
};
use sp_core::H256;
use sp_core::{ConstU32, H256};
use sp_runtime::{
testing::Header,
traits::{Hash, IdentityLookup},
@@ -85,7 +85,7 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
parameter_types! {
@@ -104,6 +104,10 @@ impl pallet_balances::Config for Runtime {
type WeightInfo = ();
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
}
#[cfg(feature = "runtime-benchmarks")]
@@ -130,9 +134,9 @@ impl pallet_uniques::Config for Runtime {
type MetadataDepositBase = frame_support::traits::ConstU128<1_000>;
type AttributeDepositBase = frame_support::traits::ConstU128<1_000>;
type DepositPerByte = frame_support::traits::ConstU128<1>;
type StringLimit = frame_support::traits::ConstU32<64>;
type KeyLimit = frame_support::traits::ConstU32<64>;
type ValueLimit = frame_support::traits::ConstU32<128>;
type StringLimit = ConstU32<64>;
type KeyLimit = ConstU32<64>;
type ValueLimit = ConstU32<128>;
type Locker = ();
type WeightInfo = ();
#[cfg(feature = "runtime-benchmarks")]
@@ -416,7 +420,7 @@ impl pallet_xcm::Config for Runtime {
type CurrencyMatcher = ();
type TrustedLockers = ();
type SovereignAccountOf = LocationToAccountId;
type MaxLockers = frame_support::traits::ConstU32<8>;
type MaxLockers = ConstU32<8>;
type WeightInfo = pallet_xcm::TestWeightInfo;
#[cfg(feature = "runtime-benchmarks")]
type ReachableDest = ReachableDest;
@@ -21,7 +21,7 @@ use frame_support::{
traits::{AsEnsureOriginWithArg, Everything, Nothing},
weights::Weight,
};
use sp_core::H256;
use sp_core::{ConstU32, H256};
use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32};
use polkadot_parachain::primitives::Id as ParaId;
@@ -67,7 +67,7 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
parameter_types! {
@@ -86,6 +86,10 @@ impl pallet_balances::Config for Runtime {
type WeightInfo = ();
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
}
impl pallet_uniques::Config for Runtime {
@@ -100,9 +104,9 @@ impl pallet_uniques::Config for Runtime {
type MetadataDepositBase = frame_support::traits::ConstU128<1_000>;
type AttributeDepositBase = frame_support::traits::ConstU128<1_000>;
type DepositPerByte = frame_support::traits::ConstU128<1>;
type StringLimit = frame_support::traits::ConstU32<64>;
type KeyLimit = frame_support::traits::ConstU32<64>;
type ValueLimit = frame_support::traits::ConstU32<128>;
type StringLimit = ConstU32<64>;
type KeyLimit = ConstU32<64>;
type ValueLimit = ConstU32<128>;
type Locker = ();
type WeightInfo = ();
#[cfg(feature = "runtime-benchmarks")]
@@ -213,7 +217,7 @@ impl pallet_xcm::Config for Runtime {
type CurrencyMatcher = IsConcrete<TokenLocation>;
type TrustedLockers = ();
type SovereignAccountOf = LocationToAccountId;
type MaxLockers = frame_support::traits::ConstU32<8>;
type MaxLockers = ConstU32<8>;
type WeightInfo = pallet_xcm::TestWeightInfo;
#[cfg(feature = "runtime-benchmarks")]
type ReachableDest = ReachableDest;
@@ -22,7 +22,7 @@ use frame_support::{
traits::{Everything, Nothing},
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
};
use sp_core::H256;
use sp_core::{ConstU32, H256};
use sp_runtime::{
testing::Header,
traits::{Hash, IdentityLookup},
@@ -94,6 +94,10 @@ impl pallet_balances::Config for Runtime {
type WeightInfo = ();
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
}
parameter_types! {
@@ -21,7 +21,7 @@ use frame_support::{
traits::{Everything, Nothing},
weights::Weight,
};
use sp_core::H256;
use sp_core::{ConstU32, H256};
use sp_runtime::{testing::Header, traits::IdentityLookup, AccountId32};
use polkadot_parachain::primitives::Id as ParaId;
@@ -66,7 +66,7 @@ impl frame_system::Config for Runtime {
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
type MaxConsumers = ConstU32<16>;
}
parameter_types! {
@@ -85,6 +85,10 @@ impl pallet_balances::Config for Runtime {
type WeightInfo = ();
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type HoldIdentifier = ();
type FreezeIdentifier = ();
type MaxHolds = ConstU32<0>;
type MaxFreezes = ConstU32<0>;
}
impl shared::Config for Runtime {}
@@ -177,7 +181,7 @@ impl pallet_xcm::Config for Runtime {
type CurrencyMatcher = ();
type TrustedLockers = ();
type SovereignAccountOf = SovereignAccountOf;
type MaxLockers = frame_support::traits::ConstU32<8>;
type MaxLockers = ConstU32<8>;
type WeightInfo = pallet_xcm::TestWeightInfo;
#[cfg(feature = "runtime-benchmarks")]
type ReachableDest = ReachableDest;