Skip to content
Merged
Show file tree
Hide file tree
Changes from 59 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
91b7c38
chore: RuntimeCheckErrorKind::ExpectName to ExpectAcceptable
federico-stacks Feb 4, 2026
9ade36d
chore: RuntimeCheckErrorKind::BadMatchInput to ExpectAcceptable
federico-stacks Feb 4, 2026
285f964
chore: RuntimeCheckErrorKind::InvalidTypeDescription to ExpectAcceptable
federico-stacks Feb 4, 2026
6658d51
chore: RuntimeCheckErrorKind::UnknownTypeName to ExpectAcceptable
federico-stacks Feb 4, 2026
5285cff
chore: RuntimeCheckErrorKind::UnionTypeError to ExpectAcceptable
federico-stacks Feb 4, 2026
a10bfd5
chore: RuntimeCheckErrorKind::ExpectedOptionalValue to ExpectAcceptable
federico-stacks Feb 4, 2026
9454df2
chore: RuntimeCheckErrorKind::ExpectedResponseValue to ExpectAcceptable
federico-stacks Feb 4, 2026
18a550e
chore: RuntimeCheckErrorKind::ExpectedOptionalOrResponseValue to Expe…
federico-stacks Feb 5, 2026
d35f0f9
chore: RuntimeCheckErrorKind::BadTokenName to ExpectAcceptable
federico-stacks Feb 5, 2026
11947ab
chore: RuntimeCheckErrorKind::NoSuchNFT to ExpectAcceptable
federico-stacks Feb 5, 2026
0f0dda6
chore: RuntimeCheckErrorKind::NoSuchFT to ExpectAcceptable
federico-stacks Feb 5, 2026
1849ddc
chore: RuntimeCheckErrorKind::BadTransferSTXArguments to ExpectAccept…
federico-stacks Feb 5, 2026
1565e4d
chore: RuntimeCheckErrorKind::BadTransferFTArguments to ExpectAcceptable
federico-stacks Feb 5, 2026
f863389
chore: RuntimeCheckErrorKind::BadTransferNFTArguments to ExpectAccept…
federico-stacks Feb 5, 2026
73bf6be
chore: RuntimeCheckErrorKind::BadMintFTArguments to ExpectAcceptable
federico-stacks Feb 5, 2026
90ccc40
chore: RuntimeCheckErrorKind::BadBurnFTArguments to ExpectAcceptable
federico-stacks Feb 5, 2026
ca5f063
chore: RuntimeCheckErrorKind::ExpectedTuple to ExpectAcceptable
federico-stacks Feb 5, 2026
4fc96ae
chore: RuntimeCheckErrorKind::NoSuchTupleField to ExpectAcceptable
federico-stacks Feb 5, 2026
e435263
chore: RuntimeCheckErrorKind::DefineFunctionBadSignature to ExpectAcc…
federico-stacks Feb 5, 2026
2cb3172
chore: RuntimeCheckErrorKind::BadFunctionName to ExpectAcceptable
federico-stacks Feb 5, 2026
c681016
chore: RuntimeCheckErrorKind::PublicFunctionMustReturnResponse to Exp…
federico-stacks Feb 5, 2026
b818026
chore: RuntimeCheckErrorKind::EmptyTuplesNotAllowed to ExpectAcceptable
federico-stacks Feb 5, 2026
7697013
chore: RuntimeCheckErrorKind::NoSuchMap to ExpectAcceptable
federico-stacks Feb 5, 2026
05465fe
chore: RuntimeCheckErrorKind::NoSuchDataVariable to ExpectAcceptable
federico-stacks Feb 5, 2026
c4529a6
chore: RuntimeCheckErrorKind::ContractAlreadyExists to ExpectAcceptable
federico-stacks Feb 5, 2026
0966477
chore: RuntimeCheckErrorKind::PublicFunctionNotReadOnly to ExpectAcce…
federico-stacks Feb 5, 2026
4bdd625
chore: RuntimeCheckErrorKind::NoSuchBurnBlockInfoProperty to ExpectAc…
federico-stacks Feb 5, 2026
66baa0e
chore: RuntimeCheckErrorKind::NoSuchStacksBlockInfoProperty to Expect…
federico-stacks Feb 5, 2026
6c47d6e
chore: RuntimeCheckErrorKind::GetBlockInfoExpectPropertyName to Expec…
federico-stacks Feb 5, 2026
02386e8
chore: RuntimeCheckErrorKind::GetStacksBlockInfoExpectPropertyName to…
federico-stacks Feb 5, 2026
1c1cc63
chore: RuntimeCheckErrorKind::GetTenureInfoExpectPropertyName to Expe…
federico-stacks Feb 9, 2026
ec1953b
chore: RuntimeCheckErrorKind::NonFunctionApplication to ExpectAcceptable
federico-stacks Feb 9, 2026
44932ba
chore: RuntimeCheckErrorKind::ExpectedListApplication to ExpectAccept…
federico-stacks Feb 9, 2026
aa6a99a
chore: RuntimeCheckErrorKind::ExpectedSequence to ExpectAcceptable
federico-stacks Feb 9, 2026
ff1d332
chore: RuntimeCheckErrorKind::BadLetSyntax to ExpectAcceptable
federico-stacks Feb 9, 2026
ccb1da4
chore: RuntimeCheckErrorKind::BadSyntaxBinding to ExpectAcceptable
federico-stacks Feb 9, 2026
e3657bb
chore: RuntimeCheckErrorKind::UndefinedVariable to ExpectAcceptable
federico-stacks Feb 9, 2026
821a139
chore: RuntimeCheckErrorKind::RequiresAtLeastArguments to ExpectAccep…
federico-stacks Feb 9, 2026
111328d
chore: RuntimeCheckErrorKind::RequiresAtMostArguments to ExpectAccept…
federico-stacks Feb 9, 2026
235c4c4
chore: RuntimeCheckErrorKind::TooManyFunctionParameters to ExpectAcce…
federico-stacks Feb 9, 2026
d2fad95
chore: RuntimeCheckErrorKind::TraitReferenceUnknown to ExpectAcceptable
federico-stacks Feb 9, 2026
c2768f1
chore: RuntimeCheckErrorKind::TraitMethodUnknown to ExpectAcceptable
federico-stacks Feb 9, 2026
a0b2452
chore: RuntimeCheckErrorKind::ExpectedTraitIdentifier to ExpectAccept…
federico-stacks Feb 9, 2026
dedd31f
chore: RuntimeCheckErrorKind::DefineTraitBadSignature to ExpectAccept…
federico-stacks Feb 9, 2026
6428724
chore: RuntimeCheckErrorKind::DefineTraitDuplicateMethod to ExpectAcc…
federico-stacks Feb 9, 2026
649072e
chore: RuntimeCheckErrorKind::TraitBasedContractCallInReadOnly to Exp…
federico-stacks Feb 9, 2026
fb03e77
chore: RuntimeCheckErrorKind::ContractOfExpectsTrait to ExpectAcceptable
federico-stacks Feb 9, 2026
51abc99
chore: RuntimeCheckErrorKind::TraitTooManyMethods to ExpectAcceptable
federico-stacks Feb 9, 2026
c48e278
chore: RuntimeCheckErrorKind::WriteAttemptedInReadOnly to ExpectAccep…
federico-stacks Feb 9, 2026
50fba5a
chore: RuntimeCheckErrorKind::ExpectedListOfAllowances to ExpectAccep…
federico-stacks Feb 9, 2026
231e3c7
chore: RuntimeCheckErrorKind::AllowanceExprNotAllowed to ExpectAccept…
federico-stacks Feb 9, 2026
5900431
chore: RuntimeCheckErrorKind::ExpectedAllowanceExpr to ExpectAcceptable
federico-stacks Feb 9, 2026
bb09aba
chore: RuntimeCheckErrorKind::TooManyAllowances to ExpectAcceptable
federico-stacks Feb 9, 2026
8f86b3c
chore: RuntimeCheckErrorKind::BadMatchOptionSyntax to ExpectAcceptable
federico-stacks Feb 9, 2026
35e9761
chore: RuntimeCheckErrorKind::BadMatchResponseSyntax to ExpectAcceptable
federico-stacks Feb 9, 2026
1e99114
chore: RuntimeCheckErrorKind::SupertypeTooLarge to ExpectRejectable
federico-stacks Feb 9, 2026
3045880
chore: fix unit-tests
federico-stacks Feb 9, 2026
481c3cc
chore: fix clarity fuzzer
federico-stacks Feb 9, 2026
41c7347
chore: fix clippy
federico-stacks Feb 9, 2026
8e993ca
crc: improve errors message
federico-stacks Feb 10, 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
230 changes: 35 additions & 195 deletions clarity-types/src/errors/analysis.rs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions clarity/fuzz/fuzz_targets/fuzz_sanitize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ pub fn strict_admits(me: &TypeSignature, x: &ClarityValue) -> Result<bool, Runti
}
TypeSignature::CallableType(_)
| TypeSignature::ListUnionType(_)
| TypeSignature::TraitReferenceType(_) => Err(
RuntimeCheckErrorKind::TraitReferenceUnknown("Unknown trait reference".into()),
),
| TypeSignature::TraitReferenceType(_) => Err(RuntimeCheckErrorKind::ExpectsAcceptable(
"Trait reference unknown".into(),
)),
}
}

