-
Notifications
You must be signed in to change notification settings - Fork 53
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
Refactor: replace dapp-tools with foundry for spell flattening #391
Conversation
Current state of the flattening: running Spotted differences:
|
It doesn't matter. Each contract or library bytecode is a separate "entity". What the verifier does is to check against all bytecodes generated by the compilation and match it against the contract under verification. |
This PR implements two small flattener features mentioned in makerdao/spells-mainnet#391 (comment) 1. Combine pragmas from different sources into one pragma so that version restrictions are kept the same before and after flattening 2. Comments specifying original source file of the flattened code (`// src/File.sol`)
Do you refer to some known implementation of the verifier that does it this way? |
To be honest, I don't know about the implementation details of any verifier tools, but I'm inferring based on how smart contracts are deployed on-chain. Each contract/library is a separate entity in the state trie, with their own nonce, balance and bytecode. I'm guessing that what any verifier tool does is:
The change in the order of declaration of the contracts could potentially just impact the order under each compiled bytecode is compared against the one on-chain, but not the final result. |
I'm not fluent in Rust, but Blockscout's verifier – that does roughly what I'm trying to describe – can be found here: |
Since goerli PR can't proceed (as goerli is not mining any blocks and was officially deprecated), we can try to use sepolia to validate flattening correctness. |
While temporary changing hardcoded network ids in various scripts in order to deploy the spell to Sepolia, I've realised that we first need to deploy ExecLib in order for the deployment command to work, while ExecLib depends on the chainlog to be deployed, which blows up the scope of this PR and doesn't actually help others to review it. To merge this sooner, my suggestion is to test code flattening functionality locally (i.e. flatten a spell in the PR vs master and compare flattened code or the compiled binaries). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I couldn't find any other differences than already reported ones hence approve
Description
This PR implements minimal changes required to remove dependency on dapp.tools and replace it with foundry commands (ie
hevm
withforge
,seth
withcast
).In order to try out this PR, one have to install a foundry build containing the fix with rewritten implementation of the flattening logic, eg:
Or a later version that also includes this major fix.