-
Notifications
You must be signed in to change notification settings - Fork 45
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
Adds property-based testing and fuzzing for SMT
#385
base: next
Are you sure you want to change the base?
Conversation
SMT
SMT
SMT
SMT
SMT
SMT
847c83c
to
2d38238
Compare
SMT
SMT
75fa774
to
571ee3a
Compare
571ee3a
to
c642f56
Compare
The code looks good to me. It's probably expected, but heads up that tests for |
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.
Looks good! Thank you! I left a few minor comments inline. A couple of other questions/comments:
In this PR we create the miden-crypto-fuzz
crate which is in the directory tree of the miden-crypto
crate - would this affect publishing of the miden-crypto
crate somehow (e.g., would the fuzz crate get included with the crypto crate when we publish)? Maybe it makes sense to put them in separate directories - e.g., something like:
.
├── miden-crypto
│ ├── scr
│ ├── Cargo.toml
│ └── README.md
├── miden-crypto-fuzz
│ ├── src
│ ├── Cargo.toml
│ └── README.md
├── Cargo.toml
├── CHANGELOG.md
├── README.md
├── Makefile
└── etc.
The code looks good to me. It's probably expected, but heads up that tests for
merkle::smt::full::concurrent
now take 5 min on my M3 Max processor.
I'm not a CI expert, but is it possible to run these tests only when merging into next
or main
? Maybe we could mark them as "ignored" and then use different commands for when merging into next
or main
vs. pushing a commit or merging into other branches. cc @Mirko-von-Leipzig.
Any of these is possible; one just needs to decide precisely when one wants them to run.
The simplest is having a separate job/step which checks what the github target ref is. If its There are also several ways of segregating the tests:
An issue with (2) is if you truly do want to ignore a test, you now cannot do this because you're (ab)using (3) means having them on a common path prefix, or sharing a common test name prefix so you can exclude them using the test runner. The downside is that you can no longer trivially I would use (3) myself I think. |
a73cc08
to
69b5de0
Compare
I verified that
Cargo treats it as a separate crate and does not include it in the main package. For extra safety, I can restructure the tree as suggested, or explicitly add exclude = ["fuzz/"] to |
69b5de0
to
03309b1
Compare
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.
Looks good! Thank you! Would also be good to get a review from @PhilippGackstatter before merging.
How difficult would it be to update the CI to run the expensive tests only when merging to main
/next
? If not too difficult, I'd do it in this PR - otherwise, we can leave this for a follow up.
I verified that
miden-crypto-fuzz
is not included in the published crate:
publish = false
is set infuzz/Cargo.toml
, ensuring it won't be published.cargo package --list
confirmed thatfuzz/
is excluded.Cargo treats it as a separate crate and does not include it in the main package.
For extra safety, I can restructure the tree as suggested, or explicitly add exclude = ["fuzz/"] to
Cargo.toml
.
I would still probably update the directory structure, but let's do it in a follow-up PR.
Just to confirm: merging into In either case it will require slightly changing these lines: crypto/.github/workflows/test.yml Lines 25 to 28 in 8ce7b68
into something like: - name: Update rust
run: rustup update --no-self-update ${{matrix.toolchain}}
- name: Run tests (cheap)
run: make test-${{matrix.args}}
- name: Run expensive tests on PR into main/next
if: ${{ github.event_name == 'pull_request' && (github.base_ref == 'main' || github.base_ref == 'next') }}
run: make expensive-test
- name: Run expensive tests on merge into main/next
if: ${{ github.event_name == 'push' && (github.ref == 'main' || github.ref == 'next') }}
run: make expensive-test |
Thanks @Mirko-von-Leipzig! |
One more nit: fuzz/Cargo.lock is not committed so running fuzzing creates changes in my working directory. |
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.
Looks good to me!
2d1f30a
to
810c710
Compare
Run concurrent SMT tests in CI only when merging to `main` or `next
810c710
to
af2babb
Compare
# Conflicts: # src/merkle/smt/full/mod.rs
7346c3f
to
264b534
Compare
|
@@ -26,3 +26,20 @@ jobs: | |||
run: | | |||
rustup update --no-self-update ${{matrix.toolchain}} | |||
make test-${{matrix.args}} | |||
|
|||
test-smt-concurrent: |
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.
@Mirko-von-Leipzig, to avoid redundant runs in each matrix combination, I moved the expensive tests into a separate job that runs only once per toolchain (stable
& nightly
) on PRs targeting either main
or next
. Let me know if that works for you!
This PR introduces fuzz testing for the Sparse Merkle Tree (Smt) implementation.
It adds fuzzing targets, property-based tests, ensuring correctness and consistency between sequential and concurrent implementations.