@@ -406,7 +406,6 @@ pub fn initialize_contract(
406
406
} ) ?;
407
407
let mut store = Store :: new ( & engine, init_context) ;
408
408
let mut linker = Linker :: new ( & engine) ;
409
-
410
409
// Link in the host interface functions.
411
410
link_host_functions ( & mut linker) ?;
412
411
@@ -500,7 +499,6 @@ pub fn call_function<'a>(
500
499
501
500
// Link in the host interface functions.
502
501
link_host_functions ( & mut linker) ?;
503
-
504
502
let instance = linker
505
503
. instantiate ( & mut store, & module)
506
504
. map_err ( |e| Error :: Wasm ( WasmError :: UnableToLoadModule ( e) ) ) ?;
@@ -8900,6 +8898,7 @@ mod error_mapping {
8900
8898
read_bytes_from_wasm, read_from_wasm_indirect, read_identifier_from_wasm,
8901
8899
signature_from_string,
8902
8900
} ;
8901
+ use crate :: vm:: costs:: CostErrors ;
8903
8902
use crate :: vm:: errors:: { CheckErrors , Error , RuntimeErrorType , ShortReturnType , WasmError } ;
8904
8903
use crate :: vm:: types:: { OptionalData , ResponseData } ;
8905
8904
use crate :: vm:: { ClarityVersion , Value } ;
@@ -8974,6 +8973,21 @@ mod error_mapping {
8974
8973
/// Indicates an attempt to use a function with too many arguments
8975
8974
ArgumentCountAtMost = 15 ,
8976
8975
8976
+ /// Indicates a runtime cost overrun
8977
+ CostOverrunRuntime = 100 ,
8978
+
8979
+ /// Indicates a read count cost overrun
8980
+ CostOverrunReadCount = 101 ,
8981
+
8982
+ /// Indicates a read length cost overrun
8983
+ CostOverrunReadLength = 102 ,
8984
+
8985
+ /// Indicates a write count cost overrun
8986
+ CostOverrunWriteCount = 103 ,
8987
+
8988
+ /// Indicates a write length cost overrun
8989
+ CostOverrunWriteLength = 104 ,
8990
+
8977
8991
/// A catch-all for errors that are not mapped to specific error codes.
8978
8992
/// This might be used for unexpected or unclassified errors.
8979
8993
NotMapped = 99 ,
@@ -8999,6 +9013,11 @@ mod error_mapping {
8999
9013
13 => ErrorMap :: ArgumentCountMismatch ,
9000
9014
14 => ErrorMap :: ArgumentCountAtLeast ,
9001
9015
15 => ErrorMap :: ArgumentCountAtMost ,
9016
+ 100 => ErrorMap :: CostOverrunRuntime ,
9017
+ 101 => ErrorMap :: CostOverrunReadCount ,
9018
+ 102 => ErrorMap :: CostOverrunReadLength ,
9019
+ 103 => ErrorMap :: CostOverrunWriteCount ,
9020
+ 104 => ErrorMap :: CostOverrunWriteLength ,
9002
9021
_ => ErrorMap :: NotMapped ,
9003
9022
}
9004
9023
}
@@ -9179,6 +9198,11 @@ mod error_mapping {
9179
9198
let ( expected, got) = get_runtime_error_arg_lengths ( & instance, & mut store) ;
9180
9199
Error :: Unchecked ( CheckErrors :: RequiresAtMostArguments ( expected, got) )
9181
9200
}
9201
+ ErrorMap :: CostOverrunRuntime => Error :: from ( CostErrors :: CostOverflow ) ,
9202
+ ErrorMap :: CostOverrunReadCount => Error :: from ( CostErrors :: CostOverflow ) ,
9203
+ ErrorMap :: CostOverrunReadLength => Error :: from ( CostErrors :: CostOverflow ) ,
9204
+ ErrorMap :: CostOverrunWriteCount => Error :: from ( CostErrors :: CostOverflow ) ,
9205
+ ErrorMap :: CostOverrunWriteLength => Error :: from ( CostErrors :: CostOverflow ) ,
9182
9206
_ => panic ! ( "Runtime error code {} not supported" , runtime_error_code) ,
9183
9207
}
9184
9208
}
0 commit comments