There is a widely known misconception that all contracts are immutable, that their ABIs are firm and we can always rely on the ABI we have to decode the contract logic. We can also trust that the contract is safe for us to interact with as it’s been audited… Well, the truth is far from that, at least for how the EVM stands as of now! There are proposals attempting to alter this behaviour.

Introduction

I came about this realization whilst trying to create a contract_creations table. More specifically after I realized that there is something called a self_destruct call (here). This specific call destroys* the contract and sends all remaining tokens stored in the contract to a designated address. This is not a problem at all if one could not redeploy bytecode (contract code) on top of the same address, but they actually can! That’s the problem!

https://tenor.com/view/frustrated-ugh-headache-gif-7532429">Frustrated

How can they do that you might ask? Well, it’s because of create2 the more deterministic functionality, allowing developers to re-deploy on top of the same address. But don’t take my word for it, let’s read about it.

TL:DR on CREATE vs CREATE2

Redeployed Contracts

Let’s look at contracts that have been redeployed on the Ethereum mainnet. I will also provide the code one can use on BigQuery to follow along with this investigation.

The following code snippet, when sorted by count_times_created descending yields the following results:

 in creation traces designates the  that is created.

to_address in creation traces designates the new_address that is created.

We can notice a few things from just looking at the top 10 by count_times_created:

  1. to_address is null???
    1. Possibly the rpc endpoint BigQuery is using does not have a fallback for fetching the new_address in some cases. Or something completely different. I do not believe that this is an EVM flaw, but just to be absolutely certain, let’s verify instead of believe (deep dive below):
      • To address is null Investigation
  2. The next 9 contracts have been deployed at least 488+ times! That blows my mind 🤯!

Different bytecode

We’ve updated our priors and we have seen that different contracts can be redeployed on top of the same address which is the side-effect or intended effect of the CREATE2 + self_destruct implementations.

https://forumstatic.oneplusmobile.com/opforum-gl/upload/image/front/thread/20220615/9786425/1089262911752765445/1089262911752765445.gif

To address duplicates with different bytecodes, use the first code snippet found here.

To address duplicates with different bytecodes, use the first code snippet found here.