ethereum / sourcify

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

Fix the check for already existing partial match #1625

Closed marcocastignoli closed 14 hours ago

marcocastignoli commented 1 week ago

Saving a new match with creationMatch better than the existing one doesn't work.

There are two places in which we check for already existing partial match:

  1. In storeMatch inside StorageService.ts https://github.com/ethereum/sourcify/blob/498821296528660df41eb7a4c7bbe83b15245491/services/server/src/server/services/StorageService.ts#L246-L258

  2. In updateExistingVerifiedContract inside AbstractDatabaseService.ts https://github.com/ethereum/sourcify/blob/d7c3ac708ce8badc09c369edd3e74a0260379753/services/server/src/server/services/storageServices/AbstractDatabaseService.ts#L452-L481

The second case is working fine but the execution can't reach it because it exits when reaching the first case.

We cannot remove the first case because otherwise we could have different contracts stored for each storage services, we need a centralized check in storeMatch before continuing calling every enabled storage service.

So in storeMatch, instead of evaluating the combined match status, we can verify if either the runtime or creation match is better, and ensure that neither the runtime nor creation is worse than the previous match.

TODO