@jsm-mit/tigi-sharded-package 0.7.0 → 0.8.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.
@@ -114,6 +114,8 @@ export declare class RideRequest {
114
114
  private readonly heldViews;
115
115
  /** ZO-24: the last ride shown (status and position never go back). */
116
116
  private lastRide;
117
+ /** ZO-25: the next read of the request goes through consensus (after the rider's own action). */
118
+ private freshNext;
117
119
  private readonly rejected;
118
120
  private readonly notFree;
119
121
  private readonly refreshingUntilMs;
@@ -1 +1 @@
1
- {"version":3,"file":"rides-actor.d.ts","sourceRoot":"","sources":["../../src/actors/rides-actor.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAKpD,OAAO,EAAgJ,KAAK,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC7M,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAA2B,KAAK,GAAG,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAa,eAAe,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAInI,sFAAsF;AACtF,eAAO,MAAM,oBAAoB,OAAQ,CAAC;AAC1C,eAAO,MAAM,kBAAkB,OAAQ,CAAC;AACxC,yEAAyE;AACzE,eAAO,MAAM,cAAc,QAAS,CAAC;AACrC,qFAAqF;AACrF,eAAO,MAAM,eAAe,OAAQ,CAAC;AACrC;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAS,CAAC;AACtC,+GAA+G;AAC/G,eAAO,MAAM,YAAY,OAAQ,CAAC;AAClC,eAAO,MAAM,iBAAiB,OAAQ,CAAC;AAEvC,wFAAwF;AACxF,UAAU,YAAY;IAClB,CAAC,EAAE,CAAC,CAAC;IACL,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,GAAG,CAA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wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAW1F;;;;;;;OAOG;IACU,uBAAuB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAW1E;;;;;;OAMG;IACU,sBAAsB,IAAI,OAAO,CAAC,WAAW,CAAC;IAoB3D;;;OAGG;IACU,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAO/C;;;;;OAKG;IACU,kBAAkB,IAAI,OAAO,CAAC,QAAQ,CAAC;IAOpD;;;;;OAKG;IACU,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAMnD;;;;OAIG;IACU,qBAAqB,IAAI,OAAO,CAAC,WAAW,CAAC;IAO1D;;;;;;;;;OASG;IACU,uBAAuB,IAAI,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAOtE;;;;;;OAMG;IACU,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IASnE,4IAA4I;IAC5I,OAAO,CAAC,WAAW;YAML,kBAAkB;YA2BlB,UAAU;IA8DxB,iHAAiH;YACnG,gBAAgB;IAS9B,6FAA6F;YAC/E,UAAU;YASV,kBAAkB;YAalB,mBAAmB;YAOnB,WAAW;CAG5B"}
@@ -159,6 +159,8 @@ export class RideRequest {
159
159
  heldViews = new Map();
160
160
  /** ZO-24: the last ride shown (status and position never go back). */
161
161
  lastRide;
162
+ /** ZO-25: the next read of the request goes through consensus (after the rider's own action). */
163
+ freshNext = false;
162
164
  rejected = new Set();
163
165
  notFree = new Set();
164
166
  refreshingUntilMs = new Map();
@@ -266,6 +268,7 @@ export class RideRequest {
266
268
  */
267
269
  async rejectOfferAsyncUnsafe(offerId) {
268
270
  const done = await this.onOfferAsyncUnsafe(offerId, (actor, ref) => actor.rejectOffer(ref));
271
+ this.freshNext = true;
269
272
  this.offerWorkers.delete(offerId);
270
273
  // U-42: the entry stays in its place, as `gone: "rejected"`.
271
274
  this.rejected.add(offerId);
@@ -281,6 +284,7 @@ export class RideRequest {
281
284
  */
282
285
  async refreshOfferAsyncUnsafe(offerId) {
283
286
  const asked = await this.onOfferAsyncUnsafe(offerId, (actor, ref) => actor.refreshOffer(ref));
287
+ this.freshNext = true;
284
288
  // The offer is absent until its driver confirms again; its place waits (REFRESH_WAIT_MS).
285
289
  if (asked)
286
290
  this.refreshingUntilMs.set(offerId, Date.now() + REFRESH_WAIT_MS);
@@ -318,6 +322,7 @@ export class RideRequest {
318
322
  return { kind: "driverNotFree" };
319
323
  }
320
324
  const outcome = await this.onOfferAsyncUnsafe(offerId, (actor, ref) => actor.chooseOffer(ref));
325
+ this.freshNext = true;
321
326
  if ("ordered" in outcome) {
322
327
  this.orderedOfferId = offerId;
323
328
  return { kind: "ordered", answerByMs: msOf(outcome.ordered.answerByNs) };
@@ -404,6 +409,7 @@ export class RideRequest {
404
409
  */
405
410
  async giveUpAsyncUnsafe() {
406
411
  const results = await Promise.allSettled(this.state.workers.map((worker) => this.group.onWorkerAsyncUnsafe(worker, (actor) => actor.giveUp({ requestId: this.state.requestId }))));
412
+ this.freshNext = true;
407
413
  const failed = results.find((result) => result.status === "rejected" && errorKeyOf(result.reason) === undefined);
408
414
  if (failed?.status === "rejected")
409
415
  throw failed.reason;
@@ -429,6 +435,7 @@ export class RideRequest {
429
435
  async cancelRideAsyncUnsafe() {
430
436
  const accepted = await this.acceptedAsyncUnsafe();
431
437
  await executeProtocolAsyncUnsafe(async () => (await this.driverAsync(accepted.canister)).cancelRide({ requestId: this.state.requestId, driverKey: accepted.driverKey }));
438
+ this.freshNext = true;
432
439
  }
433
440
  /**
434
441
  * U-11, PR-23: the driver's licence, from the acceptance to the end of the ride.
@@ -465,7 +472,9 @@ export class RideRequest {
465
472
  */
466
473
  async rateDriverAsyncUnsafe(stars) {
467
474
  const accepted = await this.acceptedAsyncUnsafe();
468
- return this.group.onWorkerAsyncUnsafe(accepted.worker, (actor) => actor.rateDriver({ requestId: this.state.requestId, stars }));
475
+ const rated = await this.group.onWorkerAsyncUnsafe(accepted.worker, (actor) => actor.rateDriver({ requestId: this.state.requestId, stars }));
476
+ this.freshNext = true;
477
+ return rated;
469
478
  }
470
479
  // ----- inside -----
471
480
  /** U-42: the driver of this offer is busy — the entry is gone, and its place in the worker goes to the next driver (ZO-12, best-effort). */
@@ -475,7 +484,11 @@ export class RideRequest {
475
484
  void this.onOfferAsyncUnsafe(offerId, (actor, ref) => actor.rejectOffer(ref)).catch(() => undefined);
476
485
  }
477
486
  async readAllAsyncUnsafe(workers) {
478
- const results = await Promise.allSettled(workers.map(async (worker) => ({ worker, view: await this.group.onWorkerAsyncUnsafe(worker, (actor) => actor.getRequest({ requestId: this.state.requestId })) })));
487
+ // ZO-25: the first read after the rider's own action goes through consensus.
488
+ const fresh = this.freshNext;
489
+ this.freshNext = false;
490
+ const read = (worker) => (fresh ? this.group.onWorkerFreshAsyncUnsafe(worker, (actor) => actor.getRequest({ requestId: this.state.requestId })) : this.group.onWorkerAsyncUnsafe(worker, (actor) => actor.getRequest({ requestId: this.state.requestId })));
491
+ const results = await Promise.allSettled(workers.map(async (worker) => ({ worker, view: await read(worker) })));
479
492
  const answers = [];
480
493
  const failed = [];
481
494
  let failure;
@@ -1,10 +1,17 @@
1
1
  import { type ActorSubclass, type Identity } from "@icp-sdk/core/agent";
2
+ import type { IDL } from "@icp-sdk/core/candid";
2
3
  import { Principal } from "@icp-sdk/core/principal";
3
4
  import type { _SERVICE as CoreService } from "../../declarations/core/core.did.js";
4
5
  import type { _SERVICE as WorkerService } from "../../declarations/worker/worker.did.js";
5
6
  import type { _SERVICE as CoordinatorService } from "../../declarations/coordinator/coordinator.did.js";
6
7
  import { type GroupOptions, type MotokoResult } from "./canister-actor.js";
7
8
  import { type PrefixEntryView } from "./prefixes.js";
9
+ /**
10
+ * ZO-25: the worker's interface with `getRequest` as an update call — the subnet answers from
11
+ * the state after every finished call, so no replica a round behind answers a read made right
12
+ * after the rider's own action with the state from before it.
13
+ */
14
+ export declare const workerFreshIdl: IDL.InterfaceFactory;
8
15
  export type CoreActor = ActorSubclass<CoreService>;
9
16
  export type WorkerActor = ActorSubclass<WorkerService>;
10
17
  export type CoordinatorActor = ActorSubclass<CoordinatorService>;
@@ -37,6 +44,8 @@ export declare class TigiGroup {
37
44
  private constructor();
38
45
  coordinatorAsync(): Promise<CoordinatorActor>;
39
46
  workerAsync(workerId: string): Promise<WorkerActor>;
47
+ /** ZO-25: a worker whose `getRequest` goes through consensus. */
48
+ workerFreshAsync(workerId: string): Promise<WorkerActor>;
40
49
  coreAsync(): Promise<CoreActor>;
41
50
  /**
42
51
  * The core's id, from the coordinator, kept for good.
@@ -55,6 +64,8 @@ export declare class TigiGroup {
55
64
  workerForAsyncUnsafe(geohash: string): Promise<string | undefined>;
56
65
  /** One call to one worker, its Result unwrapped. */
57
66
  onWorkerAsyncUnsafe<T>(workerId: string, callAsync: (worker: WorkerActor) => Promise<MotokoResult<T>>): Promise<T>;
67
+ /** ZO-25: one call through consensus to one worker, its Result unwrapped. */
68
+ onWorkerFreshAsyncUnsafe<T>(workerId: string, callAsync: (worker: WorkerActor) => Promise<MotokoResult<T>>): Promise<T>;
58
69
  /** The same read in every worker, in the order of the list. */
59
70
  onAllWorkersAsyncUnsafe<T>(callAsync: (worker: WorkerActor) => Promise<MotokoResult<T>>): Promise<T[]>;
60
71
  }
@@ -1 +1 @@
1
- {"version":3,"file":"group.d.ts","sourceRoot":"","sources":["../../src/group/group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,QAAQ,IAAI,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAEnF,OAAO,KAAK,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAEzF,OAAO,KAAK,EAAE,QAAQ,I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M,EAAE,CAAC;IASpE,2EAA2E;IAC9D,uBAAuB,CAAC,KAAK,UAAQ,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IAS/E;;;;OAIG;IACU,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAS/E,oDAAoD;IACvC,mBAAmB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAI/H,6EAA6E;IAChE,wBAAwB,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAIpI,+DAA+D;IAClD,uBAAuB,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC;CAItH;AAED,wEAAwE;AACxE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAEnD"}
@@ -5,6 +5,15 @@ import { idlFactory as workerIdl } from "../../declarations/worker/worker.did.js
5
5
  import { idlFactory as coordinatorIdl } from "../../declarations/coordinator/coordinator.did.js";
6
6
  import { executeAsyncUnsafe, MAINNET_HOST, rawActorAsync, transportAsync } from "./canister-actor.js";
7
7
  import { longestMatch } from "./prefixes.js";
8
+ /**
9
+ * ZO-25: the worker's interface with `getRequest` as an update call — the subnet answers from
10
+ * the state after every finished call, so no replica a round behind answers a read made right
11
+ * after the rider's own action with the state from before it.
12
+ */
13
+ export const workerFreshIdl = (args) => {
14
+ const service = workerIdl(args);
15
+ return args.IDL.Service(Object.fromEntries(service._fields.map(([name, func]) => [name, name === "getRequest" ? args.IDL.Func(func.argTypes, func.retTypes, []) : func])));
16
+ };
8
17
  /** The list of workers and the prefix map are asked for again after this long. */
9
18
  export const MAP_TTL_MS = 30_000;
10
19
  /**
@@ -56,6 +65,10 @@ export class TigiGroup {
56
65
  async workerAsync(workerId) {
57
66
  return rawActorAsync(workerIdl, workerId, this.identity, this.options);
58
67
  }
68
+ /** ZO-25: a worker whose `getRequest` goes through consensus. */
69
+ async workerFreshAsync(workerId) {
70
+ return rawActorAsync(workerFreshIdl, workerId, this.identity, this.options);
71
+ }
59
72
  async coreAsync() {
60
73
  return rawActorAsync(coreIdl, await this.getCoreIdAsyncUnsafe(), this.identity, this.options);
61
74
  }
@@ -108,6 +121,10 @@ export class TigiGroup {
108
121
  async onWorkerAsyncUnsafe(workerId, callAsync) {
109
122
  return executeAsyncUnsafe(async () => callAsync(await this.workerAsync(workerId)));
110
123
  }
124
+ /** ZO-25: one call through consensus to one worker, its Result unwrapped. */
125
+ async onWorkerFreshAsyncUnsafe(workerId, callAsync) {
126
+ return executeAsyncUnsafe(async () => callAsync(await this.workerFreshAsync(workerId)));
127
+ }
111
128
  /** The same read in every worker, in the order of the list. */
112
129
  async onAllWorkersAsyncUnsafe(callAsync) {
113
130
  const workers = await this.getWorkersAsyncUnsafe();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsm-mit/tigi-sharded-package",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "The one package of the Tigi network group: takes the coordinator's id and hides the coordinator, the core and the workers — for a consumer the group is one canister; plus the rider's few driver-canister endpoints (U-14).",
5
5
  "homepage": "https://github.com/JSM-Tigi/tigi-sharded/tree/master/package#readme",
6
6
  "repository": {
@@ -59,11 +59,11 @@
59
59
  "tigiSharded": {
60
60
  "repo": "tigi-sharded",
61
61
  "repoUrl": "https://github.com/JSM-Tigi/tigi-sharded",
62
- "commit": "ac6ef3488e4cda361833ac4819491f8a0231df5b"
62
+ "commit": "5ec9ad29681d2cf1bca3013f21bdafaf8ca55488"
63
63
  },
64
64
  "tigiDriverRust": {
65
65
  "repo": "tigi-driver-rust",
66
66
  "repoUrl": "https://github.com/JSM-Tigi/tigi-driver-rust",
67
- "commit": "516d8b97918290f300ca954e6f6efde4e9e41654"
67
+ "commit": "2b94213452793026865ac2a51412984eb40c7c8d"
68
68
  }
69
69
  }