Skip to content

Commit

Permalink
WORKING on ci
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerTaule committed Sep 17, 2024
1 parent fce5b2f commit fa9cbaf
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 35 deletions.
118 changes: 111 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ name: CI Checks
on:
push:
branches: [main, develop]
pull_request:
pull_request:
branches: [main, develop]
jobs:
cargo-test:
name: cargo test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Install Dependencies
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- name: Set up Rust Toolchain
Expand All @@ -21,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Install Dependencies
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- name: Set up Rust Toolchain
Expand All @@ -33,7 +34,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Set up Rust Toolchain
run: curl https://sh.rustup.rs -sSf | sh -s -- -y
- name: cargo fmt
Expand All @@ -43,7 +44,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Install Dependencies
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- name: Set up Rust Toolchain
Expand All @@ -65,7 +66,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Install Dependencies
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
- name: Set up Rust Toolchain
Expand All @@ -77,10 +78,113 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Set up Rust Toolchain
run: curl https://sh.rustup.rs -sSf | sh -s -- -y
- name: install cargo-audit
run: cargo install cargo-audit
- name: cargo audit
run: cargo audit
fibonacci-square:
name: Test fibonacci square
runs-on: ubuntu-latest
env:
STARKS_LIB_C: zkevm-prover/lib/libstarks.a
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Check out pil2-components
uses: actions/checkout@v3
with:
repository: 0xPolygonHermez/pil2-components
token: ${{ secrets.ZISK_CI_TOKEN }}
ref: fix/dependencies_proofman
path: pil2-components

- name: Install pil2-components dependencies
working-directory: pil2-components
run: |
npm install
- name: Check out pil2-proofman-js
uses: actions/checkout@v3
with:
repository: 0xPolygonHermez/pil2-proofman-js
token: ${{ secrets.ZISK_CI_TOKEN }}
ref: feature/setup
path: pil2-proofman-js

- name: Install pil2-proofman-js dependencies
working-directory: pil2-proofman-js
run: npm install

- name: Check out pil2-compiler
uses: actions/checkout@v3
with:
repository: 0xPolygonHermez/pil2-compiler
token: ${{ secrets.GITHUB_TOKEN }}
ref: develop
path: pil2-compiler

- name: Install pil2-compiler dependencies
working-directory: pil2-compiler
run: npm install

- name: Install dependencies
run: |
sudo apt-get update
sudo apt install build-essential libbenchmark-dev libomp-dev libgmp-dev nlohmann-json3-dev postgresql libpqxx-dev libpqxx-doc nasm libsecp256k1-dev grpc-proto libsodium-dev libprotobuf-dev libssl-dev cmake libgrpc++-dev uuid-dev
sudo apt-get install -y protobuf-compiler
- name: Check out zkevm-prover
uses: actions/checkout@v3
with:
repository: 0xPolygonHermez/zkevm-prover
token: ${{ secrets.GITHUB_TOKEN }}
ref: develop_rust_lib
path: zkevm-prover

- name: Install zkevm-prover
working-directory: zkevm-prover
run: |
git submodule init
git submodule update
make clean
make starks_lib -j
make -j bctree
- name: Compile PIL
run: |
node pil2-compiler/src/pil.js pil2-components/test/fibonacci/pil/build.pil -I pil2-components/lib/std/pil -o ./examples/fibonacci-square/pil/build.pilout
- name: Generate setup
run: |
node pil2-proofman-js/src/main_setup.js -a ./examples/fibonacci-square/pil/build.pilout -b ./examples/fibonacci-square/build -t zkevm-prover/build/bctree
- name: Generate PIL Helpers
run: |
cargo run --bin proofman-cli pil-helpers --pilout ./examples/fibonacci-square/pil/build.pilout --path ./examples/fibonacci-square/src -o
- name: Modify Cargo.toml
run: |
sed -i 's/# examples\/fibonacci-square/examples\/fibonacci-square/g' ./Cargo.toml
- name: Modify stark-prover-lib
run: |
sed -i 's/default = \["no_lib_link"\]/default = \[\]/g' ./provers/starks-lib-c/Cargo.toml
- name: Cargo build
run: RUST_BACKTRACE=1 cargo build -v

- name: Verify constraints
run: |
cargo run --bin proofman-cli verify-constraints --witness-lib ./target/debug/libfibonacci_square.so --proving-key examples/fibonacci-square/build/provingKey/ --public-inputs examples/fibonacci-square/src/inputs.json
- name: Generate proof
run: |
cargo run --bin proofman-cli prove --witness-lib ./target/debug/libfibonacci_square.so --proving-key examples/fibonacci-square/build/provingKey/ --public-inputs examples/fibonacci-square/src/inputs.json --output-dir examples/fibonacci-square/build/proofs
- name: Verify proof
run: |
node pil2-proofman-js/src/main_verify -k examples/fibonacci-square/build -p examples/fibonacci-square/build/proofs
2 changes: 1 addition & 1 deletion examples/fibonacci-square/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ proofman-common = { path = "../../common" }
proofman-macros.workspace = true
proofman = { path = "../../proofman" }

