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

Commit

Permalink
use safe math (#3249)
Browse files Browse the repository at this point in the history
  • Loading branch information
shawntabrizi authored and s3krit committed Jun 17, 2021
1 parent 91aa501 commit ea7f0d1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions xcm/xcm-builder/src/weight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ impl<T: Get<Weight>, C: Decode + GetDispatchInfo> WeightBounds<C> for FixedWeigh
fn shallow(message: &mut Xcm<C>) -> Result<Weight, ()> {
Ok(match message {
Xcm::Transact { call, .. } => {
call.ensure_decoded()?.get_dispatch_info().weight + T::get()
call.ensure_decoded()?.get_dispatch_info().weight.saturating_add(T::get())
}
Xcm::RelayedFrom { ref mut message, .. } => T::get() + Self::shallow(message.as_mut())?,
Xcm::RelayedFrom { ref mut message, .. } => T::get().saturating_add(Self::shallow(message.as_mut())?),
Xcm::WithdrawAsset { effects, .. }
| Xcm::ReserveAssetDeposit { effects, .. }
| Xcm::TeleportAsset { effects, .. }
Expand All @@ -46,7 +46,7 @@ impl<T: Get<Weight>, C: Decode + GetDispatchInfo> WeightBounds<C> for FixedWeigh
},
_ => T::get(),
}).sum();
T::get() + inner
T::get().saturating_add(inner)
}
_ => T::get(),
})
Expand All @@ -63,7 +63,7 @@ impl<T: Get<Weight>, C: Decode + GetDispatchInfo> WeightBounds<C> for FixedWeigh
match effect {
Order::BuyExecution { xcm, .. } => {
for message in xcm.iter_mut() {
extra += Self::shallow(message)? + Self::deep(message)?;
extra.saturating_accrue(Self::shallow(message)?.saturating_add(Self::deep(message)?));
}
},
_ => {}
Expand Down

0 comments on commit ea7f0d1

Please sign in to comment.