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

Commit

Permalink
Remove BuyExecution::orders (#3640)
Browse files Browse the repository at this point in the history
* Remove BuyExecution::orders

* Fixes

* Fixes

* Fixes

* Formatting
  • Loading branch information
gavofyork authored and chevdor committed Sep 13, 2021
1 parent 11bcd5e commit e3bf763
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 43 deletions.
2 changes: 0 additions & 2 deletions xcm/pallet-xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ pub mod pallet {
weight: 0,
debt: dest_weight,
halt_on_error: false,
orders: vec![],
instructions: vec![],
},
DepositAsset { assets: Wild(All), max_assets, beneficiary },
Expand Down Expand Up @@ -255,7 +254,6 @@ pub mod pallet {
weight: 0,
debt: dest_weight, // covers this, `TransferReserveAsset` xcm, and `DepositAsset` order.
halt_on_error: false,
orders: vec![],
instructions: vec![],
},
DepositAsset { assets: Wild(All), max_assets, beneficiary },
Expand Down
1 change: 0 additions & 1 deletion xcm/pallet-xcm/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ pub(crate) fn buy_execution<C>(fees: impl Into<MultiAsset>, debt: Weight) -> Ord
weight: 0,
debt,
halt_on_error: false,
orders: vec![],
instructions: vec![],
}
}
Expand Down
5 changes: 1 addition & 4 deletions xcm/src/v0/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,7 @@ impl<Call> TryFrom<Order1<Call>> for Order<Call> {
},
Order1::QueryHolding { query_id, dest, assets } =>
QueryHolding { query_id, dest: dest.try_into()?, assets: assets.try_into()? },
Order1::BuyExecution { fees, weight, debt, halt_on_error, orders, instructions } => {
if !orders.is_empty() {
return Err(())
}
Order1::BuyExecution { fees, weight, debt, halt_on_error, instructions } => {
let xcm = instructions
.into_iter()
.map(Xcm::<Call>::try_from)
Expand Down
19 changes: 4 additions & 15 deletions xcm/src/v1/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use super::{
super::v0::Order as Order0, MultiAsset, MultiAssetFilter, MultiAssets, MultiLocation, Xcm,
};
use alloc::{vec, vec::Vec};
use alloc::vec::Vec;
use core::{
convert::{TryFrom, TryInto},
result,
Expand Down Expand Up @@ -140,8 +140,6 @@ pub enum Order<Call> {
/// any surrounding operations/orders.
/// - `halt_on_error`: If `true`, the execution of the `orders` and `operations` will halt on the first failure. If
/// `false`, then execution will continue regardless.
/// - `orders`: Orders to be executed with the existing Holding Register; execution of these orders happens PRIOR to
/// execution of the `operations`. The (shallow) weight for these must be paid for with the `weight` purchased.
/// - `instructions`: XCM instructions to be executed outside of the context of the current Holding Register;
/// execution of these instructions happens AFTER the execution of the `orders`. The (shallow) weight for these
/// must be paid for with the `weight` purchased.
Expand All @@ -152,7 +150,6 @@ pub enum Order<Call> {
weight: u64,
debt: u64,
halt_on_error: bool,
orders: Vec<Order<Call>>,
instructions: Vec<Xcm<Call>>,
},
}
Expand All @@ -179,10 +176,9 @@ impl<Call> Order<Call> {
InitiateTeleport { assets, dest, effects } =>
InitiateTeleport { assets, dest, effects },
QueryHolding { query_id, dest, assets } => QueryHolding { query_id, dest, assets },
BuyExecution { fees, weight, debt, halt_on_error, orders, instructions } => {
let orders = orders.into_iter().map(Order::from).collect();
BuyExecution { fees, weight, debt, halt_on_error, instructions } => {
let instructions = instructions.into_iter().map(Xcm::from).collect();
BuyExecution { fees, weight, debt, halt_on_error, orders, instructions }
BuyExecution { fees, weight, debt, halt_on_error, instructions }
},
}
}
Expand Down Expand Up @@ -232,14 +228,7 @@ impl<Call> TryFrom<Order0<Call>> for Order<Call> {
Order0::BuyExecution { fees, weight, debt, halt_on_error, xcm } => {
let instructions =
xcm.into_iter().map(Xcm::<Call>::try_from).collect::<result::Result<_, _>>()?;
BuyExecution {
fees: fees.try_into()?,
weight,
debt,
halt_on_error,
orders: vec![],
instructions,
}
BuyExecution { fees: fees.try_into()?, weight, debt, halt_on_error, instructions }
},
})
}
Expand Down
5 changes: 0 additions & 5 deletions xcm/xcm-builder/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ fn weigher_should_work() {
weight: 0,
debt: 30,
halt_on_error: true,
orders: vec![],
instructions: vec![],
},
Order::DepositAsset { assets: All.into(), max_assets: 1, beneficiary: Here.into() },
Expand Down Expand Up @@ -139,7 +138,6 @@ fn allow_paid_should_work() {
weight: 0,
debt: 20,
halt_on_error: true,
orders: vec![],
instructions: vec![],
},
Order::DepositAsset { assets: All.into(), max_assets: 1, beneficiary: Here.into() },
Expand All @@ -164,7 +162,6 @@ fn allow_paid_should_work() {
weight: 0,
debt: 30,
halt_on_error: true,
orders: vec![],
instructions: vec![],
},
Order::DepositAsset { assets: All.into(), max_assets: 1, beneficiary: Here.into() },
Expand Down Expand Up @@ -206,7 +203,6 @@ fn paying_reserve_deposit_should_work() {
weight: 0,
debt: 30,
halt_on_error: true,
orders: vec![],
instructions: vec![],
},
Order::<TestCall>::DepositAsset {
Expand Down Expand Up @@ -347,7 +343,6 @@ fn paid_transacting_should_refund_payment_for_unused_weight() {
weight: 70,
debt: 30,
halt_on_error: true,
orders: vec![],
instructions: vec![Xcm::<TestCall>::Transact {
origin_type: OriginKind::Native,
require_weight_at_most: 60,
Expand Down
7 changes: 1 addition & 6 deletions xcm/xcm-builder/src/weight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,13 @@ impl<T: Get<Weight>, C: Decode + GetDispatchInfo> FixedWeightBounds<T, C> {
}
fn deep_order(order: &mut Order<C>) -> Result<Weight, ()> {
Ok(match order {
Order::BuyExecution { orders, instructions, .. } => {
Order::BuyExecution { instructions, .. } => {
let mut extra = 0;
for instruction in instructions.iter_mut() {
extra.saturating_accrue(
Self::shallow(instruction)?.saturating_add(Self::deep(instruction)?),
);
}
for order in orders.iter_mut() {
extra.saturating_accrue(
Self::shallow_order(order)?.saturating_add(Self::deep_order(order)?),
);
}
extra
},
_ => 0,
Expand Down
2 changes: 0 additions & 2 deletions xcm/xcm-executor/integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ fn execute_within_recursion_limit() {
weight: 0,
debt: 0,
halt_on_error: true,
orders: vec![],
// nest `msg` into itself on each iteration.
instructions: vec![msg],
}],
Expand Down Expand Up @@ -101,7 +100,6 @@ fn exceed_recursion_limit() {
weight: 0,
debt: 0,
halt_on_error: true,
orders: vec![],
// nest `msg` into itself on each iteration.
instructions: vec![msg],
}],
Expand Down
9 changes: 1 addition & 8 deletions xcm/xcm-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ impl<Config: config::Config> XcmExecutor<Config> {
Xcm::QueryResponse { query_id, response: Response::Assets(assets) },
)?;
},
Order::BuyExecution { fees, weight, debt, halt_on_error, orders, instructions } => {
Order::BuyExecution { fees, weight, debt, halt_on_error, instructions } => {
// pay for `weight` using up to `fees` of the holding register.
let purchasing_weight =
Weight::from(weight.checked_add(debt).ok_or(XcmError::Overflow)?);
Expand All @@ -342,13 +342,6 @@ impl<Config: config::Config> XcmExecutor<Config> {
holding.subsume_assets(unspent);

let mut remaining_weight = weight;
for order in orders.into_iter() {
match Self::execute_orders(origin, holding, order, trader, num_recursions + 1) {
Err(e) if halt_on_error => return Err(e),
Err(_) => {},
Ok(surplus) => total_surplus += surplus,
}
}
for instruction in instructions.into_iter() {
match Self::do_execute_xcm(
origin.clone(),
Expand Down

0 comments on commit e3bf763

Please sign in to comment.