# pil-std-lib = { git = "https://github.com/0xPolygonHermez/pil2-components.git", branch ="std_rust" }
#pil-std-lib = { git = "ssh://git@github.com/0xPolygonHermez/pil2-components.git", branch = "fix/range-check-inputs" }
#Local development
pil-std-lib = { path = "../../../pil2-components/lib/std/rs" }

Expand Down
4 changes: 2 additions & 2 deletions proofman/src/proofman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,11 @@ impl<F: Field + 'static> ProofMan<F> {

if valid_constraints && global_constraints_verified {
log::debug!("{}: ··· {}", Self::MY_NAME, "All constraints were verified!".bright_green().bold());
return Ok(vec![]);
} else {
log::debug!("{}: ··· {}", Self::MY_NAME, "Not all constraints were verified.".bright_red().bold());
return Err(format!("Failed to verify constraints").into());
}

return Ok(vec![]);
}

// Compute Quotient polynomial
Expand Down
67 changes: 42 additions & 25 deletions provers/starks-lib-c/build.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
use std::env;
use std::{env, path::Path};

fn main() {
// Check if the "NO_LIB_LINK" feature is enabled
if std::env::var("CARGO_FEATURE_NO_LIB_LINK").is_err() {
let library_folder = "../../../zkevm-prover/lib";
let library_short_name = "starks";
let library_name = format!("lib{}.a", library_short_name);
let library_path = format!("{}/{}", library_folder, library_name);
let library_folder: String;
let library_path = if let Ok(path) = env::var("STARKS_LIB_C") {
// If STARKS_LIB_C is set, use its value
library_folder = Path::new(&path).parent().unwrap_or_else(|| Path::new(".")).to_str().unwrap().to_string();
path
} else {
// Fallback if STARKS_LIB_C is not set
library_folder = "../../../zkevm-proverrrrrrrr/lib".to_string();
format!("{}/lib{}.a", library_folder, library_short_name)
};

println!("cargo:rerun-if-changed={}", env::current_dir().unwrap().join(library_path).display());
println!("Library folder: {} and library path: {}", library_folder, library_path);

// Tipically the libraries are in: sudo find /usr /lib /lib64 /usr/lib /usr/lib64 -name "libstdc++.a"
println!("cargo:rustc-link-search=native={}", env::current_dir().unwrap().join(library_folder).display());
// Trigger a rebuild if the library path changes
println!("cargo:rerun-if-changed={}", env::current_dir().unwrap().join(&library_path).display());

// Add the library folder to the linker search path
println!("cargo:rustc-link-search=native={}", env::current_dir().unwrap().join(&library_folder).display());

// Add additional common library search paths
println!("cargo:rustc-link-search=native=/usr/lib/x86_64-linux-gnu/");
println!("cargo:rustc-link-search=native=/usr/lib/gcc/x86_64-linux-gnu/11/");

// Add linker arguments
println!("cargo:rustc-link-arg=-fopenmp");
println!("cargo:rustc-link-arg=-MMD");
println!("cargo:rustc-link-arg=-MP");
Expand All @@ -25,25 +38,29 @@ fn main() {
println!("cargo:rustc-link-arg=-rdynamic");
println!("cargo:rustc-link-arg=-mavx2");

// Link the static library specified by `library_short_name`
println!("cargo:rustc-link-lib=static={}", library_short_name);

println!("cargo:rustc-link-lib=protobuf");
println!("cargo:rustc-link-lib=sodium");
println!("cargo:rustc-link-lib=grpc++");
println!("cargo:rustc-link-lib=grpc");
println!("cargo:rustc-link-lib=gpr");
println!("cargo:rustc-link-lib=grpc++_reflection");
println!("cargo:rustc-link-lib=pthread");
println!("cargo:rustc-link-lib=pqxx");
println!("cargo:rustc-link-lib=pq");
println!("cargo:rustc-link-lib=gmp");
println!("cargo:rustc-link-lib=stdc++");
println!("cargo:rustc-link-lib=gmpxx");
println!("cargo:rustc-link-lib=secp256k1");
println!("cargo:rustc-link-lib=crypto");
println!("cargo:rustc-link-lib=uuid");

//-lgrpc++ -lgrpc -lgpr
println!("cargo:rustc-link-lib=iomp5");
// Link other required libraries
for lib in &[
"protobuf",
"sodium",
"grpc++",
"grpc",
"gpr",
"grpc++_reflection",
"pthread",
"pqxx",
"pq",
"gmp",
"stdc++",
"gmpxx",
"secp256k1",
"crypto",
"uuid",
"iomp5",
] {
println!("cargo:rustc-link-lib={}", lib);
}
}
}

0 comments on commit fa9cbaf

Please sign in to comment.