From 9dd3a769bf8ef133e75533871b0c814ebad4e24d Mon Sep 17 00:00:00 2001 From: Bartosz Nowak Date: Thu, 8 Feb 2024 20:18:32 +0100 Subject: [PATCH] parser implemented --- Cargo.toml | 11 +++++------ benches/Cargo.toml | 1 - run.sh | 6 +----- runner/Cargo.toml | 18 +++--------------- runner/src/main.rs | 32 ++++++++++++++------------------ src/stark.cairo | 2 +- 6 files changed, 24 insertions(+), 46 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fe7297851..dde0e5305 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/benches/Cargo.toml b/benches/Cargo.toml index 0cdf808a2..83e806f79 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -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 diff --git a/run.sh b/run.sh index 585d91d41..d6197daa5 100755 --- a/run.sh +++ b/run.sh @@ -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) diff --git a/runner/Cargo.toml b/runner/Cargo.toml index b12b33767..3989e7104 100644 --- a/runner/Cargo.toml +++ b/runner/Cargo.toml @@ -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 @@ -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) diff --git a/runner/src/main.rs b/runner/src/main.rs index 06d9379f6..2e541fa15 100644 --- a/runner/src/main.rs +++ b/runner/src/main.rs @@ -1,4 +1,3 @@ -mod ast; mod vec252; use std::{ @@ -6,10 +5,18 @@ use std::{ 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)] @@ -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::(&fs::read_to_string(target)?)?.into_v1()?; @@ -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> { - 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())], - )?) -} diff --git a/src/stark.cairo b/src/stark.cairo index d894b1d0d..64e6b9418 100644 --- a/src/stark.cairo +++ b/src/stark.cairo @@ -26,7 +26,7 @@ mod stark_verify; #[cfg(test)] mod tests; -const SECURITY_BITS: felt252 = 96; +const SECURITY_BITS: felt252 = 30; #[derive(Drop)]