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

Heap zone enforce passable state and state shape #10170

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mhofman
Copy link
Member

@mhofman mhofman commented Sep 30, 2024

refs: endojs/endo#1648

Description

Check heap exo state to be passable and match any stateShape provided. Implements the checks by wrapping the endo defineExo functions to replace their init function with one that creates state accessors similar to the ones created by liveslots.

This likely should move into Endo itself

Security Considerations

Enforces previously ignored invariants of exos

Scaling Considerations

Similar to liveslots, exo classes (and kits) share a prototype object. If a state shape is provided, the accessors are created on that prototype.

To avoid WeakMap costs, the state when using a shape uses a private field to hold the data.

Documentation Considerations

This is a breaking change in the sense that some stated invariants of exo / zone were not actually enforced. Some tests seemed to be relying on this lack of enforcement.

Testing Considerations

Trivial updates of breaking tests

TODO: add thorough checking of exo state accessors

Verify that the checks done here are consistent with the checks done by liveslots. In particular an exo without state shape may not accept state values that are not first explicitly hardened?

Upgrade Considerations

This updates the code of @agoric/base-zone package. While this package is depended on by a broad number of other packages, either directly or transitively through @agoric/zone, heap zones are only part of contract bundles, and not part of liveslots or zcf (TODO: check this).

A contract has to opt-in to this breaking change by using a new version of @agoric/base-zone when updating. Since only heap state is affected, there is no particular risk regarding upgrading beyond what the package would do to update its dependencies.

Copy link

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

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: ec8191b
Status: ✅  Deploy successful!
Preview URL: https://6012ebe0.agoric-sdk.pages.dev
Branch Preview URL: https://mhofman-endo-1648-heap-zone.agoric-sdk.pages.dev

View logs

@mhofman mhofman added the force:integration Force integration tests to run on PR label Sep 30, 2024
@mhofman mhofman changed the base branch from master to mhofman/passable-exo-state October 5, 2024 01:08
@mhofman mhofman mentioned this pull request Oct 5, 2024
@mhofman mhofman force-pushed the mhofman/endo-1648-heap-zone-state-checks branch from 6f5c965 to 48bfbfb Compare October 5, 2024 01:22
mergify bot added a commit that referenced this pull request Oct 5, 2024
refs: #10170 
refs: endojs/endo#1648

best reviewed by ignoring white space

## Description
After implementing a change to enforce that heap exo are passable, I found that some things currently stored in heap exos, mostly in tests, are not actually passable. Almost all of them are remotable like objects not marked as `Far`, usually related to storage nodes.

While I plan on moving the implementation of the checks into endo instead of landing it in agoric-sdk first, I figured we should already fix the issues found.

### Security Considerations
None

### Scaling Considerations
None

### Documentation Considerations
None

### Testing Considerations
See #10170 for passing tests with checks enabled

### Upgrade Considerations
As it's a heap zone change, cross upgrade behavior is not involved. In the future any code using a stricter heap zone would need to comply. However heaps zones are used as packages bundled by the contract, and are not provided by liveslots or zcf, so there is no compatibility risk.
Base automatically changed from mhofman/passable-exo-state to master October 5, 2024 23:47
Copy link

github-actions bot commented Oct 5, 2024

Base branch is changed to master. Please re-run the integration tests by adding 'force:integration' label.

@mhofman mhofman force-pushed the mhofman/endo-1648-heap-zone-state-checks branch from 48bfbfb to ec8191b Compare October 17, 2024 18:22
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.

This likely should move into Endo itself

Yes. I would prefer that you do it this way from the outset. If you then want to make it available to agoric-sdk before the next round of endo sync, do that with an agoric-sdk patch of endo, as we’ve done on other such occasions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
force:integration Force integration tests to run on PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants