-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(swingset): allow buildRootObject to return a Promise
New (or upgraded) vats are defined by a user-provided `buildRootObject` function. This function has two responsibilities: * provide a root object * use `defineDurableKind` to bind behavior to any pre-existing durable kinds Previously, `buildRootObject` was given exactly one "turn" to fulfill these responsibilities: it was required to return the root object synchronously. If it returned a Promise, that was rejected as an error. This requirement is at odds with the needs for updated ZCF vats to evaluate their contract code and interact with it (giving the contract a chance to bind their own Kind behavior). The `importBundle` function we use to load contracts is async. However, it is still "prompt": it needs no IO, nor any messages leaving the vat. So it will still complete within the *crank*, just not synchronously within the turn. So this commit changes liveslots to allow `buildRootObject` to return a Promise for the root object. The requirement, however, is that this Promise must resolve by the end of the initial crank (before `waitUntilQuiescent` / `setImmediate` determines that the promise queue is empty). If the Promise is not fulfilled by then, the vat creation/update is considered broken. closes #5246
- Loading branch information
Showing
7 changed files
with
44 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { makePromiseKit } from '@endo/promise-kit'; | ||
|
||
export function buildRootObject() { | ||
const pk = makePromiseKit(); | ||
return pk.promise; // never resolves | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters