foundry: Anvil stops producing blocks and then mines a bunch of blocks at once

Component

Anvil

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (f8a07c3 2023-08-22T21:43:06.347698566Z)

What command(s) is the bug in?

anvil

Operating System

Linux

Describe the bug

I am running anvil in the kubernetes with following dockerfile and entrypoint:

Dockerfile:

FROM ghcr.io/foundry-rs/foundry

WORKDIR /app

COPY . ./

RUN ["chmod", "+x", "./entrypoint.sh"]

EXPOSE 8545

ENTRYPOINT ["./entrypoint.sh"]

entrypoint.sh

#!/bin/sh
anvil \
    -b 12 \
    --host '0.0.0.0' \
    --prune-history 300 \
    --state "/app/blockchain_data" \
    --transaction-block-keeper 3600 \
    -f ${ETHEREUM_URL}

Sometimes the anvil hangs up and stops producing blocks for about 5 minutes. During this time it does not respond to most requests and just hangs. The amount of RAM consumption does not increase, the process does not crash. After this delay, the anvil produces a bunch of blocks at a time and starts responding to some requests. After 2-3 such delays, the node starts responding steadily, and nothing crashes

In the attached logs the bug starts at 2023-10-13T09:31:54.519257387Z anvil.log

About this issue

  • Original URL
  • State: open
  • Created 9 months ago
  • Comments: 16 (13 by maintainers)

Most upvoted comments

By the way, the reason is actually metamask, we don’t experience any problems while not creating new accounts/adding anvil as a new network

hmm, interesting, I guess the call chainId blocknumber a lot, need to check those if they somehow interfere with blockproduction in forking mode

Hmmm, I use 12 seconds to mock Ethereum, what are your suggestions?

I meant in anvil we should delay missed blocks (for what ever reason) and if a block is late, still target the next block for 12s because rn I think we just mined all missed blocks in bulk