Skip to content

Commit

Permalink
fix(swingset): remove Far/Remotable/getInterfaceOf from vatPowers
Browse files Browse the repository at this point in the history
Vat code should import these three from `@agoric/marshal` rather than pulling
them from `vatPowers`.

closes #2637
  • Loading branch information
warner committed Mar 15, 2021
1 parent aaa0a39 commit c19a941
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 36 deletions.
10 changes: 0 additions & 10 deletions packages/SwingSet/docs/static-vats.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ A few vats do not use liveslots. The main one is the "comms vat", which performs

Static vats currently receive the following objects in their `buildRootObject()`'s sole `vatPowers` argument:

* `Remotable`
* `getInterfaceOf`
* `makeGetMeter`
* `transformMetering`
* `transformTildot`
Expand All @@ -73,14 +71,6 @@ Static vats currently receive the following objects in their `buildRootObject()`

(dynamic vats do not get `makeGetMeter` or `transformMetering`)

### marshalling: `Remotable` and `getInterfaceOf`

Messages sent between vats include arguments (and return values) which are serialized with `@agoric/marshal`. This marshalling library makes a distinction between plain data, and "remotable objects". Data is merely copied, but remotables arrive as a *Presence*, to which messages can be sent, with e.g. `counter~.increment()`.

Objects which are frozen, and whose enumerable properties are all functions, will automatically qualify as remotable. In addition, vats can use `Remotable()` to create new remotable objects with a particular "interface" name, as well as other properties. The interface name can be retrieved with `getInterfaceOf`.

This functionality is still in development. See https://github.com/Agoric/agoric-sdk/issues/804 for details.

### metering: `makeGetMeter`, `transformMetering`

Static vats are, for now, allowed to apply metering enforcement within their own walls. These vat powers provide the tools they need to do this. `makeGetMeter` returns a new `getMeter` function and a collection of functions to check and refill the meter it wraps. `transformMetering` takes a string of code and returns a new string into which metering code has been injected. By including `getMeter` in the `endowments` of a new `Compartment`, and adding `transformMetering` in the `transforms` of that compartment, vats can impose metering limits on other code evaluated inside the new compartment. When the meter runs out, the code subject to that meter starts throwing exceptions (which it cannot catch itself), and keeps throwing them until the meter is refilled.
Expand Down
15 changes: 5 additions & 10 deletions packages/SwingSet/src/kernel/kernel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Remotable, getInterfaceOf } from '@agoric/marshal';
import { assert, details as X } from '@agoric/assert';
import { importBundle } from '@agoric/import-bundle';
import { assertKnownOptions } from '../assertOptions';
Expand Down Expand Up @@ -188,17 +187,13 @@ export default function buildKernel(

// These will eventually be provided by the in-worker supervisor instead.

// We need to give the vat the correct Remotable and getKernelPromise so
// that they can access our own @agoric/marshal, not a separate instance in
// a bundle. TODO: ideally the powerless ones (Remotable, getInterfaceOf,
// maybe transformMetering) are imported by the vat, not passed in an
// argument. The powerful one (makeGetMeter) should only be given to the
// root object, to share with (or withhold from) other objects as it sees
// fit. TODO: makeGetMeter and transformMetering will go away
// TODO: ideally the powerless ones (maybe transformMetering) are imported
// by the vat, not passed in an argument. The powerful one (makeGetMeter)
// should only be given to the root object, to share with (or withhold
// from) other objects as it sees fit. TODO: makeGetMeter and
// transformMetering will go away

const allVatPowers = harden({
Remotable,
getInterfaceOf,
makeGetMeter: meterManager.makeGetMeter,
transformMetering: (...args) =>
meterManager.runWithoutGlobalMeter(transformMetering, ...args),
Expand Down
5 changes: 0 additions & 5 deletions packages/SwingSet/src/kernel/liveSlots.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import {
Remotable,
Far,
getInterfaceOf,
passStyleOf,
REMOTE_STYLE,
makeMarshal,
Expand Down Expand Up @@ -669,9 +667,6 @@ export function makeLiveSlots(
) {
const allVatPowers = {
...vatPowers,
getInterfaceOf,
Remotable,
Far,
makeMarshal,
};
const r = build(syscall, forVatID, cacheSize, allVatPowers, vatParameters);
Expand Down
2 changes: 0 additions & 2 deletions packages/SwingSet/src/kernel/vatManager/manager-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ export function makeLocalVatManagerFactory(tools) {
const { makeGetMeter, refillAllMeters, stopGlobalMeter } = meterManager;
const { WeakRef, FinalizationRegistry } = gcTools;
const baseVP = {
Remotable: allVatPowers.Remotable,
getInterfaceOf: allVatPowers.getInterfaceOf,
makeMarshal: allVatPowers.makeMarshal,
transformTildot: allVatPowers.transformTildot,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import anylogger from 'anylogger';

import { assert, details as X } from '@agoric/assert';
import { importBundle } from '@agoric/import-bundle';
import { Remotable, getInterfaceOf, makeMarshal } from '@agoric/marshal';
import { makeMarshal } from '@agoric/marshal';
import { WeakRef, FinalizationRegistry } from '../../weakref';
import { waitUntilQuiescent } from '../../waitUntilQuiescent';
import { makeLiveSlots } from '../liveSlots';
Expand Down Expand Up @@ -95,8 +95,6 @@ parentPort.on('message', ([type, ...margs]) => {
// transformTildot should be async and outsourced to the kernel
// process/thread.
const vatPowers = {
Remotable,
getInterfaceOf,
makeMarshal,
testLog,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import fs from 'fs';

import { assert, details as X } from '@agoric/assert';
import { importBundle } from '@agoric/import-bundle';
import { Remotable, getInterfaceOf, makeMarshal } from '@agoric/marshal';
import { makeMarshal } from '@agoric/marshal';
import { WeakRef, FinalizationRegistry } from '../../weakref';
import { arrayEncoderStream, arrayDecoderStream } from '../../worker-protocol';
import {
Expand Down Expand Up @@ -115,8 +115,6 @@ fromParent.on('data', ([type, ...margs]) => {
// transformTildot should be async and outsourced to the kernel
// process/thread.
const vatPowers = {
Remotable,
getInterfaceOf,
makeMarshal,
testLog,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @ts-check
import { assert, details as X } from '@agoric/assert';
import { importBundle } from '@agoric/import-bundle';
import { Remotable, getInterfaceOf, makeMarshal } from '@agoric/marshal';
import { makeMarshal } from '@agoric/marshal';
// grumble... waitUntilQuiescent is exported and closes over ambient authority
import { waitUntilQuiescent } from '../../waitUntilQuiescent';

Expand Down Expand Up @@ -210,8 +210,6 @@ function makeWorker(port) {
});

const vatPowers = {
Remotable,
getInterfaceOf,
makeMarshal,
transformTildot,
testLog: (...args) =>
Expand Down

0 comments on commit c19a941

Please sign in to comment.