Skip to content

Commit

Permalink
Cairo reorganized (#607)
Browse files Browse the repository at this point in the history
* initial commit

* modified README

* fix cairo programs dir

* Update provers/cairo/README.md

Co-authored-by: Mariano A. Nicolini <[email protected]>

* Update provers/cairo/README.md

Co-authored-by: Mariano A. Nicolini <[email protected]>

* Fix cargo

* Re organized

* Remove proof

* Update readme

* Fmt

* CLI feature

* CLI Fix

* Fmt

---------

Co-authored-by: Jmunoz <[email protected]>
Co-authored-by: Mauro Toscano <[email protected]>
Co-authored-by: Mariano A. Nicolini <[email protected]>
Co-authored-by: MauroFab <[email protected]>
  • Loading branch information
5 people authored Oct 18, 2023
1 parent 23154c1 commit 8f7b415
Show file tree
Hide file tree
Showing 18 changed files with 151 additions and 262 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ jobs:
- name: Run cargo check
run: cargo check

- name: Run cargo check cli
run: |
cargo check --features cli
- name: Run cargo check for math with no-std
run: cargo check --package lambdaworks-math --no-default-features

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["math", "crypto", "gpu", "benches", "provers/plonk", "provers/stark", "provers/cairo", "provers/cairo-prover-cli"]
members = ["math", "crypto", "gpu", "benches", "provers/plonk", "provers/stark", "provers/cairo", "provers/cairo"]
exclude = ["ensure-no_std"]
resolver = "2"

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ So, we decided to build our library, focusing on performance, with clear documen
- [Crypto primitives](https://github.com/lambdaclass/lambdaworks/tree/main/crypto)
- [Plonk Prover](https://github.com/lambdaclass/lambdaworks/tree/main/provers/plonk)
- [Cairo Prover](https://github.com/lambdaclass/lambdaworks/tree/main/provers/cairo)
- [Cairo Prover CLI](https://github.com/lambdaclass/lambdaworks/tree/main/provers/cairo-prover-cli)

If you are interested in proving Cairo programs, use the Cairo Prover CLI.

Expand Down
17 changes: 0 additions & 17 deletions provers/cairo-prover-cli/Cargo.toml

This file was deleted.

43 changes: 0 additions & 43 deletions provers/cairo-prover-cli/Makefile

This file was deleted.

107 changes: 0 additions & 107 deletions provers/cairo-prover-cli/README.md

This file was deleted.

11 changes: 0 additions & 11 deletions provers/cairo-prover-cli/cairo_compile.Dockerfile

This file was deleted.

14 changes: 10 additions & 4 deletions provers/cairo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@

[package]
name = "cairo-platinum-prover"
rust-version = "1.66"
version.workspace = true
edition.workspace = true
license.workspace = true

[[bin]]
name = "platinum-prover"
path = "src/main.rs"
required-features = ["cli"]

[lib]
name = "platinum_prover"
crate-type = ["cdylib", "rlib"]

[dependencies]
Expand All @@ -25,15 +30,16 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
num-integer = "0.1.45"
itertools = "0.11.0"

serde_cbor = { version = "0.11.1" }
# For cli
clap = { version = "4.4.6", features = ["derive"], optional = true }
# Parallelization crates
rayon = { version = "1.7.0", optional = true }

# wasm
wasm-bindgen = { version = "0.2", optional = true }
serde-wasm-bindgen = { version = "0.5", optional = true }
web-sys = { version = "0.3.64", features = ['console'], optional = true }
serde_cbor = { version = "0.11.1"}

[dev-dependencies]
hex = "0.4.3"
Expand All @@ -51,7 +57,7 @@ instruments = [] # This enables timing prints in prover and ve
metal = ["lambdaworks-math/metal"]
parallel = ["dep:rayon"]
wasm = ["dep:wasm-bindgen", "dep:serde-wasm-bindgen", "dep:web-sys"]

cli = ["dep:clap"]
[target.'cfg(not(all(target_arch = "wasm32", target_os = "unknown")))'.dev-dependencies]
proptest = "1.2.0"

Expand Down
42 changes: 28 additions & 14 deletions provers/cairo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,37 @@ test: $(COMPILED_CAIRO0_PROGRAMS)

test_metal: $(COMPILED_CAIRO0_PROGRAMS)
cargo test -F metal


docker_build_cairo_compiler:
docker build -f cairo_compile.Dockerfile -t cairo .

docker_compile_cairo:
docker run -v $(ROOT_DIR):/pwd cairo --proof_mode /pwd/$(PROGRAM) > $(COMPILED_PROGRAM)

compile:
cairo-compile --proof_mode $(PROGRAM_PATH) > $(COMPILED_PROGRAM) 2>/dev/null || \
docker run -v $(ROOT_DIR):/pwd cairo --proof_mode /pwd/$(PROGRAM_PATH) > $(COMPILED_PROGRAM)

prove:
cargo run --quiet --release prove $(PROGRAM_PATH) $(PROOF_PATH)

verify:
cargo run --quiet --release verify $(PROOF_PATH)

run_all:
cargo run --quiet --release prove-and-verify $(PROGRAM_PATH)

compile_and_run_all:
@cairo-compile --proof_mode $(PROGRAM_PATH) > $(COMPILED_PROGRAM) 2>/dev/null || \
docker run -v $(ROOT_DIR):/pwd cairo --proof_mode /pwd/$(PROGRAM_PATH) > $(COMPILED_PROGRAM)
@echo "Compiling done \n"
@cargo run --quiet --release prove-and-verify $(COMPILED_PROGRAM) $(PROOF_PATH)
@rm $(COMPILED_PROGRAM)

clippy:
cargo clippy --workspace --all-targets -- -D warnings


benchmarks_sequential: $(COMPILED_CAIRO0_PROGRAMS)
cargo bench

Expand All @@ -44,12 +71,6 @@ benchmarks_parallel_all: $(COMPILED_CAIRO0_PROGRAMS)
build_metal:
cargo b --features metal --release

docker_build_cairo_compiler:
docker build -f cairo_compile.Dockerfile -t cairo .

docker_compile_cairo:
docker run -v $(ROOT_DIR):/pwd cairo --proof_mode /pwd/$(PROGRAM) > $(COMPILED_PROGRAM)

target/release/cairo-platinum-prover:
cargo build --bin cairo-platinum-prover --release --features instruments

Expand All @@ -67,13 +88,6 @@ docker_compile_and_prove: target/release/cairo-platinum-prover
@cargo run --bin cairo-platinum-prover --features instruments --quiet --release prove $(COMPILED_PROGRAM) $(PROOF_PATH)
@rm $(COMPILED_PROGRAM)

compile_and_run_all: target/release/cairo-platinum-prover
@echo "Compiling program with cairo-compile"
@cairo-compile --proof_mode $(PROGRAM) > $(COMPILED_PROGRAM)
@echo "Compiling done \n"
@cargo run --bin cairo-platinum-prover --features instruments --quiet --release prove_and_verify $(COMPILED_PROGRAM)
@rm $(COMPILED_PROGRAM)

compile_and_prove: target/release/cairo-platinum-prover
@echo "Compiling program with cairo-compile"
@cairo-compile --proof_mode $(PROGRAM) --output $(COMPILED_PROGRAM)
Expand Down
Loading

0 comments on commit 8f7b415

Please sign in to comment.