Skip to content

Commit 28a2a86

Browse files
authored
Merge branch 'develop' into chore/3.3.0.0.0_develop
2 parents 0a67d21 + aa20011 commit 28a2a86

File tree

29 files changed

+1125
-103
lines changed

29 files changed

+1125
-103
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to the versioning scheme outlined in the [README.md](README.md).
77

8+
## [Unreleased]
9+
10+
### Added
11+
- Fixed an issue where `event.committed` was always equal to `true` in the block replay RPC endpoint
12+
- Added `result_hex` and `post_condition_aborted` to the block replay RPC endpoint
13+
-
814
## [3.3.0.0.0]
915

1016
### Added

clarity-types/src/errors/cost.rs

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,43 @@ use std::fmt;
1616

1717
use 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)]
2025
pub 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

3158
impl fmt::Display for CostErrors {

clarity-types/src/errors/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ impl fmt::Display for Error {
134134
match self {
135135
Error::Runtime(err, stack) => {
136136
write!(f, "{err}")?;
137-
if let Some(stack_trace) = stack {
137+
if let Some(stack_trace) = stack
138+
&& !stack_trace.is_empty()
139+
{
138140
writeln!(f, "\n Stack Trace: ")?;
139141
for item in stack_trace.iter() {
140142
writeln!(f, "{item}")?;

clarity/src/vm/clarity.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,28 @@ impl From<CheckError> for Error {
8181
}
8282
}
8383

84+
/// Converts [`InterpreterError`] to [`Error`] for transaction execution contexts.
85+
///
86+
/// This conversion is used in:
87+
/// - [`TransactionConnection::initialize_smart_contract`]
88+
/// - [`TransactionConnection::run_contract_call`]
89+
/// - [`TransactionConnection::run_stx_transfer`]
90+
///
91+
/// # Notes
92+
///
93+
/// - [`CheckErrors::MemoryBalanceExceeded`] and [`CheckErrors::CostComputationFailed`]
94+
/// are intentionally not converted to [`Error::CostError`].
95+
/// Instead, they remain wrapped in `Error::Interpreter(Unchecked(CheckErrors::MemoryBalanceExceeded))`,
96+
/// which causes the transaction to fail, but still be included in the block.
97+
///
98+
/// - This behavior differs from direct conversions of [`CheckError`] and [`ParseError`] to [`Error`],
99+
/// where [`CheckErrors::MemoryBalanceExceeded`] is converted to [`Error::CostError`],
100+
/// during contract analysis.
101+
///
102+
/// As a result:
103+
/// - A `MemoryBalanceExceeded` during contract analysis causes the block to be rejected.
104+
/// - A `MemoryBalanceExceeded` during execution (initialization or contract call)
105+
/// causes the transaction to fail, but the block remains valid.
84106
impl From<InterpreterError> for Error {
85107
fn from(e: InterpreterError) -> Self {
86108
match &e {

docs/rpc/components/examples/block-replay.example.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@
9898
}
9999
}
100100
},
101+
"result_hex": "0x0703",
102+
"post_condition_aborted": false,
101103
"stx_burned": 0,
102104
"tx_index": 0,
103105
"txid": "f14dd7dec56405fd7dac69c3080fb569fae4c49c591f9ad0e5cf5c797add9005"

docs/rpc/components/schemas/block-replay.schema.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ properties:
3636
state_index_root:
3737
type: string
3838
pattern: "^[0-9a-f]{64}$"
39-
description: block state index root computed from the MARF (got from the original block)
39+
description: block state index root computed from the MARF (got from the original block)
4040
timestamp:
4141
type: integer
4242
tx_merkle_root:
@@ -67,6 +67,12 @@ properties:
6767
result:
6868
type: object
6969
description: Clarity value representing the transaction result
70+
result_hex:
71+
type: string
72+
description: The transaction's result, encoded as a Clarity hex string
73+
post_condition_aborted:
74+
type: boolean
75+
description: Whether the transaction was aborted by a post-condition
7076
stx_burned:
7177
type: integer
7278
description: number of burned stx

0 commit comments

Comments
 (0)