-
Notifications
You must be signed in to change notification settings - Fork 295
/
canister_state_bits.proto
373 lines (331 loc) · 10 KB
/
canister_state_bits.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
syntax = "proto3";
package state.canister_state_bits.v1;
import "google/protobuf/wrappers.proto";
import "state/ingress/v1/ingress.proto";
import "state/queues/v1/queues.proto";
import "state/v1/metadata.proto";
import "types/v1/ic00_types.proto";
import "types/v1/types.proto";
message CallContext {
message Ingress {
types.v1.UserId user_id = 1;
bytes message_id = 2;
}
message CanisterUpdateOrQuery {
types.v1.CanisterId canister_id = 1;
uint64 callback_id = 2;
}
// System task is either a Heartbeat or a GlobalTimer.
message SystemTask {}
oneof call_origin {
Ingress ingress = 1;
CanisterUpdateOrQuery canister_update = 2;
types.v1.UserId query = 3;
CanisterUpdateOrQuery canister_query = 4;
SystemTask system_task = 7;
}
bool responded = 5;
state.queues.v1.Funds available_funds = 6;
bool deleted = 8;
uint64 time_nanos = 9;
uint64 instructions_executed = 10;
state.queues.v1.RequestMetadata metadata = 11;
}
message CallContextEntry {
uint64 call_context_id = 1;
CallContext call_context = 2;
}
message WasmClosure {
uint32 func_idx = 1;
uint32 env = 2;
}
message Callback {
uint64 call_context_id = 1;
WasmClosure on_reply = 2;
WasmClosure on_reject = 3;
WasmClosure on_cleanup = 4;
state.queues.v1.Cycles cycles_sent = 5;
types.v1.CanisterId originator = 6;
types.v1.CanisterId respondent = 7;
state.queues.v1.Cycles prepayment_for_response_execution = 8;
state.queues.v1.Cycles prepayment_for_response_transmission = 9;
}
message CallbackEntry {
uint64 callback_id = 1;
Callback callback = 2;
}
message CallContextManager {
uint64 next_call_context_id = 1;
uint64 next_callback_id = 2;
repeated CallContextEntry call_contexts = 3;
repeated CallbackEntry callbacks = 4;
}
message CyclesAccount {
// Cycle balance is stored as u128::to_bytes_le()
bytes cycles_balance = 1;
reserved 2;
reserved "max_exec_cycles";
}
message Global {
oneof global {
int32 i32 = 1;
int64 i64 = 2;
float f32 = 3;
double f64 = 4;
}
}
message WasmMethod {
enum SystemMethod {
SYSTEM_METHOD_UNSPECIFIED = 0;
SYSTEM_METHOD_CANISTER_START = 1;
SYSTEM_METHOD_CANISTER_INIT = 2;
SYSTEM_METHOD_CANISTER_PRE_UPGRADE = 3;
SYSTEM_METHOD_CANISTER_POST_UPGRADE = 4;
SYSTEM_METHOD_CANISTER_INSPECT_MESSAGE = 5;
SYSTEM_METHOD_CANISTER_HEARTBEAT = 6;
SYSTEM_METHOD_EMPTY = 7;
SYSTEM_METHOD_CANISTER_GLOBAL_TIMER = 8;
}
oneof wasm_method {
string update = 1;
string query = 2;
SystemMethod system = 3;
string composite_query = 4;
}
}
enum CustomSectionType {
CUSTOM_SECTION_TYPE_UNSPECIFIED = 0;
CUSTOM_SECTION_TYPE_PUBLIC = 1;
CUSTOM_SECTION_TYPE_PRIVATE = 2;
}
message WasmCustomSection {
CustomSectionType visibility = 1;
bytes content = 2;
optional bytes hash = 3;
}
message WasmMetadata {
map<string, WasmCustomSection> custom_sections = 1;
}
enum NextScheduledMethod {
NEXT_SCHEDULED_METHOD_UNSPECIFIED = 0;
NEXT_SCHEDULED_METHOD_GLOBAL_TIMER = 1;
NEXT_SCHEDULED_METHOD_HEARTBEAT = 2;
NEXT_SCHEDULED_METHOD_MESSAGE = 3;
}
message ExecutionStateBits {
repeated Global exported_globals = 1;
uint32 heap_size = 2;
repeated WasmMethod exports = 3;
uint64 last_executed_round = 4;
WasmMetadata metadata = 5;
optional bytes binary_hash = 6;
optional NextScheduledMethod next_scheduled_method = 7;
}
message StopCanisterContext {
message Ingress {
types.v1.UserId sender = 1;
bytes message_id = 2;
optional uint64 call_id = 5;
}
message Canister {
types.v1.CanisterId sender = 1;
uint64 reply_callback = 2;
state.queues.v1.Funds funds = 3;
state.queues.v1.Cycles cycles = 4;
optional uint64 call_id = 5;
}
oneof context {
Ingress ingress = 1;
Canister canister = 2;
}
}
message CanisterStatusRunning {
CallContextManager call_context_manager = 1;
}
message CanisterStatusStopping {
CallContextManager call_context_manager = 1;
repeated StopCanisterContext stop_contexts = 2;
}
message CanisterStatusStopped {}
message ExecutionTask {
enum CanisterTask {
CANISTER_TASK_UNSPECIFIED = 0;
CANISTER_TASK_HEARTBEAT = 1;
CANISTER_TASK_TIMER = 2;
}
message AbortedExecution {
oneof input {
state.queues.v1.Request request = 1;
state.queues.v1.Response response = 2;
ingress.v1.Ingress ingress = 3;
CanisterTask task = 5;
}
// The execution cost that has already been charged from the canister.
// Retried execution does not have to pay for it again.
state.queues.v1.Cycles prepaid_execution_cycles = 4;
}
message AbortedInstallCode {
oneof message {
state.queues.v1.Request request = 1;
ingress.v1.Ingress ingress = 2;
}
// The execution cost that has already been charged from the canister.
// Retried execution does not have to pay for it again.
state.queues.v1.Cycles prepaid_execution_cycles = 3;
reserved "request_id";
optional uint64 call_id = 4;
}
oneof task {
AbortedExecution aborted_execution = 1;
AbortedInstallCode aborted_install_code = 2;
}
}
enum CyclesUseCase {
CYCLES_USE_CASE_UNSPECIFIED = 0;
CYCLES_USE_CASE_MEMORY = 1;
CYCLES_USE_CASE_COMPUTE_ALLOCATION = 2;
CYCLES_USE_CASE_INGRESS_INDUCTION = 3;
CYCLES_USE_CASE_INSTRUCTIONS = 4;
CYCLES_USE_CASE_REQUEST_AND_RESPONSE_TRANSMISSION = 5;
CYCLES_USE_CASE_UNINSTALL = 6;
CYCLES_USE_CASE_CANISTER_CREATION = 7;
CYCLES_USE_CASE_ECDSA_OUTCALLS = 8;
CYCLES_USE_CASE_HTTP_OUTCALLS = 9;
CYCLES_USE_CASE_DELETED_CANISTERS = 10;
CYCLES_USE_CASE_NON_CONSUMED = 11;
CYCLES_USE_CASE_BURNED_CYCLES = 12;
}
message ConsumedCyclesByUseCase {
CyclesUseCase use_case = 1;
types.v1.NominalCycles cycles = 2;
}
message CanisterChangeFromUser {
types.v1.PrincipalId user_id = 1;
}
message CanisterChangeFromCanister {
types.v1.PrincipalId canister_id = 1;
optional uint64 canister_version = 2;
}
message CanisterCreation {
repeated types.v1.PrincipalId controllers = 1;
}
message CanisterCodeUninstall {}
message CanisterCodeDeployment {
types.v1.CanisterInstallMode mode = 1;
bytes module_hash = 2;
}
message CanisterControllersChange {
repeated types.v1.PrincipalId controllers = 1;
}
message CanisterChange {
uint64 timestamp_nanos = 1;
uint64 canister_version = 2;
oneof change_origin {
CanisterChangeFromUser canister_change_from_user = 3;
CanisterChangeFromCanister canister_change_from_canister = 4;
}
oneof change_details {
CanisterCreation canister_creation = 5;
CanisterCodeUninstall canister_code_uninstall = 6;
CanisterCodeDeployment canister_code_deployment = 7;
CanisterControllersChange canister_controllers_change = 8;
}
}
message CanisterHistory {
repeated CanisterChange changes = 1;
uint64 total_num_changes = 2;
}
message Unsigned128 {
bytes raw = 1;
}
message TotalQueryStats {
Unsigned128 num_calls = 1;
Unsigned128 num_instructions = 2;
Unsigned128 ingress_payload_size = 3;
Unsigned128 egress_payload_size = 4;
}
message WasmChunkData {
bytes hash = 1;
uint64 index = 2;
uint64 length = 3;
}
message WasmChunkStoreMetadata {
repeated WasmChunkData chunks = 1;
uint64 size = 2;
}
enum LogVisibility {
LOG_VISIBILITY_UNSPECIFIED = 0;
LOG_VISIBILITY_CONTROLLERS = 1;
LOG_VISIBILITY_PUBLIC = 2;
}
message CanisterStateBits {
reserved 1;
reserved "controller";
uint64 last_full_execution_round = 2;
CallContextManager call_context_manager = 3;
uint64 compute_allocation = 4;
int64 accumulated_priority = 5;
reserved 6;
reserved "query_allocation";
ExecutionStateBits execution_state_bits = 7;
uint64 memory_allocation = 8;
reserved 9;
reserved "cycles_account";
reserved 10;
reserved "icp_balance";
oneof canister_status {
CanisterStatusRunning running = 11;
CanisterStatusStopping stopping = 12;
CanisterStatusStopped stopped = 13;
}
reserved 14;
reserved "scheduled_to_run";
uint64 scheduled_as_first = 15;
reserved 16;
reserved "skipped_round_due_to_low_cycles";
uint64 skipped_round_due_to_no_messages = 17;
// In how many rounds a canister is executed.
uint64 executed = 18;
reserved 19;
reserved "executed_and_exhausted_its_messages";
bytes certified_data = 20;
uint64 interrupted_during_execution = 21;
types.v1.NominalCycles consumed_cycles_since_replica_started = 22;
uint64 freeze_threshold = 23;
reserved 24;
reserved "stable_memory_size";
repeated types.v1.PrincipalId controllers = 25;
state.queues.v1.Cycles cycles_balance = 26;
// The size of the canister's stable memory in bytes.
uint64 stable_memory_size64 = 27;
// The memory delta debit of this canister. This is tracked for the purposes
// of rate limiting the amount of memory delta generated per round.
uint64 heap_delta_debit = 28;
// The instruction debit for install_code messages of this canister. This is
// tracked for the purposes of rate limiting the install_code messages.
uint64 install_code_debit = 29;
// Contains tasks that need to be executed before processing any input of the
// canister.
repeated ExecutionTask task_queue = 30;
// Time of last charge for resource allocations.
google.protobuf.UInt64Value time_of_last_allocation_charge_nanos = 31;
// Postponed charges that are not applied to `cycles_balance` yet.
state.queues.v1.Cycles cycles_debit = 32;
// Canister global timer, in nanoseconds since Unix epoch.
optional uint64 global_timer_nanos = 33;
// Canister version.
uint64 canister_version = 34;
reserved 35;
repeated ConsumedCyclesByUseCase consumed_cycles_since_replica_started_by_use_cases = 36;
CanisterHistory canister_history = 37;
// Resource reservation cycles.
state.queues.v1.Cycles reserved_balance = 38;
// The user-specified upper limit on `reserved_balance`.
state.queues.v1.Cycles reserved_balance_limit = 39;
// Maps tracking chunks in the Wasm chunk store.
WasmChunkStoreMetadata wasm_chunk_store_metadata = 40;
// Statistics on query execution for entire lifetime of canister.
TotalQueryStats total_query_stats = 41;
// Log visibility for the canister.
LogVisibility log_visibility = 42;
}