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 and not * leads to empty compiler output in <=0.5.8 #14214

Open
kuzdogan opened this issue May 11, 2023 · 2 comments
Labels

Comments

@kuzdogan
Copy link
Member

kuzdogan commented May 11, 2023

Description

Summary:

Providing a contract name in the contract selection of the outputSelection field of the JSON input is outputting empty JSON fields in versions <=0.5.8.

Doesn't work:

"outputSelection": {
  "*": {
    "Storage": ["*"]
  }
}

Works:

"outputSelection": {
  "*": {
    "*": ["*"]
  }
}

Details

I've encountered multiple issues about the outputSelection.

Digging into the issue ethereum/sourcify#1017 in Sourcify, I came across this issue which affects versions <=0.5.8 but not >=0.5.9. I couldn't find any related changes in this version about the outputSelection so I'm opening the issue.

To reproduce, here's the compiler input JSON:

{
  "language": "Solidity",
  "settings": {
    "optimizer": { "enabled": true, "runs": 200 },
    "outputSelection": {
      "*": {
        "Storage": ["evm.bytecode"]
      }
    }
  },
  "sources": {
    "Storage.sol": {
      "content": "pragma solidity >=0.4.0 <0.9.0;\n\ncontract Storage {\n\n    uint256 number;\n\n    function store(uint256 num) public {\n        number = num;\n    }\n\n    function retrieve() public view returns (uint256){\n        return number;\n    }\n}\n"
    }
  }
}

This would generate the following unexpected output:

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

Changing the "Storage" field in the JSON to "*" will lead to an expected compiler output with bytecode.

The contract is fairly simple and attached here:
Storage.sol.txt

Environment

  • Compiler version: affected <=0.5.8
  • Target EVM version (as per compiler settings): default
  • Framework/IDE (e.g. Truffle or Remix): Both in 0.5.8+commit.23d335f2.Darwin.appleclang downloaded with solc-select. I was able to reproduce in Remix, as well as in Sourcify, which uses solc-js on Mac ARM.
  • Operating system: MacOS ARM 64bit
@ekpyron
Copy link
Member

ekpyron commented May 15, 2023

Since we won't touch old releases, the fix for this will probably be something similar to ethereum/solc-js#690, although we may want to come up with a nicer cross-platform way to do such input/output translations.

@kuzdogan
Copy link
Member Author

Right. Putting this for the record and if it is indeed a bug, maybe to be listed in bugs.

We just went forward with the workaround of using * on all levels, so all fine if this should be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants