Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

Internal functions are not estimated. #94

Open
andreafspeziale opened this issue Aug 7, 2018 · 3 comments
Open

Internal functions are not estimated. #94

andreafspeziale opened this issue Aug 7, 2018 · 3 comments

Comments

@andreafspeziale
Copy link

andreafspeziale commented Aug 7, 2018

Hi dear @cgewecke,
first of all thanks for the great tool!

Maybe I'm wrong or missing something but I've noticed that internal functions are not estimated in the report but they are in the inline test report.

I've been working on this little project TokenLocker contract where I've implemented this pattern:

contract TokenLocker is Ownable {
....
function release(address _to) internal ... { ... }
function() public {
        release(msg.sender);
    }
}

The tests are running cool
(e.g ✓ should release the tokens to the first beneficiary expecting the LogRelease event (47139 gas))

but in the resume table at the end I got 0 estimation of the release function
| TokenTimelock · release · - · - · - · 0 · - │

It could be my lack of experience.
Thanks in advance!

@andreafspeziale andreafspeziale changed the title Internal function are not estimated. Internal functions are not estimated. Aug 7, 2018
@cgewecke
Copy link
Owner

cgewecke commented Aug 7, 2018

Hi @andreafspeziale, thanks very kind of you.

Yes I think this is a limitation of the way the reporter works. As the tests run it fetches the executed transactions from each block, looks at their input field and matches that to the hash of a method's function signature.

So if you never directly call a method, the reporter won't be able to associate gas readings with it, although you could wrap a public mock around internal functions and get an approximation of how much they cost that way.

In your case, the fallback function is being used - this is something that needs investigation because it's possible the report could detect that. Have to check out what the tx.input data looks like there....

@andreafspeziale
Copy link
Author

@cgewecke Thank you so much, keep us up to date!

@alxiong
Copy link

alxiong commented Nov 12, 2021

Same feature request here 🙌 , would be great if we can have the tracing gas report like eth-brownie has.

May I ask what's the inherent limitation for not supporting it? @cgewecke
It seems hardhat's eth_traceTransaction would provide enough info?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants