Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e78e417
Update functions that should return CheckErrorKind instead of VmExecu…
jacinta-stacks Dec 3, 2025
e211cee
Merge branch 'develop' of https://github.com/stacks-network/stacks-co…
jacinta-stacks Dec 3, 2025
542346f
Merge branch 'develop' of https://github.com/stacks-network/stacks-co…
jacinta-stacks Dec 9, 2025
13480cf
Merge branch 'feat/aac-split-static-check-errors' of https://github.c…
jacinta-stacks Dec 9, 2025
b8ca7dd
First pass: add ClarityTypeError and cleanup RuntimeError a bit
jacinta-stacks Dec 10, 2025
b141d7c
Merge branch 'develop' of https://github.com/stacks-network/stacks-co…
jacinta-stacks Dec 10, 2025
8f25aad
Add From implementations for ClarityErrorType
jacinta-stacks Dec 10, 2025
b03ad0f
CRC: fix comments and revert pub append to a private function in List…
jacinta-stacks Dec 30, 2025
ed662a8
CRC: remove DiagnosableError from ClarityTypeError
jacinta-stacks Jan 5, 2026
1b6decc
CRC: remove ClarityTypeError conversion to Error::ClarityError, addin…
jacinta-stacks Jan 5, 2026
1210c8a
CRC: add a custom error message to ExpectsAcceptable
jacinta-stacks Jan 5, 2026
418f1ff
CRC: add a custom error message to ExpectsAcceptable in CommonCheckEr…
jacinta-stacks Jan 5, 2026
edea85b
CRC: fix error type in special_concat_v205
jacinta-stacks Jan 5, 2026
c10f33a
Fix special_slice to return the type of the bad sequence
jacinta-stacks Jan 5, 2026
0865eaa
CRC: annotate mod datamaps and mod sequences with cfg(test)
jacinta-stacks Jan 5, 2026
9074197
CRC: remove ClarityTypeError conversion to chainstate::stacks::Error:…
jacinta-stacks Jan 5, 2026
1128a74
CRC: remove SupertypeTooLarge and TypeMismatch from CommonCheckErrorKind
jacinta-stacks Jan 5, 2026
e22cbad
Map consensus critical paths to appropriate VmInternalError and remov…
jacinta-stacks Jan 5, 2026
bf0d4a1
CRC: address comments on clarity-types/src/types/mod.rs
jacinta-stacks Jan 5, 2026
dc55e20
CRC: address comments on clarity-types/src/types/signatures.rs
jacinta-stacks Jan 5, 2026
1396c0f
CRC: make things consistent with before for VmInternalError conversio…
jacinta-stacks Jan 5, 2026
95707bd
cargo fmt
jacinta-stacks Jan 5, 2026
278d2ac
Do not prematurely convert ClarityTypes to Invariants where logic is …
jacinta-stacks Jan 6, 2026
096610b
Fix to_value call handling in special_filter
jacinta-stacks Jan 6, 2026
9cd9706
Fix O(n^2) retain_values function to be O(n)
jacinta-stacks Jan 6, 2026
f3c25ed
Move VmExecutionError, VmInternalError, RuntimeError, and EarlyReturn…
jacinta-stacks Jan 6, 2026
f9fac72
CRC: remove conversion to ClarityTypeError in ChainstateError and exp…
jacinta-stacks Jan 6, 2026
7a1344a
Update copyright for the missed files
jacinta-stacks Jan 6, 2026
829d75f
Remove helper TODO comments
jacinta-stacks Jan 6, 2026
31c24fe
Merge branch 'develop' of https://github.com/stacks-network/stacks-co…
jacinta-stacks Jan 6, 2026
d8f8ed9
Revert accidental change to From<VmExecutionError> for Chainstate Error
jacinta-stacks Jan 6, 2026
09214b9
Fix test_simple_list_concat test
jacinta-stacks Jan 7, 2026
70752cc
CRC: fix retain_values to not mutate on error, remove unused error, f…
jacinta-stacks Jan 7, 2026
5121826
Merge branch 'develop' of https://github.com/stacks-network/stacks-co…
jacinta-stacks Jan 8, 2026
1c8a274
Merge branch 'develop' of https://github.com/stacks-network/stacks-co…
jacinta-stacks Jan 8, 2026
8c01888
Merge branch 'develop' of https://github.com/stacks-network/stacks-co…
jacinta-stacks Jan 9, 2026
de4db2c
Fix retain_values function to match old behaviour and use ExpectsAcce…
jacinta-stacks Jan 9, 2026
3cd5ad2
Clippy fix
jacinta-stacks Jan 9, 2026
23c8c6b
Fix unit test now that we just use ExpectAcceptable instead of Specif…
jacinta-stacks Jan 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

209 changes: 183 additions & 26 deletions clarity-types/src/errors/analysis.rs

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions clarity-types/src/errors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub use lexer::LexerError;
use rusqlite::Error as SqliteError;
use stacks_common::types::chainstate::BlockHeaderHash;

use crate::ClarityTypeError;
use crate::representations::SymbolicExpression;
use crate::types::{FunctionIdentifier, Value};

