When Ethereum changes from proof-of-work to proof-of-stake, there are a few changes to the application layer that developers should be aware of. Some of these changes could impact the security of protocols that are currently safe under ETH 1 but not on ETH 2.
TL;DR
- Block time is decreasing from a variable ~13 seconds to exactly 12 seconds. If your contract relies on the average block time in its formula, consider updating it to reflect this change.
- The 0x44 DIFFICULTY opcode is being supplanted by PREVRANDAO. This
change is backwards compatible with contracts that use
block.difficultyas a source of pseudorandomness, so developers do not have to make changes. - Most importantly, consecutive slot miner extractable value (MEV) may invalidate prior security assumptions. Developers should presume that an attacker may control two consecutive blocks and reassess their security logic with this in mind.
In this article, we’ll cover each of these changes in depth as well as potential scenarios in which they could cause problems. We will progress through the changes from the least to the most important because the last two are interrelated.
Block time
The simplest change for developers to consider is the reduction in block time. Block time↗ refers to the amount of time it takes to mine a new block.
The average block time will change from ~13 seconds with a fair amount of variance to exactly 12 seconds except when a slot is missed due to a validator being offline or not submitting a block in time.
Suggestions for developers:
If your smart contract uses the average proof-of-work block time you may want to consider incorporating the 12-second proof-of-stake block time in your calculations.
Many popular DeFi applications use formulas that rely on the average block time. For example, Compound’s formula↗ to calculate interest payments uses a blocksPerYear value↗ that is derived from a ~15-second block time. After the merge, this formula could be updated to use a 12-second block time to calculate interest payments more accurately.