Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xtokens weights #907

Open
sander2 opened this issue Apr 26, 2023 · 1 comment
Open

xtokens weights #907

sander2 opened this issue Apr 26, 2023 · 1 comment

Comments

@sander2
Copy link
Contributor

sander2 commented Apr 26, 2023

Xtokens extrinsics weight is determined like this:

#[pallet::weight(XtokensWeight::<T>::weight_of_transfer(currency_id.clone(), *amount, dest))]
pub fn transfer(

Where the weight pretty much boils down to the weight of the equivalent xcm message:

let mut msg = match transfer_kind {
SelfReserveAsset => Xcm(vec![TransferReserveAsset {
assets: vec![asset].into(),
dest,
xcm: Xcm(vec![]),
}]),
ToReserve | ToNonReserve => Xcm(vec![
WithdrawAsset(MultiAssets::from(asset)),
InitiateReserveWithdraw {
assets: All.into(),
// `dest` is always (equal to) `reserve` in both cases
reserve,
xcm: Xcm(vec![]),
},
]),
};
return T::Weigher::weight(&mut msg)
.map_or(Weight::max_value(), |w| T::BaseXcmWeight::get().saturating_add(w));

Wouldn't this underestimate the weight, since it doesn't account for a bunch of logic that constructs the actual message?

@xlc
Copy link
Member

xlc commented Apr 26, 2023

Yeah we need some improvement on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants