@@ -259,16 +259,16 @@ pub fn deployment_cost_v2<N: Network>(
259259 ) ;
260260 }
261261
262- // Bound each query function's worst-case compute. Queries are off-consensus and have no
262+ // Bound each view function's worst-case compute. Views are off-consensus and have no
263263 // dedicated fee component beyond what is already counted in `storage_cost` (their bytes
264264 // contribute to `size_in_bytes`). The bound below is purely a deploy-time sanity check
265- // to keep pathological queries from being accepted.
266- for query in deployment. program ( ) . queries ( ) . values ( ) {
267- let query_cost = query_cost_for_single_query ( & stack, query . name ( ) , ConsensusFeeVersion :: V3 ) ?;
265+ // to keep pathological views from being accepted.
266+ for view in deployment. program ( ) . views ( ) . values ( ) {
267+ let view_cost = view_cost_for_single_view ( & stack, view . name ( ) , ConsensusFeeVersion :: V3 ) ?;
268268 ensure ! (
269- query_cost <= N :: TRANSACTION_SPEND_LIMIT [ 1 ] . 1 ,
270- "Query '{}' has a cost '{query_cost }' which exceeds the transaction spend limit '{}'" ,
271- query . name( ) ,
269+ view_cost <= N :: TRANSACTION_SPEND_LIMIT [ 1 ] . 1 ,
270+ "View '{}' has a cost '{view_cost }' which exceeds the transaction spend limit '{}'" ,
271+ view . name( ) ,
272272 N :: TRANSACTION_SPEND_LIMIT [ 1 ] . 1
273273 ) ;
274274 }
@@ -1014,28 +1014,28 @@ fn finalize_cost_for_single_function_raw<N: Network>(
10141014 Ok ( finalize_cost)
10151015}
10161016
1017- /// Returns the maximum compute cost (in microcredits) of a single query function's body.
1017+ /// Returns the maximum compute cost (in microcredits) of a single view function's body.
10181018///
1019- /// Queries do not run as part of consensus, so this cost is not paid by anyone — it is only
1019+ /// Views do not run as part of consensus, so this cost is not paid by anyone — it is only
10201020/// used as a deploy-time sanity bound (mirrors the per-function `TRANSACTION_SPEND_LIMIT`
1021- /// check) to prevent deploying queries whose worst-case compute is unreasonable.
1022- fn query_cost_for_single_query < N : Network > (
1021+ /// check) to prevent deploying views whose worst-case compute is unreasonable.
1022+ fn view_cost_for_single_view < N : Network > (
10231023 stack : & Stack < N > ,
1024- query_name : & Identifier < N > ,
1024+ view_name : & Identifier < N > ,
10251025 consensus_fee_version : ConsensusFeeVersion ,
10261026) -> Result < u64 > {
1027- let query = stack. program ( ) . get_query_ref ( query_name ) ?;
1027+ let view = stack. program ( ) . get_view_ref ( view_name ) ?;
10281028
1029- // Query types are not cached on the stack today; recompute them here for the cost walk.
1030- let query_types = FinalizeTypes :: from_query ( stack, query ) ?;
1029+ // View types are not cached on the stack today; recompute them here for the cost walk.
1030+ let view_types = FinalizeTypes :: from_view ( stack, view ) ?;
10311031
1032- let mut query_cost = 0u64 ;
1033- for command in query . commands ( ) {
1034- query_cost = query_cost
1035- . checked_add ( cost_per_command ( stack, & query_types , command, consensus_fee_version) ?)
1036- . ok_or ( anyhow ! ( "Query cost overflowed" ) ) ?;
1032+ let mut view_cost = 0u64 ;
1033+ for command in view . commands ( ) {
1034+ view_cost = view_cost
1035+ . checked_add ( cost_per_command ( stack, & view_types , command, consensus_fee_version) ?)
1036+ . ok_or ( anyhow ! ( "View cost overflowed" ) ) ?;
10371037 }
1038- Ok ( query_cost )
1038+ Ok ( view_cost )
10391039}
10401040
10411041/// Returns the total finalize cost for an execution by iterating over all concrete transitions.
0 commit comments