foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Forge script stuck when running anvil with fixed block time

Open Thegaram opened this issue 9 months ago • 1 comments

Component

Anvil

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 (d495216 2024-05-03T00:21:54.426103000Z)

What command(s) is the bug in?

No response

Operating System

macOS (Apple Silicon)

Describe the bug

Not sure if this is an issue with anvil or forge script.

I have a forge script that sends about 60 transactions. It works well with anvil, but it's stuck indefinitely with anvil --block-time 3.

[⠑] Compiling...
No files changed, compilation skipped
Script ran successfully.

## Setting up 1 EVM.

==========================

Chain 111111

Estimated gas price: 0.158191454 gwei

Estimated total gas used for script: 44606349

Estimated amount required: 0.007056343205941446 ETH

==========================
##
Sending transactions [0 - 56].
⠒ [00:00:00] [###############################################################################################################################>---------------------------------------------------------------------] 37/57 txes (0.1s)##
Waiting for receipts.
⠐ [00:00:07] [##############################################################################################################>--------------------------------------------------------------------------------] 33/57 receipts (160.9s)

On the anvil console output I see one block with a bunch of transactions, the next block with 1 transaction, then all subsequent blocks have 0 transactions. I also see non-stop eth_getTransactionReceipt logs.

It works if I run forge script with --batch-size 10, but it's stuck with the default setting.

Thegaram avatar May 03 '24 07:05 Thegaram

The --slow option is the solution. The scripts try to spam the chain with as many TXs at once. From the docs

--slow
    Makes sure a transaction is sent, only after its previous one has been confirmed and succeeded.

gititGoro avatar Aug 10 '24 12:08 gititGoro