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

Create a lastGasUsed() function in Vm.sol #7272

Closed
AmadiMichael opened this issue Feb 29, 2024 · 1 comment · Fixed by #7573
Closed

Create a lastGasUsed() function in Vm.sol #7272

AmadiMichael opened this issue Feb 29, 2024 · 1 comment · Fixed by #7573
Assignees
Labels
T-feature Type: feature

Comments

@AmadiMichael
Copy link

AmadiMichael commented Feb 29, 2024

Component

Forge

Describe the feature you would like

With support for --isolate when running tests and scripts, it would be helpful to expose a function lastGasUsed() in VM.sol that returns the gasUsed of the immediate last top-level transaction.

Better still, a function gasUsed() returns (uint256[] memory) that returns an array of gasUsed of all top level calls made in that isolated vm execution

Additional context

This would be particularly helpful given that currently, when a function is called multiple times, the only way to see the gas used for individual calls is to look at the expanded trace, a gasUsed helper function, would make it possible for a dev to access and use this info how they deem fit.

No response

@mds1
Copy link
Collaborator

mds1 commented Apr 5, 2024

would make it possible for a dev to access and use this info how they deem fit.

Can you expand on the use case? Instead of a cheatcode specific to --isolate mode, a more generic solution may be to use forge test --gas-report, and perhaps update it to also output the raw data as JSON or something if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-feature Type: feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants