Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pip package release #166

Merged
merged 35 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
15425da
remove maturin scrit
feltroidprime Aug 20, 2024
802ce29
gitignore update
feltroidprime Aug 20, 2024
9f786d8
fix kkt cargo
feltroidprime Aug 20, 2024
c82828b
init cli
feltroidprime Aug 20, 2024
b8922d9
cli gen
feltroidprime Aug 20, 2024
95250d0
Cairo1 circuits: Use Horner evaluation when applicable.
feltroidprime Aug 21, 2024
a362721
Update ECIP_OPS class hash.
feltroidprime Aug 21, 2024
e57c1f2
Merge commit 'a3627211c385d4431aed38edc2733be570bdefe7' into cli
feltroidprime Aug 21, 2024
a2f957b
add autoflake to pre commit
feltroidprime Aug 21, 2024
3fdc322
e2e devnet CI
feltroidprime Aug 21, 2024
c74494a
apply pre-commit on all files
feltroidprime Aug 21, 2024
3456d08
Merge commit '2986b7baa04e9fda536a5d470c1bb641d4d5daf5' into cli
feltroidprime Aug 21, 2024
748864f
Remove cairo-lang dependency from garaga package.
feltroidprime Aug 21, 2024
c45e6d3
declare
feltroidprime Aug 23, 2024
9171162
use uv + dev dependencies ; deps only controlled by pyproject.toml
feltroidprime Aug 23, 2024
5cbd803
remove cairo zero (moved to garaga-zero)
feltroidprime Aug 23, 2024
6342b6a
next alpha version
feltroidprime Aug 23, 2024
2fec107
fix CI
feltroidprime Aug 23, 2024
9a959f2
Fix CI & Bump Cairo to 2.7.1
feltroidprime Aug 23, 2024
38bd7e5
Fix.
feltroidprime Aug 23, 2024
74f3246
bump package version
feltroidprime Aug 23, 2024
f13c0e3
Finalize CairoZero removal
feltroidprime Aug 24, 2024
86cf460
Merge branch 'main' into cli
feltroidprime Aug 24, 2024
bf99e49
bn254: use JY00 encoding to save one miller loop iteration
feltroidprime Aug 24, 2024
270da2a
Small fix.
feltroidprime Aug 24, 2024
f59e94d
add secrets template
feltroidprime Aug 24, 2024
8af5c74
aply ruff suggestions
feltroidprime Aug 24, 2024
694646f
remove hint document
feltroidprime Aug 24, 2024
ca6c938
choose fee
feltroidprime Aug 24, 2024
d12adf5
deploy
feltroidprime Aug 24, 2024
d9644c2
verify-onchain
feltroidprime Aug 24, 2024
1f98ef9
rm hi command
feltroidprime Aug 24, 2024
e34c5e5
clean cli
feltroidprime Aug 24, 2024
9bb2f05
bump version
feltroidprime Aug 24, 2024
cd49890
upd readme
feltroidprime Aug 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/cairo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- uses: actions/checkout@v3
- uses: software-mansion/setup-scarb@v1
with:
scarb-version: "2.7.0"
scarb-version: "2.7.1"
- run: scarb fmt --check
working-directory: src/cairo
- run: cd src/cairo && scarb test
working-directory: src/
- run: cd src/ && scarb test
29 changes: 15 additions & 14 deletions .github/workflows/fustat.yml → .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Cairo Zero (Fustat) tests
name: E2E-devnet

on:
push:
Expand All @@ -18,10 +18,11 @@ jobs:
with:
concurrent_skipping: 'same_content_newer'

test-fustat:
devnet-test:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10.14
Expand All @@ -33,16 +34,16 @@ jobs:
with:
toolchain: stable
override: true
components: rustfmt, clippy

- name: Setup repo
profile: minimal
- name: Setup Scarb
uses: software-mansion/setup-scarb@v1
with:
scarb-version: "2.7.1"
- name: Install dependencies
run: make setup
- name: Check cairo Formatting
run: |
source venv/bin/activate && ./tools/make/fustat_format_check.sh
- name: Compile cairo files
run: source venv/bin/activate && make clean && ./tools/make/build.sh tests
- name: Run fustat programs
run: |
source venv/bin/activate
pytest tests/fustat_programs/test_fustat.py -n auto -s

- name: Install devnet
run: ./tests/contracts_e2e/install_devnet.sh

- name: Run tests
run: source venv/bin/activate && pytest -s -x tests/contracts_e2e/e2e_test.py
23 changes: 10 additions & 13 deletions .github/workflows/hydra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,28 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal

- uses: actions/checkout@v3
- name: Set up Python 3.10.14
uses: actions/setup-python@v2
with:
python-version: 3.10.14
- name: Install dependencies
run: |
python -m venv venv
source venv/bin/activate
echo 'export PYTHONPATH="$PWD/hydra/:$PYTHONPATH"' >> venv/bin/activate
pip install -r tools/make/requirements.txt
run: make setup

- name: Check Black formatting
run: source venv/bin/activate && black --check .
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy

- name: Compile Rust bindings with maturin
- name: Test garaga_rs
run: |
source venv/bin/activate
(cd tools/garaga_rs && cargo fmt --check && cargo test)
maturin develop --release
- name: Run pytest
run: |
source venv/bin/activate
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ venv
*.so
*.html
*.sage.py
*.idea
*.secrets

tools/garaga_rs/target/
tools/garaga_rs/Cargo.lock
tools/make/requirements.txt

src/cairo/target/
*target*

