Skip to content

Commit 66355d7

Browse files
Cairo-v0.14.0.1.
1 parent 6d99011 commit 66355d7

File tree

15 files changed

+7096
-6873
lines changed

15 files changed

+7096
-6873
lines changed

src/starkware/cairo/common/cairo_blake2s/blake2s.cairo

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,6 @@ const BLAKE2S_FINALIZE_INSTRUCTION = OFF_MINUS_1 * COUNTER_OFFSET + OFF_MINUS_3
667667
OPCODE_EXT_OFFSET;
668668

669669
// Computes blake2s of `input` of size `len` felts, representing 32 bits each.
670-
// Note: this function guarantees that len > 0.
671670
func blake_with_opcode{range_check_ptr}(len: felt, data: felt*, out: felt*) {
672671
alloc_locals;
673672

@@ -682,8 +681,16 @@ func blake_with_opcode{range_check_ptr}(len: felt, data: felt*, out: felt*) {
682681
assert state[7] = 0x5BE0CD19;
683682

684683
// Express the length in bytes, subtract the remainder for finalize.
685-
let (_, rem) = unsigned_div_rem(len - 1, 16);
686-
local rem = rem + 1;
684+
local rem;
685+
if (len == 0) {
686+
assert rem = 0;
687+
tempvar range_check_ptr = range_check_ptr;
688+
} else {
689+
let (_, r) = unsigned_div_rem(len - 1, 16);
690+
assert rem = r + 1;
691+
tempvar range_check_ptr = range_check_ptr;
692+
}
693+
687694
local len_in_bytes = (len - rem) * 4;
688695

689696
local range_check_ptr = range_check_ptr;

src/starkware/cairo/common/cairo_blake2s/blake2s_test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,23 @@ def test_unpack_into_u32s(program):
438438
),
439439
False,
440440
),
441+
(
442+
[],
443+
True,
444+
blake_state_into_felt(
445+
[
446+
813310313,
447+
2491453561,
448+
3491828193,
449+
2085238082,
450+
1219908895,
451+
514171180,
452+
4245497115,
453+
4193177630,
454+
]
455+
),
456+
False,
457+
),
441458
],
442459
)
443460
def test_calculate_blake2s_hash_from_felt252s(

src/starkware/cairo/common/cairo_blake2s/blake2s_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def calculate_blake2s_hash_from_felt252s(
166166
total_bytes = len(words) * 4
167167
bytes_seen = 0
168168

169-
for i in range(0, len(words), 16):
169+
for i in range(0, max(len(words), 1), 16):
170170
block = words[i : i + 16]
171171
if len(block) < 16:
172172
block += [0] * (16 - len(block))

src/starkware/cairo/lang/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ py_library(
1010
],
1111
data = [
1212
"@" + CAIRO_COMPILER_ARCHIVE,
13+
"//src/starkware/starknet/builtins/segment_arena:segment_arena_cairo_lib",
1314
],
1415
visibility = ["//visibility:public"],
1516
deps = [
1617
"//src/starkware/cairo/bootloaders:cairo_bootloader_generate_fact_lib",
1718
"//src/starkware/cairo/bootloaders:cairo_hash_program_lib",
1819
"//src/starkware/cairo/bootloaders:program_hash_test_utils_lib",
20+
"//src/starkware/cairo/builtin_selection:cairo_builtin_selection_lib",
1921
"//src/starkware/cairo/common:cairo_common_lib",
2022
"//src/starkware/cairo/lang/compiler:cairo_compile_lib",
2123
"//src/starkware/cairo/lang/compiler:cairo_compile_test_utils_lib",

src/starkware/cairo/lang/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.14.0
1+
0.14.0.1

src/starkware/cairo/lang/compiler/cairo_compile.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,25 @@ def cairo_assemble_program(
379379
return program
380380

381381

382+
def cairo_compile_wrapper(args: argparse.Namespace):
383+
"""
384+
Wraps cairo_compile_common with the default pass manager and the assembler.
385+
"""
386+
387+
def pass_manager_factory(args: argparse.Namespace, module_reader: ModuleReader) -> PassManager:
388+
return default_pass_manager(
389+
prime=args.prime,
390+
read_module=module_reader.read,
391+
opt_unused_functions=args.opt_unused_functions,
392+
)
393+
394+
cairo_compile_common(
395+
args=args,
396+
pass_manager_factory=pass_manager_factory,
397+
assemble_func=cairo_assemble_program,
398+
)
399+
400+
382401
def main():
383402
parser = argparse.ArgumentParser(description="A tool to compile Cairo code.")
384403
parser.add_argument(
@@ -395,21 +414,10 @@ def main():
395414
help="Disable proof mode (see --proof_mode).",
396415
)
397416

398-
def pass_manager_factory(args: argparse.Namespace, module_reader: ModuleReader) -> PassManager:
399-
return default_pass_manager(
400-
prime=args.prime,
401-
read_module=module_reader.read,
402-
opt_unused_functions=args.opt_unused_functions,
403-
)
404-
405417
try:
406418
cairo_compile_add_common_args(parser)
407419
args = parser.parse_args()
408-
cairo_compile_common(
409-
args=args,
410-
pass_manager_factory=pass_manager_factory,
411-
assemble_func=cairo_assemble_program,
412-
)
420+
cairo_compile_wrapper(args=args)
413421
except LocationError as err:
414422
print(err, file=sys.stderr)
415423
return 1

src/starkware/cairo/stark_verifier/air/dynamic_layout_proof.json

Lines changed: 3194 additions & 3161 deletions
Large diffs are not rendered by default.

src/starkware/cairo/stark_verifier/air/example_expected.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"public_input_test": {
3-
"initial_hash_chain_seed": "0x0780925e94035a112642ac02f685584462e6290c6902a08c7cfc124883a21837"
3+
"initial_hash_chain_seed": "0x0106ff8c067191534401309349553339cc4574f462295b55b1efd1e72818c7ef"
44
},
55
"dynamic_layout_public_input_test": {
6-
"initial_hash_chain_seed": "0x064ad62db04b674633f85f7f80d3bad37d46cbae742d7b77fe4166be6f232393"
6+
"initial_hash_chain_seed": "0x060ded6fa399a0bec38c1dd55104bdb30bc8a8e1de6a0f652e36cb83134fa076"
77
},
88
"diluted_test": {
99
"spacing": 4,

src/starkware/cairo/stark_verifier/air/example_proof.json

Lines changed: 3832 additions & 3687 deletions
Large diffs are not rendered by default.

src/starkware/starknet/core/os/constants.cairo

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,10 @@ const V1_BOUND_ACCOUNTS_CAIRO0_3 = (
164164
const V1_BOUND_ACCOUNTS_CAIRO0_4 = (
165165
0x041cb0280ebadaa75f996d8d92c6f265f6d040bb3ba442e5f86a554f1765244e
166166
);
167-
const V1_BOUND_ACCOUNTS_CAIRO0_LEN = 5;
167+
const V1_BOUND_ACCOUNTS_CAIRO0_5 = (
168+
0x03530cc4759d78042f1b543bf797f5f3d647cde0388c33734cf91b7f7b9314a9
169+
);
170+
const V1_BOUND_ACCOUNTS_CAIRO0_LEN = 6;
168171

169172
// List of Cairo1 account contracts that require the transaction version to be 1.
170173
const V1_BOUND_ACCOUNTS_CAIRO1_0 = (

0 commit comments

Comments
 (0)