Skip to content

Commit

Permalink
BREAKING CHANGE: create the RUN Mint within Zoe (#3647)
Browse files Browse the repository at this point in the history
* BREAKING CHANGE: make the run mint within Zoe, and give only the treasury the ability to create a ZCFMint with it

* chore: change 'makeZoe' to 'makeZoeKit'

* chore: add "shutdownZoeVat" argument to Zoe, and pass it to `makeIssuerKit` for invitation issuerKit and fee issuerKit

* chore: manually lint-fix install-on-chain.js

See #3672 for the issue to fix the root problem
  • Loading branch information
katelynsills authored and michaelfig committed Aug 17, 2021
1 parent e347ec5 commit 48762aa
Show file tree
Hide file tree
Showing 68 changed files with 658 additions and 228 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import { makeIssuerKit } from '@agoric/ertp';
import { makeZoe } from '@agoric/zoe';
import { makeZoeKit } from '@agoric/zoe';
import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
// eslint-disable-next-line import/no-extraneous-dependencies
import { makeBoard } from '@agoric/vats/src/lib-board.js';
Expand All @@ -24,7 +24,7 @@ function makeFakeMyAddressNameAdmin() {
}

const setup = async () => {
const zoe = makeZoe(fakeVatAdmin);
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const board = makeBoard();

const pursesStateChangeHandler = _data => {};
Expand Down
8 changes: 4 additions & 4 deletions packages/dapp-svelte-wallet/api/test/test-lib-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';
import bundleSource from '@agoric/bundle-source';
import { makeIssuerKit, AmountMath, AssetKind } from '@agoric/ertp';

import { makeZoe } from '@agoric/zoe';
import { makeZoeKit } from '@agoric/zoe';
import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';

import { assert } from '@agoric/assert';
Expand Down Expand Up @@ -45,7 +45,7 @@ async function setupTest() {
const moolaBundle = makeIssuerKit('moola');
const simoleanBundle = makeIssuerKit('simolean');
const rpgBundle = makeIssuerKit('rpg', AssetKind.SET);
const zoe = makeZoe(fakeVatAdmin);
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const board = makeBoard();

// Create AutomaticRefund instance
Expand Down Expand Up @@ -1193,7 +1193,7 @@ test('addOffer offer.invitation', async t => {
});

test('addOffer makeContinuingInvitation', async t => {
const zoe = makeZoe(fakeVatAdmin);
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const board = makeBoard();

// Create ContinuingInvitationExample instance
Expand Down Expand Up @@ -1275,7 +1275,7 @@ test('addOffer makeContinuingInvitation', async t => {
});

test('getZoe, getBoard', async t => {
const zoe = makeZoe(fakeVatAdmin);
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);
const board = makeBoard();

const pursesStateChangeHandler = _data => {};
Expand Down
4 changes: 2 additions & 2 deletions packages/deploy-script-support/test/unitTests/test-install.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import { makeZoe } from '@agoric/zoe';
import { makeZoeKit } from '@agoric/zoe';
import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
import { makeBoard } from '@agoric/vats/src/lib-board.js';
import bundleSource from '@agoric/bundle-source';
Expand All @@ -12,7 +12,7 @@ import '../../exported.js';
import { makeInstall } from '../../src/install.js';

test('install', async t => {
const zoe = makeZoe(fakeVatAdmin);
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);

let addedInstallation;

Expand Down
4 changes: 2 additions & 2 deletions packages/deploy-script-support/test/unitTests/test-offer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import { makeZoe } from '@agoric/zoe';
import { makeZoeKit } from '@agoric/zoe';
import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
import bundleSource from '@agoric/bundle-source';
import { makeIssuerKit, AmountMath } from '@agoric/ertp';
Expand Down Expand Up @@ -37,7 +37,7 @@ test('offer', async t => {
},
saveOfferResult: () => {},
};
const zoe = makeZoe(fakeVatAdmin);
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);

const bundleUrl = await importMetaResolve(
'@agoric/zoe/src/contracts/automaticRefund.js',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import { makeZoe } from '@agoric/zoe';
import { makeZoeKit } from '@agoric/zoe';
import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
import bundleSource from '@agoric/bundle-source';
import { makeIssuerKit } from '@agoric/ertp';
Expand All @@ -19,7 +19,7 @@ test('startInstance', async t => {
const moolaKit = makeIssuerKit('moola');
const usdKit = makeIssuerKit('usd');

const zoe = makeZoe(fakeVatAdmin);
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);

const bundleUrl = new URL(
await importMetaResolve(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

import { Far } from '@agoric/marshal';

import { makeZoe } from '@agoric/zoe';
import { makeZoeKit } from '@agoric/zoe';

export function buildRootObject(_vatPowers) {
export function buildRootObject(vatPowers) {
return Far('root', {
buildZoe: vatAdminSvc => makeZoe(vatAdminSvc),
buildZoe: vatAdminSvc => {
const shutdownZoeVat = vatPowers.exitVatWithFailure;
const { zoeService: zoe } = makeZoeKit(vatAdminSvc, shutdownZoeVat);
return zoe;
},
});
}
4 changes: 2 additions & 2 deletions packages/governance/test/unitTests/test-committee.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import '@agoric/zoe/exported.js';

import path from 'path';
import { E } from '@agoric/eventual-send';
import { makeZoe } from '@agoric/zoe';
import { makeZoeKit } from '@agoric/zoe';
import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
import bundleSource from '@agoric/bundle-source';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
Expand All @@ -20,7 +20,7 @@ const registrarRoot = `${dirname}/../../src/committeeRegistrar.js`;
const counterRoot = `${dirname}/../../src/binaryBallotCounter.js`;

async function setupContract() {
const zoe = makeZoe(fakeVatAdmin);
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);

// pack the contract
const [registrarBundle, counterBundle] = await Promise.all([
Expand Down
36 changes: 24 additions & 12 deletions packages/pegasus/bundles/install-on-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ import pegasusBundle from './bundle-pegasus.js';
* @param {NameHub} param0.namesByAddress
* @param {ERef<ZoeService>} param0.zoe
*/
export async function installOnChain({ agoricNames, board, nameAdmins, namesByAddress, zoe }) {
export async function installOnChain({
agoricNames,
board,
nameAdmins,
namesByAddress,
zoe,
}) {
// Fetch the nameAdmins we need.
const [installAdmin, instanceAdmin, uiConfigAdmin] = await Promise.all(
['installation', 'instance', 'uiConfig'].map(async edge => {
Expand All @@ -38,8 +44,12 @@ export async function installOnChain({ agoricNames, board, nameAdmins, namesByAd
namesByAddress,
});

const { instance, creatorFacet } = await E(zoe).startInstance(pegasusInstall, undefined, terms);

const { instance, creatorFacet } = await E(zoe).startInstance(
pegasusInstall,
undefined,
terms,
);

const pegasusUiDefaults = {
CONTRACT_NAME: 'Pegasus',
BRIDGE_URL: 'http://127.0.0.1:8000',
Expand All @@ -49,14 +59,14 @@ export async function installOnChain({ agoricNames, board, nameAdmins, namesByAd
};

// Look up all the board IDs.
const boardIdValue = [
['INSTANCE_BOARD_ID', instance],
];
await Promise.all(boardIdValue.map(async ([key, valP]) => {
const val = await valP;
const boardId = await E(board).getId(val);
pegasusUiDefaults[key] = boardId;
}));
const boardIdValue = [['INSTANCE_BOARD_ID', instance]];
await Promise.all(
boardIdValue.map(async ([key, valP]) => {
const val = await valP;
const boardId = await E(board).getId(val);
pegasusUiDefaults[key] = boardId;
}),
);

// Stash the defaults where the UI can find them.
harden(pegasusUiDefaults);
Expand All @@ -69,7 +79,9 @@ export async function installOnChain({ agoricNames, board, nameAdmins, namesByAd
[instanceAdmin, pegasusUiDefaults.CONTRACT_NAME, instance],
];
await Promise.all(
nameAdminUpdates.map(([nameAdmin, name, value]) => E(nameAdmin).update(name, value)),
nameAdminUpdates.map(([nameAdmin, name, value]) =>
E(nameAdmin).update(name, value),
),
);

return creatorFacet;
Expand Down
4 changes: 2 additions & 2 deletions packages/pegasus/test/test-peg.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {

import bundleSource from '@agoric/bundle-source';
import { AmountMath } from '@agoric/ertp';
import { makeZoe } from '@agoric/zoe';
import { makeZoeKit } from '@agoric/zoe';

import fakeVatAdmin from '@agoric/zoe/tools/fakeVatAdmin.js';
import { Far } from '@agoric/marshal';
Expand Down Expand Up @@ -47,7 +47,7 @@ async function testRemotePeg(t) {
},
});

const zoe = makeZoe(fakeVatAdmin);
const { zoeService: zoe } = makeZoeKit(fakeVatAdmin);

// Pack the contract.
const contractBundle = await bundleSource(contractPath);
Expand Down
17 changes: 14 additions & 3 deletions packages/swingset-runner/demo/exchangeBenchmark/vat-zoe.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { makeZoe } from '@agoric/zoe';
// @ts-check

import { Far } from '@agoric/marshal';

export function buildRootObject(_vatPowers, vatParameters) {
import { makeZoeKit } from '@agoric/zoe';

export function buildRootObject(vatPowers, vatParameters) {
return Far('root', {
buildZoe: vatAdminSvc => makeZoe(vatAdminSvc, vatParameters.zcfBundleName),
buildZoe: vatAdminSvc => {
const shutdownZoeVat = vatPowers.exitVatWithFailure;
const { zoeService: zoe } = makeZoeKit(
vatAdminSvc,
shutdownZoeVat,
vatParameters.zcfBundleName,
);
return zoe;
},
});
}
17 changes: 14 additions & 3 deletions packages/swingset-runner/demo/swapBenchmark/vat-zoe.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { makeZoe } from '@agoric/zoe';
// @ts-check

import { Far } from '@agoric/marshal';

export function buildRootObject(_vatPowers, vatParameters) {
import { makeZoeKit } from '@agoric/zoe';

export function buildRootObject(vatPowers, vatParameters) {
return Far('root', {
buildZoe: vatAdminSvc => makeZoe(vatAdminSvc, vatParameters.zcfBundleName),
buildZoe: vatAdminSvc => {
const shutdownZoeVat = vatPowers.exitVatWithFailure;
const { zoeService: zoe } = makeZoeKit(
vatAdminSvc,
shutdownZoeVat,
vatParameters.zcfBundleName,
);
return zoe;
},
});
}
18 changes: 14 additions & 4 deletions packages/swingset-runner/demo/zoeTests/vat-zoe.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
// noinspection ES6PreferShortImport
import { makeZoe } from '@agoric/zoe';
// @ts-check

import { Far } from '@agoric/marshal';

export function buildRootObject(_vatPowers, vatParameters) {
import { makeZoeKit } from '@agoric/zoe';

export function buildRootObject(vatPowers, vatParameters) {
return Far('root', {
buildZoe: vatAdminSvc => makeZoe(vatAdminSvc, vatParameters.zcfBundleName),
buildZoe: vatAdminSvc => {
const shutdownZoeVat = vatPowers.exitVatWithFailure;
const { zoeService: zoe } = makeZoeKit(
vatAdminSvc,
shutdownZoeVat,
vatParameters.zcfBundleName,
);
return zoe;
},
});
}
Loading

0 comments on commit 48762aa

Please sign in to comment.