You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you use vm.pauseGasMetering() and call an address, if the address is a contract address and the contract uses the gasleft() function in a loop, the call can get stuck in an infinite loop. The reason is that the gasleft() function keeps returning the same gas limit indefinitely. While using vm.resumeGasMetering() can prevent this issue, it's not always effective.
For instance, I have a script that calls many contracts, and I don't want to encounter gas limit exceeded or out-of-gas errors. Thus, setting the gas limit again after it's lowered by vm.resumeGasMetering() isn't always possible.
A possible solution is to introduce an option like vm.callTimeout(address, data, timeout), which could be highly useful in various contexts such as fuzzing.
Alternatively, adding a function like vm.setGas(uint256) to adjust the gas limit inside the contract, allowing it to increase after execution, would be extremely beneficial.
Proposed Feature:
vm.callTimeout(address, data, timeout)
Calls an address with a specified data payload and a timeout.
Terminates the call if the timeout duration is exceeded.
vm.setGas(uint256)
Sets the gas limit to the specified value.
Allows resetting the gas limit to a higher value after execution.
These options would offer developers more control over gas usage and prevent infinite loops in contract calls.
Additional context
No response
The text was updated successfully, but these errors were encountered:
Component
Forge
Describe the feature you would like
When you use
vm.pauseGasMetering()
and call an address, if the address is a contract address and the contract uses thegasleft()
function in a loop, the call can get stuck in an infinite loop. The reason is that thegasleft()
function keeps returning the same gas limit indefinitely. While usingvm.resumeGasMetering()
can prevent this issue, it's not always effective.For instance, I have a script that calls many contracts, and I don't want to encounter gas limit exceeded or out-of-gas errors. Thus, setting the gas limit again after it's lowered by
vm.resumeGasMetering()
isn't always possible.A possible solution is to introduce an option like
vm.callTimeout(address, data, timeout)
, which could be highly useful in various contexts such as fuzzing.Alternatively, adding a function like
vm.setGas(uint256)
to adjust the gas limit inside the contract, allowing it to increase after execution, would be extremely beneficial.Proposed Feature:
vm.callTimeout(address, data, timeout)
vm.setGas(uint256)
These options would offer developers more control over gas usage and prevent infinite loops in contract calls.
Additional context
No response
The text was updated successfully, but these errors were encountered: