-
Notifications
You must be signed in to change notification settings - Fork 93
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
feat: add PlonkVerifier contracts and tests #722
Conversation
3d55b9a
to
1e09fb3
Compare
I will deal with some minor TODOs and fix CI failure tmr, but I think it's good to start reviewing this PR now.
|
b94fd1a
to
388ddd1
Compare
contract PlonkVerifier_preparePcsInfo_Test is PlonkVerifierCommonTest { | ||
/// forge-config: default.fuzz.runs = 5 | ||
/// @dev Test `preparePcsInfo` matches that of Jellyfish | ||
function testFuzz_preparePcsInfo_matches( |
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.
Encountered 1 failing test in contracts/test/PlonkVerifier.t.sol:PlonkVerifier_preparePcsInfo_Test
[FAIL. Reason: InvalidPolyEvalArgs() Counterexample: calldata=0x0x99fdc07100000000000000000000000000000000000000000000000000000000000005fe000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000003b2, args=[1534, [], 0x00000000000000000000000000000000000000000000000000000000000003b2]] testFuzz_preparePcsInfo_matches(uint64,uint256[],bytes) (runs: 1, μ: 8001859, ~: 8001859)
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.
good catch, I will add test logic for empty publicInput
array.
(nothing wrong with code, just test is not careful)
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.
done in 90bf8d1
foundry.toml
Outdated
@@ -26,3 +27,6 @@ sepolia = { key = "${ETHERSCAN_API_KEY}" } | |||
line_length=100 | |||
bracket_spacing=true | |||
wrap_comments=true | |||
|
|||
[profile.ci] | |||
fuzz = { run = 50 } |
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.
fuzz = { run = 50 } | |
fuzz = { runs = 50 } |
Should we run a bit more?
I also noticed that the inline comments seems to take precedence over setting it via env var or in foundry.toml which seems weird. In that case should we not use the inline comments?
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 use inline ones previously because some tests run slower than others, but now the released built diff-test
binary, all of these tests are fast, so I will remove any inline configs for fuzzer (just use 256 runs by default) and even remove this as well (256 for ci seems good enough)?
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.
Or we could add something like the following and run it once a day on the CI.
[profile.fuzz]
fuzz = { runs = 10000 }
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 use inline ones previously because some tests run slower than others, but now the released built
diff-test
binary, all of these tests are fast, so I will remove any inline configs for fuzzer (just use 256 runs by default) and even remove this as well (256 for ci seems good enough)?
Yeah if that's not too slow that is fine I think.
Since it's almost free and only costs CPU time I think it's not a bad idea to run more iterations on the CI occasionally, but we don't have to do it as part of this PR.
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.
done in 90bf8d1
contracts/test/PlonkVerifier.t.sol
Outdated
// muteate the x coordinate | ||
mstore(mload(add(proof, mul(0x20, nthPoint))), 0x1234) | ||
} | ||
// else, mutate y coordinate |
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.
The y
coordinate is always mutated.
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.
fixed in b914f77
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.
Great work!
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.
LGTM
Replace explorer prefix search with exact match for block and transaction hash
Resolves #702
Create issues tracking TODOs in the codemore-test-api
branch to a rev after test: Expose more internal functions for test jellyfish#398 is mergeddiff-test
executable inPATH
and directly invoking it instead ofcargo run --bin diff-test
Bug Fixes
In this PR, we have fixed two bugs:
Transcript.state
computation.zetaOmega
field of a plonk proof. This is important since all of the following computation assume these fields are valid. (credit to @sveitser for spotting it, and we have added automated fuzz-test to detect such error)