Skip to content

Commit

Permalink
Merge pull request #814 from Consensys/develop
Browse files Browse the repository at this point in the history
v0.9.0 placeholder
  • Loading branch information
gbotrel authored Aug 18, 2023
2 parents e162c98 + 8824986 commit f9dfb87
Show file tree
Hide file tree
Showing 585 changed files with 69,658 additions and 29,203 deletions.
10 changes: 5 additions & 5 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Note that in most cases the PR should be against the `develop` branch.
<!-- Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Note that in most cases the PR should be against the `develop` branch. -->

Fixes # (issue)

## Type of change

Please delete options that are not relevant.
<!-- Please delete options that are not relevant. -->

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
Expand All @@ -16,14 +16,14 @@ Please delete options that are not relevant.

# How has this been tested?

Please describe the tests that you ran or implemented to verify your changes. Provide instructions so we can reproduce.
<!-- Please describe the tests that you ran or implemented to verify your changes. Provide instructions so we can reproduce. -->

- [ ] Test A
- [ ] Test B

# How has this been benchmarked?

Please describe the benchmarks that you ran to verify your changes.
<!-- Please describe the benchmarks that you ran to verify your changes. -->

- [ ] Benchmark A, on Macbook pro M1, 32GB RAM
- [ ] Benchmark B, on x86 Intel xxx, 16GB RAM
Expand Down
53 changes: 35 additions & 18 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
Expand All @@ -22,10 +22,6 @@ jobs:
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
args: --timeout=5m
- name: install deps
run: go install golang.org/x/tools/cmd/goimports@latest && go install github.com/klauspost/asmfmt/cmd/asmfmt@latest
- name: gofmt
Expand All @@ -35,24 +31,35 @@ jobs:
go generate ./...
git update-index --assume-unchanged go.mod
git update-index --assume-unchanged go.sum
if [[ -n $(git status --porcelain) ]]; then echo "git repo is dirty after runing go generate -- please don't modify generated files"; echo $(git diff);echo $(git status --porcelain); exit 1; fi
if [[ -n $(git status --porcelain) ]]; then echo "git repo is dirty after running go generate -- please don't modify generated files"; echo $(git diff);echo $(git status --porcelain); exit 1; fi
# hack to ensure golanglint process generated files
- name: remove "generated by" comments from generated files
run: |
find . -type f -name '*.go' -exec sed -i 's/Code generated by .* DO NOT EDIT/FOO/g' {} \;
# on macos: find . -type f -name '*.go' -exec sed -i '' -E 's/Code generated by .* DO NOT EDIT/FOO/g' {} \;

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
args: --timeout=5m

