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

Cairo1 proof mode #1517

Merged
merged 21 commits into from
Dec 20, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix comments
MauroToscano committed Nov 23, 2023
commit c4fe8828eb0027bc365911951020e67afa5755d7
15 changes: 7 additions & 8 deletions cairo1-run/src/main.rs
Original file line number Diff line number Diff line change
@@ -178,8 +178,6 @@ fn run(args: impl Iterator<Item = String>) -> Result<Vec<MaybeRelocatable>, Erro
.map_err(|err| Error::SierraCompilation(err.to_string()))?)
.clone();

println!("Sierra: {}", sierra_program);

let metadata_config = Some(Default::default());
let gas_usage_check = metadata_config.is_some();
let metadata = create_metadata(&sierra_program, metadata_config)?;
@@ -191,12 +189,11 @@ fn run(args: impl Iterator<Item = String>) -> Result<Vec<MaybeRelocatable>, Erro

let main_func = find_function(&sierra_program, "::main")?;

println!("Main func: {:?}", main_func.entry_point);
// println!("Main func: {:?}", main_func.entry_point);

// Entry code and footer are part of the whole instructions that are
// ran by the VM.

// We are replacing the entry with a proof mode like code, so this is unused
let initial_gas = 9999999999999_usize;

// This call should be removed
@@ -212,13 +209,16 @@ fn run(args: impl Iterator<Item = String>) -> Result<Vec<MaybeRelocatable>, Erro
let check_gas_usage = false;

// ap_change_info maybe useful, we can also count builtins from sierra
println!("Ap change info: {:?}", metadata.ap_change_info);
let metadata = calc_metadata(&sierra_program, Default::default(), false)?;
let casm_program = compile(&sierra_program, &metadata, check_gas_usage)?;

println!("Builtins: {:?}", builtins);
println!("Compiling with proof mode and running ...");

println!("Builtins used: {:?}", builtins);

// println!(" Main signs: {:?}", main_func.signature.param_types);


println!(" Main signs: {:?}", main_func.signature.param_types);

// Each params needs the AP to be updated for them to work
let amount_of_main_args = main_func.signature.param_types.len();
@@ -261,7 +261,6 @@ fn run(args: impl Iterator<Item = String>) -> Result<Vec<MaybeRelocatable>, Erro
if has_gas_builtin {
// If there's a gas builtin, we need to set the initial gas to a high number. It shouldn't be needed, but cairo sierra compiler will add the "gas builtin" for programs with explicit recursion
// ap needs to be increased at this moment, and not with the usual ap offset
println!("Appending gas builtin code");
casm_extend! {ctx,
[ap + 0] = initial_gas, ap++;
}