@@ -16,16 +16,43 @@ use std::fmt;
1616
1717use crate :: execution_cost:: ExecutionCost ;
1818
19+ /// Errors related to cost tracking and resource accounting in the Clarity VM.
20+ ///
21+ /// Each error variant is annotated with "Invalidates Block" status, indicating
22+ /// whether the inclusion of the transaction that caused the error should cause
23+ /// an entire block to be rejected.
1924#[ derive( Debug , PartialEq , Eq ) ]
2025pub enum CostErrors {
21- CostComputationFailed ( String ) ,
26+ /// Arithmetic overflow in cost computation during type-checking, exceeding the maximum threshold.
27+ /// Invalidates Block: true.
2228 CostOverflow ,
29+ /// Cumulative type-checking cost exceeds the allocated budget, indicating budget depletion.
30+ /// The first `ExecutionCost` represents the total consumed cost, and the second represents the budget limit.
31+ /// Invalidates Block: true.
2332 CostBalanceExceeded ( ExecutionCost , ExecutionCost ) ,
33+ /// Memory usage during type-checking exceeds the allocated budget.
34+ /// The first `u64` represents the total consumed memory, and the second represents the memory limit.
35+ /// Invalidates Block:
36+ /// - true if happens during contract analysis
37+ /// - false if happens during contract intitialization or contract call.
2438 MemoryBalanceExceeded ( u64 , u64 ) ,
39+ /// Failure to access or load cost-related contracts or their state during runtime operations.
40+ /// Invalidates Block: false.
2541 CostContractLoadFailure ,
42+ /// Failure in cost-tracking due to an unexpected condition or invalid state.
43+ /// The `String` wraps the specific reason for the failure.
44+ /// Invalidates Block: false.
45+ CostComputationFailed ( String ) ,
46+ // Time checker errors
47+ /// Type-checking time exceeds the allowed budget, halting analysis to ensure responsiveness.
48+ /// Invalidates Block: true.
49+ ExecutionTimeExpired ,
50+ /// Unexpected condition or failure, indicating a bug or invalid state.
51+ /// Invalidates Block: true.
2652 InterpreterFailure ,
53+ /// Unexpected condition or failure, indicating a bug or invalid state.
54+ /// Invalidates Block: true.
2755 Expect ( String ) ,
28- ExecutionTimeExpired ,
2956}
3057
3158impl fmt:: Display for CostErrors {
0 commit comments