test:
strategy:
matrix:
go-version: [1.19.x]
go-version: [1.20.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
needs:
- staticcheck
steps:
- name: install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
Expand All @@ -63,10 +70,19 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: install deps
run: go install golang.org/x/tools/cmd/goimports@latest && go install github.com/klauspost/asmfmt/cmd/asmfmt@latest
run: |
go install golang.org/x/tools/cmd/goimports@latest && go install github.com/klauspost/asmfmt/cmd/asmfmt@latest
go install github.com/ethereum/go-ethereum/cmd/[email protected]
go install github.com/consensys/gnark-solidity-checker@latest
sudo add-apt-repository ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install solc
- name: Test
run: |
go test -v -short -timeout=30m ./...
go test -v -short -tags=solccheck -timeout=30m ./...
- name: Test race
run: |
go test -v -short -race -timeout=30m
slack-workflow-status-failed:
if: failure()
Expand All @@ -78,15 +94,16 @@ jobs:
steps:
- name: Notify slack -- workflow failed
id: slack
uses: slackapi/slack-github-action@v1.19.0
uses: slackapi/slack-github-action@v1.23.0
with:
payload: |
{
"actor": "${{ github.actor }}",
"repo": "${{ github.repository }}",
"status": "FAIL",
"title": "${{ github.event.pull_request.title }}",
"pr": "${{ github.event.pull_request.head.ref }}"
"pr": "${{ github.event.pull_request.head.ref }}",
"failed_step_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Expand All @@ -101,7 +118,7 @@ jobs:
steps:
- name: Notify slack -- workflow succeeded
id: slack
uses: slackapi/slack-github-action@v1.19.0
uses: slackapi/slack-github-action@v1.23.0
with:
payload: |
{
Expand Down
43 changes: 27 additions & 16 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: 1.19.x
go-version: 1.20.x
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
Expand All @@ -26,10 +26,8 @@ jobs:
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
args: --timeout=5m
- name: install deps
run: go install golang.org/x/tools/cmd/goimports@latest && go install github.com/klauspost/asmfmt/cmd/asmfmt@latest
- name: gofmt
Expand All @@ -39,24 +37,36 @@ jobs:
go generate ./...
git update-index --assume-unchanged go.mod
git update-index --assume-unchanged go.sum
if [[ -n $(git status --porcelain) ]]; then echo "git repo is dirty after runing go generate -- please don't modify generated files"; echo $(git diff);echo $(git status --porcelain); exit 1; fi
if [[ -n $(git status --porcelain) ]]; then echo "git repo is dirty after running go generate -- please don't modify generated files"; echo $(git diff);echo $(git status --porcelain); exit 1; fi
# hack to ensure golanglint process generated files
- name: remove "generated by" comments from generated files
run: |
find . -type f -name '*.go' -exec sed -i 's/Code generated by .* DO NOT EDIT/FOO/g' {} \;
# on macos: find . -type f -name '*.go' -exec sed -i '' -E 's/Code generated by .* DO NOT EDIT/FOO/g' {} \;

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
args: --timeout=5m


test:
strategy:
matrix:
go-version: [1.19.x]
go-version: [1.20.x]
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
needs:
- staticcheck
steps:
- name: install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: checkout code
uses: actions/checkout@v2
- uses: actions/cache@v2
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
Expand Down Expand Up @@ -86,15 +96,16 @@ jobs:
steps:
- name: Notify slack -- workflow failed
id: slack
uses: slackapi/slack-github-action@v1.19.0
uses: slackapi/slack-github-action@v1.23.0
with:
payload: |
{
"actor": "${{ github.actor }}",
"repo": "${{ github.repository }}",
"status": "FAIL",
"title": "push to ${{ github.event.push.base_ref }}",
"pr": ""
"pr": "",
"failed_step_url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Expand All @@ -109,7 +120,7 @@ jobs:
steps:
- name: Notify slack -- workflow succeeded
id: slack
uses: slackapi/slack-github-action@v1.19.0
uses: slackapi/slack-github-action@v1.23.0
with:
payload: |
{
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,9 @@ gnarkd/circuits/**

# Jetbrains stuff
.idea/

# go workspace
go.work
go.work.sum

examples/gbotrel/**
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,17 @@ If you use `gnark` in your research a citation would be appreciated.
Please use the following BibTeX to cite the most recent release.

```bib
@software{gnark-v0.8.0,
@software{gnark-v0.9.0,
author = {Gautam Botrel and
Thomas Piellard and
Youssef El Housni and
Ivo Kubjas and
Arya Tabaie},
title = {ConsenSys/gnark: v0.8.0},
title = {ConsenSys/gnark: v0.9.0},
month = feb,
year = 2023,
publisher = {Zenodo},
version = {v0.8.0},
version = {v0.9.0},
doi = {10.5281/zenodo.5819104},
url = {https://doi.org/10.5281/zenodo.5819104}
}
Expand Down
56 changes: 7 additions & 49 deletions backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
// Package backend implements Zero Knowledge Proof systems: it consumes circuit compiled with gnark/frontend.
package backend

import (
"github.com/consensys/gnark/backend/hint"
"github.com/consensys/gnark/logger"
"github.com/rs/zerolog"
)
import "github.com/consensys/gnark/constraint/solver"

// ID represent a unique ID for a proving scheme
type ID uint16
Expand Down Expand Up @@ -50,26 +46,20 @@ func (id ID) String() string {
}
}

// ProverOption defines option for altering the behaviour of the prover in
// ProverOption defines option for altering the behavior of the prover in
// Prove, ReadAndProve and IsSolved methods. See the descriptions of functions
// returning instances of this type for implemented options.
type ProverOption func(*ProverConfig) error

// ProverConfig is the configuration for the prover with the options applied.
type ProverConfig struct {
Force bool // defaults to false
HintFunctions map[hint.ID]hint.Function // defaults to all built-in hint functions
CircuitLogger zerolog.Logger // defaults to gnark.Logger
SolverOpts []solver.Option
}

// NewProverConfig returns a default ProverConfig with given prover options opts
// applied.
func NewProverConfig(opts ...ProverOption) (ProverConfig, error) {
log := logger.Logger()
opt := ProverConfig{CircuitLogger: log, HintFunctions: make(map[hint.ID]hint.Function)}
for _, v := range hint.GetRegistered() {
opt.HintFunctions[hint.UUID(v)] = v
}
opt := ProverConfig{}
for _, option := range opts {
if err := option(&opt); err != nil {
return ProverConfig{}, err
Expand All @@ -78,42 +68,10 @@ func NewProverConfig(opts ...ProverOption) (ProverConfig, error) {
return opt, nil
}

// IgnoreSolverError is a prover option that indicates that the Prove algorithm
// should complete even if constraint system is not solved. In that case, Prove
// will output an invalid Proof, but will execute all algorithms which is useful
// for test and benchmarking purposes.
func IgnoreSolverError() ProverOption {
return func(opt *ProverConfig) error {
opt.Force = true
return nil
}
}

// WithHints is a prover option that specifies additional hint functions to be used
// by the constraint solver.
func WithHints(hintFunctions ...hint.Function) ProverOption {
log := logger.Logger()
return func(opt *ProverConfig) error {
// it is an error to register hint function several times, but as the
// prover already checks it then omit here.
for _, h := range hintFunctions {
uuid := hint.UUID(h)
if _, ok := opt.HintFunctions[uuid]; ok {
log.Warn().Int("hintID", int(uuid)).Str("name", hint.Name(h)).Msg("duplicate hint function")
} else {
opt.HintFunctions[uuid] = h
}
}
return nil
}
}

// WithCircuitLogger is a prover option that specifies zerolog.Logger as a destination for the
// logs printed by api.Println(). By default, uses gnark/logger.
// zerolog.Nop() will disable logging
func WithCircuitLogger(l zerolog.Logger) ProverOption {
// WithSolverOptions specifies the constraint system solver options.
func WithSolverOptions(solverOpts ...solver.Option) ProverOption {
return func(opt *ProverConfig) error {
opt.CircuitLogger = l
opt.SolverOpts = solverOpts
return nil
}
}
Loading

0 comments on commit f9dfb87

Please sign in to comment.