-
Notifications
You must be signed in to change notification settings - Fork 360
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
perf, feat: assert.CheckCircuit(...)
#825
Merged
Merged
Conversation
This file contains 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
Reviewing now. |
Suggested edit: diff --git a/test/assert.go b/test/assert.go
index 35ed4a45..81c346db 100644
--- a/test/assert.go
+++ b/test/assert.go
@@ -72,7 +72,7 @@ func (assert *Assert) Log(v ...interface{}) {
assert.t.Log(v...)
}
-// ProverSucceeded is deprecated: use CheckCircuit instead
+// ProverSucceeded is deprecated: use [Assert.CheckCircuit] instead
func (assert *Assert) ProverSucceeded(circuit frontend.Circuit, validAssignment frontend.Circuit, opts ...TestingOption) {
// copy the options
newOpts := make([]TestingOption, len(opts), len(opts)+2)
@@ -82,7 +82,7 @@ func (assert *Assert) ProverSucceeded(circuit frontend.Circuit, validAssignment
assert.CheckCircuit(circuit, newOpts...)
}
-// ProverSucceeded is Deprecated use CheckCircuit instead
+// ProverSucceeded is deprecated use [Assert.CheckCircuit] instead
func (assert *Assert) ProverFailed(circuit frontend.Circuit, invalidAssignment frontend.Circuit, opts ...TestingOption) {
// copy the options
newOpts := make([]TestingOption, len(opts), len(opts)+2)
@@ -92,7 +92,7 @@ func (assert *Assert) ProverFailed(circuit frontend.Circuit, invalidAssignment f
assert.CheckCircuit(circuit, newOpts...)
}
-// SolvingSucceeded is deprecated: use CheckCircuit instead
+// SolvingSucceeded is deprecated: use [Assert.CheckCircuit] instead
func (assert *Assert) SolvingSucceeded(circuit frontend.Circuit, validWitness frontend.Circuit, opts ...TestingOption) {
// copy the options
diff --git a/test/assert_checkcircuit.go b/test/assert_checkcircuit.go
index e5bb6b96..f3502ee1 100644
--- a/test/assert_checkcircuit.go
+++ b/test/assert_checkcircuit.go
@@ -14,19 +14,19 @@ import (
// CheckCircuit performs a series of check on the provided circuit.
//
-// go test -short --> testEngineChecks
-// go test --> testEngineChecks + constraintSolverChecks
-// go test -tags=prover_checks --> ... + proverChecks
-// go test -tags=release_checks --> ... + releaseChecks (solidity, serialization, ...)
+// go test -short --> testEngineChecks
+// go test --> testEngineChecks + constraintSolverChecks
+// go test -tags=prover_checks --> ... + proverChecks
+// go test -tags=release_checks --> ... + releaseChecks (solidity, serialization, ...)
//
// Depending on the above flags, the following checks are performed:
-// - the circuit compiles
-// - the circuit can be solved with the test engine
-// - the circuit can be solved with the constraint system solver
-// - the circuit can be solved with the prover
-// - the circuit can be verified with the verifier
-// - the circuit can be verified with gnark-solidity-checker
-// - the circuit, witness, proving and verifying keys can be serialized and deserialized
+// - the circuit compiles
+// - the circuit can be solved with the test engine
+// - the circuit can be solved with the constraint system solver
+// - the circuit can be solved with the prover
+// - the circuit can be verified with the verifier
+// - the circuit can be verified with gnark-solidity-checker
+// - the circuit, witness, proving and verifying keys can be serialized and deserialized
func (assert *Assert) CheckCircuit(circuit frontend.Circuit, opts ...TestingOption) {
// get the testing configuration
opt := assert.options(opts...)
|
ivokub
approved these changes
Sep 8, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the approach is really good. A few questions about additional behaviour control options (which I'm not sure are worth it).
Also added a few suggestions to make godoc output look nicer.
Summary✅ Passed: 5693 🚧 Skipped
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR tackles the issue of heterogeneous tests for circuits and long runs in the CI.
Previously some tests call the test engine directly, sometime we commit tests that only check one curve and one backend to go faster, ... ;
Proposition here is to replace
assert.ProverSucceeded
assert.ProverFailed
assert.SolverSucceeded
... withassert.CheckCircuit
.Through build tags and
-short
test option, an increasing number of checks are performed;This allow a fast dev workflow (test engine only with
-short
option) and various CI workflows to do extra validations.This PR also factorize / clean up quite a bit of repeated code (for example for testing serialization round trips).
Last but not least,
test.Engine
has aBatchInvert
method called inlogderivarg.go
Build()
method; it saves 30% of test time since a lot of inverses usingbig.Int
are performed in the test engine. A potential follow up to this PR would be to have the test engine parametrized with field element instead ofbig.Int
.Fixes # (issue)
This PR also fixes some minor issues;
groth16.Proof
serialization was missing commitment info.witness.ReadFrom
returned incorrect number of bytes read when deserializingBreaking changes
test.NoSerialization()
->test.NoSerializationChecks()
Type of change
How has this been benchmarked?
go test -short ./...
up to 90% faster.Checklist:
golangci-lint
does not output errors locally