-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Different bytecodes for the same contracts #6487
Comments
@sammyne Thanks for your report. I'll have a look! |
This is expected behaviour. The reason behind this is that depending on the paths used, import statements will behave differently. So the (relative) paths are exposed as the unique names of contracts when compiling. Since the bytecode contains the metadata information of contracts, this also affects the bytecode. |
Same here, https://snowtrace.io/contractdiffchecker?a2=0x0804Dd62deb46F11cDf47997778527B067E0D054&a1=0xB43C0e6460DAE61280fd4e6E793ae43Ed72AFA57, only difference I saw is that one had optimization enabled and other one did not. Could this cause that? |
These contracts are not identical. Parameters passed to the inherited constructor differ: constructor() ERC20("WAVAXPrinter", "WAVAXP", 9) { vs constructor() ERC20("SonOfDAO", "SOD", 9) { |
Aah yeah sorry didn't mean it like that, I meant the overall bytecode is completely different while only the constructor is different in the human readable code |
What specifically do you mean by "overall bytecode"? The compiler gives you separate bytecode for each contract it finds. So if constructor parameters are different, this particular contract will have different bytecode even if everything else in it is identical. Other contracts in the same compilation should have identical bytecode (if you ignore the metadata). Please try to compile with |
Description
Bug
Given the same contracts file but different path, compile with
solc
generate different bytecodesExpectation
The same contract manifest should produce the same bytecodes
Environment
Steps to Reproduce
To ease the reproduction, I have make a repository as solidity-playground containing the relevant files below, and the steps for reproduce the problem found go as follows
Clone the repository and change into the repository directory
In the root directory, compile the
World
contract described ascontracts/World.sol
with bytecodes output to current directorysolc --bin --optimize contracts/World.sol -o .
This should give us two files
Hello.bin
andWorld.bin
containing bytecodes for the respective contractsChange into the
contracts
folder, and compile theWorld.sol
with bytecodes output to that foldersolc --bin --optimize World.sol -o .
This should also give us two files
Hello.bin
andWorld.bin
containing bytecodes for the respective contractsComparison tells difference
Hello.bin
andcontracts/Hello.bin
withdiff
would tell us differenceWorld.bin
andcontracts/World.bin
withdiff
would tell us differenceThe text was updated successfully, but these errors were encountered: