Skip to content

Conversation

@jacinta-stacks
Copy link
Contributor

@jacinta-stacks jacinta-stacks commented Dec 10, 2025

I have added a bunch of comments that I will need to rip out before merging this. Mostly around where I am changing what was previously an "Expect" into a Nonexpect error. Mostly cause they prob shouldn't ever happen/I don't know why they would actually invalidate a block. I also added an ExpectAcceptable and ExpectRejectable type.

Feedback would be good.

@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

❌ Patch coverage is 71.54538% with 348 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.42%. Comparing base (c9003aa) to head (8f25aad).

Files with missing lines Patch % Lines
clarity-types/src/types/mod.rs 74.73% 72 Missing ⚠️
clarity-types/src/errors/analysis.rs 34.44% 59 Missing ⚠️
stackslib/src/chainstate/nakamoto/signer_set.rs 55.68% 39 Missing ⚠️
...ackslib/src/chainstate/nakamoto/coordinator/mod.rs 47.82% 24 Missing ⚠️
...y/src/vm/analysis/type_checker/v2_1/natives/mod.rs 25.80% 23 Missing ⚠️
clarity-types/src/types/signatures.rs 83.13% 14 Missing ⚠️
clarity/src/vm/analysis/type_checker/v2_1/mod.rs 26.66% 11 Missing ⚠️
.../src/vm/analysis/type_checker/v2_05/natives/mod.rs 28.57% 10 Missing ⚠️
clarity/src/vm/functions/sequences.rs 78.72% 10 Missing ⚠️
clarity/src/vm/analysis/type_checker/v2_05/mod.rs 18.18% 9 Missing ⚠️
... and 20 more

❌ Your project check has failed because the head coverage (77.42%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #6751      +/-   ##
===========================================
- Coverage    77.90%   77.42%   -0.48%     
===========================================
  Files          580      580              
  Lines       361187   361490     +303     
===========================================
- Hits        281374   279877    -1497     
- Misses       79813    81613    +1800     
Files with missing lines Coverage Δ
clarity-types/src/errors/mod.rs 76.34% <100.00%> (+0.78%) ⬆️
clarity-types/src/lib.rs 100.00% <ø> (ø)
clarity-types/src/representations.rs 85.49% <ø> (ø)
clarity-types/src/tests/representations.rs 75.00% <ø> (ø)
clarity-types/src/tests/types/mod.rs 97.07% <100.00%> (+0.02%) ⬆️
clarity-types/src/tests/types/serialization.rs 98.27% <100.00%> (-0.04%) ⬇️
clarity-types/src/tests/types/signatures.rs 99.12% <100.00%> (ø)
...rc/vm/analysis/type_checker/v2_1/natives/assets.rs 98.36% <100.00%> (ø)
...lysis/type_checker/v2_1/natives/post_conditions.rs 97.27% <ø> (ø)
clarity/src/vm/contexts.rs 92.24% <100.00%> (+0.01%) ⬆️
... and 50 more

... and 91 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 c9003aa...8f25aad. 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.

@jacinta-stacks jacinta-stacks force-pushed the chore/add-custom-error-to-clarity-types branch 5 times, most recently from 826c4d7 to 9d27ff0 Compare December 10, 2025 17:52
@jacinta-stacks jacinta-stacks force-pushed the chore/add-custom-error-to-clarity-types branch 2 times, most recently from 59cb8ff to b8ca7dd Compare December 10, 2025 20:07
Copy link
Contributor

@federico-stacks federico-stacks left a comment

Choose a reason for hiding this comment

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

Did a first pass. In the meantime, I’m sharing some thoughts

/// Expected type does not match the actual type during analysis.
/// The first `Box<TypeSignature>` wraps the expected type, and the second wraps the actual type.
TypeMismatch(Box<TypeSignature>, Box<TypeSignature>),
/// Expected an different response type
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
/// Expected an different response type
/// Expected a different response type

/// Empty tuple is not allowed in Clarity.
EmptyTuplesNotAllowed,
/// Supertype (e.g., trait or union) exceeds the maximum allowed size or complexity.
/// This error indicates a transaction would invalidate a block if included.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: block validation logic/comment should not be part of ClarityTypeError

Comment on lines +1346 to +1347
/// TODO: remove this comment. For code reviwers: this is only ever called in tests and immediately unwrapped
pub fn expect_bool(self) -> Result<bool, ClarityTypeError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

It appears this is also used in production code by StacksChainState::is_pox_active(), which relies on expect(), so current change should be still safe.


pub fn expect_callable(self) -> Result<CallableData, VmExecutionError> {
/// TODO: remove this comment. For reviwers: this is only called in tests and immediately unwrapped
pub fn expect_callable(self) -> Result<CallableData, ClarityTypeError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be tagged with #[cfg(any(test, feature = "testing"))], or do we want to keep it as part of the reusable public API?

This comment apply to other TODO comment like this one.

}

fn append(
pub fn append(
Copy link
Contributor

Choose a reason for hiding this comment

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

Not strictly necessary, but I’m fine with it if the goal is to improve the reusable public API.

Comment on lines +1720 to +1721
/// TODO: Do we want to make these return errors? I know in theory its infallible, but there is a lot of
/// in theory infallible that return errors instead of straight expects.
Copy link
Contributor

Choose a reason for hiding this comment

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

Good point! I don’t have a definitive answer. On one hand, I’d prefer to eliminate the expect calls; on the other hand, they do help break the "error chain".

}

fn admits_type_v2_1(&self, other: &TypeSignature) -> Result<bool, CommonCheckErrorKind> {
fn admits_type_v2_1(&self, other: &TypeSignature) -> Result<bool, ClarityTypeError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just sharing some reasoning on possibly changing admits_type_v2_0 and admits_type_v2_1 to return a plain bool instead of Result<bool, ClarityTypeError>:

  • For both admits_type_v2_0 and admits_type_v2_1, it looks feasible to return only bool since they don’t meaningfully use the error channel.
  • The only blocker comes from the top-level admits_type, which currently returns
    StacksEpochId::Epoch10 => Err(ClarityTypeError::UnsupportedEpoch(*epoch))

If we could treat that case as StacksEpochId::Epoch10 => false instead, then all admits_type* methods could avoid returning ClarityTypeError entirely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants