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

Fix creation bytecode perfect matching #1769

Open
kuzdogan opened this issue Dec 4, 2024 · 0 comments
Open

Fix creation bytecode perfect matching #1769

kuzdogan opened this issue Dec 4, 2024 · 0 comments
Labels
🪲 bug Something isn't working

Comments

@kuzdogan
Copy link
Member

kuzdogan commented Dec 4, 2024

While discussing if it's appropriate to have "perfect/partial" match for creation bytecode, we encountered a potential bug. In the code below, the creation bytecode will be "perfect"ly matched only if it has a metadata hash at the very end of the bytecode. This is correct for the runtime bytecode but not necessarily true for the creation bytecode. For the creation bytecode this could be anywhere.

We can still take our chances to see if it's at the end of the bytecode, which is quite often, but otherwise we need to find where it is with findAuxdataPositions and also check if the auxdata has a metadata hash.

  if (match.onchainCreationBytecode.startsWith(recompiledCreationBytecode)) {
    // if the bytecode doesn't end with metadata then "partial" match
    if (endsWithMetadataHash(recompiledCreationBytecode)) {
      match.creationMatch = 'perfect';
    } else {
      match.creationMatch = 'partial';
    }
    logDebug('Found creation match', {
      chainId: match.chainId,
      address,
      creationMatch: match.creationMatch,
    });
  } else {
@kuzdogan kuzdogan added the 🪲 bug Something isn't working label Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪲 bug Something isn't working
Projects
Status: Triage
Development

No branches or pull requests

1 participant