foundry
foundry copied to clipboard
setBalance hangs/times out in fork mode.
Component
Anvil
Have you ensured that all of these are up to date?
- [X] Foundry
- [X] Foundryup
What version of Foundry are you on?
0.1.0 (92f8951 2022-08-06T00:12:01.716963548Z)
What command(s) is the bug in?
anvil
Operating System
No response
Describe the bug
Command used:
anvil --host 0.0.0.0 --fork-url="https://eth-mainnet.g.alchemy.com/v2/XXX" --fork-block-number=15187941 --port=8545 --block-time=5 --chain-id=1
When running in fork mode, in our e2e tests, we've been noticing that hardhat_setBalance/anvil_setBalance will hang and timeout.
Error: timeout (requestBody="{\"method\":\"hardhat_setBalance\",\"params\":[\"0x54B456a97E631cd224FBFe12B513684e601A6571\",\"0x56bc75e2d63100000\"],\"id\":46,\"jsonrpc\":\"2.0\"}", requestMethod="POST", timeout=120000, url="http://127.0.0.1:8545", code=TIMEOUT, version=web/5.5.1)
I haven't been able to reproduce this locally, so just hoping for either ideas to better debug this or if the logs I have would be a hint to what's wrong.
Log file: https://github.com/sunwrobert/anvil-log/blob/main/ethereum-mainnet.log
the logs include a lot of targets
could you double check that you run with RUST_LOG=backend,node,miner,rpc=warn anvil and not with RUST_LOG=trace which would enable tracing for all dependencies as well
this is auto mine mode, right? what's the interval?
this is auto mine mode, right? what's the interval?
The block time is 5, using interval mining
Here's the log with RUST_LOG=backend,node,miner,rpc=warn
ethereum-mainnet.log
thanks!
could you try to reproduce this with https://github.com/foundry-rs/foundry/pull/2648
(hopefully not)
thanks!
could you try to reproduce this with #2648
(hopefully not)
Will do once that's merged!
you can install specific branches via foundryup --pr 2648 btw
you can install specific branches via
foundryup --pr 2648btw
oh, TIL. Yeah let me try that
for some reason, having trouble installing from this specific PR in our docker container.
@sunwrobert Unsure what container you are using, but the one we ship does not come with the necessary build tools. You need cargo with rustc, at least Rust 1.62 and preferably not use musl etc. (it works it just involves other steps)
Otherwise it would be helpful to get more context on the trouble you are having (error messages etc.)
is now in master and will land in tonight's nightly @sunwrobert
@mattsse I now seem to be seeing a different error:
Error: missing response (requestBody="{\"method\":\"hardhat_setBalance\",\"params\":[\"0x9F754922a85340EaA41094A06a3fa5BeEC30afa8\",\"0x11c37937e08000\"],\"id\":42,\"jsonrpc\":\"2.0\"}", req
uestMethod="POST", serverError={"errno":-111,"code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8545}, url="http://127.0.0.1:8545", code=SERVER_ERROR, version=web/5.5.1)
so instead of timeout, it seems to be missing response.
This is the last thing the log fails with:
api_local-ethereum-mainnet-1 | [2m2022-08-09T02:25:28.897922Z[0m [35mTRACE[0m [2mbackend[0m[2m:[0m get balance for 0xcb10d83d8447a90bfda18b6a57376dab13270a31
api_local-ethereum-mainnet-1 | [2m2022-08-09T02:25:28.911384Z[0m [35mTRACE[0m [2mminer[0m[2m:[0m creating new block
api_local-ethereum-mainnet-1 | [2m2022-08-09T02:25:28.911402Z[0m [35mTRACE[0m [2mbackend[0m[2m:[0m creating new block with 0 transactions
api_local-ethereum-mainnet-1 | thread 'fork-backend-thread' panicked at 'Failed to get account for 0x8481…b078
api_local-ethereum-mainnet-1 | ProviderError(ReqwestError(reqwest::Error { kind: Request, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("eth-mainnet.g.alchemy.com")), port: None, path: "/v2/wjHFOUwHNdrFd0eogO0IP4oA0PxhDRSD", query: None, fragment: None }, source: TimedOut }))', evm/src/executor/fork/backend.rs:271:33
api_local-ethereum-mainnet-1 | note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
api_local-ethereum-mainnet-1 | ./scripts/run_ethereum.sh: line 4: 10 Aborted (core dumped) RUST_LOG=backend,node,miner,rpc=warn anvil --host 0.0.0.0 --fork-url="https://eth-mainnet.g.alchemy.com/v2/wjHFOUwHNdrFd0eogO0IP4oA0PxhDRSD" --fork-block-number=15187941 --port=8545 --block-time=5 --chain-id=1
api_local-ethereum-mainnet-1 exited with code 134
Full log here
cc @mattsse
oh this is a timeout issue and unrelated
api_local-ethereum-mainnet-1 | ProviderError(ReqwestError(reqwest::Error { kind: Request, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("eth-mainnet.g.alchemy.com")), port: None, path: "/v2/wjHFOUwHNdrFd0eogO0IP4oA0PxhDRSD", query: None, fragment: None }, source: TimedOut }))', evm/src/executor/fork/backend.rs:271:33
we just introduced 30s timeouts, reqwest default is No timeouts which means connections can hang.
I'll bump the timeout to 90s, so if nodes have some backend backoff added, 90s is probably a reasonable amount of time to wait.
closing as unrelated.