-
Notifications
You must be signed in to change notification settings - Fork 187
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
Find reliable method for verifying contracts on Etherscan #1807
Comments
Turns out @kendricktan was working on this exact issue at Omisego (he was their devops lead after all) and seems to have an understanding of why verifying doesn't work sometimes. So maybe @kendricktan you can share your analysis of the actual problem to get the ball rolling? |
Tagging @chrismaree here as well. |
Verifying contracts on etherscan has been more of a horror story for me. I've made an example repository showcasing how slight changes to the contracts location/headers can lead to different generated bytecode. The example repository uses the Findings1. Contract directory location affects generated bytecodeThis is likely because of the contract metadata inside This in theory should not be too much of a issue because swarm hashes should not affect (in most cases) etherscan contract verification 2.
|
@kendricktan Even after fixing the ABIEncoderV2 issues, I've still run into mysterious errors. The one process that has worked in the past is to the compile the flattened contract (after fixing the pragma errors as you list above) in remix, deploy via Remix, and use that ABI/bytecode to verify the contracts. If there's a way to see the Remix source code or dynamically leverage it, this might be the best strategy |
@nicholaspai this is the code Remix uses for compiling: https://github.com/ethereum/remix/blob/master/remix-solidity/src/compiler/compiler.ts They're just using |
@kendricktan I think this is really solid analysis -- +1!
Same. The sensitivity of the compilation system to minute and non-logic-related details has always been quite worrisome to me.
Does this only apply to code that sits below the ABIEncoderV2 declaration or does it affect all code in the file? If it's the former, it might work to just move all of the contracts that had ABIEncoderV2 declared in them below the declaration and move those that didn't above the declaration when trying to verify. Although, that may be just as hard as pre-flattening the files before compilation 🤷.
Yeah, I think this makes sense. Mimicking the exact source that Etherscan sees is probably prudent if we want our compilation system to match consistently, even if it is a little strange to flatten in the local compilation process. This could be why we've seen Remix work. I do have one final piece of confusion, however. Etherscan has a multi-file upload verification, where you can upload many files that import one another and it will compile them that way. This should in theory almost exactly match what we're doing locally. However, I've found that even that fails to match sometimes (although it has also fixed the problem on occasion too). The difference here may be caused by the metadata differences you mentioned in 1 since the directory structure changes to one single flattened directory. Note: when using this method, you do have to rework the imports so they work in a flat dir rather than our directory structure (we wrote a quick-and-dirty script to do this). That context aside, I think a good testing ground to ensure the flattening method you have proposed will work is compiling a pre-flattened Thoughts? |
Remix uses
It seems like it'll affect all code in the file. In the example repo, the generated bytecode from contracts A, and D differs quite significantly in structure (more than just a swarm hash difference). For context, Contract D is basically Contract A, but with
Sounds like a horror story 😛
Sounds good! |
A bit of an update. Without any additional scripts, I've managed to verify the contracts ExpiringMultiPartyCreator and Voting on etherscan. StepsWithout any additional config, in the core directory
"settings": {
...
"libraries": {
"contracts/financial-templates/expiring-multiparty/ExpiringMultiPartyLib.sol": {
"ExpiringMultiPartyLib": "0xB6693A4cB6CFd70680145e733388C7FE8b778841" // ExpiringMultiPartyLib deployed address
}
},
...
} |
@kendricktan Is there an easy way to determine the ABI-encoded constructor arguments passed into contracts? Or do we just use an external tool |
@nicholaspai iirc etherscan automatically finds the ABI-encoded constructor agrs for you. |
Why
We've repeatedly had issues deploying via truffle and using truffle flattener to verify the contracts on etherscan. We should find a new pipeline that reliably works.
How
I think either a new flattening or a new deployment method will be required.
Resolution
Contracts are verified either programmatically or manually, but with an obvious, always-working process.
Difficulty Score [1-10]
6: ~1 day or 7: ~3 days (rough estimate, lots of uncertainty)
The text was updated successfully, but these errors were encountered: