Skip to content

Commit

Permalink
feat(swingset): defaultManagerType option in makeSwingsetController
Browse files Browse the repository at this point in the history
... and to buildVatController

Set the default manager type to xs-worker in a couple tests:
  test-message-patterns in SwingSet
  test-splitPayments in ERTP

ref #2260
  • Loading branch information
dckc committed Jan 27, 2021
1 parent e3e7255 commit 8198a23
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import path from 'path';
async function main(basedir, argv) {
const dir = path.resolve(`${__dirname}/..`, basedir);
const config = await loadBasedir(dir);
const controller = await buildVatController(config, argv);
const controller = await buildVatController(config, argv, {
defaultManagerType: 'xs-worker',
});
await controller.run();
return controller.dump();
}
Expand Down
11 changes: 9 additions & 2 deletions packages/SwingSet/src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export async function makeSwingsetController(
debugPrefix = '',
slogFile,
testTrackDecref,
defaultManagerType = 'local',
} = runtimeOptions;
if (typeof Compartment === 'undefined') {
throw Error('SES must be installed before calling makeSwingsetController');
Expand Down Expand Up @@ -205,7 +206,7 @@ export async function makeSwingsetController(
FinalizationRegistry,
};

const kernelOptions = { verbose, testTrackDecref };
const kernelOptions = { verbose, testTrackDecref, defaultManagerType };
const kernel = buildKernel(kernelEndowments, deviceEndowments, kernelOptions);

if (runtimeOptions.verbose) {
Expand Down Expand Up @@ -298,8 +299,14 @@ export async function buildVatController(
kernelBundles,
debugPrefix,
testTrackDecref,
defaultManagerType,
} = runtimeOptions;
const actualRuntimeOptions = { verbose, debugPrefix, testTrackDecref };
const actualRuntimeOptions = {
verbose,
debugPrefix,
testTrackDecref,
defaultManagerType,
};
const initializationOptions = { verbose, kernelBundles };
let bootstrapResult;
if (!swingsetIsInitialized(hostStorage)) {
Expand Down
7 changes: 6 additions & 1 deletion packages/SwingSet/src/kernel/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ export default function buildKernel(
FinalizationRegistry,
} = kernelEndowments;
deviceEndowments = { ...deviceEndowments }; // copy so we can modify
const { verbose, testTrackDecref = false } = kernelOptions;
const {
verbose,
testTrackDecref = false,
defaultManagerType = 'local',
} = kernelOptions;
const logStartup = verbose ? console.debug : () => 0;

insistStorageAPI(hostStorage);
Expand Down Expand Up @@ -562,6 +566,7 @@ export default function buildKernel(
startSubprocessWorkerNode,
startXSnap,
gcTools,
defaultManagerType,
});

function buildVatSyscallHandler(vatID, translators) {
Expand Down
3 changes: 2 additions & 1 deletion packages/SwingSet/src/kernel/vatManager/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function makeVatManagerFactory({
startSubprocessWorkerNode,
startXSnap,
gcTools,
defaultManagerType,
}) {
const localFactory = makeLocalVatManagerFactory({
allVatPowers,
Expand Down Expand Up @@ -74,7 +75,7 @@ export function makeVatManagerFactory({
// returns promise for new vatManager
function vatManagerFactory(vatID, managerOptions) {
validateManagerOptions(managerOptions);
const { managerType = 'local', setup, bundle } = managerOptions;
const { managerType = defaultManagerType, setup, bundle } = managerOptions;

if (managerType === 'local') {
if (setup) {
Expand Down
12 changes: 10 additions & 2 deletions packages/SwingSet/test/test-message-patterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ test.before(async t => {
creationOptions: {
enablePipelining: true,
enableSetup: true,
managerType: 'local',
},
};
const moreVatTP = { bundle: kernelBundles.vattp };
Expand All @@ -97,7 +98,11 @@ test.before(async t => {

export async function runVatsLocally(t, name) {
const { localConfig: config, kernelBundles } = t.context.data;
const c = await buildVatController(config, [name], { kernelBundles });
const c = await buildVatController(config, [name], {
kernelBundles,
defaultManagerType: 'xs-worker',
});
t.teardown(c.shutdown);
// await runWithTrace(c);
await c.run();
return c.dump().log;
Expand Down Expand Up @@ -134,7 +139,10 @@ export async function runVatsInComms(t, name) {
};
const hostStorage = initSwingStore().storage;
await initializeSwingset(config, [name], hostStorage, { kernelBundles });
const c = await makeSwingsetController(hostStorage, deviceEndowments);
const c = await makeSwingsetController(hostStorage, deviceEndowments, {
defaultManagerType: 'xs-worker',
});
t.teardown(c.shutdown);

// await runWithTrace(c);
await c.run();
Expand Down

0 comments on commit 8198a23

Please sign in to comment.