Skip to content

Commit

Permalink
fix: excise @agoric/harden from the codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Aug 8, 2020
1 parent 184c912 commit eee6fe1
Show file tree
Hide file tree
Showing 18 changed files with 10 additions and 134 deletions.
1 change: 0 additions & 1 deletion packages/ERTP/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"@agoric/assert": "^0.0.8",
"@agoric/eventual-send": "^0.9.3",
"@agoric/import-manager": "^0.0.7",
"@agoric/layer-cake": "^0.0.1",
"@agoric/marshal": "^0.2.3",
"@agoric/nat": "^2.0.1",
"@agoric/promise-kit": "^0.1.3",
Expand Down
5 changes: 1 addition & 4 deletions packages/SwingSet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ anything else.
Each Vat source file (like `vat-foo.js` or `vat-bar.js`) is treated as a
starting point for the `rollup` tool, which converts the Vat's source tree
into a single string (so it can be evaluated in a SES realm). This starting
point can use `import` to reference shared local files. It can also import a
few special non-local modules: `@agoric/nat` and `@agoric/harden`. No other
point can use `import` to reference shared local files. No
non-local imports are allowed yet.

The source file is expected to contain a single default export function named
Expand All @@ -87,8 +86,6 @@ The "Live Slots" layer provides a function to build `dispatch` out of
lines of boilerplate in the `setup()` function.

```js
import harden from '@agoric/harden';

function buildRootObject(E) {
return harden({
callRight(arg1, right) {
Expand Down
6 changes: 0 additions & 6 deletions packages/SwingSet/docs/devices.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,6 @@ in which each value is a 3-item list.
* an object containing endowments that will be passed into the setup
function.

Like vats, the file will be evaluated with a `require` endowment that
provides access to `@agoric/harden`, `@agoric/nat`, and `@agoric/evaluate`
(unlike `SES.makeRequire()`, which doesn't provide a `require` to the
evaluated string).

"Kernel devices" do not need to be configured by the host. The only kernel
device currently envisioned is one which provides the `addVat` call, which
allows new Vats to be created at runtime.
Expand Down Expand Up @@ -166,7 +161,6 @@ methods that can be called from the kernel.

```js
// exampledevice-src.js
import harden from '@agoric/harden';
export default function setup(syscall, state, helpers, endowments) {
const { stuff } = endowments;
// use stuff
Expand Down
10 changes: 1 addition & 9 deletions packages/SwingSet/test/metering/test-metering.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ async function runUnderMeter(meter, thunk) {
return true;
}

function vatRequire(what) {
if (what === '@agoric/harden') {
return harden;
} else {
throw Error(`vatRequire unprepared to satisfy require(${what})`);
}
}

async function meteredImportBundle(bundle, endowments) {
const { meter, refillFacet } = makeMeter();
function getMeter() {
Expand Down Expand Up @@ -75,7 +67,7 @@ async function meteredImportBundle(bundle, endowments) {
// importBundle requires a 'require', even if nothing uses it
function doImport() {
const p = importBundle(bundle, {
endowments: { ...endowments, require: vatRequire, getMeter, RegExp: re2 },
endowments: { ...endowments, getMeter, RegExp: re2 },
transforms: [transform],
});
p.then(n => (ns = n));
Expand Down
10 changes: 1 addition & 9 deletions packages/SwingSet/test/metering/vat-within.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@

import { importBundle } from '@agoric/import-bundle';

function vatRequire(what) {
if (what === '@agoric/harden') {
return harden;
} else {
throw Error(`vatRequire unprepared to satisfy require(${what})`);
}
}

export function buildRootObject(vatPowers) {
const { makeGetMeter, transformMetering } = vatPowers;
const log = vatPowers.testLog;
Expand All @@ -34,7 +26,7 @@ export function buildRootObject(vatPowers) {
async start(bundle) {
// console.log(`vatPowers`, vatPowers);
// console.log('bundle', bundle);
const endowments = { require: vatRequire, console, getMeter };
const endowments = { console, getMeter };
// console.log('doing importBundle');
log('importing');
const ns = await importBundle(bundle, {
Expand Down
9 changes: 1 addition & 8 deletions packages/agoric-cli/bin/agoric
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
#!/usr/bin/env node

/* global globalThis */

const esmRequire = require('esm')(module);

// Do a dance to suppress the "'@agoric/harden' is ineffective without SES" warning.
// This only affects uses inside the 'agoric' tool, not child processes. See #971
// for details.
globalThis.harden = null;
// Now redefine to cache the instance.
globalThis.harden = esmRequire('@agoric/harden');
esmRequire('@agoric/install-ses');

const path = require('path');
const WebSocket = require('ws');
Expand Down
8 changes: 0 additions & 8 deletions packages/agoric-cli/lib/install-ersatz-harden.js

This file was deleted.

2 changes: 0 additions & 2 deletions packages/agoric-cli/lib/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import './install-ersatz-harden';

import { Command } from 'commander';

import cosmosMain from './cosmos';
Expand Down
1 change: 0 additions & 1 deletion packages/agoric-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"dependencies": {
"@agoric/bundle-source": "^1.1.6",
"@agoric/captp": "^1.3.3",
"@agoric/harden": "^0.0.8",
"@agoric/promise-kit": "^0.1.3",
"@iarna/toml": "^2.2.3",
"anylogger": "^0.21.0",
Expand Down
1 change: 1 addition & 0 deletions packages/agoric-cli/test/test-main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* global globalThis */
import { test } from 'tape-promise/tape';
import '@agoric/install-ses';
import fs from 'fs';
import anylogger from 'anylogger';

Expand Down
18 changes: 1 addition & 17 deletions packages/eventual-send/integration-test/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions packages/eventual-send/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ export default [
file: 'dist/eventual-send.umd.js',
format: 'umd',
name: 'EventualSend',
// globals: {
// '@agoric/harden': 'harden',
// },
},
{
file: 'dist/eventual-send.esm.js',
Expand All @@ -19,6 +16,5 @@ export default [
format: 'cjs',
},
],
external: ['@agoric/harden'],
},
];
6 changes: 3 additions & 3 deletions packages/marshal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ an object with `serialize` and `unserialize` properties. If the callback
arguments are omitted, they default to the identity function.

```js
import harden from '@agoric/harden';
import '@agoric/install-ses';
import { makeMarshal } from '@agoric/marshal';

const m = makeMarshal();
Expand All @@ -40,8 +40,8 @@ console.log(o2); // { a: 1 }
## Frozen Objects Only

The entire object graph must be "hardened" (recursively frozen), such as done
by the `@agoric/harden` module. The serialization function will refuse to
marshal any graph that contains a non-frozen object.
by the `ses` module (installed with `@agoric/install-ses`). The serialization
function will refuse to marshal any graph that contains a non-frozen object.

## Beyond JSON

Expand Down
9 changes: 0 additions & 9 deletions packages/spawner/src/contractHost.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ function makeContractHost(vatPowers, additionalEndowments = {}) {
});
}

function myRequire(what) {
if (what === '@agoric/harden') {
return harden;
}
throw Error(`require(${what}) not implemented`);
}
harden(myRequire);

// TODO: this should really have console and HandledPromise. We need
// 'require' until we change the environment definition (and
// bundle-source's "externals" list) to get 'harden' from a global, not an
Expand All @@ -68,7 +60,6 @@ function makeContractHost(vatPowers, additionalEndowments = {}) {
harden,
Nat,
makePromiseKit,
require: myRequire,
HandledPromise,
};

Expand Down
1 change: 0 additions & 1 deletion packages/transform-metering/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"tape-promise": "^4.0.0"
},
"dependencies": {
"@agoric/harden": "^0.0.8",
"@agoric/nat": "^2.0.1",
"@agoric/tame-metering": "^1.2.3",
"re2": "^1.10.5"
Expand Down
25 changes: 1 addition & 24 deletions packages/zoe/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,30 +58,7 @@ To test that that the Zoe update works (in the most basic sense) with cosmic-swi

1. Run `yarn install` from the workspace root
2. Run `yarn build` from the workspace root
3. `cd packages/cosmic-swingset`
4. `make scenario3-setup`
5. `make scenario3-run-client`
6. Open `http://127.0.0.1:8000/`
8. `moolaAssayP = E(home.registry).get("moola_3467");`
9. `simoleanAssayP = E(home.registry).get("simolean_2059");`
10. `automaticRefundHandleP = E(home.zoe).install("function getExport() { 'use strict'; let exports = {}; const module = { exports }; 'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nfunction _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }\n\nvar harden = _interopDefault(require('@agoric/harden'));\n\n/**\n * This is a very trivial contract to explain and test Zoe.\n * AutomaticRefund just gives you back what you put in. It has one\n * method: `makeOffer`. AutomaticRefund then tells Zoe to complete the\n * offer, which gives the user their payout through Zoe. Other\n * contracts will use these same steps, but they will have more\n * sophisticated logic and interfaces.\n * @param {contractFacet} zoe - the contract facet of zoe\n */\nconst makeContract = harden((zoe, terms) => {\n let offersCount = 0;\n const makeSeatInvite = () => {\n const seat = harden({\n makeOffer: () => {\n offersCount += 1;\n // eslint-disable-next-line no-use-before-define\n zoe.complete(harden([inviteHandle]));\n return `The offer was accepted`;\n },\n });\n const { invite, inviteHandle } = zoe.makeInvite(seat, {\n seatDesc: 'getRefund',\n });\n return invite;\n };\n return harden({\n invite: makeSeatInvite(),\n publicAPI: {\n getOffersCount: () => offersCount,\n makeInvite: makeSeatInvite,\n },\n terms,\n });\n});\n\nexports.makeContract = makeContract;\n\n\nreturn module.exports;\n}\n", "getExport");`
11. `inviteP = automaticRefundHandleP.then( automaticRefundHandle =>
E(home.zoe).makeInstance(automaticRefundHandle, harden({ assays:
[moolaAssayP, simoleanAssayP]})));`
12. `inviteAssayP = E(home.zoe).getInviteAssay();`
13. `exclInviteP = E(inviteAssayP).claimAll(inviteP);`
14. `E(exclInviteP).getBalance();`
15. `E(moolaAssayP).makeUnits(3).then(units => moola3 = units);`
16. `E(simoleanAssayP).makeUnits(2).then(units => simoleans2 = units);`
17. `offerRules = harden({ payoutRules: [{ kind: 'wantAtLeast', units:
moola3}, { kind: 'wantAtLeast', units: simoleans2 }], exitRule: {
kind: 'waived' }});`
18. `seatAndPayoutP = E(home.zoe).redeem(exclInviteP, offerRules,
harden([undefined, undefined]));`
19. `seatAndPayoutP.then(obj => {seat = obj.seat; payoutP = obj.payout});`
20. `E(seat).makeOffer();`
21. `payoutP.then(p => moolaPayment = p[0]);`
20. `E(moolaPayment).getBalance();` (should be an extent of 0)
3. ... Profit!


To test that the update works with agoric-cli, follow the instructions
Expand Down
8 changes: 0 additions & 8 deletions packages/zoe/src/evalContractCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ const evalContractBundle = (bundle, additionalEndowments = {}) => {
...console,
log: console.info,
};
function myRequire(what) {
if (what === '@agoric/harden') {
return harden;
}
throw Error(`require(${what}) not implemented`);
}
harden(myRequire);

// TODO: this should really only be console and HandledPromise
const defaultEndowments = {
Expand All @@ -36,7 +29,6 @@ const evalContractBundle = (bundle, additionalEndowments = {}) => {
const fullEndowments = Object.create(null, {
...Object.getOwnPropertyDescriptors(defaultEndowments),
...Object.getOwnPropertyDescriptors(additionalEndowments),
...Object.getOwnPropertyDescriptors({ require: myRequire }),
});

// Evaluate the export function, and use the resulting
Expand Down
20 changes: 0 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@
"@agoric/default-evaluate-options" "^0.3.6"
esm "^3.2.5"

"@agoric/harden@^0.0.4":
version "0.0.4"
resolved "https://registry.yarnpkg.com/@agoric/harden/-/harden-0.0.4.tgz#b0d0b2fdfc1a8c7e60454374824442f5b37ea8bd"
integrity sha512-WvTw2otvchy3mScAvqQcX0l6049xp6cF17/Pw0PNNqUTJtOo/84tE9OyBSjEp8wn/XBNArPaJuRjMhQpIQ775Q==
dependencies:
"@agoric/make-hardener" "0.0.4"

"@agoric/harden@^0.0.6":
version "0.0.6"
resolved "https://registry.yarnpkg.com/@agoric/harden/-/harden-0.0.6.tgz#81f25d008c1bddf7f85fc6878be60490c445bf2b"
Expand All @@ -50,19 +43,6 @@
dependencies:
"@agoric/make-hardener" "0.0.8"

"@agoric/layer-cake@^0.0.1":
version "0.0.1"
resolved "https://registry.yarnpkg.com/@agoric/layer-cake/-/layer-cake-0.0.1.tgz#fb131324b35d0b6e2f9e5ef7a72d8729993c3605"
integrity sha512-IhaLWRn1aX42WdAZF3B5aTL+d4QaB++6SaDg8kDPj92cgmZcY8XVrWH7lKFOxks2Kz2yocgoBxdJTEq6pyN5XA==
dependencies:
"@agoric/harden" "^0.0.4"
esm "^3.2.5"

"@agoric/make-hardener@0.0.4":
version "0.0.4"
resolved "https://registry.yarnpkg.com/@agoric/make-hardener/-/make-hardener-0.0.4.tgz#9b5d6692bc2fbbac2fff0a6682959ac5e69c582d"
integrity sha512-0k/wGkIVQO3IY7p/H/5OS3BIXsRK9Qb7nHnqyvj6hzvSyumwgPp8e4rz5QaVWSen43TGJl+zQn4mW9ZZShT1aw==

"@agoric/make-hardener@0.0.8":
version "0.0.8"
resolved "https://registry.yarnpkg.com/@agoric/make-hardener/-/make-hardener-0.0.8.tgz#7f9e9d6874600b2e1b0543ce9456fbf62463be2d"
Expand Down

0 comments on commit eee6fe1

Please sign in to comment.