@jsm-mit/tigi-sharded-package 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +128 -2
- package/declarations/coordinator/coordinator.did +661 -0
- package/declarations/coordinator/coordinator.did.d.ts +1016 -0
- package/declarations/coordinator/coordinator.did.js +430 -0
- package/declarations/core/core.did +486 -0
- package/declarations/core/core.did.d.ts +403 -0
- package/declarations/core/core.did.js +325 -0
- package/declarations/tigi-driver/tigi-driver.did +201 -0
- package/declarations/tigi-driver/tigi-driver.did.d.ts +165 -0
- package/declarations/tigi-driver/tigi-driver.did.js +117 -0
- package/declarations/tigi-simulator/tigi-simulator.did +300 -0
- package/declarations/tigi-simulator/tigi-simulator.did.d.ts +417 -0
- package/declarations/tigi-simulator/tigi-simulator.did.js +177 -0
- package/declarations/worker/worker.did +453 -0
- package/declarations/worker/worker.did.d.ts +399 -0
- package/declarations/worker/worker.did.js +348 -0
- package/dist/actors/profiles-actor.d.ts +41 -0
- package/dist/actors/profiles-actor.d.ts.map +1 -0
- package/dist/actors/profiles-actor.js +83 -0
- package/dist/actors/rides-actor.d.ts +227 -0
- package/dist/actors/rides-actor.d.ts.map +1 -0
- package/dist/actors/rides-actor.js +566 -0
- package/dist/actors/test-manager-actor.d.ts +37 -0
- package/dist/actors/test-manager-actor.d.ts.map +1 -0
- package/dist/actors/test-manager-actor.js +64 -0
- package/dist/chat.d.ts +51 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/chat.js +87 -0
- package/dist/geo.d.ts +18 -0
- package/dist/geo.d.ts.map +1 -0
- package/dist/geo.js +132 -0
- package/dist/group/canister-actor.d.ts +94 -0
- package/dist/group/canister-actor.d.ts.map +1 -0
- package/dist/group/canister-actor.js +182 -0
- package/dist/group/group.d.ts +63 -0
- package/dist/group/group.d.ts.map +1 -0
- package/dist/group/group.js +120 -0
- package/dist/group/prefixes.d.ts +14 -0
- package/dist/group/prefixes.d.ts.map +1 -0
- package/dist/group/prefixes.js +26 -0
- package/dist/group-entry.d.ts +3 -0
- package/dist/group-entry.d.ts.map +1 -0
- package/dist/group-entry.js +5 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/interfaces.d.ts +168 -0
- package/dist/interfaces.d.ts.map +1 -0
- package/dist/interfaces.js +5 -0
- package/dist/mappers.d.ts +70 -0
- package/dist/mappers.d.ts.map +1 -0
- package/dist/mappers.js +169 -0
- package/package.json +63 -5
|
@@ -0,0 +1,661 @@
|
|
|
1
|
+
// WHERE the accounts of a principal are (rule `sharding.md`, "A WHERE answer is a place"):
|
|
2
|
+
// a canister to ask, or a referral to another coordinator to ask the same question (after
|
|
3
|
+
// the core budded into a peer group). The client follows at most 2 referrals.
|
|
4
|
+
type AccountsPlace = variant {
|
|
5
|
+
// Ask this canister `isUser` (today: the core of the group).
|
|
6
|
+
canister : principal;
|
|
7
|
+
// Ask this coordinator `accountsCanisterFor` again.
|
|
8
|
+
coordinator : principal;
|
|
9
|
+
};
|
|
10
|
+
type AssignPrefixArgs = record { prefix : text; worker : principal };
|
|
11
|
+
type CanisterArgs = record { canister : principal };
|
|
12
|
+
// The chat group's admin methods this coordinator calls for its core (rule `sharding.md`,
|
|
13
|
+
// "Between two groups": the coordinator calls for its group). A fixed list: the core
|
|
14
|
+
// composes the arguments and keeps the logic, the coordinator only forwards. A new
|
|
15
|
+
// method of the chat group is a new case here, never a free method name.
|
|
16
|
+
type ChatAdminMethod = variant { updateRoom; createRoom; deleteRoom };
|
|
17
|
+
type CommitWasmArgs = record {
|
|
18
|
+
// Of the whole module. The coordinator refuses a module that does not match.
|
|
19
|
+
sha256 : blob;
|
|
20
|
+
chunks : nat32;
|
|
21
|
+
};
|
|
22
|
+
// Stored as ONE Candid record. A new field is `Option<…>` with `#[serde(default)]`, or the
|
|
23
|
+
// records stored before the change stop decoding. Never remove or retype a field.
|
|
24
|
+
type Config = record {
|
|
25
|
+
// The most workers the group may have (KO-7). None = `DEFAULT_MAX_WORKERS`.
|
|
26
|
+
maxWorkers : opt nat64;
|
|
27
|
+
// The core wasm, likewise.
|
|
28
|
+
coreWasm : opt WasmInfo;
|
|
29
|
+
// The version of the prefix map: one more at every change. A worker keeps the newest
|
|
30
|
+
// map it got (`setAreaMap`).
|
|
31
|
+
mapVersion : nat64;
|
|
32
|
+
// What the coordinator keeps for itself (`own_reserve_cycles`).
|
|
33
|
+
ownReserve : opt nat;
|
|
34
|
+
// The core the coordinator owns.
|
|
35
|
+
core : opt CoreRecord;
|
|
36
|
+
// Query instructions per minute (from query_stats) at which a worker is at level 1, 2,
|
|
37
|
+
// 3. The query load only ALARMS — a split for it is a superadmin's order (KO-8). None =
|
|
38
|
+
// `DEFAULT_QUERY_THRESHOLDS`.
|
|
39
|
+
queryThresholds : opt LevelThresholds;
|
|
40
|
+
// The core of the group (`core/`). A worker is installed with it.
|
|
41
|
+
home : opt principal;
|
|
42
|
+
mode : Mode;
|
|
43
|
+
// What every worker of the group is configured with: the superadmin sets it once, the
|
|
44
|
+
// coordinator gives it to the workers that exist and to every worker it creates.
|
|
45
|
+
// None = the workers keep the defaults they were built with.
|
|
46
|
+
workerConfig : opt WorkerConfigArgs;
|
|
47
|
+
// The worker wasm the superadmin uploaded, once committed.
|
|
48
|
+
wasm : opt WasmInfo;
|
|
49
|
+
// Somebody who asked for the superadmin role (LIVE; one request a day for the group).
|
|
50
|
+
roleRequest : opt RoleRequest;
|
|
51
|
+
// The UTC day of the last request: a second request the same day is refused in inspect.
|
|
52
|
+
lastRequestDay : nat64;
|
|
53
|
+
// What a new worker starts with, and what a worker or the core gets when it reports a
|
|
54
|
+
// low balance. A worker asks below half of it.
|
|
55
|
+
cyclesPerWorker : nat;
|
|
56
|
+
// false (STAGE, local): the coordinator never creates a worker or splits by itself,
|
|
57
|
+
// whatever the load; the levels are only shown (KO-7). true (prod): it does.
|
|
58
|
+
spread : bool;
|
|
59
|
+
nextEventId : nat64;
|
|
60
|
+
// The ONE superadmin of a LIVE group: a person, who hands the role over on a request.
|
|
61
|
+
superadmin : opt principal;
|
|
62
|
+
// The identities of the deploy and of the machines that run seeds and tests: every
|
|
63
|
+
// right while DEPLOYED and, outside prod, after the claim too; never the handover.
|
|
64
|
+
deployAdmins : vec principal;
|
|
65
|
+
lastCreatedAtNs : nat64;
|
|
66
|
+
// DEPLOYED until somebody claims the superadmin role in the front; LIVE after.
|
|
67
|
+
groupState : GroupState;
|
|
68
|
+
};
|
|
69
|
+
type CoordinatorError = variant {
|
|
70
|
+
// The coordinator cannot pay for what was asked.
|
|
71
|
+
NoCycles : text;
|
|
72
|
+
// Another canister (the management canister, a worker, the core) refused or did not
|
|
73
|
+
// answer.
|
|
74
|
+
RemoteCanisterError : text;
|
|
75
|
+
NotFound;
|
|
76
|
+
NotAuthorized : text;
|
|
77
|
+
InvalidData : text;
|
|
78
|
+
AlreadyExists;
|
|
79
|
+
};
|
|
80
|
+
// What the core says of itself right now, asked in a composite query — its admins and
|
|
81
|
+
// its wiring — or why it could not be asked.
|
|
82
|
+
type CoreLive = record {
|
|
83
|
+
wiring : opt CoreWiring;
|
|
84
|
+
error : opt text;
|
|
85
|
+
canister : principal;
|
|
86
|
+
admins : opt vec principal;
|
|
87
|
+
};
|
|
88
|
+
type CoreLoggingArgs = record { enabled : bool };
|
|
89
|
+
// The core of the group, as the coordinator owns it (KO-3, variant A): created by the
|
|
90
|
+
// coordinator, installed and upgraded by it, administered from its front. `home` in the
|
|
91
|
+
// config is this canister's id.
|
|
92
|
+
type CoreRecord = record {
|
|
93
|
+
moduleSha256 : opt blob;
|
|
94
|
+
createdAtNs : nat64;
|
|
95
|
+
// The last report of an outbox that cannot empty itself (`reportOutboxStuck`).
|
|
96
|
+
outboxStuck : opt OutboxStuck;
|
|
97
|
+
// What `refreshCore` read last: the balance and the hash of the module.
|
|
98
|
+
cyclesReported : opt nat;
|
|
99
|
+
canister : principal;
|
|
100
|
+
installedAtNs : nat64;
|
|
101
|
+
// The core asked for cycles and did not get them yet (`reportCoreLowCycles`).
|
|
102
|
+
lowCycles : opt bool;
|
|
103
|
+
// The core wasm is installed. False right after a creation that failed half-way,
|
|
104
|
+
// or for a core handed over at the install until it is installed again.
|
|
105
|
+
ready : bool;
|
|
106
|
+
};
|
|
107
|
+
// Mirror of the Tigi core's `AT.Wiring` (core/src/ActorTypes.mo).
|
|
108
|
+
type CoreWiring = record {
|
|
109
|
+
mode : Mode;
|
|
110
|
+
knownWorkers : vec principal;
|
|
111
|
+
coordinator : opt principal;
|
|
112
|
+
};
|
|
113
|
+
type DeleteWorkerArgs = record {
|
|
114
|
+
// Delete a worker WITH its open requests and rides, or with prefixes. Never in prod.
|
|
115
|
+
force : bool;
|
|
116
|
+
canister : principal;
|
|
117
|
+
};
|
|
118
|
+
// What `deleteWorker` did.
|
|
119
|
+
type DeletedWorker = record {
|
|
120
|
+
// What came back to the coordinator with the deletion.
|
|
121
|
+
cyclesReturned : nat;
|
|
122
|
+
canister : principal;
|
|
123
|
+
// Prefixes the map named it for, taken off the map (none without `force`).
|
|
124
|
+
prefixes : vec text;
|
|
125
|
+
};
|
|
126
|
+
// The dependents of the coordinator: what a reinstall must be handed.
|
|
127
|
+
type Dependents = record { core : opt principal; workers : vec principal };
|
|
128
|
+
// A drain: every prefix of `canister` goes to `target`.
|
|
129
|
+
type DrainWorkerArgs = record { target : principal; canister : principal };
|
|
130
|
+
type Event = record {
|
|
131
|
+
id : nat64;
|
|
132
|
+
atNs : nat64;
|
|
133
|
+
// "alarm" (a worker at level 3, a stuck outbox), "error" (a creation or a top-up that
|
|
134
|
+
// failed), "warn", "info".
|
|
135
|
+
kind : text;
|
|
136
|
+
"text" : text;
|
|
137
|
+
};
|
|
138
|
+
// The arguments of the method are the core's, Candid-encoded (`to_candid` in Motoko) —
|
|
139
|
+
// the coordinator does not read them and keeps no copy of the chat group's types.
|
|
140
|
+
type ForwardChatAdminArgs = record {
|
|
141
|
+
method : ChatAdminMethod;
|
|
142
|
+
// The one argument of the method, Candid-encoded.
|
|
143
|
+
args : blob;
|
|
144
|
+
// The chat group's COORDINATOR (the core's chat config) — the group's address. The
|
|
145
|
+
// coordinator asks it where the chat core is.
|
|
146
|
+
chatCoordinator : principal;
|
|
147
|
+
};
|
|
148
|
+
type GeohashesArgs = record { geohashes : vec text };
|
|
149
|
+
// DEPLOYED: fresh from the deploy, the deploy admins rule, no worker exists or is created.
|
|
150
|
+
// LIVE: a person claimed the superadmin role; the group works.
|
|
151
|
+
type GroupState = variant { deployed; live };
|
|
152
|
+
// A Candid-encodable representation of an HTTP request. This struct is used by
|
|
153
|
+
// the `http_request` method of the HTTP Gateway Protocol's Candid interface.
|
|
154
|
+
//
|
|
155
|
+
// # Examples
|
|
156
|
+
//
|
|
157
|
+
// ```
|
|
158
|
+
// use ic_http_certification::{HttpRequest, Method};
|
|
159
|
+
//
|
|
160
|
+
// let request = HttpRequest::builder()
|
|
161
|
+
// .with_method(Method::GET)
|
|
162
|
+
// .with_url("/")
|
|
163
|
+
// .with_headers(vec![("X-Custom-Foo".into(), "Bar".into())])
|
|
164
|
+
// .with_body(&[1, 2, 3])
|
|
165
|
+
// .with_certificate_version(2)
|
|
166
|
+
// .build();
|
|
167
|
+
//
|
|
168
|
+
// assert_eq!(request.method(), Method::GET);
|
|
169
|
+
// assert_eq!(request.url(), "/");
|
|
170
|
+
// assert_eq!(request.headers(), &[("X-Custom-Foo".into(), "Bar".into())]);
|
|
171
|
+
// assert_eq!(request.body(), &[1, 2, 3]);
|
|
172
|
+
// assert_eq!(request.certificate_version(), Some(2));
|
|
173
|
+
// ```
|
|
174
|
+
//
|
|
175
|
+
// # Helpers
|
|
176
|
+
//
|
|
177
|
+
// There are also a number of convenience methods for quickly creating an [HttpRequest] with
|
|
178
|
+
// commonly used HTTP methods:
|
|
179
|
+
//
|
|
180
|
+
// - [GET](HttpRequest::get)
|
|
181
|
+
// - [POST](HttpRequest::post)
|
|
182
|
+
// - [PUT](HttpRequest::put)
|
|
183
|
+
// - [PATCH](HttpRequest::patch)
|
|
184
|
+
// - [DELETE](HttpRequest::delete)
|
|
185
|
+
//
|
|
186
|
+
// ```
|
|
187
|
+
// use ic_http_certification::HttpRequest;
|
|
188
|
+
//
|
|
189
|
+
// let request = HttpRequest::get("/").build();
|
|
190
|
+
//
|
|
191
|
+
// assert_eq!(request.method(), "GET");
|
|
192
|
+
// assert_eq!(request.url(), "/");
|
|
193
|
+
// ```
|
|
194
|
+
type HttpRequest = record {
|
|
195
|
+
// HTTP request URL.
|
|
196
|
+
url : text;
|
|
197
|
+
// HTTP request method.
|
|
198
|
+
method : text;
|
|
199
|
+
// HTTP request body as an array of bytes.
|
|
200
|
+
body : blob;
|
|
201
|
+
// HTTP request headers.
|
|
202
|
+
headers : vec record { text; text };
|
|
203
|
+
// The max response verification version to use in the response's
|
|
204
|
+
// certificate.
|
|
205
|
+
certificate_version : opt nat16;
|
|
206
|
+
};
|
|
207
|
+
// A Candid-encodable representation of an HTTP response. This struct is used
|
|
208
|
+
// by the `http_request` method of the HTTP Gateway Protocol's Candid interface.
|
|
209
|
+
//
|
|
210
|
+
// # Examples
|
|
211
|
+
//
|
|
212
|
+
// ```
|
|
213
|
+
// use ic_http_certification::{HttpResponse, StatusCode};
|
|
214
|
+
//
|
|
215
|
+
// let response = HttpResponse::builder()
|
|
216
|
+
// .with_status_code(StatusCode::OK)
|
|
217
|
+
// .with_headers(vec![("Content-Type".into(), "text/plain".into())])
|
|
218
|
+
// .with_body(b"Hello, World!")
|
|
219
|
+
// .with_upgrade(false)
|
|
220
|
+
// .build();
|
|
221
|
+
//
|
|
222
|
+
// assert_eq!(response.status_code(), StatusCode::OK);
|
|
223
|
+
// assert_eq!(response.headers(), &[("Content-Type".into(), "text/plain".into())]);
|
|
224
|
+
// assert_eq!(response.body(), b"Hello, World!");
|
|
225
|
+
// assert_eq!(response.upgrade(), Some(false));
|
|
226
|
+
// ```
|
|
227
|
+
//
|
|
228
|
+
// # Helpers
|
|
229
|
+
//
|
|
230
|
+
// There are also a number of convenience methods for quickly creating an [HttpResponse] with
|
|
231
|
+
// commonly used HTTP status codes:
|
|
232
|
+
//
|
|
233
|
+
// - [OK](HttpResponse::ok)
|
|
234
|
+
// - [CREATED](HttpResponse::created)
|
|
235
|
+
// - [NO_CONTENT](HttpResponse::no_content)
|
|
236
|
+
// - [MOVED_PERMANENTLY](HttpResponse::moved_permanently)
|
|
237
|
+
// - [TEMPORARY_REDIRECT](HttpResponse::temporary_redirect)
|
|
238
|
+
// - [BAD_REQUEST](HttpResponse::bad_request)
|
|
239
|
+
// - [UNAUTHORIZED](HttpResponse::unauthorized)
|
|
240
|
+
// - [FORBIDDEN](HttpResponse::forbidden)
|
|
241
|
+
// - [NOT_FOUND](HttpResponse::not_found)
|
|
242
|
+
// - [METHOD_NOT_ALLOWED](HttpResponse::method_not_allowed)
|
|
243
|
+
// - [TOO_MANY_REQUESTS](HttpResponse::too_many_requests)
|
|
244
|
+
// - [INTERNAL_SERVER_ERROR](HttpResponse::internal_server_error)
|
|
245
|
+
//
|
|
246
|
+
// ```
|
|
247
|
+
// use ic_http_certification::{HttpResponse, StatusCode};
|
|
248
|
+
//
|
|
249
|
+
// let response = HttpResponse::ok(b"Hello, World!", vec![("Content-Type".into(), "text/plain".into())]).build();
|
|
250
|
+
//
|
|
251
|
+
// assert_eq!(response.status_code(), StatusCode::OK);
|
|
252
|
+
// assert_eq!(response.headers(), &[("Content-Type".into(), "text/plain".into())]);
|
|
253
|
+
// assert_eq!(response.body(), b"Hello, World!");
|
|
254
|
+
// ```
|
|
255
|
+
type HttpResponse = record {
|
|
256
|
+
// HTTP response body as an array of bytes.
|
|
257
|
+
body : blob;
|
|
258
|
+
// HTTP response headers.
|
|
259
|
+
headers : vec record { text; text };
|
|
260
|
+
// Whether the corresponding HTTP request should be upgraded to an update
|
|
261
|
+
// call.
|
|
262
|
+
upgrade : opt bool;
|
|
263
|
+
// HTTP response status code.
|
|
264
|
+
status_code : nat16;
|
|
265
|
+
};
|
|
266
|
+
// The arguments of the install: the mode of the group, the deploy admins and the
|
|
267
|
+
// dependents handed over. The deploy admins (the dfx identity that deploys, the
|
|
268
|
+
// identities of the machines that run seeds and tests) have every right while the group
|
|
269
|
+
// is DEPLOYED; after the claim they keep them outside prod and lose them in prod (KO-14).
|
|
270
|
+
// The arguments of an upgrade are ignored: the stable config stays.
|
|
271
|
+
type InitArgs = record {
|
|
272
|
+
// The dependents of the coordinator that was on this canister before — handed over
|
|
273
|
+
// at a reinstall, outside prod only (the install traps otherwise): the core and the
|
|
274
|
+
// workers it created. They are installed again (`resetGroup`) — the same ids, no
|
|
275
|
+
// create fee.
|
|
276
|
+
core : opt principal;
|
|
277
|
+
mode : Mode;
|
|
278
|
+
workers : vec principal;
|
|
279
|
+
deployAdmins : vec principal;
|
|
280
|
+
};
|
|
281
|
+
type InjectTestLoadArgs = record { load : TestLoadArgs; canister : principal };
|
|
282
|
+
type LevelThresholds = record { level1 : nat; level2 : nat; level3 : nat };
|
|
283
|
+
// What a worker measured in a minute that crossed a threshold (the worker's
|
|
284
|
+
// `T.LoadReport`). Motoko's `Nat` is Candid `nat`, which is `u128` here.
|
|
285
|
+
type LoadReport = record {
|
|
286
|
+
updateCalls : nat;
|
|
287
|
+
minute : nat;
|
|
288
|
+
instructions : nat;
|
|
289
|
+
level : nat;
|
|
290
|
+
maxMessagesPerRound : nat;
|
|
291
|
+
};
|
|
292
|
+
type LoadThresholds = record {
|
|
293
|
+
messagesPerRound : LevelThresholds;
|
|
294
|
+
instructionsPerMinute : LevelThresholds;
|
|
295
|
+
};
|
|
296
|
+
// Where the group runs. Given at the install of the coordinator and never changed; every
|
|
297
|
+
// canister it creates is installed with it (KO-13). What a test mode allows (test load
|
|
298
|
+
// injected into a worker) is never allowed on stage or in prod.
|
|
299
|
+
type Mode = variant {
|
|
300
|
+
// The local replica.
|
|
301
|
+
localTest;
|
|
302
|
+
prod;
|
|
303
|
+
// DEV and the test canisters on mainnet.
|
|
304
|
+
test;
|
|
305
|
+
stage;
|
|
306
|
+
};
|
|
307
|
+
// An outbox (of a worker or of the core) that has not emptied itself for a long time:
|
|
308
|
+
// its calls keep failing. Reported every hour while it lasts; it counts as stuck for
|
|
309
|
+
// `OUTBOX_STUCK_TTL_NS` after the last report, so a recovery needs no report of its own.
|
|
310
|
+
type OutboxStuck = record {
|
|
311
|
+
reportedAtNs : nat64;
|
|
312
|
+
// Entries waiting at the report.
|
|
313
|
+
pending : nat64;
|
|
314
|
+
// Since when the calls fail (the first failed flush).
|
|
315
|
+
sinceNs : nat64;
|
|
316
|
+
lastError : opt text;
|
|
317
|
+
};
|
|
318
|
+
// The load a worker counts in one geohash cell (the worker's `getPrefixCounts`): reports,
|
|
319
|
+
// requests and quotes of the last minutes (WO-13).
|
|
320
|
+
type PrefixCount = record { load : nat; prefix : text };
|
|
321
|
+
// One entry of the prefix map: a geohash that starts with `prefix` (and with no longer
|
|
322
|
+
// prefix of the map) is served by `worker`. The empty prefix is the rest of the world.
|
|
323
|
+
type PrefixEntry = record { prefix : text; worker : principal };
|
|
324
|
+
type PrincipalArgs = record { "principal" : principal };
|
|
325
|
+
// The query totals of a worker at one reading, and the rate since the reading before.
|
|
326
|
+
type QueryLoad = record {
|
|
327
|
+
atNs : nat64;
|
|
328
|
+
instructionsTotal : nat;
|
|
329
|
+
instructionsPerMinute : nat;
|
|
330
|
+
callsTotal : nat;
|
|
331
|
+
// Since the reading before; 0 at the first one.
|
|
332
|
+
callsPerMinute : nat;
|
|
333
|
+
};
|
|
334
|
+
type ReportFullArgs = record {
|
|
335
|
+
heapBytes : nat;
|
|
336
|
+
// false = the live data fell below the threshold again.
|
|
337
|
+
full : bool;
|
|
338
|
+
};
|
|
339
|
+
type ReportLowCyclesArgs = record { cycles : nat };
|
|
340
|
+
type ReportOutboxStuckArgs = record {
|
|
341
|
+
pending : nat64;
|
|
342
|
+
sinceNs : nat64;
|
|
343
|
+
lastError : opt text;
|
|
344
|
+
};
|
|
345
|
+
type Result = variant { Ok : vec principal; Err : CoordinatorError };
|
|
346
|
+
type Result_1 = variant { Ok : Roles; Err : CoordinatorError };
|
|
347
|
+
type Result_10 = variant { Ok : vec WorkerLive; Err : CoordinatorError };
|
|
348
|
+
type Result_11 = variant { Ok : bool; Err : CoordinatorError };
|
|
349
|
+
type Result_12 = variant { Ok : vec WorkerRecord; Err : CoordinatorError };
|
|
350
|
+
type Result_13 = variant { Ok : CoreRecord; Err : CoordinatorError };
|
|
351
|
+
type Result_14 = variant { Ok : WorkerStatus; Err : CoordinatorError };
|
|
352
|
+
type Result_15 = variant { Ok : Dependents; Err : CoordinatorError };
|
|
353
|
+
type Result_16 = variant { Ok : Config; Err : CoordinatorError };
|
|
354
|
+
type Result_17 = variant { Ok : SetWorkerConfigResult; Err : CoordinatorError };
|
|
355
|
+
type Result_18 = variant { Ok : WorkerView; Err : CoordinatorError };
|
|
356
|
+
type Result_19 = variant { Ok : SplitResult; Err : CoordinatorError };
|
|
357
|
+
type Result_2 = variant { Ok : vec PrefixEntry; Err : CoordinatorError };
|
|
358
|
+
type Result_20 = variant { Ok : nat; Err : CoordinatorError };
|
|
359
|
+
type Result_21 = variant { Ok : nat64; Err : CoordinatorError };
|
|
360
|
+
type Result_3 = variant { Ok : WasmInfo; Err : CoordinatorError };
|
|
361
|
+
type Result_4 = variant { Ok : principal; Err : CoordinatorError };
|
|
362
|
+
type Result_5 = variant { Ok : DeletedWorker; Err : CoordinatorError };
|
|
363
|
+
type Result_6 = variant { Ok : vec text; Err : CoordinatorError };
|
|
364
|
+
type Result_7 = variant { Ok : blob; Err : CoordinatorError };
|
|
365
|
+
type Result_8 = variant { Ok : CoreLive; Err : CoordinatorError };
|
|
366
|
+
type Result_9 = variant { Ok : Status; Err : CoordinatorError };
|
|
367
|
+
// Somebody asked for the superadmin role.
|
|
368
|
+
type RoleRequest = record { "principal" : principal; atNs : nat64 };
|
|
369
|
+
// Who rules the group — for the front.
|
|
370
|
+
type Roles = record {
|
|
371
|
+
// Whether the deploy admins still have their rights (DEPLOYED, or LIVE outside prod).
|
|
372
|
+
deployAdminsActive : bool;
|
|
373
|
+
roleRequest : opt RoleRequest;
|
|
374
|
+
// Whether a request may be made today (one a day for the group).
|
|
375
|
+
requestOpenToday : bool;
|
|
376
|
+
superadmin : opt principal;
|
|
377
|
+
deployAdmins : vec principal;
|
|
378
|
+
groupState : GroupState;
|
|
379
|
+
};
|
|
380
|
+
// What a superadmin may change. Only the fields given are changed.
|
|
381
|
+
type SetConfigArgs = record {
|
|
382
|
+
maxWorkers : opt nat64;
|
|
383
|
+
ownReserve : opt nat;
|
|
384
|
+
queryThresholds : opt LevelThresholds;
|
|
385
|
+
cyclesPerWorker : opt nat;
|
|
386
|
+
spread : opt bool;
|
|
387
|
+
};
|
|
388
|
+
type SetWorkerConfigResult = record {
|
|
389
|
+
// What is stored now: what every worker has, and what a new worker gets.
|
|
390
|
+
stored : WorkerConfigArgs;
|
|
391
|
+
workers : vec WorkerConfigOutcome;
|
|
392
|
+
};
|
|
393
|
+
type SetWorkerOpenArgs = record { open : bool; canister : principal };
|
|
394
|
+
type SplitResult = record { worker : principal; prefixes : vec text };
|
|
395
|
+
type Status = record {
|
|
396
|
+
// The core's outbox reported being stuck within `OUTBOX_STUCK_TTL_NS`.
|
|
397
|
+
coreOutboxStuckNow : bool;
|
|
398
|
+
cycles : nat;
|
|
399
|
+
// Newest first.
|
|
400
|
+
events : vec Event;
|
|
401
|
+
workers : vec WorkerView;
|
|
402
|
+
config : Config;
|
|
403
|
+
creationInFlight : bool;
|
|
404
|
+
// The whole prefix map.
|
|
405
|
+
prefixes : vec PrefixEntry;
|
|
406
|
+
};
|
|
407
|
+
// A load a test puts on a worker (test modes only; the worker's `T.TestLoadArgs`): the
|
|
408
|
+
// counters of these cells grow, and the worker reports `reportLevel` to the coordinator as
|
|
409
|
+
// a real minute would.
|
|
410
|
+
type TestLoadArgs = record { reportLevel : opt nat; cells : vec PrefixCount };
|
|
411
|
+
type WasmChunkArgs = record { bytes : blob; index : nat32 };
|
|
412
|
+
type WasmInfo = record {
|
|
413
|
+
uploadedAtNs : nat64;
|
|
414
|
+
sha256 : blob;
|
|
415
|
+
size : nat64;
|
|
416
|
+
chunks : nat32;
|
|
417
|
+
};
|
|
418
|
+
type WorkerConfig = record {
|
|
419
|
+
fullAtHeapBytes : nat;
|
|
420
|
+
load : LoadThresholds;
|
|
421
|
+
lowCyclesBelow : nat;
|
|
422
|
+
};
|
|
423
|
+
// What a superadmin sets for the workers of the group. Only the fields given are changed.
|
|
424
|
+
// The memory threshold and the cycles threshold are not a superadmin's: the coordinator
|
|
425
|
+
// computes them.
|
|
426
|
+
type WorkerConfigArgs = record {
|
|
427
|
+
load : opt LoadThresholds;
|
|
428
|
+
loggingEnabled : opt bool;
|
|
429
|
+
};
|
|
430
|
+
type WorkerConfigOutcome = record {
|
|
431
|
+
// None = the worker took the config.
|
|
432
|
+
error : opt text;
|
|
433
|
+
canister : principal;
|
|
434
|
+
};
|
|
435
|
+
// What a worker says of itself right now, asked in one composite query over the group —
|
|
436
|
+
// or why it could not be asked (no code, another subnet, unreachable).
|
|
437
|
+
type WorkerLive = record {
|
|
438
|
+
status : opt WorkerStatus;
|
|
439
|
+
error : opt text;
|
|
440
|
+
canister : principal;
|
|
441
|
+
};
|
|
442
|
+
type WorkerRecord = record {
|
|
443
|
+
// The queries the worker answered, read from `canister_status` (KO-8).
|
|
444
|
+
queryLoad : opt QueryLoad;
|
|
445
|
+
heapBytes : opt nat;
|
|
446
|
+
// The worker's live data is over its threshold: it keeps its prefixes, gets no new one.
|
|
447
|
+
full : bool;
|
|
448
|
+
createdAtNs : nat64;
|
|
449
|
+
// The last report of an outbox that cannot empty itself (`reportOutboxStuck`).
|
|
450
|
+
outboxStuck : opt OutboxStuck;
|
|
451
|
+
cyclesReported : opt nat;
|
|
452
|
+
// The level of the last report, and when it came. It counts for `LEVEL_TTL_NS`.
|
|
453
|
+
level : nat8;
|
|
454
|
+
levelAtNs : nat64;
|
|
455
|
+
canister : principal;
|
|
456
|
+
// The version of the prefix map the worker confirmed (`setAreaMap`). Behind
|
|
457
|
+
// `Config.map_version` = the worker gets the map again.
|
|
458
|
+
areaVersion : opt nat64;
|
|
459
|
+
// false = a superadmin closed the worker (`drainWorker`, `setWorkerOpen`): it serves
|
|
460
|
+
// the prefixes it holds and is the target of no split. Stored: an upgrade keeps the
|
|
461
|
+
// superadmin's will (KO-9).
|
|
462
|
+
acceptsNewPrefixes : bool;
|
|
463
|
+
// The level of the last query load reading. Shown and alarmed only — it splits nothing.
|
|
464
|
+
queryLevel : opt nat8;
|
|
465
|
+
// The worker asked for cycles and did not get them yet.
|
|
466
|
+
lowCycles : bool;
|
|
467
|
+
lastLoad : opt LoadReport;
|
|
468
|
+
lastReportAtNs : nat64;
|
|
469
|
+
// false = the canister exists but the code is not installed (a creation that failed
|
|
470
|
+
// half-way). Such a worker gets no prefix and is not named to anybody.
|
|
471
|
+
ready : bool;
|
|
472
|
+
};
|
|
473
|
+
// The worker's `T.WorkerStatus`.
|
|
474
|
+
type WorkerStatus = record {
|
|
475
|
+
heapBytes : nat;
|
|
476
|
+
lastMinute : opt LoadReport;
|
|
477
|
+
full : bool;
|
|
478
|
+
home : principal;
|
|
479
|
+
activeRides : nat;
|
|
480
|
+
mode : Mode;
|
|
481
|
+
cycles : nat;
|
|
482
|
+
// Driver canisters present (WO-4); they do not move — size zero (WO-14).
|
|
483
|
+
drivers : nat;
|
|
484
|
+
// The version of the prefix map the worker holds.
|
|
485
|
+
areaVersion : nat64;
|
|
486
|
+
config : WorkerConfig;
|
|
487
|
+
// Open rider requests and active rides: what a delete would lose.
|
|
488
|
+
openRequests : nat;
|
|
489
|
+
coordinator : principal;
|
|
490
|
+
};
|
|
491
|
+
// A worker as the superadmin front shows it: the record, and what counts NOW.
|
|
492
|
+
type WorkerView = record {
|
|
493
|
+
// Its outbox reported being stuck within `OUTBOX_STUCK_TTL_NS`.
|
|
494
|
+
outboxStuckNow : bool;
|
|
495
|
+
levelNow : nat8;
|
|
496
|
+
// The worker may take prefixes of a split.
|
|
497
|
+
open : bool;
|
|
498
|
+
// A split or a drain runs for it right now.
|
|
499
|
+
draining : bool;
|
|
500
|
+
// The prefixes of the map that name it.
|
|
501
|
+
prefixes : vec text;
|
|
502
|
+
"record" : WorkerRecord;
|
|
503
|
+
};
|
|
504
|
+
service : (InitArgs) -> {
|
|
505
|
+
// KO-16: WHERE the accounts of a principal are — a place: `canister` (ask it `isUser`) or
|
|
506
|
+
// `coordinator` (a referral: ask that coordinator again). Asked by the chat core for a
|
|
507
|
+
// customer of the project whose accounts field names this coordinator. Today `canister` =
|
|
508
|
+
// the core of the group for every principal (null = no core yet). Never the answer itself.
|
|
509
|
+
accountsCanisterFor : (principal) -> (opt AccountsPlace) query;
|
|
510
|
+
// An admin of the core, added by a superadmin through the coordinator.
|
|
511
|
+
addCoreAdmin : (PrincipalArgs) -> (Result);
|
|
512
|
+
// A deploy admin more — a machine that runs seeds or tests. Not in a live prod group.
|
|
513
|
+
addDeployAdmin : (PrincipalArgs) -> (Result_1);
|
|
514
|
+
// A prefix to a worker, by hand: new reports and requests of the area go there from now
|
|
515
|
+
// on.
|
|
516
|
+
assignPrefix : (AssignPrefixArgs) -> (Result_2);
|
|
517
|
+
// DEPLOYED → LIVE: the caller becomes THE superadmin. In prod the deploy admins lose
|
|
518
|
+
// their rights here, in the coordinator and in the core.
|
|
519
|
+
claimSuperadmin : () -> (Result_1);
|
|
520
|
+
commitCoreWasm : (CommitWasmArgs) -> (Result_3);
|
|
521
|
+
// The uploaded chunks become THE worker wasm — when they are all there and their hash is
|
|
522
|
+
// the one the uploader names.
|
|
523
|
+
commitWorkerWasm : (CommitWasmArgs) -> (Result_3);
|
|
524
|
+
// Creates the core of the group: a canister this coordinator alone controls, with the core
|
|
525
|
+
// wasm installed. Once per group.
|
|
526
|
+
createCore : () -> (Result_4);
|
|
527
|
+
// A worker by hand: the first one of a group, or one more. Neither `spread` nor the load
|
|
528
|
+
// of the others is asked; `maxWorkers` and the cycles are.
|
|
529
|
+
createWorker : () -> (Result_4);
|
|
530
|
+
// KO-9: deletes a worker: its cycles come back first, then it is stopped, deleted and
|
|
531
|
+
// taken off the list. A worker that holds prefixes, open requests or rides goes with
|
|
532
|
+
// `force` only, and never in prod (`logic::may_delete`).
|
|
533
|
+
deleteWorker : (DeleteWorkerArgs) -> (Result_5);
|
|
534
|
+
// The superadmin says no to the one who asked.
|
|
535
|
+
dismissRoleRequest : () -> (Result_1);
|
|
536
|
+
// KO-9: every prefix of the worker goes to `target`, and the worker is closed. The
|
|
537
|
+
// emptied worker stays until a superadmin deletes it or opens it again.
|
|
538
|
+
drainWorker : (DrainWorkerArgs) -> (Result_6);
|
|
539
|
+
// KO-16: the core only — one admin call on the chat group, made by this coordinator, the
|
|
540
|
+
// admin of the project there. The core composes the argument (`to_candid`) and reads the
|
|
541
|
+
// answer (`from_candid`); the coordinator checks the method against its fixed list, finds
|
|
542
|
+
// the chat core through the chat coordinator, and answers with the chat core's reply as it
|
|
543
|
+
// came (`Ok`), whatever it says. `Err` = the chat group could not be reached: a rejected
|
|
544
|
+
// call forgets the chat core, asks the chat coordinator again and tries once more.
|
|
545
|
+
forwardChatAdmin : (ForwardChatAdminArgs) -> (Result_7);
|
|
546
|
+
// What the core says of itself right now — one composite query for the front.
|
|
547
|
+
getCoreStatus : () -> (Result_8) composite_query;
|
|
548
|
+
// The core of the group.
|
|
549
|
+
getHomeCanister : () -> (opt principal) query;
|
|
550
|
+
// The whole prefix map: which worker serves which area.
|
|
551
|
+
getPrefixMap : () -> (vec PrefixEntry) query;
|
|
552
|
+
// Who rules — for everybody: the front shows a signed-in stranger whether to claim or to
|
|
553
|
+
// ask. The principal who asked is for the superadmin only.
|
|
554
|
+
getRoles : () -> (Roles) query;
|
|
555
|
+
// Everything the superadmin front shows.
|
|
556
|
+
getStatus : () -> (Result_9) query;
|
|
557
|
+
// What every worker says of itself right now — one composite query, the workers' own
|
|
558
|
+
// `getStatus` queries inside it. A worker that cannot be asked carries the reason instead.
|
|
559
|
+
getWorkersStatus : () -> (Result_10) composite_query;
|
|
560
|
+
// The superadmin hands the role over to the one who asked.
|
|
561
|
+
handOverSuperadmin : () -> (Result_1);
|
|
562
|
+
// Whether this coordinator still has dependents — the core it owns, or workers, code or
|
|
563
|
+
// not. A slot is reinstalled only when this answers false, or when the dependents are
|
|
564
|
+
// handed over (rule "hasDependents").
|
|
565
|
+
hasDependents : () -> (bool) query;
|
|
566
|
+
// The superadmin front, for everybody: the page and its files. It shows nothing by
|
|
567
|
+
// itself — what it shows it asks the methods above for, as the person who signed in.
|
|
568
|
+
http_request : (HttpRequest) -> (HttpResponse) query;
|
|
569
|
+
// A test mode only (`prod` and `stage` refuse, and so does the worker): a load put on
|
|
570
|
+
// ONE worker — its per-prefix counters grow, and it reports the level given to the
|
|
571
|
+
// coordinator as a real minute would. What a local script uses to force a split.
|
|
572
|
+
injectWorkerTestLoad : (InjectTestLoadArgs) -> (Result_11);
|
|
573
|
+
// Installs the core wasm on the core: a core without code, or — outside prod — a core
|
|
574
|
+
// that has code (handed over at the install, or a reset). A fresh state, the same canister.
|
|
575
|
+
installCore : () -> (Result_3);
|
|
576
|
+
// Installs the worker wasm on a canister of this group that has no code — a creation that
|
|
577
|
+
// failed after the canister was made. Outside prod a reinstall: the same canister, fresh
|
|
578
|
+
// state, no create fee.
|
|
579
|
+
installWorker : (CanisterArgs) -> (Result_4);
|
|
580
|
+
// "Is this canister one of your workers?" — the core asks once per unknown caller.
|
|
581
|
+
isWorker : (CanisterArgs) -> (bool) query;
|
|
582
|
+
// The dependents by name — for the handover.
|
|
583
|
+
listDependents : () -> (Dependents) query;
|
|
584
|
+
// Every worker that has its code — for reads over the whole network.
|
|
585
|
+
listWorkers : () -> (vec principal) query;
|
|
586
|
+
// The workers of many geohashes at once, in the order asked — a rider's request that
|
|
587
|
+
// reaches the areas of several workers (WO-12).
|
|
588
|
+
locateGeohashes : (GeohashesArgs) -> (vec opt principal) query;
|
|
589
|
+
// A superadmin reads the query load of every installed worker now.
|
|
590
|
+
readQueryLoads : () -> (Result_12);
|
|
591
|
+
// What the management canister says of the core: its balance and its module.
|
|
592
|
+
refreshCore : () -> (Result_13);
|
|
593
|
+
// What a worker says of itself now. The coordinator keeps the memory and the cycles.
|
|
594
|
+
refreshWorker : (CanisterArgs) -> (Result_14);
|
|
595
|
+
removeCoreAdmin : (PrincipalArgs) -> (Result);
|
|
596
|
+
removeDeployAdmin : (PrincipalArgs) -> (Result_1);
|
|
597
|
+
// KO-10, C-11: the core's balance is below `lowCyclesBelow`: it gets `cyclesPerWorker`,
|
|
598
|
+
// like a worker. One top-up in flight; a failed one is tried again at the next report.
|
|
599
|
+
reportCoreLowCycles : (ReportLowCyclesArgs) -> ();
|
|
600
|
+
// WO-15: the live data of the calling worker crossed its threshold (`full`), or fell below
|
|
601
|
+
// it again. A full worker keeps its prefixes, takes no new one, and half of them go to a
|
|
602
|
+
// fresh worker.
|
|
603
|
+
reportFull : (ReportFullArgs) -> ();
|
|
604
|
+
// KO-4, KO-5: a minute of the calling worker that crossed a threshold. The level counts
|
|
605
|
+
// for `LEVEL_TTL_NS`. Level 2: about half of its prefixes go to a low worker (a new one
|
|
606
|
+
// when there is none); level 3: an alarm and a split to a fresh worker. With `spread` off
|
|
607
|
+
// the levels are only shown (KO-7).
|
|
608
|
+
reportLoad : (LoadReport) -> ();
|
|
609
|
+
// KO-10: the balance of the calling worker is below its threshold. The coordinator tops it
|
|
610
|
+
// up when it can pay; when it cannot, the superadmin sees why. One top-up in flight.
|
|
611
|
+
reportLowCycles : (ReportLowCyclesArgs) -> ();
|
|
612
|
+
// A worker or the core: its outbox has not emptied itself for an hour. Stored on its
|
|
613
|
+
// record (the front shows it while `OUTBOX_STUCK_TTL_NS` lasts) and kept as an alarm.
|
|
614
|
+
reportOutboxStuck : (ReportOutboxStuckArgs) -> ();
|
|
615
|
+
// LIVE: a signed-in person who is not the superadmin asks for the role. One request a
|
|
616
|
+
// day for the whole group — the inspect refuses the rest of the day.
|
|
617
|
+
requestSuperadmin : () -> (Result_1);
|
|
618
|
+
// KO-15: a fresh group on the same canisters (outside prod): the core and every worker are
|
|
619
|
+
// installed again from scratch — the same ids, the same cycles, no create fee — and the
|
|
620
|
+
// map starts again: the first worker holds the world. One canister at a time; refused
|
|
621
|
+
// while a split, a drain or an upgrade runs.
|
|
622
|
+
resetGroup : () -> (Result_15);
|
|
623
|
+
// Changes what a superadmin may: `spread`, the cycles of a worker, the own reserve,
|
|
624
|
+
// `maxWorkers`, the query thresholds. Only the fields given are changed.
|
|
625
|
+
setConfig : (SetConfigArgs) -> (Result_16);
|
|
626
|
+
setCoreLoggingEnabled : (CoreLoggingArgs) -> (Result_11);
|
|
627
|
+
// The config of the workers of the group: the load thresholds, logging. Only the fields
|
|
628
|
+
// given are changed. The result is stored, given to every worker that has its code, and
|
|
629
|
+
// to every worker created later.
|
|
630
|
+
setWorkerConfig : (WorkerConfigArgs) -> (Result_17);
|
|
631
|
+
// Opens a worker to the prefixes of a split again, or closes it without giving anything
|
|
632
|
+
// away.
|
|
633
|
+
setWorkerOpen : (SetWorkerOpenArgs) -> (Result_18);
|
|
634
|
+
// A superadmin splits a worker now, whatever its load and `spread` (KO-17): a fresh worker
|
|
635
|
+
// takes about half of its prefixes. Answers with the new worker and the prefixes it got.
|
|
636
|
+
splitWorker : (CanisterArgs) -> (Result_19);
|
|
637
|
+
// A worker of the group sends its cycles here before it is deleted (`giveBackCycles`).
|
|
638
|
+
// The workers only: somebody else's cycles are refused (they go back to the sender).
|
|
639
|
+
takeCycles : () -> (nat);
|
|
640
|
+
// Cycles for the core, by hand: `cyclesPerWorker`, like a worker's top-up.
|
|
641
|
+
topUpCore : () -> (Result_20);
|
|
642
|
+
// Cycles for a worker, by hand.
|
|
643
|
+
topUpWorker : (CanisterArgs) -> (Result_20);
|
|
644
|
+
// KO-11: a new build of the core: stop → upgrade → start; its state stays (C-12).
|
|
645
|
+
upgradeCore : () -> (Result_3);
|
|
646
|
+
// KO-11: a new worker build on a worker that runs: stop → upgrade → start. Its state
|
|
647
|
+
// stays (a Motoko build with enhanced orthogonal persistence keeps its memory). Not while
|
|
648
|
+
// a split or a drain holds the worker.
|
|
649
|
+
upgradeWorker : (CanisterArgs) -> (Result_3);
|
|
650
|
+
// The core wasm, in chunks like the worker's.
|
|
651
|
+
uploadCoreWasmChunk : (WasmChunkArgs) -> (Result_21);
|
|
652
|
+
// One chunk of a NEW worker wasm. The first chunk (index 0) drops what was uploaded
|
|
653
|
+
// before; the module counts only after `commitWorkerWasm`.
|
|
654
|
+
uploadWorkerWasmChunk : (WasmChunkArgs) -> (Result_21);
|
|
655
|
+
// KO-1, KO-2: the worker of the area a geohash lies in — the longest prefix of the map
|
|
656
|
+
// wins. None = no installed worker serves the area (no worker yet, or its worker is being
|
|
657
|
+
// installed). Uncertified: the package checks the answer against `listWorkers`, and a
|
|
658
|
+
// worker refuses a geohash outside its area (`notMyArea`). The protocol's form: a bare
|
|
659
|
+
// geohash (`protocol/tigi-driver.did`).
|
|
660
|
+
workerFor : (text) -> (opt principal) query;
|
|
661
|
+
}
|