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

refactor: Cairo trace #697

Draft
wants to merge 190 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
eea014e
Add f_op1_imm_bit constraint
entropidelic Nov 21, 2023
b8b8811
Add flag_res_op1_bit constraint
entropidelic Nov 21, 2023
9132999
Add flag_pc_update_regular_bit constraint
entropidelic Nov 21, 2023
cd1c7c6
Add flag_fp_update_regular_bit constraint
entropidelic Nov 21, 2023
1f0a852
Add cpu/opcodes/call/off0 constraint
entropidelic Nov 21, 2023
96b72c6
Add cpu/opcodes/call/off1 constraint
entropidelic Nov 21, 2023
48285de
Add cpu/opcodes/call/flags constraint
entropidelic Nov 21, 2023
f3d608f
Add cpu/opcodes/ret/off0 constraint
entropidelic Nov 21, 2023
08138c4
Add cpu/opcodes/ret/off2 constraint
entropidelic Nov 21, 2023
589423b
Add cpu/opcodes/ret/flags constraint
entropidelic Nov 21, 2023
718a062
Merge branch 'main' into add-constraints
entropidelic Nov 22, 2023
20b6a75
Fix wasm tes
entropidelic Nov 22, 2023
e8be514
Merge remote-tracking branch 'origin/add-constraints' into add-constr…
entropidelic Nov 22, 2023
3680920
Fix wasm test
entropidelic Nov 22, 2023
029df35
Add layouts folder
entropidelic Nov 22, 2023
817f5c3
Merge branch 'main' into refactor-cairo-trace
entropidelic Nov 22, 2023
a43a388
Add constants
entropidelic Nov 23, 2023
b8a3c92
Merge branch 'main' into refactor-cairo-trace
entropidelic Nov 23, 2023
dcf72ee
Add more trace cells position constants
entropidelic Nov 23, 2023
dad50aa
Merge branch 'main' into refactor-cairo-trace
entropidelic Nov 23, 2023
77f5b77
Move plain layout AIR to its file
entropidelic Nov 23, 2023
b16cf76
Add set_offsets function
entropidelic Nov 23, 2023
b8a19c3
Add test for set_offsets function
entropidelic Nov 24, 2023
6ec7941
Merge branch 'main' into refactor-cairo-trace
entropidelic Nov 24, 2023
a0187fa
Add test for set_update_pc function
entropidelic Nov 24, 2023
b1efd61
Merge remote-tracking branch 'origin/refactor-cairo-trace' into refac…
entropidelic Nov 24, 2023
b18f4f0
Add test for set_mem_pool
entropidelic Nov 24, 2023
857db79
Add set_flag_prefixes function and test
entropidelic Nov 24, 2023
8b30f6d
Remove code
entropidelic Nov 24, 2023
8058264
Start work on sorted trace cell values
entropidelic Nov 27, 2023
0a7c53d
Add stone-compatible fill memory holes functionality
entropidelic Nov 27, 2023
89f1b30
Add stone-compatible fill rc holes functionality
entropidelic Nov 27, 2023
6b5b6a9
Fix bug in finalize_rc_pool
entropidelic Nov 27, 2023
9c66dd7
Fix get_rc_holes function
entropidelic Nov 28, 2023
57f0aff
Add rc sorted values column
entropidelic Nov 28, 2023
86892da
Add assertion for rc holes
entropidelic Nov 28, 2023
08978ac
Save work in progress
entropidelic Nov 28, 2023
5fceb59
Save work in progress
entropidelic Nov 28, 2023
93583c9
Save work in progress
entropidelic Nov 29, 2023
09b92f5
Merge branch 'main' into refactor-cairo-trace
entropidelic Nov 29, 2023
26ae5b3
Save progress in set_sorted_mem_pool
entropidelic Nov 29, 2023
031c607
Merge branch 'main' into refactor-cairo-trace
entropidelic Nov 29, 2023
1a76340
Add sorted memory stone compatible column to trace
entropidelic Nov 30, 2023
336b1ec
remove legacy code
entropidelic Nov 30, 2023
5329135
Start refactor
entropidelic Dec 14, 2023
9219428
Add TransitionZerofiersIter and implement Iterator trait
entropidelic Dec 15, 2023
3b97382
Stark prover code compiling
entropidelic Dec 15, 2023
00f7fb1
Save progress
entropidelic Dec 15, 2023
2572ae6
Refactor is compiling
entropidelic Dec 18, 2023
c33f548
Comment code to run only fibonacci AIR tests
entropidelic Dec 18, 2023
368ee81
Change compute_transition function
entropidelic Dec 19, 2023
12d7894
Code is compiling
entropidelic Dec 19, 2023
cc3a058
Add some debug prints
entropidelic Dec 19, 2023
216fc00
Dummy commit
entropidelic Dec 19, 2023
ff2d52a
Dummy commit
entropidelic Dec 19, 2023
17e0b2d
Dummy commit
entropidelic Dec 19, 2023
a95fe56
Fix zerofier evaluations bugs and make fibonacci AIR test pass
entropidelic Dec 19, 2023
dae0093
Remove commented code
entropidelic Dec 20, 2023
ae504be
Implement bit flags AIR and test
entropidelic Dec 20, 2023
725e276
Add bit flag AIR example file
entropidelic Dec 20, 2023
50098fb
Fix get_trace_evaluations function for multi-row step AIRs
entropidelic Dec 21, 2023
db071c1
Save debugging process
entropidelic Dec 23, 2023
edb653d
Refactor step view functionality
entropidelic Jan 4, 2024
8c09d43
Save work in progress
entropidelic Jan 4, 2024
5d98b39
Bugs fixed and bit flags AIR integration test pussing
entropidelic Jan 4, 2024
b11cffb
Remove unused code
entropidelic Jan 4, 2024
d30a25b
Fix fibonacci 2 cols to new constraints design
entropidelic Jan 5, 2024
ee73a6e
Fix quadratic AIRs to new constraints design
entropidelic Jan 5, 2024
9fea590
Fix fibonacci RAP AIR
entropidelic Jan 5, 2024
aa92bf1
Fix shifted 2 columns fibonacci AIR to new constraints design
entropidelic Jan 5, 2024
eb45666
Fix dummy AIR to new constraints design
entropidelic Jan 5, 2024
324bd3b
Remove unused code and fix winterfell adapter version of lambdaworks …
entropidelic Jan 5, 2024
4411e50
Implement some Cairo constraints with the new constraints model
entropidelic Jan 8, 2024
ad8d5b4
Add some more constraints
entropidelic Jan 8, 2024
0503bab
Finish operand constraints
entropidelic Jan 8, 2024
922561b
Add some more constraints
entropidelic Jan 9, 2024
03db5e2
Finish porting all constraints
entropidelic Jan 9, 2024
f647d2e
Make Cairo prover compile
entropidelic Jan 9, 2024
9073632
Make Cairo prover compile
entropidelic Jan 9, 2024
3ed7785
Cairo tests running but not passing with some constraints enabled
entropidelic Jan 9, 2024
90dbe7a
Make zerofier evaluations independent of constraint index in constrai…
entropidelic Jan 10, 2024
c098339
Remove unused code
entropidelic Jan 10, 2024
ed2e117
Remove more unused code
entropidelic Jan 10, 2024
6e82f4f
Rollback change in exercises file
entropidelic Jan 10, 2024
2ccbae8
Uncomment winterfell adapter
entropidelic Jan 10, 2024
b87dca0
Update winterfell adapter AI
entropidelic Jan 10, 2024
19e5531
Update winterfell adapter example
entropidelic Jan 10, 2024
967161a
Fix TOML
entropidelic Jan 10, 2024
662d5d3
Save changes in winterfell adapter
entropidelic Jan 10, 2024
bc2c6c6
Save changes in winterfell adapter
entropidelic Jan 10, 2024
ae5ee5c
Fix TOML
entropidelic Jan 10, 2024
042be77
Fix winterfell adapter crate
entropidelic Jan 10, 2024
80ea80c
Minor fix
entropidelic Jan 10, 2024
4c450fa
Save work in progress
entropidelic Jan 11, 2024
7ba0deb
Save work in progress - code compiling, fibonacci test failing
entropidelic Jan 11, 2024
1fab5a9
Fix some bugs
entropidelic Jan 12, 2024
4479345
Make 2 columns fibonacci test pass
entropidelic Jan 12, 2024
fe69691
Make 2 columns shifted fibonacci test pass
entropidelic Jan 12, 2024
abec134
Save work in progress
entropidelic Jan 15, 2024
33b9be0
Fix bug and make bit flags AIR test pass
entropidelic Jan 15, 2024
2365559
Make quadratic AIR test pass
entropidelic Jan 15, 2024
bb6c0ee
Fix dummy AIR test
entropidelic Jan 15, 2024
044df29
Save work in progress
entropidelic Jan 15, 2024
dd89c08
Fix some bugs
entropidelic Jan 15, 2024
e751cd1
Fix some more bugs
entropidelic Jan 15, 2024
87e43c2
Fix some more bugs
entropidelic Jan 15, 2024
aa95b45
Fix some more bugs
entropidelic Jan 15, 2024
1843be6
Make Cairo tests pass
entropidelic Jan 15, 2024
4143cad
Remove commented code
entropidelic Jan 16, 2024
c8f5333
Merge branch 'main' into constraints-refactor
entropidelic Jan 16, 2024
3065df5
Merge branch 'main' into constraints-refactor
entropidelic Jan 16, 2024
ee457c3
Merge remote-tracking branch 'origin/constraints-refactor' into const…
entropidelic Jan 16, 2024
f0f473e
Pin winterfell adapter and miden example to version of lambdaworks
entropidelic Jan 16, 2024
b7c46c6
Polish code
entropidelic Jan 16, 2024
5bddb6c
Polish more code
entropidelic Jan 16, 2024
a747a89
Fix periodic columns AIR example and tests
entropidelic Jan 16, 2024
d2b86d5
Remove some useless code
entropidelic Jan 16, 2024
1480306
Fix some clippy warnings
entropidelic Jan 16, 2024
fd0a46b
Apply clippy fix
entropidelic Jan 16, 2024
94c25b6
Rearrange debug code in Cairo AIR
entropidelic Jan 16, 2024
5b9aa42
Fix wasm test
entropidelic Jan 16, 2024
48d6403
Import module inside debug scope
entropidelic Jan 16, 2024
890889b
Fix code
entropidelic Jan 16, 2024
f96dfb7
Fix lint
entropidelic Jan 16, 2024
8ee97b2
Remove useless comments
entropidelic Jan 16, 2024
4233aea
Add some docs for transition constraints trait
entropidelic Jan 16, 2024
f95de6c
Polish docs a bit
entropidelic Jan 16, 2024
faa67df
Add more comments to code
entropidelic Jan 17, 2024
74950fc
Remove unused code
entropidelic Jan 17, 2024
90f55cf
Apply optimization
entropidelic Jan 17, 2024
eb6383f
Remove unused code
entropidelic Jan 17, 2024
62aee83
Add some comments
entropidelic Jan 17, 2024
4d88a50
Add type alias for ZerofierGroupKey
entropidelic Jan 17, 2024
c3cc34a
Merge branch 'main' into refactor-cairo-trace
entropidelic Jan 18, 2024
577a6be
Save work in progress
entropidelic Jan 18, 2024
15c0bdf
Save work in progress
entropidelic Jan 18, 2024
bdf6938
Fix public inputs in test
entropidelic Jan 18, 2024
dbede91
Remove unused code
entropidelic Jan 18, 2024
75709ad
Add rc permutation argument column
entropidelic Jan 19, 2024
56b3623
Make trace mutable in AIR trait and fix examples
entropidelic Jan 19, 2024
4c0f0c3
Add memory permutation argument column
entropidelic Jan 19, 2024
acecd53
Merge branch 'constraints-refactor' into refactor-cairo-trace
entropidelic Jan 23, 2024
cdf442e
Save work in progress
entropidelic Jan 23, 2024
c4fc884
Save work in progress
entropidelic Jan 23, 2024
846b5b6
Save work in progress - trait generics problem fixed
entropidelic Jan 23, 2024
1ba9abf
Fix compilation
entropidelic Jan 24, 2024
a108507
Start Cairo AIR debugging
entropidelic Jan 24, 2024
2fb7c3a
Fix some Cairo constraints in the new trace layout
entropidelic Jan 25, 2024
b76edb1
Fix more Cairo constraints
entropidelic Jan 25, 2024
18e8744
Fix more Cairo constraints - 9 fixed
entropidelic Jan 25, 2024
0c4a0cb
Fix more Cairo constraints - 10 fixed
entropidelic Jan 25, 2024
59a8fd4
Fix more Cairo constraints - 12 fixed
entropidelic Jan 25, 2024
2504446
Fix more Cairo constraints - 13 fixed
entropidelic Jan 25, 2024
40c2fe8
Fix more Cairo constraints - 18 fixed
entropidelic Jan 25, 2024
cd0cebc
Fix more Cairo constraints - 20 fixed
entropidelic Jan 25, 2024
50909f4
Fix more Cairo constraints - 21 fixed
entropidelic Jan 25, 2024
b84b174
Fix more Cairo constraints - 22 fixed
entropidelic Jan 25, 2024
db587c3
Fix all Cairo constraints
entropidelic Jan 25, 2024
0a42e92
remove unused code and fix cairo prover bench
entropidelic Jan 25, 2024
4671f98
Merge remote-tracking branch 'origin/main' into refactor-cairo-trace
entropidelic Jan 26, 2024
a23fa3a
Fix compilation and tests
entropidelic Jan 26, 2024
19538cc
Fix some starks integration tests
entropidelic Jan 26, 2024
e80cd6d
Fix fibonacci RAP test
entropidelic Jan 26, 2024
be424db
Remove unused code
entropidelic Jan 26, 2024
a75b48e
Fix more tests
entropidelic Jan 26, 2024
bb2ecb5
Remove unused file
entropidelic Jan 26, 2024
a637ec3
Remove repeated Cairo constriants
entropidelic Jan 26, 2024
be8cbd6
Fix boundary constraints of Cairo AIR and delelte old Cairo AIR file
entropidelic Jan 26, 2024
e81353a
Fix validate_trace debug function
entropidelic Jan 26, 2024
0d3f99c
Refactor some code of validate_trace
entropidelic Jan 26, 2024
8d3fce7
Merge branch 'main' into refactor-cairo-trace
entropidelic Jan 26, 2024
1b0daec
Fix quadratic AIR test
entropidelic Jan 26, 2024
69b36d0
Fix dummy AIR test
entropidelic Jan 26, 2024
8ca9ea7
Merge remote-tracking branch 'origin/main' into refactor-cairo-trace
entropidelic Jan 26, 2024
6e16193
Fix dummy and fibonacci 2 columns shifter AIRs
entropidelic Jan 26, 2024
0d16252
Merge remote-tracking branch 'origin/refactor-cairo-trace' into refac…
entropidelic Jan 26, 2024
521be18
Uncomment miden related examples
entropidelic Jan 26, 2024
5ff233b
Apply some clippy fixes
entropidelic Jan 26, 2024
6316d76
Apply more clippy fixes
entropidelic Jan 26, 2024
902fff5
Apply more clippy fixes
entropidelic Jan 26, 2024
1cbbe5e
Fix instruments feature
entropidelic Jan 26, 2024
a8f2cb1
Fix parallel feature
entropidelic Jan 26, 2024
aedde0d
Increase number of test queries to 3
MauroToscano Jan 31, 2024
aef4332
Update stone compatibility tests
MauroToscano Jan 31, 2024
08288b1
Remove comment
MauroToscano Jan 31, 2024
ce773e7
Merge branch 'main' into refactor-cairo-trace
MauroToscano Jan 31, 2024
3bb0eda
Re add periodic trace tests
MauroToscano Jan 31, 2024
9a0d2a3
Fmt
MauroToscano Jan 31, 2024
af21787
Merge remote-tracking branch 'origin/main' into refactor-cairo-trace
entropidelic Feb 5, 2024
e91f61d
Apply clippy suggestions
entropidelic Feb 5, 2024
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
9 changes: 5 additions & 4 deletions provers/cairo/benches/criterion_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use criterion::{
black_box, criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion,
};
use platinum_prover::{
air::generate_cairo_proof, cairo_layout::CairoLayout, runner::run::generate_prover_args,
cairo_layout::CairoLayout, layouts::plain::air::generate_cairo_proof,
runner::run::generate_prover_args,
};
use stark_platinum_prover::proof::options::{ProofOptions, SecurityLevel};

