In my benchmarks, I've written multiple benchmarks for an extrinsic to cover different scenarios, which gave me WeightIinfo for each of my benchmarks.
Now the question here is how I can pick the worst scenario for my extrinsic dynamically?
Substrate and Polkadot Stack Exchange is a question and answer site for developers building blockchains with the Substrate SDK. It only takes a minute to sign up.Sign up to join this community
#[pallet::weight(…)] annotation allows you to do some light compile-time computations.
This makes it possible to calculate a maximum like this:
One example of this can be found in the bags-list pallet.
It is important to only do very lightweight calculations here, since the terms are evaluated to judge whether or not an extrinsic should be able to execute.
I think the most complicated weight terms are in the utility pallet.