-
Notifications
You must be signed in to change notification settings - Fork 206
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
feat(zone)!: implement zone.makeOnce(key, maker)
#7891
Conversation
Agreed. But doesn't this mean the title should be |
zone.makeOnce(key, maker)
zone.makeOnce(key, maker)
Yes. When I squash the commits (one of them has the breaking change bang) I'll also update the commit messages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More testing? I see only test-make-once.js . IIUC, it tests only makeOnce
and isStorable
.
I mean, not just in this PR, but in the zone/test directory that would result from this PR. IOW, prior testing situation was thin.
See endojs/endo#1648 , which I assigned to myself. I will continue the review under the assumption we expect endojs/endo#1648 to be fixed shortly after this PR. Thus, this PR should behave sensibly both before and afterwards, but be designed for the world in which endojs/endo#1648 has been fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am concerned about the upgradability of this change, but then I don't really know how to solve the problem either.
I think we half painted ourselves in a corner with the prepare and zone abstractions.
At the lowest level, kind handles are the unique identity representing a durable class definition, and it's up to the contract code to stash it in baggage and reconnect the definitions on restart. The code has full control over the process.
What the prepare and zone abstractions do is hide the handles and automatically store them in a location derived from the definition. However this removes the flexibility to restructure the code and update the definition, such as renaming the class, or switching from the provide pattern to the zone mechanism.
We should have a discussion about what transition use case we want to support, and how.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found some problems that I think need to be fixed. However, I'm too tired now to try to write them up. It looks like I'll be able to focus on this for most of tomorrow.
Requesting changes for now just as an interlock, so it's not accidentally merged before I write these down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my suggestions at #7971
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, somehow I thought I'd already approved this.
LGTM!!
Putting back into draft until more tests are written. |
#7116 raises an additional question about this PR: When switching durable state in the obvious manner from a pre-zone baggage-based API to a zone-based one, is the resulting durable state exactly the same? If not, what are the implications for upgrade? Should we have a test for upgrade of code using pre-zone baggage to zone, such as #7116 ? How would we write such a test? |
990098b
to
0e6ce59
Compare
0e6ce59
to
dc8eb4a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Looking forward to using this a lot!
* Ensure the wrapped function is only called once per incarnation. It is | ||
* expected to update the backing store directly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, per wrapper, where each call to wrapProvider
creates a fresh wrapper. I want to avoid the misunderstanding that the "ensure" is based on the identity of the provide
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I'll make note of that next time I'm in the vicinity.
feat(zone)!: implement `zone.makeOnce(key, maker)`
closes: #7663
Description
Implements
zone.makeOnce(key, maker)
in a similar spirit to #7663, but with verification that it is called only once per key,zone,incarnation.Also moves the implementation to
Zone
. The originalonce
implementation was a method on Stores, but they might be detached (i.e. have no backing store) and thereby not need key usage tracking.Security Considerations
A breaking change in this PR was necessary:
heapZone
andvirtualZone
became new vestiges of global mutable state since they each had a new namespace (the used keys) associated with them. This was not Jessie-safe and introduced many name conflicts in actual code (especially in concurrent testing), so I removed them and replaced them withmakeHeapZone()
andmakeVirtualZone()
to make them more POLA-friendly and segregate their scope.Scaling Considerations
Documentation Considerations
Testing Considerations