Closed mikeshultz closed 4 years ago
This is known behaviour. You tell the compiler: "Compile the file called a/SafeMath.sol
", so this is how the file is known to the compiler. Any imports performed will also call the file by that name and because of that, this fact has to be hashed into the compilation artefact to make the build reproducible (otherwise, imports might resolve to different files).
If you want to abstract away the directories a / b / c, you have three options:
--base-path
option to tell the compiler where the root of its virtual filesystem isI'm curious about the hashing logic. What does the bytecode care about source imports? Any interfaces or library code should be effectively integrated or placeholdered at the point of bytecode output, no? I get why placeholder hashes might include file paths since it's very relevant, but not why that might effect contract bytecode. If you happen to move source files around but leave execution instructions all the same, I think most of us would expect the build to output the same bytecode at the end.
Not a big deal to me, it's just unintuitive. Thank you for the options, those will be helpful.
Of course, there are changes to filenames and paths that should not change the semantics of the contract, but if you exchange the names of to files, then this can have a big influence, especially if they define the same symbols. The idea is that we want a hash in the bytecode that basically is a watermark and allows re-compilation in exactly the same way as it was done before deployment, including the names of all files and all comments in the source code.
Description
I'm seeing non-deterministic output according to filesystem path when compiling libraries. I've been able to reproduce it with multiple versions.
Environment
Steps to Reproduce
I put together a test case repository. If you run
run.sh /path/to/solc
it'll compile 3 identical libraries in 3 different directories displaying md5 hashes of the source contract and output.Example from my last run:
This may be related to #168 which was closed before resolution.