Skip to content

Commit 6c2e0bb

Browse files
authored
Update cairo to 2.6.0 (#283)
<!--- Please provide a general summary of your changes in the title above --> ## Pull Request type <!-- Please try to limit your pull request to one type; submit multiple pull requests if needed. --> Please check the type of change your PR introduces: - [ ] Bugfix - [ ] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no API changes) - [x] Build-related changes - [ ] Documentation content changes - [ ] Other (please describe): <!-- Please describe the behavior or changes that are being added by this PR. --> - Updated scarb.toml and ran new format ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this does introduce a breaking change, please describe the impact and migration path for existing applications below. --> This will need a new release of alexandria
1 parent e7b6957 commit 6c2e0bb

8 files changed

Lines changed: 48 additions & 40 deletions

File tree

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
scarb 2.5.4
1+
scarb 2.6.0

Scarb.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ name = "alexandria"
1717
version = "0.1.0"
1818
description = "Community maintained Cairo and Starknet libraries"
1919
homepage = "https://github.com/keep-starknet-strange/alexandria/"
20-
cairo-version = "2.5.4"
20+
cairo-version = "2.6.0"
2121

2222
[workspace.dependencies]
23-
starknet = "=2.5.4"
23+
starknet = "=2.6.0"
2424

2525
[workspace.tool.fmt]
2626
sort-module-level-items = true

src/ascii/src/integer.cairo

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ impl ToAsciiArrayTraitImpl<
3636
}
3737

3838
let mut num = self;
39-
while num.is_non_zero() {
40-
let (quotient, remainder) = DivRem::div_rem(
41-
num, TryInto::<felt252, T>::try_into(10).unwrap().try_into().expect('Division by 0')
42-
);
43-
new_arr.append(remainder.into() + 48);
44-
num = quotient;
45-
};
39+
while num
40+
.is_non_zero() {
41+
let (quotient, remainder) = DivRem::div_rem(
42+
num,
43+
TryInto::<felt252, T>::try_into(10).unwrap().try_into().expect('Division by 0')
44+
);
45+
new_arr.append(remainder.into() + 48);
46+
num = quotient;
47+
};
4648
new_arr
4749
}
4850
}

src/bytes/src/bytes.cairo

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,13 @@ impl BytesImpl of BytesTrait {
499499
let mut hash_data: Array<u8> = array![];
500500
let mut i: usize = 0;
501501
let mut offset: usize = 0;
502-
while i != self.size() {
503-
let (new_offset, hash_data_item) = self.read_u8(offset);
504-
hash_data.append(hash_data_item);
505-
offset = new_offset;
506-
i += 1;
507-
};
502+
while i != self
503+
.size() {
504+
let (new_offset, hash_data_item) = self.read_u8(offset);
505+
hash_data.append(hash_data_item);
506+
offset = new_offset;
507+
i += 1;
508+
};
508509

509510
let output: Array<u8> = sha256(hash_data);
510511
u8_array_to_u256(output.span())

src/bytes/src/utils.cairo

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,15 @@ fn update_u256_array_at(arr: @Array<u256>, index: usize, value: u256) -> Array<u
7171
let mut new_arr = array![];
7272
let mut i = 0;
7373

74-
while i != arr.len() {
75-
if i == index {
76-
new_arr.append(value);
77-
} else {
78-
new_arr.append(*arr[i]);
79-
}
80-
i += 1;
81-
};
74+
while i != arr
75+
.len() {
76+
if i == index {
77+
new_arr.append(value);
78+
} else {
79+
new_arr.append(*arr[i]);
80+
}
81+
i += 1;
82+
};
8283
new_arr
8384
}
8485

src/linalg/src/dot.cairo

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ fn dot<T, +Mul<T>, +AddEq<T>, +Zeroable<T>, +Copy<T>, +Drop<T>,>(
1414

1515
// [Compute] Dot product in a loop
1616
let mut sum = Zeroable::zero();
17-
while !xs.is_empty() {
18-
let x = *xs.pop_front().unwrap();
19-
let y = *ys.pop_front().unwrap();
20-
sum += x * y;
21-
};
17+
while !xs
18+
.is_empty() {
19+
let x = *xs.pop_front().unwrap();
20+
let y = *ys.pop_front().unwrap();
21+
sum += x * y;
22+
};
2223
sum
2324
}

src/math/src/keccak256.cairo

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ fn reverse_endianness(value: u256) -> u256 {
4646
fn keccak256(mut self: Span<u8>) -> u256 {
4747
// Converts byte array to little endian 8 byte words array.
4848
let mut words64: Array<u64> = Default::default();
49-
while self.len() >= 8 {
50-
let current_word = self.slice(0, 8);
51-
let (value, _) = U64Trait::from_le_bytes(current_word);
52-
words64.append(value);
53-
self = self.slice(8, self.len() - 8);
54-
};
49+
while self
50+
.len() >= 8 {
51+
let current_word = self.slice(0, 8);
52+
let (value, _) = U64Trait::from_le_bytes(current_word);
53+
words64.append(value);
54+
self = self.slice(8, self.len() - 8);
55+
};
5556
// handle last word specifically
5657
let (last_word, last_word_bytes) = U64Trait::from_le_bytes(self);
5758
reverse_endianness(cairo_keccak(ref words64, last_word, last_word_bytes))

src/numeric/src/trapezoidal_rule.cairo

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ fn trapezoidal_rule<
2929
// [Compute] Trapezoidal rule
3030
let mut index = 0;
3131
let mut value = Zeroable::zero();
32-
while index + 1 != xs.len() {
33-
assert(*xs[index + 1] > *xs[index], 'Abscissa must be sorted');
34-
value += (*xs[index + 1] - *xs[index]) * (*ys[index] + *ys[index + 1]);
35-
index += 1;
36-
};
32+
while index
33+
+ 1 != xs
34+
.len() {
35+
assert(*xs[index + 1] > *xs[index], 'Abscissa must be sorted');
36+
value += (*xs[index + 1] - *xs[index]) * (*ys[index] + *ys[index + 1]);
37+
index += 1;
38+
};
3739
value / Into::into(2_u8)
3840
}

0 commit comments

Comments
 (0)