Expand Down Expand Up @@ -160,8 +161,6 @@ pub enum RuntimeError {
MaxStackDepthReached,
/// The execution context depth exceeded the virtual machine's limit.
MaxContextDepthReached,
/// Attempt to construct an invalid or unsupported type at runtime (e.g., malformed data structure).
BadTypeConstruction,
/// Reference to an invalid or out-of-bounds block height.
/// The `String` represents the string representation of the queried block height that was invalid.
BadBlockHeight(String),
Expand All @@ -173,9 +172,6 @@ pub enum RuntimeError {
NoCallerInContext,
/// No sender principal available in the current execution context.
NoSenderInContext,
/// Invalid name-value pair in contract data (e.g., map keys).
/// The `&'static str` represents the name of the invalid pair, and the `String` represents the offending value.
BadNameValue(&'static str, String),
/// Reference to a non-existent block header hash.
/// The `BlockHeaderHash` represents the unknown block header hash.
UnknownBlockHeaderHash(BlockHeaderHash),
Expand Down Expand Up @@ -261,6 +257,12 @@ impl error::Error for RuntimeError {
}
}

impl From<ClarityTypeError> for VmExecutionError {
fn from(err: ClarityTypeError) -> Self {
Self::from(CheckErrorKind::from(err))
}
}

impl From<ParseError> for VmExecutionError {
fn from(err: ParseError) -> Self {
match *err.err {
Expand Down
2 changes: 1 addition & 1 deletion clarity-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub mod types;

pub use errors::VmExecutionError;
pub use representations::{ClarityName, ContractName};
pub use types::Value;
pub use types::{ClarityTypeError, Value};

pub const MAX_CALL_STACK_DEPTH: usize = 64;

Expand Down
13 changes: 5 additions & 8 deletions clarity-types/src/representations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ use regex::Regex;
use stacks_common::codec::{Error as codec_error, StacksMessageCodec, read_next, write_next};

use crate::Value;
use crate::errors::RuntimeError;
use crate::types::TraitIdentifier;
use crate::types::{ClarityTypeError, TraitIdentifier};

pub const CONTRACT_MIN_NAME_LENGTH: usize = 1;
pub const CONTRACT_MAX_NAME_LENGTH: usize = 40;
Expand Down Expand Up @@ -63,20 +62,18 @@ lazy_static! {

guarded_string!(
ClarityName,
"ClarityName",
CLARITY_NAME_REGEX,
MAX_STRING_LEN,
RuntimeError,
RuntimeError::BadNameValue
ClarityTypeError,
ClarityTypeError::InvalidClarityName
);

guarded_string!(
ContractName,
"ContractName",
CONTRACT_NAME_REGEX,
MAX_STRING_LEN,
RuntimeError,
RuntimeError::BadNameValue
ClarityTypeError,
ClarityTypeError::InvalidContractName
);

impl StacksMessageCodec for ClarityName {
Expand Down
10 changes: 5 additions & 5 deletions clarity-types/src/tests/representations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

use rstest::rstest;

use crate::errors::RuntimeError;
use crate::representations::{
CONTRACT_MAX_NAME_LENGTH, CONTRACT_MIN_NAME_LENGTH, ClarityName, ContractName, MAX_STRING_LEN,
};
use crate::stacks_common::codec::StacksMessageCodec;
use crate::types::ClarityTypeError;

#[rstest]
#[case::valid_name("hello")]
Expand Down Expand Up @@ -73,7 +73,7 @@ fn test_clarity_name_invalid(#[case] name: &str) {
assert!(result.is_err());
assert!(matches!(
result.unwrap_err(),
RuntimeError::BadNameValue(_, _)
ClarityTypeError::InvalidClarityName(_)
));
}

Expand All @@ -99,7 +99,7 @@ fn test_clarity_name_serialization(#[case] name: &str) {
// the first byte is the length of the buffer.
#[rstest]
#[case::invalid_utf8(vec![4, 0xFF, 0xFE, 0xFD, 0xFC], "Failed to parse Clarity name: could not contruct from utf8")]
#[case::invalid_name(vec![2, b'2', b'i'], "Failed to parse Clarity name: BadNameValue(\"ClarityName\", \"2i\")")] // starts with number
#[case::invalid_name(vec![2, b'2', b'i'], "Failed to parse Clarity name: InvalidClarityName(\"2i\")")] // starts with number
#[case::too_long(vec![MAX_STRING_LEN + 1], "Failed to deserialize clarity name: too long")]
#[case::wrong_length(vec![3, b'a'], "failed to fill whole buffer")]
fn test_clarity_name_deserialization_errors(#[case] buffer: Vec<u8>, #[case] error_message: &str) {
Expand Down Expand Up @@ -157,7 +157,7 @@ fn test_contract_name_invalid(#[case] name: &str) {
assert!(result.is_err());
assert!(matches!(
result.unwrap_err(),
RuntimeError::BadNameValue(_, _)
ClarityTypeError::InvalidContractName(_)
));
}

Expand Down Expand Up @@ -201,7 +201,7 @@ fn test_contract_name_serialization_too_long() {
// the first byte is the length of the buffer.
#[rstest]
#[case::invalid_utf8(vec![4, 0xFF, 0xFE, 0xFD, 0xFC], "Failed to parse Contract name: could not construct from utf8")]
#[case::invalid_name(vec![2, b'2', b'i'], "Failed to parse Contract name: BadNameValue(\"ContractName\", \"2i\")")] // starts with number
#[case::invalid_name(vec![2, b'2', b'i'], "Failed to parse Contract name: InvalidContractName(\"2i\")")] // starts with number
#[case::too_long(vec![MAX_STRING_LEN + 1], &format!("Failed to deserialize contract name: too short or too long: {}", MAX_STRING_LEN + 1))]
#[case::wrong_length(vec![3, b'a'], "failed to fill whole buffer")]
fn test_contract_name_deserialization_errors(#[case] buffer: Vec<u8>, #[case] error_message: &str) {
Expand Down
Loading