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(liveslots): move passStyleOf from vatGlobals to inescapableGlobalProperties #10005

Merged
merged 1 commit into from
Aug 31, 2024

Conversation

warner
Copy link
Member

@warner warner commented Aug 30, 2024

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

Copy link

cloudflare-workers-and-pages bot commented Aug 30, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: e40a8b9
Status: ✅  Deploy successful!
Preview URL: https://8585e882.agoric-sdk.pages.dev
Branch Preview URL: https://warner-9981-passstyleof-ines.agoric-sdk.pages.dev

View logs

Copy link
Member

@erights erights left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM so far...

…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
@warner warner force-pushed the warner/9981-passStyleOf-inescapable-global branch from 4981bc0 to e40a8b9 Compare August 30, 2024 23:12
@warner warner marked this pull request as ready for review August 30, 2024 23:12
@warner warner added the automerge:rebase Automatically rebase updates, then merge label Aug 30, 2024
@mergify mergify bot merged commit 661af66 into master Aug 31, 2024
100 checks passed
@mergify mergify bot deleted the warner/9981-passStyleOf-inescapable-global branch August 31, 2024 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

passStyleOf endowment should be inescapable
3 participants