Data Availability (DA) using Celestia
Introduction
Rollup reduces transaction costs and increases Ethereum's throughput by processing transactions off-chain. Rollup transactions are compressed and posted on L1 in batches. Batches represent thousands of individual off-chain transactions in a single transaction on L1. This reduces congestion on the base layer and reduces fees for users.
However, it is only possible to trust the 'summary' transactions posted to L1 if the state change proposed can be independently verified and confirmed to be the result of applying all the individual off-chain transactions. If rollup operators do not make the transaction data available for this verification, then they could send incorrect data to L1.
This problem is referred to as the data availability problem. In fact, if it is possible to verify that the data corresponding to a rollup block is available directly on the L1, then anyone can take the transaction data and recompute the correct rollup state. The data availability problem is particularly interesting for rollups as the rollup itself operates as an off-chain database and if the rollup operators do not post the data on a Data Availability layer such as the L1, then it becomes impossible to verify the rollup state.
A cheaper and more scalable rollup using Celestia as Data availability layer
The most obvious DA option is to use a base monolithic chain such as Ethereum. Full nodes in a monolithic network share and hold raw transaction data that gets included in each block by a validator. With that data, a full node can recompute the chain’s state and compare it with any state root committed by a network validator. As a result, even in the absolute worst-case when the validator network is compromised and produces an invalid block, a full node can reject the block at the social layer.
However, any monolithic chain that performs execution, consensus and ensures data availability all on one single P2P layer is often not optimised for either and hence can be costly if used for data availability needs.
For context, Arbitrum One pays about USD 112k per day to Ethereum for its DA needs. This is about USD 0.15 per transaction on average, considering the average daily transaction volume on Arbitrum One.
There are many applications, such as on-chain gaming, for which a transaction cost of USD 0.15 would be completely unacceptable. As a result, new types of networks optimized for data availability are being built. One such solution is Celestia.
Celestia is a data availability (DA) layer that provides a scalable solution to the data availability problem. Two key features of Celestia's DA layer are data availability sampling (DAS) and Namespaced Merkle trees (NMTs). Both features are novel blockchain scaling solutions: DAS enables light nodes to verify data availability without downloading an entire block; NMTs enable execution and settlement layers on Celestia to download transactions that are only relevant to them.
Integrating Celestia into AltLayer
At AltLayer, we are creating modular rollups. One example will be using Celestia as the data availability layer for rollup created by AltLayer rollups-as-a-service platform to lower the costs required for data availability.
Workflow
We have developed a service that performs the following workflow
1. Initialisation
The service first retrieves the genesis information and node version of the rollup. It posts both information into Celestiab (similar to step 4) and updates the smart contract with the block height at which the data is stored.
2. Retrieval of blocks data from L2 rollup
The goal here is to retrieve sufficient data from the L2 to commit to DA layer such that the L2 rollup can be reconstructed in a disastrous event. To do that, the data availability service will constantly fetch blocks and proof of validity in batches.
3. Compressing blocks data
To minimize data cost, block data are compressed using zlib
compression library. To achieve better data compression efficiency, batch size can be increased. For example, compressing a batch of 2 blocks will result in a 48% data size reduction. If the batch size is increased to 100 blocks, the reduction increases to 67%.
4. Posting data to Celestia
To post data,
Set up a Celestia light node. Light nodes ensure data availability in particular,
Light nodes ensure data availability by
Listens for new block headers and relevant DA metadata
Data availability sampling on the received headers
Specify a namespace, version and commitment
Post your data to Celestia DA using
blob.Submit
Sample query:
Celestia API will return the block height at which the data is posted
5. Tracking block height where data is stored
To track which L2 block number corresponds to the block height at which the data is posted to the smart contract will be deployed on L1. The smart contract will maintain a block number mapping to Celestia block height.
To do that, the service calls set()
on the smart contract and populate it with the related data.
key
: Start block number for this batchvalue
: block number at which the data is stored into celetiametadata_
: End block number for this batch
Full contract code:
6. Reconstruction of chain
From time to time, there may be a need to reconstruct back the chain. It can be due to
disastrous events causing the node operator to be down indefinitely
malicious node denying or returning invalid query results to the challenger
In such a case, the rollup can be reconstructed
Retrieve genesis information and node version by calling
blob.GetAll
with the right namespace and block height
Run the node with the correct version
Retrieve the mapping of the rollup block number to Celestia block height from the L1 smart contract
Download block data from Celestia by calling
blob.GetAll
with the right namespace and block heightDecompress the block data
import block data into the node
Repeat till the node is fully synced
Start the node with the required information
Last updated