Closed golden-expiriensu closed 1 day ago
I see this is in forking mode,
are you making any requests during that time?
This happened again and I think it is happening when metamask makes requests to node in order to get info about a newly imported account. The RAM consumption raised from ~500 MiB to 1.2 GiB after this particular delay
Additional context: RAM limit on pod is 4 GiB, anvil is running for 46 hours
I see this is in forking mode,
are you making any requests during that time?
Yeah, it looks like anvil is not able to handle all the incoming requests from metamask + backend. But the stange thing tho is that it working good then account is not newly imported, so I think when you importing a new account metamask makes a ton of requests
I see there are a few eth_call requests
I wonder if this has something to do with rpc rate limits, could you try this with --no-rate-limit
Sure, I'll add a flag, redeploy the pod and report back with results
Unfortunately disabling rate-limits didnt fix the problem, here is the new logs first batch: 2023-10-13T11:29:52.754852809Z second batch: 2023-10-13T11:34:41.848433939Z normal block: 2023-10-13T11:34:44.932910143Z anvil_no_rate_limits.log
The changes in command:
Hello, I am still experiencing this issue on ghcr.io/foundry-rs/foundry:nightly image :(
looking at the logs, I'm pretty sure this is an issue with tx execution in forked mode, which delays block production. I think we we should tune the block interval so that missed intervals aren't resulting in bursts of blocks?
Hmmm, I use 12 seconds to mock Ethereum, what are your suggestions?
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
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
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
I had a similar issue but in a non-fork mode with Metamask. I was getting a lot of frustrating -32603: Internal JSON-RPC error
errors from Metamask. The recommendation here by @mattsse seems to work.
I also tried using the prefix RUST_LOG=node,backend,api,rpc=warn anvil
and realised that transactions seem to fail when they come in too early before the next block is mined and that is why shortening the block time interval seem to make the problem go away (my interpretation might be wrong).
If I was proficient in rust and understood anvil enough, I would have attempted solving this issue.
Thank you @mattsse . Hoping to test this soon
I have built anvil from your branch. With a block time of 5s I get the internal RPC error once in a while. I suspect I might be sending too many requests to anvil.
I am wondering about anvil keeping unprocessed txns in a pool until they're mined.
Tentatively marking as resolved by https://github.com/foundry-rs/foundry/pull/7328
@golden-expiriensu / @KELs7 feel free to re-open with additional details / minimal reproduction if this is still an issue
Component
Anvil
Have you ensured that all of these are up to date?
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:
entrypoint.sh
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