header-langage
简体中文
繁體中文
English
Scan to Download the APP
Partnered With:

Simplifying complexity: How Cairo 1.0 changes the programming paradigm for StarkWare.

Read this article in 7 Minutes
On January 5th, StarkWare announced the official release of programming language Cairo 1.0, marking the possibility of writing smart contracts on StarkNet using this language while also ensuring high execution efficiency. This is a milestone event for the
Original Title: "Simplifying Complexity: How Cairo 1.0 Changes StarkWare's Programming Paradigm"
Source: PANews


On January 5th, StarkWare announced the official release of programming language Cairo 1.0, replacing the two-year testing and preview versions. This also marks the possibility of writing smart contracts on StarkNet using this language, while also ensuring efficient execution efficiency, becoming a milestone event for the ZK-based Layer 2 Rollup technology.


This update's features can be summarized into three points: intelligence, efficiency, and security.


More intelligent: Implementing Sierra design and ensuring Cairo code can be proven, StarkNet smart contracts will be implemented in the next version.


More efficient: Following the design principles of Rust language's strong typing, ownership mechanism, and borrowing, balancing execution efficiency and writing standardization;


More secure: Maintaining Turing completeness, the security of the STARK mechanism is guaranteed by mathematical proof.


The workflow of Cairo 1.0 public version will be different from the past, with the main development direction being continuous improvement in smart contract writing ability and developer friendliness.


Two birds with one stone: Towards ZK-EVM


In this round of Layer 2 battles, STARK and SNARK in the ZK system have become the two mainstream routes, but EVM compatibility and execution efficiency have also become the focus of attention from all parties. Better compatibility will receive the security support of the Ethereum mainnet, while higher execution efficiency will accelerate the execution speed of L2 itself.


However, there is a paradox: EVM compatibility and execution efficiency are often incompatible. The better the L1 compatibility, the lower the L2 execution efficiency, and vice versa, there are security issues.


Therefore, StarkWare hopes to use the Cairo language as a glue between the two, and the smart contracts written through it can not only run at full speed on StarkNet, but also maintain high compatibility with the Ethereum mainnet. This is also the true meaning of ZK-EVM.


In this update, Cairo will support the complete Cairo-VM, with the key being the intermediate representation layer Sierra.


In simple terms, Sierra will serve as a "translation layer" between the code written in the Cairo language and its underlying bytecode. This translation will be performed with a focus on speed while ensuring security, without the need to set the execution state of transactions, and proofs can be generated directly based on the current state.


This is an improvement in Cairo's own syntax. In addition, StarkWare's smart contracts will gradually transition to the complete Cairo language to achieve standardization of their language.



Due to maintaining a considerable level of Ethereum mainnet compatibility, the conversion between smart contracts written in Cairo and Solidity will also be easier. The Warp translator of Ethereum client Nethermind already supports rewriting Uniswap V3 into Cairo code.


Actually, in late October 2022, StarkNet announced the development of ZK-EVM using Cairo. With the real deployment of StarkNet in production environment, the actual compatibility effect can be verified.


新芽:基于 Rust 的平衡特性


translates to

New Sprout: Balanced Features Based on Rust



In fact, Cairo can be seen as a language written in Rust itself, inheriting many Rust features.


Rust is different from so-called modern languages like Python/Go in that its runtime efficiency is highly comparable to that of lower-level development languages, while also balancing readability, such as with its special memory management mechanism - ownership and borrowing.


Strictly speaking, the ownership of Cairo/Rust refers to the explicit requirement for managing memory. Due to the special node operation mechanism of blockchain, it is a typical memory-sensitive development environment. Taking C/C++, Java as examples, there are currently three mainstream memory resource utilization mechanisms:


C/C++: Manually manage memory. Thanks to (or victimized by) the progress of modern devices, most developers have not developed the habit of releasing memory in a timely manner, which can cause serious resource waste.


Java: Automatic resource recycling mechanism. JVM is the virtual machine of Java runtime, which has the function of automatically managing memory. However, in order to ensure running efficiency, JVM usually keeps a certain amount of memory resources, which may cause supply-demand mismatch problems.


Cairo/Rust: Ownership mechanism manages memory resources. Any variable in Rust must specify an owner, and there can only be one owner at a time. Once the variable is executed, it is released and cannot continue to exist in memory.


