From ae3d55178e36c5b987536491cbcd731112b9d93b Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Tue, 11 May 2021 12:53:24 -0500 Subject: [PATCH] fix(xs-worker): respect metered from managerOptions --- packages/SwingSet/src/controller.js | 6 ++++-- .../src/kernel/vatManager/manager-subprocess-xsnap.js | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/SwingSet/src/controller.js b/packages/SwingSet/src/controller.js index fcbc744bf4a9..ca1ce15c9159 100644 --- a/packages/SwingSet/src/controller.js +++ b/packages/SwingSet/src/controller.js @@ -80,8 +80,9 @@ export function makeStartXSnap(bundles, { snapstorePath, env }) { /** * @param {string} name * @param {(request: Uint8Array) => Promise} handleCommand + * @param { boolean } metered */ - async function startXSnap(name, handleCommand) { + async function startXSnap(name, handleCommand, metered) { if (supervisorHash) { return snapStore.load(supervisorHash, async snapshot => { const xs = xsnap({ snapshot, name, handleCommand, ...xsnapOpts }); @@ -89,7 +90,8 @@ export function makeStartXSnap(bundles, { snapstorePath, env }) { return xs; }); } - const worker = xsnap({ handleCommand, name, ...xsnapOpts }); + const meterOpts = metered ? {} : { meteringLimit: 0 }; + const worker = xsnap({ handleCommand, name, ...meterOpts, ...xsnapOpts }); for (const bundle of bundles) { assert( diff --git a/packages/SwingSet/src/kernel/vatManager/manager-subprocess-xsnap.js b/packages/SwingSet/src/kernel/vatManager/manager-subprocess-xsnap.js index a579e306ed63..8be6515fc08e 100644 --- a/packages/SwingSet/src/kernel/vatManager/manager-subprocess-xsnap.js +++ b/packages/SwingSet/src/kernel/vatManager/manager-subprocess-xsnap.js @@ -20,7 +20,7 @@ const decoder = new TextDecoder(); * allVatPowers: VatPowers, * kernelKeeper: KernelKeeper, * kernelSlog: KernelSlog, - * startXSnap: (name: string, handleCommand: SyncHandler) => Promise, + * startXSnap: (name: string, handleCommand: SyncHandler, metered: boolean) => Promise, * testLog: (...args: unknown[]) => void, * }} tools * @returns { VatManagerFactory } @@ -53,6 +53,7 @@ export function makeXsSubprocessFactory({ virtualObjectCacheSize, enableDisavow, name, + metered, } = managerOptions; assert( !managerOptions.enableSetup, @@ -101,7 +102,7 @@ export function makeXsSubprocessFactory({ } // start the worker and establish a connection - const worker = await startXSnap(`${vatID}:${name}`, handleCommand); + const worker = await startXSnap(`${vatID}:${name}`, handleCommand, metered); /** @type { (item: Tagged) => Promise } */ async function issueTagged(item) {