foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.31k stars 1.76k forks source link

`forge test` fails to deserialize response from etherscan #3621

Closed jo-es closed 1 year ago

jo-es commented 2 years ago

Component

Forge

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

What version of Foundry are you on?

forge 0.2.0 (8b0af47 2022-11-06T00:06:24.552295Z)

What command(s) is the bug in?

forge test

Operating System

macOS (Apple Silicon)

Describe the bug

The following error seems to be thrown for every RPC request in a test case. (SOME ADDRESS points to a contract called in the test)

2022-11-06T15:19:29.642847Z ERROR etherscan: Failed to deserialize response: data did not match any variant of untagged enum ResponseData res="{\"message\":\"OK\",\"result\":[{\"Address\":\"<SOME ADDRESS>\"}],\"status\":\"1\"}"
mattsse commented 2 years ago

is this a hard error or a log?

jo-es commented 2 years ago

Just an error log. The test run will proceed with execution and pass.

mattsse commented 2 years ago

could you please add all logs for RUST_LOG=ethers,foundry_evm,foundry_cli,forge?

jo-es commented 2 years ago

The following sequence of logs repeats for every RPC request

2022-11-06T15:50:41.907278Z TRACE etherscanidentifier: fetching info for <CONTRACT_ADDRESS_A>
2022-11-06T15:50:41.907319Z TRACE etherscan: GET https://blockscout.com/poa/core/api
2022-11-06T15:50:42.218126Z ERROR etherscan: Failed to deserialize response: data did not match any variant of untagged enum ResponseData res="{\"message\":\"OK\",\"result\":[{\"Address\":\"<CONTRACT_ADDRESS_B>\"}],\"status\":\"1\"}"
2022-11-06T15:50:42.218243Z  WARN etherscanidentifier: could not get etherscan info: Serde(Error("data did not match any variant of untagged enum ResponseData", line: 0, column: 0))
mattsse commented 2 years ago

this is strange, because the response does not match the documented API: for the getsourcecode endpoint https://blockscout.com/eth/mainnet/api-docs#contract

amusingaxl commented 1 year ago

I'm facing the same issue and I believe that Etherscan has changed their free tier: image

Here are the traces I get when enabling the logs:

image

So apparently Foundry is querying Etherscan at a rate that is faster than 5 reqs/s.

There are some duplicate requests, so I guess some sort of caching could help alleviate the problem,.

PaulRBerg commented 1 year ago

Posting one more example from our project.

CI logs after `forge script`

```text Run forge script script/DeployProxyTarget.s.sol --broadcast --rpc-url "goerli" --sig "run(address)" -vvvv "0xcf482b964883F58c2413b7500925FD8299293Cd1" forge script script/DeployProxyTarget.s.sol --broadcast --rpc-url "goerli" --sig "run(address)" -vvvv "0xcf48[2](https://github.com/sablierhq/v2-periphery/actions/runs/4930343514/jobs/8811136535#step:4:2)b96488[3](https://github.com/sablierhq/v2-periphery/actions/runs/4930343514/jobs/8811136535#step:4:3)F58c2413b7500925FD8299293Cd1" shell: /usr/bin/bash -e {0} Compiling 99 files with 0.8.19 Solc 0.8.19 finished in 13.80s Compiler run successful! 2023-05-09T20:50:57.579099Z ERROR etherscan: Failed to deserialize response: expected value at line 1 column 1 res="\n\n\n Just a moment...\n \n \n \n \n \n \n\n\n\n

\n
\n \n
\n
\n \n
\n
\n
\n\n\n\n\n\n" 2023-05-09T20:50:57.604999Z ERROR etherscan: Failed to deserialize response: expected value at line 1 column 1 res="\n\n\n Just a moment...\n \n \n \n \n \n \n\n\n\n
\n
\n \n
\n
\n \n
\n
\n
\n\n\n\n\n\n" Traces: [3273325] DeployProxyTarget::run(0xcf482b964883F58c24[13](https://github.com/sablierhq/v2-periphery/actions/runs/4930343514/jobs/8811136535#step:4:14)b7500925FD8299293Cd1) ├─ [0] VM::startBroadcast(0x0E109f35926575FC64Ec73735101966d434Ed591) │ └─ ← () ├─ [3210607] → new SablierV2ProxyTarget@0x47FD63a79D39E72D2870EEd0C481620091F44c04 │ └─ ← 16034 bytes of code ├─ [0] VM::stopBroadcast() │ └─ ← () └─ ← SablierV2ProxyTarget: [0x47FD63a79D39E72D2870EEd0C481620091F44c04] Script ran successfully. == Return == target: contract SablierV2ProxyTarget 0x47FD63a79D39E72D2870EEd0C481620091F44c04 ## Setting up (1) EVMs. ========================== Simulated On-chain Traces: [3505927] → new SablierV2ProxyTarget@0x47FD63a79D39E72D2870EEd0C481620091F44c04 └─ ← 16034 bytes of code ========================== Chain 5 Estimated gas price: 16.764240798 gwei Estimated total gas used for script: 4557705 Estimated amount required: 0.07640646410624859 ETH ========================== ### Finding wallets for all the necessary addresses... ## Sending transactions [0 - 0]. Transactions saved to: /home/runner/work/v2-periphery/v2-periphery/broadcast/DeployProxyTarget.s.sol/5/run-latest.json ## Waiting for receipts. ##### goerli ✅ Hash: 0xcecc762c016432b446be9fd8d8138ebebcf5646ac393a98055bef5fd0fd78dde Contract Address: 0x47fd63a79d39e72d2870eed0c481620091f44c04 Block: 8971716 Paid: 0.038791778202910557 ETH (3506943 gas * 11.06[14](https://github.com/sablierhq/v2-periphery/actions/runs/4930343514/jobs/8811136535#step:4:15)22499 gwei) Transactions saved to: /home/runner/work/v2-periphery/v2-periphery/broadcast/DeployProxyTarget.s.sol/5/run-latest.json ```

mattsse commented 1 year ago

@Evalir can we close this after the recent etherscan fixes?

Evalir commented 1 year ago

Yep I believe so—we did have some deserialization issues that we fixed. Closing!

codemedici commented 1 year ago

@Evalir the monthly subscription for Etherscan is $200 a month for 10 API calls per second, this is a major issue for developers, because I am not able to verify contracts manually either and not having them verified is unacceptable, forcing me to pay for Etherscan; could you just lower the API calls rate on the Foundry side!?

codemedici commented 1 year ago

Yep I believe so—we did have some deserialization issues that we fixed. Closing!

How are deserialization fixes related to the api rate limit of Etherscan? Thank you