Skip to content

Commit

Permalink
chore(swingset): fix all import paths
Browse files Browse the repository at this point in the history
Part two of the big reorg: modify imports to point at the updated paths, but
do not move any files around.

refs #4502
  • Loading branch information
warner committed Feb 26, 2022
1 parent d9a2078 commit 675e665
Show file tree
Hide file tree
Showing 111 changed files with 296 additions and 257 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { buildRootObject } from '../../src/vats/vat-tp.js';
export { buildRootObject } from '../../src/vats/vattp/vat-vattp.js';
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { buildRootObject } from '../../src/vats/vat-tp.js';
export { buildRootObject } from '../../src/vats/vattp/vat-vattp.js';
2 changes: 1 addition & 1 deletion packages/SwingSet/exported.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import './src/vats/types.js';
import './src/vats/timer/types.js';
24 changes: 12 additions & 12 deletions packages/SwingSet/misc-tools/replay-transcript.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ import readline from 'readline';
import process from 'process';
import { spawn } from 'child_process';
import bundleSource from '@endo/bundle-source';
import { waitUntilQuiescent } from '../src/waitUntilQuiescent.js';
import { makeStartXSnap } from '../src/controller.js';
import { makeXsSubprocessFactory } from '../src/kernel/vatManager/manager-subprocess-xsnap.js';
import { makeLocalVatManagerFactory } from '../src/kernel/vatManager/manager-local.js';
import { makeNodeSubprocessFactory } from '../src/kernel/vatManager/manager-subprocess-node.js';
import { startSubprocessWorker } from '../src/spawnSubprocessWorker.js';
import { requireIdentical } from '../src/kernel/vatManager/transcript.js';
import { waitUntilQuiescent } from '../src/lib-nodejs/waitUntilQuiescent.js';
import { makeStartXSnap } from '../src/controller/controller.js';
import { makeXsSubprocessFactory } from '../src/kernel/vat-loader/manager-subprocess-xsnap.js';
import { makeLocalVatManagerFactory } from '../src/kernel/vat-loader/manager-local.js';
import { makeNodeSubprocessFactory } from '../src/kernel/vat-loader/manager-subprocess-node.js';
import { startSubprocessWorker } from '../src/lib-nodejs/spawnSubprocessWorker.js';
import { requireIdentical } from '../src/kernel/vat-loader/transcript.js';
import { makeDummyMeterControl } from '../src/kernel/dummyMeterControl.js';
import { makeGcAndFinalize } from '../src/gc-and-finalize.js';
import engineGC from '../src/engine-gc.js';
import { makeGcAndFinalize } from '../src/lib-nodejs/gc-and-finalize.js';
import engineGC from '../src/lib-nodejs/engine-gc.js';

async function makeBundles() {
const srcGE = rel =>
bundleSource(new URL(rel, import.meta.url).pathname, 'getExport');
const lockdown = await srcGE(
'../src/kernel/vatManager/lockdown-subprocess-xsnap.js',
'../src/supervisors/subprocess-xsnap/lockdown-subprocess-xsnap.js',
);
const supervisor = await srcGE(
'../src/kernel/vatManager/supervisor-subprocess-xsnap.js',
'../src/supervisors/subprocess-xsnap/supervisor-subprocess-xsnap.js',
);
fs.writeFileSync('lockdown-bundle', JSON.stringify(lockdown));
fs.writeFileSync('supervisor-bundle', JSON.stringify(supervisor));
Expand Down Expand Up @@ -105,7 +105,7 @@ async function replay(transcriptFile) {
// kind of useless for vats that use virtual objects
function startSubprocessWorkerNode() {
const supercode = new URL(
'../src/kernel/vatManager/supervisor-subprocess-node.js',
'../src/supervisors/subprocess-node/supervisor-subprocess-node.js',
import.meta.url,
).pathname;
return startSubprocessWorker(process.execPath, ['-r', 'esm', supercode]);
Expand Down
22 changes: 11 additions & 11 deletions packages/SwingSet/src/controller/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import { assert, details as X } from '@agoric/assert';
import { importBundle } from '@endo/import-bundle';
import { xsnap, recordXSnap } from '@agoric/xsnap';

import { computeBundleID } from './validate-archive.js';
import { createSHA256 } from './hasher.js';
import engineGC from './engine-gc.js';
import { startSubprocessWorker } from './spawnSubprocessWorker.js';
import { waitUntilQuiescent } from './waitUntilQuiescent.js';
import { makeGcAndFinalize } from './gc-and-finalize.js';
import { insistStorageAPI } from './storageAPI.js';
import { insistCapData } from './capdata.js';
import { computeBundleID } from '../lib-nodejs/validate-archive.js';
import { createSHA256 } from '../lib-nodejs/hasher.js';
import engineGC from '../lib-nodejs/engine-gc.js';
import { startSubprocessWorker } from '../lib-nodejs/spawnSubprocessWorker.js';
import { waitUntilQuiescent } from '../lib-nodejs/waitUntilQuiescent.js';
import { makeGcAndFinalize } from '../lib-nodejs/gc-and-finalize.js';
import { insistStorageAPI } from '../lib/storageAPI.js';
import { insistCapData } from '../lib/capdata.js';
import { provideHostStorage } from './hostStorage.js';
import {
swingsetIsInitialized,
Expand Down Expand Up @@ -233,7 +233,7 @@ export async function makeSwingsetController(
// this launches a worker in a Node.js thread (aka "Worker")
function makeNodeWorker() {
const supercode = new URL(
'kernel/vatManager/supervisor-nodeworker.js',
'../supervisors/nodeworker/supervisor-nodeworker.js',
import.meta.url,
).pathname;
return new Worker(supercode);
Expand All @@ -242,7 +242,7 @@ export async function makeSwingsetController(
// launch a worker in a subprocess (which runs Node.js)
function startSubprocessWorkerNode() {
const supercode = new URL(
'kernel/vatManager/supervisor-subprocess-node.js',
'../supervisors/subprocess-node/supervisor-subprocess-node.js',
import.meta.url,
).pathname;
const args = [supercode];
Expand Down Expand Up @@ -279,7 +279,7 @@ export async function makeSwingsetController(
};

const kernelOptions = { verbose, warehousePolicy, overrideVatManagerOptions };
/** @type { ReturnType<typeof import('./kernel').default> } */
/** @type { ReturnType<typeof import('../kernel').default> } */
const kernel = buildKernel(kernelEndowments, deviceEndowments, kernelOptions);

if (runtimeOptions.verbose) {
Expand Down
16 changes: 8 additions & 8 deletions packages/SwingSet/src/controller/initializeKernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import { makeMarshal, Far } from '@endo/marshal';
import { assert, details as X } from '@agoric/assert';
import { createSHA256 } from '../hasher.js';
import { assertKnownOptions } from '../assertOptions.js';
import { insistVatID } from './id.js';
import { makeVatSlot } from '../parseVatSlots.js';
import { insistStorageAPI } from '../storageAPI.js';
import makeKernelKeeper from './state/kernelKeeper.js';
import { exportRootObject } from './kernel.js';
import { makeKernelQueueHandler } from './kernelQueue.js';
import { createSHA256 } from '../lib-nodejs/hasher.js';
import { assertKnownOptions } from '../lib/assertOptions.js';
import { insistVatID } from '../lib/id.js';
import { makeVatSlot } from '../lib/parseVatSlots.js';
import { insistStorageAPI } from '../lib/storageAPI.js';
import makeKernelKeeper from '../kernel/state/kernelKeeper.js';
import { exportRootObject } from '../kernel/kernel.js';
import { makeKernelQueueHandler } from '../kernel/kernelQueue.js';

function makeVatRootObjectSlot() {
return makeVatSlot('object', true, 0);
Expand Down
32 changes: 18 additions & 14 deletions packages/SwingSet/src/controller/initializeSwingset.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { resolve as resolveModuleSpecifier } from 'import-meta-resolve';
import { assert, details as X } from '@agoric/assert';
import bundleSource from '@endo/bundle-source';

import './types.js';
import { insistStorageAPI } from './storageAPI.js';
import { initializeKernel } from './kernel/initializeKernel.js';
import { kdebugEnable } from './kernel/kdebug.js';
import { computeBundleID } from './validate-archive.js';
import '../types.js';
import { insistStorageAPI } from '../lib/storageAPI.js';
import { initializeKernel } from './initializeKernel.js';
import { kdebugEnable } from '../lib/kdebug.js';
import { computeBundleID } from '../lib-nodejs/validate-archive.js';

/**
* @param {X[]} xs
Expand Down Expand Up @@ -50,15 +50,19 @@ export async function buildKernelBundles(options = {}) {
});

const bundles = await allValues({
kernel: src('./kernel/kernel.js'),
adminDevice: src('./kernel/vatAdmin/vatAdmin-src'),
adminVat: src('./kernel/vatAdmin/vatAdminWrapper'),
comms: src('./vats/comms'),
vattp: src('./vats/vat-tp'),
timer: src('./vats/vat-timerWrapper'),

lockdown: srcGE('./kernel/vatManager/lockdown-subprocess-xsnap.js'),
supervisor: srcGE('./kernel/vatManager/supervisor-subprocess-xsnap.js'),
kernel: src('../kernel/kernel.js'),
adminDevice: src('../devices/vat-admin/device-vat-admin.js'),
adminVat: src('../vats/vat-admin/vat-vat-admin.js'),
comms: src('../vats/comms/index.js'),
vattp: src('../vats/vattp/vat-vattp.js'),
timer: src('../vats/timer/vat-timer.js'),

lockdown: srcGE(
'../supervisors/subprocess-xsnap/lockdown-subprocess-xsnap.js',
),
supervisor: srcGE(
'../supervisors/subprocess-xsnap/supervisor-subprocess-xsnap.js',
),
});

return harden(bundles);
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/src/devices/bridge/bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function sanitize(data) {
}

export function buildBridge(outboundCallback) {
const srcPath = new URL('bridge-src.js', import.meta.url).pathname;
const srcPath = new URL('device-bridge.js', import.meta.url).pathname;
let inboundCallback;

function registerInboundCallback(inbound) {
Expand All @@ -115,7 +115,7 @@ export function buildBridge(outboundCallback) {
function callOutbound(...args) {
// TODO: prevent cross-Realm contamination by serializing/deserializing
// all the data that crosses this boundary. Inside the device
// (bridge-src.js), we know we're immediately serializaing this data, so
// (device-bridge.js), we know we're immediately serializaing this data, so
// we don't need to sanitize it there. But here, we have no idea what
// outboundCallback() might do, so we want to avoid confusion. When we
// switch to new-SES, we can remove this protection.
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/devices/bundle/device-bundle.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from '@agoric/assert';
import { buildSerializationTools } from '../deviceTools.js';
import { buildSerializationTools } from '../lib/deviceTools.js';

/*
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/devices/command/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { assert, details as X } from '@agoric/assert';
export default function buildCommand(broadcastCallback) {
assert(broadcastCallback, X`broadcastCallback must be provided.`);
let inboundCallback;
const srcPath = new URL('command-src.js', import.meta.url).pathname;
const srcPath = new URL('device-command.js', import.meta.url).pathname;
let nextCount = 0n;
const responses = new Map();

Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/src/devices/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Export all the default exports of the driver top-halves.
export { buildMailboxStateMap, buildMailbox } from './mailbox';
export { buildTimer } from './timer';
export { buildMailboxStateMap, buildMailbox } from './mailbox/mailbox.js';
export { buildTimer } from './timer/timer.js';
2 changes: 1 addition & 1 deletion packages/SwingSet/src/devices/lib/deviceTools.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert, details as X } from '@agoric/assert';
import { makeMarshal, Far } from '@endo/marshal';
import { parseVatSlot } from './parseVatSlots.js';
import { parseVatSlot } from '../../lib/parseVatSlots.js';

// raw devices can use this to build a set of convenience tools for
// serialization/unserialization
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/devices/loopbox/loopbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function buildLoopbox(deliverMode) {
deliverMode === 'immediate' || deliverMode === 'queued',
X`deliverMode=${deliverMode}, must be 'immediate' or 'queued'`,
);
const loopboxSrcPath = new URL('loopbox-src', import.meta.url).pathname;
const loopboxSrcPath = new URL('device-loopbox.js', import.meta.url).pathname;

let loopboxPassOneMessage;
function registerPassOneMessage(lpom) {
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/devices/mailbox/device-mailbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function buildRootDeviceNode(tools) {
// the host
let { inboundHandler } = getDeviceState() || {};

// console.debug(`mailbox-src build: inboundHandler is`, inboundHandler);
// console.debug(`device-mailbox build: inboundHandler is`, inboundHandler);
deliverInboundMessages = (peer, newMessages) => {
assert(
inboundHandler,
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/devices/mailbox/mailbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export function buildMailboxStateMap(state = harden(new Map())) {
}

export function buildMailbox(state) {
const srcPath = new URL('mailbox-src', import.meta.url).pathname;
const srcPath = new URL('device-mailbox.js', import.meta.url).pathname;

// endowments made available to the inner half
let inboundCallback;
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/devices/plugin/plugin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export function buildPlugin(pluginDir, importPlugin, queueThunkForKernel) {
const srcPath = new URL('plugin-src', import.meta.url).pathname;
const srcPath = new URL('device-plugin.js', import.meta.url).pathname;
let resetter;

function reset() {
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/devices/timer/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { assert, details as X } from '@agoric/assert';
* controller.run() when it returns true.
*/
export function buildTimer() {
const srcPath = new URL('timer-src', import.meta.url).pathname;
const srcPath = new URL('./device-timer.js', import.meta.url).pathname;
let devicePollFunction;

function registerDevicePollFunction(pollFn) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
import { Nat } from '@agoric/nat';
import { assert } from '@agoric/assert';
import { buildSerializationTools } from '../../deviceTools.js';
import { buildSerializationTools } from '../lib/deviceTools.js';

/*
Expand Down
20 changes: 13 additions & 7 deletions packages/SwingSet/src/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
export { buildVatController, makeSwingsetController } from './controller.js';
export {
buildVatController,
makeSwingsetController,
} from './controller/controller.js';
export {
swingsetIsInitialized,
initializeSwingset,
buildKernelBundles,
loadBasedir,
loadSwingsetConfigFile,
} from './initializeSwingset.js';
} from './controller/initializeSwingset.js';

export { buildMailboxStateMap, buildMailbox } from './devices/mailbox.js';
export { buildTimer } from './devices/timer.js';
export { buildBridge } from './devices/bridge.js';
export { default as buildCommand } from './devices/command.js';
export { buildPlugin } from './devices/plugin.js';
export {
buildMailboxStateMap,
buildMailbox,
} from './devices/mailbox/mailbox.js';
export { buildTimer } from './devices/timer/timer.js';
export { buildBridge } from './devices/bridge/bridge.js';
export { default as buildCommand } from './devices/command/command.js';
export { buildPlugin } from './devices/plugin/plugin.js';

// eslint-disable-next-line import/export
export * from './types-exported.js';
2 changes: 1 addition & 1 deletion packages/SwingSet/src/kernel/cleanup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// import { kdebug } from './kdebug.js';
// import { kdebug } from '../lib/kdebug.js';
import { parseKernelSlot } from './parseKernelSlots.js';

export function getKpidsToRetire(kernelKeeper, rootKPID, rootKernelData) {
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/kernel/deviceManager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
import { assert } from '@agoric/assert';
import { makeDeviceSlots } from './deviceSlots.js';
import { insistCapData } from '../capdata.js';
import { insistCapData } from '../lib/capdata.js';

import '../types.js';

Expand Down
8 changes: 6 additions & 2 deletions packages/SwingSet/src/kernel/deviceSlots.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// @ts-check
import { Remotable, passStyleOf, makeMarshal } from '@endo/marshal';
import { assert, details as X } from '@agoric/assert';
import { insistVatType, makeVatSlot, parseVatSlot } from '../parseVatSlots.js';
import { insistCapData } from '../capdata.js';
import {
insistVatType,
makeVatSlot,
parseVatSlot,
} from '../lib/parseVatSlots.js';
import { insistCapData } from '../lib/capdata.js';

// 'makeDeviceSlots' is a subset of makeLiveSlots, for device code

Expand Down
8 changes: 4 additions & 4 deletions packages/SwingSet/src/kernel/deviceTranslator.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { assert, details as X } from '@agoric/assert';
import { insistMessage } from '../message.js';
import { insistMessage } from '../lib/message.js';
import { insistKernelType } from './parseKernelSlots.js';
import { insistVatType, parseVatSlot } from '../parseVatSlots.js';
import { insistCapData } from '../capdata.js';
import { kdebug } from './kdebug.js';
import { insistVatType, parseVatSlot } from '../lib/parseVatSlots.js';
import { insistCapData } from '../lib/capdata.js';
import { kdebug } from '../lib/kdebug.js';
import { assertValidVatstoreKey } from './vatTranslator.js';

/*
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/kernel/gc-actions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert } from '@agoric/assert';
import { insistKernelType } from './parseKernelSlots.js';
import { insistVatID } from './id.js';
import { insistVatID } from '../lib/id.js';

const typePriority = ['dropExport', 'retireExport', 'retireImport'];

Expand Down
21 changes: 10 additions & 11 deletions packages/SwingSet/src/kernel/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,25 @@
import { assert, details as X } from '@agoric/assert';
import { importBundle } from '@endo/import-bundle';
import { stringify } from '@endo/marshal';
import { assertKnownOptions } from '../assertOptions.js';
import { foreverPolicy } from '../runPolicies.js';
import { makeVatManagerFactory } from './vatManager/factory.js';
import { makeVatWarehouse } from './vatManager/vat-warehouse.js';
import { assertKnownOptions } from '../lib/assertOptions.js';
import { foreverPolicy } from '../lib/runPolicies.js';
import { makeVatManagerFactory } from './vat-loader/manager-factory.js';
import { makeVatWarehouse } from './vat-warehouse.js';
import makeDeviceManager from './deviceManager.js';
import makeKernelKeeper from './state/kernelKeeper.js';
import { kdebug, kdebugEnable, legibilizeMessageArgs } from './kdebug.js';
import { kdebug, kdebugEnable, legibilizeMessageArgs } from '../lib/kdebug.js';
import { insistKernelType, parseKernelSlot } from './parseKernelSlots.js';
import { parseVatSlot } from '../parseVatSlots.js';
import { insistCapData } from '../capdata.js';
import { insistMessage, insistVatDeliveryResult } from '../message.js';
import { insistDeviceID, insistVatID } from './id.js';
import { parseVatSlot } from '../lib/parseVatSlots.js';
import { insistCapData } from '../lib/capdata.js';
import { insistMessage, insistVatDeliveryResult } from '../lib/message.js';
import { insistDeviceID, insistVatID } from '../lib/id.js';
import { makeKernelQueueHandler } from './kernelQueue.js';
import { makeKernelSyscallHandler } from './kernelSyscall.js';
import { makeSlogger, makeDummySlogger } from './slogger.js';
import { makeDummyMeterControl } from './dummyMeterControl.js';
import { getKpidsToRetire } from './cleanup.js';
import { processNextGCAction } from './gc-actions.js';

import { makeVatLoader } from './loadVat.js';
import { makeVatLoader } from './vat-loader/vat-loader.js';
import { makeDeviceTranslators } from './deviceTranslator.js';
import { notifyTermination } from './notifyTermination.js';

Expand Down
Loading

0 comments on commit 675e665

Please sign in to comment.