2

As the question suggests, I'm curious about how to find statistics for:

  • what is the biggest contract by loc/bytecode size
  • what contract is currently taking up the most storage space on the chain.
zcaudate
  • 105
  • 7

2 Answers2

3

I was able to find that out via Google's BigQuery engine by running the following query:

SELECT
  contracts.address,
  SAFE_DIVIDE(SAFE_SUBTRACT(LENGTH(contracts.bytecode), 2), 2) AS bytecode_length
FROM
  `bigquery-public-data.crypto_ethereum.contracts` as contracts
ORDER BY
  bytecode_length
  DESC

The results show that the largest smart contract bytecode size is 24,576 bytes, which is also the size limit that was introduced in the Spurious Dragon hard fork.

Here are a couple of smart contracts with that size:

  • 0xb1effc011f8ed3df599f8cf2ec205d99e0544ce6
  • 0x38a4bded512eb5b115f8224e9830cac7124c209e
  • 0x99179faac2c7ce615a3cfeb13cfcd0aaf8d48871
  • 0xef323fbbc6342e6daede0b045bbd843e92edb528

enter image description here

Ahmed Ihsan Tawfeeq
  • 4,524
  • 2
  • 19
  • 47
  • I tried decompiling one of them and it seemed like the source code is only 50loc https://etherscan.io/bytecode-decompiler?a=0xb1effc011f8ed3df599f8cf2ec205d99e0544ce6. It seems really strange. – zcaudate Sep 22 '22 at 05:31
  • Would you know roughly how many loc of solidity would end up going over the limit? – zcaudate Sep 22 '22 at 05:37
  • @zcaudate From Solidity by Example: "Solidity storage is like an array of length 2^256. Each slot in the array can store 32 bytes." – Ahmed Ihsan Tawfeeq Sep 22 '22 at 15:37
  • @zcaudate The deployed bytecode is not stored in the storage layout. You get a clean slate of 2^256 storage slots when you deploy a smart contract. Each storage slot is 32 bytes long. – Ahmed Ihsan Tawfeeq Sep 22 '22 at 15:41
  • ok. so I guess my question is... how many lines of solidity code does it take to get up to the smart contract bytecode size limit of 24,576 bytes? – zcaudate Sep 23 '22 at 04:35
  • @zcaudate I don't think I could answer that. The Solidity code is compiled to assembly, which is the real code that runs. The assembly code you get from compiling the same Solidity file could change depending on which version of the Solidity compiler you're using and how many optimizer runs you have. The bytecode is simply another way to represent the compiled Assembly code. So instead of human-readable assembly, you get the hexadecimal representation of that assembly code. – Ahmed Ihsan Tawfeeq Sep 23 '22 at 15:29
  • thanks for your patience and appreciate your help with this issue! – zcaudate Sep 24 '22 at 04:12
1

Although I couldn't find statistics on what is the biggest contract by loc/bytecode size and what contract is currently taking up the most storage space on the chain, I found the relationship between transaction costs and contract size is that transaction costs are the costs for sending the contract code to the Ethereum blockchain, and they depend on the size of the contract.

See: What is the difference between transaction cost and execution cost in remix?

What I found are statistics of lists of projects on the Ethereum blockchain by total transaction fee, which could shed light on what is the biggest contract by loc/bytecode size and what contract is currently currently taking up the most storage space on the chain.

See: https://dune.com/agaperste/The-State-of-Ethereum-Network

Yongjian P.
  • 4,170
  • 1
  • 3
  • 10
  • sweet. that's really helpful. would you of any way to explore the memory layout of the blockchain? I'm trying to figure out how to query a mapping without knowing all of it's current keys beforehand. – zcaudate Sep 21 '22 at 03:13