Ability to mine/wait for blocks in scripts #1902
Labels
C-forge
Command: forge
Cmd-forge-script
Command: forge script
D-hard
Difficulty: hard
T-feature
Type: feature
Component
Forge
Describe the feature you would like
This is a follow-up on #1848 , which got closed even thought the bug (rust panic) still persists
In scripts, we can use
--slow
to force transactions to happen across different blocks. However, if those transactions rely on data such asblockhash(block.number - 1)
, forge will actually fail to simulate them, because no actual blocks and blockhashes are being created during that time. e.g., the following fails in a script, but works in a unit test:The specific error I get is :
It would be very useful to be able to request our forked instance (anvil?) to simulate a new block being mined, which is the behaviour necessary here, and what suposedly
--slow
should enforceAdditional context
My real-world scenario here is actually trying to solve Ethernaut #03 on-chain using a forge script.
The script must:
The current blocker for this is that each call relies on
blockhash(block.number - 1)
, which doesn't seem to exist while simulating the scriptThe text was updated successfully, but these errors were encountered: