Skip to content

Commit

Permalink
Fix verification logic (#1594)
Browse files Browse the repository at this point in the history
* Don't return false when auxdata differs in creation code but find by edited-recompilation

When a contract's creation code has for some reason a different auxdata, the current control flow returns false and abrubts the cborAuxdata position finding process.

Instead it should continue to find the positions by editing the contract and recompiling. The real auxdata is actually embedded inside the bytecode.

* Fix wrong match check in verification logic. Change logs

* Add comment
  • Loading branch information
kuzdogan authored Aug 27, 2024
1 parent 51d6750 commit aa7b4ca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 0 additions & 1 deletion packages/lib-sourcify/src/lib/CheckedContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ export class CheckedContract {
"The creation auxdata from raw bytecode differs from the legacyAssembly's auxdata",
{ name: this.name },
);
return false;
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions packages/lib-sourcify/src/lib/SourcifyChain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export default class SourcifyChain {
}

throw new Error(
'None of the RPCs responded fetching tx ' +
'None of the RPCs could successfully fetch tx traces for ' +
creatorTxHash +
' on chain ' +
this.chainId,
Expand Down Expand Up @@ -420,7 +420,9 @@ export default class SourcifyChain {
}

if (!creationBytecode) {
throw new Error('Cannot get creation bytecode');
throw new Error(
`Cannot get the creation bytecode for ${address} from the transaction hash ${transactionHash} on chain ${this.chainId}`,
);
}

return {
Expand Down
6 changes: 3 additions & 3 deletions packages/lib-sourcify/src/lib/verification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,16 @@ export async function verifyDeployed(
generateCreationCborAuxdataPositions,
recompiled.creationLinkReferences,
);
if (match.runtimeMatch === 'partial') {
if (match.creationMatch === 'partial') {
logDebug('Matched partial with creation tx', {
chain: sourcifyChain.chainId,
address,
runtimeMatch: match.runtimeMatch,
creationMatch: match.creationMatch,
creatorTxHash,
});
match = await tryToFindPerfectMetadataAndMatch(
checkedContract,
runtimeBytecode,
runtimeBytecode, // TODO: This is also weird we pass the runtime bytecode here
match,
async (match, recompiled) => {
await matchWithCreationTx(
Expand Down

0 comments on commit aa7b4ca

Please sign in to comment.