foundry
foundry copied to clipboard
fix: script simulation with default sender
Motivation
Closes #8960
Right now, when simulating a script without providing a --sender
arg, we will use the default sender both for script contract deployment and setUp
/run
. This will result in sender nonce being higher than an actual on-chain nonce. For certain scripts, this might result in mismatched addresses and failure during on-chain simulation, if incorrect addresses end up in calldata.
Solution
Fix contains 2 parts:
- Follow-up for https://github.com/foundry-rs/foundry/pull/7907 which enables nonce correction even when sender is default foundry sender. Unsure why this case was excluded earlier
- Hack during script execution — if we're simulating with default sender, we'd set it's nonce to a hardcoded high value for script contract CREATE transaction. This allows us to reset nonce back to on-chain value when simulating the script, and ensure matching contract addresses during on-chain sumlation