@@ -54,11 +54,11 @@ pub enum LogVisibility {
54
54
AllowedViewers ( Vec < PrincipalId > ) ,
55
55
}
56
56
57
- /// Partial copy-paste of ic-types::ic_00::DefiniteCanisterSettings.
57
+ /// Partial copy-paste of `ic_management_canister_types::DefiniteCanisterSettings`, and it's used
58
+ /// for the response type in the NNS/SNS Root `canister_status` method.
58
59
///
59
- /// Only the fields that we need are copied.
60
- /// Candid deserialization is supposed to be tolerant to having data for unknown
61
- /// fields (which is simply discarded).
60
+ /// Only the fields that we need are copied. Candid deserialization is supposed to be tolerant to
61
+ /// having data for unknown fields (which is simply discarded).
62
62
#[ derive( Clone , Eq , PartialEq , Debug , CandidType , Deserialize ) ]
63
63
pub struct DefiniteCanisterSettings {
64
64
pub controllers : Vec < PrincipalId > ,
@@ -71,11 +71,11 @@ pub struct DefiniteCanisterSettings {
71
71
pub wasm_memory_threshold : Option < candid:: Nat > ,
72
72
}
73
73
74
- /// Partial copy-paste of ic-types::ic_00::CanisterStatusResult.
74
+ /// Partial copy-paste of `ic_management_canister_types::CanisterStatusResultV2`, and it's used for
75
+ /// the response type in the NNS/SNS Root `canister_status` method.
75
76
///
76
- /// Only the fields that we need are copied.
77
- /// Candid deserialization is supposed to be tolerant to having data for unknown
78
- /// fields (which are simply discarded).
77
+ /// Only the fields that we need are copied. Candid deserialization is supposed to be tolerant to
78
+ /// having data for unknown fields (which is simply discarded).
79
79
#[ derive( Clone , Eq , PartialEq , Debug , CandidType , Deserialize ) ]
80
80
pub struct CanisterStatusResult {
81
81
pub status : CanisterStatusType ,
@@ -86,9 +86,24 @@ pub struct CanisterStatusResult {
86
86
pub cycles : candid:: Nat ,
87
87
pub idle_cycles_burned_per_day : Option < candid:: Nat > ,
88
88
pub reserved_cycles : Option < candid:: Nat > ,
89
+ pub query_stats : Option < QueryStats > ,
89
90
}
90
91
91
- /// Copy-paste of `ic_management_canister_types::CanisterStatusResultV2`.
92
+ /// Partial copy-paste of `ic_management_canister_types::QueryStats`, and it's used for the response
93
+ /// type in the NNS/SNS Root `canister_status` method.
94
+ ///
95
+ /// Only the fields that we need are copied. Candid deserialization is supposed to be tolerant to
96
+ /// having data for unknown fields (which is simply discarded).
97
+ #[ derive( Clone , Eq , PartialEq , Debug , CandidType , Deserialize ) ]
98
+ pub struct QueryStats {
99
+ pub num_calls_total : Option < candid:: Nat > ,
100
+ pub num_instructions_total : Option < candid:: Nat > ,
101
+ pub request_payload_bytes_total : Option < candid:: Nat > ,
102
+ pub response_payload_bytes_total : Option < candid:: Nat > ,
103
+ }
104
+
105
+ /// Copy-paste of `ic_management_canister_types::CanisterStatusResultV2`, and it's used for the
106
+ /// `canister_status`` method on the management canister.
92
107
#[ derive( Clone , Eq , PartialEq , Debug , Default , CandidType , Deserialize ) ]
93
108
pub struct CanisterStatusResultFromManagementCanister {
94
109
pub status : CanisterStatusType ,
@@ -98,13 +113,14 @@ pub struct CanisterStatusResultFromManagementCanister {
98
113
pub cycles : candid:: Nat ,
99
114
pub idle_cycles_burned_per_day : candid:: Nat ,
100
115
pub reserved_cycles : candid:: Nat ,
116
+ pub query_stats : QueryStatsFromManagementCanister ,
101
117
}
102
118
103
- /// Partial copy-paste of `ic_management_canister_types::DefiniteCanisterSettingsArgs`.
119
+ /// Partial copy-paste of `ic_management_canister_types::DefiniteCanisterSettingsArgs`, and it's
120
+ /// used for the response type in the management canister `canister_status` method.
104
121
///
105
- /// Only the fields that we need are copied.
106
- /// Candid deserialization is supposed to be tolerant to having data for unknown
107
- /// fields (which is simply discarded).
122
+ /// Only the fields that we need are copied. Candid deserialization is supposed to be tolerant to
123
+ /// having data for unknown fields (which is simply discarded).
108
124
#[ derive( Clone , Eq , PartialEq , Debug , Default , CandidType , Deserialize ) ]
109
125
pub struct DefiniteCanisterSettingsFromManagementCanister {
110
126
pub controllers : Vec < PrincipalId > ,
@@ -117,6 +133,16 @@ pub struct DefiniteCanisterSettingsFromManagementCanister {
117
133
pub wasm_memory_threshold : candid:: Nat ,
118
134
}
119
135
136
+ /// Partial copy-paste of `ic_management_canister_types::QueryStats`, and it's used for the response
137
+ /// type in the management canister `canister_status` method.
138
+ #[ derive( Clone , Eq , PartialEq , Debug , Default , CandidType , Deserialize ) ]
139
+ pub struct QueryStatsFromManagementCanister {
140
+ pub num_calls_total : candid:: Nat ,
141
+ pub num_instructions_total : candid:: Nat ,
142
+ pub request_payload_bytes_total : candid:: Nat ,
143
+ pub response_payload_bytes_total : candid:: Nat ,
144
+ }
145
+
120
146
impl From < CanisterStatusResultFromManagementCanister > for CanisterStatusResult {
121
147
fn from ( value : CanisterStatusResultFromManagementCanister ) -> Self {
122
148
let CanisterStatusResultFromManagementCanister {
@@ -127,9 +153,11 @@ impl From<CanisterStatusResultFromManagementCanister> for CanisterStatusResult {
127
153
cycles,
128
154
idle_cycles_burned_per_day,
129
155
reserved_cycles,
156
+ query_stats,
130
157
} = value;
131
158
132
159
let settings = DefiniteCanisterSettings :: from ( settings) ;
160
+ let query_stats = Some ( QueryStats :: from ( query_stats) ) ;
133
161
134
162
let idle_cycles_burned_per_day = Some ( idle_cycles_burned_per_day) ;
135
163
let reserved_cycles = Some ( reserved_cycles) ;
@@ -142,6 +170,7 @@ impl From<CanisterStatusResultFromManagementCanister> for CanisterStatusResult {
142
170
cycles,
143
171
idle_cycles_burned_per_day,
144
172
reserved_cycles,
173
+ query_stats,
145
174
}
146
175
}
147
176
}
@@ -180,6 +209,29 @@ impl From<DefiniteCanisterSettingsFromManagementCanister> for DefiniteCanisterSe
180
209
}
181
210
}
182
211
212
+ impl From < QueryStatsFromManagementCanister > for QueryStats {
213
+ fn from ( value : QueryStatsFromManagementCanister ) -> Self {
214
+ let QueryStatsFromManagementCanister {
215
+ num_calls_total,
216
+ num_instructions_total,
217
+ request_payload_bytes_total,
218
+ response_payload_bytes_total,
219
+ } = value;
220
+
221
+ let num_calls_total = Some ( num_calls_total) ;
222
+ let num_instructions_total = Some ( num_instructions_total) ;
223
+ let request_payload_bytes_total = Some ( request_payload_bytes_total) ;
224
+ let response_payload_bytes_total = Some ( response_payload_bytes_total) ;
225
+
226
+ QueryStats {
227
+ num_calls_total,
228
+ num_instructions_total,
229
+ request_payload_bytes_total,
230
+ response_payload_bytes_total,
231
+ }
232
+ }
233
+ }
234
+
183
235
impl CanisterStatusResultFromManagementCanister {
184
236
pub fn controllers ( & self ) -> & [ PrincipalId ] {
185
237
self . settings . controllers . as_slice ( )
@@ -202,6 +254,12 @@ impl CanisterStatusResultFromManagementCanister {
202
254
log_visibility : LogVisibility :: Controllers ,
203
255
wasm_memory_threshold : candid:: Nat :: from ( 49_u32 ) ,
204
256
} ,
257
+ query_stats : QueryStatsFromManagementCanister {
258
+ num_calls_total : candid:: Nat :: from ( 50_u32 ) ,
259
+ num_instructions_total : candid:: Nat :: from ( 51_u32 ) ,
260
+ request_payload_bytes_total : candid:: Nat :: from ( 52_u32 ) ,
261
+ response_payload_bytes_total : candid:: Nat :: from ( 53_u32 ) ,
262
+ } ,
205
263
cycles : candid:: Nat :: from ( 47_u32 ) ,
206
264
idle_cycles_burned_per_day : candid:: Nat :: from ( 48_u32 ) ,
207
265
reserved_cycles : candid:: Nat :: from ( 49_u32 ) ,
@@ -230,6 +288,7 @@ pub struct CanisterStatusResultV2 {
230
288
pub cycles : candid:: Nat ,
231
289
// this is for compat with Spec 0.12/0.13
232
290
pub idle_cycles_burned_per_day : candid:: Nat ,
291
+ pub query_stats : Option < QueryStats > ,
233
292
}
234
293
235
294
impl CanisterStatusResultV2 {
@@ -263,6 +322,12 @@ impl CanisterStatusResultV2 {
263
322
Some ( wasm_memory_threshold) ,
264
323
) ,
265
324
idle_cycles_burned_per_day : candid:: Nat :: from ( idle_cycles_burned_per_day) ,
325
+ query_stats : Some ( QueryStats {
326
+ num_calls_total : Some ( candid:: Nat :: from ( 0_u64 ) ) ,
327
+ num_instructions_total : Some ( candid:: Nat :: from ( 0_u64 ) ) ,
328
+ request_payload_bytes_total : Some ( candid:: Nat :: from ( 0_u64 ) ) ,
329
+ response_payload_bytes_total : Some ( candid:: Nat :: from ( 0_u64 ) ) ,
330
+ } ) ,
266
331
}
267
332
}
268
333
@@ -403,6 +468,12 @@ impl From<CanisterStatusResultFromManagementCanister> for CanisterStatusResultV2
403
468
memory_size : value. memory_size ,
404
469
cycles : value. cycles ,
405
470
idle_cycles_burned_per_day : value. idle_cycles_burned_per_day ,
471
+ query_stats : Some ( QueryStats {
472
+ num_calls_total : Some ( value. query_stats . num_calls_total ) ,
473
+ num_instructions_total : Some ( value. query_stats . num_instructions_total ) ,
474
+ request_payload_bytes_total : Some ( value. query_stats . request_payload_bytes_total ) ,
475
+ response_payload_bytes_total : Some ( value. query_stats . response_payload_bytes_total ) ,
476
+ } ) ,
406
477
}
407
478
}
408
479
}
@@ -438,6 +509,12 @@ mod tests {
438
509
cycles : candid:: Nat :: from ( 999_u32 ) ,
439
510
idle_cycles_burned_per_day : candid:: Nat :: from ( 998_u32 ) ,
440
511
reserved_cycles : candid:: Nat :: from ( 997_u32 ) ,
512
+ query_stats : QueryStatsFromManagementCanister {
513
+ num_calls_total : candid:: Nat :: from ( 93_u32 ) ,
514
+ num_instructions_total : candid:: Nat :: from ( 92_u32 ) ,
515
+ request_payload_bytes_total : candid:: Nat :: from ( 91_u32 ) ,
516
+ response_payload_bytes_total : candid:: Nat :: from ( 90_u32 ) ,
517
+ } ,
441
518
} ;
442
519
443
520
let expected_canister_status_result = CanisterStatusResult {
@@ -457,6 +534,12 @@ mod tests {
457
534
cycles : candid:: Nat :: from ( 999_u32 ) ,
458
535
idle_cycles_burned_per_day : Some ( candid:: Nat :: from ( 998_u32 ) ) ,
459
536
reserved_cycles : Some ( candid:: Nat :: from ( 997_u32 ) ) ,
537
+ query_stats : Some ( QueryStats {
538
+ num_calls_total : Some ( candid:: Nat :: from ( 93_u32 ) ) ,
539
+ num_instructions_total : Some ( candid:: Nat :: from ( 92_u32 ) ) ,
540
+ request_payload_bytes_total : Some ( candid:: Nat :: from ( 91_u32 ) ) ,
541
+ response_payload_bytes_total : Some ( candid:: Nat :: from ( 90_u32 ) ) ,
542
+ } ) ,
460
543
} ;
461
544
462
545
let actual_canister_status_result = CanisterStatusResult :: from ( m) ;
0 commit comments