Skip to content

Commit

Permalink
parser implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed Feb 8, 2024
1 parent dd8282e commit 9dd3a76
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 46 deletions.
11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ version = "0.1.0"
[workspace.dependencies]
anyhow = "1"
cairo-args-runner = "1.0"
clap = { version = "4", features = ["derive"] }
lalrpop = "0.20"
lalrpop-util = { version = "0.20", features = ["lexer", "unicode"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
cairo-felt = "0.9"
cairo-lang-runner = "2.5.0"
cairo-lang-sierra = "2.5.0"
cairo-lang-utils = "2.5.0"
cairo-proof-parser = { git = "https://github.com/cartridge-gg/cairo-proof-parser", tag = "v0.1.0" }
cairo-vm = "0.9.2"
clap = { version = "4", features = ["derive"] }
itertools = "0.12.0"
thiserror = "1.0"
num-bigint = "0.4"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
thiserror = "1.0"
1 change: 0 additions & 1 deletion benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ cairo-lang-utils.workspace = true
cairo-vm.workspace = true
clap.workspace = true
itertools.workspace = true
lalrpop-util.workspace = true
num-bigint.workspace = true
serde_json.workspace = true
serde.workspace = true
Expand Down
6 changes: 1 addition & 5 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#!/usr/bin/env bash

scarb build && \
<<<<<<< HEAD
cargo run --release -- ./target/dev/cairo_verifier.sierra.json < ./resources/in.txt
cargo run --release --bin runner -- ./target/dev/cairo_verifier.sierra.json < ./resources/main_proof.json

scarb build && \
cargo run --release --bin benches -- ./target/dev/cairo_verifier.sierra.json
=======
cargo run --release -- ./target/dev/cairo_verifier.sierra.json < ./resources/main_proof.json
>>>>>>> 5b660f3 (new parser integration)
18 changes: 3 additions & 15 deletions runner/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
[package]
name = "runner"
version = "0.1.0"
edition = "2021"
version.workspace = true
edition.workspace = true

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
<<<<<<< HEAD
anyhow.workspace = true
clap.workspace = true
lalrpop-util.workspace = true
cairo-proof-parser.workspace = true
cairo-felt.workspace = true
cairo-lang-runner.workspace = true
cairo-lang-sierra.workspace = true
Expand All @@ -20,14 +19,3 @@ serde.workspace = true
serde_json.workspace = true
thiserror.workspace = true
num-bigint.workspace = true

[build-dependencies]
lalrpop.workspace = true
=======
anyhow = "1.0.79"
cairo-args-runner = "1.0.1"
clap = { version = "4.4.18", features = ["derive"] }
cairo-proof-parser = { git = "https://github.com/cartridge-gg/cairo-proof-parser", tag = "v0.1.0" }
serde = { version = "1.0.196", features = ["derive"] }
serde_json = "1.0.113"
>>>>>>> 5b660f3 (new parser integration)
32 changes: 14 additions & 18 deletions runner/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
mod ast;
mod vec252;

use std::{
fs,
io::{stdin, Read},
};

use cairo_args_runner::{Arg, Felt252, VecFelt252};
use cairo_lang_runner::{
build_hints_dict, profiling::ProfilingInfoProcessor, Arg, CairoHintProcessor, RunResult, SierraCasmRunner, StarknetState
};
use cairo_lang_sierra::program::VersionedProgram;
use cairo_lang_utils::{ordered_hash_map::OrderedHashMap, unordered_hash_map::UnorderedHashMap};
use cairo_vm::vm::runners::cairo_runner::RunResources;
use clap::Parser;

use cairo_proof_parser::parse;
use itertools::chain;

use crate::vec252::VecFelt252;

#[derive(Parser)]
#[command(author, version, about, long_about = None)]
Expand All @@ -19,16 +26,16 @@ struct Cli {
}

fn main() -> anyhow::Result<()> {
let args = Cli::parse();
let cli = Cli::parse();
let mut input = String::new();
stdin().read_to_string(&mut input)?;
let exprs = parse(input)?.to_string();
let parsed = parse(input)?.to_string();

run(exprs, args.target)?;
println!("{}", parsed);

let target = cli.target;
let function = "main";
let args: VecFelt252 = serde_json::from_str(&result)?;
let args: VecFelt252 = serde_json::from_str(&parsed).unwrap();

let sierra_program =
serde_json::from_str::<VersionedProgram>(&fs::read_to_string(target)?)?.into_v1()?;
Expand Down Expand Up @@ -77,21 +84,10 @@ fn main() -> anyhow::Result<()> {
println!("n_steps: {}", memory.len());
println!("return: {:#?}", value);

let profiling_processor = ProfilingInfoProcessor::new(sierra_program.program);
let profiling_processor = ProfilingInfoProcessor::new(sierra_program.program, UnorderedHashMap::default());
let processed_profiling_info = profiling_processor.process(&profiling_info.unwrap());

// println!("profiling: {}", processed_profiling_info);

Ok(())
}

fn run(parsed: String, target: String) -> anyhow::Result<Vec<Felt252>> {
let target = target;
let function = "main";
let args: VecFelt252 = serde_json::from_str(&parsed).unwrap();
Ok(cairo_args_runner::run(
&target,
function,
&[Arg::Array(args.to_vec())],
)?)
}
2 changes: 1 addition & 1 deletion src/stark.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mod stark_verify;
#[cfg(test)]
mod tests;

const SECURITY_BITS: felt252 = 96;
const SECURITY_BITS: felt252 = 30;


#[derive(Drop)]
Expand Down

0 comments on commit 9dd3a76

Please sign in to comment.