Skip to content

Test Epoch3.4 and Clarity5#6912

Open
BowTiedRadone wants to merge 30 commits intostacks-network:developfrom
BowTiedRadone:test/epoch34-clarity5
Open

Test Epoch3.4 and Clarity5#6912
BowTiedRadone wants to merge 30 commits intostacks-network:developfrom
BowTiedRadone:test/epoch34-clarity5

Conversation

@BowTiedRadone
Copy link
Copy Markdown
Contributor

@BowTiedRadone BowTiedRadone commented Feb 17, 2026

This PR applies stateless and stateful property-based testing techniques for Epoch 3.4 / Clarity 5 changes.

Stateless (proptest-rs)

  • secp256r1-verify: digest roundtrip, tamper/wrong-key/malformed-key cases, and version-governance checks
  • from-consensus-buff?: roundtrip, error/none boundary behavior across epochs, and fuzz stability
  • Relay depth filter and epoch gating invariants

Stateful (madhouse-rs)

  • Relay filter and depth-chain acceptance/rejection at each epoch
  • Cross-version Clarity 4/5 call semantics
  • SIP-040 Originator/Deny/MaybeSent post-condition sequences

Infrastructure

  • scenario! macro with deterministic default order + MADHOUSE=1 randomized mode
  • Run: cargo test -p stackslib --lib chainstate::tests::madhouse
  • Randomized: MADHOUSE=1 PROPTEST_CASES=50 cargo test -p stackslib --lib chainstate::tests::madhouse

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.00%. Comparing base (58545bc) to head (28c62ff).

Additional details and impacted files
@@             Coverage Diff              @@
##           develop    #6912       +/-   ##
============================================
- Coverage    77.73%   61.00%   -16.74%     
============================================
  Files          412      412               
  Lines       218667   218667               
  Branches       338      338               
============================================
- Hits        169981   133387    -36594     
- Misses       48686    85280    +36594     

see 295 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 58545bc...28c62ff. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@BowTiedRadone BowTiedRadone force-pushed the test/epoch34-clarity5 branch 2 times, most recently from ec722ea to 7b53b4f Compare February 22, 2026 23:00
Eight proptests covering the version-dependent hashing change. Validates
primitive/VM agreement on accept and reject paths, confirms ClarityVersion
governs hashing (not epoch), and fuzzes arbitrary inputs for crash resistance.
…proptests

Three new property-based tests for Clarity5 consensus deserialization:

- Round-trip: serialize then from-consensus-buff? recovers original value
- Type mismatch: wrong top-level constructors always returns none
- Truncation: slicing a valid encoding at any interior byte returns none
@BowTiedRadone BowTiedRadone force-pushed the test/epoch34-clarity5 branch from b51347c to 2c24755 Compare March 2, 2026 15:30
@BowTiedRadone BowTiedRadone changed the title [DRAFT] Test Epoch3.4 and Clarity5 Test Epoch3.4 and Clarity5 Mar 19, 2026
@BowTiedRadone BowTiedRadone marked this pull request as ready for review March 19, 2026 21:42
@BowTiedRadone BowTiedRadone mentioned this pull request Mar 25, 2026
5 tasks
Comment thread clarity/src/vm/tests/conversions.rs
Comment thread stackslib/Cargo.toml Outdated
Comment thread Cargo.lock
Comment thread stackslib/src/chainstate/tests/madhouse/commands/depth.rs Outdated
Comment on lines +85 to +90
let call_stack_limit = if state.chain_epoch() >= StacksEpochId::Epoch34 {
128
} else {
64
};
let parser_limit = call_stack_limit + AST_DEPTH_BUFFER;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we leverage StackDepthLimits::for_epoch here? Then we could drop all the constants: 64, 128 and AST_DEPTH_BUFFER.

