foundry-rs / foundry-rs/foundry
bug(`anvil`): anvil in fork mode is unstable when performing multiple `snapshot` / `revert` in parallel
- Dominant language
- Rust
- Stars
- 10.6k
- Forks
- 2.6k
- Avg merge
- 18h 20m
- Merged PRs (30d)
- 510
Description
### Component
Anvil
### Have you ensured that all of these are up to date?
- [ ] Foundry
- [x] Foundryup
### What version of Foundry are you on?
1.3.1
### What version of Foundryup are you on?
1.3.1
### What command(s) is the bug in?
anvil --fork-chain-id ${chainId} --fork-url ${forkUrl} --fork-block-number ${blockNumber} --accounts ${this.MAX_WALLETS} --balance 1000000 --no-request-size-limit --no-cors --quiet --order fifo --port ${port} --timeout 5000 --retries 1 --gas-price 0 --block-base-fee-per-gas 0 --code-size-limit 1000000000 --gas-limit 1000000000000000000 --auto-impersonate --prune-history --memory-limit 1073741824 --disable-console-log --disable-min-priority-fee --disable-default-create2-deployer --host 127.0.0.1
### Operating System
Linux
### Describe the bug
I’m using Anvil in fork-mainnet mode to simulate buy, sell, and transfer actions of tokens. However, I often encounter RPC timeouts. Currently, I’m using snapshot and revert for each simulation session, but since all requests share a single Anvil instance, parallel token simulations cause issues — when one session reverts, it can affect the others and lead to failures. Is there a more optimal solution for this? I came across a similar issue reported in https://github.com/foundry-rs/foundry/issues/11238
Contributor guide
Assessment
This issue has not been assessed yet.