Skip to content

Commit

Permalink
WIP: away with boot-psm
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed May 3, 2023
1 parent 28dbdea commit 96e15f7
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 96 deletions.
2 changes: 1 addition & 1 deletion packages/vats/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export * from './src/types.js';
export * from './src/nameHub.js';
export * from './src/bridge.js';
export { makePromiseSpace } from './src/core/promise-space.js';
export { makeAgoricNamesAccess } from './src/core/utils.js';
export { makeWellKnownSpaces } from './src/core/utils.js';
62 changes: 1 addition & 61 deletions packages/vats/src/core/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { E } from '@endo/far';
import { heapZone } from '@agoric/zone';
import { provide } from '@agoric/vat-data';
import { makeNameHubKit } from '../nameHub.js';
import { Stable, Stake } from '../tokens.js';
import { makeLogHooks, makePromiseSpace } from './promise-space.js';

Expand Down Expand Up @@ -259,66 +258,6 @@ export const makeWellKnownSpaces = async (
return typedSpaces;
};

/**
* Make the well-known agoricNames namespace so that we can
* E(home.agoricNames).lookup('issuer', 'IST') and likewise
* for brand, installation, instance, etc.
*
* @param {typeof console.log} [log]
* @param {Record<string, Record<string, unknown>>} reserved a property
* for each of issuer, brand, etc. with a value whose keys are names
* to reserve.
*
* For static typing and integrating with the bootstrap permit system,
* return { produce, consume } spaces rather than NameAdmins.
*
* @deprecated in favor of makeWellKnownSpaces
*
* @returns {{
* agoricNames: import('../types.js').NameHub,
* agoricNamesAdmin: import('../types.js').NameAdmin,
* spaces: WellKnownSpaces,
* }}
*/
export const makeAgoricNamesAccess = (
log = noop, // console.debug
reserved = agoricNamesReserved,
) => {
const { nameHub: agoricNames, nameAdmin: agoricNamesAdmin } =
makeNameHubKit();

const hubs = mapEntries(reserved, (key, _d) => {
const { nameHub, nameAdmin } = makeNameHubKit();
// const passableAdmin = {
// ...nameAdmin,
// update: (nameKey, val) => {
// assertPassable(val); // else we can't publish
// return nameAdmin.update(nameKey, val);
// },
// };
agoricNamesAdmin.update(key, nameHub, nameAdmin);
return [key, { nameHub, nameAdmin }];
});
const spaces = mapEntries(reserved, (key, detail) => {
const { nameAdmin } = hubs[key];
const subSpaceLog = (...args) => log(key, ...args);
const { produce, consume } = makePromiseSpace({ log: subSpaceLog });
for (const k of keys(detail)) {
nameAdmin.reserve(k);
void consume[k].then(v => nameAdmin.update(k, v));
}
return [key, { produce, consume }];
});
const typedSpaces = /** @type { WellKnownSpaces } */ (
/** @type {any} */ (spaces)
);
return {
agoricNames,
agoricNamesAdmin,
spaces: typedSpaces,
};
};

/**
* @param {ERef<ReturnType<Awaited<VatAdminVat>['createVatAdminService']>>} svc
* @param {unknown} criticalVatKey
Expand All @@ -338,6 +277,7 @@ export const makeVatSpace = (
) => {
const subSpaceLog = (...args) => log(label, ...args);

// @@@TODO until this subsumes loadCriticalVat, share stores
/** @type {VatStore} */
const store = zone.mapStore('vatStore');

Expand Down
2 changes: 1 addition & 1 deletion packages/vats/test/test-boot-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { mustMatch } from '@agoric/store';
import { loadSwingsetConfigFile, shape as ssShape } from '@agoric/swingset-vat';
import { provideBundleCache } from '@agoric/swingset-vat/tools/bundleTool.js';
import { extractCoreProposalBundles } from '@agoric/deploy-script-support/src/extract-proposal.js';
import { ParametersShape as BootParametersShape } from '../src/core/boot-psm.js';
import { ParametersShape as BootParametersShape } from '@agoric/inter-protocol/test/smartWallet/boot-psm.js/index.js';

/** @type {import('ava').TestFn<Awaited<ReturnType<typeof makeTestContext>>>} */
const test = anyTest;
Expand Down
32 changes: 1 addition & 31 deletions packages/vats/test/test-boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import bundleSourceAmbient from '@endo/bundle-source';
import { E, passStyleOf } from '@endo/far';

import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';
import { buildRootObject as buildPSMRootObject } from '../src/core/boot-psm.js';
import { buildRootObject as buildPSMRootObject } from '@agoric/inter-protocol/test/smartWallet/boot-psm.js/index.js';
import { buildRootObject } from '../src/core/boot-chain.js';
import { buildRootObject as buildSimRootObject } from '../src/core/boot-sim.js';
import { buildRootObject as buildSoloRootObject } from '../src/core/boot-solo.js';
Expand Down Expand Up @@ -152,33 +152,3 @@ test('bootstrap provides a way to pass items to CORE_EVAL', async t => {
await E(root).produceItem('swissArmyKnife', 4);
t.deepEqual(await E(root).consumeItem('swissArmyKnife'), 4);
});

const psmParams = {
anchorAssets: [{ denom: 'ibc/toyusdc' }],
economicCommitteeAddresses: {},
argv: { bootMsg: {} },
};

test.skip(`PSM-only bootstrap`, async t => {
const root = buildPSMRootObject({ D: mockDProxy, logger: t.log }, psmParams);

void E(root).bootstrap(...mockPsmBootstrapArgs(t.log));
await eventLoopIteration();

const agoricNames =
/** @type {Promise<import('../src/types.js').NameHub>} */ (
E(root).consumeItem('agoricNames')
);
const instance = await E(agoricNames).lookup('instance', 'psm-IST-AUSD');
t.is(passStyleOf(instance), 'remotable');
});

test('PSM-only bootstrap provides a way to pass items to CORE_EVAL', async t => {
const root = buildPSMRootObject({ D: mockDProxy, logger: t.log }, psmParams);

await E(root).produceItem('swissArmyKnife', [1, 2, 3]);
t.deepEqual(await E(root).consumeItem('swissArmyKnife'), [1, 2, 3]);
await E(root).resetItem('swissArmyKnife');
await E(root).produceItem('swissArmyKnife', 4);
t.deepEqual(await E(root).consumeItem('swissArmyKnife'), 4);
});
2 changes: 1 addition & 1 deletion packages/vats/test/test-clientBundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { makeIssuerKit } from '@agoric/ertp';
import { makeScalarBigMapStore } from '@agoric/vat-data';
import { connectFaucet, showAmount } from '../src/core/demoIssuers.js';
import { setupClientManager } from '../src/core/chain-behaviors.js';
import { makeAgoricNamesAccess } from '../src/core/utils.js';
import { makeAgoricNamesAccess } from './boot-support';
import { makePromiseSpace } from '../src/core/promise-space.js';
import { buildRootObject as mintsRoot } from '../src/vat-mints.js';
import { buildRootObject as boardRoot } from '../src/vat-board.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/vats/test/test-vat-bank.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
addBankAssets,
installBootContracts,
} from '../src/core/basic-behaviors.js';
import { makeAgoricNamesAccess } from '../src/core/utils.js';
import { makeAgoricNamesAccess } from './boot-support';
import { makePromiseSpace } from '../src/core/promise-space.js';
import { makePopulatedFakeVatAdmin } from '../tools/boot-test-utils.js';

Expand Down

0 comments on commit 96e15f7

Please sign in to comment.