Skip to content

Commit

Permalink
added logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayevbeosa Iyamu committed Dec 24, 2024
1 parent 7b32c89 commit 2101bc1
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 12 deletions.
5 changes: 4 additions & 1 deletion polkadot/xcm/xcm-builder/src/fungibles_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ impl<
let dest = AccountIdConverter::convert_location(to)
.ok_or(MatchError::AccountIdConversionFailed)?;
Assets::transfer(asset_id, &source, &dest, amount, Preserve)
.map_err(|e| XcmError::FailedToTransactAsset(e.into()))?;
.map_err(|e| {
tracing::error!(target: "xcm::fungibles_adapter", ?e, ?amount, "Failed to transfer asset internally");
XcmError::FailedToTransactAsset(e.into())
})?;
Ok(what.clone().into())
}
}
Expand Down
15 changes: 12 additions & 3 deletions polkadot/xcm/xcm-builder/src/nonfungible_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ impl<
let destination = AccountIdConverter::convert_location(to)
.ok_or(MatchError::AccountIdConversionFailed)?;
NonFungible::transfer(&instance, &destination)
.map_err(|e| XcmError::FailedToTransactAsset(e.into()))?;
.map_err(|e| {
tracing::error!(target: LOG_TARGET, ?e, "Failed to transfer asset");
XcmError::FailedToTransactAsset(e.into())
})?;
Ok(what.clone().into())
}
}
Expand Down Expand Up @@ -209,7 +212,10 @@ impl<
let who = AccountIdConverter::convert_location(who)
.ok_or(MatchError::AccountIdConversionFailed)?;
NonFungible::mint_into(&instance, &who)
.map_err(|e| XcmError::FailedToTransactAsset(e.into()))
.map_err(|e| {
tracing::error!(target: LOG_TARGET, ?e, "Failed to mint asset");
XcmError::FailedToTransactAsset(e.into())
})
}

fn withdraw_asset(
Expand All @@ -229,7 +235,10 @@ impl<
.ok_or(MatchError::AccountIdConversionFailed)?;
let instance = Matcher::matches_nonfungible(what).ok_or(MatchError::AssetNotHandled)?;
NonFungible::burn(&instance, Some(&who))
.map_err(|e| XcmError::FailedToTransactAsset(e.into()))?;
.map_err(|e| {
tracing::error!(target: LOG_TARGET, ?e, "Failed to withdraw asset");
XcmError::FailedToTransactAsset(e.into())
})?;
Ok(what.clone().into())
}
}
Expand Down
15 changes: 12 additions & 3 deletions polkadot/xcm/xcm-builder/src/nonfungibles_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ impl<
let destination = AccountIdConverter::convert_location(to)
.ok_or(MatchError::AccountIdConversionFailed)?;
Assets::transfer(&class, &instance, &destination)
.map_err(|e| XcmError::FailedToTransactAsset(e.into()))?;
.map_err(|e| {
tracing::error!(target: LOG_TARGET, ?e, "Failed to transfer asset");
XcmError::FailedToTransactAsset(e.into())
})?;
Ok(what.clone().into())
}
}
Expand Down Expand Up @@ -226,7 +229,10 @@ impl<
let who = AccountIdConverter::convert_location(who)
.ok_or(MatchError::AccountIdConversionFailed)?;
Assets::mint_into(&class, &instance, &who)
.map_err(|e| XcmError::FailedToTransactAsset(e.into()))
.map_err(|e| {
tracing::error!(target: LOG_TARGET, ?e, "Failed to mint asset");
XcmError::FailedToTransactAsset(e.into())
})
}

fn withdraw_asset(
Expand All @@ -246,7 +252,10 @@ impl<
.ok_or(MatchError::AccountIdConversionFailed)?;
let (class, instance) = Matcher::matches_nonfungibles(what)?;
Assets::burn(&class, &instance, Some(&who))
.map_err(|e| XcmError::FailedToTransactAsset(e.into()))?;
.map_err(|e| {
tracing::error!(target: LOG_TARGET, ?e, "Failed to burn asset");
XcmError::FailedToTransactAsset(e.into())
})?;
Ok(what.clone().into())
}
}
Expand Down
3 changes: 2 additions & 1 deletion polkadot/xcm/xcm-builder/src/process_xcm_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ impl<
let versioned_message = VersionedXcm::<Call>::decode(&mut &message[..]).map_err(|e| {
tracing::trace!(
target: LOG_TARGET,
"`VersionedXcm` failed to decode: {e:?}",
"`VersionedXcm` failed to decode: {:?}",
e
);

ProcessMessageError::Corrupt
Expand Down
5 changes: 4 additions & 1 deletion polkadot/xcm/xcm-builder/src/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ impl<Inner: SendXcm, TopicSource: SourceTopic> SendXcm for WithTopicSource<Inner
unique_id
};
let (ticket, assets) = Inner::validate(destination, &mut Some(message))
.map_err(|_| SendError::NotApplicable)?;
.map_err(|e| {
tracing::error!(target: "xcm::validate", ?e, "Failed to validate with error");
SendError::NotApplicable
})?;
Ok(((ticket, unique_id), assets))
}

Expand Down
15 changes: 12 additions & 3 deletions polkadot/xcm/xcm-builder/src/weight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ impl<T: Get<(AssetId, u128, u128)>, R: TakeRevenue> WeightTrader for FixedRateOf
return Ok(payment)
}
let unused =
payment.checked_sub((id, amount).into()).map_err(|_| XcmError::TooExpensive)?;
payment.checked_sub((id, amount).into()).map_err(|error| {
tracing::error!(target: "xcm::weight", ?error, "Failed to substract from payment");
XcmError::TooExpensive
})?;
self.0 = self.0.saturating_add(weight);
self.1 = self.1.saturating_add(amount);
Ok(unused)
Expand Down Expand Up @@ -231,9 +234,15 @@ impl<
) -> Result<AssetsInHolding, XcmError> {
tracing::trace!(target: "xcm::weight", "UsingComponents::buy_weight weight: {:?}, payment: {:?}, context: {:?}", weight, payment, context);
let amount = WeightToFee::weight_to_fee(&weight);
let u128_amount: u128 = amount.try_into().map_err(|_| XcmError::Overflow)?;
let u128_amount: u128 = amount.try_into().map_err(|error| {
tracing::error!(target: "xcm::weight", "Amount could not be converted");
XcmError::Overflow
})?;
let required = Asset { id: AssetId(AssetIdValue::get()), fun: Fungible(u128_amount) };
let unused = payment.checked_sub(required).map_err(|_| XcmError::TooExpensive)?;
let unused = payment.checked_sub(required).map_err(|error| {
tracing::error!(target: "xcm::weight", ?error, "Failed to substract from payment");
XcmError::TooExpensive
})?;
self.0 = self.0.saturating_add(weight);
self.1 = self.1.saturating_add(amount);
Ok(unused)
Expand Down

0 comments on commit 2101bc1

Please sign in to comment.