foundry icon indicating copy to clipboard operation
foundry copied to clipboard

bug(`forge script`): `--skip-simulation` does not skip simulation

Open Philogy opened this issue 1 year ago • 14 comments

Component

Forge

Have you ensured that all of these are up to date?

  • [X] Foundry
  • [X] Foundryup

What version of Foundry are you on?

forge 0.2.0 (24abca6 2024-01-16T00:26:29.551032000Z)

What command(s) is the bug in?

forge script --skip-simulation

Operating System

macOS (Apple Silicon)

Describe the bug

Often there are things that my script depends on that foundry is unable to simulate correctly (self-destruct reinit, hot/cold storage gas cost).

Whether --skip-simulation is provided or not forge script will simulate the script first before attempting to broadcast it. Meaning that if it's incorrectly failing in the simulation I'm unable to broadcast transactions using foundry.

The --skip-simulation flag does however get the script runner to exclaim "SKIPPING ON CHAIN SIMULATION." after it has successfully ran the simulation 😅 image

Philogy avatar Jan 16 '24 20:01 Philogy

thanks for flagging, possible regression, fixing asap

mattsse avatar Jan 16 '24 20:01 mattsse

do you have a minimal repro for this?

mattsse avatar Jan 16 '24 21:01 mattsse

Had some previous discussion in #5776

Sabnock01 avatar Jan 16 '24 21:01 Sabnock01

Yeah based on @Evalir's comment here: https://github.com/foundry-rs/foundry/issues/5776#issuecomment-1867287499 it does seem like this intentional and kind of unavoidable based on how scripts currently work.

Unfortunately, this does mean that forge script is unusable for me in many use-cases. Specifically because of the simulation being in 1 tx (meaning gas accounting for warm/cold storage slots will be off and self-destruct / reinit doesn't work).

Not sure how you'd fix this exactly, maybe have a separate environment in which the script contract is run and the actual simulation itself, any external CALLs made in one are captured and emitted as transactions in the actual environment?

Philogy avatar Jan 16 '24 21:01 Philogy

Here's a minimal repro

This seems like a niche case but there are others like self-destruct, reinit or other weird dependencies like gas-price that would cause the same issue

Philogy avatar Jan 16 '24 21:01 Philogy

copying good background provided by @evalir from #5776 :

--skip-simulation avoids using the provided URL to do gas estimation. It does not prevent foundry from simulating the script locally. The latter is not possible to disable, as we must simulate the script to gather all the transactions to broadcast. If the local simulation fails, the whole script fails.

much of my experience with wanting this feature to avoid local sim was around similar edge cases. On-chain randomness where the randomness is seeded by things like gas, gas-limit, coinbase, etc that is difficult to match exactly in a forge script.

plotchy avatar Jan 17 '24 06:01 plotchy

Can we get an ETA on this?

Xenoset77 avatar Mar 13 '24 02:03 Xenoset77

+1 to this change. It's very annoying to deploy something like a price from an oracle feed since the price data will expire before being persisted on chain with large deployment scripts & especially on slow networks like ETH.

Austinhs avatar Feb 11 '25 04:02 Austinhs

this is a thorough re-design of forge script, putting into backlog

jenpaff avatar Mar 25 '25 15:03 jenpaff

this seems to still be an issue

mshakeg avatar Aug 09 '25 11:08 mshakeg

Still an issue

0xMeir avatar Aug 19 '25 19:08 0xMeir

wtf................

maxim-inj avatar Oct 05 '25 05:10 maxim-inj

Still an issue. @mattsse could you help?

grasphoper avatar Oct 20 '25 06:10 grasphoper

This would be a very helpful workaround when developing on EVM's that have precompile contracts, which currently forge is unable to call/staticcall (I'm not sure why) and complains that the simulation would revert call to non-contract address...

nicholaspai avatar Nov 26 '25 20:11 nicholaspai