What are Ethereum commitment levels?
The Beacon Chain introduces two new Ethereum commitment levels, safe and finalized, that are used to label blocks alongside the existing latest, label from the PoW chain. The latest block tag is the most recent block to be added to Ethereum's blockchain, also known as the "head," the safe commitment level is one epoch (i.e. 32 slots) behind the current epoch, and the finalized commitment level is one epoch behind the most recently marked safe block.
Ethereum commitment levels are helpful because they offer useful primitives for web3 developers to query unlikely-to-reorg blocks enabled by Ethereum’s Proof-of-Stake algorithm changes.
Because developers have higher guarantees that justified and finalized blocks are unlikely to be reorged, they can build stronger assumptions into their smart contracts and decentralized applications.
What is a block number?
The block number is a numerical value used to designate the order of a block added to the blockchain. For example, if the pending block being built and validated has a block number of 100, the most recently validated block (i.e. the latest block) would have a block number of 99.
What is a chain re-organization (re-org)?
A chain re-organization is when a block that was added to the canonical chain (i.e. main chain, or longest chain) is removed and replaced by a different block. Reorgs impact settlement finality because blocks added to the canonical chain can be changed through a reorg.
Because reorgs can happen from exploits and as a result of Maximal Extractable Value (MEV), trusting that the latest block is settled is a difficult assumption for developers to make.
With the migration from Proof-of-Work to Proof-of-Stake, Ethereum’s Beacon chain introduced safe and finalized block commitment levels to provide developers with stronger guarantees.
What is an epoch?
In the post-merge Ethereum environment, the Beacon Chain introduces slots, which are opportunities for new blocks to be built, and epochs which are equal to 32 slots. Because a new block can be validated exactly every 12 seconds, an epoch is equal to 6.4 minutes.
During each epoch, the Beacon Chain randomizes a committee of validators to attest to the validity of blocks being added to the blockchain. The safe and finalized block commitment levels are determined based on epochs.
While there are 32 slots in each epoch, on rare instances (less than 1%), a block might not get validated in every slot, so some epochs may have less than 32 blocks. One example is if the randomly chosen validator is not online.
What are Ethereum commitment levels?
Ethereum commitment levels are tags used to label validated blocks as either latest, justified, or finalized, which offers developers certain guarantees with regards to how likely the blocks will be reorganized.
The latest block is the most recent block to be built and validated by Ethereum validators. The latest block should be used with caution because there are no guarantees that the Beacon Chain will not get reorganized, and this block becomes an Uncle Block, or a block that was not added to the canonical chain.
The safe block is a block that has received attestations from two-thirds of Ethereum’s validator set. Safe blocks are understood as unlikely to be reorged.
For example, one of the few ways safe blocks could experience a chain reorganization is if there is a large-scale, coordinated attack on the network.
A finalized block is a justified block that is 1 epoch behind the most recently justified block. Finalized blocks are extremely unlikely to be re-organized, with the only exception being if a two-thirds majority of validators finalize a competing chain of blocks.
How are safe and finalized commitment levels determined?
Safe and finalized commitment levels are determined by the completion of epochs. Let’s imagine the first three epochs (epoch 0, 1, and 2) after The Merge to visualize how safe and finalized blocks work.
- Epoch 0 = blocks 0-31
- Epoch 1 = blocks 32-63
- Epoch 2 = blocks 64-95
- Epoch 3 = blocks 96-127
Let’s assume the latest block is block 96, which marks the beginning of epoch 3 and the end of epoch 2.
Because block 96 includes attestations (i.e. votes from validators that signal the proposed canonical block head is true) for block 64, once the Beacon Chain receives attestations from two-thirds of the validators, block 64 is labeled as justified (safe).
Once block 64 is labeled is justified and marked safe, the previously justified block is marked as finalized. Because safe and finalized blocks occur at the beginning of epochs, block 32 (the first block of epoch 1) is marked finalized.
Here’s another way to visualize it if the current block number is 96:
- Block 96 (start of epoch 3) = latest
- Block 64 (start of epoch 2) = justified (safe)
- Block 32 (start of epoch 1) = finalized