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

passStyleOf endowment should be inescapable #9981

Closed
gibson042 opened this issue Aug 27, 2024 · 1 comment · Fixed by #10005
Closed

passStyleOf endowment should be inescapable #9981

gibson042 opened this issue Aug 27, 2024 · 1 comment · Fixed by #10005
Assignees
Labels
enhancement New feature or request

Comments

@gibson042
Copy link
Member

What is the Problem Being Solved?

#9874 updated liveslots to endow its child compartment global object with passStyleOf via a property keyed on a @endo passStyleOf symbol reserved this purpose, but @erights points out that ZCF probably uses a child compartment of its own, which should also have the same endowment.

Description of the Design

Updating packages/swingset-liveslots/src/liveslots.js to declare [PassStyleOfEndowmentSymbol]: passStyleOf in inescapableGlobalProperties rather than vatGlobals should ensure that all descendant compartments get the endowment and can import a passStyleOf that will use it rather than build on top of the virtual-object-aware WeakMap.

Security Considerations

We already convinced ourselves that such an endowment is safe.

Scaling Considerations

This will provide the same benefits to contracts that are already anticipated for non-contract vats such as Zoe.

Test Plan

Performance measurement is highly desired if feasible.

Upgrade Considerations

Contracts will not get the benefits until upgrade to a version whose bundle includes an endowment-aware passStyleOf, or restart with a bundle that already includes it.

@gibson042 gibson042 added the enhancement New feature or request label Aug 27, 2024
warner added a commit that referenced this issue Aug 30, 2024
…Properties

Previously, liveslots added the special `PassStyleOfEndowmentSymbol`
on `vatGlobals`. This enabled the first-level vat bundle (the one that
defines buildRootObject, e.g. ZCF) to use the same passStyleOf as
liveslots is using, with a real WeakMap for its memoization cache.

However, child Compartments of that vat, such as the ones contract
bundles are loaded into, do not automatically get the same global, and
ZCF does not pass any special options to `importBundle()`, which would
enable that.

This commit attaches the symbol to `inescapableGlobalProperties`,
rather than `vatGlobals`. Those properties are automatically (indeed
unavoidably) copied onto the `globalThis` of each child Compartment,
recursively. This is stronger than we need: we're ok with a
Compartment choosing to omit or change this property.

This allows contract code which does `import { passStyleOf } from
'@endo/pass-style'` to get the correct/fast/cheap version too.

fixes #9981
@warner warner assigned warner and unassigned erights and gibson042 Aug 30, 2024
@warner
Copy link
Member

warner commented Aug 30, 2024

stealing this one, I've got a patch

warner added a commit that referenced this issue Aug 30, 2024
…Properties

Previously, liveslots added the special `PassStyleOfEndowmentSymbol`
on `vatGlobals`. This enabled the first-level vat bundle (the one that
defines buildRootObject, e.g. ZCF) to use the same passStyleOf as
liveslots is using, with a real WeakMap for its memoization cache.

However, child Compartments of that vat, such as the ones contract
bundles are loaded into, do not automatically get the same global, and
ZCF does not pass any special options to `importBundle()`, which would
enable that.

This commit attaches the symbol to `inescapableGlobalProperties`,
rather than `vatGlobals`. Those properties are automatically (indeed
unavoidably) copied onto the `globalThis` of each child Compartment,
recursively. This is stronger than we need: we're ok with a
Compartment choosing to omit or change this property.

This allows contract code which does `import { passStyleOf } from
'@endo/pass-style'` to get the correct/fast/cheap version too.

Tests were added to liveslots to assert that it gives the expected
`inescapableGlobalProperties` option when asking the supervisor to
build the vat's namespace, and to SwingSet to assert that both child
and grandchild Compartments get the expected version of
passStyleOf (which was not the case for mere `vatGlobals`).

fixes #9981
@mergify mergify bot closed this as completed in #10005 Aug 31, 2024
mergify bot added a commit that referenced this issue Aug 31, 2024
…Properties (#10005)

Previously, liveslots added the special `PassStyleOfEndowmentSymbol` on `vatGlobals`. This enabled the first-level vat bundle (the one that defines buildRootObject, e.g. ZCF) to use the same passStyleOf as liveslots is using, with a real WeakMap for its memoization cache.

However, child Compartments of that vat, such as the ones contract bundles are loaded into, do not automatically get the same global, and ZCF does not pass any special options to `importBundle()`, which would enable that.

This commit attaches the symbol to `inescapableGlobalProperties`, rather than `vatGlobals`. Those properties are automatically (indeed unavoidably) copied onto the `globalThis` of each child Compartment, recursively. This is stronger than we need: we're ok with a Compartment choosing to omit or change this property.

This allows contract code which does `import { passStyleOf } from '@endo/pass-style'` to get the correct/fast/cheap version too.

fixes #9981
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants