Releases: starkware-libs/cairo
Releases · starkware-libs/cairo
v2.4.0-rc2
What's Changed
- Downgrade cairo-felt and cairo-vm dependencies back to the previous versions. by #4392
Full Changelog: v2.4.0-rc1...v2.4.0-rc2
v2.4.0-rc1
Bug Fixes
- Raise diagnostic on impl inference cycle. #4368
- Made ap-changes be calculated without LP. #4250
- Fixes various inconsistent annotations code.
- Uses an algorithm similar to the new gas usage calculation - available only for 1.4.0 sierra declared classes.
New Features
- Improved Trait Mismatch diagnostic message. #4374
Other
- Upgrade dependencies. #4370
Full Changelog: v2.4.0-rc0...v2.4.0-rc1
v2.4.0-rc0
This is the Cairo version associated with Starknet 0.13.0. Contracts written with 2.4.0 are not declarable on Starknet until the upgrade.
Major Updates
- Added basic byte array formatting:
- Added
core::fmt::Formatter
for creating aByteArray
constructively. - Added
core::fmt::Display
andcore::fmt::Debug
as traits describing how to write a value based on a format string. - Added
derive
forDebug
for easy implementation ofcore::fmt::Debug
. - Inline macros
write!
andwriteln!
- adds to a formatter:write!(f, "format_string({})", value)
. - Inline macro
format!
- creates a byte array:format!("format_string({})", value)
. - Inline macros
print!
andprintln!
- prints a format string to stdout for debug:print!("format_string({})", value)
. - Inline macro
panic!
- panics with a formatted byte array:panic!("format_string({})", value)
. - Inline macro
assert!
- asserts condition:- Panic with the format string if the condition is false:
assert!(cond, "format_string({})", value)
. - Panic with the condition as a bytearray if the condition is false:
assert!(cond)
.
- Panic with the format string if the condition is false:
- In test plugin only Inline macro
assert_eq!
- asserts equality condition:assert_eq!(a, b, "Extra description {}, param");
- Added
- Contracts with sierra versions 1.4.0 and up calculate gas usage in a more efficient way.
- Removed need for
available_gas
in tests not testing specific gas usage - Now using a default large value. (#4172)- If testing not using dynamic gas - add
#[available_gas(static)]
instead.
- If testing not using dynamic gas - add
- Added Cairo Editions, allowing introducing opt-in for features that make break existing code.
- Currently 2 editions exist:
2023_01
(default) and2023_10
.
- Currently 2 editions exist:
- Added prelude (control for which code is in the context for all cairo code).
- Previously - all the corelib base module was in the context of all cairo code.
- Now - it is according to edition configured per crate:
2023_01
- The prelude includes all the top level of the corelib as of the state of the corelib at release2.3.1
.2023_10
- A much smaller subset.
- Users are encouraged to update their packages to the newest edition.
- Updated ExecutionInfo to be an extended version.
Bug Fixes
Optimizations
- Removing extra store temps happening before store locals. #4173
- Added cast for signed integers. #3623
- Changed bytes31 casts to use libfunc upcast. #4098
- Accessing a member of a struct does not cause all the struct to be stored. #4263
- Avoid storing zero sized objects on the stack. #4290
- Adding
Zero-Sized
handling in the Sierra-to-casm compiler for better stack merging capabilities, and more efficient casm.
New Features
- Added libfunc for efficient u256 inv_mod_n. #3603
- Added Nullable
deref_or
method by @enitrat in #4037 - Added Option
unwrap_or
andunwrap_default
by @Eikix in #4203 - Added
append_array
to Array. #4260 - Added
match_nullable_snapshot
. #4253 - Testing
#[should_panic(expected: 'error')]
supported - no need for wrapping(
)
in the case of a single var. - Testing
#[should_panic(expected: "error")]
supported - for testing panicking with byte array. - Add verify_signature function for secp curves. #4120
- Zero and One traits by @enitrat in #4254
- Support match on felt252 continuous from 0 and on values. #4284
- Skip attributes with no related item, getting better diagnostics for later code. #4296
- Added plugin suites. #4349
- Better compiler performance by avoiding data copies. #4244
- Caching compiler parser actions. #4247
- Allocate arguments before return values, generating more easily read Sierra code. #4258
- Move literal values validation to parser. #4295
- Made inline macro plugins point to the inner syntax, Improving diagnostics. #4345
Others
- docs: fix typo by @shuoer86 in #4235
- fix typos by @vuittont60 in #4264
- Remove redundent diagnostics for inline macros. #4346
New Contributors
- @shuoer86 made their first contribution in #4235
- @Eikix made their first contribution in #4203
- @vuittont60 made their first contribution in #4264
Full Changelog: v2.3.1...v2.4.0-rc0
v2.3.1
Bug fixes
- Semantic evaluation of tail statement of loop after the other statements, Fixing #4318. #4319
- Fixed scc panic checks to be consistently post inlining, Fixing #4314. #4315
- Solved #4380. missing inference of
?
error type. #4321 - Made unsupported attribute error not happen on dropped elements. #4323
What's Changed
- Implement IntoIterator for Contract. #4322
Full Changelog: v2.3.0...v2.3.1
v2.3.0
Major Updates
- Components support. see more details.
Breaking Changes
- Some
*Internal
member traits no longer available - the non-internal versions still exists. - Added diagnostics for attributes not declared in plugins. #4096
- Secp functions updates, better splitting into modules for eth signature functionalities. #4287
Bug fixes
- Fixed derive Hash for enums. #3959
- Handling impl alias generics lookup (no longer causes compiler panic). #3990
- Added support for zero sized types in contract/component storage. #3998
- Added support for path types in contract/component storage members. #3995
- Refactored derives in starknet to make Store and Event work together. #4040
- Fixed issue #4036. #4058
- Fixing issue #4034. Removing unused vars goto mappings. #4069
- Fixed issue 4038. Properly finding required ap tracking config. #4070
- Fixed issue #4075 solving recursive type. #4083* Missing type due not propagated through inference as known type. #4156
- Validating in tests that deployed class hashes are declared. #4157
- Generating diagnostics when using string literal with non-matching type. #4179
- Prevented bugs in
use
statements being propagated as many additional errors. #4175 #4193 - Handling doc of
generate_trait
. #4201 - Removed panic from looking up completions in non inline submodules. #4239
- Fixed returned execution info simulation to include all fields. #4274
What's Changed
- Improved diagnostics:
- Adding
Hash
impl for ClassHash by @gaetbout in #3962 - Added conversions of basic types to byte-arrays. #3893
- feat: serde for signed integer types by @milancermak in #3923
- Added support for events defined out of contract. #3980
- feat(cairo-format): allow using module items sorting. #3991
- Added Hash/Store/Serde to types for secp
Signature
andEthAddress
. #4001 - Enabled no panic minus literal. #4025
- Added traits from impl aliases in the module, to the context. #4042
- Added support for minus literals in const items. #4027
- Improve macro coloring in language server. #4053
- Added anonymous impl generic params. #4051
- Add Coloring to generic impls. #4080
- Added implementation for i128 mul. #3625
- feat: ok_or by @enitrat in #4066
- feat: add print functionality to signed integers by @rmrt1n in #4082
- Updating formatting of short arm blocks. #4099
- Allow untyped tail expr in loops. #4104
- Made more fine grained borrow checking for branch merges. #4124
- Fix formatting of generic args. #4081
- Giving diagnostics instead of crashing on bad match inputs. #4147
- Compiler runtime improvements. #4279
- Added dep_component{_mut}! macros, for easier usage of a component within another component. #4271
New Contributors
Full Changelog: v2.2.0...v2.3.0
v2.3.0-rc0
Major Updates
- Components support. see more details.
Breaking Changes
- Some
*Internal
member traits no longer available - the non-internal versions still exists. - Added diagnostics for attributes not declared in plugins. #4096
Bug fixes
- Fixed derive Hash for enums. #3959
- Handling impl alias generics lookup (no longer causes compiler panic). #3990
- Added support for zero sized types in contract/component storage. #3998
- Added support for path types in contract/component storage members. #3995
- Refactored derives in starknet to make Store and Event work together. #4040
- Fixed issue #4036. #4058
- Fixing issue #4034. Removing unused vars goto mappings. #4069
- Fixed issue 4038. Properly finding required ap tracking config. #4070
- Fixed issue #4075 solving recursive type. #4083
What's Changed
- Improved diagnostics:
- Adding
Hash
impl for ClassHash by @gaetbout in #3962 - Added conversions of basic types to byte-arrays. #3893
- feat: serde for signed integer types by @milancermak in #3923
- Added support for events defined out of contract. #3980
- feat(cairo-format): allow using module items sorting. #3991
- Added Hash/Store/Serde to types for secp
Signature
andEthAddress
. #4001 - Enabled no panic minus literal. #4025
- Added traits from impl aliases in the module, to the context. #4042
- Added support for minus literals in const items. #4027
- Improve macro coloring in language server. #4053
- Added anonymous impl generic params. #4051
- Add Coloring to generic impls. #4080
- Added implementation for i128 mul. #3625
- feat: ok_or by @enitrat in #4066
- feat: add print functionality to signed integers by @rmrt1n in #4082
- Updating formatting of short arm blocks. #4099
- Allow untyped tail expr in loops. #4104
- Made more fine grained borrow checking for branch merges. #4124
- Fix formatting of generic args. #4081
- Giving diagnostics instead of crashing on bad match inputs. #4147
New Contributors
Full Changelog: v2.2.0...v2.3.0-rc0
v2.2.0
Breaking Changes
Bug Fixes
- Avoid unnecessary struct reconstruction. #3739
- Marked account contract trait with starknet interface. #3743
- Fixed error message for missing gas. #3738
- Fixed member usages under
if
s in loops. #3770 - Forbid error propagation inside a loop. #3773
- Fixing snippets view fn without external by @gaetbout in #3857
- Fix issues with self referential generics. #3879
- Fix issue #3863. #3892
New Features
- Formatter Improvements.
- Better line breaks in recursive struct construction.
- No extra space after commas at end of lines.
- Language Server improvements.
- Additional auto completions.
- Additional goto definitions.
- Better syntax highlighting.
- ByteArray + String literals (Experimental: Cannot be used on starknet).
- Signed Integers (Experimental: Cannot be used on starknet).
- Added estimated gas to test result. #3709
- Added
default
impl for tuples up to size 4. #3742 - Added ecdsa recovery. #3735
- Made error message for entry point be dependent on failing var. #3740
- derive
Serde
for BlockInfo/TxInfo by @enitrat in #3781 - Add option for sorting imports in formatter by @ericnordelo in #3778
- Refactored Hash trait, hash implementation is now generic. #3714
- snippets use array! by @gaetbout in #3814
- Added PartialEq impl for Array. #3812
- Add
pop_l2_to_l1_message
cheatcode by @0xChqrles in #3783 - Nullable new method by @enitrat in #3841
- Added line number to sierra printing. #3902
- Made inline macros pluginable. #3873
- Named generic arguments. #3903
- Added derive for
Default
trait. #3935 - Added derive for
Hash
trait. #3936 - Added inline macro
selector!("entry_point_name")
for starknet, that returns the corresponding numeric value of the entry point selector.
Diagnostics Improvements.
code:
#[derive(Copy)]
struct ACopy {}
#[derive(Drop)]
struct ADrop {}
fn use_a_copy(x: ACopy) { .. }
fn use_a_drop(x: ADrop) { .. }
fn foo(x: ACopy, y: ADrop) -> ADrop {
if true {
use_a_copy(x);
use_a_drop(y);
} else {
}
y
}
diagnostics:
error: Variable was previously moved.
--> lib.cairo:14:3
y
^
note: variable was previously used here:
--> lib.cairo:11:16
use_a_drop(y);
^
note: Trait has no implementation in context: core::traits::Copy::<test::ADrop>
error: Variable not dropped.
--> lib.cairo:8:8
fn foo(x: ACopy, y: ADrop) -> ADrop {
^
+note: the variable needs to be dropped due to the divergence here:
+ --> lib.cairo:9:3
+ if true {
+ ^*******^
note: Trait has no implementation in context: core::traits::Drop::<test::ACopy>
note: Trait has no implementation in context: core::traits::Destruct::<test::ACopy>
code:
struct A {}
fn foo(ref a: A) {
1 + 1;
}
diagnostics:
error: Variable not dropped.
--> lib.cairo:2:12
fn foo(ref a: A) {
^
+note: the variable needs to be dropped due to the potential panic here:
+ --> lib.cairo:3:4
+ 1 + 1;
+ ^***^
note: Trait has no implementation in context: core::traits::Drop::<test::A>
note: Trait has no implementation in context: core::traits::Destruct::<test::A>
code:
struct NonCopy {}
struct MyStruct {
a: felt252,
b: NonCopy,
}
fn foo(mut x: MyStruct) -> MyStruct {
x.a = 17;
x.a += 1;
return x;
}
diagnostics:
error: Variable not dropped.
- --> lib.cairo:10:3
- x.a = 17;
- ^*^
+ --> lib.cairo:9:12
+fn foo(mut x: MyStruct) -> MyStruct {
+ ^
+note: the variable needs to be dropped due to the potential panic here:
+ --> lib.cairo:11:3
x.a += 1;
^******^
note: Trait has no implementation in context: core::traits::Drop::<test::NonCopy>
note: Trait has no implementation in context: core::traits::Destruct::<test::NonCopy>
Optimizations
- Statement reorder and remove unused not only for literals. #3696
- Improve encode/decode implementation. #3800
- Faster compile time generally (Various optimizations)
Others
- Fix typos by @xiaolou86 in #3324
- Fix broken Cairo 0.12 link by @MegaRedHand in #3685
- Search asdf directories for scarb executable by @szymmis in #3665
- Update prerequisits.adoc by @kapsteur in #3816
New Contributors
- @xiaolou86 made their first contribution in #3324
- @MegaRedHand made their first contribution in #3685
- @szymmis made their first contribution in #3665
- @kapsteur made their first contribution in #3816
- @0xChqrles made their first contribution in #3783
- @tkstanczak made their first contribution in #3849
Full Changelog: v2.1.1...v2.2.0
v2.1.1
Bug Fixes
- Correctly updating constructor caller address for testing.
- Not deleting unused inline macros - fully allowing downstream plugins inline macros.
- Fix signature_from_vrs - fixed meaning of
v
part of the signature. #3895 - Support self referential types in compilation.
Full Changelog: v2.1.0...v2.1.1
v2.1.0
Breaking Changes
- Add --single-file flag for all compilations based on a single cairo file (no crate). #3533
- Trait
starknet::StorageAccess
updates:- Renamed to
starknet::Store
. - Updated
derive
for it to bestarknet::Store
. - Removed
_internal
from its methods. - Made
size
not accept a value, in preparation for it being an associated constant for the trait. - Enabling #[default] as a enum variant attribute to set the variant indicator in storage as 0.
- Renamed to
Bug Fixes
- Fix account contract core interface by @gaetbout in #3381
- Fix break returns never type (allowing
let x = if .. { ... } else { break; }
expressions). #3412 - Fixed struct generic impl args compiler panic. #2995.
- Add empty calldata when no constructor validation by @ericnordelo in #3681
- Added dependent types to the ABI.
- Fixed bug in syscall simulation of
secp256k1_get_point_from_x
using the wrong parity. #3768 - Enabled serialization of contracts using Unary minus operator. #3809
New Features
- Formatter Improvements.
- Changed debug::print to print hex values. #3377
- Add pop logs to testing by @ericnordelo in #3300
pop_log_raw
andpop_log<EventType>
for testing contracts emitted events.
- Introduce a
consteval_int
macro to compute const integers at compile-time by @wraitii in #3132 - replace_class support in test runner. #3416
- Added fully functional and approved u256_divmod.
- Added support for all unsigned integers bitwise operations.
- Add array! macro for one-liner initialization of arrays. #3501
- Branch inversion optimization.
if !cond { <code_1> } else { <code_2> }
intoif cond { <code_2> } else { <code_1> }
.
- Full support for secp256k1.
- Full support for Keccak.
- Add safe dispatchers implementation by @Arcticae in #3591
- Using downcasts for more efficient multiplications. #3616
- Feat/support empty variants by @neotheprogramist in #3569
- Updated gas costs for syscalls to be up to date with actual charged gas.
- feat: PartialEq for 2,3,4-tuples by @milancermak in #3556
- Added BoolIntoFelt252. #3667
- feat:serde for Result enum by @PhilippeR26 in #3560
- Better diagnostics for literals for unsupported types. #3675
- Added
starknet::Store
for tuples up to size 4. #3674 - Added StorePacking trait. #3676
- Derive Store impl for enums by @maciejka in #3460
New Contributors
- @MaksymilianDemitraszek made their first contribution in #3283
- @piotmag769 made their first contribution in #3488
- @abulenok made their first contribution in #3588
- @jessupjn made their first contribution in #3580
- @Arcticae made their first contribution in #3591
- @neotheprogramist made their first contribution in #3569
- @cptartur made their first contribution in #3632
- @PhilippeR26 made their first contribution in #3560
Full Changelog: v2.0.2...v2.1.0
v2.1.0-rc4
What's Changed
- Allowing downstream macros. #3818
- Changed enum
derive(starknet::Store)
implementation. #3817- Enabling
#[default]
to set the 0 index field. - None default fields enum indicators are never 0.
- Enabling
Full Changelog: v2.1.0-rc3...v2.1.0-rc4