-
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
make bundleStore accept nestedEvaluate bundles too #7190
Comments
Talking with @FUDCo just now:
|
We'll also need to reference these bundle ids in any vat start/upgrade synthetic transcript entry as described in #7199 |
BTW by using Glad I was in a 1-indexed mood when I decided to use |
This enhances the bundleStore to accomodate NestedEvaluate -format bundles, with a BundleID that is a hash of the JSON-serialized bundle object, using a `b0-` prefix. This adds to the previous facility which handled only EndoZipBase64 -format bundles, using a `b1-` prefixed BundleID that hashes only the compartment-map.json component of the zipfile. It also adds a number of tests. closes #7190
This enhances the bundleStore to accomodate NestedEvaluate -format bundles, with a BundleID that is a hash of the JSON-serialized bundle object, using a `b0-` prefix. This adds to the previous facility which handled only EndoZipBase64 -format bundles, using a `b1-` prefixed BundleID that hashes only the compartment-map.json component of the zipfile. It also adds a number of tests. closes #7190
This enhances the bundleStore to accomodate NestedEvaluate -format bundles, with a BundleID that is a hash of the JSON-serialized bundle object, using a `b0-` prefix. This adds to the previous facility which handled only EndoZipBase64 -format bundles, using a `b1-` prefixed BundleID that hashes only the compartment-map.json component of the zipfile. It also adds a number of tests. closes #7190
This enhances the bundleStore to accomodate NestedEvaluate -format bundles, with a BundleID that is a hash of the JSON-serialized bundle object, using a `b0-` prefix. This adds to the previous facility which handled only EndoZipBase64 -format bundles, using a `b1-` prefixed BundleID that hashes only the compartment-map.json component of the zipfile. It also adds a number of tests. closes #7190
What is the Problem Being Solved?
To support our new approach in #6596 (comment) , we need to store the
xsnap-lockdown
andswingset-xsnap-supervisor
bundles persistently, so a vat created today will maintain the same behavior tomorrow (after those packages have been updated or changed in some way).We're in the process of moving vat/contract bundles out of the
kvStore
and into a new dedicatedbundleStore
(#7089), which saves space in the IAVL tree (export data only holds bundle ID hashes, not the whole bundles, which are delivered in export artifacts instead). So we'd like to avoid putting these lockdown/supervisor bundles back into thekvStore
where they used to live. ThebundleStore
feels like the right place for them.However, these two bundles are special: they use
moduleFormat: 'nestedEvaluate'
instead ofendoZipBase64
. They cannot use the more advanced format because such bundles need a specialized loader, and the initial xsnap environment does not contain one (it is thesupervisor
bundle which installs this loader, so we'd have a bootstrapping / chicken-vs-egg problem). ThenestedEvaluate
format can be loaded with a simple IIFE wrapper.To live in the
bundleStore
, and more specifically to be safely importable from a swing-store export artifact (i.e. state-sync snapshot), we need a safe integrity hash of these bundles to be included in the export data. TheendoZipBase64
format defines an integrity hash which is the SHA512 hash of the compartment map, which works because 1: the compartment map defines hashes for all the other components of the zip file, and 2: thecheckBundle
/importBundle
code enforces those hashes, so that one hash is sufficient to define the behavior completely (and is compatible with a future scheme where we build bundles at runtime out of shared components, while a single flat hash would not). The swingset-centricBundleID
is then a version prefix (the literal stringb1-
) followed by the lowercase hex encoding of that SHA512 hash.So we need to define an integrity hash "bundle ID" for the
nestedEvaluate
-format bundles. I'm thinking that we (somewhat retroactively) defineb0-${SHA256(JSON.stringify(bundle))}
as its Bundle ID. Compared tob1-
-format bundles:{ moduleFormat, source }
instead of{ source, moduleFormat }
would not appear to be the same (not a big deal)b0-
can actually holdendoZipBase64
format bundles too, it is a superset, but we wouldn't use it for them, we'd only use it for these early-stage IIFE+eval
-loadable bundles that are needed to bootstrap a worker environmentDescription of the Design
b0-
format bundles (probably? seems better than poly-schema-ing the existing table to handle both)format
orversion
columnb0-
format as abovebundleStore.addBundle
to switch on the prefix of the supplied bundle IDb1-
, proceed as beforeb0-
:moduleFormat
isnestedEvaluate
getBundle
to extract, maybe decompress,JSON.parse
theb0-
format bundlesThen we need to add
kernelKeeper
changes to talk to thebundleStore
for these, something which knows the bundle names ("xsnap-lockdown" and "xsnap-supervisor").The work to store these bundles at
initializeSwingset
time, and to use them when launching a worker, will be covered by #6596, not this ticket.Security Considerations
The hash must be tight enough to prevent a "replace the bundle with a malicious variant" attack during the swingstore export/import process. The import code must assert that the bundle artifact matches the export-data hash.
Scaling Considerations
We'll record only a small number of these bundles, one per version of our runtime, so size isn't a big concern. Compressing the bundles in the DB might be nice, but not as important as compressing the vat/contract bundles (of which there will be a lot more).
We'll still have a
yarn build
step, so unit tests / etc won't be re-runningbundleSource
(adding a second or two to each test file). Unit tests will be doing a lot of loading that pre-generated bundle from disk, and storing it in the DB, and loading it back from the DB, but that's probably very fast compared to thebundleSource
call (which rummages through all ofnode_modules
to do its job).Test Plan
Unit tests in
swing-store
, plus a few inSwingSet/test/test-state.js
to exercise thekernelKeeper
integration.The text was updated successfully, but these errors were encountered: