From 26be0727e5aaa5ed569b29bd9a6b043899a5617b Mon Sep 17 00:00:00 2001 From: Gavin Wood Date: Tue, 22 Aug 2023 13:19:05 +0200 Subject: [PATCH] Bound number of assets which can be withdrawn to pay for execution. (#7641) * Bound number of assets which can be withdrawn to pay for execution. * ".git/.scripts/commands/fmt/fmt.sh" * Include ClaimAsset in limiting the assets * Change max assets to constant --------- Co-authored-by: command-bot <> Co-authored-by: Francisco Aguirre --- polkadot/xcm/xcm-builder/src/barriers.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/polkadot/xcm/xcm-builder/src/barriers.rs b/polkadot/xcm/xcm-builder/src/barriers.rs index 6996c7145528..353e111b813b 100644 --- a/polkadot/xcm/xcm-builder/src/barriers.rs +++ b/polkadot/xcm/xcm-builder/src/barriers.rs @@ -52,6 +52,8 @@ impl ShouldExecute for TakeWeightCredit { } } +const MAX_ASSETS_FOR_BUY_EXECUTION: usize = 1; + /// Allows execution from `origin` if it is contained in `T` (i.e. `T::Contains(origin)`) taking /// payments into account. /// @@ -79,10 +81,10 @@ impl> ShouldExecute for AllowTopLevelPaidExecutionFro instructions[..end] .matcher() .match_next_inst(|inst| match inst { - ReceiveTeleportedAsset(..) | - WithdrawAsset(..) | - ReserveAssetDeposited(..) | - ClaimAsset { .. } => Ok(()), + ReceiveTeleportedAsset(..) | ReserveAssetDeposited(..) => Ok(()), + WithdrawAsset(ref assets) if assets.len() <= MAX_ASSETS_FOR_BUY_EXECUTION => Ok(()), + ClaimAsset { ref assets, .. } if assets.len() <= MAX_ASSETS_FOR_BUY_EXECUTION => + Ok(()), _ => Err(ProcessMessageError::BadFormat), })? .skip_inst_while(|inst| matches!(inst, ClearOrigin))?