Bug: benchmark does not generate WeightInfo
dmoka opened this issue · comments
It appears that when we generate a new benchmark based on our template, the generated file does not include the WeightInfo trait with the associated functions for each benchmark.
This issue can cause problems when adding a new benchmark function and generating its weight. The existing WeightInfo trait will become outdated with the new state.
In the past we had script for generating benchmark for pallets too. A few months ago, we reorganized our files and removed pallet-weight-template-no-back.hbs
, leaving us with only script/pallet-weight-template.hbs
.This template file doesn't contain template code for WeightInfo anymore, namely this:
/// Weight functions needed for {{pallet}}.
pub trait WeightInfo {
{{#each benchmarks as |benchmark|}}
fn {{benchmark.name~}}
(
{{~#each benchmark.components as |c| ~}}
{{c.name}}: u32, {{/each~}}
) -> Weight;
{{/each}}
}
So we should fix this so we can generate weights and regenerate WeightInfo trait in a completely automated fashion.
Possible solution: we could create a new teamplate where we add the WeightInfo trait generation, and also implementing this for () rust unit type.