As part of opening StarkNet Shamans for community discussions, we wanted to share our ongoing research on how StarkNet will handle reverted transactions, and prevent Sequencer DoS. This research has been going for the past 5 months, and we’ve come up with a few viable options. The goal of this post is to share those options in high-level, and to start an open conversation to help hear more inputs on those solutions.
This is an introductory post in which we present the problem. We intend to release two more posts that will describe in greater detail the two main approaches.
Problem Description
Let’s start with describing the problem - Cairo is not natively capable of proving reverted transactions. The reason is that for a transaction to fail, one needs to prove that the transaction resulted in an error.
Like in Bitcoin, on the current version of StarkNet Alpha, either a transaction is valid and can be included in a proof or it is unprovable and cannot be included.
The problem this triggers is that an unprovable transaction cannot pay fees and one can imagine sending expensive computation-wise transactions which consume sequencers’ resources without compensating for them. This allows DoS attacks on the sequencers.
Ethereum solves this problem by including reverted transactions and making users pay for the consumed resources. This is possible since Ethereum runs transactions in a virtual machine.
Approaches for a Solution
Few paths exist to solve this scenario attack vector.
Making All Transactions Provable
Making all transactions in StarkNet provable, will allow including them in a proof and taking their fees, similarly to Ethereum. This can be achieved by using a new programming language (whose syntax can be very similar to Cairo), in which the compiled contract will include the code to handle exceptions. We will publish a more detailed description of such a language in a separate post.
-
Pros
- It fully solves the DDoS vector
- UX stays familiar
- A first step towards enabling censorship-resistance via L1 forced transactions.
-
Cons
- User would pay for reverted transactions (like they do on Ethereum)
- It would add an extra overhead in the proof
- It requires significant engineering resources to implement this safe language
Economic Solution - “Red/Green”
We’ve been working on this approach with Prof. Tim Roughgarden for the past 3 months. StarkNet does not implement any restrictions on Cairo. In that case The main idea is that a sequencer can choose to include a transaction without executing it and receive a red fee, thus enabling it to ensure it receives a fee payment for their work. We can design the mechanism in such a way that a Sequencer will always be incentivized to execute a provable transaction and take the green fee instead of the red fee.
-
Pros
- StarkNet would only prove transactions that do something on the state
- No extra engineering
- No user cost on regular reversion (e.i: no more NFT minting where users pay for no reason)
-
Cons
- New approach means unknown attack vectors
Transaction level PoW
Users provide a PoW on top of their transactions based on the numbers of reverted txs. In such a way, a user would have to provide a small proof of work or none on the average case, but in the case too many reversions, the PoW will be much larger. A user would have their PoW requirement decay over time or could set it back to 0 by paying the sequencer.
This approach was less explored in work, but might still be a viable path.
We are opening the problem to the community to understand if we can explore the design space.
If the topic gathers enough interest, we will organize a research call around the topic to dive into the problem and the various existing approach. We would appreciate people to make comments and share their thoughts and questions