Expand Down Expand Up @@ -53,12 +54,12 @@ fn run_cairo_bench(
) {
let program_content = std::fs::read(program_path).unwrap();
let proof_options = ProofOptions::new_secure(SecurityLevel::Provable80Bits, 3);
let (main_trace, pub_inputs) = generate_prover_args(&program_content, layout).unwrap();
println!("Generated main trace with {} rows", main_trace.n_rows());
let (mut main_trace, pub_inputs) = generate_prover_args(&program_content, layout).unwrap();
println!("Generated main trace with {} rows", main_trace.num_rows());

group.bench_function(benchname, |bench| {
bench.iter(|| {
black_box(generate_cairo_proof(&main_trace, &pub_inputs, &proof_options).unwrap())
black_box(generate_cairo_proof(&mut main_trace, &pub_inputs, &proof_options).unwrap())
});
});
}
Expand Down
8 changes: 4 additions & 4 deletions provers/cairo/benches/criterion_prover_70k.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use criterion::{
black_box, criterion_group, criterion_main, measurement::WallTime, BenchmarkGroup, Criterion,
SamplingMode,
};
use platinum_prover::cairo_layout::CairoLayout;
use platinum_prover::{air::generate_cairo_proof, runner::run::generate_prover_args};
use platinum_prover::runner::run::generate_prover_args;
use platinum_prover::{cairo_layout::CairoLayout, layouts::plain::air::generate_cairo_proof};
use stark_platinum_prover::proof::options::{ProofOptions, SecurityLevel};

pub mod functions;
Expand Down Expand Up @@ -48,11 +48,11 @@ fn run_cairo_bench(
) {
let program_content = std::fs::read(program_path).unwrap();
let proof_options = ProofOptions::new_secure(SecurityLevel::Provable80Bits, 3);
let (main_trace, pub_inputs) = generate_prover_args(&program_content, layout).unwrap();
let (mut main_trace, pub_inputs) = generate_prover_args(&program_content, layout).unwrap();

group.bench_function(benchname, |bench| {
bench.iter(|| {
black_box(generate_cairo_proof(&main_trace, &pub_inputs, &proof_options).unwrap())
black_box(generate_cairo_proof(&mut main_trace, &pub_inputs, &proof_options).unwrap())
});
});
}
Expand Down
3 changes: 1 addition & 2 deletions provers/cairo/benches/criterion_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ use criterion::{
use lambdaworks_math::{
field::fields::fft_friendly::stark_252_prime_field::Stark252PrimeField, traits::Deserializable,
};
use platinum_prover::air::{verify_cairo_proof, PublicInputs};
use platinum_prover::layouts::plain::air::{verify_cairo_proof, PublicInputs};
use stark_platinum_prover::proof::{
options::{ProofOptions, SecurityLevel},
stark::StarkProof,
};

pub mod functions;

fn load_proof_and_pub_inputs(
Expand Down
2 changes: 1 addition & 1 deletion provers/cairo/benches/criterion_verifier_70k.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use criterion::{
use lambdaworks_math::{
field::fields::fft_friendly::stark_252_prime_field::Stark252PrimeField, traits::Deserializable,
};
use platinum_prover::air::{verify_cairo_proof, PublicInputs};
use platinum_prover::layouts::plain::air::{verify_cairo_proof, PublicInputs};
use stark_platinum_prover::proof::{
options::{ProofOptions, SecurityLevel},
stark::StarkProof,
Expand Down
33 changes: 33 additions & 0 deletions provers/cairo/cairo_programs/cairo0/fibonacci_stone.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright 2023 StarkWare Industries Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.starkware.co/open-source-license/
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions
// and limitations under the License.

func main() {
alloc_locals;

let res = fib(1, 1, 10);

assert res = 144;
// Return the updated output_ptr.
return ();
}

func fib(first_element: felt, second_element: felt, n: felt) -> felt {
if (n == 0) {
return second_element;
}

return fib(
first_element=second_element, second_element=first_element + second_element, n=n - 1
);
}
6 changes: 3 additions & 3 deletions provers/cairo/src/decode/instruction_offsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ impl InstructionOffsets {
i32::from(i16::from_le_bytes(aux))
}

pub fn to_trace_representation<F: IsField>(&self) -> [FieldElement<F>; 3] {
[
pub fn to_trace_representation(&self) -> (Felt252, Felt252, Felt252) {
(
to_unbiased_representation(self.off_dst),
to_unbiased_representation(self.off_op0),
to_unbiased_representation(self.off_op1),
]
)
}
}

Expand Down
Loading
Loading