generated from MetaMask/metamask-module-template
-
Notifications
You must be signed in to change notification settings - Fork 7
feat(omnium): Add caplet vat implementation #753
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3c78bee
feat(omnium): Add Phase 1a - Single echo caplet implementation
rekmarks 47d276f
feat(omnium): Add Phase 1b - Store and retrieve caplet root krefs
rekmarks 1dffc1a
fix(omnium): Fix TypeScript type errors in Phase 1b implementation
rekmarks 3894833
refactor(omnium): Simplify LaunchResult and remove KrefWrapper
rekmarks 3b7f375
test(kernel-browser-runtime): Add error case tests for launchSubcluster
rekmarks 335ce4d
feat(omnium): Expose caplet manifests in background console
rekmarks c43d32c
feat(omnium): Add loadCaplet method and fix vat bootstrap kref
rekmarks 0446603
fix: Fix launch-subcluster RPC result type for JSON compatibility
rekmarks 66356ca
test: Fix test failures
rekmarks cd8014e
refactor(omnium): omnium.loadCaplet -> omnium.caplet.load
rekmarks 2de71e8
fix: Fix nodejs test helper
rekmarks 355e5fe
fix: Fix another nodejs test helper
rekmarks 0e06cb4
chore: Remove unused dependency from nodejs
rekmarks 33727fa
refactor: Post-rebase fixup
rekmarks 4b58ada
test(caplet-controller): Add unit tests for getCapletRoot method
rekmarks 51ef13a
refactor(omnium): Colocate caplet files and complete manifest
rekmarks b9089b5
refactor: Remove unused import / export tables
rekmarks 1aeb855
refactor(echo-caplet): Use console.log instead of vatPowers
rekmarks bc6e395
refactor: Cleanup
rekmarks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import { makeDefaultExo } from '@metamask/kernel-utils/exo'; | ||
| import type { Kernel, ClusterConfig, KRef, VatId } from '@metamask/ocap-kernel'; | ||
|
|
||
| import type { KernelFacade } from '../../types.ts'; | ||
| import type { KernelFacade, LaunchResult } from '../../types.ts'; | ||
|
|
||
| export type { KernelFacade } from '../../types.ts'; | ||
|
|
||
|
|
@@ -15,8 +15,10 @@ export function makeKernelFacade(kernel: Kernel): KernelFacade { | |
| return makeDefaultExo('KernelFacade', { | ||
| ping: async () => 'pong' as const, | ||
|
|
||
| launchSubcluster: async (config: ClusterConfig) => { | ||
| return kernel.launchSubcluster(config); | ||
| launchSubcluster: async (config: ClusterConfig): Promise<LaunchResult> => { | ||
| const { subclusterId, bootstrapRootKref } = | ||
| await kernel.launchSubcluster(config); | ||
| return { subclusterId, rootKref: bootstrapRootKref }; | ||
| }, | ||
|
|
||
| terminateSubcluster: async (subclusterId: string) => { | ||
|
|
@@ -34,6 +36,12 @@ export function makeKernelFacade(kernel: Kernel): KernelFacade { | |
| pingVat: async (vatId: VatId) => { | ||
| return kernel.pingVat(vatId); | ||
| }, | ||
|
|
||
| getVatRoot: async (krefString: string) => { | ||
| // Return wrapped kref for future CapTP marshalling to presence | ||
| // TODO: Enable custom CapTP marshalling tables to convert this to a presence | ||
| return { kref: krefString }; | ||
| }, | ||
|
Comment on lines
+41
to
+44
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As Bugbot so astutely points out, this doesn't work, and won't work until #754. |
||
| }); | ||
| } | ||
| harden(makeKernelFacade); | ||
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,21 +1,32 @@ | ||
| import type { Kernel } from '@metamask/ocap-kernel'; | ||
| import type { Kernel, ClusterConfig } from '@metamask/ocap-kernel'; | ||
| import type { Json } from '@metamask/utils'; | ||
|
|
||
| /** | ||
| * A CapTP message that can be sent over the wire. | ||
| */ | ||
| export type CapTPMessage = Record<string, Json>; | ||
|
|
||
| /** | ||
| * Result of launching a subcluster. | ||
| * | ||
| * The rootKref contains the kref string for the bootstrap vat's root object. | ||
| */ | ||
| export type LaunchResult = { | ||
| subclusterId: string; | ||
| rootKref: string; | ||
| }; | ||
|
|
||
| /** | ||
| * The kernel facade interface - methods exposed to userspace via CapTP. | ||
| * | ||
| * This is the remote presence type that the background receives from the kernel. | ||
| */ | ||
| export type KernelFacade = { | ||
| ping: () => Promise<'pong'>; | ||
| launchSubcluster: Kernel['launchSubcluster']; | ||
| launchSubcluster: (config: ClusterConfig) => Promise<LaunchResult>; | ||
| terminateSubcluster: Kernel['terminateSubcluster']; | ||
| queueMessage: Kernel['queueMessage']; | ||
| getStatus: Kernel['getStatus']; | ||
| pingVat: Kernel['pingVat']; | ||
| getVatRoot: (krefString: string) => Promise<unknown>; | ||
| }; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.