@@ -38,7 +38,7 @@ use crate::vm::types::Value::UInt;
38
38
use crate :: vm:: types:: {
39
39
FunctionType , PrincipalData , QualifiedContractIdentifier , TupleData , TypeSignature ,
40
40
} ;
41
- use crate :: vm:: { eval_all , ClarityName , SymbolicExpression , Value } ;
41
+ use crate :: vm:: { CallStack , ClarityName , Environment , LocalContext , SymbolicExpression , Value } ;
42
42
43
43
pub mod constants;
44
44
pub mod cost_functions;
@@ -1054,7 +1054,7 @@ pub fn parse_cost(
1054
1054
// TODO: add tests from mutation testing results #4832
1055
1055
#[ cfg_attr( test, mutants:: skip) ]
1056
1056
fn compute_cost (
1057
- cost_tracker : & mut TrackerData ,
1057
+ cost_tracker : & TrackerData ,
1058
1058
cost_function_reference : ClarityCostFunctionReference ,
1059
1059
input_sizes : & [ u64 ] ,
1060
1060
eval_in_epoch : StacksEpochId ,
@@ -1073,7 +1073,7 @@ fn compute_cost(
1073
1073
1074
1074
let cost_contract = cost_tracker
1075
1075
. cost_contracts
1076
- . get_mut ( & cost_function_reference. contract_id )
1076
+ . get ( & cost_function_reference. contract_id )
1077
1077
. ok_or ( CostErrors :: CostComputationFailed ( format ! (
1078
1078
"CostFunction not found: {cost_function_reference}"
1079
1079
) ) ) ?;
@@ -1088,14 +1088,23 @@ fn compute_cost(
1088
1088
) ) ) ;
1089
1089
}
1090
1090
1091
- let function_invocation = [ SymbolicExpression :: list ( program) ] ;
1091
+ let function_invocation = SymbolicExpression :: list ( program) ;
1092
+ let eval_result = global_context. execute ( |global_context| {
1093
+ let context = LocalContext :: new ( ) ;
1094
+ let mut call_stack = CallStack :: new ( ) ;
1095
+ let publisher: PrincipalData = cost_contract. contract_identifier . issuer . clone ( ) . into ( ) ;
1096
+ let mut env = Environment :: new (
1097
+ global_context,
1098
+ cost_contract,
1099
+ & mut call_stack,
1100
+ Some ( publisher. clone ( ) ) ,
1101
+ Some ( publisher. clone ( ) ) ,
1102
+ None ,
1103
+ ) ;
1092
1104
1093
- let eval_result = eval_all (
1094
- & function_invocation,
1095
- cost_contract,
1096
- & mut global_context,
1097
- None ,
1098
- ) ;
1105
+ let result = super :: eval ( & function_invocation, & mut env, & context) ?;
1106
+ Ok ( Some ( result) )
1107
+ } ) ;
1099
1108
1100
1109
parse_cost ( & cost_function_reference. to_string ( ) , eval_result)
1101
1110
}
0 commit comments