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

Source name instead of contract name is being used for contracts in .yul files #243

Closed
elfedy opened this issue Jan 7, 2025 · 0 comments · Fixed by #245
Closed

Source name instead of contract name is being used for contracts in .yul files #243

elfedy opened this issue Jan 7, 2025 · 0 comments · Fixed by #245
Labels
bug Something isn't working

Comments

@elfedy
Copy link

elfedy commented Jan 7, 2025

🐛 Bug Report

📝 Description

When compiling a .yul file, zksolc will name the contract with its source name vs the contract name on its output.
The latter is what is done with Solidity files and what solc does with yul, so any tools making the assumption that zksolc does the same may have unintended behavior or have to adapt ad hoc to this. Source file names in the input are often given as paths (for example in Foundry) so the contract name being a path instead of a raw string may also lead to unexpected behavior as well.

🔄 Reproduction Steps

Compile a contract via standard json with a yul file on it's input:

sample input:

{
    "language": "Yul",
    "sources": {
        "File.yul": {
            "content": "object \"Contract\" {\n  code {\n    datacopy(0, dataoffset(\"Contract_deployed\"), datasize(\"Contract_deployed\"))\n    return(0, datasize(\"Contract_deployed\"))\n  }\n  object \"Contract_deployed\" {\n    code {\n      calldatacopy(0, 0, 36)\n    }\n  }\n}"
        }
    },
    "settings": {
        "viaIR": false,
        "codegen": "yul"
    }
}

🤔 Expected Behavior

Output uses contract name as the field that contains the compilation result for the contract like solc. This is also the behaviour for Solidity files.

Output for compiling the example with solidity:

{
  "contracts": {
    "File.yul": {
      "Contract": {
        ...
      }
    }
  },
  "errors": []
}

Note that Contract is used for the compilation result of the contract

😯 Current Behavior

File name is used for as the field that contains contract compilation results, instead of contract name:

{
  "contracts": {
    "File.yul": {
      "File.yul": {
       ...
     }
  },
  "sources": {
    "File.yul": {
      "id": 0
    }
  },
  "zk_version": "1.5.7"
}
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

Successfully merging a pull request may close this issue.

1 participant