This ownership mechanism design can ensure that valuable memory resources are only called during execution, which can balance the efficiency of C/C++ and avoid problems such as memory leaks. Memory resources do not need to be constantly prepared, which is of great significance for reducing the overall size of smart contracts.


Next is the strong-typed approach. Cairo/Rust involves the development and execution of numerous smart contracts, which carry high-value tokens, NFTs, and personal data that require special handling and careful consideration for every change.


Strongly typed languages and weakly typed languages are relative to the definition of variables. In simple terms, strong typing requires variables to be defined in terms of "data types" before use, such as integers, floating-point numbers, strings, etc. Without explicit type conversion operations, their definitions cannot be changed arbitrarily.


Weakly typed languages do not have such strict rules, and the data type of variables can be changed flexibly.


In the writing of smart contracts, asset types and quantities must be treated explicitly to ensure clear ownership and clear processes for transactions, conversions, etc. Cairo/Rust is highly readable and developer-friendly, making it easier to avoid more security issues.



According to the official schedule, the compiler for Cairo 1.0 will be released in the first quarter of this year. At that time, it will be more deeply integrated with StarkNet. With the language features of Rust, it is expected to improve the execution speed from the bottom layer, thereby raising its TPS to a level that can be used daily.


Rebirth: Developer Friendly


Cairo 1.0 is tasked with bridging L2 and the Ethereum mainnet. According to its official Regenesis plan, StarkNet will fully transition to Cairo in the first quarter of 2023, ending the current fragmented state and entering a new stage of ecological competition.



However, lacking truly killer applications, coupled with the departure of top projects such as dYdX, StarkWare's road to advancement is still full of thorns.


In the current landscape of public chains/L2/dApp development, Solidity (Vyper) holds a near-monopoly position with almost 98% market share, while Cairo occupies less than 1% of the market space. Currently, only StarkWare is able to support its operation.


Since the establishment of StarkNet and StarkEx, dApps powered by Cairo have processed over 300 million transactions, minted over 65 million NFTs, and processed transactions worth $700 billion, all settled on Ethereum as the final settlement layer.


Before Cairo 1.0 was truly applied to StarkNet, the developer experience was the first step in vying for entry into the StarkWare ecosystem. In addition to Nethermind's Warp support, ConsenSys also partnered with StarkWare to provide security audit services for smart contracts in Cairo.


According to the official statement, the development progress of Cairo 0's various functions is as follows. We can also refer to the development direction of Cairo 1.0 from it. It is also stated that StarkWare will follow the plan to open source all of StarkNet, and Cairo will be its first step.


Related reading: A review of the StarkWare ecosystem: 7 applications in StarkEx and 105 projects in StarkNet.

 


It can be found that Cairo's functional development progress is faster, and it is expected to implement more functions. StarkNet will also fill the current functional gap after Cairo is implemented, and ultimately realize the full-featured module for StarkNet system-level calls.


Currently, it is possible to refer to the data provided by StarkEx. Unlike the generalization route of StarkNet, StarkEx is aimed at several major projects, including Immutable X, Sorare, Rgino.Fi, and dYdX. The number of users who have used the service has reached 20 million, with daily active users in the tens of thousands.



With the help of mature DeFi and blockchain games, the marketization of StarkEx has been relatively smooth. However, StarkNet will participate in the competition of various L2s as a general Layer 2, and Cairo is expected to further drive the increase of StarkNet's market share.


Conclusion


Cairo 1.0 is not just a simple language update, but it will play a more diverse role, including activating StarkNet's EVM compatibility and execution efficiency. By leveraging Rust's mature programming paradigms such as ownership and strong typing, it reduces development difficulty.


At the same time, it should be noted that there are still some incomplete features in Cairo 1.0, and its complete state may require a longer development cycle. The token issuance time will also be adjusted accordingly.


In short, Cairo's completion of the current "incomplete" version of StarkNet is of great significance. Combined with new tools such as Sierra and compilers, as well as integration with mainstream development tools, it significantly reduces the pressure on developers to write smart contracts on it.


Original article link


Welcome to join the official BlockBeats community:

Telegram Subscription Group: https://t.me/theblockbeats

Telegram Discussion Group: https://t.me/BlockBeats_App

Official Twitter Account: https://twitter.com/BlockBeatsAsia

举报 Correction/Report
Choose Library
Add Library
Cancel
Finish
Add Library
Visible to myself only
Public
Save
Correction/Report
Submit