Skip to content
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

Verification flow refactoring #1845

Draft
wants to merge 9 commits into
base: staging
Choose a base branch
from

Conversation

marcocastignoli
Copy link
Member

This is the main pull request for the verification flow refactoring. Smaller feature-specific pull requests will be merged into this branch before it is finalized and merged into the staging environment.

See #1665 for more details

@marcocastignoli marcocastignoli linked an issue Jan 8, 2025 that may be closed by this pull request
kuzdogan and others added 4 commits January 15, 2025 14:21
* Init class

* Init SolidityMetadataContracts, split zipUtils and processFiles

* SolidityMetadataContract: create dummy Compilation, add fetchMissing methods

* Add tests for zipUtils, Fix directories being in `files` array

* Add fetchUtils tests

* Run tests both under test/*.spec.ts and in subfolders test/**/*.spec.ts

* Remove `outputSelection` to be handled by the Compilation class

* Fetch missing before creating the Compilation

* Rename everything `check..` to `create...` in validation ie. SolidityMetadataContract

* Try first assembling the contract without variations, only try after if it doesn't work

* Rename metadata2Provided to metadataPathToProvidedFilePath
* Add Compilation classes and types

* Add tests

* Refactor compilation classes to unify compile methods and remove deprecated properties

- Renamed `recompile` methods to `compile` across `AbstractCompilation`, `SolidityCompilation`, and `VyperCompilation` classes for consistency.
- Removed unused properties such as `metadataRaw`, `creationBytecode`, and `runtimeBytecode` from `AbstractCompilation`.
- Updated related methods to utilize new `getCreationBytecode` and `getRuntimeBytecode` methods.
- Cleaned up `CompilationTypes` by removing `RecompilationResult` interface.
- Adjusted tests to reflect changes in method names and ensure functionality remains intact.

* Refactor AbstractCompilation to improve error handling and logging

* always add 0x to get...Bytecode( functions

* fix PR suggestions

* Update packages/lib-sourcify/src/Compilation/AbstractCompilation.ts

Co-authored-by: Kaan Uzdoğan <kaanuzdogan@hotmail.com>

* fix tests

* enable all tests

---------

Co-authored-by: Kaan Uzdoğan <kaanuzdogan@hotmail.com>
* push vyper tests (still need refactoring)

* Implement solidity test to get 100% coverage

* Refactor Vyper tests

* refactor solidity tests

* Update packages/lib-sourcify/src/Compilation/VyperCompilation.ts

Co-authored-by: Manuel Wedler <34456797+manuelwedler@users.noreply.github.com>

* Update packages/lib-sourcify/test/Compilation/VyperCompilation.spec.ts

Co-authored-by: Manuel Wedler <34456797+manuelwedler@users.noreply.github.com>

* fix duplicate check

---------

Co-authored-by: Manuel Wedler <34456797+manuelwedler@users.noreply.github.com>
@ethereum ethereum deleted a comment from cshein45 Jan 24, 2025
marcocastignoli and others added 4 commits January 27, 2025 10:22
* Add tests for SolidityMetadataContract

* use real SolidityCompilation class in SolidityMetadataContract

* fixes from PR review
* implement Verifcation.ts

* Refactor Verification.ts

* Add tests

* Add more tests

* Add comment to tests

* Add Vyper tests in Verification

* refactor Verification class

* handle ContructorTransformation

* add comment

* Refactor runtime bytecode matching and add call protection transformation

* Refactor Verification class to use getter methods and improve encapsulation

* Refactor AbstractCompilation to use protected properties and getter methods

* Move check transformation functions into Verification class
Refactor project structure and import paths in lib-sourcify

* restore old `verification.ts` tests

* fix constructor arguments trasformantion tests

* restore old `types.ts`

* add VerificationError class

* Implement Vyper constructor argument transformation test

* Pass forceEmscripten option to compilation call

* Split library map into runtime and creation maps

* replace expectMatch with expectVerification

* fix "should verify a contract with viaIR:true, optimizer disabled, and compiler <0.8.21" test

* Add test for library verification with call protection transformation

* fix call protection test

* increase coverage

* add missing tests from verification.spec.ts increasing coverage

* Refactor bytecode transformations and verification logic
- Extracted transformation functions from the Verification class to a separate module
- Added a new SolidityBugType enum to handle specific compilation scenarios
- Improved error handling for RPC unavailability

* fix linting

* Refactor error handling and type definitions in Sourcify library

* Update error handling for bytecode fetching in Sourcify verification

* Remove unnecessary compilationTarget deletion in SolidityCompilation

* Refactor bytecode matching method signature and remove unused context interface

* Improve bytecode matching readability with descriptive variable names

* Remove unused getter abiEncodedConstructorArguments in Verification class

* Refactor Solidity settings type and improve bug handling in verification

* Update SolidityBugType and improve error handling in verification tests

* Renamed functions in Transformations.ts to use 'extract' prefix instead of 'checkAndCreate'

* Simplify extra file input bug detection and remove redundant error handling

* Refactor Solidity metadata and compiler settings types

* fixes for PR comments

* Validate the bytecode length for Solidity and Vyper compilations before proceeding with bytecode matching

* do not use existing transformations/values in `matchBytecode`.

* Fix extra-file-input-bug at bytecode mismatch error

* fix `should return null match when there is no perfect match and no auxdata`

* fix "maliciously verify with creation bytecode that startsWith the creatorTx input" test

* fixes after PR review

* Improve source file reading and verification error handling

- Update source file reading to support nested directory structures
- Clarify error message for bytecode matching with no auxdata
- Improve test description for bytecode matching scenario

---------

Co-authored-by: Manuel Wedler <manuel@wedler.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Milestone] Refactoring the Verification Flow
2 participants