Or is the goal to replicate the stack depth computation to guard against changes in the underlying implementation? (and in this case we could just write some unit tests specifics for StackDepthLimits)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the latter: the goal is to replicate the computation and guard against silent changes in the underlying implementation. If max_call_stack_depth_for_epoch or AST_CALL_STACK_DEPTH_BUFFER were accidentally modified, tests that delegate to StackDepthLimits::for_epoch would be tautological (testing the implementation against itself). The hardcoded values act as independent witnesses of the expected behavior.

Adding dedicated unit tests for StackDepthLimits would just duplicate what these commands already cover with the same hardcoded assertions, so I'd rather not add them unless you feel strongly.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point about avoiding tautological tests and using hardcoded values as an independent check, that makes sense.

That said, I’m wondering if we might be mixing concerns a bit between unit tests and madhouse tests (just calling them “madhouse” here for distinction, but could be any higher-level test). My thinking is:

We could add focused unit tests for StackDepthLimits::for_epoch that explicitly assert the expected values (including the constants). That would lock in the behavior in a single, well-scoped place.
Then, in madhouse tests, we could rely on StackDepthLimits::for_epoch directly, since at that point we’re more interested in validating system behavior end-to-end (e.g. RelayDeepContract) rather than re-checking the exact computation.

This way:

  • The computation is still guarded against accidental changes via dedicated unit tests related to the component that encapsulate the behaviour (which we don’t currently have).
  • madhouse tests stay simpler and avoid duplicating logic or constants (and try to cross-reference with the original ones by docstring)
  • If the computation ever legitimately changes, we only need to update expectations in one place, avoiding duplication across test layers.
  • No duplication between tests because they would be layered (if we dont need additional safeguard).

Do you think this split could work?

Comment thread stackslib/src/chainstate/tests/madhouse/commands/postcond.rs
Comment thread stackslib/src/chainstate/tests/madhouse/commands/sip040.rs Outdated
Comment on lines +974 to +991
pub fn consensus_buff_type_strategy() -> BoxedStrategy<String> {
let len_range = 1u32..=128;

prop_oneof![
Just("int".to_string()),
Just("uint".to_string()),
Just("bool".to_string()),
Just("principal".to_string()),
len_range.clone().prop_map(|n| format!("(buff {n})")),
len_range
.clone()
.prop_map(|n| format!("(string-ascii {n})")),
len_range.clone().prop_map(|n| format!("(string-utf8 {n})")),
Just("(optional int)".to_string()),
len_range.prop_map(|n| format!("(list {n} int)")),
Just("(response int int)".to_string()),
]
.boxed()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sanity-check: should tuple also be considered here?

Comment thread clarity/src/vm/tests/epoch_gating.rs Outdated
Comment thread stackslib/src/chainstate/tests/madhouse/commands/postcond.rs Outdated
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 9, 2026

CLA assistant check
All committers have signed the CLA.

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 9, 2026

Coverage Report for CI Build 24514498135

Coverage increased (+0.004%) to 85.716%

Details

  • Coverage increased (+0.004%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 3018 coverage regressions across 78 files.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

3018 previously-covered lines in 78 files lost coverage.

Top 10 Files by Coverage Loss Lines Losing Coverage Coverage
stackslib/src/net/inv/epoch2x.rs 213 79.95%
stackslib/src/net/chat.rs 201 93.01%
stackslib/src/chainstate/stacks/miner.rs 190 83.5%
stacks-node/src/nakamoto_node/miner.rs 156 86.82%
stackslib/src/chainstate/stacks/db/mod.rs 135 86.21%
clarity/src/vm/costs/mod.rs 125 83.57%
stackslib/src/net/api/postblock_proposal.rs 120 80.99%
stacks-node/src/nakamoto_node/relayer.rs 115 86.1%
stackslib/src/config/mod.rs 101 68.84%
stackslib/src/clarity_vm/database/marf.rs 99 60.67%

Coverage Stats

Coverage Status
Relevant Lines: 218251
Covered Lines: 187077
Line Coverage: 85.72%
Coverage Strength: 17343172.08 hits per line

💛 - Coveralls

@radu-stacks radu-stacks force-pushed the test/epoch34-clarity5 branch from dfd390f to 80dd989 Compare April 15, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants