Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Bound number of assets which can be withdrawn to pay for execution. #7641

Merged
merged 4 commits into from
Aug 22, 2023
Merged
Changes from 3 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
9 changes: 5 additions & 4 deletions xcm/xcm-builder/src/barriers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,18 @@ impl<T: Contains<MultiLocation>> ShouldExecute for AllowTopLevelPaidExecutionFro
);

ensure!(T::contains(origin), ProcessMessageError::Unsupported);
let max_assets_for_buy_execution = 1;
franciscoaguirre marked this conversation as resolved.
Show resolved Hide resolved
// We will read up to 5 instructions. This allows up to 3 `ClearOrigin` instructions. We
// allow for more than one since anything beyond the first is a no-op and it's conceivable
// that composition of operations might result in more than one being appended.
let end = instructions.len().min(5);
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))?
Expand Down