Skip to content

Commit

Permalink
fix: endow with original unstructured assert
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Jun 15, 2024
1 parent 513adc9 commit 16b9b69
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 15 deletions.
5 changes: 4 additions & 1 deletion packages/SwingSet/src/controller/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ export async function makeSwingsetController(
filePrefix: 'kernel/...',
endowments: {
console: makeConsole(`${debugPrefix}SwingSet:kernel`),
assert,
// This is the underlying unstructured assert that @endo/errors
// uses to build the structured assert that it exports. So we
// cannot use the assert imported from @endo/errors here.
assert: globalThis.assert,
require: kernelRequire,
URL: globalThis.Base64, // Unavailable only on XSnap
Base64: globalThis.Base64, // Available only on XSnap
Expand Down
9 changes: 8 additions & 1 deletion packages/SwingSet/src/kernel/kernel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1644,7 +1644,14 @@ export default function buildKernel(
assert(bundle);
const NS = await importBundle(bundle, {
filePrefix: `dev-${name}/...`,
endowments: harden({ ...vatEndowments, console: devConsole, assert }),
endowments: harden({
...vatEndowments,
console: devConsole,
// This is the underlying unstructured assert that @endo/errors
// uses to build the structured assert that it exports. So we
// cannot use the assert imported from @endo/errors here.
assert: globalThis.assert
}),
});

if (deviceEndowments[name] || unendowed) {
Expand Down
5 changes: 4 additions & 1 deletion packages/SwingSet/src/kernel/vat-loader/manager-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ export function makeLocalVatManagerFactory({
const workerEndowments = harden({
...vatEndowments,
console: makeVatConsole(makeLogMaker('vat')),
assert,
// This is the underlying unstructured assert that @endo/errors
// uses to build the structured assert that it exports. So we
// cannot use the assert imported from @endo/errors here.
assert: globalThis.assert,
TextEncoder,
TextDecoder,
Base64: globalThis.Base64, // Available only on XSnap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ function handleSetBundle(margs) {
// Enable or disable the console accordingly.
const workerEndowments = {
console: makeVatConsole(makeLogMaker(`SwingSet:vat:${vatID}`)),
assert,
// This is the underlying unstructured assert that @endo/errors
// uses to build the structured assert that it exports. So we
// cannot use the assert imported from @endo/errors here.
assert: globalThis.assert,
};

async function buildVatNamespace(lsEndowments, inescapableGlobalProperties) {
Expand Down
12 changes: 9 additions & 3 deletions packages/SwingSet/test/zcf-ish-upgrade/pseudo-zcf.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// @ts-nocheck
/* global VatData */
/* global globalThis, VatData */
/* eslint-disable no-unused-vars */

import { Far } from '@endo/far';
import { importBundle } from '@endo/import-bundle';
import { defineDurableKind } from '@agoric/vat-data';
import { assert } from '@agoric/assert';
import {
provideHandle,
provideBaggageSubset as provideBaggageSubTree,
Expand All @@ -24,7 +23,14 @@ export const buildRootObject = async (vatPowers, vatParameters, baggage) => {
const { D } = vatPowers;
const { contractBundleCap } = vatParameters;
const contractBundle = D(contractBundleCap).getBundle();
const endowments = { console, assert, VatData };
const endowments = {
console,
// This is the underlying unstructured assert that @endo/errors
// uses to build the structured assert that it exports. So we
// cannot use the assert imported from @endo/errors here.
assert: globalThis.assert,
VatData,
};
const contractNS = await importBundle(contractBundle, { endowments });
const { setupInstallation, setup: _ } = contractNS;
if (!setupInstallation) {
Expand Down
5 changes: 4 additions & 1 deletion packages/cosmic-swingset/scripts/clean-core-eval.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export const compartmentEvaluate = code => {
const globals = harden({
...modules,
...farExports,
assert,
// This is the underlying unstructured assert that @endo/errors
// uses to build the structured assert that it exports. So we
// cannot use the assert imported from @endo/errors here.
assert: globalThis.assert,
console: {
// Ensure we don't pollute stdout.
debug: console.warn,
Expand Down
5 changes: 4 additions & 1 deletion packages/spawner/src/vat-spawned.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import { Far } from '@endo/marshal';
const endowments = {
VatData,
console,
assert,
// This is the underlying unstructured assert that @endo/errors
// uses to build the structured assert that it exports. So we
// cannot use the assert imported from @endo/errors here.
assert: globalThis.assert,
Base64: globalThis.Base64, // Present only on XSnap
URL: globalThis.URL, // Absent only on XSnap
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ function makeWorker(port) {

const workerEndowments = {
console: makeVatConsole(makeLogMaker('vat')),
assert,
// This is the underlying unstructured assert that @endo/errors
// uses to build the structured assert that it exports. So we
// cannot use the assert imported from @endo/errors here.
assert: globalThis.assert,
// bootstrap provides HandledPromise
HandledPromise: globalThis.HandledPromise,
TextEncoder,
Expand Down
5 changes: 4 additions & 1 deletion packages/vats/src/core/chain-behaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ export const bridgeCoreEval = async allPowers => {
const endowments = {
VatData: globalThis.VatData,
console,
assert,
// This is the underlying unstructured assert that @endo/errors
// uses to build the structured assert that it exports. So we
// cannot use the assert imported from @endo/errors here.
assert: globalThis.assert,
Base64: globalThis.Base64, // Present only on XSnap
URL: globalThis.URL, // Absent only on XSnap
};
Expand Down
5 changes: 4 additions & 1 deletion packages/vats/src/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ export function getReplHandler(replObjects, send) {
...farExports,
...vowExports,
E,
assert,
// This is the underlying unstructured assert that @endo/errors
// uses to build the structured assert that it exports. So we
// cannot use the assert imported from @endo/errors here.
assert: globalThis.assert,
console: replConsole,
commands,
history,
Expand Down
2 changes: 1 addition & 1 deletion packages/xsnap/src/avaAssertXS.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ function makeTester(htest, out) {
fail(message) {
assert(false, message);
},
assert,
assert, // Not the SES assert
truthy,
/**
* @param {unknown} value
Expand Down
6 changes: 4 additions & 2 deletions packages/zoe/src/contractFacet/evalContractCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
/* global globalThis */

import { importBundle } from '@endo/import-bundle';
import { assert } from '@agoric/assert';
import { handlePWarning } from '../handleWarning.js';

const evalContractBundle = (bundle, additionalEndowments = {}) => {
Expand All @@ -16,7 +15,10 @@ const evalContractBundle = (bundle, additionalEndowments = {}) => {

const defaultEndowments = {
console: louderConsole,
assert,
// This is the underlying unstructured assert that @endo/errors
// uses to build the structured assert that it exports. So we
// cannot use the assert imported from @endo/errors here.
assert: globalThis.assert,
VatData: globalThis.VatData,
};

Expand Down

0 comments on commit 16b9b69

Please sign in to comment.