Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic weight sanity checker #152

Open
Tracked by #6151
kianenigma opened this issue Jul 21, 2023 · 5 comments
Open
Tracked by #6151

Automatic weight sanity checker #152

kianenigma opened this issue Jul 21, 2023 · 5 comments
Labels
C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. I5-enhancement An additional feature request. T1-FRAME This PR/Issue is related to core FRAME, the framework.

Comments

@kianenigma
Copy link
Contributor

In any given FRAME based runtime, the total block weight is known. Moreover, an extensive list of weight functions is also known. Most often, each weight function corresponds to a single dispatchable, or a single hook. If not, it almost always refers to a subset of them.

We also know that the entire weight system is linear.

Given these two points, it is fair to assume that the following is possibly a mis-configuration of the runtime.

If the execution of any weight function, where all components are Bounded::min_value() already exceeds the maximum block weight.

This can happen as a separate test that lives inside construct_runtime, an independent opt-in test, or seemingly best, happen as a part of the benchmark execution where the component ranges is known, and we don't need to fallback to Bounded::min_value.

@jtfirek
Copy link
Contributor

jtfirek commented Jul 23, 2023

I've been looking into starting this and I have a few questions / assumptions.

  • Out of the 3 options, I have planning on doing the first one as it seems like a great way to start learning about how the construct_runtime macro works, but imk if you guys prefer one of the other ways.

This can happen as a separate test that lives inside construct_runtime

@xlc
Copy link
Contributor

xlc commented Jul 23, 2023

We really should have the benchmark data stored in a proper data file format such as csv and then use the csv file to generate weight file. And then can also do whatever additional checks from the csv file directly without all the complicated Rust changes.

@juangirini juangirini transferred this issue from paritytech/substrate Aug 24, 2023
@the-right-joyce the-right-joyce added I5-enhancement An additional feature request. C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. T1-FRAME This PR/Issue is related to core FRAME, the framework. and removed J0-enhancement labels Aug 25, 2023
@Daanvdplas
Copy link
Contributor

@jtfirek are you still working on it? Otherwise I'd like to do it!

@kianenigma
Copy link
Contributor Author

Moreover, an extensive list of weight functions is also known

I want to clarify that I am pretty sure this information is available, but I can't recall the exact trait that would return it. I will post it here if I find it, as it would be the starting point of this issue. @ggwpez maybe you know it in your 🧠? :D

@Daanvdplas feel free to ask questions if you have any!

@ggwpez
Copy link
Member

ggwpez commented Sep 7, 2023

Daan asked me about it and seems to be on his way 😄
The current approach will print the warning when running the CLI, not as part of construct_runtime!.

jonathanudd pushed a commit to jonathanudd/polkadot-sdk that referenced this issue Apr 10, 2024
@Daanvdplas Daanvdplas removed their assignment Jul 30, 2024
@kianenigma kianenigma added this to AHM Oct 21, 2024
@kianenigma kianenigma moved this to Backlog in AHM Oct 22, 2024
@kianenigma kianenigma removed this from AHM Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C1-mentor A task where a mentor is available. Please indicate in the issue who the mentor could be. I5-enhancement An additional feature request. T1-FRAME This PR/Issue is related to core FRAME, the framework.
Projects
Status: Backlog
Development

Successfully merging a pull request may close this issue.

7 participants