Add native Clarity fuzzing for sBTC contracts#882
Add native Clarity fuzzing for sBTC contracts#882moodmosaic wants to merge 22 commits intostacks-sbtc:mainfrom
Conversation
c8f0101 to
308a1ad
Compare
476b1a1 to
f5d8b7e
Compare
|
Taking the PR out of draft state now that |
- Create `.invariants.clar` files for stateful, invariant fuzzing. - Create `.tests.clar` files for property-based testing. - Add placeholder comments to each file indicating their purpose.
(cherry picked from commit a61a426)
(cherry picked from commit 7686ffd)
(cherry picked from commit d626f47)
This commit adds four invariants that check general truths in the registry contract regarding: - current-signature-threshold variable - current-signer-principal variable - current-aggregate-pubkey variable - multi-sig-address map
This commit unifies the invariants and the property-based tests for each contract in a single `.tests` Clarity file.
4d41d28 to
72fbfdf
Compare
|
This PR doesn't seem to include any of the necessary testing/fuzzing logic. @moodmosaic Do you plan on adding that here? |
|
This PR actually does that logic through the To clarify:
For context, this technique has already proven valuable - a few issues in PoX-4 were identified and addressed before it went on mainnet. The Rust equivalent would be something like adding madhouse-rs for stateful fuzzing, as shown in #1633. Note that we didn't complete all |
|
Hi @aldur @djordon @setzeus! 👋 Just updated the Rendezvous tests to the current logic of the sBTC contracts. Some invariants and properties are simple, establishing a set of must-have sanity checks while showcasing the principles and features of the tool @moodmosaic and I built. For a better review experience, I've added some comments to Quick guide on how to run all the possible test suites locally: cd contracts
npm i
npx rv . sbtc-registry invariant
npx rv . sbtc-registry test
npx rv . sbtc-token invariant
npx rv . sbtc-token test
npx rv . sbtc-withdrawal testTo increase the number of runs of a testing routine (100 by default), you can use: npx rv . sbtc-registry invariant --runs=1000On failure (shouldn't be the case at this point), a seed is reported at the end of the run. You can use that seed to reproduce the exact same sequence of events: npx rv . sbtc-registry invariant --seed=<REPRO_SEED>There are more advanced features in Rendezvous, but I'd stick to the basics until common ground is settled. 🙌 For all features explained in detail you can check Rendezvous Book 📖 |
|
Hi hi gentlemen! Deeply appreciative of the hard work here - thank you for that penultimate comment with testing instructions. Giving it a whirl this weekend & will come back with additional thoughts / requests (or a good ole' LGTM). |
|
Hi @moodmosaic @BowTiedRadone, I tried running the tests following the instructions above & get the following: To clarify, I did the following:
Am I doing something wrong? |
|
Quick question before starting debugging: did you checkout the |
|
@setzeus Checked on a clean VM–no globally installed
|
|
Hi hi @BowTiedRadone, tried the instructions above & got the following now: |
|
@setzeus that's interesting. I just tried it on my MacBook and it's working fine for me. What's your setup like (Node version, etc.)? Also, here's the Rendezvous workflow file we run for all PRs and releases, and all the tests are passing on macOS in our CI. I'm thinking this might be a versioning issue. |
In order to say, @setzeus can you let us know your environment please? /cc @hugocaillard |
|
@setzeus Any updates on this? |

This adds native, Clarity-based fuzzing for the sBTC contracts, inspired by prior work in stacks-core#4550 and stacks-core#4842.
The approach is similar to Echidna and Foundry but uses Rendezvous, a forthcoming tool for Clarity fuzzing. This PR will move out of draft once Rendezvous is publicly available and all sBTC contracts are covered.