Expand Down
4 changes: 2 additions & 2 deletions clarity/fuzz/fuzz_targets/fuzz_value_sanitize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ pub fn strict_admits(me: &TypeSignature, x: &ClarityValue) -> Result<bool, Runti
}
TypeSignature::CallableType(_)
| TypeSignature::ListUnionType(_)
| TypeSignature::TraitReferenceType(_) => Err(RuntimeCheckErrorKind::TraitReferenceUnknown(
"Unknown trait reference".into(),
| TypeSignature::TraitReferenceType(_) => Err(RuntimeCheckErrorKind::ExpectsAcceptable(
"Trait reference unknown".into(),
)),
}
}
Expand Down
14 changes: 7 additions & 7 deletions clarity/src/vm/callables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,16 +329,16 @@ impl DefinedFunction {
let trait_name = trait_identifier.name.to_string();
let constraining_trait = contract_defining_trait
.lookup_trait_definition(&trait_name)
.ok_or(RuntimeCheckErrorKind::TraitReferenceUnknown(
trait_name.to_string(),
))?;
.ok_or(RuntimeCheckErrorKind::ExpectsAcceptable(format!(
"Trait reference unknown: {trait_name}"
)))?;
let expected_sig =
constraining_trait
.get(&self.name)
.ok_or(RuntimeCheckErrorKind::TraitMethodUnknown(
trait_name.to_string(),
self.name.to_string(),
))?;
.ok_or(RuntimeCheckErrorKind::ExpectsAcceptable(format!(
"Trait method unknown: {trait_name}.{}",
self.name
)))?;

let args = self.arg_types.to_vec();
if !expected_sig.check_args_trait_compliance(epoch, args)? {
Expand Down
27 changes: 14 additions & 13 deletions clarity/src/vm/contexts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ impl<'a, 'b, 'hooks> Environment<'a, 'b, 'hooks> {
if !allow_private && !func.is_public() {
return Err(RuntimeCheckErrorKind::NoSuchPublicFunction(contract_identifier.to_string(), tx_name.to_string()).into());
} else if read_only && !func.is_read_only() {
return Err(RuntimeCheckErrorKind::PublicFunctionNotReadOnly(contract_identifier.to_string(), tx_name.to_string()).into());
return Err(RuntimeCheckErrorKind::ExpectsAcceptable(format!("Public function not read-only: {contract_identifier} {tx_name}")).into());
}

let args: Result<Vec<Value>, VmExecutionError> = args.iter()
Expand Down Expand Up @@ -1338,9 +1338,9 @@ impl<'a, 'b, 'hooks> Environment<'a, 'b, 'hooks> {
.database
.has_contract(&contract_identifier)
{
return Err(RuntimeCheckErrorKind::ContractAlreadyExists(
contract_identifier.to_string(),
)
return Err(RuntimeCheckErrorKind::ExpectsAcceptable(format!(
"Contract already exists: {contract_identifier}"
))
.into());
}

Expand Down Expand Up @@ -1876,12 +1876,11 @@ impl<'a, 'hooks> GlobalContext<'a, 'hooks> {
self.commit()?;
Ok(result)
} else {
Err(
RuntimeCheckErrorKind::PublicFunctionMustReturnResponse(Box::new(
TypeSignature::type_of(&result)?,
))
.into(),
)
Err(RuntimeCheckErrorKind::ExpectsAcceptable(format!(
"Public function must return response: {}",
TypeSignature::type_of(&result)?
))
.into())
}
} else {
self.roll_back()?;
Expand Down Expand Up @@ -2504,9 +2503,11 @@ mod test {
.initialize_contract_from_ast(contract_id.clone(), version, &ast, contract_src)
.unwrap_err();

assert!(matches!(
assert_eq!(
err,
VmExecutionError::RuntimeCheck(RuntimeCheckErrorKind::ContractAlreadyExists(_))
));
VmExecutionError::RuntimeCheck(RuntimeCheckErrorKind::ExpectsAcceptable(
"Contract already exists: S1G2081040G2081040G2081040G208105NK8PE5.dup".to_string()
))
);
}
}
23 changes: 15 additions & 8 deletions clarity/src/vm/database/clarity_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1537,8 +1537,12 @@ impl ClarityDatabase<'_> {
) -> Result<DataVariableMetadata, VmExecutionError> {
let key = ClarityDatabase::make_metadata_key(StoreType::VariableMeta, variable_name);

map_no_contract_as_none(self.fetch_metadata(contract_identifier, &key))?
.ok_or(RuntimeCheckErrorKind::NoSuchDataVariable(variable_name.to_string()).into())
map_no_contract_as_none(self.fetch_metadata(contract_identifier, &key))?.ok_or(
RuntimeCheckErrorKind::ExpectsAcceptable(format!(
"No such data variable: {variable_name}"
))
.into(),
)
}

#[cfg(any(test, feature = "testing"))]
Expand Down Expand Up @@ -1678,8 +1682,9 @@ impl ClarityDatabase<'_> {
) -> Result<DataMapMetadata, VmExecutionError> {
let key = ClarityDatabase::make_metadata_key(StoreType::DataMapMeta, map_name);

map_no_contract_as_none(self.fetch_metadata(contract_identifier, &key))?
.ok_or(RuntimeCheckErrorKind::NoSuchMap(map_name.to_string()).into())
map_no_contract_as_none(self.fetch_metadata(contract_identifier, &key))?.ok_or(
RuntimeCheckErrorKind::ExpectsAcceptable(format!("No such map: {map_name}")).into(),
)
}

pub fn make_key_for_data_map_entry(
Expand Down Expand Up @@ -2042,8 +2047,9 @@ impl ClarityDatabase<'_> {
) -> Result<FungibleTokenMetadata, VmExecutionError> {
let key = ClarityDatabase::make_metadata_key(StoreType::FungibleTokenMeta, token_name);

map_no_contract_as_none(self.fetch_metadata(contract_identifier, &key))?
.ok_or(RuntimeCheckErrorKind::NoSuchFT(token_name.to_string()).into())
map_no_contract_as_none(self.fetch_metadata(contract_identifier, &key))?.ok_or(
RuntimeCheckErrorKind::ExpectsAcceptable(format!("No such FT: {token_name}")).into(),
)
}

pub fn create_non_fungible_token(
Expand All @@ -2068,8 +2074,9 @@ impl ClarityDatabase<'_> {
) -> Result<NonFungibleTokenMetadata, VmExecutionError> {
let key = ClarityDatabase::make_metadata_key(StoreType::NonFungibleTokenMeta, token_name);

map_no_contract_as_none(self.fetch_metadata(contract_identifier, &key))?
.ok_or(RuntimeCheckErrorKind::NoSuchNFT(token_name.to_string()).into())
map_no_contract_as_none(self.fetch_metadata(contract_identifier, &key))?.ok_or(
RuntimeCheckErrorKind::ExpectsAcceptable(format!("No such NFT: {token_name}")).into(),
)
}

pub fn checked_increase_token_supply(
Expand Down
16 changes: 8 additions & 8 deletions clarity/src/vm/functions/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,10 +601,10 @@ pub fn native_bitwise_left_shift(input: Value, pos: Value) -> Result<Value, VmEx
let result = input.wrapping_shl(shamt);
Ok(Value::UInt(result))
}
_ => Err(RuntimeCheckErrorKind::UnionTypeError(
vec![TypeSignature::IntType, TypeSignature::UIntType],
Box::new(TypeSignature::type_of(&input)?),
)
_ => Err(RuntimeCheckErrorKind::ExpectsAcceptable(format!(
"Union type error {}",
TypeSignature::type_of(&input)?
))
.into()),
}
} else {
Expand All @@ -630,10 +630,10 @@ pub fn native_bitwise_right_shift(input: Value, pos: Value) -> Result<Value, VmE
let result = input.wrapping_shr(shamt);
Ok(Value::UInt(result))
}
_ => Err(RuntimeCheckErrorKind::UnionTypeError(
vec![TypeSignature::IntType, TypeSignature::UIntType],
Box::new(TypeSignature::type_of(&input)?),
)
_ => Err(RuntimeCheckErrorKind::ExpectsAcceptable(format!(
"Union type error {}",
TypeSignature::type_of(&input)?
))
.into()),
}
} else {
Expand Down
Loading
Loading