Cointime

Download App
iOS & Android

StarkNet Mainnet Alpha Upgraded to v0.10.2

StarkNet Mainnet alpha upgraded to v0.10.2.

Expect an improved TPS in the upcoming StarkNet versions.

Sequencer parallelization - already deployed on Mainnet!

A new rust implementation for the Cairo VM

Sequencer re-implementation in rust

StarkNet Performance Roadmap

TL;DR

Validity rollups are not limited in throughput in the same manner as L1s. This gives rise to potentially much higher TPS on L2 validity rollups.

StarkNet performance roadmap addresses a key element in the system: the sequencer.

We present here the roadmap for performance improvements:

— Sequencer parallelization

— A new rust implementation for the Cairo VM

— Sequencer re-implementation in rust

Provers, being battle-tested as they are, are not the bottleneck and can handle much more than they do now!

Intro

StarkNet launched on Mainnet almost a year ago. We started building StarkNet by focusing on functionality. Now, we shift the focus to improving performance with a series of steps that will help enhance the StarkNet experience.

In this post, we explain why there’s a wide range of optimizations that are only applicable in validity rollups, and we will share our plan to implement these steps on StarkNet. Some of these steps are already implemented in StarkNet Alpha 0.10.2, which was released on Testnet on Nov 16 and Yesterday on Mainnet. But before we discuss the solutions, let’s review the limitations and their cause.

Block Limitations: Validity Rollups versus L1

A potential approach towards increasing blockchain scalability and increasing TPS would be to lift the block limitations (in terms of gas/size) while keeping the block time constant. This would require more effort from the block producers (validators on L1, sequencers on L2) and thus calls for a more efficient implementation of those components. To this end, we now shift the focus to StarkNet sequencer optimizations, which we describe in more detail in the following sections.

A natural question arises here. Why are sequencer optimizations limited to validity rollups, that is, why can’t we implement the same improvements on L1 and avoid the complexities of validity rollups entirely? In the next section, we claim that there is a fundamental difference between the two, allowing a wide range of optimizations on L2 that are not applicable to L1.

Why is L1 throughput limited?

Unfortunately, lifting the block limitations on L1 suffers from a major pitfall. By increasing the growth rate of the chain, we also increase the demands from full nodes, who are attempting to keep up with the most recent state. Since L1 full nodes must re-execute all the history, a high increase in the block size (in terms of gas) puts a significant strain on them, again leading to weaker machines dropping out of the system and leaving the ability to run full nodes only to large enough entities. As a result, users won’t be able to verify the state themselves and participate in the network trustlessly.

This leaves us with the understanding that L1 throughput should be limited, in order to maintain a truly decentralized and secure system.

Why don’t the same barriers affect Validity Rollups?

Only when considering the full node perspective do we see the true power offered by validity rollups. An L1 full node needs to re-execute the entire history to ensure the current state’s correctness. StarkNet nodes only need to verify STARK proofs, and this verification takes an exponentially lower amount of computational resources. In particular, syncing from scratch does not have to involve execution; a node may receive a dump of the current state from its peers and only verify via a STARK proof that this state is valid. This allows us to increase the throughput of the network without increasing the requirements from the full node.

We therefore conclude that the L2 sequencer is subject to an entire spectrum of optimizations that are not possible on an L1.

Performance Roadmap Ahead

In the next sections, we discuss which of those are currently planned for the StarkNet sequencer.

Sequencer parallelization

The first step on our roadmap was to introduce parallelization to the transaction execution. This was introduced in StarkNet alpha 0.10.2, which was released Yesterday on Mainnet. We now dive into what parallelization is (this is a semi-technical section, to continue on the roadmap, jump to the next section).

So what does “transaction parallelization” mean? Naively, executing a block of transactions in parallel is impossible as different transactions may be dependent. This is illustrated in the following example. Consider a block with three transactions from the same user:

Transaction A: swap USDC for ETH

Transaction B: pay ETH for an NFT

