This repository has been archived by the owner on May 21, 2024. It is now read-only.
[0.9.40] Weights v2 - Include WeightToFee on XCM Trader #168
Labels
discussion
Discussions about design/implementations/etc.
Milestone
At the moment the XCM Trader configuration at Trappist looks like this:
The
UsingComponents
trait looks all right and it shouldn't bring any incompatibilities when we migrate to XCM v3/Weights v2.But i would like to point out the impl
FixedRateOfFungible<XUsdPerSecond, ()>
, specially theXUsdPerSecond
.Let's take a look at how FixedRateOfFungible is defined:
in the
buy_weight
function, this is calculation what makes the charges the fee specifically:But if we come back as how XUsdPerSecond is defined, we can get the following:
We can see the following definition for default_fee_per_second() :
The problem we have with this logic is that
ExtrinsicBaseWeight
is hardcoded to return0
for the proof_size:So we could just solve this by simply adding
0
to the XUsdPerSecond and leave the default impl ofFixedRateOfFungible
to calculate the fee in base of the formula shared above.Or we could follow Statemine guidelines, where they are using the
TakeFirstAssetTrader
instead ofFixedRateOfFungible
.I will not share all the steps to get into the fee translation formula, but the
TakeFirstAssetTrader
ends up calculating the amount of the fee with this line:Where
FeeCharger::charge_weight_in_fungibles(local_asset_id, weight)
is theWeightToFee::weight_to_fee
from theWeightsToFee
implementation:This new
WeightToFee
struct for weights V2 is basically taking the maximum instead of the sum to charge by the more scarce resource, as the comment mentions.All the development to this new struct on Statemine can be followed here:
paritytech/cumulus#2322
paritytech/substrate#13612
paritytech/cumulus#2326
Also @kalaninja this PR might be interesting for you since you are working with benchmarking atm: paritytech/cumulus#2344
So after all the explanation we have one decision to make:
Should we keep the
FixedRateOfFungible
and we provide0
for the proof_size for simplicity sake or should we follow Statemine and rely on the newWeightToFee
struct that takes the MAX of both values? My vote goes for the second option.Then i think that we should adapt the new
WeightToFee
as it is defined in here:https://github.com/paritytech/cumulus/blob/master/parachains/runtimes/assets/statemine/src/constants.rs#L57
CC: @stiiifff @valentinfernandez1 @kalaninja
The text was updated successfully, but these errors were encountered: