-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
--extra-output metadata
option outputs different metadata than the expected compilation JSON output with bytecode_hash = "ipfs"
#1738
Comments
Try bytecodehash: none |
thanks for reporting looks like gakonst/ethers-rs#1307 only fixed the problem partially. |
Ref #1315 |
should be fixed by 1317 |
thanks for the quick turn around @mattsse ! Should I expect the |
@mattsse what's the easiest way for me to test this fix? |
we haven't bumped it yet on foundry the easiest way would be to build it forge yourself with patched ethers is by following this: https://github.com/foundry-rs/foundry/blob/master/Cargo.toml#L52 then |
@mattsse Thank you! the metadata output now has relative paths has expected. However, I'm still not getting a match between the output metadata IPFS hash and the IPFS hash appended to the bytecode by solc. In my investigation, I found a few issues in Thank you again for your hard work. |
@mattsse FYI, opened gakonst/ethers-rs#1325 - the serialization of the compiler metadata output is altering its original contents, resulting in a different IPFS hash than the one that gets appended to the bytecode. |
Is this solved? |
Just tested it today. The new rawMetadata field is now present in the output. I would suggest writing a test comparing the raw metadata and the parsed one. There's still some differences. Last one i noticed is a missing |
closed by gakonst/ethers-rs#1365 which added metadata string as raw string |
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (4fcd7e0 2022-05-26T00:04:48.079145Z)
What command(s) is the bug in?
forge build
Operating System
macOS (Apple Silicon)
Describe the bug
When outputting the solc compilation metadata using
--extra-output metadata
or--extra-output-files metadata
the resulting metadata is not matching the bytecode IPFS hash of the compiled contract.To reproduce in a fresh project:
then inspect the json output in
out/Contract.sol/Contract.json
.I've done the same setup with hardhat and raw solcjs, both produce the expected metadata that matches exactly the IPFS hash appended to the bytecode.
For the same, empty contract, here's the metadata that
hardhat
outputs:and here's the metadata that
forge
outputs:Both hardhat and solcjs output metadata with relative paths, but forge outputs absolute paths. This seems strange to me as this metadata is supposed to be used to help re-compile the contracts on other machines, absolute paths make no sense to me here.
I've looked at the ethers-rs source and have noticed the function: with_stripped_file_prefixes
This seems relevant to my problem, is it possible that forge is not calling this function to strip the base paths out of the compilation artifacts, therefore causing a mismatch between the IPFS hash of the metadata and the IPFS hash appended to the bytecode by the compiler?
Might be totally wrong on this, but it's my best guess.
Any help on figuring out this mystery would be greatly appreciated, I can provide sample test code to compare extracted IPFS hashes from bytecode and computed IPFS hashes from a file if it helps.
The text was updated successfully, but these errors were encountered: