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.17k stars 1.7k forks source link

Forge create + verify uploads 40 files when the actual contract is 20lines with no dependencies #3739

Open Elyx0 opened 1 year ago

Elyx0 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 (f523139 2022-11-16T00:07:04.576471Z)

What command(s) is the bug in?

forge create contracts/helpers/SearcherHelperRepayerEcho.sol:SearcherHelperRepayerEcho --rpc-url $ALCHEMY_APIKEY_POLYGON --gas-price 200gwei --private-key $RELAY_TEST_PRIV_KEY --etherscan-api-key $POLYGONSCAN_APIKEY --verify

Operating System

macOS (Apple Silicon)

Describe the bug

My whole contract is :

//SPDX-License-Identifier: Unlicensed
pragma solidity ^0.8.16;
contract SearcherHelperRepayerEcho {
    function fastLaneCall(
            address _sender,
            uint256 _bidAmount,
            bytes calldata _searcherCallData
    ) external payable returns (bool, bytes memory) {
        bool success;
        address to = msg.sender;
        assembly {
            // Transfer the ETH and store if it succeeded or not.
            success := call(gas(), to, _bidAmount, 0, 0, 0, 0)
        }

        require(success, "ETH_TRANSFER_FAILED");
        return (true,bytes("ok"));
    }
}

Living in a simple file by itself in contracts/helpers/SearcherHelperRepayerEcho.sol

Despite that foundry compiles everything and uploads 39 files alongside

https://polygonscan.com/address/0xeA26974363EC1dBc132C99cF9A29273B17254aE3#code

Elyx0 commented 1 year ago

I deleted cache and it didn't change anything

mattsse commented 1 year ago

thanks for flagging this.

@rkrasiuk there seems to be something off with what artifacts are attached, any ideas?

Edit: I assume this happens here https://github.com/foundry-rs/foundry/blob/master/cli/src/cmd/forge/verify/etherscan/standard_json.rs#L22 perhaps something wrong with how the graphs is filtered?

joshieDo commented 1 year ago

The contract mentioned does not seem to be in polygonscan though, how can that happen?

mattsse commented 1 year ago

could be that the wrong artifact is used which just happens to also pull in the target contract?

any way to replicate this @Elyx0 ?

rkrasiuk commented 1 year ago

+1 on repro, it seems like it submitted all of the source files. I've found the target contract SearcherRepayerEcho as detected by polygonscan under PFL_AuctionHandler.t.sol. is it possible that you have contracts with duplicate names in the repo? https://polygonscan.deth.net/address/0xb47387995e866908b25b49e8bac7e499170461a6#code

Elyx0 commented 1 year ago

Yes in a previous commit I had duplicate names at some point, then renamed so they're all unique but it still happened