Starknet’s Cairo-native execution utilizes its custom programming language, Cairo, to boost scalability, cut costs, and improve smart contract performance. However, challenges arise from the need for broader developer adoption, tooling compatibility, and balancing innovation with accessibility across the ecosystem.
Introduction: Starknet and Cairo execution
Starknet is an Ethereum Layer 2 (L2) protocol that leverages cryptographic STARK (Succinct Transparent Arguments of Knowledge) proofs to power verifiable computation at scale. Like other L2 blockchains, Starknet is able to offer meaningful scalability and security for L2 transactions while preserving decentralization.
At the core of Starknet lies the Cairo virtual machine (VM), a purpose-built execution environment designed to leverage the cryptographic proof capabilities of STARKs. Unlike other VMs, Starknet’s Cairo VM is designed to run provable programs—which reduces the overhead associated with generating proofs to verify computation. This allows Starknet to process a vast number of transactions while maintaining trustless verification.
That said, the true measure of Starknet’s performance—as experienced by end-users—depends on the speed at which its sequencer processes transactions and confirms execution results. Also known as “soft confirmations”, the sequencer’s confirmation of transaction success (or failure) are useful for time-sensitive users who want to avoid waiting for transactions to finalize on Ethereum L1 before knowing a transaction’s status.
As it stands today, Starknet’s transaction throughput relies heavily on the efficiency of the sequencer. The sequencer is responsible for receiving, organizing, and proving transactions before submitting them to Ethereum for final verification. Although Starknet uses a single sequencer currently, it plans to decentralize the sequencer for better censorship resistance and higher failure tolerance (one offline sequencer cannot take down the network).
On October 29, Starknet recorded an average of 127 transactions per second (TPS) over a continuous 24-hour period. This was not just a one-time peak but a sustained throughput milestone achieved during normal operations, showcasing the rollup’s ability to handle high transaction volumes under real-world conditions. Alongside this achievement, Starknet’s performance stands out for its lightning-fast transaction confirmations (averaging under two seconds) and ultra-low fees ($0.002 per transaction)—making it a cost-effective and efficient solution for scaling Ethereum.
Maintaining this level of performance requires constant innovation, however, especially as user demand grows. This is where Starknet’s upcoming enhancements to its execution model come into play, introducing optimizations that promise not only faster transaction processing but also more efficient resource usage. These developments mark a critical step toward elevating Starknet’s execution environment to meet the demands of a rapidly evolving ecosystem.
Starknet has already introduced transformative upgrades to its architecture to improve performance and bolster UX (e.g., parallel execution and block-packing via Bolt upgrade). These innovations have drastically reduced transaction processing times and gas costs by enabling the sequencer to handle transactions more efficiently. To learn more about the Bolt upgrade and how it improves Starknet’s scalability, read our Starknet Bolt explainer.
Building on this foundation, Starknet is now focusing on further optimizing its execution environment with Cairo-Native. The upcoming enhancements will redefine how transactions are processed, transitioning from virtual machine-based emulation to native execution. These changes promise significant improvements in processing speed and resource efficiency, ensuring that Starknet can meet the growing demands of users.
In the following section, we’ll take a closer look at Starknet’s execution environment and dive deeper into how the Cairo VM and the broader architecture are being reimagined to support the next phase of scalability and efficiency. Let’s dive in!
A gentle introduction to Cairo-Native execution
The execution environment of Starknet has evolved significantly over time to improve performance and ensure safety. Initially, Starknet relied on a straightforward pipeline where high-level Cairo code was compiled directly into CASM (Cairo Assembly) for execution. While this approach worked, it left the network vulnerable to inefficiencies and security risks. For example, invalid code could not be proven, and the sequencer was exposed to potential DoS attacks due to the lack of safeguards in gas accounting.
To address these issues, the Cairo 1.0 upgrade introduced Sierra, an intermediate representation (IR) that enforces safety by design. Inspired by languages like Rust, Sierra ensures developers follow stricter coding patterns, effectively eliminating runtime errors and enabling accurate gas accounting. This upgrade is already live on Starknet’s mainnet and marks a crucial step toward a more robust and secure execution environment.
Cairo-Native builds on this progress and further enhances Starknet’s performance by enabling native execution. Native execution is a departure from the previous pattern of executing programs in the Cairo VM and represents the next leap forward in terms of performance for Starknet.
How does Cairo-Native execution work?
Previously, the Starknet sequencer executed programs using a virtual machine that emulated code, which introduced significant overhead and slowed down transaction processing. Emulation in this context involves programming the CPU to behave like a theoretical Cairo CPU, interpreting instructions step by step. While functional, this process is inherently inefficient because it prevents the CPU from fully utilizing its native capabilities and execution styles.
In contrast, native execution eliminates this awkwardness, allowing programs to run directly on the operating system in the CPU’s native instruction set. This change dramatically improves execution speed and resource efficiency, enabling Starknet to process transactions faster than ever.
To achieve this, Cairo-Native execution integrates advanced compilation technologies like MLIR (Multi-Level Intermediate Representation) and LLVM (Low Level Virtual Machine). These tools are widely used in modern software development to compile code into optimized machine-level instructions.
Cairo-Native takes Sierra programs and organizes them into an intermediate form, MLIR, that also allows for sophisticated optimizations, while LLVM further compiles this into native executables tailored for the underlying operating system. This dual-layer compilation process ensures that the generated executables are fast, efficient, and ready for direct execution without any additional overhead.
The impact of this upgrade on the sequencer’s performance (and the network in general) is profound:
- Increased speed: By removing the need for VM emulation, native execution allows the sequencer to process transactions significantly faster, reducing latency across the network.
- Better resource utilization: The optimized executables generated by LLVM make better use of system resources, enabling the sequencer to handle higher transaction volumes.
- Lower costs: While faster execution alone doesn’t immediately translate to reduced gas fees due to the absence of a fee mechanism, Starknet continues to demonstrate cost efficiency. For instance, during Starknet’s record-breaking performance, gas fees averaged around $0.002 per transaction. The 0.13.4 update, which introduces Cairo-Native, also includes pricing-related improvements. However, these improvements are not directly related to Cairo-Native itself. While the full potential of Cairo-Native’s scalability on transaction fees has yet to be realized, combining this scalability with future fee-related enhancements positions Starknet as a highly affordable and scalable solution for Ethereum.
- Enhanced innovation: Performance gains from native execution enables more complex and dynamic applications to thrive on Starknet, opening the door to innovative use cases and opportunities for developers.
Although native execution brings significant speed improvements, a natural concern arises for developers regarding the dual-execution workflow between the sequencer and the prover. While the sequencer benefits from running transactions using native artifacts for speed, the prover still relies on the Cairo VM to execute transactions step-by-step, ensuring they can be proven to Ethereum’s STARK verifier.
CASM is still used in this process, as it is the representation validated by the STARK verifier on Ethereum. This duality—executing the same transactions through two different systems—can raise valid questions about consistency and correctness. Specifically, how can we be certain that the outcomes from native execution and Cairo VM execution will always match?
The short answer lies in rigorous testing and validation. Specifically, the LambdaClass team conducted extensive replay tests, a process where historical Starknet blocks are re-executed under the new system to ensure every transaction produces the same results.
Replay tests are a critical method for verifying that even with two distinct execution paths, the outputs remain consistent. Thus developers can rest assured that this extensive validation process significantly minimizes the risk of discrepancies.
Additionally, it’s worth noting that Starknet has always operated with two separate execution flows. Even before Cairo-Native, the sequencer did not fully rely on the Cairo VM for tasks like syscalls or state access. These were already handled differently, with the prover focusing on producing cryptographic proofs to update Starknet’s state on Ethereum.
In this sense, the introduction of native execution represents an evolution—not a departure—from Starknet’s established architecture. This also means developers should have few issues designing applications to work with Starknet’s new execution model.
Overall, Cairo-Native unlocks a new level of scalability and speed for Starknet. By transitioning from VM-based emulation to native execution, the network can support more users, handle larger transaction volumes, and deliver a seamless experience for developers and end-users alike. This transformation solidifies Starknet’s position as a leading L2 solution and paves way for greater innovation in the Ethereum ecosystem.
Cairo-Native vs Cairo: A comparison of Starknet execution models
Cairo-Native marks a groundbreaking improvement in Starknet’s execution environment—one that delivers significant speedups over the traditional Cairo VM. Through extensive benchmarks conducted by LambdaClass and Nethermind, the performance gains from native execution have been quantified, highlighting Cairo-Native’s ability to drastically enhance transaction and contract processing speeds.
Execution benchmarks
The benchmarks revealed that Cairo-Native achieves an average speedup of 5x over the Cairo VM, with performance gains ranging from 1.5x to 20x, depending on the specific contract. These results are more than just numbers—they illustrate how native execution directly benefits users and developers.
For example, a simple STRK transfer between two Argent accounts not only completed 2.3x faster but also showed 4.8x speedup in ERC-20 contract logic. For users, this means lower waiting times for transactions and smoother interactions with decentralized applications (dApps). For developers, these improvements ensure their applications perform faster and more reliably, even under heavy network load.
In more demanding scenarios like STRK/ETH swaps or gaming applications such as Influenceth, the benefits are even more apparent. Influenceth transactions recorded a 10.5x transaction speedup, with some contract executions improving by as much as 70x. These advancements empower developers to create complex, high-performance decentralized applications, paving the way for richer gaming experiences, advanced DeFi protocols, and other computationally intensive use cases
The transition from emulation to native execution underpins these advancements. By compiling programs directly into machine-native code, Cairo-Native eliminates the inefficiencies of emulating Cairo instructions, where the CPU essentially mimics another virtual CPU. Native execution allows the hardware to operate at full capacity, delivering unmatched performance improvements across all transaction types.
Compilation benchmarks
Cairo-Native introduces a more advanced compilation pipeline, adding several steps to translate Sierra code into native executables. This includes processes such as converting Sierra to MLIR, optimizing the code, and finally compiling it into machine-native instructions. While this more complex pipeline might intuitively seem like it would increase overall compilation time, benchmarks show that the additional steps contribute to less than 15% of total compilation time, demonstrating that the process remains efficient.
It’s also worth noting that native executables are larger in size compared to CASM artifacts. This increase reflects the added detail and optimization required for machine-native code but does not affect network performance. Importantly, compilation is only performed once, at the time the contract is deployed on the network, ensuring that this step does not impact the real-time performance of the sequencer
What are the implications of Cairo-native execution for Starknet?
The implications of Cairo-Native for Starknet’s ecosystem are far-reaching. By enabling faster, more efficient transaction execution, this upgrade is set to massively enhance the user experience for all applications on the network. With the network projected to handle nearly 1000 transactions per second (TPS) by the end of 2024, Starknet will become one of the most scalable and responsive L2 chains in the Ethereum ecosystem.
For users, the Cairo-Native upgrade means quicker transaction confirmation and even lower costs. During Starknet’s record-breaking performance earlier this year, gas fees averaged around $0.002 per transaction. With Cairo-Native, these costs are expected to decrease even further, solidifying Starknet as one of the most affordable Layer-2 networks.
The introduction of Cairo-Native execution will also supercharge the following use cases:
Onchain gaming applications
Starknet has already gained traction as a platform for blockchain-based games, and Cairo-Native takes this to the next level. Games like Influenceth, which rely on intricate logic and fast-paced interactions, will benefit significantly from the speed improvements. Faster execution times reduce in-game latency, enabling smoother experiences for players.
Developers can also introduce more complex game mechanics, such as real-time multiplayer capabilities and dynamic NFT interactions, without worrying about performance bottlenecks. This can bring about a new class of onchain gaming applications whose gameplay can rival that of traditional competitors.
Social media platforms
Decentralized social media platforms demand high transaction throughput and low latency to ensure seamless user interactions, such as posting, commenting, and voting. With Cairo-Native, these platforms can scale to support millions of users, offering real-time feeds and instantaneous reactions, rivaling the performance of traditional Web2 counterparts. Lower gas costs further enhance accessibility, making decentralized social media a more viable alternative to centralized platforms and preparing it for mainstream adoption.
Decentralized finance (DeFi)
The DeFi ecosystem on Starknet will also reap the benefits of Cairo-Native. Complex financial operations like swaps, lending, and yield farming require high throughput and precision. Faster execution times ensure that trades and liquidations happen in real-time, minimizing slippage and providing users with better outcomes. Additionally, lower gas fees enable micro-transactions, making DeFi protocols more accessible to a broader audience.
Conclusion
Cairo-Native execution is a critical milestone in the Starknet roadmap. By introducing a new level of execution, Starknet not only solidifies its position as a leading Layer-2 platform but also sets a precedent for the broader Ethereum rollup ecosystem. Starknet’s innovation showcases how rollups can achieve unparalleled scalability and efficiency, helping Ethereum move closer to its vision of mass adoption while maintaining its principles of decentralization and security.
Cairo-Native provides developers with a robust, high-performance environment that supports more dynamic and innovative applications. By reducing execution times and resource overhead, developers can focus on creating richer, more interactive experiences that were previously constrained by network limitations.
As noted in a tweet, there is still potential for further optimization—meaning Cairo-Native’s performance may continue to improve over time. In this sense, the upgrade to Cairo-Native execution represents a crucial step toward realizing Starknet’s full potential as a fast, scalable, and developer-friendly platform and advancing the capabilities of rollup technology across Ethereum’s ecosystem.
A version of this article was originally published here.