Releases: starkware-libs/cairo
v1.0.0-rc0
Optimizations:
- Sierra code size:
- Compressed sierra code - X20 shrinking of the sent code size.
- Removed unrequired
StructDestructure
commands when followed by drops.
Bug Fixes:
- 2932 - Branch Alignment Issue
- 2933 - Made contract using bitwise operations compile
- 2946 - Felt252Dict works now
Breaking Changes:
- Made
Serde
non owning (Kudos @wraitii) - Removed Sierra libfuncs that weren’t required (does not break Cairo1.0 existing code, as this just changed the underlying implementation of the code).
- u{8,16,32,64,128}_le, u{8,16,32,64,128}_lt (replaced by using `u*_overflowing_sub)
- felt252_dict_read, felt252_dict_write (replaced by felt252_dict_entry_*)
- u128_wide_mul (replaced by u128_guarantee_mul and u128_mul_guarantee_verify)
- Attribute argos are now
:
based instead of=
based. #[should_panic(expected: ('assert(false)', ))]
- Names of parameters in impl methods are now enforced to be the same as in the trait.
New Features:
- Only a single constructor in contract is enforced earlier (Kudos @tserg)
continue
now supported in loop blocks (Kudos @tserg)- Basic Keccak support - still pending user level code of generating padding.
Felt252Dict
now has an update option through theentry
method.#[test]
framework now supports contract interoperability simulation.- Added
u256_sqrt
. use
statement aliases are now supported.use some::path::to::usage as better_name;
use
statement can now provide multiple values.use some::path::to::{one, the_other};
- New #[inline] attribute, allows inlining of functions that may call themselve.
- Added
cmp::{min, max}
forPartialOrd
supporting types (Kudos @bllu404) - Improved formatting all around
- Additional and more efficient Integer casting (Kudos @hemantjoestar)
Additional Contributions:
- Fix should_panic error message (Kudos @andrew-fleming)
- Implement inline macro parsing (Kudos @tarrencev)
- Rename test in ecdsa_completeness (Kudos @gaetbout)
- Migrate to @types/vscode & @vscode/test-electron (Kudos @pcdotfan)
- Refactor parser.lalrpop to remove unicode-perl regex (Kudos @tarrencev)
- Expose test runner as lib (Kudos @ericnordelo)
- Initialize db in TestRunner constructor (Kudos @tarrencev)
- Expose TestRunner members (Kudos @tarrencev)
- Restore
starknet-compile
(Kudos @war-in) - Expose more use statements in the starknet module (Kudos @taco-paco)
- Adding u128 overflow sub (Kudos @gaetbout)
- Displays cairo-run panic msg as string (Kudos @notV4l)
- Fix and unify list styles (Kudos @microbecode)
v1.0.0-alpha.7
Note: This version is not yet supported on starknet!
- Automatic
withdraw_gas
calls- Added automatic addition of
withdraw_gas_all
calls to cycles in your Cairo code. That is, you no more need to manually add it anywhere.
- Added automatic addition of
- Added basic docs
- u256 division
- / and % operators for u256.
- Removed turbofish need in many places
Span::slice()
- Poseidon support (Not in starknet yet)
- Inferred literal types
- match and
.expect()
optimizations - Support for loop expr:
let res = loop { …; break expr; };
- panic_with_felt252()
- BoundedInt trait
BoundedInt::max()
andBoundedInt::min()
- Index operator
- Oct and bin literals
- Destructors
- Destruct trait for destructing non Droppable objects such as Dict
- Span pop_back
#[should_panic]
attribute syntax change,=
was replaced with:
to match named function arguments syntax:#[should_panic(expected: ('panic_with_felt252()', ))]
v1.0.0-alpha.6
Cairo compiler.
v1.0.0-alpha.5
Cairo compiler.
v1.0.0-alpha.4
Release notes
Cairo Language
Added ability to test specific panic values in tests. For example:
#[test]
#[should_panic(expected = ('assert(false)'))]
fn test_assert_false() {
assert(false, 'assert(false)');
}
-
Syntax:
No need for turbofish in types. For example,Array::<felt>
is nowArray<felt>
.
ref
arguments no longer have to be the first arguments. -
Added
Array::span
to the corelib.
StarkNet contract features
All execution info getters was merged into one syscall. These syscalls were removed:
get_block_number_syscall
get_block_timestamp_syscall
get_caller_address_syscall
get_contract_address_syscall
get_sequencer_address_syscall
And replaced with:
get_execution_info_syscall
Release v1.0.0-alpha.3
Release notes
Cairo Language
- Snapshot type - A type that creates a reference to an object at a point in time, which can not be further changed, of a possibly non-copyable object.
Added Snapshot operator@
and De-snapping operator*
.
For example - Snapshot:
trait ArrayTrait<T> {
...
fn at(self: @Array::<T>, index: usize) -> @T;
...
}
Desnapping:
let mut arr = ArrayTrait::new();
arr.append(10);
let x = *arr.at(0_usize);
-
Improved inlining - more functions are supported.
New#[inline(never)]
attribute. -
EC library extended:
ec_point_zero, ec_point_is_zero, ec_state_finalize. -
New operators:
+=, -=, *=, /=, %=
. -
Traits for
Neg
andNot
operators. -
Into
andTryInto
traits. -
Support for new integer types:
u8, u16, u32, u64
. -
Improved diagnostics.
StarkNet contract features
- Contract address. For example:
#[contract]
mod contract {
...
#[event]
fn Transfer(from: ContractAddress, to: ContractAddress, value: u256) {}
#[event]
fn Approval(owner: ContractAddress, spender: ContractAddress, value: u256) {}
...
}
Sierra
The Sierra language was stabilized as a preparation for integration with Starknet.
Bug fixes
Fixed Dups and Drops behavior.
Fixed types inference bug.
Support recursive types.
Release v1.0.0-alpha.2
Release notes
Cairo Language
- Support for type inference. For example:
Instead of:You can now also use:let arr = ArrayTrait::<felt>::new(); arr.append(1);
let arr = ArrayTrait::new(); arr.append(1);
- Support for global constants:
const CONSTANT: felt = 1;
- Support for serialization:
let mut data = ArrayTrait::new(); serde::Serde::serialize(ref data, value);
- Syntax change - requiring
ref
keyword on callsite. For example:
Instead ofUse:array_append(arr, 1);
array_append(ref arr, 1);
- Support for dictionaries from felt to {
u128
,felt
,u8
,u64
,Nullable::<T>
}.let mut d = DictFeltToTrait::new(); d.insert(1, 1); // Write. d.get(1); // Read. d.squash(); // Destroy the dictionary.
- Function inlining - support only for very simple functions. For example:
#[inline(always)] fn foo(arg: felt) -> felt { … }
- Basic print capabilities.
debug::print_felt(‘some debug short string’);
- Trait support. For example:
trait SomeTrait<T> { fn some_func(a: T); } impl SomeTypeSomeTrait of SomeTrait::<SomeType> { fn some_func(a: SomeType) { …implementation… } } // This line would now work in code that sees both `SomeTrait` and `SomeTypeSomeTrait`. SomeTrait::some_func(SomeType { … initialization … });
- Self and methods support. For example:
struct MyStruct { … members … } trait MyTrait { fn calc(self: MyStruct, a: felt) -> u128; } impl MyImpl of MyTrait { fn calc(self: MyStruct, a: felt) -> u128 { … implementation … } } // This line would now work in code that sees both `MyTrait` and `MyImpl`. let value = MyStruct { … initialization ... }.calc(5);
- Generic user code support. For example:
fn pair_swap<T, S>(p: (T, S)) -> (S, T) { let (t, s) = p; (s, t) }
- Added ec library support
- ec::{ec_state_init, ec_state_add, ec_state_finalize, ec_state_add_mul}
- ec::{EcPoint, ec_point_new, ec_point_from_x, ec_point_unwrap, ec_neg}
- Core Library extended:
- Option::{is_some, is_none, unwrap, expect}
- Result::{is_ok, is_err, unwrap, expect, unwrap_err, expect_err}
- Array::{new, at, get, len, append, pop_front}
- DictFeltTo::{new, insert, get, squash}
StarkNet contract features
- Mapping storage variables. For example:
#[contract] mod contract { struct Storage { mapping: Map::<key_type, value_type>, } … }
- Wider storage variables support. For example:
#[contract] mod contract { struct Storage { mapping: Map::<u256, u256>, } … }
- Events. For example:
#[contract] mod contract { … #[event] fn SomeEvent(value1: felt, value2: bool, value3: u256) {} }
Bug fixes
- Borrow checking is now handled correctly.
- Multiple panics were removed.
- Crate can be used as a dependency - by explicitly specifying corelib location.
Release 0.1.0
Release 0.1.0
Includes:
- Cairo compiler
- Sierra compiler
- Starknet compiler
- Language server
- Formatter
- Runner and testing framework