One of the major challenges L2 rollups face today is the high cost of L1 data availability, which can account for a significant portion of transaction fees. We propose Volition as a way to address this challenge, by giving developers and users the ability to choose between multiple data availability solutions. In this post, we will discuss the design and remaining open questions.
We want to thank all reviewers, especially the buildersâ council, for their comments and reviews.
Introduction
L1 data availability can be expensive due to the fact that all state diffs are sent as calldata to Ethereum. In March 2023, for example, L1 data availability (L1DA), meaning the state diffs sent to Ethereum, accounted for over 93% of the transaction fees paid on Starknet.
To address this challenge, Starknet will let developers use L2 data availability (L2DA) mode, per their choice, as a complementary possibility to the L1DA. With L2DA, only a commitment to the L2DA mode is posted on L1 so that the state transition can be verified by Ethereum, but the data itself is not posted on L1, Instead it is posted on L2.
This approach is made possible thanks to the Validity Rollup principle: Verifying a STARK proof on L1 is sufficient to guarantee the validity of the transactionâs execution on L2, with no need to send the detailed information of the transaction to Ethereum (unlike optimistic rollups that base their security on having the entire data on Ethereum for verifying fraud proofs). Using the L2DA solution will enable a data availability cost reduction of at least 10X.
This post discusses the importance of both types of data availability modes and presents Volition â the innovative solution that combines the two. Specifically, we explore the concept of a hybrid data availability mode, which allows developers to use both L1 and L2 data availability modes in the same contract. Additionally, we discuss how this solution can be applied in practice, using the example of ERC-20 contracts.
But what about EIP-4844? Once EIP-4844 is available on Ethereum, Starknet will use it to replace the current method of L1DA. However, we should keep in mind that the cost of data availability is determined by market forces of supply and demand. Therefore, the exact cost of EIP-4844 is not known yet, as it will involve a separate market used by all rollups (and probably other usecases) on Ethereum. The introduction of a dedicated market for Starknet users has the potential to establish a cheaper pricing for data availability. This specialized market could offer advantages in setting prices tailored specifically to Starknet usersâ needs and requirements.
Principles for Hybrid Data Availability
Now that we understand the potential benefits of L2DA mode, it is important to consider the trade-offs and whether relying solely on this mode is feasible. The security of state transitions, verified by STARK proofs on L1, remains the same in both L2 and L1 data availability modes. The difference lies in the mechanism that guarantees data availability.
In the L1 solution, data availability is ensured by Ethereum consensus (both in the current solution and with EIP-4844). On the other hand, in the L2DA mode, data availability depends on the L2 consensus layer. Sequencers in the decentralized protocol only approve a block if they possess a fully updated state.
However, it is crucial to acknowledge the risk associated with relying exclusively on L2DA: The potential for a malicious majority stakeholder attack on L2. In this scenario, we still have the commitment to the data, but accessing the data itself might become problematic.
This risk can be managed by using both L2 and L1 data availability modes. This approach allows developers to benefit from the cost efficiency of L2DA for cheaper and highly used assets, while maintaining the more secure L1DA mode for valuable assets.
By supporting both L2 and L1 data availability modes, Starknet provides developers with flexibility and the ability to optimize data availability based on the specific requirements of their applications. This way, they can leverage cheaper data availability while ensuring the security of high-value assets.
The key principles to consider for the hybrid data availability mode for Starknet are as follows:
- The failure of one DA mode does not affect other DA modes. Specifically, the ability to access and execute transactions on the other DA modes should be possible.
- The account contract must always be able to operate, even after a data availability crisis.
- Builders should have the flexibility to use L1 and L2 data availability in every contract, and potentially allow the users to choose.
- Applications should have the ability to move variables between the data-availability modes (L2 and L1), even in the event of a data availability crisis (although the data wonât be accessible, the contract should still be able to function).
One network, multiple data availability modes
How will the hybrid data availability modes work? Essentially, Starknet will hold storage for every contract in both L1 and L2 data availability modes. Currently, Starknetâs state commitment consists of commitment on two Patricia trees: one for the declared classes and one for the storage of all deployed contracts. The hybrid state will include a commitment for another Patricia tree (and maybe more in the future) that will hold the commitment for the L2DA mode. The result will be multiple trees that, together, will contain the commitment for the state: 1 - for declared contracts; 2 - for the L1DA mode of all contracts; other - for the L2DA mode of all contracts.
Each deployed contract will have the same address in all data availability modes. The developers will be able to choose for every storage variable whether to store it in L2DA mode, L1DA mode, or, for example, store a variable under the same key in both trees, in which case, they will choose in runtime from where to conduct the read/write operations.
By making this separation of the state between the different DA modes, we ensure that the failure of one does not affect the others. Letâs consider a case where the L2DA mode has failed. This means that a state update was posted on L1, together with the commitment to the L2DA state, but the data for this state is not available. In this case, even though it is not possible to access the state of the L2DA part, Sequencers and users have the full state of the L1DA part and so can continue operating with L1DA as if nothing happened.
To allow account contracts to operate even in spite of malicious attempts to prevent access to L2DA and still reduce costs for those who will choose to store data in the L2DA mode, Starknet will maintain an account nonce in both L1 and L2 data availability modes. Every transaction will specify the nonceâs data availability mode relevant to the transaction. This way, users will be able to use their L2DA nonce for cheaper transaction fees and use the L1DA nonce (same as today) during a data availability crisis.
In the first Starknet version to support Volition the L2DA mode will be presented as described above. In the future, additional data availability modes could be added, such as a data availability committee for users who prefer a trusted party for their data availability.
As for the data cost in the L2DA mode, it will be defined more accurately in the future, after further development of the L2DA model.
Case study - ERC-20
Letâs imagine how the hybrid state could lead to cost reduction by implementing it in a standard token contract with minimal risk. A common behavior with fee tokens is a lot of activity with small amounts. As the average fee in Starknet will likely be reduced to a few cents, a user will be able to conduct thousands of transactions for a few dozens dollars, while the savings of the user might be much higher. In this case, a rational user might want to store a small amount of funds in their L2DA mode balance for common activities, while the lionâs share of their funds will be stored in an L1DA mode balance. The user could transfer funds to the L2DA âsmall expensesâ balance once in a while.
To implement this in a standard ERC-20 token, an L1 and L2 data availability modes mapping for balances would be required, so each user would have a balance in both mappings. The user will also be able to set and change the default balance for charging. In this way, data from certain activities will be posted on L2, and data from other activities will be posted on L1.
Whatâs next - how will developers use it?
From the protocol perspective, the read and write syscalls will have another field which will allow specifying the DA mode to write/read from.
In order to make it more convenient and safe for Starknet builders, Cairo will allow you to annotate, for every storage variable, what data availability mode is used.
The L1DA mode will be the default mode, which will behave exactly like storage variables do today. Changes to those storage variables will be posted on L1.
The MANUAL mode, marked with #[manual_da]
, will allow only explicit reading and writing from the desired data availability mode, with no default mode, the contract developer will specify, with every read/write access to that var, to what data availability mode heâs aiming at.
In the example below, my_var
and may_map
are defined without special annotation like before, and so are kept on L1DA mode, same as before.
The Remaining Challenges
As Uncle Ben said âwith great power comes great responsibilityâ. While Volition holds a huge potential for cost reduction, there is one behavioral risk associated with it that needs to be addressed: It is unclear how easy it will be for developers and users to understand the risks associated with different DA modes and to analyze the risk of a specific application or contract:
- Will my contract continue working under an L2DA crisis?
- Even if Iâm sure as a developer that my contract can continue to operate, how can I be sure of other contracts that I interact with?
An L2 Data Availability crisis may not only impact the known contracts using L2DA but also affect contracts that are considered safe but actually rely on other contracts that utilize L2DA in an unsafe manner. This situation could potentially lead to significant damage and a widespread network failure.
To assess this risk, we propose a longer testnet period for this version to thoroughly examine the actual risks. Additionally, we aim to introduce more features that can better distinguish between pure L1DA and contracts that utilize other data availability modes. We welcome comments and suggestions, so please donât hesitate to propose ideas.
Summary
Volitionâs approach to L2DA offers a promising solution to reduce the high fees of posting data on L1. By enabling the use of L2DA for certain data, developers can potentially reduce up to 90% of the costs and improve scalability without compromising the integrity and security of the Ethereum network. The potential benefits of L2DA are significant and could pave the way for new possibilities in the development of decentralized applications. There is a potential risk of a malicious majority affecting the normal functioning of the network, and we would appreciate your thoughts and ideas on this matter.