Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions xcm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ edition = "2018"
impl-trait-for-tuples = "0.2.0"
parity-scale-codec = { version = "2.0.0", default-features = false, features = [ "derive" ] }
derivative = {version = "2.2.0", default-features = false, features = [ "use_core" ] }
log = { version = "0.4.14", default-features = false }

[features]
default = ["std"]
Expand Down
1 change: 1 addition & 0 deletions xcm/pallet-xcm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ version = "0.1.0"
[dependencies]
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.101", optional = true, features = ["derive"] }
log = { version = "0.4.14", default-features = false }

sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
Expand Down
1 change: 1 addition & 0 deletions xcm/pallet-xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ pub mod pallet {
MultiLocation::Null => message,
who => Xcm::<()>::RelayedFrom { who, message: Box::new(message) },
};
log::trace!(target: "xcm::send_xcm", "dest: {:?}, message: {:?}", &dest, &message);
T::XcmRouter::send_xcm(dest, message)
}

Expand Down
7 changes: 7 additions & 0 deletions xcm/src/v0/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ pub trait ExecuteXcm<Call> {
/// a basic hard-limit and the implementation may place further restrictions or requirements on weight and
/// other aspects.
fn execute_xcm(origin: MultiLocation, message: Xcm<Call>, weight_limit: Weight) -> Outcome {
log::debug!(
target: "xcm::execute_xcm",
"origin: {:?}, message: {:?}, weight_limit: {:?}",
origin,
message,
weight_limit,
);
Self::execute_xcm_in_credit(origin, message, weight_limit, 0)
}

Expand Down
27 changes: 26 additions & 1 deletion xcm/xcm-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ impl<Config: config::Config> ExecuteXcm<Config::Call> for XcmExecutor<Config> {
weight_limit: Weight,
mut weight_credit: Weight,
) -> Outcome {
log::trace!(
target: "xcm::execute_xcm_in_credit",
"origin: {:?}, message: {:?}, weight_limit: {:?}, weight_credit: {:?}",
origin,
message,
weight_limit,
weight_credit,
);
// TODO: #2841 #HARDENXCM We should identify recursive bombs here and bail.
let mut message = Xcm::<Config::Call>::from(message);
let shallow_weight = match Config::Weigher::shallow(&mut message) {
Expand All @@ -67,6 +75,7 @@ impl<Config: config::Config> ExecuteXcm<Config::Call> for XcmExecutor<Config> {
let mut trader = Config::Trader::new();
let result = Self::do_execute_xcm(origin, true, message, &mut weight_credit, Some(shallow_weight), &mut trader);
drop(trader);
log::trace!(target: "xcm::execute_xcm", "result: {:?}", &result);
match result {
Ok(surplus) => Outcome::Complete(maximum_weight.saturating_sub(surplus)),
// TODO: #2841 #REALWEIGHT We can do better than returning `maximum_weight` here, and we should otherwise
Expand Down Expand Up @@ -94,6 +103,15 @@ impl<Config: config::Config> XcmExecutor<Config> {
maybe_shallow_weight: Option<Weight>,
trader: &mut Config::Trader,
) -> Result<Weight, XcmError> {
log::trace!(
target: "xcm::do_execute_xcm",
"origin: {:?}, top_level: {:?}, message: {:?}, weight_credit: {:?}, maybe_shallow_weight: {:?}",
origin,
top_level,
message,
weight_credit,
maybe_shallow_weight,
);
// This is the weight of everything that cannot be paid for. This basically means all computation
// except any XCM which is behind an Order::BuyExecution.
let shallow_weight = maybe_shallow_weight
Expand Down Expand Up @@ -165,7 +183,7 @@ impl<Config: config::Config> XcmExecutor<Config> {
}
Some((Assets::from(assets), effects))
}
(origin, Xcm::Transact { origin_type, require_weight_at_most, mut call }) => {
(origin, Xcm::Transact { origin_type, require_weight_at_most, mut call }) => {
// We assume that the Relay-chain is allowed to use transact on this parachain.

// TODO: #2841 #TRANSACTFILTER allow the trait to issue filters for the relay-chain
Expand Down Expand Up @@ -225,6 +243,13 @@ impl<Config: config::Config> XcmExecutor<Config> {
effect: Order<Config::Call>,
trader: &mut Config::Trader,
) -> Result<Weight, XcmError> {
log::trace!(
target: "xcm::execute_effects",
"origin: {:?}, holding: {:?}, effect: {:?}",
origin,
holding,
effect,
);
let mut total_surplus = 0;
match effect {
Order::DepositAsset { assets, dest } => {
Expand Down
6 changes: 6 additions & 0 deletions xcm/xcm-executor/src/traits/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ impl<O> ConvertOrigin<O> for Tuple {
r => return r
};
)* );
log::trace!(
target: "xcm::convert_origin",
"could not convert: origin: {:?}, kind: {:?}",
origin,
kind,
);
Err(origin)
}
}
Expand Down
6 changes: 6 additions & 0 deletions xcm/xcm-executor/src/traits/filter_asset_location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ impl FilterAssetLocation for Tuple {
for_tuples!( #(
if Tuple::filter_asset_location(what, origin) { return true }
)* );
log::trace!(
target: "xcm::filter_asset_location",
"got filtered: what: {:?}, origin: {:?}",
what,
origin,
);
false
}
}
1 change: 1 addition & 0 deletions xcm/xcm-executor/src/traits/matches_fungible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ impl<Balance> MatchesFungible<Balance> for Tuple {
for_tuples!( #(
match Tuple::matches_fungible(a) { o @ Some(_) => return o, _ => () }
)* );
log::trace!(target: "xcm::matches_fungible", "did not match fungible asset: {:?}", &a);
None
}
}
1 change: 1 addition & 0 deletions xcm/xcm-executor/src/traits/matches_fungibles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl<
for_tuples!( #(
match Tuple::matches_fungibles(a) { o @ Ok(_) => return o, _ => () }
)* );
log::trace!(target: "xcm::matches_fungibles", "did not match fungibles asset: {:?}", &a);
Err(Error::AssetNotFound)
}
}
9 changes: 9 additions & 0 deletions xcm/xcm-executor/src/traits/should_execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ impl ShouldExecute for Tuple {
_ => (),
}
)* );
log::trace!(
target: "xcm::should_execute",
"did not pass barrier: origin: {:?}, top_level: {:?}, message: {:?}, shallow_weight: {:?}, weight_credit: {:?}",
origin,
top_level,
message,
shallow_weight,
weight_credit,
);
Err(())
}
}
30 changes: 30 additions & 0 deletions xcm/xcm-executor/src/traits/transact_asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,34 +107,64 @@ impl TransactAsset for Tuple {
r => return r,
}
)* );
log::trace!(
target: "xcm::TransactAsset::can_check_in",
"asset not found: what: {:?}, origin: {:?}",
what,
origin,
);
Err(XcmError::AssetNotFound)
}

