Skip to content

Commit

Permalink
fix(xs-worker): respect metered from managerOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed May 11, 2021
1 parent 25d5d43 commit ae3d551
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/SwingSet/src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,18 @@ export function makeStartXSnap(bundles, { snapstorePath, env }) {
/**
* @param {string} name
* @param {(request: Uint8Array) => Promise<Uint8Array>} 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 });
await xs.evaluate('null'); // ensure that spawn is done
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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const decoder = new TextDecoder();
* allVatPowers: VatPowers,
* kernelKeeper: KernelKeeper,
* kernelSlog: KernelSlog,
* startXSnap: (name: string, handleCommand: SyncHandler) => Promise<XSnap>,
* startXSnap: (name: string, handleCommand: SyncHandler, metered: boolean) => Promise<XSnap>,
* testLog: (...args: unknown[]) => void,
* }} tools
* @returns { VatManagerFactory }
Expand Down Expand Up @@ -53,6 +53,7 @@ export function makeXsSubprocessFactory({
virtualObjectCacheSize,
enableDisavow,
name,
metered,
} = managerOptions;
assert(
!managerOptions.enableSetup,
Expand Down Expand Up @@ -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<CrankResults> } */
async function issueTagged(item) {
Expand Down

0 comments on commit ae3d551

Please sign in to comment.