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

[CLI] Relative paths result in different contracts #4702

Closed
chriseth opened this issue Aug 6, 2018 · 5 comments · Fixed by #11545
Closed

[CLI] Relative paths result in different contracts #4702

chriseth opened this issue Aug 6, 2018 · 5 comments · Fixed by #11545
Assignees
Labels
bug 🐛 codegen error Compiler generates invalid code. Critical.

Comments

@chriseth
Copy link
Contributor

chriseth commented Aug 6, 2018

Input:

A.sol:

contract A {}

B.sol:

import "./A.sol";
contract B {}

solc --metadata ./A.sol B.sol results in:

======= ./A.sol:A =======
Metadata: 
{"compiler":{"version":"0.4.25-develop.2018.8.6+commit.7c9bfb62.mod"},"language":"Solidity","output":{"abi":[],"devdoc":{"methods":{}},"userdoc":{"methods":{}}},"settings":{"compilationTarget":{"./A.sol":"A"},"evmVersion":"byzantium","libraries":{},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"./A.sol":{"keccak256":"0x883c1af8f1ad6d7cdfb8aaed151eebcdd940c8dae0a659cb38054c7ec32ce890","urls":["bzzr://7ce182fe82cc04e1b5a9c5b29df9dd55ee945ee1879b2768926014ead7f5706c"]}},"version":1}

======= A.sol:A =======
Metadata: 
{"compiler":{"version":"0.4.25-develop.2018.8.6+commit.7c9bfb62.mod"},"language":"Solidity","output":{"abi":[],"devdoc":{"methods":{}},"userdoc":{"methods":{}}},"settings":{"compilationTarget":{"A.sol":"A"},"evmVersion":"byzantium","libraries":{},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"A.sol":{"keccak256":"0x883c1af8f1ad6d7cdfb8aaed151eebcdd940c8dae0a659cb38054c7ec32ce890","urls":["bzzr://7ce182fe82cc04e1b5a9c5b29df9dd55ee945ee1879b2768926014ead7f5706c"]}},"version":1}

======= B.sol:B =======
Metadata: 
{"compiler":{"version":"0.4.25-develop.2018.8.6+commit.7c9bfb62.mod"},"language":"Solidity","output":{"abi":[],"devdoc":{"methods":{}},"userdoc":{"methods":{}}},"settings":{"compilationTarget":{"B.sol":"B"},"evmVersion":"byzantium","libraries":{},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"A.sol":{"keccak256":"0x883c1af8f1ad6d7cdfb8aaed151eebcdd940c8dae0a659cb38054c7ec32ce890","urls":["bzzr://7ce182fe82cc04e1b5a9c5b29df9dd55ee945ee1879b2768926014ead7f5706c"]},"B.sol":{"keccak256":"0xac4c8a7250ed35c29ffa1b0f2c28e1454084ef3de7fe385a96763ee8faf1125f","urls":["bzzr://2b76fbe8200e4ca3c60410492f1bf1e594adad1bfe0c132063257c0ab06f8c3e"]}},"version":1}
@axic
Copy link
Member

axic commented Feb 25, 2019

@chriseth any proposal to fix this? Should have a well defined path cleaning step?

@chriseth
Copy link
Contributor Author

Yes, there is a well-defined path cleaning step, as can be seen through import "./A.sol" working properly. We just seem to not apply it from the commandline.

@chriseth
Copy link
Contributor Author

chriseth commented Sep 18, 2019

So to clarify: The issue here is not the import "./A.sol" but instead calling the compiler using solc ./A.sol B.sol instead of solc A.sol B.sol.

@chriseth chriseth changed the title Relative paths result in different contracts [CLI] Relative paths result in different contracts Aug 31, 2020
@chriseth
Copy link
Contributor Author

Related: #4623

@chriseth
Copy link
Contributor Author

We should not just turn the arguments into absolute paths but instead remove the current working directory (or the base path, if given) from the absolute path, if it is a prefix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 codegen error Compiler generates invalid code. Critical.
Projects
None yet
3 participants