Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cairo v0.13.2a0 fixes #142

Merged
merged 9 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 0 additions & 45 deletions .github/workflows/proof_verification_tests.yml

This file was deleted.

2 changes: 1 addition & 1 deletion src/air/layouts/dex/public_input.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl DexPublicInputImpl of PublicInputTrait {
ref memory_index
);

// 3. Output segment
// 3. Output segment
let output_len = output_stop - output_start;
let output = memory
.extract_range(
Expand Down
32 changes: 23 additions & 9 deletions src/air/layouts/recursive/public_input.cairo
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use core::array::ArrayTrait;
use core::traits::Into;
use cairo_verifier::{
common::{
math::{pow, Felt252PartialOrd, Felt252Div},
Expand All @@ -10,7 +12,10 @@ use cairo_verifier::{
segments, get_builtins, CPU_COMPONENT_HEIGHT, CPU_COMPONENT_STEP, LAYOUT_CODE,
PEDERSEN_BUILTIN_ROW_RATIO, RANGE_CHECK_BUILTIN_ROW_RATIO, BITWISE_ROW_RATIO
},
public_input::{PublicInput, PublicInputTrait, verify_cairo1_public_input}
public_input::{
PublicInput, PublicInputTrait, verify_cairo1_public_input,
get_builtins as get_program_builtins
}
},
domains::StarkDomains
};
Expand All @@ -36,7 +41,8 @@ impl RecursivePublicInputImpl of PublicInputTrait {
// TODO support more pages?
assert(self.continuous_page_headers.len() == 0, 'Invalid continuous_page_headers');

let builtins = get_builtins();
let layout_builtins = get_builtins();
let program_builtins = get_program_builtins();
let memory = self.main_page;

// 1. Program segment
Expand All @@ -55,7 +61,7 @@ impl RecursivePublicInputImpl of PublicInputTrait {
assert(
*program[0] == 0x40780017fff7fff, 'Invalid program'
); // Instruction: ap += N_BUILTINS.
assert(*program[1] == builtins.len().into(), 'Invalid program');
assert(*program[1] == program_builtins.len().into(), 'Invalid program');
assert(*program[2] == 0x1104800180018000, 'Invalid program'); // Instruction: call rel ?.
assert(*program[4] == 0x10780017fff7fff, 'Invalid program'); // Instruction: jmp rel 0.
assert(*program[5] == 0x0, 'Invalid program');
Expand All @@ -76,10 +82,10 @@ impl RecursivePublicInputImpl of PublicInputTrait {
// 2.2 Main arguments and return values
let mut begin_addresses = ArrayTrait::new();
let mut stop_addresses = ArrayTrait::new();
let layout_builtins_len = layout_builtins.len();
let mut i = 0;
let builtins_len = builtins.len();
loop {
if i == builtins_len {
if i == layout_builtins_len {
break;
}

Expand All @@ -88,16 +94,24 @@ impl RecursivePublicInputImpl of PublicInputTrait {

i += 1;
};
memory.verify_stack(initial_ap, begin_addresses.span(), builtins_len, ref memory_index);
memory
.verify_stack(
final_ap - builtins_len.into(),
initial_ap,
begin_addresses.span(),
program_builtins.span(),
layout_builtins.span(),
ref memory_index
);
memory
.verify_stack(
final_ap - program_builtins.len().into(),
stop_addresses.span(),
builtins_len,
program_builtins.span(),
layout_builtins.span(),
ref memory_index
);

// 3. Output segment
// 3. Output segment
let output_len = output_stop - output_start;
let output = memory
.extract_range(
Expand Down
30 changes: 21 additions & 9 deletions src/air/layouts/recursive_with_poseidon/public_input.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ use cairo_verifier::{
PEDERSEN_BUILTIN_ROW_RATIO, RANGE_CHECK_BUILTIN_ROW_RATIO, BITWISE_ROW_RATIO,
POSEIDON_ROW_RATIO
},
public_input::{PublicInput, PublicInputTrait, verify_cairo1_public_input}
public_input::{
PublicInput, PublicInputTrait, verify_cairo1_public_input,
get_builtins as get_program_builtins
}
},
domains::StarkDomains
};
Expand All @@ -37,7 +40,8 @@ impl RecursiveWithPoseidonPublicInputImpl of PublicInputTrait {
// TODO support more pages?
assert(self.continuous_page_headers.len() == 0, 'Invalid continuous_page_headers');

let builtins = get_builtins();
let layout_builtins = get_builtins();
let program_builtins = get_program_builtins();
let memory = self.main_page;

// 1. Program segment
Expand All @@ -56,7 +60,7 @@ impl RecursiveWithPoseidonPublicInputImpl of PublicInputTrait {
assert(
*program[0] == 0x40780017fff7fff, 'Invalid program'
); // Instruction: ap += N_BUILTINS.
assert(*program[1] == builtins.len().into(), 'Invalid program');
assert(*program[1] == program_builtins.len().into(), 'Invalid program');
assert(*program[2] == 0x1104800180018000, 'Invalid program'); // Instruction: call rel ?.
assert(*program[4] == 0x10780017fff7fff, 'Invalid program'); // Instruction: jmp rel 0.
assert(*program[5] == 0x0, 'Invalid program');
Expand All @@ -77,10 +81,10 @@ impl RecursiveWithPoseidonPublicInputImpl of PublicInputTrait {
// 2.2 Main arguments and return values
let mut begin_addresses = ArrayTrait::new();
let mut stop_addresses = ArrayTrait::new();
let layout_builtins_len = layout_builtins.len();
let mut i = 0;
let builtins_len = builtins.len();
loop {
if i == builtins_len {
if i == layout_builtins_len {
break;
}

Expand All @@ -89,16 +93,24 @@ impl RecursiveWithPoseidonPublicInputImpl of PublicInputTrait {

i += 1;
};
memory.verify_stack(initial_ap, begin_addresses.span(), builtins_len, ref memory_index);
memory
.verify_stack(
final_ap - builtins_len.into(),
initial_ap,
begin_addresses.span(),
program_builtins.span(),
layout_builtins.span(),
ref memory_index
);
memory
.verify_stack(
final_ap - program_builtins.len().into(),
stop_addresses.span(),
builtins_len,
program_builtins.span(),
layout_builtins.span(),
ref memory_index
);

// 3. Output segment
// 3. Output segment
let output_len = output_stop - output_start;
let output = memory
.extract_range(
Expand Down
30 changes: 21 additions & 9 deletions src/air/layouts/small/public_input.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use cairo_verifier::{
segments, get_builtins, CPU_COMPONENT_HEIGHT, CPU_COMPONENT_STEP, LAYOUT_CODE,
PEDERSEN_BUILTIN_ROW_RATIO, RANGE_CHECK_BUILTIN_ROW_RATIO, ECDSA_BUILTIN_ROW_RATIO
},
public_input::{PublicInput, PublicInputTrait, verify_cairo1_public_input}
public_input::{
PublicInput, PublicInputTrait, verify_cairo1_public_input,
get_builtins as get_program_builtins
}
},
domains::StarkDomains
};
Expand All @@ -36,7 +39,8 @@ impl SmallPublicInputImpl of PublicInputTrait {
// TODO support more pages?
assert(self.continuous_page_headers.len() == 0, 'Invalid continuous_page_headers');

let builtins = get_builtins();
let layout_builtins = get_builtins();
let program_builtins = get_program_builtins();
let memory = self.main_page;

// 1. Program segment
Expand All @@ -55,7 +59,7 @@ impl SmallPublicInputImpl of PublicInputTrait {
assert(
*program[0] == 0x40780017fff7fff, 'Invalid program'
); // Instruction: ap += N_BUILTINS.
assert(*program[1] == builtins.len().into(), 'Invalid program');
assert(*program[1] == program_builtins.len().into(), 'Invalid program');
assert(*program[2] == 0x1104800180018000, 'Invalid program'); // Instruction: call rel ?.
assert(*program[4] == 0x10780017fff7fff, 'Invalid program'); // Instruction: jmp rel 0.
assert(*program[5] == 0x0, 'Invalid program');
Expand All @@ -76,10 +80,10 @@ impl SmallPublicInputImpl of PublicInputTrait {
// 2.2 Main arguments and return values
let mut begin_addresses = ArrayTrait::new();
let mut stop_addresses = ArrayTrait::new();
let layout_builtins_len = layout_builtins.len();
let mut i = 0;
let builtins_len = builtins.len();
loop {
if i == builtins_len {
if i == layout_builtins_len {
break;
}

Expand All @@ -88,16 +92,24 @@ impl SmallPublicInputImpl of PublicInputTrait {

i += 1;
};
memory.verify_stack(initial_ap, begin_addresses.span(), builtins_len, ref memory_index);
memory
.verify_stack(
final_ap - builtins_len.into(),
initial_ap,
begin_addresses.span(),
program_builtins.span(),
layout_builtins.span(),
ref memory_index
);
memory
.verify_stack(
final_ap - program_builtins.len().into(),
stop_addresses.span(),
builtins_len,
program_builtins.span(),
layout_builtins.span(),
ref memory_index
);

// 3. Output segment
// 3. Output segment
let output_len = output_stop - output_start;
let output = memory
.extract_range(
Expand Down
30 changes: 21 additions & 9 deletions src/air/layouts/starknet/public_input.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ use cairo_verifier::{
PEDERSEN_BUILTIN_ROW_RATIO, RANGE_CHECK_BUILTIN_ROW_RATIO, BITWISE_ROW_RATIO,
ECDSA_BUILTIN_ROW_RATIO, EC_OP_BUILTIN_ROW_RATIO, POSEIDON_ROW_RATIO
},
public_input::{PublicInput, PublicInputTrait, verify_cairo1_public_input}
public_input::{
PublicInput, PublicInputTrait, verify_cairo1_public_input,
get_builtins as get_program_builtins
}
},
domains::StarkDomains
};
Expand All @@ -37,7 +40,8 @@ impl StarknetPublicInputImpl of PublicInputTrait {
// TODO support more pages?
assert(self.continuous_page_headers.len() == 0, 'Invalid continuous_page_headers');

let builtins = get_builtins();
let layout_builtins = get_builtins();
let program_builtins = get_program_builtins();
let memory = self.main_page;

// 1. Program segment
Expand All @@ -56,7 +60,7 @@ impl StarknetPublicInputImpl of PublicInputTrait {
assert(
*program[0] == 0x40780017fff7fff, 'Invalid program'
); // Instruction: ap += N_BUILTINS.
assert(*program[1] == builtins.len().into(), 'Invalid program');
assert(*program[1] == program_builtins.len().into(), 'Invalid program');
assert(*program[2] == 0x1104800180018000, 'Invalid program'); // Instruction: call rel ?.
assert(*program[4] == 0x10780017fff7fff, 'Invalid program'); // Instruction: jmp rel 0.
assert(*program[5] == 0x0, 'Invalid program');
Expand All @@ -77,10 +81,10 @@ impl StarknetPublicInputImpl of PublicInputTrait {
// 2.2 Main arguments and return values
let mut begin_addresses = ArrayTrait::new();
let mut stop_addresses = ArrayTrait::new();
let layout_builtins_len = layout_builtins.len();
let mut i = 0;
let builtins_len = builtins.len();
loop {
if i == builtins_len {
if i == layout_builtins_len {
break;
}

Expand All @@ -89,16 +93,24 @@ impl StarknetPublicInputImpl of PublicInputTrait {

i += 1;
};
memory.verify_stack(initial_ap, begin_addresses.span(), builtins_len, ref memory_index);
memory
.verify_stack(
final_ap - builtins_len.into(),
initial_ap,
begin_addresses.span(),
program_builtins.span(),
layout_builtins.span(),
ref memory_index
);
memory
.verify_stack(
final_ap - program_builtins.len().into(),
stop_addresses.span(),
builtins_len,
program_builtins.span(),
layout_builtins.span(),
ref memory_index
);

// 3. Output segment
// 3. Output segment
let output_len = output_stop - output_start;
let output = memory
.extract_range(
Expand Down
Loading
Loading