diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index b4df574e7..000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: CI -on: - push: - merge_group: - pull_request: -jobs: - check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: software-mansion/setup-scarb@v1 - - run: scarb fmt --check - - run: scarb test diff --git a/.github/workflows/proof_verification_tests.yml b/.github/workflows/proof_verification_tests.yml new file mode 100644 index 000000000..cd3eb4dcb --- /dev/null +++ b/.github/workflows/proof_verification_tests.yml @@ -0,0 +1,44 @@ +name: Continuous Integration - proof verification tests + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + verify-proof: + runs-on: ubuntu-latest + strategy: + matrix: + layout: ["dex", "recursive", "recursive_with_poseidon", "small", "starknet"] + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Scarb + uses: software-mansion/setup-scarb@v1 + + - name: Setup Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.10' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Configure layout + run: python configure.py -l ${{ matrix.layout }} -s keccak + + - name: Build project + run: scarb build + + - name: Run verification + run: cargo run --release --bin runner -- target/dev/cairo_verifier.sierra.json < examples/proofs/${{ matrix.layout }}/example_proof.json diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..1a2cfaa1b --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,21 @@ +name: Continuous Integration - tests + +on: + push: + pull_request: + +jobs: + formatting-and-testing: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Scarb + uses: software-mansion/setup-scarb@v1 + + - name: Format code + run: scarb fmt --check + + - name: Run tests + run: scarb test \ No newline at end of file diff --git a/.tool-versions b/.tool-versions index f2e92b793..31ea1ea1b 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1,2 @@ -scarb 2.6.0 +scarb nightly-2024-03-16 +starknet-foundry 0.20.0 \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index d33a7eb10..f50202ad2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,10 +9,10 @@ version = "0.1.0" [workspace.dependencies] anyhow = "1" cairo-felt = "0.9" -cairo-lang-casm = "=2.6.0" -cairo-lang-runner = "=2.6.0" -cairo-lang-sierra = "=2.6.0" -cairo-lang-utils = "=2.6.0" +cairo-lang-casm = { git = "https://github.com/starkware-libs/cairo/" } +cairo-lang-runner = { git = "https://github.com/starkware-libs/cairo/" } +cairo-lang-sierra = { git = "https://github.com/starkware-libs/cairo/" } +cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo/" } cairo-proof-parser = { git = "https://github.com/Okm165/cairo-proof-parser" } cairo-vm = "=0.9.2" clap = { version = "4.5.2", features = ["derive"] } diff --git a/configure.py b/configure.py index 934c96748..86371dc9f 100644 --- a/configure.py +++ b/configure.py @@ -4,8 +4,8 @@ from pathlib import Path from utils import process_file -LAYOUT_TYPES = ("DEX", "RECURSIVE", "RECURSIVE_WITH_POSEIDON", "SMALL", "STARKNET") -HASH_TYPES = ("KECCAK", "BLAKE") +LAYOUT_TYPES = ("dex", "recursive", "recursive_with_poseidon", "small", "starknet") +HASH_TYPES = ("keccak", "blake") def select_types() -> str: @@ -23,18 +23,18 @@ def main(layout_type=None, hash_type=None): if layout_type is None or hash_type is None: layout_type, hash_type = select_types() - if layout_type.upper() not in LAYOUT_TYPES: + if layout_type.lower() not in LAYOUT_TYPES: print(f"Invalid layout type: {layout_type}") sys.exit(1) - if hash_type.upper() not in HASH_TYPES: + if hash_type.lower() not in HASH_TYPES: print(f"Invalid hash type: {hash_type}") sys.exit(1) current_directory = Path("src") for file_path in current_directory.rglob("*.cairo"): if file_path.is_file(): - process_file(file_path, [layout_type, hash_type]) + process_file(file_path, [layout_type.upper(), hash_type.upper()]) if __name__ == "__main__": diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..6ad893532 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +colorama==0.4.6 +inquirer==3.2.4 diff --git a/runner/src/main.rs b/runner/src/main.rs index 5c81a6139..b062e25aa 100644 --- a/runner/src/main.rs +++ b/runner/src/main.rs @@ -58,7 +58,7 @@ fn main() -> anyhow::Result<()> { let result = runner .run_function_with_starknet_context( func, - &[Arg::Array(proof.to_vec())], + &[Arg::Array(proof.into_iter().map(Arg::Value).collect_vec())], Some(u32::MAX as usize), Default::default(), ) diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 000000000..457524456 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "stable" +profile = "minimal" \ No newline at end of file diff --git a/test_layouts.py b/test_layouts.py index 95d67d9fd..bcb7ceb8f 100644 --- a/test_layouts.py +++ b/test_layouts.py @@ -24,7 +24,7 @@ def log_and_run(commands, description, cwd=None): # List of layouts to test -LAYOUTS = ["DEX", "RECURSIVE", "RECURSIVE_WITH_POSEIDON", "SMALL"] +LAYOUTS = ["dex", "recursive", "recursive_with_poseidon", "small"] # Main function to run the tests and optionally restore the src folder @@ -32,9 +32,9 @@ def main(restore_src=None): for layout in LAYOUTS: log_and_run( [ - f"python configure.py -l {layout} -s KECCAK", + f"python configure.py -l {layout} -s keccak", "scarb build", - f"cargo run --release --bin runner -- target/dev/cairo_verifier.sierra.json < examples/proofs/{layout.lower()}/example_proof.json", + f"cargo run --release --bin runner -- target/dev/cairo_verifier.sierra.json < examples/proofs/{layout}/example_proof.json", ], f"Testing {layout.lower()} layout", cwd=".",