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

feat(swingset): devices.bundle, install-bundle, bundlecaps, createVat(bundlecap) #4485

Merged
merged 1 commit into from
Feb 9, 2022

Conversation

warner
Copy link
Member

@warner warner commented Feb 7, 2022

Add kernel support for code "bundles", specifically objects with { moduleFormat: "EndoZipBase64" } whose .EndoZipBase64 property is a large
string (base64-encoded zipfile with a compartment map and module components).
Each bundle has a "bundleID" which is the versioning prefix b1- followed by
the lowercase hex encoding of the SHA512 hash of the compartment map bytes.

Bundles are represented within userspace as "bundlecaps", which are device
nodes owned by a new "bundle device" (devices.bundle). These can be passed
in messages from one vat to another, just like Remotables. Bundlecaps are
used to create vats in lieu of passing the actual (large) code bundles around
through messages. Bundlecaps can also be asked for their code bundle in case
you need to importBundle one directly into userspace (e.g. when ZCF
evaluates a contract bundle).

The config.bundles table is now handled by installing the bundles at
initializeSwingset time, and populating a name->ID table for later.

The new APIs are:

  • computedBundleID = controller.validateAndInstallBundle(bundle, allegedBundleID) will validate the bundle against the claimed ID and add it
    to the kernel tables (NOTE: validation is minimal so far, must be improved
    before release)
  • kernel.installBundle(bundleID, bundle) will install a bundle under the
    given ID without validation
  • devices.bundle provides access to bundles
    • D(devices.bundle).getBundleCap(bundleID) yields a bundlecap or
      undefined if no bundle was installed with that ID
    • D(devices.bundle).getNamedBundleCap(name) yields a bundlecap or
      undefined if config.bundles lacked a bundle with that name
  • bundlescaps are device nodes
    • D(bundlecap).getBundleID() yields the bundleID
    • D(bundlecap).getBundle() yields a code bundle, for importBundle()
  • E(vatAdminService).createVat(bundleOrBundleCap) creates a dynamic vat
    • eventually we'll remove the option to use a bundle, making this strictly
      E(vatAdminService).createVat(bundlecap)
    • E(vatAdminService).createVatByName(name) still works, but eventually it
      will be removed in favor of userspace doing getNamedBundleCap first

closes #4372

@warner warner added the SwingSet package: SwingSet label Feb 7, 2022
@warner warner added this to the Mainnet: Phase 1 - RUN Protocol milestone Feb 7, 2022
@warner warner requested a review from FUDCo February 7, 2022 20:27
@warner warner self-assigned this Feb 7, 2022
@warner warner force-pushed the 4372-bundlecaps branch 2 times, most recently from 6fd47f4 to f7386c3 Compare February 7, 2022 21:40
@Tartuffo Tartuffo removed this from the Mainnet: Phase 1 - RUN Protocol milestone Feb 8, 2022
Copy link
Contributor

@FUDCo FUDCo left a comment

Choose a reason for hiding this comment

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

Other than one minor comment quibble, this looks very nice.

const capToIDKey = `slot.${cap}`;
syscall.vatstoreSet(capToIDKey, bundleID);
}
// need iserialize to make ['ok', capdata]
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment seems out of context.

…(bundlecap)

Add kernel support for code "bundles", specifically objects with `{
moduleFormat: "EndoZipBase64" }` whose `.EndoZipBase64` property is a large
string (base64-encoded zipfile with a compartment map and module components).
Each bundle has a "bundleID" which is the versioning prefix `b1-` followed by
the lowercase hex encoding of the SHA512 hash of the compartment map bytes.

Bundles are represented within userspace as "bundlecaps", which are device
nodes owned by a new "bundle device" (`devices.bundle`). These can be passed
in messages from one vat to another, just like Remotables. Bundlecaps are
used to create vats in lieu of passing the actual (large) code bundles around
through messages. Bundlecaps can also be asked for their code bundle in case
you need to `importBundle` one directly into userspace (e.g. when ZCF
evaluates a contract bundle).

The `config.bundles` table is now handled by installing the bundles at
`initializeSwingset` time, and populating a name->ID table for later.

The new APIs are:

* `computedBundleID = controller.validateAndInstallBundle(bundle,
allegedBundleID)` will validate the bundle against the claimed ID and add it
to the kernel tables (NOTE: validation is minimal so far, must be improved
before release)
* `kernel.installBundle(bundleID, bundle)` will install a bundle under the
given ID without validation
* `devices.bundle` provides access to bundles
  * `D(devices.bundle).getBundleCap(bundleID)` yields a bundlecap or
    `undefined` if no bundle was installed with that ID
  * `D(devices.bundle).getNamedBundleCap(name)` yields a bundlecap or
    `undefined` if config.bundles lacked a bundle with that name
* bundlescaps are device nodes
  * `D(bundlecap).getBundleID()` yields the bundleID
  * `D(bundlecap).getBundle()` yields a code bundle, for `importBundle()`
* `E(vatAdminService).createVat(bundleOrBundleCap)` creates a dynamic vat
  * eventually we'll remove the option to use a bundle, making this strictly
    `E(vatAdminService).createVat(bundlecap)`
  * `E(vatAdminService).createVatByName(name)` still works, but eventually it
    will be removed in favor of userspace doing `getNamedBundleCap` first

refs #4372
closes #3269
closes #4373
@warner warner added the automerge:rebase Automatically rebase updates, then merge label Feb 9, 2022
@mergify mergify bot merged commit 21ed4c7 into master Feb 9, 2022
@mergify mergify bot deleted the 4372-bundlecaps branch February 9, 2022 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge SwingSet package: SwingSet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement bundlecaps, bundle device
3 participants