7

I have an unsigned call in my pallet. Since there will be no fees associated, should I include a weight for it?

Example:

#[pallet::weight(???)]
pub fn submit_metric_unsigned(
    origin: OriginFor<T>,
    _block_number: T::BlockNumber,
    metric: u32,
)

2 Answers 2

4

Yes. Weight is used not only for calculating how much the sender should pay, it is also a measure of how much work can be done. There is also a limit of how much work can be done within a block which should not be exceeded.

If you leave the extrinsic without weight, then the time taken to process it will not be accounted. Too much or unbounded amount of unaccounted processing time can enable DoS vectors.

2
  • Would adding a weight prevent multiple of these extrinsics to fill up the block sequentially and not allow any room for other extrinsics?
    – Bruno
    Feb 23, 2022 at 22:02
  • Yes, setting weight to non-zero would prevent filling up the block with those transactions.
    – pepyakin
    Feb 23, 2022 at 22:04
3

Yes you need to assign a weight for this call. The purpose of weights is not to calculate the fees.

Weights are there to ensure that your block is staying in the expected limits. Otherwise someone could DoS your chain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.