fn check_in(origin: &MultiLocation, what: &MultiAsset) {
for_tuples!( #(
Tuple::check_in(origin, what);
)* );
}

fn check_out(dest: &MultiLocation, what: &MultiAsset) {
for_tuples!( #(
Tuple::check_out(dest, what);
)* );
}

fn deposit_asset(what: &MultiAsset, who: &MultiLocation) -> XcmResult {
for_tuples!( #(
match Tuple::deposit_asset(what, who) { o @ Ok(_) => return o, _ => () }
)* );
log::trace!(
target: "xcm::TransactAsset::deposit_asset",
"did not deposit asset: what: {:?}, who: {:?}",
what,
who,
);
Err(XcmError::Unimplemented)
}

fn withdraw_asset(what: &MultiAsset, who: &MultiLocation) -> Result<Assets, XcmError> {
for_tuples!( #(
match Tuple::withdraw_asset(what, who) { o @ Ok(_) => return o, _ => () }
)* );
log::trace!(
target: "xcm::TransactAsset::withdraw_asset",
"did not withdraw asset: what: {:?}, who: {:?}",
what,
who,
);
Err(XcmError::Unimplemented)
}

fn transfer_asset(what: &MultiAsset, from: &MultiLocation, to: &MultiLocation) -> Result<Assets, XcmError> {
for_tuples!( #(
match Tuple::transfer_asset(what, from, to) { o @ Ok(_) => return o, _ => () }
)* );
log::trace!(
target: "xcm::TransactAsset::transfer_asset",
"did not transfer asset: what: {:?}, from: {:?}, to: {:?}",
what,
from,
to,
);
Err(XcmError::Unimplemented)
}
}