Cairo 1.0 — changes, features, release date

Introduction

Extropy.IO

--

Cairo 1.0 is not just an iteration over Cairo 0. It is a full rewrite in Rust, whereas Cairo 0 has been written in a pythonic DSL. New Cairo at its core is very similar to Rust. It is meant to be backward compatible with Cairo 0.10 but this is at the bytecode level.

Why such a big change? Cairo 0 had many problems, it was created as StarkWare’s internal tool which wasn’t designed to be released to the public. Cairo 1.0 is an improvement on literally every possible level. Let’s go through them:

Improved syntax and features

  • Variables with no revoked references. No tempvar or local anymore. Cairo 1.0 is completely abstracting away the non-deterministic read-only memory model of Cairo. Variable allocation is handled by the compiler.
  • Native boolean expressions and conditions.
  • Improved Error handling.
  • Libraries for array, dictionary and other collections with easier manipulation
  • Algebraic data types like Option and Result

Sierra

Cairo 1 compiles first to Sierra and then Sierra Assembly compiles into bytecode. Sierra stands for Safe IntErmdiate RepResentAtion. The benefits of this approach are huge.

Cairo 1 transactions are always provable. In Cairo 0 failed transactions have been not provable so transaction fees couldn’t be collected on them. Hence it has been possible to execute a denial of service attack on the network by submitting failing transactions for free. In Cairo 1 there are no failed transactions, they can only result in TRUE or FALSE.

As Cairo 1 is a higher level language StarkNet contracts compiling to Sierra won’t require recompilation in case of changes in Cairo Operating System architectural changes.

Gas counting and the fact that asserts can return an error instead of just a failure are improvements from the developer’s perspective.

Other improvements

Improved safety with native overflow and division handling. Improved tooling using the cargo package manager and IDE support with a language server. The Cairo language has its own GitHub public repository allowing easier community contributions.

Release date

--

--

Extropy.IO

Oxford-based blockchain and zero knowledge consultancy and auditing firm