Skip to content

Commit

Permalink
fix(base-zone,zone): import isPassable from @endo/pass-style (#9230)
Browse files Browse the repository at this point in the history
closes: #XXXX
refs: endojs/endo#2096
endojs/endo#2042

## Description

Deleting @agoric/base-zone's implementation of `isPassable` completes
the migration of `isPassable` from @agoric/base-zone to @endo/pass-style
explained in endojs/endo#2096 and started in
endojs/endo#2042

The remaining issue explained in
endojs/endo#2096 , changing how `isPassable`
is implemented, remains to be done in @endo/pass-style. But this need no
longer concern us here since that difference will now be encapsulated
from us.

### Security Considerations
None
### Scaling Considerations

We know that `passStyleOf` remains a performance hotspot that needs
attention. This PR does not affect that at all. But I'll note that the
remaining suggested change from
endojs/endo#2096 --- to implement `isPassable`
and `passStyleOf` in terms of a more expressive internal function
parameterized by a checker --- might make this performance issue worse.
Just something to keep in mind as we tune `passStyleOf`. Attn @gibson042

### Documentation Considerations

none
### Testing Considerations

none
### Upgrade Considerations

As of this PR, @agoric/base-zone also no longer exports `isPassable`,
potentially breaking importers outside agoric-sdk until they are
modified to import it from @endo/pass-style as well. This PR does take
care of all such import sites within agoric-sdk.

If this turns out to be a problem in practice, this PR could be changed
to have @agoric/base-zone reexport the `isPassable` it imports from
@endo/pass-style, but deprecate that reexport, leaving it to future work
to change those old import sites outside agoric-sdk.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
erights and mergify[bot] committed Apr 30, 2024
1 parent d15cb41 commit fbd8633
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 32 deletions.
3 changes: 1 addition & 2 deletions packages/base-zone/src/heap.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
// @jessie-check

import { Far } from '@endo/far';
import { Far, isPassable } from '@endo/pass-style';
import { makeExo, defineExoClass, defineExoClassKit } from '@endo/exo';
import {
makeScalarMapStore,
Expand All @@ -12,7 +12,6 @@ import {

import { makeOnceKit } from './make-once.js';
import { agoricVatDataKeys as keys } from './keys.js';
import { isPassable } from './is-passable.js';

/**
* @type {import('./types.js').Stores}
Expand Down
21 changes: 3 additions & 18 deletions packages/base-zone/src/is-passable.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
import { passStyleOf } from '@endo/pass-style';
import { isPassable as realIsPassable } from '@endo/pass-style';

/**
* Is `specimen` Passable? This returns true iff `passStyleOf(specimen)`
* returns a string. This returns `false` iff `passStyleOf(specimen)` throws.
* Under no normal circumstance should `isPassable(specimen)` throw.
*
* TODO implement an isPassable that does not rely on try/catch, and
* move it to @endo/pass-style.
* This implementation is just a standin until then
*
* @deprecated Import `isPassable` directly from `@endo/pass-style`
* @param {any} specimen
* @returns {specimen is Passable}
*/
export const isPassable = specimen => {
try {
// In fact, it never returns undefined. It either returns a
// string or throws.
return passStyleOf(specimen) !== undefined;
} catch (_) {
return false;
}
};
export const isPassable = specimen => realIsPassable(specimen);
8 changes: 2 additions & 6 deletions packages/zone/src/durable.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
// @jessie-check

import { Far } from '@endo/far';
import { Far, isPassable } from '@endo/pass-style';
import {
canBeDurable,
makeScalarMapStore,
Expand All @@ -14,11 +14,7 @@ import {
provideDurableWeakSetStore,
} from '@agoric/vat-data';

import {
agoricVatDataKeys as keys,
isPassable,
makeOnceKit,
} from '@agoric/base-zone';
import { agoricVatDataKeys as keys, makeOnceKit } from '@agoric/base-zone';

const { Fail } = assert;

Expand Down
8 changes: 2 additions & 6 deletions packages/zone/src/virtual.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
// @jessie-check

import { Far } from '@endo/far';
import { Far, isPassable } from '@endo/pass-style';
import {
defineVirtualExoClass,
defineVirtualExoClassKit,
Expand All @@ -11,11 +11,7 @@ import {
makeScalarBigWeakSetStore,
} from '@agoric/vat-data';

import {
agoricVatDataKeys as keys,
isPassable,
makeOnceKit,
} from '@agoric/base-zone';
import { agoricVatDataKeys as keys, makeOnceKit } from '@agoric/base-zone';

const emptyRecord = harden({});
const initEmpty = harden(() => emptyRecord);
Expand Down

0 comments on commit fbd8633

Please sign in to comment.