galacticcouncil / galacticcouncil/hydration-node
Bug: benchmark does not generate WeightInfo
- Dominant language
- Rust
- Stars
- 208
- Forks
- 109
- Avg merge
- 6d 3h
- Merged PRs (30d)
- 3
Description
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.
Contributor guide
Research direction
Start with script/pallet-weight-template.hbs and trace how it is used to generate pallet benchmarks. Compare the generated output with the WeightInfo trait shown in the issue, then verify that regeneration produces the trait and its benchmark functions, including the proposed unit-type implementation if required. Done means benchmark weights and WeightInfo can be regenerated automatically without becoming outdated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100