test: property-based + stateful tests for the Bitcoin-staking surface#7268
Open
simone-stacks wants to merge 46 commits into
Open
test: property-based + stateful tests for the Bitcoin-staking surface#7268simone-stacks wants to merge 46 commits into
simone-stacks wants to merge 46 commits into
Conversation
Contributor
|
@simone-stacks Can you please run |
Contributor
Author
|
@radu-stacks done! |
Coverage Report for CI Build 27410170590Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage increased (+0.1%) to 86.077%Details
Uncovered Changes
Coverage Regressions6698 previously-covered lines in 100 files lost coverage.
Coverage Stats
💛 - Coveralls |
radu-stacks
reviewed
Jun 5, 2026
radu-stacks
left a comment
Contributor
There was a problem hiding this comment.
This is a solid piece of work! Leaving here the first round of review comments after thoroughly checking the targeted areas.
251fc97 to
219d675
Compare
9e10f28 to
146633a
Compare
…x-5-waterfall-proptests
…nd reclaim script
This file contains hidden or 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
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
Adds a comprehensive property-based and stateful (
madhouse-rs) test layer for the Bitcoin-staking feature surface, with no changes to production behaviour. It covers the Clarity Bitcoin builtins, the sBTC deposit-address derivation, the PoX-5 STX-locking primitives, and the node↔contract dispatch seam.Additional info (benefits, drawbacks, caveats)
Surface covered
verify-merkle-proof,get-bitcoin-tx-output?)clarity/src/vm/functions/bitcoin.rsclarity/src/vm/functions/bitcoin_madhouse.rsstackslib/src/chainstate/stacks/sbtc.rspox-locking/src/pox_5.rs,pox-locking/src/tests/madhouse.rsWhat's added
tx-countcollision, and canonical depth vs an independent oracle.tx-counttransitions over deep trees, with a global invariant hook (tx_count = 0and an inflated cross-count rejected for every tree in the pool) re-checked after every command.native_*coercion layer: wrong arity, mis-typed arguments (non-32 buffs, non-uint scalars, non-list siblings), and oversized (>24) siblings lists never panic on consensus input — they return an error orfalse; plus a randomizedbuff_to_array::<32>length-rejection property.get-bitcoin-tx-output?: roundtrip,voutout-of-range /u64-overflow →err u2, unparseable bytes →err u1, the script at-cap / over-cap boundary, and the consensus cost-input function.pox_rollover_v5gates) with exact error-code assertions (LockingError::as_error_code), plus full-balance boundary acceptance.handle_contract_call → parse_pox_stake_result → pox_lock_v5/pox_rollover_v5— the node parsing and applying the contract's stake / lockup / roll-over response (the boundary the companion contract-side effort never reaches).unlock_height, the off-by-one a random walk never lands on), and negative-path (illegal-transition) commands.verify-merkle-proofhardening.Companion effort #7245 (PoX-5 Clarity Stateful PBT)
#7245 drives
pox-5.clardirectly with afast-checkstateful machine (staking lifecycle, signer grants/rotation, bond setup/registration, error branches, standing invariants). The two efforts hit the stack from opposite ends and meet at the Bitcoin builtins:verify-merkle-proof/get-bitcoin-tx-output?at the Rust level (CVE-resistant, panic-free); [DRAFT] PoX-5 Clarity Stateful PBT #7245's register-for-bond L1 path and announce-l1-early-exit sit on top of those builtins in-contract, but simnet can't supply real burn headers, so [DRAFT] PoX-5 Clarity Stateful PBT #7245 covers only the rejection branches (ERR_INVALID_BTC_HEADER, the is-l1-lock gate, etc.); this PR covers the builtins' happy paths the contract layer can't reach.No overlap; together they cover pox-5 / Bitcoin staking top-to-bottom.
Validation
MADHOUSE=1 PROPTEST_CASES=2500.cargo-mutants; the one real surviving mutant found during review — a node-crash vector in the merkle builtin's buffer coercion (buff_to_arrayon a short consensus buffer) — is now pinned.Checklist
docs/property-testing.md)changelog.d/README.md)rpc/openapi.yamlfor RPC endpoints,event-dispatcher.mdfor new events)clarity-benchmarkingrepo