Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix deviceslots to use same Presence mechanism as liveslots #1316

Closed
warner opened this issue Jul 20, 2020 · 1 comment
Closed

fix deviceslots to use same Presence mechanism as liveslots #1316

warner opened this issue Jul 20, 2020 · 1 comment
Labels
enhancement New feature or request SwingSet package: SwingSet
Milestone

Comments

@warner
Copy link
Member

warner commented Jul 20, 2020

What is the Problem Being Solved?

We noticed that deviceSlots.js is still using the old-fashioned way to construct Presences. Newer code (in liveSlots.js) uses HandledPromise mechanisms to create promise/presence pairs. One consequence is that the presence objects handed to device code have spurious extra debug properties:

function makePresence(id) {
return harden({
[`_importID_${id}`]() {},
});
}

This showed up in #1309 in some code which wanted to use an "options bag", which defaults to an empty object (which is pass-by-reference between vats, and shows up as a Presence). I was trying to guard against typos in the options by checking for unrecognized properties on the options bag:

function createVatDynamically(vatSourceBundle, options = {}) {
const { metered = true, ...unknownOptions } = options;
if (Object.keys(unknownOptions).length) {
const msg = JSON.stringify(Object.keys(unknownOptions));
throw Error(`createVatDynamically got unknown options ${msg}`);
}

When I had a vat method include an options={} default value, the device received a Presence, and handed an object with a _importID_NN property to this code, which triggered that check. The liveslots/HandledPromise approach would probably not have. I fixed the problem by removing the default from everywhere except the last step, so marshal is not being asked to pass empty objects when callers omit the options. But someone could easily run into this again later if the dynamic vat creation code gets refactored.

So the task is to update deviceSlots.js to use the same code as liveSlots.js. One potential wrinkle is that devices don't really support promises as well as regular vats, because they don't manage state in quite the same way (no transcript-replay -based orthogonal persistence).

We don't have a lot of devices, and they're only created/modified by a small set of people, so this is low-priority.

@warner
Copy link
Member Author

warner commented Jan 28, 2022

I'm no longer interested in doing this: I think raw devices (#1346) are the way to go.

@warner warner closed this as completed Jan 28, 2022
@Tartuffo Tartuffo added this to the Mainnet 1 milestone Mar 23, 2022
@Tartuffo Tartuffo modified the milestones: Mainnet 1, RUN Protocol RC0 Apr 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request SwingSet package: SwingSet
Projects
None yet
Development

No branches or pull requests

2 participants