hardhat-contract-sizer
hardhat-contract-sizer copied to clipboard
Uncompiled Internal Functions
Overview
We use the contract sizer to analyze our contract size a lot. An issue we find is if internal functions are not been called in the contract, they will not be compiled into the contract, so it's hard to analyze the size of internal functions. This case does happen if I have a contract A with some internal functions, and then contract B inherits A and calls the internal functions.
Proposed Solution
Show how many internal functions that are igonre when compiling. I'm not sure whether it's doable. It's just an idea. Hope someone can propose better ideas or guidance.
I have a contract A with some internal functions, and then contract B inherits A and calls the internal functions.
In this case, the size of those internal functions will be reflected in the size of contract B. That's really the best that one can hope for, because the concept of "size" of an individual function is not very meaningful.
I do like your suggestion to display rough data about skipped functions. I would suggest generalizing the idea and also displaying counts of external functions and internal functions that are not skipped.
I'm not sure how to do this, however, as I've never worked with the compiler directly. It's possible that there's a flag that will trigger output of this information. If not, the source code might need to be analyzed directly. The latter is possibly too slow and/or complex to be within the scope of this plugin, but could possibly be released as a separate plugin.
I would consider a PR if anyone knows a good way to do this.
Closing because I don't think this is possible.