From b2cdea329319d46f51ce8e00dc67112646d49856 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Sat, 6 Jul 2024 11:39:15 -0700 Subject: [PATCH 1/5] refactor: makeZoeInstanceStorageManager unused param --- packages/zoe/src/typeGuards.js | 1 - packages/zoe/src/zoeService/internal-types.js | 1 - packages/zoe/src/zoeService/startInstance.js | 6 ------ packages/zoe/src/zoeService/zoeStorageManager.js | 1 - 4 files changed, 9 deletions(-) diff --git a/packages/zoe/src/typeGuards.js b/packages/zoe/src/typeGuards.js index 7d2fd0664c3..f2642599293 100644 --- a/packages/zoe/src/typeGuards.js +++ b/packages/zoe/src/typeGuards.js @@ -296,7 +296,6 @@ export const ZoeStorageManagerIKit = harden({ }), startInstanceAccess: M.interface('ZoeStorage startInstance access', { makeZoeInstanceStorageManager: M.call( - M.any(), InstallationShape, M.any(), IssuerPKeywordRecordShape, diff --git a/packages/zoe/src/zoeService/internal-types.js b/packages/zoe/src/zoeService/internal-types.js index eeb1f09281b..eb7badb4ce5 100644 --- a/packages/zoe/src/zoeService/internal-types.js +++ b/packages/zoe/src/zoeService/internal-types.js @@ -99,7 +99,6 @@ * instance-specific terms * * @callback MakeZoeInstanceStorageManager - * @param {import('@agoric/vat-data').Baggage} instanceBaggage * @param {Installation} installation * @param {object} customTerms * @param {IssuerKeywordRecord} uncleanIssuerKeywordRecord diff --git a/packages/zoe/src/zoeService/startInstance.js b/packages/zoe/src/zoeService/startInstance.js index e729c1d9ce2..79d1d8470f9 100644 --- a/packages/zoe/src/zoeService/startInstance.js +++ b/packages/zoe/src/zoeService/startInstance.js @@ -3,7 +3,6 @@ import { E } from '@endo/eventual-send'; import { passStyleOf } from '@endo/marshal'; import { M, - makeScalarBigMapStore, provideDurableWeakMapStore, prepareExoClass, prepareExo, @@ -301,14 +300,9 @@ export const makeStartInstance = ( const instanceHandle = makeInstanceHandle(); - const instanceBaggage = makeScalarBigMapStore('instanceBaggage', { - durable: true, - }); - const zoeInstanceStorageManager = await E( startInstanceAccess, ).makeZoeInstanceStorageManager( - instanceBaggage, installation, customTerms, uncleanIssuerKeywordRecord, diff --git a/packages/zoe/src/zoeService/zoeStorageManager.js b/packages/zoe/src/zoeService/zoeStorageManager.js index ae763e42adc..80d0c2cd5d6 100644 --- a/packages/zoe/src/zoeService/zoeStorageManager.js +++ b/packages/zoe/src/zoeService/zoeStorageManager.js @@ -352,7 +352,6 @@ export const makeZoeStorageManager = ( /** @type {MakeZoeInstanceStorageManager} */ const makeZoeInstanceStorageManager = async ( - instanceBaggage, installation, customTerms, uncleanIssuerKeywordRecord, From 727cb5499a7852b135c6c6160bdb8bb5d870ac97 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Sat, 6 Jul 2024 11:58:46 -0700 Subject: [PATCH 2/5] refactor: rm obsolete instanceRecord Added in https://github.com/Agoric/agoric-sdk/blame/2c28414a0ab2dd4c05bb9f6955b8d658b484253d/packages/zoe/src/instanceRecordStorage.js#L31 9f4d39bc7750dc48c42347fa21a1985914fbbdab made it obsolete but neglected to remove --- packages/zoe/src/instanceRecordStorage.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/zoe/src/instanceRecordStorage.js b/packages/zoe/src/instanceRecordStorage.js index 34faf24500f..2405c4caee3 100644 --- a/packages/zoe/src/instanceRecordStorage.js +++ b/packages/zoe/src/instanceRecordStorage.js @@ -1,5 +1,5 @@ import { q, Fail } from '@endo/errors'; -import { provide, prepareExoClass, M } from '@agoric/vat-data'; +import { prepareExoClass, M } from '@agoric/vat-data'; import { assertKeywordName } from './cleanProposal.js'; import { BrandKeywordRecordShape, @@ -28,8 +28,6 @@ const { ownKeys } = Reflect; * @returns {(ir: InstanceRecord) => InstanceState} */ export const makeInstanceRecordStorage = baggage => { - provide(baggage, 'instanceRecord', () => undefined); - const assertInstantiated = instanceRecord => { instanceRecord !== 'undefined' || Fail`instanceRecord has not been instantiated`; From 365cc9e8d0a4afcc9281aebf36276eedfd933a9b Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Sat, 6 Jul 2024 12:15:19 -0700 Subject: [PATCH 3/5] docs: setUpZoeForTest --- packages/zoe/tools/setup-zoe.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/zoe/tools/setup-zoe.js b/packages/zoe/tools/setup-zoe.js index 6c6a97a1b1c..03dc1de104e 100644 --- a/packages/zoe/tools/setup-zoe.js +++ b/packages/zoe/tools/setup-zoe.js @@ -23,6 +23,7 @@ export const makeZoeForTest = vatAdminSvc => /** * Returns promises for `zoe` and the `feeMintAccess`. + * Provide testing versions of capabilities for Zoe contracts. * * @template {object} [T=unknown] * @param {object} options From 94ec93c4ad9f8f2dd958eba7d265246e43a5d2ec Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Sat, 6 Jul 2024 12:39:24 -0700 Subject: [PATCH 4/5] fix: BundleCache type --- packages/SwingSet/tools/bundleTool.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/SwingSet/tools/bundleTool.js b/packages/SwingSet/tools/bundleTool.js index 6c5abd14443..6b0e612fc30 100755 --- a/packages/SwingSet/tools/bundleTool.js +++ b/packages/SwingSet/tools/bundleTool.js @@ -1,6 +1,7 @@ import { makeNodeBundleCache as wrappedMaker } from '@endo/bundle-source/cache.js'; import styles from 'ansi-styles'; // less authority than 'chalk' +/** @type {typeof wrappedMaker} */ export const makeNodeBundleCache = async (dest, options, loadModule, pid) => { const log = (...args) => { const flattened = args.map(arg => @@ -16,9 +17,9 @@ export const makeNodeBundleCache = async (dest, options, loadModule, pid) => { }; return wrappedMaker(dest, { log, ...options }, loadModule, pid); }; -/** @typedef {ReturnType} BundleCache */ +/** @typedef {Awaited>} BundleCache */ -/** @type {Map} */ +/** @type {Map>} */ const providedCaches = new Map(); /** @@ -29,10 +30,11 @@ const providedCaches = new Map(); * @param {{ format?: string, dev?: boolean }} options * @param {(id: string) => Promise} loadModule * @param {number} [pid] - * @returns {BundleCache} + * @returns {Promise} */ export const provideBundleCache = (dest, options, loadModule, pid) => { const uniqueDest = [dest, options.format, options.dev].join('-'); + // store the promise instead of awaiting to prevent a race let bundleCache = providedCaches.get(uniqueDest); if (!bundleCache) { bundleCache = makeNodeBundleCache(dest, options, loadModule, pid); @@ -42,5 +44,9 @@ export const provideBundleCache = (dest, options, loadModule, pid) => { }; harden(provideBundleCache); +/** + * @param {string} dest + * @returns {Promise} + */ export const unsafeMakeBundleCache = dest => makeNodeBundleCache(dest, {}, s => import(s)); From 3c531f561dd98e754fcb7bc5ab1ad8af9b7f27a1 Mon Sep 17 00:00:00 2001 From: Mark Miller Date: Sun, 7 Jul 2024 08:25:56 -0700 Subject: [PATCH 5/5] lint: restore ts-ignore This reverts commit 7f4d952aac75fc258159506ec838207b6890a91d. Co-authored-by: Turadg Aleahmad --- packages/async-flow/src/replay-membrane.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/async-flow/src/replay-membrane.js b/packages/async-flow/src/replay-membrane.js index b37ea0bfed0..44ed86848e7 100644 --- a/packages/async-flow/src/replay-membrane.js +++ b/packages/async-flow/src/replay-membrane.js @@ -285,7 +285,14 @@ export const makeReplayMembrane = ({ try { optVerb ? heapVowE.sendOnly(hostTarget)[optVerb](...hostArgs) - : // @ts-expect-error XXX heapVowE + : // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore once we changed this from E to heapVowE, + // typescript started complaining that heapVowE(hostTarget) + // is not callable. I'm not sure if this is a just a typing bug + // in heapVowE or also reflects a runtime deficiency. But this + // case it not used yet anyway. We disable it + // with at-ts-ignore rather than at-ts-expect-error because + // the dependency-graph tests complains that the latter is unused. heapVowE.sendOnly(hostTarget)(...hostArgs); } catch (hostProblem) { throw Panic`internal: eventual sendOnly synchrously failed ${hostProblem}`; @@ -313,7 +320,14 @@ export const makeReplayMembrane = ({ try { const hostPromise = optVerb ? heapVowE(hostTarget)[optVerb](...hostArgs) - : // @ts-expect-error XXX heapVowE + : // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore once we changed this from E to heapVowE, + // typescript started complaining that heapVowE(hostTarget) + // is not callable. I'm not sure if this is a just a typing bug + // in heapVowE or also reflects a runtime deficiency. But this + // case it not used yet anyway. We disable it + // with at-ts-ignore rather than at-ts-expect-error because + // the dependency-graph tests complains that the latter is unused. heapVowE(hostTarget)(...hostArgs); resolver.resolve(hostPromise); // TODO does this always work? } catch (hostProblem) {