Transaction C: swap USDT for BTC

Clearly, Tx A must happen before Tx B, but Tx C is entirely independent of both and can be executed in parallel. If each transaction requires 1 second to execute, then the block production time can be reduced from 3 seconds to 2 seconds by introducing parallelization.

The crux of the problem is that we do not know the transaction dependencies in advance. In practice, only when we execute transaction B from our example do we see that it relies on changes made by transaction A. More formally, the dependency follows from the fact that transaction B reads from storage cells that transaction A has written to. We can think of the transactions as forming a dependency graph, where there is an edge from transaction A to transaction B iff A writes to a storage cell that is read by B, and thus has to be executed before B. The following figure shows an example of such a dependency graph:

In the above example, each column can be executed in parallel, and this is the optimal arrangement (while naively, we would have executed transactions 1–9 sequentially).

To overcome the fact that the dependency graph is not known in advance, we introduce optimistic parallelization, in the spirit of BLOCK-STM developed by Aptos Labs, to the StarkNet sequencer. Under this paradigm, we optimistically attempt to run transactions in parallel and re-execute upon finding a collision. For example, we may execute transactions 1–4 from figure 1 in parallel, only to find out afterward that Tx4 depends on Tx1. Hence, its execution was useless (we ran it relative to the same state we ran Tx1 against, while we should have run it against the state resulting from applying Tx1). In that case, we will re-execute Tx4.

Note that we can add many optimizations on top of optimistic parallelization. For example, rather than naively waiting for each execution to end, we can abort an execution the moment we find a dependency that invalidates it.

Another example is optimizing the choice of which transactions to re-execute. Suppose that a block which consists of all the transactions from figure 1 is fed into a sequencer with five CPU cores. First, we try to execute transactions 1–5 in parallel. If the order of completion was Tx2, Tx3, Tx4, Tx1, and finally Tx5, then we will find the dependency Tx1→Tx4 only after Tx4 was already executed — indicating that it should be re-executed. Naively, we may want to re-execute Tx5 as well since it may behave differently given the new execution of Tx4. However, rather than just re-executing all the transactions after the now invalidated Tx4, we can traverse the dependency graph constructed from the transactions whose execution has already terminated and only re-execute transactions that depended on Tx4.

A New Rust Implementation for the Cairo-VM

Smart contracts in StarkNet are written in Cairo and are executed inside the Cairo-VM, which specification appears in the Cairo paper. Currently, the sequencer is using a python implementation of the Cairo-VM. To optimize the VM implementation performance, we have launched an effort of re-writing the VM in rust. Thanks to the great work of Lambdaclass, who are by now an invaluable team in the StarkNet ecosystem, this effort is soon coming to fruition.

The VM’s rust implementation, cairo-rs, can now execute native Cairo code. The next step is handling smart-contracts execution and integrations with the pythonic sequencer. Once integrated with cairo-rs, the sequencer’s performance are expected to improve significantly.

Sequencer Re-Implementation in Rust

Our shift from python to rust to improve performance is not limited to the Cairo VM. Alongside the improvements mentioned above, we plan to rewrite the sequencer from scratch in rust. In addition to Rust’s internal advantages, this presents an opportunity for other optimizations to the sequencer. Listing a couple, we can enjoy the benefits of cairo-rs without the overhead of python-rust communication, and we can completely redesign the way the state is stored and accessed (which today is based on the Patricia-Trie structure).

What About Provers?

Throughout this post, we didn’t mention the perhaps most famous element of validity rollups — the prover. One could imagine that being the arguably most sophisticated component of the architecture, it should be the bottleneck and, thus, the focus of optimization. Interestingly, it is the more “standard” components that are now the bottleneck of StarkNet. Today, particularly with recursive proofs, we can fit a lot more transactions than the current traffic on Testnet/Mainnet into a proof. In fact, today, StarkNet blocks are proven alongside StarkEx transactions, where the latter can sometimes incur several hundred thousand NFT mints.

