Skip to content

Commit

Permalink
fix: Far and Remotable do unverified local marking rather than WeakMap (
Browse files Browse the repository at this point in the history
#2361)

* fix: Far and Remotable do unverified local marking rather than WeakMap
  • Loading branch information
erights authored Feb 14, 2021
1 parent 1eb65d4 commit ab59ab7
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 118 deletions.
11 changes: 8 additions & 3 deletions packages/SwingSet/src/kernel/deviceSlots.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Remotable, mustPassByPresence, makeMarshal } from '@agoric/marshal';
import {
Remotable,
passStyleOf,
REMOTE_STYLE,
makeMarshal,
} from '@agoric/marshal';
import { assert, details as X } from '@agoric/assert';
import { insistVatType, makeVatSlot, parseVatSlot } from '../parseVatSlots';
import { insistCapData } from '../capdata';
Expand Down Expand Up @@ -67,7 +72,7 @@ export function makeDeviceSlots(
if (!valToSlot.has(val)) {
// must be a new export
// lsdebug('must be a new export', JSON.stringify(val));
mustPassByPresence(val);
assert.equal(passStyleOf(val), REMOTE_STYLE);
const slot = exportPassByPresence();
parseVatSlot(slot); // assertion
valToSlot.set(val, slot);
Expand Down Expand Up @@ -167,7 +172,7 @@ export function makeDeviceSlots(
deviceParameters,
serialize: m.serialize, // We deliberately do not provide m.deserialize
});
mustPassByPresence(rootObject);
assert.equal(passStyleOf(rootObject), REMOTE_STYLE);

const rootSlot = makeVatSlot('device', true, 0);
valToSlot.set(rootObject, rootSlot);
Expand Down
7 changes: 4 additions & 3 deletions packages/SwingSet/src/kernel/liveSlots.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
Remotable,
Far,
getInterfaceOf,
mustPassByPresence,
passStyleOf,
REMOTE_STYLE,
makeMarshal,
} from '@agoric/marshal';
import { assert, details as X } from '@agoric/assert';
Expand Down Expand Up @@ -248,7 +249,7 @@ function build(syscall, forVatID, cacheSize, vatPowers, vatParameters) {
if (isPromise(val)) {
slot = exportPromise(val);
} else {
mustPassByPresence(val);
assert.equal(passStyleOf(val), REMOTE_STYLE);
slot = exportPassByPresence();
}
parseVatSlot(slot); // assertion
Expand Down Expand Up @@ -602,7 +603,7 @@ function build(syscall, forVatID, cacheSize, vatPowers, vatParameters) {
harden({ D, exitVat, exitVatWithFailure, ...vatPowers }),
harden(vatParameters),
);
mustPassByPresence(rootObject);
assert.equal(passStyleOf(rootObject), REMOTE_STYLE);

const rootSlot = makeVatSlot('object', true, 0);
valToSlot.set(rootObject, rootSlot);
Expand Down
6 changes: 3 additions & 3 deletions packages/dapp-svelte-wallet/api/test/test-lib-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ test('lib-wallet dapp suggests issuer, instance, installation petnames', async t
],
currentAmountSlots: {
body:
'{"brand":{"@qclass":"slot","iface":"Alleged: Zoe Invitation brand","index":0},"value":[{"description":"getRefund","handle":{"@qclass":"slot","index":1},"installation":{"@qclass":"slot","iface":"Alleged: Installation","index":2},"instance":{"@qclass":"slot","iface":"Alleged: InstanceHandle","index":3}}]}',
'{"brand":{"@qclass":"slot","iface":"Alleged: Zoe Invitation brand","index":0},"value":[{"description":"getRefund","handle":{"@qclass":"slot","iface":"Alleged: InvitationHandle","index":1},"installation":{"@qclass":"slot","iface":"Alleged: Installation","index":2},"instance":{"@qclass":"slot","iface":"Alleged: InstanceHandle","index":3}}]}',
slots: [
{ kind: 'brand', petname: 'zoe invite' },
{ kind: 'unnamed', petname: 'unnamed-4' },
Expand Down Expand Up @@ -412,7 +412,7 @@ test('lib-wallet dapp suggests issuer, instance, installation petnames', async t
],
currentAmountSlots: {
body:
'{"brand":{"@qclass":"slot","iface":"Alleged: Zoe Invitation brand","index":0},"value":[{"description":"getRefund","handle":{"@qclass":"slot","index":1},"installation":{"@qclass":"slot","iface":"Alleged: Installation","index":2},"instance":{"@qclass":"slot","iface":"Alleged: InstanceHandle","index":3}}]}',
'{"brand":{"@qclass":"slot","iface":"Alleged: Zoe Invitation brand","index":0},"value":[{"description":"getRefund","handle":{"@qclass":"slot","iface":"Alleged: InvitationHandle","index":1},"installation":{"@qclass":"slot","iface":"Alleged: Installation","index":2},"instance":{"@qclass":"slot","iface":"Alleged: InstanceHandle","index":3}}]}',
slots: [
{ kind: 'brand', petname: 'zoe invite' },
{ kind: 'unnamed', petname: 'unnamed-4' },
Expand Down Expand Up @@ -517,7 +517,7 @@ test('lib-wallet dapp suggests issuer, instance, installation petnames', async t
],
currentAmountSlots: {
body:
'{"brand":{"@qclass":"slot","iface":"Alleged: Zoe Invitation brand","index":0},"value":[{"description":"getRefund","handle":{"@qclass":"slot","index":1},"installation":{"@qclass":"slot","iface":"Alleged: Installation","index":2},"instance":{"@qclass":"slot","iface":"Alleged: InstanceHandle","index":3}}]}',
'{"brand":{"@qclass":"slot","iface":"Alleged: Zoe Invitation brand","index":0},"value":[{"description":"getRefund","handle":{"@qclass":"slot","iface":"Alleged: InvitationHandle","index":1},"installation":{"@qclass":"slot","iface":"Alleged: Installation","index":2},"instance":{"@qclass":"slot","iface":"Alleged: InstanceHandle","index":3}}]}',
slots: [
{ kind: 'brand', petname: 'zoe invite' },
{ kind: 'unnamed', petname: 'unnamed-4' },
Expand Down
2 changes: 0 additions & 2 deletions packages/marshal/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
export {
REMOTE_STYLE,
mustPassByPresence,
getInterfaceOf,
pureCopy,
QCLASS,
getErrorConstructor,
mustPassByRemote,
sameValueZero,
passStyleOf,
makeMarshal,
Expand Down
Loading

0 comments on commit ab59ab7

Please sign in to comment.