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

refactor: prepare for use of non-trapping integrity trait #10795

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

erights
Copy link
Member

@erights erights commented Jan 4, 2025

#endo-branch: master

closes: #XXXX
refs: endojs/endo#2679

Description

Does for agoric-sdk what endojs/endo#2679 does for endo

Prepare for anticipated introduction and use of the non-trapping integrity trait as explained at https://github.com/endojs/endo/blob/b12eb434b6672f0ceae41be55aac7f24c4562b7b/packages/ses/docs/preparing-for-stabilize.md

These preparations must work now, before these traits are introduced, and should continue to work after these traits are introduced and used.

Security Considerations

Some things that had been deeply frozen automatically by harden are now manually frozen by explicit calls to freeze. We need to review these carefully to ensure that nothing has inadvertently be left unfrozen as a result of the changes in this PR.

Some proxies will become unhardenable, but they will still be hardenable as of now, so mistaken hardenings will not be detected.

Scaling Considerations

For this PR by itself, none. Using the shim-based implementation of the non-trapping trait will have scaling consequences: endojs/endo#2675

Documentation Considerations

https://github.com/endojs/endo/blob/b12eb434b6672f0ceae41be55aac7f24c4562b7b/packages/ses/docs/preparing-for-stabilize.md will need to be reflected in developer docs.

Testing Considerations

Since this PR by itself should be a pure refactor with no observable changes, there is nothing to test at this stage. The testing burden will come with #10796 to see how adequate these preparations were.

Compatibility Considerations

The point. This changes to coding patterns that should be compat both with the current status quo and with #10796

Upgrade Considerations

As a pure refactor, none.

@erights erights self-assigned this Jan 4, 2025
Copy link

cloudflare-workers-and-pages bot commented Jan 4, 2025

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 94cb9d3
Status: ✅  Deploy successful!
Preview URL: https://aef03699.agoric-sdk.pages.dev
Branch Preview URL: https://markm-prepare-for-non-trappi.agoric-sdk.pages.dev

View logs

Copy link
Member

@mhofman mhofman left a comment

Choose a reason for hiding this comment

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

This made me realize a broader upgrade hazard which I've described in endojs/endo#2675 (review)

Copy link
Member

Choose a reason for hiding this comment

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

The change in this file points to a potential future upgrade hazard. It means we cannot simply use the currently deployed code and re-run its transcript on top of a lockdown + liveslots (or an XS engine) that introduces non-trapping behavior. Such a "replay" is one of the option we're still keeping under consideration, especially for the bootstrap vat which cannot be upgraded.

Copy link
Member Author

Choose a reason for hiding this comment

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

Below, @michaelfig writes:

We may need to have some kind of opt-in for packages/swingset-liveslots/src/liveslots.js changes, or else replaying the bootstrap vat (our only upgrade mechanism that would work for it) may cause divergence, as @mhofman points out.

I think that needs to be solved before we can land this change.

(repeating here to answer both together)

Copy link
Member Author

Choose a reason for hiding this comment

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

Assuming this PR by itself is a pure refactor, as claimed, without any observable effect, why would this question need to be resolved before this PR is merged?

Copy link
Member Author

Choose a reason for hiding this comment

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

I do understand that replay is especially sensitive. But is there some way that the changes in this file have an observable effect even on replay?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, in a "replay" of the bootstrap vat (such as on mainnet), and indeed any source bundle in use that is not rebuilt and upgraded, the proxy target hardening "refactor" changes in this PR and the earlier Endo PR will not apply, since the existing source bundle will be reused. The refactors will only apply to future chains (or vat/contract upgrades).

By "needs to be solved," I mean we should have a plan for upgradable vats (and contracts) to opt-in to the shim for their future upgrades so that non-opted-in vats/contracts will continue to execute in a non-shimmed environment.

Thinking about adopting the non-trapping shim without such an opt-in plan makes me nervous about asserting that there are no Upgrade Considerations.

Copy link
Member

@michaelfig michaelfig Jan 19, 2025

Choose a reason for hiding this comment

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

So, the changes have an observable effect (the tolerance of a stabilizing harden()), but only for new vats or existing vats' future upgrades. This PR alone does not prepare existing vats for a stabilizing harden() (whether native or shimmed).

Calling this out in the "Upgrade Considerations" section, and in the markdown file you wrote (I don't remember the PR, but it was in Endo) describing what needs to change to be ready for suppressTrapping would be useful.

Copy link
Member Author

Choose a reason for hiding this comment

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

Calling this out in the "Upgrade Considerations" section, and in the markdown file you wrote (I don't remember the PR, but it was in Endo) describing what needs to change to be ready for suppressTrapping would be useful.

The markdown file in question is

https://github.com/endojs/endo/blob/master/packages/ses/docs/preparing-for-stabilize.md

@erights erights force-pushed the markm-prepare-for-non-trapping branch 2 times, most recently from f43c9e5 to 4d00b72 Compare January 6, 2025 22:22
erights added a commit that referenced this pull request Jan 6, 2025
Copy link
Member

@michaelfig michaelfig left a comment

Choose a reason for hiding this comment

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

It seems to me that these changes are not sufficiently defensive against accidental hardening of a proxy that is intended to remain trapping. Would it make sense to add a (I'm handwaving here) suppressTrapping(x) { throw Error('This proxy cannot be passed through a marshaller because hardening it would suppress its trap handling...'); } trap handler to all the proxy handlers whose targets have been changed to be merely frozen instead of hardened?

packages/SwingSet/tools/run-utils.js Outdated Show resolved Hide resolved
@michaelfig
Copy link
Member

It seems to me that these changes are not sufficiently defensive against accidental hardening of a proxy that is intended to remain trapping.

My mistake, I see this documented as fixed by default in endojs/endo#2675

@erights erights force-pushed the markm-prepare-for-non-trapping branch from 4d00b72 to c851744 Compare January 10, 2025 05:37
erights added a commit that referenced this pull request Jan 10, 2025
@erights erights force-pushed the markm-prepare-for-non-trapping branch from c851744 to 9c4cad6 Compare January 12, 2025 00:01
erights added a commit that referenced this pull request Jan 12, 2025
@erights erights force-pushed the markm-prepare-for-non-trapping branch from 9c4cad6 to 1220dd0 Compare January 12, 2025 05:54
erights added a commit that referenced this pull request Jan 12, 2025
@erights erights force-pushed the markm-prepare-for-non-trapping branch from 1220dd0 to fc10f0d Compare January 18, 2025 03:19
@erights erights marked this pull request as ready for review January 18, 2025 03:21
@erights erights requested a review from a team as a code owner January 18, 2025 03:21
@erights
Copy link
Member Author

erights commented Jan 18, 2025

As with endojs/endo#2679 (comment)

Reviewers: I claim that this PR by itself prior to the introduction or use of the non-trapping or stabilize integrity traits is a pure refactor, i.e., it should not produce any observable changes. Please review with that claim in mind. If you do spot something that looks like an observable change, please let me know. Thanks!

@erights erights requested review from michaelfig and mhofman January 18, 2025 03:22
Copy link
Member

@michaelfig michaelfig left a comment

Choose a reason for hiding this comment

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

We may need to have some kind of opt-in for packages/swingset-liveslots/src/liveslots.js changes, or else replaying the bootstrap vat (our only upgrade mechanism that would work for it) may cause divergence, as @mhofman points out.

I think that needs to be solved before we can land this change.

packages/SwingSet/tools/run-utils.js Outdated Show resolved Hide resolved
erights added a commit to endojs/endo that referenced this pull request Jan 19, 2025
Closes: #XXXX
Refs: Agoric/agoric-sdk#10795

## Description

Prepare for anticipated introduction and use of the non-trapping
integrity trait as explained at
https://github.com/endojs/endo/blob/b12eb434b6672f0ceae41be55aac7f24c4562b7b/packages/ses/docs/preparing-for-stabilize.md

These preparations must work now, before these traits are introduced,
and should continue to work after these traits are introduced and used.

### Security Considerations

Some things that had been deeply frozen automatically by `harden` are
now manually frozen by explicit calls to `freeze`. We need to review
these carefully to ensure that nothing has inadvertently be left
unfrozen as a result of the changes in this PR.

Some proxies will become unhardenable, but they will still be hardenable
as of now, so mistaken hardenings will not be detected.

### Scaling Considerations

For this PR by itself, none. Using the shim-based implementation of the
non-trapping trait will have scaling consequences:
#2675

### Documentation Considerations


https://github.com/endojs/endo/blob/b12eb434b6672f0ceae41be55aac7f24c4562b7b/packages/ses/docs/preparing-for-stabilize.md
will need to be reflected in developer docs.

### Testing Considerations

Since this PR by itself should be a pure refactor with no observable
changes, there is nothing to test at this stage. The testing burden will
come with #2675 to see how adequate
these preparations were.

### Compatibility Considerations

The point. This changes to coding patterns that should be compat both
with the current status quo and with
#2675

### Upgrade Considerations

As a pure refactor, none.
@erights erights requested a review from michaelfig January 19, 2025 03:54
@erights erights force-pushed the markm-prepare-for-non-trapping branch from efecd94 to ad52363 Compare January 19, 2025 19:36
@erights erights force-pushed the markm-prepare-for-non-trapping branch from ad52363 to 94cb9d3 Compare January 20, 2025 19:18
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.

3 participants