-
Notifications
You must be signed in to change notification settings - Fork 227
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
maybe replace 'harden' import with a global #1214
Comments
As discussed in the meeting this morning, We'll separate the question of whether to remove the ability to do the import for later. The task of removing imports can proceed incrementally, one module at a time. When we've finally removed them all, then we can decide whether to get rid of |
As a tangent, I would eventually like something I'd call // Modify globals to closer emulate our desired EcmaScript future.
import './harden-shim'; // if harden is missing, complain and use Object.freeze
import './eventual-send-shim'; // Add Promise.delegate (currently HandledPromise)
import './compartment-shim'; // Add Compartment I want to use this to shim and future-proof library code I intend to write. |
As of the current trunk (4fe3c83), we're down to one import of agoric-sdk/packages/agoric-cli/lib/install-ersatz-harden.js Lines 3 to 8 in 4fe3c83
That's @michaelfig 's domain, and I don't think it's involved in vat/contract code. So I think we can consider this ticket closable without removing that one. We've removed agoric-sdk/packages/bundle-source/src/index.js Lines 45 to 52 in 4fe3c83
and the agoric-sdk/packages/SwingSet/src/controller.js Lines 178 to 180 in 4fe3c83
But we still want to remove it from the names honored by the agoric-sdk/packages/SwingSet/src/controller.js Lines 119 to 122 in 4fe3c83
And then, since #362 is closed, I think we can remove support for |
oops, #362 isn't really done yet, I can remove the |
The kernel now gets `harden` from the globals, so we no longer need to support it doing `require('@agoric/haren')`. refs #1214
Vats no longer get `harden` via require, and they aren't allowed to `require` anything else either, so this removes the endowment entirely. refs #1214
#362 is fixed, I'll make a PR to remove |
Swingset's
controller.js
andkernel.js
both contain functions that look somewhat like:which are provided to the kernel and to vats (respectively) as a
require
endowment. While reviewing #1201, @FUDCo said:You rock!
We need to have a group decision about what SES/vat/contract code can expect on the global, what it gets by import, and what it gets by argument. And how that affects the developer experience (i.e. if you get
harden
as a global, your library cannot be imported by applications which aren't using SES, which might be a pain point and reduce the audience for your library, or maybe it's no big deal). But assuming we decide to go with the global, then yeah, the task is to delete the import from everything (agoric-sdk and all the dapp repos), remove it from theexternals
configuration inbundle-source
, then remove the@agoric/harden
clause from thekernelRequire
andvatRequire
lines. And then (probably) remove therequire
endowments entirely.But, maybe, leave it in just for the purpose of revealing (in an error) the leftover unbound package name which the bundle depended upon. I was talking to @michaelfig about this today: if a contract imports some random NPM library, and that library's dependency graph happens to be well-behaved and doesn't use any Node.js builtins, then
rollup
will be able to find source code for everything, and the bundle will have no remainingrequire
statements. But if something (maybe several levels deep) is not so well-behaved,rollup
will be faced with someimport 'fs'
orimport 'http'
somewhere, and currently rollup emits a warning and then includes arequire('fs')
anyways. When that bundle finally meetsimportBundle
, then either therequire
will fail (ReferenceError, or maybe "TypeError: undefined is not a function"), or thekernelRequire
will fail ("cannot satisfy require('fs')"), and the latter is slightly more informative. But, what would be even better is ifbundle-source
rejected it in the first place, and showed the full dependency chain that resulted in attempting to bundle an unbundleable native module, so the contract author could either say "oh bummer, I can't use that library", or "oh hey I'll go bug the author of the not-so-well-behaved module to tame it nicely so I can use it from a SES-confined environment".Originally posted by @warner in #1201
The text was updated successfully, but these errors were encountered: