-
Notifications
You must be signed in to change notification settings - Fork 99
Migrate to GR1CS #154
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
Merged
Merged
Migrate to GR1CS #154
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
86ba793
Refacto: R1CS to GR1CS
alireza-shirzad 7c85546
tweak
alireza-shirzad 9f3ee2c
tweak
alireza-shirzad a2c1b03
Merge branch 'master' into master
Pratyush 0084eb3
relations crate fixed
alireza-shirzad 4c436da
Merge branch 'master' into master
Pratyush 35de2df
added the migration script
alireza-shirzad 2827eaf
fmt
alireza-shirzad 23a1a89
doc test fix
alireza-shirzad 09776fc
mwork
alireza-shirzad ca5708d
work
alireza-shirzad 2f85589
Merge branch 'master' into master
Pratyush 5f2e90d
work
alireza-shirzad ce625d6
addressed comments
alireza-shirzad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # ----------------------------------------------------------------------------- | ||
| # rename_r1cs.sh | ||
| # | ||
| # Recursively: | ||
| # 1. Renames .rs filenames: R1CS->GR1CS, r1cs->gr1cs (except those with r1cs_std). | ||
| # 2. In .rs file contents, replaces R1CS->GR1CS, r1cs->gr1cs (except lines with r1cs_std). | ||
| # 3. Finally replaces enforce_constraint->enforce_r1cs_constraint (except lines with r1cs_std). | ||
| # ----------------------------------------------------------------------------- | ||
|
|
||
| # --- Detect which 'sed' in-place flag to use (GNU vs BSD/macOS) --- | ||
| # On macOS, 'sed -i' requires a backup extension parameter (can be empty ''). | ||
| # On GNU sed, 'sed -i' is fine without extra args. | ||
| if sed --version 2>/dev/null | grep -q "GNU"; then | ||
| # GNU sed | ||
| SED_INPLACE=(-i) | ||
| else | ||
| # BSD/macOS sed | ||
| SED_INPLACE=(-i '') | ||
| fi | ||
|
|
||
| echo "###############################################" | ||
| echo "# ⚠️ Cautious: RUN THIS SCRIPT ONLY ONCE! DO NOT RUN IT TWICE! #" | ||
alireza-shirzad marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| echo "# Make sure you have a backup before running. #" | ||
| echo "###############################################" | ||
| echo | ||
| read -p "Are you sure you want to continue? (yes/no) " choice | ||
|
|
||
| if [[ "$choice" != "yes" ]]; then | ||
| echo "Aborting script execution." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # 1) Rename files that contain 'r1cs' or 'R1CS' in their name, skipping any with 'r1cs_std'. | ||
| echo "Renaming files that contain 'r1cs' or 'R1CS' (but not 'r1cs_std')..." | ||
| export LC_ALL=C # Ensure consistent behavior for case conversions | ||
|
|
||
| # Use 'find' + 'while IFS= read -r -d ""' to handle spaces & special chars in filenames. | ||
| while IFS= read -r -d '' file; do | ||
| # If filename includes r1cs_std, skip | ||
| if [[ "$file" =~ r1cs_std ]]; then | ||
| continue | ||
| fi | ||
|
|
||
| # Compute new filename by substituting: | ||
| newfile="$(echo "$file" | sed 's/R1CS/GR1CS/g; s/r1cs/gr1cs/g')" | ||
|
|
||
| if [[ "$newfile" != "$file" ]]; then | ||
| echo " -> Renaming: $file -> $newfile" | ||
| mv "$file" "$newfile" | ||
| fi | ||
| done < <(find . -type f -name "*.rs" -print0) | ||
|
|
||
| # 2) Replace R1CS->GR1CS and r1cs->gr1cs in file contents, | ||
| # skipping lines that have 'r1cs_std'. | ||
| echo "Replacing (R1CS->GR1CS, r1cs->gr1cs) in .rs file contents..." | ||
| while IFS= read -r -d '' file; do | ||
| # Replace R1CS -> GR1CS on lines NOT containing 'r1cs_std' | ||
| sed "${SED_INPLACE[@]}" '/r1cs_std/! s/R1CS/GR1CS/g' "$file" | ||
| # Replace r1cs -> gr1cs on lines NOT containing 'r1cs_std' | ||
| sed "${SED_INPLACE[@]}" '/r1cs_std/! s/r1cs/gr1cs/g' "$file" | ||
| done < <(find . -type f -name "*.rs" ! -name "*r1cs_std*" -print0) | ||
|
|
||
| # 3) Finally, replace 'enforce_constraint' -> 'enforce_r1cs_constraint', | ||
| # skipping lines that have 'r1cs_std'. | ||
| echo "Replacing enforce_constraint->enforce_r1cs_constraint..." | ||
| while IFS= read -r -d '' file; do | ||
| sed "${SED_INPLACE[@]}" '/r1cs_std/! s/enforce_constraint/enforce_r1cs_constraint/g' "$file" | ||
| done < <(find . -type f -name "*.rs" ! -name "*r1cs_std*" -print0) | ||
|
|
||
| echo "Done!" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.