-
Notifications
You must be signed in to change notification settings - Fork 208
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
"virtual promises" #3787
Comments
cc @erights , who pointed out that it might be better to address the specific needs of |
It strikes me that we might still have some dangling GC issues with regular (i.e., non-virtual) promises.
More generally, never getting around to resolving a promise can be a kind of storage leak. |
I propose the name Forgotten Promise Proplem, which sounds like it is mysterious,o f ancient lore and something that can be meta-ized by telling anyone curious about it that you will explain it later and then not following up on it. I think @erights would get a kick out of that. Frankly, "virtual promises" sounds like euphemism for politicans promises. |
Thiknig some more on this. Maybe
With this tool, you could:
You could not:
So the virtual promise has the same general design as a real That might be enough for a Notifier. I worry that it would look pretty weird, and not achieve our goals of "it's just JavaScript". |
Pronoun ambiguity: Do you mean I genuinely don't know which you mean, but I agree strongly with the second. OTOH, when I start thinking about virtual promises representatives being genuine promises (or even just thenables), I get vertigo. Did you explore and reject this possibility? |
I can smell a solution in this direction if we flesh out support for Virtual Far functions (where |
Mostly the second. The existing Notifier/Subscriptions tool is pretty easy to understand and qualifies as "just JavaScript". If we could encapsulate the virtualization weirdness inside some alternate "VirtualNotifier", such that contract code which hosts a notifier merely has to do a
I didn't even consider that: way beyond my comfort zone. |
I thought about that, but I have no idea how that would work. The reason virtual objects work is because we can rebuild them on demand. "virtual functions" would require the same ability (some sort of |
This is what I was thinking. It needs review for feasibility and usefulness.
Agreed. I'm talking about a general ability to "peel off" virtual functions from a virtual object, rather than needing to have a different pathway for defining individual virtual functions. But this really requires @erights.
I think in order to have compatible-with-Promises behaviour, we'd need a
could create a virtual object
That would give virtual functions on the resolver side. As far as virtual promises on the consumer side, we'd do something like:
those virtual thenables could remain virtual as long as the callback argument(s) supplied to |
@michaelfig and I walked through some of this today. Our vague plan is:
With this scheme, a durable Notifier could create and return durable Promises to do its job. Receivers of promises could use |
Note to self: w.r.t. vat upgrade and the cleanup we must do during |
Yes, please as it would fit ocapn way of listening onto promises. |
#4932 would implement the durable nameless callable methods/functions that we'd need to have the most pleasant API for virtual/durable promises. |
Here is a quick attempt at something like virtual/durable promises: https://gist.github.com/mhofman/3b04d2e2275f7b17bece718fd32df898 |
I tried to digest what was going on in that gist, but it was too complex for me to understand the forest for the trees. Would you be able to provide a walkthrough/list of features that your solution has so that I can have some context as to what it attempts to accomplish? |
I've rewritten the gist with more comments and full typing. That might help a little. The description of the types should help but the TLDR is:
Now passes Promises/A+ Compliance Test Suite! |
We're deferring this one for now, we'll allow notifiers to be durable by using the #4567 trick to hold ephemeral at-least-one-per-version promises instead. |
So here is my strawman:
Then to complete the loop we need to ensure vattp supports resolving a promise to another, which we've been putting off. That way liveslots can inform a result promise (which it imported but became the decider by getting the delivery), has been forwarded to the durable/virtual promise that liveslots observes as the direct result of the function call to userland it makes for the delivery. The biggest complication I see here is that liveslots relies on Pseudo-promise is where all these wrapping/unwrapping complications get solved, with these flowing through platform promise chains so we can figure out where these adoptions occur. |
What is the Problem Being Solved?
In the recent testnet (phase4.5 "metering"), a significant number of lingering c-list entries were Promises, rather than objects. We've developed the "virtual object" mechanism to move the RAM costs of their data off into the DB, however we don't have a way to tolerate a large number of long-lived Promises within a vat.
Description of the Design
We're thinking of a special function, similar to the
makeKind()
used to prepare virtual objects. For purposes of discussion, let's name itmakeVirtualPromise()
. It would return a pair of Representatives. The first would have a method namedresolve
, the second would have methods for subscription (like.then
and.catch
, but not using those names). These Representatives are backed by virtual objects that will survive the Representatives themselves being dropped.The general idea is that the (virtual-object) Purse would retain a reference to the resolution facet. Both could be dropped from RAM, but when something causes the Purse to be revived (a new Representative constructed), the resolution facet would be revived too, and could be invoked. The subscription facet could be sent to a remote vat, which could use it like a Promise. Perhaps the subscription facet should arrive as a Promise (as if we sent a real Promise to begin with), although that raises interesting round-trip issues.
cc @FUDCo @michaelfig @mhofman @dtribble
Security Considerations
Test Plan
The text was updated successfully, but these errors were encountered: