Risk Warning: Beware of illegal fundraising in the name of 'virtual currency' and 'blockchain'. — Five departments including the Banking and Insurance Regulatory Commission
Information
Discover
Search
Login
简中
繁中
English
日本語
한국어
ภาษาไทย
Tiếng Việt
BTC
ETH
HTX
SOL
BNB
View Market
Detailed explanation of Cairo1.0 public version: How to change the writing paradigm of StarkWare?
PANews
特邀专栏作者
2023-01-11 03:37
This article is about 2418 words, reading the full article takes about 4 minutes
The functions of this update can be summarized into three points, namely intelligence, efficiency and safety.

On January 5th, StarkWare announced the official launch of the public version of the programming language Cairo 1.0, officially replacing the two-year test and preview version, which also marks that it is possible to use this language to write smart contracts on StarkNet, while also taking into account efficient execution Efficiency has become a milestone event of the Layer 2 Rollup technology school of the ZK series.

The functions of this update can be summarized into three points, namely intelligence, efficiency and safety.

  • Smarter: implement the Sierra design, ensure Cairo code is provable, and StarkNet smart contracts will be implemented in the next version.

  • More efficient: Follow up the Rust language's strong typing, ownership mechanism, and borrowing design ideas, taking into account execution efficiency and writing norms;

  • More secure: Turing completeness is maintained, and the security of the STARK mechanism is guaranteed by mathematical proofs;

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

The Best of Both Worlds: Towards ZK-EVM

In this round of Layer 2 battles, STARK and SNARK in the ZK series have become the two mainstream routes, but EVM compatibility and execution efficiency have also become the focus of attention of all parties, and better compatibility will be recognized by the Ethereum mainnet. Security blessing, and higher execution efficiency will speed up the execution speed of L2 itself.

But there is a paradox in this: EVM compatibility and execution efficiency often cannot be achieved at the same time. The better L1 compatibility will reduce the L2 execution efficiency, otherwise there will be security problems.

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

In this update, Cairo will support the complete Cairo-VM, the key of which is the intermediate presentation layer Sierra.

In simple terms, Sierra will serve as a "translation layer" between the code written in Cairo language and its underlying bytecode, and this translation will speed up on the basis of ensuring security, without setting the execution status of the transaction, it can directly Attestation is carried out based on the current state.

This is an improvement of Cairo's own syntax. In addition, StarkWare's smart contracts will gradually transition to the complete Cairo language to complete the unification of its own language standards.

Making Complexity Simple: How Cairo 1.0 Changed the Writing Paradigm for StarkWare

Since a considerable degree of compatibility with the Ethereum mainnet is maintained, the conversion between smart contracts written in Cairo and Solidity will also be easier. Warp, the translator of the Ethereum client Nethermind, already supports the rewriting of Uniswap V3 into Cairo code.

In fact, at the end of October 2022, StarkNet claimed to use Cairo to develop ZK-EVM, and then as StarkNet is actually put into production, the actual effect of this compatibility can be verified.

Sprouts: Rust-Based Balanced Features

Making Complexity Simple: How Cairo 1.0 Changed the Writing Paradigm for StarkWare

In fact, Cairo itself can be regarded as a language written in the Rust language, which inherits more Rust features.

Rust itself is different from so-called modern languages ​​such as Python/Go. Its operating efficiency is highly close to that of the lower-level development languages, but at the same time, it also takes into account readability, such as special memory management mechanisms - special ownership (ownership) and borrowing. design.

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


  • C/C++: Manually manage memory, thanks to (beneficiary from) the progress of modern equipment, most developers have not developed the habit of releasing memory in time, which will cause serious waste of resources;

  • Java: Automatic resource recycling mechanism. JVM is a virtual machine when Java is running. It has the function of automatically managing memory, but generally to ensure operating efficiency, JVM will maintain a certain amount of memory resources, which will also cause a mismatch between supply and demand;

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


Such an ownership mechanism design can ensure that valuable memory resources are only called during execution, which can take into account the operating efficiency of C/C++, but avoids problems such as memory leaks. Memory resources do not need to be prepared at all times, which is helpful for reducing the overall size of smart contracts is of great significance.

The second is the idea of ​​strong typing. Cairo/Rust involves the writing and running of many smart contracts, and all of them carry high-value Tokens, NFTs and personal data, which need special treatment, and every change needs to be treated with caution.

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

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

In the writing of smart contracts, the type and quantity of assets must be explicitly treated to ensure that their ownership is clear and the processes of transactions and conversions are clear. Cairo/Rust is highly readable and friendly to developers, so it is easy to avoid More security concerns.

Making Complexity Simple: How Cairo 1.0 Changed the Writing Paradigm for StarkWare

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

Reborn: Developer Friendly

Cairo 1.0 shoulders the important task of connecting L2 and Ethereum mainnet. According to its official Regenesis (rebirth) plan, StarkNet will completely transition to Cairo in the first quarter of 2023, ending the current split state and entering a new development of ecological competition stage.

Making Complexity Simple: How Cairo 1.0 Changed the Writing Paradigm for StarkWare

However, due to the lack of real killer applications, coupled with the exodus of leading projects such as dYdX, StarkWare's promotion road is still full of thorns.

In the current public chain/L2/dApp development pattern, Solidity (Vyper) occupies nearly 98% of the monopoly position, while Cairo only occupies less than 1% of the market space. Basically, only StarkWare can support the operation at present.

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

Before Cairo 1.0 is actually applied to StarkNet, the developer experience is the first step in competing for its entry into the StarkWare ecosystem. In addition to Nethermind’s Warp support, ConsenSys has also reached a cooperation with StarkWare to provide Cairo with smart contracts to provide security audit services.

Related Reading:

Related Reading:Inventory of StarkWare ecology: 7 applications in StarkEx, 105 ecological projects in StarkNet

 

Making Complexity Simple: How Cairo 1.0 Changed the Writing Paradigm for StarkWare

It can be found that Cairo's function development progress is relatively fast, and more functions are expected to be implemented, and StarkNet will also fill in the current function gap after Cairo is implemented, and finally realize the full-featured module of StarkNet system-level calls.

At present, you can properly refer to the data of StarkEx. Unlike StarkNet's generalization route, StarkEx is oriented to several major large-scale projects, including Immutable X, Sorare, Rgino.Fi and dYdX. The number of users who have used the service has reached 20 million. The average monthly life is in the tens of thousands.

Making Complexity Simple: How Cairo 1.0 Changed the Writing Paradigm for StarkWare

epilogue

epilogue

Cairo 1.0 is not simply a language update, but takes on a richer role, including activating StarkNet's EVM compatibility and execution efficiency, and reducing development difficulty by leveraging Rust's mature programming paradigms, such as ownership and strong typing.

At the same time, it should be noted that Cairo 1.0 still has some functions that have not been fully implemented, and its full state may require a longer development cycle, and its token issuance time will also be adjusted accordingly.

In short, Cairo is of great significance in ending the current "incomplete" version of StarkNet. Combining new tools such as Sierra, compilers, and mainstream development tools, it will significantly reduce the pressure on developers to write smart contracts on it.


StarkWare
Welcome to Join Odaily Official Community