Skip to content

jwasinger/eth-selfdestruct-analysis

Repository files navigation

Analysis of Selfdestruct Usage on Ethereum after the London Hard Fork

ethereum/EIPs#4758 is a proposal which changes the behavior of the EVM SELFDESTRUCT opcode and renames it to SENDALL. SENDALL removes the contract destruction aspect of SELFDESTRUCT while retaining the behavior which transfers the balance of the executing contract to a target recipient, and immediately returns execution to the calling contract.

There are two main use-cases for selfdestruct after the London hard fork:

  • Selfdestructable contracts with addresses generated by CREATE2 can be destroyed, and new contracts created at the same address. This can serve as a contract update mechanism.
  • Contracts can be created, used, and selfdestructed within the same transaction. These are referred to as ephemeral contracts.

Addresses where contracts were destroyed and then recreated (whether as a result of a contract redeployment or ephemeral contracts making use of the same address more than once) are referred to as a re-inited addresses.

Results

From genesis to block 12,799,316 (the time period looked at in the previous analysis work), there were 11304 contracts which created and redeployed child contracts, 69102 addresses which were re-inited one or more times.

Since London (block 12,965,000), 34 contracts redeployed child contracts, 233 contracts created ephemeral contracts at 97266 addresses, 235 addresses had multiple non-ephemeral contracts deployed at them. 1279 addresses where ephemeral contracts executed were re-inited.

Of all re-inited addresses and creators of re-inited addresses, 14 had nonzero Ether balances. Here are the ten addresses with the largest balances:

Address Ether balance Creator of re-inited contract re-inited contract Project
0x0000000000007f150bd6f54c40a34d7c3d5e9f56 1052.0346555690187 ✔️
0x36049d479a97cde1fc6e2a5d2cae30b666ebf92b 98.89128076172763 ✔️ Pine Finance
0x000000000035b5e5ad9019092c665357240f594e 33.67848284726566 ✔️
0x0000000099cb7fc48a935bceb9f05bbae54e8987 11.07584061230294 ✔️
0xd412054cca18a61278ced6f674a526a6940ebd84 7.271706101417892 ✔️ Pine Finance
0xf2d47e78dea8e0f96902c85902323d2a2012b0c0 3.3781819040953978 ✔️
0x00000000032962b51589768828ad878876299e14 3.051639286062525 ✔️
0xd7c8bde678ec968ae7e085b507f7d0affd27b1e8 0.20852379 ✔️
0xed63aeb5b66b47129532a3d56745387cc4d4a607 0.038416454655773064 ✔️

Some next steps for the analysis are:

  • Identifying contracts from the list of potentially-affected which hold large/valuable ERC20 balances.
  • Identifying currently-existing selfdestructable contracts which were deployed via CREATE2 and determining of these and their creators, which have large ERC20/Ether holdings.

Once there is a full list of potentially-affected contracts, further examination the solidity source or bytecode of these contracts can be useful.

Running the Analysis

The first step is to retrieve the raw dataset of contract creation / selfdestruct internal transaction traces from the BigQuery Ethereum dataset with the following query:

select block_hash, transaction_hash,  trace_id, block_number, transaction_index, from_address, to_address, trace_type, call_type, status, value from `bigquery-public-data.crypto_ethereum.traces` 
    where (trace_type='suicide' or trace_type = 'create')
    order by block_number asc, transaction_index asc

The dataset is somewhat large (30gb) and must be exported as multiple csv files to a GCS bucket. When exporting from BigQuery to GCS, choose data-*.csv as the naming format for the exported files. Download these csvs to a folder data-traces placed in the top-level directory of this repo. Execute the script rename-files.py to rename the downloaded files so that their data is ordered properly (i.e. the layout of the data in data-0001.csv, data-0002.csv, ... is chronological. when the files are downloaded from the storage bucket, the numerical prefix assigned to a given csv is somewhat random).

Execute the analysis by running analyze.py.

The analysis script producess these files as results:

  • creators-of-redeployed-addrs.csv - list of any contract that created an child contract which was redeployed.
  • creators-of-ephemeral-contracts.csv - list of accounts which created ephemeral contracts.
  • redeployed-addrs.csv - a list of addresses which had contract redeployments.
  • ephemeral-addrs.csv - a list of addresses where ephemeral contracts executed.
  • ephemeral-creators-which-reuse-addrs.csv - creators of ephemeral contracts that executed at re-inited addresses.

To get a list of Ether balances for all accounts in these files, execute query_balances_for_creators_and_reinited_addrs.py.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages