Skip to content

Commit

Permalink
refactor: give kmarshal its own package and remove duplicate implem…
Browse files Browse the repository at this point in the history
…entations
  • Loading branch information
FUDCo committed Oct 7, 2023
1 parent 3e909dc commit 21b185f
Show file tree
Hide file tree
Showing 98 changed files with 187 additions and 192 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test-all-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ jobs:
- name: yarn test (internal)
if: (success() || failure())
run: cd packages/internal && yarn ${{ steps.vars.outputs.test }} | $TEST_COLLECT
- name: yarn test (kmarshal)
if: (success() || failure())
run: cd packages/kmarshal && yarn ${{ steps.vars.outputs.test }} | $TEST_COLLECT
- name: yarn test (network)
if: (success() || failure())
run: cd packages/network && yarn ${{ steps.vars.outputs.test }} | $TEST_COLLECT
Expand Down
1 change: 1 addition & 0 deletions packages/SwingSet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"dependencies": {
"@agoric/assert": "^0.6.0",
"@agoric/internal": "^0.3.2",
"@agoric/kmarshal": "^0.1.0",
"@agoric/store": "^0.9.2",
"@agoric/swing-store": "^0.9.1",
"@agoric/swingset-liveslots": "^0.10.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/controller/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import engineGC from '@agoric/internal/src/lib-nodejs/engine-gc.js';
import { startSubprocessWorker } from '@agoric/internal/src/lib-nodejs/spawnSubprocessWorker.js';
import { waitUntilQuiescent } from '@agoric/internal/src/lib-nodejs/waitUntilQuiescent.js';
import { makeGcAndFinalize } from '@agoric/internal/src/lib-nodejs/gc-and-finalize.js';
import { kslot, krefOf } from '../lib/kmarshal.js';
import { kslot, krefOf } from '@agoric/kmarshal';
import { insistStorageAPI } from '../lib/storageAPI.js';
import {
buildKernelBundle,
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/controller/initializeKernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import { makeMarshal } from '@endo/marshal';
import { Far } from '@endo/far';
import { assert, Fail } from '@agoric/assert';
import { kser, kunser } from '@agoric/kmarshal';
import { assertKnownOptions } from '../lib/assertOptions.js';
import { insistVatID } from '../lib/id.js';
import { kser, kunser } from '../lib/kmarshal.js';
import { makeVatSlot } from '../lib/parseVatSlots.js';
import { insistStorageAPI } from '../lib/storageAPI.js';
import { makeVatOptionRecorder } from '../lib/recordVatOptions.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Nat } from '@endo/nat';
import { assert } from '@agoric/assert';
import { kunser } from '@agoric/kmarshal';
import { buildSerializationTools } from '../lib/deviceTools.js';
import { insistVatID } from '../../lib/id.js';
import { kunser } from '../../lib/kmarshal.js';

/*
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/kernel/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { assert, Fail } from '@agoric/assert';
import { isNat } from '@endo/nat';
import { importBundle } from '@endo/import-bundle';
import { makeUpgradeDisconnection } from '@agoric/internal/src/upgrade-api.js';
import { kser, kslot, makeError } from '@agoric/kmarshal';
import { assertKnownOptions } from '../lib/assertOptions.js';
import { foreverPolicy } from '../lib/runPolicies.js';
import { kser, kslot, makeError } from '../lib/kmarshal.js';
import { makeVatManagerFactory } from './vat-loader/manager-factory.js';
import { makeVatWarehouse } from './vat-warehouse.js';
import makeDeviceManager from './deviceManager.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/kernel/kernelQueue.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { kser } from '@agoric/kmarshal';
import { insistKernelType, parseKernelSlot } from './parseKernelSlots.js';
import { insistCapData } from '../lib/capdata.js';
import { insistMessage } from '../lib/message.js';
import { insistVatID } from '../lib/id.js';
import { kser } from '../lib/kmarshal.js';

/**
* @param {object} tools
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/kernel/notifyTermination.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { kunser } from '@agoric/kmarshal';
import { insistCapData } from '../lib/capdata.js';
import { kunser } from '../lib/kmarshal.js';

/**
* @param {string} vatID
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/kernel/vat-admin-hooks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert } from '@agoric/assert';
import { kser, kunser } from '@agoric/kmarshal';
import { insistVatID } from '../lib/id.js';
import { kser, kunser } from '../lib/kmarshal.js';

export function makeVatAdminHooks(tools) {
const { kernelKeeper, terminateVat } = tools;
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/lib/capdata.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Fail } from '@agoric/assert';
import { passStyleOf } from '@endo/far';
import { kunser, krefOf } from './kmarshal.js';
import { kunser, krefOf } from '@agoric/kmarshal';

/* eslint-disable jsdoc/require-returns-check */
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/lib/makeUndeliverableError.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// "data is not callable" error is kind of unique to the way swingset handles
// references, so we create a distinct error message.

import { kunser, kser } from './kmarshal.js';
import { kunser, kser } from '@agoric/kmarshal';

export function makeUndeliverableError(methargs) {
const method = kunser(methargs)[0];
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/vats/comms/controller.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Nat } from '@endo/nat';
import { assert, Fail } from '@agoric/assert';
import { kser, kunser, kslot, krefOf } from '../../lib/kmarshal.js';
import { kser, kunser, kslot, krefOf } from '@agoric/kmarshal';

// deliverToController() is used for local vats which want to talk to us as a
// vat, rather than as a conduit to talk to remote vats. The bootstrap
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/vats/comms/delivery.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* eslint-disable no-use-before-define */

import { assert, Fail } from '@agoric/assert';
import { kser } from '@agoric/kmarshal';
import { parseLocalSlot, insistLocalType } from './parseLocalSlots.js';
import { makeUndeliverableError } from '../../lib/makeUndeliverableError.js';
import { extractSingleSlot, insistCapData } from '../../lib/capdata.js';
import { insistRemoteType } from './parseRemoteSlot.js';
import { insistRemoteID } from './remote.js';
import { kser } from '../../lib/kmarshal.js';

export function makeDeliveryKit(
state,
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/src/vats/comms/dispatch.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { assert, Fail } from '@agoric/assert';
import { kser, kunser } from '@agoric/kmarshal';
import { makeVatSlot } from '../../lib/parseVatSlots.js';
import { insistMessage } from '../../lib/message.js';
import { makeState } from './state.js';
import { deliverToController } from './controller.js';
import { insistCapData } from '../../lib/capdata.js';
import { kser, kunser } from '../../lib/kmarshal.js';

import { makeCListKit } from './clist.js';
import { makeDeliveryKit } from './delivery.js';
Expand Down
3 changes: 1 addition & 2 deletions packages/SwingSet/test/bundling/test-bundles.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
// eslint-disable-next-line import/order
import { test } from '../../tools/prepare-test-env-ava.js';

// eslint-disable-next-line import/order
import fs from 'fs';
import bundleSource from '@endo/bundle-source';
import { assert } from '@agoric/assert';
import { kunser, krefOf } from '@agoric/kmarshal';
import { initSwingStore } from '@agoric/swing-store';
import { initializeSwingset, makeSwingsetController } from '../../src/index.js';
import { kunser, krefOf } from '../../src/lib/kmarshal.js';

function bfile(name) {
return new URL(name, import.meta.url).pathname;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
// eslint-disable-next-line import/order
import { test } from '../../tools/prepare-test-env-ava.js';

// eslint-disable-next-line import/order
import { assert } from '@agoric/assert';
import { kunser } from '@agoric/kmarshal';
import { initSwingStore } from '@agoric/swing-store';
import { initializeSwingset, makeSwingsetController } from '../../src/index.js';
import { kunser } from '../../src/lib/kmarshal.js';

function bfile(name) {
return new URL(name, import.meta.url).pathname;
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/commsVatDriver.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// @ts-nocheck
import { assert, Fail } from '@agoric/assert';
import { kslot, kser } from '@agoric/kmarshal';
import buildCommsDispatch from '../src/vats/comms/index.js';
import { debugState } from '../src/vats/comms/dispatch.js';
import { flipRemoteSlot } from '../src/vats/comms/parseRemoteSlot.js';
import { makeMessage, makeResolutions } from './util.js';
import { kslot, kser } from '../src/lib/kmarshal.js';

// This module provides a power tool for testing the comms vat implementation.
// It provides support for injecting events into the comms vat and observing
Expand Down
3 changes: 2 additions & 1 deletion packages/SwingSet/test/definition/test-vat-definition.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { test } from '../../tools/prepare-test-env-ava.js';

// eslint-disable-next-line import/order
import { kser } from '@agoric/kmarshal';
import { buildVatController } from '../../src/index.js';
import { kser } from '../../src/lib/kmarshal.js';

test('create with setup and buildRootObject', async t => {
const config = {
Expand Down
3 changes: 1 addition & 2 deletions packages/SwingSet/test/device-hooks/test-device-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
// eslint-disable-next-line import/order
import { test } from '../../tools/prepare-test-env-ava.js';

// eslint-disable-next-line import/order
import bundleSource from '@endo/bundle-source';
import { kunser, kser, kslot } from '@agoric/kmarshal';
import { initSwingStore } from '@agoric/swing-store';

import {
initializeSwingset,
makeSwingsetController,
buildKernelBundles,
} from '../../src/index.js';
import { kunser, kser, kslot } from '../../src/lib/kmarshal.js';

function dfile(name) {
return new URL(`./${name}`, import.meta.url).pathname;
Expand Down
5 changes: 2 additions & 3 deletions packages/SwingSet/test/device-mailbox/test-device-mailbox.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// @ts-nocheck
// eslint-disable-next-line import/order
import { test } from '../../tools/prepare-test-env-ava.js';
// eslint-disable-next-line import/order
import bundleSource from '@endo/bundle-source';

import bundleSource from '@endo/bundle-source';
import { kunser } from '@agoric/kmarshal';
import { initSwingStore } from '@agoric/swing-store';
import {
initializeSwingset,
Expand All @@ -15,7 +15,6 @@ import {
buildMailbox,
} from '../../src/devices/mailbox/mailbox.js';
import { bundleOpts } from '../util.js';
import { kunser } from '../../src/lib/kmarshal.js';

test.before(async t => {
const kernelBundles = await buildKernelBundles();
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/devices/bootstrap-1.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Fail } from '@agoric/assert';
import { kser, kunser, krefOf } from '@agoric/kmarshal';
import { extractMessage } from '../vat-util.js';
import { kser, kunser, krefOf } from '../../src/lib/kmarshal.js';

export default function setup(syscall, state, _helpers, vatPowers) {
const { testLog } = vatPowers;
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/devices/bootstrap-4.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { kunser, kser, kslot, krefOf } from '@agoric/kmarshal';
import { insistVatType } from '../../src/lib/parseVatSlots.js';
import { extractMessage } from '../vat-util.js';
import { kunser, kser, kslot, krefOf } from '../../src/lib/kmarshal.js';

// to exercise the error we get when syscall.callNow() is given a promise
// identifier, we must bypass liveslots, which would otherwise protect us
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/test/devices/test-devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import { test } from '../../tools/prepare-test-env-ava.js';

import bundleSource from '@endo/bundle-source';
import { initSwingStore } from '@agoric/swing-store';
import { parse } from '@endo/marshal';
import { kser, kslot } from '@agoric/kmarshal';
import { initSwingStore } from '@agoric/swing-store';

import {
initializeSwingset,
Expand All @@ -13,7 +14,6 @@ import {
} from '../../src/index.js';
import buildCommand from '../../src/devices/command/command.js';
import { bundleOpts, vstr } from '../util.js';
import { kser, kslot } from '../../src/lib/kmarshal.js';

function dfile(name) {
return new URL(`./${name}`, import.meta.url).pathname;
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/devices/test-raw-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { test } from '../../tools/prepare-test-env-ava.js';
// eslint-disable-next-line import/order
import bundleSource from '@endo/bundle-source';
import { initSwingStore } from '@agoric/swing-store';
import { kunser } from '../../src/lib/kmarshal.js';
import { kunser } from '@agoric/kmarshal';

import {
initializeSwingset,
Expand Down
3 changes: 1 addition & 2 deletions packages/SwingSet/test/metering/test-dynamic-vat-metered.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
// eslint-disable-next-line import/order
import { test } from '../../tools/prepare-test-env-ava.js';

// eslint-disable-next-line import/order
import bundleSource from '@endo/bundle-source';
import { kunser, krefOf } from '@agoric/kmarshal';
import { initSwingStore } from '@agoric/swing-store';
import { buildKernelBundles, buildVatController } from '../../src/index.js';
import { restartVatAdminVat } from '../util.js';
import { kunser, krefOf } from '../../src/lib/kmarshal.js';
import { enumeratePrefixedKeys } from '../../src/kernel/state/storageHelper.js';

async function prepare() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// eslint-disable-next-line import/order
import { test } from '../../tools/prepare-test-env-ava.js';

// eslint-disable-next-line import/order
import { kunser } from '@agoric/kmarshal';
import { buildVatController } from '../../src/index.js';
import { kunser } from '../../src/lib/kmarshal.js';

// Dynamic vats are created without metering by default

Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/test/run-policy/test-run-policy.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// @ts-nocheck
// eslint-disable-next-line import/order
import { test } from '../../tools/prepare-test-env-ava.js';

// eslint-disable-next-line import/order
import { kslot, kser } from '@agoric/kmarshal';
import { initSwingStore } from '@agoric/swing-store';
import { initializeSwingset, makeSwingsetController } from '../../src/index.js';
import {
crankCounter,
computronCounter,
wallClockWaiter,
} from '../../src/lib/runPolicies.js';
import { kslot, kser } from '../../src/lib/kmarshal.js';

async function testCranks(t, mode) {
/** @type {SwingSetConfig} */
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/test/test-abandon-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import buildKernel from '../src/kernel/index.js';
import { initializeKernel } from '../src/controller/initializeKernel.js';
import { extractMethod } from '../src/lib/kdebug.js';
import { makeKernelEndowments, buildDispatch } from './util.js';
import { kser, kunser, kslot } from '../src/lib/kmarshal.js';
import { kser, kunser, kslot } from '@agoric/kmarshal';

const makeKernel = async () => {
const endowments = makeKernelEndowments();
Expand Down
4 changes: 2 additions & 2 deletions packages/SwingSet/test/test-comms.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// @ts-nocheck
// eslint-disable-next-line import/order
import { test } from '../tools/prepare-test-env-ava.js';

// eslint-disable-next-line import/order
import { kser, kslot } from '@agoric/kmarshal';
import buildCommsDispatch from '../src/vats/comms/index.js';
import { flipRemoteSlot } from '../src/vats/comms/parseRemoteSlot.js';
import { makeState } from '../src/vats/comms/state.js';
Expand All @@ -15,7 +16,6 @@ import {
makeRetireImports,
} from './util.js';
import { commsVatDriver } from './commsVatDriver.js';
import { kser, kslot } from '../src/lib/kmarshal.js';

test('translation', t => {
const s = makeState(null);
Expand Down
3 changes: 1 addition & 2 deletions packages/SwingSet/test/test-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// eslint-disable-next-line import/order
import { test } from '../tools/prepare-test-env-ava.js';

// eslint-disable-next-line import/order
import { spawn } from 'child_process';
import { kser, kunser, kslot } from '@agoric/kmarshal';
import { initSwingStore } from '@agoric/swing-store';
import {
buildVatController,
Expand All @@ -12,7 +12,6 @@ import {
makeSwingsetController,
} from '../src/index.js';
import { checkKT } from './util.js';
import { kser, kunser, kslot } from '../src/lib/kmarshal.js';

const emptyVP = kser({});

Expand Down
3 changes: 2 additions & 1 deletion packages/SwingSet/test/test-exomessages.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { test } from '../tools/prepare-test-env-ava.js';

// eslint-disable-next-line import/order
import { kunser, kslot, krefOf } from '@agoric/kmarshal';
import { buildVatController } from '../src/index.js';
import { kunser, kslot, krefOf } from '../src/lib/kmarshal.js';

async function beginning(t, mode) {
const config = {
Expand Down
3 changes: 1 addition & 2 deletions packages/SwingSet/test/test-gc-kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import anylogger from 'anylogger';
// eslint-disable-next-line import/order
import { test } from '../tools/prepare-test-env-ava.js';

// eslint-disable-next-line import/order
import { assert } from '@agoric/assert';
import { kser, kunser, kslot } from '@agoric/kmarshal';
import { initSwingStore } from '@agoric/swing-store';
import { waitUntilQuiescent } from '@agoric/internal/src/lib-nodejs/waitUntilQuiescent.js';
import { parseVatSlot } from '../src/lib/parseVatSlots.js';
Expand All @@ -24,7 +24,6 @@ import {
makeRetireExports,
makeRetireImports,
} from './util.js';
import { kser, kunser, kslot } from '../src/lib/kmarshal.js';

function makeConsole(tag) {
const log = anylogger(tag);
Expand Down
3 changes: 1 addition & 2 deletions packages/SwingSet/test/test-kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
// eslint-disable-next-line import/order
import { test } from '../tools/prepare-test-env-ava.js';

// eslint-disable-next-line import/order
import { Fail } from '@agoric/assert';
import { kser, kslot } from '@agoric/kmarshal';
import buildKernel from '../src/kernel/index.js';
import { initializeKernel } from '../src/controller/initializeKernel.js';
import { makeVatSlot } from '../src/lib/parseVatSlots.js';
import { checkKT, extractMessage, makeKernelEndowments } from './util.js';
import { kser, kslot } from '../src/lib/kmarshal.js';

function oneResolution(promiseID, rejected, data) {
return [[promiseID, rejected, data]];
Expand Down
Loading

0 comments on commit 21b185f

Please sign in to comment.