Summary

Parallelization, Rust, and more — brace yourselves for an improved TPS in the upcoming StarkNet versions.

Comments

All Comments

Recommended for you

  • Ethereum stablecoin transaction volume exceeds $1 trillion so far in April, setting a new record

    On April 29th, The Block data shows that as of April 28th, the trading volume of stablecoins on the Ethereum blockchain reached a record high of $1.08 trillion in April, with DAI trading volume ranking first at $578.07 billion, followed by USDC at $268.15 billion in second place, and USDT at $198.62 billion in third place.

  • Shenyu: Up to one billion users' cloud input methods may have leaked input content. Please take immediate measures to reduce the risk.

    On April 29th, Cobo co-founder and CEO Shen Yu wrote on X platform that the cloud input method used by up to one billion users may have leaked input content. If you have entered mnemonic words or other sensitive information through any of the following cloud input methods, please take immediate measures to reduce the risk.

  • EU member states prepare to enforce landmark crypto law, MiCA

    The European Union is set to enforce MiCA, a crypto law that mandates national regulators to license and supervise service providers. While the regulation is EU-wide, countries can implement slightly different technical standards that crypto firms must adhere to. MiCA's specialized rules for stablecoin issuers will take effect in a few months, followed by licensing and other requirements for crypto firms broadly in December. Each jurisdiction must transpose the EU regulation into local law, select which of their regulators will oversee crypto, and prepare to authorize token issuers and other service providers. Regulators are facing challenges in implementing the new legislation, particularly in terms of licensing requirements, and each country's crypto industry has its own concerns about implementation and proposed laws.

  • The total open interest of BTC contracts on the entire network dropped to $29.83 billion

    According to Coinglass data, the total open position of BTC futures contracts on the entire network is 478,180 BTC, equivalent to 29.83 billion US dollars.

  • An independent Bitcoin miner obtained the entire 3.125 BTC block reward by verifying block 841,286

    On April 29th, independent mining pool ckpool's software engineer and administrator Con Kolivas posted on social media that a miner had mined the 282nd independent block in Bitcoin history. The miner's computing power at the time was about 120PH, which is equivalent to about 0.12 EH, with an average of about 12 PH per week, accounting for about 0.02% of the total network hash rate.

  • South Korea to formally establish an investigation unit focused on digital asset crimes

    The South Korean Ministry of Justice and the Ministry of Interior and Safety will begin discussions in early May to elevate the Joint Investigation Team for Virtual Asset Crimes to an official department. The purpose of this promotion is to solidify the department's position, as it currently operates as a temporary organization under the Seoul Southern District Prosecutor's Office and may be dissolved. The change is expected to improve efficiency through the appointment of new prosecutors and budget allocation, according to Sae-ki. The department is composed of about 30 experts from seven financial and tax regulatory agencies and was established in July 2023 as South Korea's first investigative agency focused on digital asset crimes.

  • Hong Kong virtual asset spot ETF debuts today

    Today, six virtual asset spot ETFs were launched online in Hong Kong. The six virtual asset spot ETFs issued this time are from Huaxia (Hong Kong), Boshi International, and Jiashi International. The three institutions have certain differences in product fees, trading, issuance, and virtual asset platforms.

  • The total open interest of Bitcoin contracts on the entire network reached US$30.62 billion

    According to Coinglass data, the total open position of Bitcoin futures contracts on the entire network is 480,870 BTC (approximately $30.62 billion).

  • Over $734 million worth of PYTH is staked

    According to Dune data, there are currently 1,253,845,543 PYTH coins in a pledged state, with a total pledge value of $734,478,896. The number of PYTH pledgers has reached 159,165.

  • ConsenSys proposes four key reasons to support Ethereum's non-security status

    The US SEC's re-examination of whether Ethereum belongs to the securities category has caused controversy. ConsenSys has put forward four reasons to support Ethereum's non-securities status: