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.1k stars 1.67k forks source link

Consider programatically forked chains in etherscan identifier #3842

Open ChristopherKai opened 1 year ago

ChristopherKai commented 1 year 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 (8d8bc28 2022-09-26T17:49:28.998299391Z)

What command(s) is the bug in?

forge test --contracts=./src/test/mycontarct.sol

Operating System

Linux

Describe the bug

Even though I have [etherscan] config in foundry.toml config file, I cant get the trace with source code.

my foundry.toml config :

[etherscan] mainnet = { key = "" } bsc = { key = "", url = "https://api.bscscan.com/api" }

output:

Traces: [5178] ContractTest::setUp() ├─ [0] VM::createSelectFork(mainnet, 12516702) │ └─ ← 0 └─ ← ()

[103448] ContractTest::testRun() ├─ [5070] 0xF0b7DE03134857391d8D43Ed48e20EDF21461097::owner() [staticcall] │ ├─ [2404] 0xDe71B24FE56358cC0ADfd6f2e0f6D8ed9e2CF634::owner() [delegatecall] │ │ └─ ← 0x000000000000000000000000904f81eff3c35877865810cca9a63f2d9cb7d4dd │ └─ ← 0x000000000000000000000000904f81eff3c35877865810cca9a63f2d9cb7d4dd ├─ [0] console::log(Before exploiting, NFT contract owner:, 0x904F81EFF3c35877865810CCA9a63f2D9cB7D4DD) [staticcall] │ └─ ← () ├─ [27962] 0xF0b7DE03134857391d8D43Ed48e20EDF21461097::init(ContractTest: [0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84], 0, 0) │ ├─ [27757] 0xDe71B24FE56358cC0ADfd6f2e0f6D8ed9e2CF634::init(ContractTest: [0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84], 0, 0) [delegatecall] │ │ ├─ emit OwnershipTransferred(param0: 0x904F81EFF3c35877865810CCA9a63f2D9cB7D4DD, param1: ContractTest: [0xb4c79daB8f259C7Aee6E5b2Aa729821864227e84

mattsse commented 1 year ago

can you run with RUST_LOG=etherscanidentifier forge test ... and share the logs?

ChristopherKai commented 1 year ago

RUST_LOG=etherscanidentifier forge test

I'm forking bsc, but it still try to get source from etherscan.io. My Code

    function setUp() public {
        cheats.createSelectFork("bsc", 23106506);
    }

My config

etherscan_api_key = ""
chain = "mainnet"
[fmt]
tab_width = 2
number_underscore = "thousands"
[rpc_endpoints] 
mainnet = "https://rpc.ankr.com/eth"
optimism = "https://rpc.ankr.com/optimism"
fantom = "https://rpc.ankr.com/fantom"
arbitrum = "https://rpc.ankr.com/arbitrum"
bsc = "https://bsc-dataseed1.binance.org"
moonriver = "https://moonriver.public.blastapi.io"
gnosis = "https://rpc.ankr.com/gnosis"
avax = "https://rpc.ankr.com/avalanche"
polygon = "https://rpc.ankr.com/polygon"

[etherscan]         
mainnet = { key = "",url = "https://api.bscscan.com/api" }
bsc = { key = "", chain="bsc", url = "https://api.bscscan.com/api" }

image

mattsse commented 1 year ago

ah you're programmatically forking,

I believe there's currently a limitation with how sources are resolved, the default is mainnet here and we don't consider fork call.

But I think we can apply this logic.

so this is not really a bug with the config, but how the etherscan identifier is set up.

changing title