-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix(forge): record gas for nested deployed contracts #9301
Conversation
3bffa24
to
95e8fa6
Compare
the idea here is to only record samples which were isolated (because that way the final report would contain values as close to real onchain transactions as possible. but if we'd also include the subcalls than the resulted value would be some average between the top-level vs non-top-level usage |
makes sense, closing as not something we want to change. One could just create dedicated test (create and call fns) for nested contracts to get proper gas reports. |
we could also consider recording subcalls usage into separate metric, so that you can track gas usage dynamics even if certain methods are not called at top level at all |
yeah, I think having several metrics would be confusing and raise more questions, IMO better to proper document how to generate accurate gas report |
@grandizzy I see. My point is/was that the current reported I think it's an okayish workaround to have to manually deploy factory deployed contracts once for the gas metering, but then again for me this seems a bit confusing. If i do I don't know enough about the internals here, but shouldn't the bytecode size be static? |
ah, ok, so if that's only re deployment size / create calls I think that could be added, was under the impression gas too, will check |
I mean the issue as you noted exists on both, but on gas i now understand the rational for why it exists (and we don't rely on the |
Motivation
Closes #9300
Atm the gas reports are not collected for Calls and Creates if not the top level call (comment says
// Only include Calls and Creates as only these calls are isolated in inspector.
but check returns if one of these kinds, so they're not added)foundry/crates/forge/src/gas_report.rs
Lines 97 to 106 in 4817280
E.g. for a
Parent
contract that createsChild
which in turn createsAnotherChild
, running tests with traces and gas report will look likeAll contracts and gas are displayed in traces but deployment cost and size for
Child
andAnotherChild
reports are missing (one more thing that is not inline between traces and gas reports is that in traces the creation bytecode size is shown whereas in gas report the deployment bytecode size)@klkvr tests are passing but probably there's a good reason for the check, please advise
Solution