Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

outputSelection with contract name does not compile while compiles with * #1017

Closed
3 tasks
kuzdogan opened this issue May 8, 2023 · 2 comments
Closed
3 tasks
Assignees
Labels
🪲 bug Something isn't working

Comments

@kuzdogan
Copy link
Member

kuzdogan commented May 8, 2023

Description

I've come across another similar case to #928. We've already worked around this by always using * in the selected files. This new case was affected by the selected contract.

I can see this is related to outputSelection being introduced in 0.4.18 and updated with the selection items array in 0.4.19.

Normally we set the ouputSelection as

"*": {
  "ContractName": [
          "evm.bytecode.object",
          "evm.deployedBytecode.object",
          "evm.deployedBytecode.immutableReferences",
          "metadata"
        ]
      }
    },

but for this and older versions we should set it both to *.

Todo

  • Double check if this is the case for all contracts earlier than 0.4.19.
  • Confirm this gets handled correctly in later versions. (Edit: See the new case below)
  • Handle the outputSelection for contracts for these earlier versions.

Example contract

This is an already verified contract on mainnet

Chain: Ethereum Mainnet Address: 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2

version: 0.4.19+commit.c4cbbb05

Non-working outputSelection:

    "outputSelection": {
      "*": {
        "WETH9": [
          "evm.bytecode.object",
          "evm.deployedBytecode.object",
          "evm.deployedBytecode.immutableReferences",
          "metadata"
        ]
      }
    },

Working:

    "outputSelection": {
      "*": {
        "*": [
          "evm.bytecode.object",
          "evm.deployedBytecode.object",
          "evm.deployedBytecode.immutableReferences",
          "metadata"
        ]
      }
    },

Complete JSON input: WETH9.json.txt

The compiler does not throw etc. but gives empty output:

{
  "contracts": {
    "WETH9.sol": {
      "WETH9": {
        "evm": {
          "bytecode": {
            "linkReferences": {},
            "object": "",
            "opcodes": "",
            "sourceMap": ""
          },
          "deployedBytecode": {
            "linkReferences": {},
            "object": "",
            "opcodes": "",
            "sourceMap": ""
          }
        },
        "metadata": ""
      }
    }
  },
  "sources": {
    "WETH9.sol": {
      "id": 0
    }
  }
}

Source code + metadata: metadata.json.txt WETH9.sol.txt

Another Identical Example

Chain: Binance Smart Chain Mainnet (56) Address: 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c

JSON Input: 56-0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c-solc-input.json.txt

Source Code and Metadata: metadata.json.txt front_run.sol.txt WBNB.sol.txt

View in Huly HI-414

@kuzdogan
Copy link
Member Author

kuzdogan commented May 9, 2023

Came across another case with v0.4.24

Chain: Godwoken Testnet v1 (71401)
Address: 0xE05d380839f32bC12Fb690aa6FE26B00Bd982613

JSON input:

{
  "settings": {
    "evmVersion": "byzantium",
    "libraries": {
      "": {}
    },
    "optimizer": {
      "enabled": false,
      "runs": 200
    },
    "remappings": [],
    "outputSelection": {
      "*": {
        "RollBackWithCallCodeContract": [
          "evm.bytecode.object",
          "evm.deployedBytecode.object",
          "evm.deployedBytecode.immutableReferences",
          "metadata"
        ]
      }
    },
    "metadata": {}
  },
  "sources": {
    "contracts/RollBackCallCode.sol": {
      "content": "pragma solidity ^0.4.24;\ncontract StateContract{\n\n    uint256 public state = 1;\n    function modState() public{\n        state++;\n    }\n    function modStateWithRevert() public {\n        state++;\n        revert();\n    }\n}\n\ncontract RollBackWithCallCodeContract{\n\n    uint256 public state = 1;\n\n    function getState() public view returns(uint256){\n        return state;\n    }\n    function callCodeWithMethod(string memory methodName) public {\n        StateContract sc = new StateContract();\n        address(sc).callcode(bytes4(keccak256(abi.encodePacked(methodName))));\n    }\n\n}\n"
    }
  },
  "language": "Solidity"
}

Compiler output:

  "contracts": {
    "contracts/RollBackCallCode.sol": {
      "RollBackWithCallCodeContract": {
        "evm": {
          "bytecode": {
            "linkReferences": {},
            "object": "",
            "opcodes": "",
            "sourceMap": ""
          },
          "deployedBytecode": {
            "linkReferences": {},
            "object": "",
            "opcodes": "",
            "sourceMap": ""
          }
        },
        "metadata": ""
      },
      "StateContract": {
        "evm": {}
      }
    }
  },

When setting the outputSelection to *, it again successfully compiles.

The same happens with the version v0.4.26 too.

This leaves me wondering if this actually is because of the above mentioned outputSelection compatibility or if there is something else underlying.

Identical Example

Another similar example with v0.4.26:

Chain: Goerli (5)
Address: 0x51745186A4216EB053BA2647B4f33fFDc013c1B1

Input JSON:
5-0x51745186A4216EB053BA2647B4f33fFDc013c1B1-solc-input.json.txt

Source Code and Metadata:
metadata.json.txt
Deployer3.sol.txt

@kuzdogan
Copy link
Member Author

Opened the issue ethereum/solidity#14214 in the Solidity repository as I couldn't really pin this down to 0.4.x versions only and it seems to be a larger issue.

As a mitigation, and since there have been many issues regarding this, setting the outputSelection to be both *.

kuzdogan added a commit that referenced this issue May 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪲 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant