From 470c569e845978474c94ee8d5babf25c58f79fd0 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Mon, 6 Mar 2023 22:47:30 -0800 Subject: [PATCH] fix types --- .../src/kernel/vat-loader/manager-subprocess-xsnap.js | 4 +++- packages/SwingSet/src/types-external.js | 3 ++- packages/swingset-worker-xsnap-v1/src/make-v1.js | 10 ++++++++++ packages/swingset-worker-xsnap-v1/test/test-worker.js | 5 +++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/packages/SwingSet/src/kernel/vat-loader/manager-subprocess-xsnap.js b/packages/SwingSet/src/kernel/vat-loader/manager-subprocess-xsnap.js index 5f9118814c91..20746545b691 100644 --- a/packages/SwingSet/src/kernel/vat-loader/manager-subprocess-xsnap.js +++ b/packages/SwingSet/src/kernel/vat-loader/manager-subprocess-xsnap.js @@ -29,7 +29,9 @@ const decoder = new TextDecoder(); * allVatPowers: VatPowers, * kernelKeeper: KernelKeeper, * kernelSlog: KernelSlog, - * startXSnap: (workerVersion: string, vatID: string, name: string, handleCommand: AsyncHandler, metered?: boolean, reload?: boolean) => Promise, + * startXSnap: (workerVersion: string, vatID: string, name: string, + * handleCommand: AsyncHandler, metered?: boolean, + * reload?: boolean) => Promise, * testLog: (...args: unknown[]) => void, * }} tools * @returns {VatManagerFactory} diff --git a/packages/SwingSet/src/types-external.js b/packages/SwingSet/src/types-external.js index 1fdd34feaf10..83a0f1745c23 100644 --- a/packages/SwingSet/src/types-external.js +++ b/packages/SwingSet/src/types-external.js @@ -151,7 +151,8 @@ export {}; * @typedef { { transcriptCount: number } } VatStats * @typedef { ReturnType } VatKeeper * @typedef { ReturnType } KernelKeeper - * @typedef { ReturnType } XSnap + * @typedef { (err: {}) => string } TrapMeteringFailure + * @typedef { ReturnType & { trapMeteringFailure: TrapMeteringFailure } } XSnap * @typedef { (dr: VatDeliveryResult) => void } SlogFinishDelivery * @typedef { (ksr: KernelSyscallResult, vsr: VatSyscallResult) => void } SlogFinishSyscall * @typedef { { write: ({}) => void, diff --git a/packages/swingset-worker-xsnap-v1/src/make-v1.js b/packages/swingset-worker-xsnap-v1/src/make-v1.js index 850e72d5b86c..837a2ecc6b1f 100644 --- a/packages/swingset-worker-xsnap-v1/src/make-v1.js +++ b/packages/swingset-worker-xsnap-v1/src/make-v1.js @@ -9,6 +9,14 @@ import { getSupervisorBundle } from '@agoric/swingset-xsnap-supervisor'; const NETSTRING_MAX_CHUNK_SIZE = 12_000_000; +/** + * SnapStore is defined by swing-store, but we don't import that: we get it + * from swingset as an option. To avoid an inconvenient dependency graph, + * we define the salient methods locally. + * + * @typedef {(vatID: string, loadRaw: (filePath: string) => Promise) => Promise} LoadSnapshot + * @typedef {{ loadSnapshot: LoadSnapshot }} SnapStore + */ /** * @param {{ * snapStore?: SnapStore, @@ -83,7 +91,9 @@ export function makeStartXSnapV1(options) { const worker = doXSnap({ handleCommand, name, ...meterOpts, ...xsnapOpts }); let bundles = []; + // eslint-disable-next-line @jessie.js/no-nested-await bundles.push(await getLockdownBundle()); + // eslint-disable-next-line @jessie.js/no-nested-await bundles.push(await getSupervisorBundle()); if (overrideBundles) { bundles = overrideBundles; // replace the usual bundles diff --git a/packages/swingset-worker-xsnap-v1/test/test-worker.js b/packages/swingset-worker-xsnap-v1/test/test-worker.js index 5fdacce06a76..54279276b3c9 100644 --- a/packages/swingset-worker-xsnap-v1/test/test-worker.js +++ b/packages/swingset-worker-xsnap-v1/test/test-worker.js @@ -7,7 +7,7 @@ import { makeMarshal } from '@endo/marshal'; import { Fail } from '@agoric/assert'; import { makeStartXSnapV1 } from '../src/index.js'; -const nope = () => Fail('nope'); +const nope = () => Fail`nope`; const kmarshal = makeMarshal(nope, nope, { serializeBodyFormat: 'smallcaps', errorTagging: 'off', @@ -19,8 +19,9 @@ test('basic delivery', async t => { const fn = new URL('./vat-simple.js', import.meta.url).pathname; const bundle = await bundleSource(fn, { dev: true }); + const snapStore = /** @type {SnapStore} */ undefined; const startXSnapV1 = makeStartXSnapV1({ - snapstore: undefined, // unused by this test + snapStore, // unused by this test spawn, });