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

add controller.getBundle(bundleID) -> bundle API #4954

Open
warner opened this issue Mar 30, 2022 · 2 comments
Open

add controller.getBundle(bundleID) -> bundle API #4954

warner opened this issue Mar 30, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request SwingSet package: SwingSet

Comments

@warner
Copy link
Member

warner commented Mar 30, 2022

What is the Problem Being Solved?

@michaelfig and @kriskowal are building the chain-side tools to install and retrieve source bundles. We have controller.validateAndInstallBundle() for the installation side, but we haven't yet written support for the retrieval side.

Description of the Design

controller.getBundle(bundleID) , which will return (synchronous) either an EndoZipBase64Bundle -shaped object (with keys moduleFormat, endoZipBase64, and endoZipBase64Sha512), or undefined.

Assuming nobody has bypassed the controller and used the (non-validating) kernel.installBundle(), the bundles returned by controller.getBundle will have been validated already.

getBundle() will query the database as seen by the kernel, which means it will see the contents of the crank buffer. If a bundle has been installed recently but the crank buffer has not been flushed to disk, getBundle() may return a bundle that is not yet nailed down on disk, and which might get discarded by a subsequent abortCrank() call. Therefore getBundle() should not be called while controller.run() / controller.step() is running (i.e. their return Promise has not yet fired).

It is safe to do c.validateAndInstallBundle() ; c.getBundle() on the same ID: the installation call will commit the crank before returning.

Security Considerations

Clients of a chain will use an RPC query that calls this function to obtain the source code being used on contracts. It must provide the same source code, with the same level of validation that the kernel itself uses.

Test Plan

unit tests in test/bundles/test-bundles-controller.js immediately after a c.validateAndInstallBundle() call

@warner warner added enhancement New feature or request SwingSet package: SwingSet labels Mar 30, 2022
@warner warner self-assigned this Mar 30, 2022
@Tartuffo Tartuffo added this to the Mainnet 1 milestone Apr 5, 2022
@Tartuffo Tartuffo assigned kriskowal and warner and unassigned warner Jun 9, 2022
@Tartuffo
Copy link
Contributor

Tartuffo commented Jun 9, 2022

@kriskowal Brian thought that you are working in this area as part of your bundle hash install. Can you do this while you are in there?

@kriskowal
Copy link
Member

@warner I would like to prioritize this as “would be nice” in the MN-1 timeframe, but reading ahead, could be convinced that’s wishful thinking…

The interim solution is to recommend that people attempt to reconstruct the hash from sources for validation purposes. Yet, that interim solution would be greatly improved if we also allowed a bundle to be published with some metadata about how to reconstruct it, like the repository location and hash at the time of build. (Just rubber ducking this, I can see why much trouble is saved by instead providing a mechanism to download what was published to the chain from an RPC node, including that these notes could just be captured in the artifact proper. In #5541 I may have learned how to build some part of the solution you’re looking for here.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request SwingSet package: SwingSet
Projects
None yet
Development

No branches or pull requests

3 participants