foundry icon indicating copy to clipboard operation
foundry copied to clipboard

`forge script` Avoid bulk gasEstimation when setting `--skip-simulation`

Open ckoopmann opened this issue 2 years ago • 1 comments

Motivation

Even when setting --skip-simulation the current implementation still tries to estimate gas for all transactions in a script before submitting any of them.

Therefore scripts that have transactions that depend on previous tx's to succeed will fail. ( Avoiding which was one of the motivations to introduce --skip-simulation in the first place).

Solution

When providing --skip-simulation don't try to estimate gas until immediately before tx submission. (If you combine this with the --slow option the state against which gas is estimated should include previous tx's from the same script, thus avoiding above outlined problem).

ckoopmann avatar Aug 04 '22 06:08 ckoopmann

Ready for review. @onbjerg I commited the changed testcase into a separate commit (where it is failing) to illustrate the issue this pr is solving. Lmk if I should squash before merge. (or feel free to do so yourself).

ckoopmann avatar Aug 07 '22 03:08 ckoopmann

lgtm, given the conflict fix

sorry was sick and my github notifications are a mess.

joshieDo avatar Aug 10 '22 16:08 joshieDo

rebased, merging, after checks

mattsse avatar Aug 10 '22 21:08 mattsse