Skip to content

Commit

Permalink
Bound number of assets which can be withdrawn to pay for execution. (…
Browse files Browse the repository at this point in the history
…#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 <franciscoaguirreperez@gmail.com>
  • Loading branch information
gavofyork and franciscoaguirre authored Aug 22, 2023
1 parent e0a2c78 commit 26be072
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions polkadot/xcm/xcm-builder/src/barriers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -79,10 +81,10 @@ impl<T: Contains<MultiLocation>> 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))?
Expand Down

0 comments on commit 26be072

Please sign in to comment.