Skip to content

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

@AmadiMichael

Description

@AmadiMichael

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

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions