@agoric/zoe 0.26.3-dev-92855b2.0 → 0.26.3-dev-6388a00.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/zoe",
3
- "version": "0.26.3-dev-92855b2.0+92855b2",
3
+ "version": "0.26.3-dev-6388a00.0+6388a00",
4
4
  "description": "Zoe: the Smart Contract Framework for Offer Enforcement",
5
5
  "type": "module",
6
6
  "main": "./src/zoeService/zoe.js",
@@ -43,15 +43,15 @@
43
43
  },
44
44
  "homepage": "https://github.com/Agoric/agoric-sdk#readme",
45
45
  "dependencies": {
46
- "@agoric/assert": "0.6.1-dev-92855b2.0+92855b2",
47
- "@agoric/ertp": "0.16.3-dev-92855b2.0+92855b2",
48
- "@agoric/internal": "0.3.3-dev-92855b2.0+92855b2",
49
- "@agoric/notifier": "0.6.3-dev-92855b2.0+92855b2",
50
- "@agoric/store": "0.9.3-dev-92855b2.0+92855b2",
51
- "@agoric/swingset-liveslots": "0.10.3-dev-92855b2.0+92855b2",
52
- "@agoric/swingset-vat": "0.32.3-dev-92855b2.0+92855b2",
53
- "@agoric/time": "0.3.3-dev-92855b2.0+92855b2",
54
- "@agoric/vat-data": "0.5.3-dev-92855b2.0+92855b2",
46
+ "@agoric/assert": "0.6.1-dev-6388a00.0+6388a00",
47
+ "@agoric/ertp": "0.16.3-dev-6388a00.0+6388a00",
48
+ "@agoric/internal": "0.3.3-dev-6388a00.0+6388a00",
49
+ "@agoric/notifier": "0.6.3-dev-6388a00.0+6388a00",
50
+ "@agoric/store": "0.9.3-dev-6388a00.0+6388a00",
51
+ "@agoric/swingset-liveslots": "0.10.3-dev-6388a00.0+6388a00",
52
+ "@agoric/swingset-vat": "0.32.3-dev-6388a00.0+6388a00",
53
+ "@agoric/time": "0.3.3-dev-6388a00.0+6388a00",
54
+ "@agoric/vat-data": "0.5.3-dev-6388a00.0+6388a00",
55
55
  "@endo/bundle-source": "^3.0.1",
56
56
  "@endo/captp": "^4.0.1",
57
57
  "@endo/eventual-send": "^1.0.1",
@@ -64,7 +64,7 @@
64
64
  "yargs-parser": "^21.1.1"
65
65
  },
66
66
  "devDependencies": {
67
- "@agoric/kmarshal": "0.1.1-dev-92855b2.0+92855b2",
67
+ "@agoric/kmarshal": "0.1.1-dev-6388a00.0+6388a00",
68
68
  "@endo/init": "^1.0.1",
69
69
  "ava": "^5.3.0",
70
70
  "c8": "^7.13.0",
@@ -137,5 +137,5 @@
137
137
  "typeCoverage": {
138
138
  "atLeast": 84.82
139
139
  },
140
- "gitHead": "92855b2b3fb3f6e533cdbebccb7aa92f7448d331"
140
+ "gitHead": "6388a002b53593f17a8d936d4e937efb7d065d97"
141
141
  }
@@ -414,6 +414,7 @@ export const makeZCFZygote = async (
414
414
  instanceRecHolder = makeInstanceRecord(instanceRecordFromZoe);
415
415
  instantiateIssuerStorage(issuerStorageFromZoe);
416
416
  zcfBaggage.init('instanceRecHolder', instanceRecHolder);
417
+ zcfBaggage.init('repairedContractCompletionWatcher', true);
417
418
 
418
419
  const { privateArgsShape } = meta;
419
420
  if (privateArgsShape) {
@@ -466,6 +467,13 @@ export const makeZCFZygote = async (
466
467
  instanceRecHolder = zcfBaggage.get('instanceRecHolder');
467
468
  initSeatMgrAndMintKind();
468
469
 
470
+ await null;
471
+ if (!zcfBaggage.has('repairedContractCompletionWatcher')) {
472
+ await E(zoeInstanceAdmin).repairContractCompletionWatcher();
473
+ console.log(`Repaired contract completion watcher`);
474
+ zcfBaggage.init('repairedContractCompletionWatcher', true);
475
+ }
476
+
469
477
  const { privateArgsShape } = meta;
470
478
  if (privateArgsShape) {
471
479
  mustMatch(privateArgs, privateArgsShape, 'privateArgs');
@@ -137,6 +137,7 @@
137
137
  * @property {(strings: Array<string>) => void} setOfferFilter
138
138
  * @property {() => Array<string>} getOfferFilter
139
139
  * @property {(seatHandle: SeatHandle) => Subscriber<AmountKeywordRecord>} getExitSubscriber
140
+ * @property {() => void} repairContractCompletionWatcher
140
141
  */
141
142
 
142
143
  /**
package/src/typeGuards.js CHANGED
@@ -196,6 +196,7 @@ export const InstanceAdminI = M.interface('InstanceAdmin', {
196
196
  getOfferFilter: M.call().returns(M.arrayOf(M.string())),
197
197
  getExitSubscriber: M.call(SeatShape).returns(SubscriberShape),
198
198
  isBlocked: M.call(M.string()).returns(M.boolean()),
199
+ repairContractCompletionWatcher: M.call().returns(),
199
200
  });
200
201
 
201
202
  export const InstanceStorageManagerIKit = harden({
@@ -6,12 +6,21 @@ import {
6
6
  makeScalarBigMapStore,
7
7
  provideDurableWeakMapStore,
8
8
  prepareExoClass,
9
+ prepareExo,
10
+ watchPromise,
9
11
  } from '@agoric/vat-data';
10
12
  import { initEmpty } from '@agoric/store';
13
+ import { isUpgradeDisconnection } from '@agoric/internal/src/upgrade-api.js';
11
14
 
12
15
  import { defineDurableHandle } from '../makeHandle.js';
13
16
  import { makeInstanceAdminMaker } from './instanceAdminStorage.js';
14
- import { AdminFacetI, InstanceAdminI } from '../typeGuards.js';
17
+ import {
18
+ AdminFacetI,
19
+ InstanceAdminI,
20
+ InstanceAdminShape,
21
+ } from '../typeGuards.js';
22
+
23
+ // import '../internal-types.js';
15
24
 
16
25
  /** @typedef {import('@agoric/vat-data').Baggage} Baggage */
17
26
  /** @typedef { import('@agoric/swingset-vat').BundleCap} BundleCap */
@@ -53,10 +62,45 @@ export const makeStartInstance = (
53
62
  const InstanceAdminStateShape = harden({
54
63
  instanceStorage: M.remotable('ZoeInstanceStorageManager'),
55
64
  instanceAdmin: M.remotable('InstanceAdmin'),
56
- seatHandleToSeatAdmin: M.remotable(),
65
+ seatHandleToSeatAdmin: M.remotable(), // seatHandleToSeatAdmin, but putting that string here is backwards-incompatible
57
66
  adminNode: M.remotable('adminNode'),
58
67
  });
59
68
 
69
+ /** @type {import('@agoric/swingset-liveslots').PromiseWatcher<unknown, [InstanceAdmin, Handle<'adminNode'>]>} */
70
+ const watcher = prepareExo(
71
+ zoeBaggage,
72
+ 'InstanceCompletionWatcher',
73
+ M.interface('InstanceCompletionWatcher', {
74
+ onFulfilled: M.call(
75
+ M.any(),
76
+ InstanceAdminShape,
77
+ M.remotable('adminNode'),
78
+ ).returns(),
79
+ onRejected: M.call(
80
+ M.any(),
81
+ InstanceAdminShape,
82
+ M.remotable('adminNode'),
83
+ ).returns(),
84
+ }),
85
+ {
86
+ onFulfilled: (completion, instanceAdmin) =>
87
+ instanceAdmin.exitAllSeats(completion),
88
+ onRejected: (/** @type {Error} */ reason, instanceAdmin, adminNode) => {
89
+ if (isUpgradeDisconnection(reason)) {
90
+ console.log(`resetting promise watcher after upgrade`, reason);
91
+ // eslint-disable-next-line no-use-before-define
92
+ watchForAdminNodeDone(adminNode, instanceAdmin);
93
+ } else {
94
+ instanceAdmin.failAllSeats(reason);
95
+ }
96
+ },
97
+ },
98
+ );
99
+
100
+ const watchForAdminNodeDone = (adminNode, instAdmin) => {
101
+ watchPromise(E(adminNode).done(), watcher, instAdmin, adminNode);
102
+ };
103
+
60
104
  const makeZoeInstanceAdmin = prepareExoClass(
61
105
  zoeBaggage,
62
106
  'zoeInstanceAdmin',
@@ -131,10 +175,10 @@ export const makeStartInstance = (
131
175
  replaceAllocations(seatHandleAllocations) {
132
176
  const { state } = this;
133
177
  try {
134
- seatHandleAllocations.forEach(({ seatHandle, allocation }) => {
178
+ for (const { seatHandle, allocation } of seatHandleAllocations) {
135
179
  const zoeSeatAdmin = state.seatHandleToSeatAdmin.get(seatHandle);
136
180
  zoeSeatAdmin.replaceAllocation(allocation);
137
- });
181
+ }
138
182
  } catch (err) {
139
183
  // nothing for Zoe to do if the termination fails
140
184
  void E(state.adminNode).terminateWithFailure(err);
@@ -161,6 +205,10 @@ export const makeStartInstance = (
161
205
  const { state } = this;
162
206
  return state.instanceAdmin.isBlocked(string);
163
207
  },
208
+ repairContractCompletionWatcher() {
209
+ const { state, self } = this;
210
+ void watchForAdminNodeDone(state.adminNode, self);
211
+ },
164
212
  },
165
213
  {
166
214
  stateShape: InstanceAdminStateShape,
@@ -278,13 +326,7 @@ export const makeStartInstance = (
278
326
  );
279
327
  zoeInstanceStorageManager.initInstanceAdmin(instanceHandle, instanceAdmin);
280
328
 
281
- E.when(
282
- E(adminNode).done(),
283
- completion => {
284
- instanceAdmin.exitAllSeats(completion);
285
- },
286
- reason => instanceAdmin.failAllSeats(reason),
287
- );
329
+ void watchForAdminNodeDone(adminNode, instanceAdmin);
288
330
 
289
331
  /** @type {ZoeInstanceAdmin} */
290
332
  const zoeInstanceAdminForZcf = makeZoeInstanceAdmin(