Skip to content

Commit 26be072

Browse files
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 <[email protected]>
1 parent e0a2c78 commit 26be072

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

polkadot/xcm/xcm-builder/src/barriers.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ impl ShouldExecute for TakeWeightCredit {
5252
}
5353
}
5454

55+
const MAX_ASSETS_FOR_BUY_EXECUTION: usize = 1;
56+
5557
/// Allows execution from `origin` if it is contained in `T` (i.e. `T::Contains(origin)`) taking
5658
/// payments into account.
5759
///
@@ -79,10 +81,10 @@ impl<T: Contains<MultiLocation>> ShouldExecute for AllowTopLevelPaidExecutionFro
7981
instructions[..end]
8082
.matcher()
8183
.match_next_inst(|inst| match inst {
82-
ReceiveTeleportedAsset(..) |
83-
WithdrawAsset(..) |
84-
ReserveAssetDeposited(..) |
85-
ClaimAsset { .. } => Ok(()),
84+
ReceiveTeleportedAsset(..) | ReserveAssetDeposited(..) => Ok(()),
85+
WithdrawAsset(ref assets) if assets.len() <= MAX_ASSETS_FOR_BUY_EXECUTION => Ok(()),
86+
ClaimAsset { ref assets, .. } if assets.len() <= MAX_ASSETS_FOR_BUY_EXECUTION =>
87+
Ok(()),
8688
_ => Err(ProcessMessageError::BadFormat),
8789
})?
8890
.skip_inst_while(|inst| matches!(inst, ClearOrigin))?

0 commit comments

Comments
 (0)