2

We have changed the decimal places of our currency to 10e8 and trying to understand how to adjust the WeightToFeePolynomial. When reading the code I noticed that filling up a block can produce a range in fees and was flabbergasted.

Can you please explain why there is a range of fees for a full block? full_block_fee_correct() test

2 Answers 2

2

My understanding of the test you are referencing is that it is just a sanity check for the fee implied by the value of the constant MAXIMUM_BLOCK_WEIGHT in a Substrate chain. You can see how the range of the test varies depending on the use intended for the chain. This is the range for the test for Polkadot relay chain for example, which is orders of magnitude larger than Rococo or Westend testnets.

Since the value of MAXIMUM_BLOCK_WEIGHT and the definition of the function weightToFee are critical for the correct functioning of a Substrate chain, it makes sense to check that the output of weight_to_fee(&MAXIMUM_BLOCK_WEIGHT) is a "reasonable" value. But this test does not make any implication beyond this sanity check.

2

That test in particular is just a sanity check. We cannot hard-code a specific value since these values change every time we re-run the benchmark for ExtrinsicBaseWeight. You can see it in the comment above:

pub struct WeightToFee;
impl WeightToFeePolynomial for WeightToFee {
    type Balance = Balance;
    fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
        // in Rococo, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT:
        let p = super::currency::CENTS;
        let q = 10 * Balance::from(ExtrinsicBaseWeight::get().ref_time());
        smallvec![WeightToFeeCoefficient {
            degree: 1,
            negative: false,
            coeff_frac: Perbill::from_rational(p % q, q),
            coeff_integer: p / q,
        }]
    }
}

There needs to be some leeway for the production process, since otherwise these tests would fail on every release.

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.