Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion polkadot/xcm/xcm-executor/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ impl AssetsInHolding {
///
/// This uses `unsafe_clone()` on the imbalance accounting trait objects,
/// which may not maintain proper accounting invariants. Only use in tests.
#[cfg(test)]
#[cfg(feature = "std")]
pub fn unsafe_clone_for_tests(&self) -> Self {
Self {
fungible: self
Expand Down
11 changes: 11 additions & 0 deletions prdoc/pr_11750.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
title: Post 2603 cleanup
doc:
- audience: Runtime Dev
description: |-
- **make clone of AssetsInHolding available for std**
- **Make pallet assets try-state check more lenient**
crates:
- name: staging-xcm-executor
bump: minor
- name: pallet-assets
bump: patch
28 changes: 20 additions & 8 deletions substrate/frame/assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1993,14 +1993,20 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
calculated_sufficients += 1;
}

if account.balance < details.min_balance {
ensure!(
matches!(
let total_balance = account.balance.saturating_add(held);
if total_balance < details.min_balance {
if !matches!(
account.reason,
ExistenceReason::DepositHeld(_) | ExistenceReason::DepositFrom(_, _)
) {
log::warn!(
"Account {who:?} for asset {asset_id:?} has total balance below min_balance but no deposit. Balance: {:?}, Held: {:?}, Min balance: {:?}, Reason: {:?}",
account.balance,
held,
details.min_balance,
account.reason,
ExistenceReason::DepositHeld(_) | ExistenceReason::DepositFrom(_, _)
),
"Account below min_balance must have a deposit"
);
);
}
}
}

Expand All @@ -2010,7 +2016,13 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
// contain overcounted supply from prior refunds.
// TODO: add a migration to recalculate supply, then tighten this to `==`.
ensure!(details.supply >= calculated_supply, "Asset supply mismatch");
ensure!(details.accounts == calculated_accounts, "Asset account count mismatch");
if details.accounts == calculated_accounts {
// Legacy error in Kusama Asset Hub that needs to be cleaned up.
log::error!(
"Asset {asset_id:?} account count mismatch: calculated {calculated_accounts} vs expected {}",
details.accounts,
);
}
ensure!(
details.sufficients == calculated_sufficients,
"Asset sufficients count mismatch"
Expand Down
Loading