Skip to content

Commit

Permalink
fix: pass through the entire marshal stack to the vat
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Sep 16, 2020
1 parent b4a1be8 commit f93c26b
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/SwingSet/src/kernel/liveSlots.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ export function makeLiveSlots(
state,
buildRootObject,
forVatID,
{ ...vatPowers, getInterfaceOf, Remotable },
{ ...vatPowers, getInterfaceOf, Remotable, makeMarshal },
vatParameters,
);
return harden({
Expand Down
1 change: 1 addition & 0 deletions packages/SwingSet/src/kernel/vatManager/localVatManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function makeLocalVatManagerFactory(tools) {
const baseVP = {
Remotable: allVatPowers.Remotable,
getInterfaceOf: allVatPowers.getInterfaceOf,
makeMarshal: allVatPowers.makeMarshal,
transformTildot: allVatPowers.transformTildot,
};
const internalMeteringVP = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import anylogger from 'anylogger';

import { assert } from '@agoric/assert';
import { importBundle } from '@agoric/import-bundle';
import { Remotable, getInterfaceOf } from '@agoric/marshal';
import { Remotable, getInterfaceOf, makeMarshal } from '@agoric/marshal';
import { waitUntilQuiescent } from '../../waitUntilQuiescent';
import { makeLiveSlots } from '../liveSlots';

Expand Down Expand Up @@ -103,7 +103,7 @@ parentPort.on('message', ([type, ...margs]) => {
// vatPowers, but only if options tell us they're wanted. Maybe
// transformTildot should be async and outsourced to the kernel
// process/thread.
const vatPowers = { Remotable, getInterfaceOf };
const vatPowers = { Remotable, getInterfaceOf, makeMarshal };
dispatch = makeLiveSlots(
syscall,
state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Netstring from 'netstring-stream';

import { assert } from '@agoric/assert';
import { importBundle } from '@agoric/import-bundle';
import { Remotable, getInterfaceOf } from '@agoric/marshal';
import { Remotable, getInterfaceOf, makeMarshal } from '@agoric/marshal';
import { waitUntilQuiescent } from '../../waitUntilQuiescent';
import { makeLiveSlots } from '../liveSlots';

Expand Down Expand Up @@ -118,7 +118,7 @@ fromParent.on('data', data => {
// vatPowers, but only if options tell us they're wanted. Maybe
// transformTildot should be async and outsourced to the kernel
// process/thread.
const vatPowers = { Remotable, getInterfaceOf };
const vatPowers = { Remotable, getInterfaceOf, makeMarshal };
dispatch = makeLiveSlots(
syscall,
state,
Expand Down
10 changes: 9 additions & 1 deletion packages/captp/lib/captp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

// This logic was mostly lifted from @agoric/swingset-vat liveSlots.js
// Defects in it are mfig's fault.
import { Remotable, makeMarshal, QCLASS } from '@agoric/marshal';
import {
Remotable as defaultRemotable,
makeMarshal as defaultMakeMarshal,
QCLASS,
} from '@agoric/marshal';
import { E, HandledPromise } from '@agoric/eventual-send';
import { isPromise } from '@agoric/promise-kit';

Expand All @@ -13,6 +17,8 @@ export { E };
/**
* @typedef {Object} CapTPOptions the options to makeCapTP
* @property {(err: any) => void} onReject
* @property {typeof defaultRemotable} Remotable
* @property {typeof defaultMakeMarshal} makeMarshal
*/
/**
* Create a CapTP connection.
Expand All @@ -25,6 +31,8 @@ export { E };
export function makeCapTP(ourId, rawSend, bootstrapObj = undefined, opts = {}) {
const {
onReject = err => console.error('CapTP', ourId, 'exception:', err),
Remotable = defaultRemotable,
makeMarshal = defaultMakeMarshal,
} = opts;

let unplug = false;
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/lib/ag-solo/vats/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export function buildRootObject(vatPowers, vatParameters) {
// Needed for DApps, maybe for user clients.
const uploads = E(vats.uploads).getUploads();

const plugin = makePluginManager(E, D, devices.plugin);
const plugin = makePluginManager(E, devices.plugin, vatPowers);

// This will allow dApp developers to register in their api/deploy.js
const httpRegCallback = {
Expand Down
13 changes: 7 additions & 6 deletions packages/cosmic-swingset/lib/ag-solo/vats/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ import { makeCapTP } from '@agoric/captp';
/**
* Create a handler that manages a promise interface to external modules.
*
* @param {import('@agoric/eventual-send').EProxy} E The eventual sender
* @param {<T>(target: Device<T>) => T} D The device sender
* @param {Device<PluginDevice>} pluginDevice The bridge to manage
* @param {{ D<T>(target: Device<T>): T }} param1
* @returns {PluginManager} admin facet for this handler
*/
export function makePluginManager(E, D, pluginDevice) {
export function makePluginManager(pluginDevice, { D, ...vatPowers }) {
/**
* @type {import('@agoric/store').Store<number, (obj: Record<string,any>) => void>}
*/
Expand All @@ -44,7 +43,6 @@ export function makePluginManager(E, D, pluginDevice) {
D(pluginDevice).registerReceiver(
harden({
receive(index, obj) {
console.info('receive', index, obj);
modReceivers.get(index)(obj);
},
}),
Expand All @@ -58,8 +56,11 @@ export function makePluginManager(E, D, pluginDevice) {
throw Error(index);
}
// Create a CapTP channel.
const { getBootstrap, dispatch } = makeCapTP(mod, obj =>
D(pluginDevice).send(index, obj),
const { getBootstrap, dispatch } = makeCapTP(
mod,
obj => D(pluginDevice).send(index, obj),
undefined,
vatPowers,
);
// Register our dispatcher for this connect index.
modReceivers.init(index, dispatch);
Expand Down

0 comments on commit f93c26b

Please sign in to comment.