tests/contracts_e2e/devnet/*

!hydra/garaga/starknet/groth16_contract_generator/examples/*.json
18 changes: 13 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
repos:
- repo: https://github.com/myint/autoflake
rev: v1.4
hooks:
- id: autoflake
args: ["--in-place", "--remove-all-unused-imports"]
files: \.py$
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]
files: \.py$
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
Expand All @@ -11,8 +23,4 @@ repos:
rev: 24.4.2
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]
files: \.py$
7 changes: 7 additions & 0 deletions .secrets.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SEPOLIA_RPC_URL="https://free-rpc.nethermind.io/sepolia-juno"
SEPOLIA_ACCOUNT_PRIVATE_KEY=0x1
SEPOLIA_ACCOUNT_ADDRESS=0x2

MAINNET_RPC_URL="https://"
MAINNET_ACCOUNT_PRIVATE_KEY=0x3
MAINNET_ACCOUNT_ADDRESS=0x4
29 changes: 2 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
.PHONY: build test coverage run run-profile
cairo_files = $(shell find ./tests/cairo_programs -name "*.cairo")

build:
$(MAKE) clean
./tools/make/build.sh

setup:
./tools/make/setup.sh
Expand All @@ -17,32 +15,9 @@ rewrite:
steps:
./tools/make/steps.sh

ci-e2e:
./tools/make/ci_e2e.sh

profile:
@echo "A script to select, run & profile one Cairo file."
@echo "Thank you for trying to improve Garaga's speed!"
./tools/make/launch_cairo_files.py -profile

profile-no-compile:
@echo "A script to select, run & profile one Cairo file. File must be already compiled."
@echo "Thank you for trying to improve Garaga's speed!"
./tools/make/launch_cairo_files.py -profile -no_compile
run:
@echo "A script to select, compile & run one Cairo file"
@echo "Total number of steps will be shown at the end of the run."
@echo "Thank you for testing Garaga!"
./tools/make/launch_cairo_files.py

run-no-compile:
@echo "A script to select, run one Cairo file without compiling it"
@echo "Thank you for testing Garaga!"
./tools/make/launch_cairo_files.py -no_compile

run-pie:
@echo "A script to select, compile & run one Cairo file with pie mode enabled"
@echo "Total number of steps will be shown at the end of the run."
@echo "Thank you for proving Garaga!"
./tools/make/launch_cairo_files.py -pie
clean:
rm -rf build/compiled_cairo_files
mkdir -p build
Expand Down
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,32 @@ Garaga consists of a Pythonic backend with Rust bindings and CairoZero / Cairo l
It also handles witnesses generation for the non-deterministic computations, smart contract contract generation for a given proof system and elliptic curve, and calldata generation from a given proof.
- The CairoZero / Starknet interfaces are responsible for composing and calling the circuits, as well as adding all the extra logic needed to make the algorithms work (Fiat-Shamir heuristic, SNARKS verifiers algorithms, etc).

## Deploying SNARKS verifier on Starknet
## Quickstart : deploying a SNARK verifier on Starknet

Docs and CLI incoming.
Checkout `hydra/garaga/starknet/groth16_contract_generator/generator.py` in the meantime.
Currently, only Groth16 on BN254 and BLS12_381 is supported with automatic support for json files coming from SnarkJS and Gnark.

## Verify a proof against a specific SNARK verifier contract
1. Create a new directory for you project, and bring the jsons files for verification key, proof file and public inputs inside it.
2. Install the garaga pip package with `pip install garaga`. Python3.10 is mandatory and a virtual environment is recommended. Enter `garaga` in your terminal to get started.
3. Run the `garaga gen` command in your terminal to generate the code for the SNARK verifier given your verification key.
4. Edit the generated smart contract to fit the needs of your dapp.

Docs, CLI and browser support incoming.
Checkout `hydra/garaga/starknet/groth16_contract_generator/calldata.py` in the meantime.
5. Create an environment file `.secrets` following the `.secrets.template` file in the root of this repository, containing the Starkner RPC url, your account address, and the private key.
6. Run the `garaga declare` command in your terminal to declare the smart contract on Starknet and obtain its class hash. Note that this is an expensive operation.
7. Run the `garaga deploy` command in your terminal using the class hash obtained in the previous step to get the contract address.

## Development setup
7. Run the `garaga verify-onchain` command in your terminal using the contract address, the verification key, the proof and the public inputs to verify the proof against the SNARK verifier contract.

For more details, please refer to the [documentation](https://felt.gitbook.io/garaga/).

## Developer setup

To get started with Garaga, you'll need to have some tools and dependencies installed. Here's everything you need:

### Prerequisites

Ensure you have the following installed:
- [Python 3.10](https://www.python.org/downloads/) - /!\ Make sure `python3.10` is a valid command in your terminal. The core language used for development. Make sure you have the correct dependencies installed (in particular, GMP) for the `fastecdsa` python package. See [here](https://pypi.org/project/fastecdsa/#installing) for linux and [here](https://github.com/AntonKueltz/fastecdsa/issues/74) for macos.
- [Scarb 2.7.0](https://docs.swmansion.com/scarb/download.html) - The Cairo package manager. Comes with Cairo inside. Requires [Rust](https://www.rust-lang.org/tools/install).
- [Scarb 2.7.1](https://docs.swmansion.com/scarb/download.html) - The Cairo package manager. Comes with Cairo inside. Requires [Rust](https://www.rust-lang.org/tools/install).

##### Optionally :

Expand Down
Loading
Loading