Skip to content

Commit a022610

Browse files
committed
add missing cost tracking errors
1 parent 8e3f0f7 commit a022610

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

clarity/src/vm/clarity_wasm.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8900,6 +8900,7 @@ mod error_mapping {
89008900
read_bytes_from_wasm, read_from_wasm_indirect, read_identifier_from_wasm,
89018901
signature_from_string,
89028902
};
8903+
use crate::vm::costs::CostErrors;
89038904
use crate::vm::errors::{CheckErrors, Error, RuntimeErrorType, ShortReturnType, WasmError};
89048905
use crate::vm::types::{OptionalData, ResponseData};
89058906
use crate::vm::{ClarityVersion, Value};
@@ -8974,6 +8975,21 @@ mod error_mapping {
89748975
/// Indicates an attempt to use a function with too many arguments
89758976
ArgumentCountAtMost = 15,
89768977

8978+
/// Indicates a runtime cost overrun
8979+
CostOverrunRuntime = 100,
8980+
8981+
/// Indicates a read count cost overrun
8982+
CostOverrunReadCount = 101,
8983+
8984+
/// Indicates a read length cost overrun
8985+
CostOverrunReadLength = 102,
8986+
8987+
/// Indicates a write count cost overrun
8988+
CostOverrunWriteCount = 103,
8989+
8990+
/// Indicates a write length cost overrun
8991+
CostOverrunWriteLength = 104,
8992+
89778993
/// A catch-all for errors that are not mapped to specific error codes.
89788994
/// This might be used for unexpected or unclassified errors.
89798995
NotMapped = 99,
@@ -8999,6 +9015,11 @@ mod error_mapping {
89999015
13 => ErrorMap::ArgumentCountMismatch,
90009016
14 => ErrorMap::ArgumentCountAtLeast,
90019017
15 => ErrorMap::ArgumentCountAtMost,
9018+
100 => ErrorMap::CostOverrunRuntime,
9019+
101 => ErrorMap::CostOverrunReadCount,
9020+
102 => ErrorMap::CostOverrunReadLength,
9021+
103 => ErrorMap::CostOverrunWriteCount,
9022+
104 => ErrorMap::CostOverrunWriteLength,
90029023
_ => ErrorMap::NotMapped,
90039024
}
90049025
}
@@ -9179,6 +9200,11 @@ mod error_mapping {
91799200
let (expected, got) = get_runtime_error_arg_lengths(&instance, &mut store);
91809201
Error::Unchecked(CheckErrors::RequiresAtMostArguments(expected, got))
91819202
}
9203+
ErrorMap::CostOverrunRuntime => Error::from(CostErrors::CostOverflow),
9204+
ErrorMap::CostOverrunReadCount => Error::from(CostErrors::CostOverflow),
9205+
ErrorMap::CostOverrunReadLength => Error::from(CostErrors::CostOverflow),
9206+
ErrorMap::CostOverrunWriteCount => Error::from(CostErrors::CostOverflow),
9207+
ErrorMap::CostOverrunWriteLength => Error::from(CostErrors::CostOverflow),
91829208
_ => panic!("Runtime error code {} not supported", runtime_error_code),
91839209
}
91849210
}

stackslib/src/cli.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ fn replay_block(
827827
block_am.weight(),
828828
true,
829829
) {
830-
Ok((receipt, _, _)) => {
830+
Ok((_, _, _)) => {
831831
info!("Cost check skipped. Block processed successfully! block = {block_id}");
832832
}
833833
Err(e) => {
@@ -863,7 +863,10 @@ fn replay_naka_staging_block(db_path: &str, index_block_hash_hex: &str, conf: &C
863863
None,
864864
true,
865865
)
866-
.unwrap();
866+
.unwrap_or_else(|err| {
867+
eprintln!("Error: {:?}", err);
868+
panic!("SortitionDB::connect failed");
869+
});
867870

868871
let (block, block_size) = chainstate
869872
.nakamoto_blocks_db()

0 commit comments

Comments
 (0)