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),作...