ethereum / sourcify

Decentralized Solidity contract source code verification service
https://sourcify.dev
MIT License
783 stars 399 forks source link

Support for Vyper verification with the current implementation of `CheckedContract` #1673

Open marcocastignoli opened 1 month ago

marcocastignoli commented 1 month ago

We can support Vyper in the current implementation of CheckedContract without needing to rewrite the entire class, as long as we are willing to sacrifice some code structure elegance in CheckedContract. For more details, refer to issue #1628.

Given that we'll have to rewrite CheckedContract soon, I think that making the code a bit more messy in order to support Vyper is not a big deal.

marcocastignoli commented 1 month ago

Proposal 1: making CheckedContract an abstract class and implementing SolidityCheckedContract + VyperCheckedContract

CheckedContract is actually used by the server in APIs handlers (not important for Vyper because we'll create a custom API), VerificationService.verifyDeployed (used to verify a contract) and StorageService.storeMatch (used to write the contract in active storage services).

I would create an abstract class for CheckedContract starting from all the mandatory properties/methods needed by verifyDeployed and storeMatch, then we can implement SolidityCheckedContract extends CheckedContract and VyperCheckedContract extends CheckedContract. Passing these new classes, verifyDeployed and storeMatch will check if SolidityCheckedContract functions are available before using them (e.g. tryToFindPerfectMetadata or accessing .metadata).

Each CheckedContract implementation will implement its own constructor, recompile and createJsonInputFromMetadata function.

marcocastignoli commented 1 month ago

Let's implement Vyper support following the proposal above. Regarding the StorageServices:

Let's keep track of the implementation in this issue.