Introducing Cairo 1.0: Building a More Powerful and Secure Language for StarkNet
The Birth of Cairo
The birth of Cairo came from the recognition that developers around the world should have access to verifiable computation. Cairo empowers developers to harness the power of STARKs, and the developer community quickly embraced Cairo and started building a thriving ecosystem around it. Today, Cairo is the foundation of the flourishing StarkNet ecosystem, handling over 220 million transactions, minting over 65 million NFTs, and processing over $700 billion worth of transactions on Ethereum.
Cairo 1.0: A New Compiler and the Introduction of Sierra
Cairo 1.0 brings a new compiler that provides enhanced security features and allows developers to write contracts in a simpler and more expressive manner. The major addition in Cairo 1.0 is Sierra, which serves as the new intermediate representation layer between Cairo 1.0 and Cairo bytecode. Sierra ensures that every Cairo run (i.e., the Cairo program and its inputs) can be proven (see below). This guarantees that every Cairo run is verifiable.
Sierra is a crucial component for StarkNet as a permissionless network. It ensures that even recovered transactions can be included in StarkNet blocks, allowing StarkNet to maintain simplicity without adding complex cryptographic mechanisms. This opens up possibilities like Sequencer being able to charge a fee for recovered transactions, enabling StarkNet to prevent Sequencer DoS attacks effectively. Additionally, it enables the implementation of forced L1 transactions, inheriting Ethereum's full censorship resistance.
Language Features in Cairo 1.0
Improved Syntax
Cairo 1.0 brings several improvements to the programming language itself:
- Removal of "local" and "temporary" variables, now using "let" for all variables.
- Improved syntax for "if" statements.
Type Safety Guarantees
The compiler will use strong typing to enhance the code's safety. For example:
- Pointers will always point to initialized memory.
- Dictionaries will always be compressed, removing the responsibility of calling "squash_dict" from the programmer.
More User-Friendly Language Structures
Cairo 1.0 aims to make language structures easier to use. For example:
- Introducing "for" loops.
- Improved boolean expressions, integers with regular integer division, overflow protection for relevant types, and boolean conditions.
A Mature Type System
Cairo 1.0 introduces several features to enhance its type system:
- Abstract data types (similar to Rust's enums).
- Traits for defining behavior.
More Intuitive Libraries
Improved libraries for dictionaries and arrays.
Optimized Code Generation
No explicit declaration of local variable allocation required as it is auto-detected and completed automatically.
Better Compiler Integration
Improved IDE support, package management, and community contributions.
Conclusion
Cairo 1.0 offers improved expressivity, safety, and syntax, making it easier for developers to write StarkNet contracts. With the introduction of Sierra and other enhancements, Cairo provides a solid foundation for the future development of Starks and empowers developers worldwide to build verifiable computation applications on the Ethereum network.
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播信息之目的,不構成任何投資建議,如有侵權行為,請第一時間聯絡我們修改或刪除,多謝。
XRP 漲至 7.5 美元?分析師告訴 XRP 大軍為純粹的煙火做好准備!
加密貨幣分析師 EGRAG 表示,XRP 即將迎來關鍵時刻,價格可能大幅上漲,這取決於能否突破關鍵...
今晚ETH迎來暴漲時代 op、arb、metis等以太坊二層項目能否跑出百倍幣?
北京時間7月23日晚上美股开盤後 ETH 的ETF开始交易。ETH的裏程碑啊,新的時代开啓。突破前...
Mt Gox 轉移 28 億美元比特幣 加密貨幣下跌 ETH ETF 提前發行
2014 年倒閉的臭名昭著的比特幣交易所 Mt Gox 已向債權人轉移了大量比特幣 (BTC),作...