Unverified Commit 5dd368ad authored by Gavin Wood's avatar Gavin Wood Committed by GitHub
Browse files

Remove BuyExecution::orders (#3640)

* Remove BuyExecution::orders

* Fixes

* Fixes

* Fixes

* Formatting
parent ea60e2db
Pipeline #152899 passed with stages
in 40 minutes
......@@ -190,7 +190,6 @@ pub mod pallet {
weight: 0,
debt: dest_weight,
halt_on_error: false,
orders: vec![],
instructions: vec![],
},
DepositAsset { assets: Wild(All), max_assets, beneficiary: *beneficiary },
......@@ -259,7 +258,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: *beneficiary },
......
......@@ -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![],
}
}
......
......@@ -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)
......
......@@ -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,
......@@ -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.
......@@ -152,7 +150,6 @@ pub enum Order<Call> {
weight: u64,
debt: u64,
halt_on_error: bool,
orders: Vec<Order<Call>>,
instructions: Vec<Xcm<Call>>,
},
}
......@@ -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 }
},
}
}
......@@ -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 }
},
})
}
......
......@@ -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() },
......@@ -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() },
......@@ -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() },
......@@ -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 {
......@@ -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,
......
......@@ -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,
......
......@@ -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],
}],
......@@ -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],
}],
......
......@@ -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)?);
......@@ -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(),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment