From 185664367efc663895b620b9c2b406558ea547c4 Mon Sep 17 00:00:00 2001 From: Bartosz Nowak Date: Wed, 20 Mar 2024 19:26:01 +0100 Subject: [PATCH 1/7] versions stabilized& ci added --- .github/workflows/ci.yml | 27 ++++++++++++++++++++++++++- configure.py | 10 +++++----- requirements.txt | 2 ++ rust-toolchain.toml | 3 +++ test_layouts.py | 6 +++--- 5 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 requirements.txt create mode 100644 rust-toolchain.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4df574e7..00500b8ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,10 +4,35 @@ on: merge_group: pull_request: jobs: - check: + fmt: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: software-mansion/setup-scarb@v1 - run: scarb fmt --check + + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: software-mansion/setup-scarb@v1 - run: scarb test + + verify-layout: + strategy: + matrix: + layout: ["dex", "recursive", "recursive_with_poseidon", "small", "starknet"] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + - uses: software-mansion/setup-scarb@v1 + - run: python configure.py -l {${{ matrix.layout }}} -s keccak + - run: scarb build + - run: cargo run --release --bin runner -- target/dev/cairo_verifier.sierra.json < examples/proofs/{${{ matrix.layout }}}/example_proof.json \ No newline at end of file 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/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=".", From 30dc53c7634574a6de90b1cd931d35fb9588b069 Mon Sep 17 00:00:00 2001 From: Bartosz Nowak Date: Wed, 20 Mar 2024 19:27:15 +0100 Subject: [PATCH 2/7] fix --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 00500b8ce..edcb401ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,6 @@ jobs: python -m pip install --upgrade pip pip install -r requirements.txt - uses: software-mansion/setup-scarb@v1 - - run: python configure.py -l {${{ matrix.layout }}} -s keccak + - run: python configure.py -l ${{ matrix.layout }} -s keccak - run: scarb build - - run: cargo run --release --bin runner -- target/dev/cairo_verifier.sierra.json < examples/proofs/{${{ matrix.layout }}}/example_proof.json \ No newline at end of file + - run: cargo run --release --bin runner -- target/dev/cairo_verifier.sierra.json < examples/proofs/${{ matrix.layout }}/example_proof.json \ No newline at end of file From 5883ad60d6eac84a3fd154e19e051932dc778e2f Mon Sep 17 00:00:00 2001 From: Bartosz Nowak Date: Wed, 20 Mar 2024 19:40:42 +0100 Subject: [PATCH 3/7] newer runner & ci split --- .github/workflows/ci.yml | 38 ---------------------- .github/workflows/full.yml | 60 +++++++++++++++++++++++++++++++++++ .github/workflows/partial.yml | 21 ++++++++++++ .tool-versions | 3 +- Cargo.toml | 8 ++--- runner/src/main.rs | 2 +- 6 files changed, 88 insertions(+), 44 deletions(-) delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/full.yml create mode 100644 .github/workflows/partial.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index edcb401ef..000000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: CI -on: - push: - merge_group: - pull_request: -jobs: - fmt: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: software-mansion/setup-scarb@v1 - - run: scarb fmt --check - - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: software-mansion/setup-scarb@v1 - - run: scarb test - - verify-layout: - strategy: - matrix: - layout: ["dex", "recursive", "recursive_with_poseidon", "small", "starknet"] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - uses: software-mansion/setup-scarb@v1 - - run: python configure.py -l ${{ matrix.layout }} -s keccak - - run: scarb build - - run: cargo run --release --bin runner -- target/dev/cairo_verifier.sierra.json < examples/proofs/${{ matrix.layout }}/example_proof.json \ No newline at end of file diff --git a/.github/workflows/full.yml b/.github/workflows/full.yml new file mode 100644 index 000000000..3bbe70f95 --- /dev/null +++ b/.github/workflows/full.yml @@ -0,0 +1,60 @@ +name: Continuous Integration - full testing + +on: + push: + branches: + - main + pull_request: + branches: + - main + +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 + + verify-layout: + needs: formatting-and-testing + 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/partial.yml b/.github/workflows/partial.yml new file mode 100644 index 000000000..95f3e04be --- /dev/null +++ b/.github/workflows/partial.yml @@ -0,0 +1,21 @@ +name: Continuous Integration - partial testing + +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/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(), ) From ea67fcdb12e2b989d5ce0b4a72cef0abf7c782cb Mon Sep 17 00:00:00 2001 From: Bartosz Nowak Date: Wed, 20 Mar 2024 19:41:41 +0100 Subject: [PATCH 4/7] temporary suppression --- .github/workflows/full.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/full.yml b/.github/workflows/full.yml index 3bbe70f95..e95e26691 100644 --- a/.github/workflows/full.yml +++ b/.github/workflows/full.yml @@ -2,11 +2,7 @@ name: Continuous Integration - full testing on: push: - branches: - - main pull_request: - branches: - - main jobs: formatting-and-testing: From 4bfa3e2c8d19ba906bb0215c6253c9ba579febe2 Mon Sep 17 00:00:00 2001 From: Bartosz Nowak Date: Wed, 20 Mar 2024 19:48:39 +0100 Subject: [PATCH 5/7] just naming --- .github/workflows/full.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/full.yml b/.github/workflows/full.yml index e95e26691..8fd2fdb32 100644 --- a/.github/workflows/full.yml +++ b/.github/workflows/full.yml @@ -20,7 +20,7 @@ jobs: - name: Run tests run: scarb test - verify-layout: + verify-proof: needs: formatting-and-testing runs-on: ubuntu-latest strategy: From 19cec0d07e5f358e2b960d4635abf2435ccdc573 Mon Sep 17 00:00:00 2001 From: Bartosz Nowak Date: Wed, 20 Mar 2024 19:51:26 +0100 Subject: [PATCH 6/7] full testing only on main push/pull --- .github/workflows/full.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/full.yml b/.github/workflows/full.yml index 8fd2fdb32..bfc2f7868 100644 --- a/.github/workflows/full.yml +++ b/.github/workflows/full.yml @@ -2,7 +2,11 @@ name: Continuous Integration - full testing on: push: + branches: + - main pull_request: + branches: + - main jobs: formatting-and-testing: From 2bd8fe1fbc6ae713e610cc243774683093e9cf0b Mon Sep 17 00:00:00 2001 From: Bartosz Nowak Date: Wed, 20 Mar 2024 20:01:57 +0100 Subject: [PATCH 7/7] refactor --- .../{full.yml => proof_verification_tests.yml} | 18 +----------------- .github/workflows/{partial.yml => tests.yml} | 2 +- 2 files changed, 2 insertions(+), 18 deletions(-) rename .github/workflows/{full.yml => proof_verification_tests.yml} (73%) rename .github/workflows/{partial.yml => tests.yml} (88%) diff --git a/.github/workflows/full.yml b/.github/workflows/proof_verification_tests.yml similarity index 73% rename from .github/workflows/full.yml rename to .github/workflows/proof_verification_tests.yml index bfc2f7868..cd3eb4dcb 100644 --- a/.github/workflows/full.yml +++ b/.github/workflows/proof_verification_tests.yml @@ -1,4 +1,4 @@ -name: Continuous Integration - full testing +name: Continuous Integration - proof verification tests on: push: @@ -9,23 +9,7 @@ on: - main 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 - verify-proof: - needs: formatting-and-testing runs-on: ubuntu-latest strategy: matrix: diff --git a/.github/workflows/partial.yml b/.github/workflows/tests.yml similarity index 88% rename from .github/workflows/partial.yml rename to .github/workflows/tests.yml index 95f3e04be..1a2cfaa1b 100644 --- a/.github/workflows/partial.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,4 @@ -name: Continuous Integration - partial testing +name: Continuous Integration - tests on: push: