From cacfd6468a19b3fb7c11d63d6b10d843d4c2f33f Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Sun, 6 Aug 2023 13:31:03 -0400 Subject: [PATCH 01/13] ci: error on any 'dependency' cycles --- .github/workflows/test-all-packages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-all-packages.yml b/.github/workflows/test-all-packages.yml index f36700cf44b..cd0761a5ec0 100644 --- a/.github/workflows/test-all-packages.yml +++ b/.github/workflows/test-all-packages.yml @@ -49,7 +49,7 @@ jobs: run: sudo apt install -y graphviz - name: Check for cycles - run: scripts/check-dependency-cycles.sh 1 + run: scripts/check-dependency-cycles.sh ################## # Lint tests From b735591b55199caee53f8fb1b046918aba0c23ea Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Sat, 12 Aug 2023 11:23:01 -0400 Subject: [PATCH 02/13] chore(types): improve coverage --- .../src/externalTypes.js | 2 +- .../src/getBundlerMaker.js | 3 ++ .../src/writeCoreProposal.js | 41 ++++++++++++++++++- .../test/unitTests/test-getBundlerMaker.js | 2 + 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/packages/deploy-script-support/src/externalTypes.js b/packages/deploy-script-support/src/externalTypes.js index 442ea8bcce3..5288582b099 100644 --- a/packages/deploy-script-support/src/externalTypes.js +++ b/packages/deploy-script-support/src/externalTypes.js @@ -30,7 +30,7 @@ export {}; * @param {string} srcSpec * @param {string} bundlePath * @param {any} [opts] - * @returns {ManifestBundleRef} + * @returns {Promise} */ /** diff --git a/packages/deploy-script-support/src/getBundlerMaker.js b/packages/deploy-script-support/src/getBundlerMaker.js index 375d7c331b7..5e419703ca6 100644 --- a/packages/deploy-script-support/src/getBundlerMaker.js +++ b/packages/deploy-script-support/src/getBundlerMaker.js @@ -13,6 +13,8 @@ import { E } from '@endo/far'; import url from 'url'; +/** @typedef {ReturnType['publicFacet']} BundleMaker */ + export const makeGetBundlerMaker = (homeP, { lookup, bundleSource }) => async ({ @@ -20,6 +22,7 @@ export const makeGetBundlerMaker = log = console.log, } = {}) => { const { board: optionalBoard, zoe, scratch } = await homeP; + /** @type {() => Promise} */ const lookupOrCreate = async () => { // Locate the bundler maker if any already exists at the given path. let bundlerMaker = await lookup(JSON.parse(BUNDLER_MAKER_LOOKUP)); diff --git a/packages/deploy-script-support/src/writeCoreProposal.js b/packages/deploy-script-support/src/writeCoreProposal.js index 57e34e9fe05..144ef6bebff 100644 --- a/packages/deploy-script-support/src/writeCoreProposal.js +++ b/packages/deploy-script-support/src/writeCoreProposal.js @@ -7,6 +7,25 @@ import { createBundles } from '@agoric/internal/src/node/createBundles.js'; import { defangAndTrim, mergePermits, stringify } from './code-gen.js'; import { makeCoreProposalBehavior, permits } from './coreProposalBehavior.js'; +/** + * @callback WriteCoreProposal + * @param {string} filePrefix + * @param {import('./externalTypes.js').ProposalBuilder} proposalBuilder + * @returns {Promise} + */ + +/** + * + * @param {*} homeP + * @param {*} endowments + * @param {{ + * getBundlerMaker: () => Promise, + * getBundleSpec: (...args: *) => Promise, + * log?: typeof console.log, + * writeFile?: typeof fs.promises.writeFile + * }} io + * @returns {WriteCoreProposal} + */ export const makeWriteCoreProposal = ( homeP, endowments, @@ -50,8 +69,18 @@ export const makeWriteCoreProposal = ( }; }; - let mutex = Promise.resolve(); + let mutex = + /** @type {Promise} */ ( + Promise.resolve() + ); + /** @type {WriteCoreProposal} */ const writeCoreProposal = async (filePrefix, proposalBuilder) => { + /** + * + * @param {string} entrypoint + * @param {string} [bundlePath] + * @returns {Promise} + */ const getBundle = async (entrypoint, bundlePath) => { if (!bundlePath) { return bundleSource(pathResolve(entrypoint)); @@ -62,7 +91,14 @@ export const makeWriteCoreProposal = ( return ns.default; }; - // Install an entrypoint. + /** + * Install an entrypoint. + * + * @param {string} entrypoint + * @param {string} [bundlePath] + * @param [opts] + * @returns {Promise} + */ const install = async (entrypoint, bundlePath, opts) => { const bundle = getBundle(entrypoint, bundlePath); @@ -71,6 +107,7 @@ export const makeWriteCoreProposal = ( // console.log('installing', { filePrefix, entrypoint, bundlePath }); return getBundleSpec(bundle, getBundler, opts); }); + // @ts-expect-error xxx mutex type narrowing return mutex; }; diff --git a/packages/deploy-script-support/test/unitTests/test-getBundlerMaker.js b/packages/deploy-script-support/test/unitTests/test-getBundlerMaker.js index 53875a9fa7d..bea7a2cb5d4 100644 --- a/packages/deploy-script-support/test/unitTests/test-getBundlerMaker.js +++ b/packages/deploy-script-support/test/unitTests/test-getBundlerMaker.js @@ -15,10 +15,12 @@ test('getBundlerMaker - already made', async t => { const getBundlerMaker = makeGetBundlerMaker({}, { lookup }); const bundler = await getBundlerMaker({ log: t.log }); + // @ts-expect-error mock lookup result t.is(bundler, 'BUNDLER_MAKER_FOUND'); }); test('getBundlerMaker - not yet made', async t => { + /** @type {any} */ let bundlerMaker; const zoe = { install: async b => { From 31d8d6c7ed4798eb3ac7bd39295555185e7189b6 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Sat, 12 Aug 2023 11:35:40 -0400 Subject: [PATCH 03/13] chore(types): package references --- packages/zoe/src/contractSupport/priceAuthority.js | 2 +- packages/zoe/src/contracts/priceAggregator.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/zoe/src/contractSupport/priceAuthority.js b/packages/zoe/src/contractSupport/priceAuthority.js index 851dcc87790..ce752811081 100644 --- a/packages/zoe/src/contractSupport/priceAuthority.js +++ b/packages/zoe/src/contractSupport/priceAuthority.js @@ -1,4 +1,4 @@ -/// +/// import { E } from '@endo/eventual-send'; import { Far } from '@endo/marshal'; diff --git a/packages/zoe/src/contracts/priceAggregator.js b/packages/zoe/src/contracts/priceAggregator.js index a5d1eca3a68..9357d24fe2b 100644 --- a/packages/zoe/src/contracts/priceAggregator.js +++ b/packages/zoe/src/contracts/priceAggregator.js @@ -1,4 +1,4 @@ -/// +/// import { Fail, q } from '@agoric/assert'; import { AmountMath, AssetKind, makeIssuerKit } from '@agoric/ertp'; From d4e8345ec60e36ee7363d51ea12c989707aa1f91 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Sat, 12 Aug 2023 12:06:57 -0400 Subject: [PATCH 04/13] feat: print path on loadSwingsetConfigFile failure --- packages/SwingSet/src/controller/initializeSwingset.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/SwingSet/src/controller/initializeSwingset.js b/packages/SwingSet/src/controller/initializeSwingset.js index 89eb7213eff..89989358724 100644 --- a/packages/SwingSet/src/controller/initializeSwingset.js +++ b/packages/SwingSet/src/controller/initializeSwingset.js @@ -249,6 +249,7 @@ export async function loadSwingsetConfigFile(configPath) { Fail`bootstrap vat ${config.bootstrap} not found in ${configPath}`; return config; } catch (e) { + console.error(`failed to load ${configPath}`); if (e.code === 'ENOENT') { return null; } else { From 206b5701223499464c8020487a641d2b0bf39118 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Sun, 6 Aug 2023 11:01:04 -0400 Subject: [PATCH 05/13] refactor: move down UnguardedHelperI --- packages/inter-protocol/src/price/roundsManager.js | 2 +- .../inter-protocol/src/reserve/assetReserveKit.js | 2 +- packages/inter-protocol/src/typeGuards.js | 11 ----------- packages/inter-protocol/src/vaultFactory/vault.js | 2 +- .../inter-protocol/src/vaultFactory/vaultHolder.js | 2 +- packages/internal/src/typeGuards.js | 8 ++++++++ packages/vats/src/provisionPoolKit.js | 2 +- 7 files changed, 13 insertions(+), 16 deletions(-) delete mode 100644 packages/inter-protocol/src/typeGuards.js diff --git a/packages/inter-protocol/src/price/roundsManager.js b/packages/inter-protocol/src/price/roundsManager.js index 881d4831d29..0347ab4d48b 100644 --- a/packages/inter-protocol/src/price/roundsManager.js +++ b/packages/inter-protocol/src/price/roundsManager.js @@ -10,7 +10,7 @@ import { import { E } from '@endo/eventual-send'; import { Far } from '@endo/marshal'; import { isNat, Nat } from '@endo/nat'; -import { UnguardedHelperI } from '../typeGuards.js'; +import { UnguardedHelperI } from '@agoric/internal/src/typeGuards.js'; const { add, subtract, multiply, floorDivide, ceilDivide, isGTE } = natSafeMath; diff --git a/packages/inter-protocol/src/reserve/assetReserveKit.js b/packages/inter-protocol/src/reserve/assetReserveKit.js index bcc4096cdde..3610027a726 100644 --- a/packages/inter-protocol/src/reserve/assetReserveKit.js +++ b/packages/inter-protocol/src/reserve/assetReserveKit.js @@ -9,7 +9,7 @@ import { } from '@agoric/zoe/src/contractSupport/topics.js'; import { AmountKeywordRecordShape } from '@agoric/zoe/src/typeGuards.js'; import { E } from '@endo/eventual-send'; -import { UnguardedHelperI } from '../typeGuards.js'; +import { UnguardedHelperI } from '@agoric/internal/src/typeGuards.js'; const { quote: q } = assert; diff --git a/packages/inter-protocol/src/typeGuards.js b/packages/inter-protocol/src/typeGuards.js deleted file mode 100644 index f3a055a082e..00000000000 --- a/packages/inter-protocol/src/typeGuards.js +++ /dev/null @@ -1,11 +0,0 @@ -// @jessie-check - -import { M } from '@agoric/store'; - -/** To be used only for 'helper' facets where the calls are from trusted code. */ -export const UnguardedHelperI = M.interface( - 'helper', - {}, - // not exposed so sloppy okay - { sloppy: true }, -); diff --git a/packages/inter-protocol/src/vaultFactory/vault.js b/packages/inter-protocol/src/vaultFactory/vault.js index 646271ec8ac..df98b78931a 100644 --- a/packages/inter-protocol/src/vaultFactory/vault.js +++ b/packages/inter-protocol/src/vaultFactory/vault.js @@ -9,7 +9,7 @@ import { makeNatAmountShape, } from '../contractSupport.js'; import { calculateCurrentDebt, reverseInterest } from '../interest-math.js'; -import { UnguardedHelperI } from '../typeGuards.js'; +import { UnguardedHelperI } from '@agoric/internal/src/typeGuards.js'; import { prepareVaultKit } from './vaultKit.js'; import '@agoric/zoe/exported.js'; diff --git a/packages/inter-protocol/src/vaultFactory/vaultHolder.js b/packages/inter-protocol/src/vaultFactory/vaultHolder.js index b5e8ef61507..025339b9f9e 100644 --- a/packages/inter-protocol/src/vaultFactory/vaultHolder.js +++ b/packages/inter-protocol/src/vaultFactory/vaultHolder.js @@ -2,7 +2,7 @@ import { AmountShape } from '@agoric/ertp'; import { M, prepareExoClassKit } from '@agoric/vat-data'; import { TopicsRecordShape } from '@agoric/zoe/src/contractSupport/index.js'; -import { UnguardedHelperI } from '../typeGuards.js'; +import { UnguardedHelperI } from '@agoric/internal/src/typeGuards.js'; const { Fail } = assert; diff --git a/packages/internal/src/typeGuards.js b/packages/internal/src/typeGuards.js index e5b4bd691f1..e6366de16bb 100644 --- a/packages/internal/src/typeGuards.js +++ b/packages/internal/src/typeGuards.js @@ -3,3 +3,11 @@ import { M } from '@endo/patterns'; export const StorageNodeShape = M.remotable('StorageNode'); + +/** To be used only for 'helper' facets where the calls are from trusted code. */ +export const UnguardedHelperI = M.interface( + 'helper', + {}, + // not exposed so sloppy okay + { sloppy: true }, +); diff --git a/packages/vats/src/provisionPoolKit.js b/packages/vats/src/provisionPoolKit.js index 7cfbc1a88e0..50e2b95d961 100644 --- a/packages/vats/src/provisionPoolKit.js +++ b/packages/vats/src/provisionPoolKit.js @@ -1,6 +1,6 @@ // @ts-check import { AmountMath, BrandShape } from '@agoric/ertp'; -import { UnguardedHelperI } from '@agoric/inter-protocol/src/typeGuards.js'; +import { UnguardedHelperI } from '@agoric/internal/src/typeGuards.js'; import { observeIteration, observeNotifier, From fcac65a031c21cec9874385733239deae82d803b Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Sun, 6 Aug 2023 11:09:15 -0400 Subject: [PATCH 06/13] refactor: raise mockPsmBootstrapArgs --- packages/inter-protocol/test/smartWallet/contexts.js | 8 +++++++- .../test/smartWallet/test-oracle-integration.js | 2 +- .../test/smartWallet/test-psm-integration.js | 2 +- packages/vats/tools/boot-test-utils.js | 7 ------- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/inter-protocol/test/smartWallet/contexts.js b/packages/inter-protocol/test/smartWallet/contexts.js index f4d12d6a5a5..1eef9117710 100644 --- a/packages/inter-protocol/test/smartWallet/contexts.js +++ b/packages/inter-protocol/test/smartWallet/contexts.js @@ -31,7 +31,13 @@ export const importBootTestUtils = async (log, bundleCache) => { bundleCache.validateOrAdd(entrypoint, name), ), ); - return import('@agoric/vats/tools/boot-test-utils.js'); + const utils = await import('@agoric/vats/tools/boot-test-utils.js'); + const mockPsmBootstrapArgs = () => { + const mock = utils.makeMock(log); + const vats = utils.mockSwingsetVats(mock); + return [vats, mock.devices]; + }; + return { ...utils, mockPsmBootstrapArgs }; }; /** diff --git a/packages/inter-protocol/test/smartWallet/test-oracle-integration.js b/packages/inter-protocol/test/smartWallet/test-oracle-integration.js index 584d5023373..f1c974ee26d 100644 --- a/packages/inter-protocol/test/smartWallet/test-oracle-integration.js +++ b/packages/inter-protocol/test/smartWallet/test-oracle-integration.js @@ -53,7 +53,7 @@ const makeTestSpace = async (log, bundleCache) => { }, psmParams, ); - void psmVatRoot.bootstrap(...mockPsmBootstrapArgs(log)); + void psmVatRoot.bootstrap(...mockPsmBootstrapArgs()); // TODO mimic the proposals and manifest of price-feed-proposal and price-feed-core // calling ensureOracleBrands and createPriceFeed diff --git a/packages/inter-protocol/test/smartWallet/test-psm-integration.js b/packages/inter-protocol/test/smartWallet/test-psm-integration.js index 1fca3f70df5..9a6ee8c110a 100644 --- a/packages/inter-protocol/test/smartWallet/test-psm-integration.js +++ b/packages/inter-protocol/test/smartWallet/test-psm-integration.js @@ -47,7 +47,7 @@ const makePsmTestSpace = async (log, bundleCache) => { }, psmParams, ); - void psmVatRoot.bootstrap(...mockPsmBootstrapArgs(log)); + void psmVatRoot.bootstrap(...mockPsmBootstrapArgs()); return psmVatRoot.getPromiseSpace(); }; diff --git a/packages/vats/tools/boot-test-utils.js b/packages/vats/tools/boot-test-utils.js index 35f63428f88..4aecb0d4bcb 100644 --- a/packages/vats/tools/boot-test-utils.js +++ b/packages/vats/tools/boot-test-utils.js @@ -155,10 +155,3 @@ export const mockSwingsetVats = mock => { }; return vats; }; - -/** @param {(msg: string) => void} log */ -export const mockPsmBootstrapArgs = log => { - const mock = makeMock(log); - const vats = mockSwingsetVats(mock); - return [vats, mock.devices]; -}; From 24a29de9a3388f9cf6eff7ab8a679bce21b142fc Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Sun, 6 Aug 2023 13:09:31 -0400 Subject: [PATCH 07/13] test: decouple smartWallet from vats --- .../test/smartWallet/boot-test-utils.js | 141 ++++++++++++++++++ .../test/smartWallet/contexts.js | 2 +- .../test/smartWallet/devices.js | 14 +- packages/vats/test/devices.js | 13 -- 4 files changed, 154 insertions(+), 16 deletions(-) create mode 100644 packages/inter-protocol/test/smartWallet/boot-test-utils.js diff --git a/packages/inter-protocol/test/smartWallet/boot-test-utils.js b/packages/inter-protocol/test/smartWallet/boot-test-utils.js new file mode 100644 index 00000000000..43454629426 --- /dev/null +++ b/packages/inter-protocol/test/smartWallet/boot-test-utils.js @@ -0,0 +1,141 @@ +/** + * @file approximately the same as the one in @agoric/vats. It's copied over to + * decouple the packages and because the test here is a deprecated style. It + * integrates multiple bundles so should move to a bootstrap-style test. + */ +// @ts-check +import { + makeFakeVatAdmin, + zcfBundleCap, +} from '@agoric/zoe/tools/fakeVatAdmin.js'; +import buildManualTimer from '@agoric/zoe/tools/manualTimer.js'; +import { Far } from '@endo/marshal'; +import { makeScalarBigMapStore } from '@agoric/vat-data'; +import { vatRoots } from '@agoric/vats/tools/boot-test-utils.js'; +import { bundles, devices } from './devices.js'; + +const { Fail } = assert; + +export const noop = () => {}; + +/** @type {DProxy} */ +// @ts-expect-error cast +export const mockDProxy = d => d; + +export const makeMock = log => + harden({ + devices: { + command: /** @type {any} */ ({ registerInboundHandler: noop }), + mailbox: /** @type {any} */ ({ + registerInboundHandler: noop, + }), + timer: /** @type {any} */ ({}), + plugin: /** @type {any} */ ({ registerReceiver: noop }), + ...devices, + }, + vats: { + vattp: /** @type {any} */ ( + Far('vattp', { + registerMailboxDevice: noop, + addRemote: () => harden({}), + }) + ), + comms: Far('comms', { + addRemote: noop, + addEgress: noop, + addIngress: async () => + harden({ + getConfiguration: () => harden({ _: 'client configuration' }), + }), + }), + http: { setPresences: noop, setCommandDevice: noop }, + spawner: { + buildSpawner: () => harden({ _: 'spawner' }), + }, + timer: Far('TimerVat', { + createTimerService: async () => buildManualTimer(log), + }), + uploads: { getUploads: () => harden({ _: 'uploads' }) }, + + network: Far('network', { + registerProtocolHandler: noop, + bind: () => harden({ addListener: noop }), + }), + }, + }); + +export const makePopulatedFakeVatAdmin = () => { + // The .createVat() from zoe/tools/fakeVatAdmin.js only knows how to + // make ZCF vats, so wrap it in a form that can create the other + // vats too. We have two types. + + const fakeCapToName = new Map(); // cap -> name + const fakeNameToCap = new Map(); // name -> cap + const { admin: fakeVatAdmin, vatAdminState } = makeFakeVatAdmin(); + for (const name of Object.getOwnPropertyNames(vatRoots)) { + // These don't have real bundles (just a buildRootObject + // function), but fakeVatAdmin wants to see a bundle.endoZipBase64 + // hash, so make some fake ones. + const id = `id-${name}`; // fake bundleID + const bundle = { endoZipBase64: id }; + const cap = vatAdminState.installNamedBundle(name, id, bundle); + fakeCapToName.set(cap, name); + fakeNameToCap.set(name, cap); + } + + for (const [name, bundle] of Object.entries(bundles)) { + // These *do* have real bundles, with an ID and everything. + const id = bundle.endoZipBase64Sha512; + const cap = vatAdminState.installNamedBundle(name, id, bundle); + fakeCapToName.set(cap, name); + fakeNameToCap.set(name, cap); + } + + const createVat = (bundleCap, options) => { + assert(bundleCap); + if (bundleCap === zcfBundleCap) { + return fakeVatAdmin.createVat(zcfBundleCap, options); + } + const name = fakeCapToName.get(bundleCap); + assert(name); + const buildRoot = vatRoots[name]; + if (!buildRoot) { + throw Error(`TODO: load vat ${name}`); + } + const vatParameters = { ...options?.vatParameters }; + if (name === 'zoe') { + // basic-behaviors.js:buildZoe() provides hard-coded zcf BundleName + // and vat-zoe.js ignores vatParameters, but this would be the + // preferred way to pass the name. + vatParameters.zcfBundleName = 'zcf'; + } + const baggage = makeScalarBigMapStore('baggage'); + const adminNode = + /** @type {import('@agoric/swingset-vat').VatAdminFacet} */ ({}); + return { root: buildRoot({}, vatParameters, baggage), adminNode }; + }; + const createVatByName = async name => { + return createVat(fakeNameToCap.get(name) || Fail`unknown vat ${name}`); + }; + + const vatAdminService = Far('vatAdminSvc', { + ...fakeVatAdmin, + createVat, + createVatByName, + }); + const criticalVatKey = vatAdminState.getCriticalVatKey(); + const getCriticalVatKey = () => criticalVatKey; + const createVatAdminService = () => vatAdminService; + /** @type {any} */ + const vatAdminRoot = { getCriticalVatKey, createVatAdminService }; + return { vatAdminService, vatAdminRoot }; +}; + +export const mockSwingsetVats = mock => { + const { vatAdminRoot } = makePopulatedFakeVatAdmin(); + const vats = { + ...mock.vats, + vatAdmin: vatAdminRoot, + }; + return vats; +}; diff --git a/packages/inter-protocol/test/smartWallet/contexts.js b/packages/inter-protocol/test/smartWallet/contexts.js index 1eef9117710..bda0f17aa76 100644 --- a/packages/inter-protocol/test/smartWallet/contexts.js +++ b/packages/inter-protocol/test/smartWallet/contexts.js @@ -31,7 +31,7 @@ export const importBootTestUtils = async (log, bundleCache) => { bundleCache.validateOrAdd(entrypoint, name), ), ); - const utils = await import('@agoric/vats/tools/boot-test-utils.js'); + const utils = await import('./boot-test-utils.js'); const mockPsmBootstrapArgs = () => { const mock = utils.makeMock(log); const vats = utils.mockSwingsetVats(mock); diff --git a/packages/inter-protocol/test/smartWallet/devices.js b/packages/inter-protocol/test/smartWallet/devices.js index 36bb6fe1671..12a8cecfc9f 100644 --- a/packages/inter-protocol/test/smartWallet/devices.js +++ b/packages/inter-protocol/test/smartWallet/devices.js @@ -1,12 +1,22 @@ +import binaryVoteCounter from '@agoric/governance/bundles/bundle-binaryVoteCounter.js'; +import committee from '@agoric/governance/bundles/bundle-committee.js'; +import contractGovernor from '@agoric/governance/bundles/bundle-contractGovernor.js'; +import walletFactory from '@agoric/smart-wallet/bundles/bundle-walletFactory.js'; import centralSupply from '@agoric/vats/bundles/bundle-centralSupply.js'; import mintHolder from '@agoric/vats/bundles/bundle-mintHolder.js'; import provisionPool from '@agoric/vats/bundles/bundle-provisionPool.js'; -import walletFactory from '@agoric/smart-wallet/bundles/bundle-walletFactory.js'; +import econCommitteeCharter from '../../bundles/bundle-econCommitteeCharter.js'; +import psm from '../../bundles/bundle-psm.js'; -const bundles = { +export const bundles = { + binaryVoteCounter, centralSupply, + committee, + contractGovernor, mintHolder, provisionPool, + psm, + econCommitteeCharter, walletFactory, }; diff --git a/packages/vats/test/devices.js b/packages/vats/test/devices.js index c9b5e7745e1..908ad4a6481 100644 --- a/packages/vats/test/devices.js +++ b/packages/vats/test/devices.js @@ -1,24 +1,11 @@ -import binaryVoteCounter from '@agoric/governance/bundles/bundle-binaryVoteCounter.js'; -import committee from '@agoric/governance/bundles/bundle-committee.js'; -import contractGovernor from '@agoric/governance/bundles/bundle-contractGovernor.js'; -import psm from '@agoric/inter-protocol/bundles/bundle-psm.js'; -import econCommitteeCharter from '@agoric/inter-protocol/bundles/bundle-econCommitteeCharter.js'; -import walletFactory from '@agoric/smart-wallet/bundles/bundle-walletFactory.js'; - import centralSupply from '../bundles/bundle-centralSupply.js'; import mintHolder from '../bundles/bundle-mintHolder.js'; import provisionPool from '../bundles/bundle-provisionPool.js'; export const bundles = { - binaryVoteCounter, centralSupply, - committee, - contractGovernor, mintHolder, provisionPool, - psm, - econCommitteeCharter, - walletFactory, }; export const devices = { From 2e1ead739cc77d53c0354b00476e68e2b5aecc06 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Sun, 6 Aug 2023 13:24:45 -0400 Subject: [PATCH 08/13] test: move PSM reviver next to PSM --- .../inter-protocol/test/psm/test-reviver.js | 28 +++++++++++++++++++ packages/vats/test/test-board-utils.js | 25 ----------------- 2 files changed, 28 insertions(+), 25 deletions(-) create mode 100644 packages/inter-protocol/test/psm/test-reviver.js diff --git a/packages/inter-protocol/test/psm/test-reviver.js b/packages/inter-protocol/test/psm/test-reviver.js new file mode 100644 index 00000000000..1b9294168f7 --- /dev/null +++ b/packages/inter-protocol/test/psm/test-reviver.js @@ -0,0 +1,28 @@ +// @ts-check +import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js'; + +import { makeHistoryReviver } from '@agoric/vats/tools/board-utils.js'; +import { chainStorageEntries } from './psm-storage-fixture.js'; + +test('restore PSM: revive metrics, governance with old board IDs', async t => { + const toSlotReviver = makeHistoryReviver(chainStorageEntries); + + const psmNames = toSlotReviver.children('published.psm.IST.'); + t.true(psmNames.includes('USDC_axl')); + + const a0 = { + metrics: toSlotReviver.getItem(`published.psm.IST.USDC_axl.metrics`), + governance: toSlotReviver.getItem(`published.psm.IST.USDC_axl.governance`), + }; + + t.deepEqual( + a0.metrics.anchorPoolBalance, + { brand: 'board0223', value: 487_464_281_410n }, + 'metrics.anchorPoolBalance', + ); + t.deepEqual( + a0.governance.current.MintLimit.value, + { brand: 'board02314', value: 1_000_000_000_000n }, + 'governance.MintLimit', + ); +}); diff --git a/packages/vats/test/test-board-utils.js b/packages/vats/test/test-board-utils.js index 2de38056dac..2e877c591a1 100644 --- a/packages/vats/test/test-board-utils.js +++ b/packages/vats/test/test-board-utils.js @@ -2,13 +2,11 @@ import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js'; import { makeFakeStorageKit } from '@agoric/internal/src/storage-test-utils.js'; -import { chainStorageEntries } from '@agoric/inter-protocol/test/psm/psm-storage-fixture.js'; import { Far } from '@endo/far'; import { boardSlottingMarshaller, makeAgoricNamesRemotesFromFakeStorage, - makeHistoryReviver, } from '../tools/board-utils.js'; const streamCellTextFromArray = values => @@ -207,26 +205,3 @@ test( slots: ['board123Atom', 'board123Ist'], }, ); - -test('restore PSM: revive metrics, governance with old board IDs', async t => { - const toSlotReviver = makeHistoryReviver(chainStorageEntries); - - const psmNames = toSlotReviver.children('published.psm.IST.'); - t.true(psmNames.includes('USDC_axl')); - - const a0 = { - metrics: toSlotReviver.getItem(`published.psm.IST.USDC_axl.metrics`), - governance: toSlotReviver.getItem(`published.psm.IST.USDC_axl.governance`), - }; - - t.deepEqual( - a0.metrics.anchorPoolBalance, - { brand: 'board0223', value: 487_464_281_410n }, - 'metrics.anchorPoolBalance', - ); - t.deepEqual( - a0.governance.current.MintLimit.value, - { brand: 'board02314', value: 1_000_000_000_000n }, - 'governance.MintLimit', - ); -}); From 3f3871227aeed1f63d98ab8660c52565ba513a99 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Sun, 6 Aug 2023 13:22:19 -0400 Subject: [PATCH 09/13] refactor: move provisionPool to inter-protocol It depends on the PSM, which is part of inter-protocol. It also depends on smart-wallet, which is lower. --- packages/builders/scripts/vats/init-core.js | 2 +- packages/inter-protocol/docs/governance.md | 2 +- packages/inter-protocol/package.json | 2 +- .../src/provisionPool.js | 4 ++- .../src/provisionPoolKit.js | 8 ++--- .../inter-protocol/src/vaultFactory/vault.js | 6 ++-- .../test/test-provisionPool.js | 30 +++++++++---------- packages/vats/package.json | 1 - packages/vats/scripts/build-bundles.js | 5 +++- packages/vats/src/core/types.js | 4 ++- packages/vm-config/decentral-core-config.json | 2 +- .../vm-config/decentral-devnet-config.json | 2 +- .../decentral-itest-vaults-config.json | 2 +- .../decentral-main-vaults-config.json | 2 +- .../decentral-test-vaults-config.json | 2 +- 15 files changed, 40 insertions(+), 34 deletions(-) rename packages/{vats => inter-protocol}/src/provisionPool.js (97%) rename packages/{vats => inter-protocol}/src/provisionPoolKit.js (98%) rename packages/{vats => inter-protocol}/test/test-provisionPool.js (96%) diff --git a/packages/builders/scripts/vats/init-core.js b/packages/builders/scripts/vats/init-core.js index 6e63d212339..44f8e600883 100644 --- a/packages/builders/scripts/vats/init-core.js +++ b/packages/builders/scripts/vats/init-core.js @@ -10,7 +10,7 @@ export const defaultProposalBuilder = async ({ publishRef, install }) => installKeys: { provisionPool: publishRef( install( - '@agoric/vats/src/provisionPool.js', + '@agoric/inter-protocol/src/provisionPool.js', '../bundles/bundle-provisionPool.js', ), ), diff --git a/packages/inter-protocol/docs/governance.md b/packages/inter-protocol/docs/governance.md index 9d8671ea80f..17d94ee29a6 100644 --- a/packages/inter-protocol/docs/governance.md +++ b/packages/inter-protocol/docs/governance.md @@ -77,7 +77,7 @@ for this contract. ### Provision Pool -In `packages/vats/src/provisionPool.js`: +In `packages/inter-protocol/src/provisionPool.js`: | Governance Key | Type | WP? | | ----------------------- | :------ | --- | diff --git a/packages/inter-protocol/package.json b/packages/inter-protocol/package.json index 555021f1336..19d0b46174a 100644 --- a/packages/inter-protocol/package.json +++ b/packages/inter-protocol/package.json @@ -39,6 +39,7 @@ "@agoric/store": "^0.9.2", "@agoric/time": "^0.3.2", "@agoric/vat-data": "^0.5.2", + "@agoric/vats": "^0.15.1", "@agoric/zoe": "^0.26.2", "@endo/captp": "^3.1.2", "@endo/eventual-send": "^0.17.3", @@ -51,7 +52,6 @@ "@agoric/smart-wallet": "^0.5.3", "@agoric/swingset-liveslots": "^0.10.2", "@agoric/swingset-vat": "^0.32.2", - "@agoric/vats": "^0.15.1", "@agoric/zone": "^0.2.2", "@endo/bundle-source": "^2.5.2", "@endo/init": "^0.5.57", diff --git a/packages/vats/src/provisionPool.js b/packages/inter-protocol/src/provisionPool.js similarity index 97% rename from packages/vats/src/provisionPool.js rename to packages/inter-protocol/src/provisionPool.js index 01aa5d4020e..b192b2fcb54 100644 --- a/packages/vats/src/provisionPool.js +++ b/packages/inter-protocol/src/provisionPool.js @@ -40,7 +40,9 @@ harden(meta); * TODO: ERef> * @param {ZCF} zcf * @param {{ - * poolBank: import('@endo/far').ERef; + * poolBank: import('@endo/far').ERef< + * import('@agoric/vats/src/vat-bank.js').Bank + * >; * initialPoserInvitation: Invitation; * storageNode: StorageNode; * marshaller: Marshaller; diff --git a/packages/vats/src/provisionPoolKit.js b/packages/inter-protocol/src/provisionPoolKit.js similarity index 98% rename from packages/vats/src/provisionPoolKit.js rename to packages/inter-protocol/src/provisionPoolKit.js index 50e2b95d961..b2a416ccda0 100644 --- a/packages/vats/src/provisionPoolKit.js +++ b/packages/inter-protocol/src/provisionPoolKit.js @@ -12,14 +12,14 @@ import { makeScalarBigSetStore, prepareExoClassKit, } from '@agoric/vat-data'; +import { PowerFlags } from '@agoric/vats/src/walletFlags.js'; import { - makeRecorderTopic, PublicTopicShape, + makeRecorderTopic, } from '@agoric/zoe/src/contractSupport/topics.js'; import { InstanceHandleShape } from '@agoric/zoe/src/typeGuards.js'; import { E } from '@endo/far'; -import { deeplyFulfilled, Far } from '@endo/marshal'; -import { PowerFlags } from './walletFlags.js'; +import { Far, deeplyFulfilled } from '@endo/marshal'; const { details: X, quote: q, Fail } = assert; @@ -55,7 +55,7 @@ const { details: X, quote: q, Fail } = assert; * @param {(depositBank: ERef) => Promise} sendInitialPayment * @param {() => void} onProvisioned * - * @typedef {import('./vat-bank.js').Bank} Bank + * @typedef {import('@agoric/vats/src/vat-bank.js').Bank} Bank */ export const makeBridgeProvisionTool = (sendInitialPayment, onProvisioned) => { /** @param {ProvisionPoolKitReferences} refs */ diff --git a/packages/inter-protocol/src/vaultFactory/vault.js b/packages/inter-protocol/src/vaultFactory/vault.js index df98b78931a..951e5ccde97 100644 --- a/packages/inter-protocol/src/vaultFactory/vault.js +++ b/packages/inter-protocol/src/vaultFactory/vault.js @@ -1,5 +1,6 @@ import { AmountMath, AmountShape } from '@agoric/ertp'; -import { makeTracer, StorageNodeShape } from '@agoric/internal'; +import { StorageNodeShape, makeTracer } from '@agoric/internal'; +import { UnguardedHelperI } from '@agoric/internal/src/typeGuards.js'; import { M, prepareExoClassKit } from '@agoric/vat-data'; import { atomicTransfer } from '@agoric/zoe/src/contractSupport/index.js'; import { SeatShape } from '@agoric/zoe/src/typeGuards.js'; @@ -9,11 +10,10 @@ import { makeNatAmountShape, } from '../contractSupport.js'; import { calculateCurrentDebt, reverseInterest } from '../interest-math.js'; -import { UnguardedHelperI } from '@agoric/internal/src/typeGuards.js'; +import { calculateDebtCosts } from './math.js'; import { prepareVaultKit } from './vaultKit.js'; import '@agoric/zoe/exported.js'; -import { calculateDebtCosts } from './math.js'; const { quote: q, Fail } = assert; diff --git a/packages/vats/test/test-provisionPool.js b/packages/inter-protocol/test/test-provisionPool.js similarity index 96% rename from packages/vats/test/test-provisionPool.js rename to packages/inter-protocol/test/test-provisionPool.js index 69643539edb..60ac910bb73 100644 --- a/packages/vats/test/test-provisionPool.js +++ b/packages/inter-protocol/test/test-provisionPool.js @@ -4,29 +4,29 @@ import { test as unknownTest } from '@agoric/swingset-vat/tools/prepare-test-env import { AmountMath, makeIssuerKit } from '@agoric/ertp'; import { CONTRACT_ELECTORATE, ParamTypes } from '@agoric/governance'; import committeeBundle from '@agoric/governance/bundles/bundle-committee.js'; -import { - makeMockChainStorageRoot, - setUpZoeForTest, - withAmountUtils, -} from '@agoric/inter-protocol/test/supports.js'; import { WalletName } from '@agoric/internal'; import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js'; -import { publishDepositFacet } from '@agoric/smart-wallet/src/walletFactory.js'; import { unsafeMakeBundleCache } from '@agoric/swingset-vat/tools/bundleTool.js'; +import { makeScalarBigMapStore } from '@agoric/vat-data'; +import centralSupplyBundle from '@agoric/vats/bundles/bundle-centralSupply.js'; +import { makeNameHubKit } from '@agoric/vats/src/nameHub.js'; +import { buildRootObject as buildBankRoot } from '@agoric/vats/src/vat-bank.js'; +import { PowerFlags } from '@agoric/vats/src/walletFlags.js'; +import { makeFakeBankKit } from '@agoric/vats/tools/bank-utils.js'; +import { makeFakeBoard } from '@agoric/vats/tools/board-utils.js'; import { makeRatio } from '@agoric/zoe/src/contractSupport/ratio.js'; import { E, Far } from '@endo/far'; import path from 'path'; -import { makeScalarBigMapStore } from '@agoric/vat-data'; -import centralSupplyBundle from '../bundles/bundle-centralSupply.js'; -import { makeFakeBoard } from '../tools/board-utils.js'; -import { makeNameHubKit } from '../src/nameHub.js'; +import { publishDepositFacet } from '@agoric/smart-wallet/src/walletFactory.js'; import { makeBridgeProvisionTool } from '../src/provisionPoolKit.js'; -import { buildRootObject as buildBankRoot } from '../src/vat-bank.js'; -import { PowerFlags } from '../src/walletFlags.js'; -import { makeFakeBankKit } from '../tools/bank-utils.js'; +import { + makeMockChainStorageRoot, + setUpZoeForTest, + withAmountUtils, +} from './supports.js'; /** - * @typedef {import('../src/vat-bank.js').Bank} Bank + * @typedef {import('@agoric/vats/src/vat-bank.js').Bank} Bank * * @typedef {import('@agoric/smart-wallet/src/smartWallet.js').SmartWallet} SmartWallet * @@ -36,7 +36,7 @@ import { makeFakeBankKit } from '../tools/bank-utils.js'; const pathname = new URL(import.meta.url).pathname; const dirname = path.dirname(pathname); -const psmRoot = `${dirname}/../../inter-protocol/src/psm/psm.js`; +const psmRoot = `${dirname}/../src/psm/psm.js`; const policyRoot = `${dirname}/../src/provisionPool.js`; const scale6 = x => BigInt(Math.round(x * 1_000_000)); diff --git a/packages/vats/package.json b/packages/vats/package.json index edf39a2ce53..4b434a0340c 100644 --- a/packages/vats/package.json +++ b/packages/vats/package.json @@ -44,7 +44,6 @@ "jessie.js": "^0.3.2" }, "devDependencies": { - "@agoric/smart-wallet": "^0.5.3", "@agoric/swingset-liveslots": "^0.10.2", "@endo/bundle-source": "^2.5.2", "@endo/init": "^0.5.57", diff --git a/packages/vats/scripts/build-bundles.js b/packages/vats/scripts/build-bundles.js index 653105e8e99..d0e0a980aec 100755 --- a/packages/vats/scripts/build-bundles.js +++ b/packages/vats/scripts/build-bundles.js @@ -8,7 +8,10 @@ const dirname = url.fileURLToPath(new URL('.', import.meta.url)); const sourceToBundle = [ ['@agoric/vats/src/centralSupply.js', '../bundles/bundle-centralSupply.js'], ['@agoric/vats/src/mintHolder.js', '../bundles/bundle-mintHolder.js'], - ['@agoric/vats/src/provisionPool.js', '../bundles/bundle-provisionPool.js'], + [ + '@agoric/inter-protocol/src/provisionPool.js', + '../bundles/bundle-provisionPool.js', + ], ]; await createBundles(sourceToBundle, dirname); diff --git a/packages/vats/src/core/types.js b/packages/vats/src/core/types.js index a4d9ea89f8e..eaf0cf6b309 100644 --- a/packages/vats/src/core/types.js +++ b/packages/vats/src/core/types.js @@ -274,7 +274,9 @@ * > * >; * provisionPool: Promise< - * Installation + * Installation< + * import('@agoric/inter-protocol/src/provisionPool.js')['start'] + * > * >; * reserve: Promise< * Installation< diff --git a/packages/vm-config/decentral-core-config.json b/packages/vm-config/decentral-core-config.json index 00c5da099b6..ca0ebd88787 100644 --- a/packages/vm-config/decentral-core-config.json +++ b/packages/vm-config/decentral-core-config.json @@ -47,7 +47,7 @@ "sourceSpec": "@agoric/vats/src/vat-priceAuthority.js" }, "provisionPool": { - "sourceSpec": "@agoric/vats/src/provisionPool.js" + "sourceSpec": "@agoric/inter-protocol/src/provisionPool.js" }, "provisioning": { "sourceSpec": "@agoric/vats/src/vat-provisioning.js" diff --git a/packages/vm-config/decentral-devnet-config.json b/packages/vm-config/decentral-devnet-config.json index 43cfe8167fd..f6d0fbf07a4 100644 --- a/packages/vm-config/decentral-devnet-config.json +++ b/packages/vm-config/decentral-devnet-config.json @@ -197,7 +197,7 @@ "sourceSpec": "@agoric/vats/src/vat-priceAuthority.js" }, "provisionPool": { - "sourceSpec": "@agoric/vats/src/provisionPool.js" + "sourceSpec": "@agoric/inter-protocol/src/provisionPool.js" }, "provisioning": { "sourceSpec": "@agoric/vats/src/vat-provisioning.js" diff --git a/packages/vm-config/decentral-itest-vaults-config.json b/packages/vm-config/decentral-itest-vaults-config.json index c36da60eb24..a6664b50cd8 100644 --- a/packages/vm-config/decentral-itest-vaults-config.json +++ b/packages/vm-config/decentral-itest-vaults-config.json @@ -191,7 +191,7 @@ "sourceSpec": "@agoric/vats/src/vat-priceAuthority.js" }, "provisionPool": { - "sourceSpec": "@agoric/vats/src/provisionPool.js" + "sourceSpec": "@agoric/inter-protocol/src/provisionPool.js" }, "provisioning": { "sourceSpec": "@agoric/vats/src/vat-provisioning.js" diff --git a/packages/vm-config/decentral-main-vaults-config.json b/packages/vm-config/decentral-main-vaults-config.json index a17713af2f4..a5676dd0bc8 100644 --- a/packages/vm-config/decentral-main-vaults-config.json +++ b/packages/vm-config/decentral-main-vaults-config.json @@ -210,7 +210,7 @@ "sourceSpec": "@agoric/vats/src/vat-priceAuthority.js" }, "provisionPool": { - "sourceSpec": "@agoric/vats/src/provisionPool.js" + "sourceSpec": "@agoric/inter-protocol/src/provisionPool.js" }, "provisioning": { "sourceSpec": "@agoric/vats/src/vat-provisioning.js" diff --git a/packages/vm-config/decentral-test-vaults-config.json b/packages/vm-config/decentral-test-vaults-config.json index 0323abbfa8e..2500380977c 100644 --- a/packages/vm-config/decentral-test-vaults-config.json +++ b/packages/vm-config/decentral-test-vaults-config.json @@ -176,7 +176,7 @@ "sourceSpec": "@agoric/vats/src/vat-priceAuthority.js" }, "provisionPool": { - "sourceSpec": "@agoric/vats/src/provisionPool.js" + "sourceSpec": "@agoric/inter-protocol/src/provisionPool.js" }, "provisioning": { "sourceSpec": "@agoric/vats/src/vat-provisioning.js" From 4dbe826401791b4af0e5a312e08360a7133f1554 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Sat, 12 Aug 2023 11:55:52 -0400 Subject: [PATCH 10/13] docs: need to end inter-package fs references --- packages/builders/scripts/inter-protocol/init-core.js | 2 ++ packages/vats/scripts/build-bundles.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/packages/builders/scripts/inter-protocol/init-core.js b/packages/builders/scripts/inter-protocol/init-core.js index 3769a26a3da..e20085be839 100644 --- a/packages/builders/scripts/inter-protocol/init-core.js +++ b/packages/builders/scripts/inter-protocol/init-core.js @@ -14,6 +14,8 @@ import { } from '@agoric/inter-protocol/src/proposals/core-proposal.js'; import { makeInstallCache } from '@agoric/inter-protocol/src/proposals/utils.js'; +// TODO end inter-package filesystem references https://github.com/Agoric/agoric-sdk/issues/8178 + /** @type {Record>} */ const installKeyGroups = { econCommittee: { diff --git a/packages/vats/scripts/build-bundles.js b/packages/vats/scripts/build-bundles.js index d0e0a980aec..df42abc085c 100755 --- a/packages/vats/scripts/build-bundles.js +++ b/packages/vats/scripts/build-bundles.js @@ -5,6 +5,8 @@ import url from 'url'; const dirname = url.fileURLToPath(new URL('.', import.meta.url)); +// TODO end inter-package filesystem references https://github.com/Agoric/agoric-sdk/issues/8178 + const sourceToBundle = [ ['@agoric/vats/src/centralSupply.js', '../bundles/bundle-centralSupply.js'], ['@agoric/vats/src/mintHolder.js', '../bundles/bundle-mintHolder.js'], From feefe9bab3ed25d7fa8700d63968228c46509da2 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Sun, 6 Aug 2023 13:26:33 -0400 Subject: [PATCH 11/13] build: drop dep on inter-protocol --- packages/vats/package.json | 1 - packages/vats/test/test-name-hub-published.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/vats/package.json b/packages/vats/package.json index 4b434a0340c..1a34ab47176 100644 --- a/packages/vats/package.json +++ b/packages/vats/package.json @@ -25,7 +25,6 @@ "@agoric/assert": "^0.6.0", "@agoric/ertp": "^0.16.2", "@agoric/governance": "^0.10.3", - "@agoric/inter-protocol": "^0.16.1", "@agoric/internal": "^0.3.2", "@agoric/network": "^0.1.0", "@agoric/notifier": "^0.6.2", diff --git a/packages/vats/test/test-name-hub-published.js b/packages/vats/test/test-name-hub-published.js index abb53587528..47d484310c9 100644 --- a/packages/vats/test/test-name-hub-published.js +++ b/packages/vats/test/test-name-hub-published.js @@ -1,7 +1,7 @@ // @ts-check import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js'; -import { makeMockChainStorageRoot } from '@agoric/inter-protocol/test/supports.js'; +import { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js'; import { makeHandle } from '@agoric/zoe/src/makeHandle.js'; import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js'; import { From 6a69b0e0999d716293c5f73021879a692bd6ae49 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Sun, 6 Aug 2023 14:18:11 -0400 Subject: [PATCH 12/13] build: drop vats dependency --- packages/governance/package.json | 1 - .../swingsetTests/committeeBinary/bootstrap.js | 12 ++++++------ .../swingsetTests/contractGovernor/bootstrap.js | 14 +++++++------- packages/governance/test/swingsetTests/utils.js | 12 ++++++++++++ .../governance/test/unitTests/test-committee.js | 16 ++++++++-------- .../test/unitTests/test-paramGovernance.js | 14 +++++++------- 6 files changed, 40 insertions(+), 29 deletions(-) create mode 100644 packages/governance/test/swingsetTests/utils.js diff --git a/packages/governance/package.json b/packages/governance/package.json index 5408d64a757..683925e631b 100644 --- a/packages/governance/package.json +++ b/packages/governance/package.json @@ -51,7 +51,6 @@ "import-meta-resolve": "^2.2.1" }, "devDependencies": { - "@agoric/vats": "^0.15.1", "@endo/bundle-source": "^2.5.2", "@endo/init": "^0.5.57", "ava": "^5.3.0", diff --git a/packages/governance/test/swingsetTests/committeeBinary/bootstrap.js b/packages/governance/test/swingsetTests/committeeBinary/bootstrap.js index b0e5b6ddccd..06f12bba858 100644 --- a/packages/governance/test/swingsetTests/committeeBinary/bootstrap.js +++ b/packages/governance/test/swingsetTests/committeeBinary/bootstrap.js @@ -1,15 +1,15 @@ -import { E } from '@endo/eventual-send'; -import { Far } from '@endo/marshal'; -import { makeFakeBoard } from '@agoric/vats/tools/board-utils.js'; import { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js'; import buildManualTimer from '@agoric/zoe/tools/manualTimer.js'; +import { E } from '@endo/eventual-send'; +import { Far } from '@endo/marshal'; import { ChoiceMethod, - QuorumRule, ElectionType, + QuorumRule, coerceQuestionSpec, } from '../../../src/index.js'; +import { remoteNullMarshaller } from '../utils.js'; const { quote: q } = assert; @@ -65,7 +65,7 @@ const committeeBinaryStart = async ( const { creatorFacet: electorateFacet, instance: electorateInstance } = await E(zoe).startInstance(installations.committee, {}, electorateTerms, { storageNode: makeMockChainStorageRoot().makeChildNode('thisElectorate'), - marshaller: makeFakeBoard().getReadonlyMarshaller(), + marshaller: remoteNullMarshaller, }); const choose = { text: 'Choose' }; @@ -128,7 +128,7 @@ const committeeBinaryTwoQuestions = async ( const { creatorFacet: electorateFacet, instance: electorateInstance } = await E(zoe).startInstance(installations.committee, {}, electorateTerms, { storageNode: makeMockChainStorageRoot().makeChildNode('thisElectorate'), - marshaller: makeFakeBoard().getReadonlyMarshaller(), + marshaller: remoteNullMarshaller, }); const invitations = await E(electorateFacet).getVoterInvitations(); diff --git a/packages/governance/test/swingsetTests/contractGovernor/bootstrap.js b/packages/governance/test/swingsetTests/contractGovernor/bootstrap.js index 755ffbbbd68..4d7dae1ae9f 100644 --- a/packages/governance/test/swingsetTests/contractGovernor/bootstrap.js +++ b/packages/governance/test/swingsetTests/contractGovernor/bootstrap.js @@ -1,15 +1,15 @@ +import { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js'; +import { observeIteration, subscribeEach } from '@agoric/notifier'; +import buildManualTimer from '@agoric/zoe/tools/manualTimer.js'; import { E } from '@endo/eventual-send'; import { Far } from '@endo/marshal'; -import buildManualTimer from '@agoric/zoe/tools/manualTimer.js'; -import { observeIteration, subscribeEach } from '@agoric/notifier'; -import { makeFakeBoard } from '@agoric/vats/tools/board-utils.js'; -import { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js'; -import { makeTerms, MALLEABLE_NUMBER } from './governedContract.js'; import { - CONTRACT_ELECTORATE, assertContractElectorate, + CONTRACT_ELECTORATE, } from '../../../src/index.js'; +import { remoteNullMarshaller } from '../utils.js'; +import { makeTerms, MALLEABLE_NUMBER } from './governedContract.js'; const { quote: q } = assert; @@ -79,7 +79,7 @@ const startElectorate = async (zoe, installations, electorateTerms) => { const { creatorFacet: electorateCreatorFacet, instance: electorateInstance } = await E(zoe).startInstance(installations.committee, {}, electorateTerms, { storageNode: makeMockChainStorageRoot().makeChildNode('thisElectorate'), - marshaller: makeFakeBoard().getReadonlyMarshaller(), + marshaller: remoteNullMarshaller, }); return { electorateCreatorFacet, electorateInstance }; }; diff --git a/packages/governance/test/swingsetTests/utils.js b/packages/governance/test/swingsetTests/utils.js new file mode 100644 index 00000000000..1a931af99d1 --- /dev/null +++ b/packages/governance/test/swingsetTests/utils.js @@ -0,0 +1,12 @@ +import { Far, makeMarshal } from '@endo/marshal'; +import { makeExo } from '@agoric/store'; + +const nullMarshaller = makeMarshal( + _ => null, + _ => Far('dummy'), +); + +export const remoteNullMarshaller = makeExo('nullMarshaller', undefined, { + toCapData: val => nullMarshaller.toCapData(val), + fromCapData: slot => nullMarshaller.fromCapData(slot), +}); diff --git a/packages/governance/test/unitTests/test-committee.js b/packages/governance/test/unitTests/test-committee.js index f9dee76f8fb..421bc944317 100644 --- a/packages/governance/test/unitTests/test-committee.js +++ b/packages/governance/test/unitTests/test-committee.js @@ -2,15 +2,14 @@ import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js'; import '@agoric/zoe/exported.js'; -import path from 'path'; -import { E } from '@endo/eventual-send'; -import { Far } from '@endo/far'; -import { makeZoeForTest } from '@agoric/zoe/tools/setup-zoe.js'; -import bundleSource from '@endo/bundle-source'; -import { makeFakeBoard } from '@agoric/vats/tools/board-utils.js'; import { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js'; -import buildManualTimer from '@agoric/zoe/tools/manualTimer.js'; import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js'; +import buildManualTimer from '@agoric/zoe/tools/manualTimer.js'; +import { makeZoeForTest } from '@agoric/zoe/tools/setup-zoe.js'; +import bundleSource from '@endo/bundle-source'; +import { E } from '@endo/eventual-send'; +import { Far } from '@endo/far'; +import path from 'path'; import { ChoiceMethod, @@ -19,6 +18,7 @@ import { coerceQuestionSpec, } from '../../src/index.js'; import { documentStorageSchema } from '../../tools/storageDoc.js'; +import { remoteNullMarshaller } from '../swingsetTests/utils.js'; const filename = new URL(import.meta.url).pathname; const dirname = path.dirname(filename); @@ -51,7 +51,7 @@ const setupContract = async () => { terms, { storageNode: mockChainStorageRoot.makeChildNode('thisElectorate'), - marshaller: makeFakeBoard().getReadonlyMarshaller(), + marshaller: remoteNullMarshaller, }, ); diff --git a/packages/governance/test/unitTests/test-paramGovernance.js b/packages/governance/test/unitTests/test-paramGovernance.js index ae0432e4e30..b096c7066f7 100644 --- a/packages/governance/test/unitTests/test-paramGovernance.js +++ b/packages/governance/test/unitTests/test-paramGovernance.js @@ -1,18 +1,18 @@ -import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js'; import '@agoric/zoe/exported.js'; +import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js'; +import { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js'; import { makeNotifierFromAsyncIterable } from '@agoric/notifier'; +import buildManualTimer from '@agoric/zoe/tools/manualTimer.js'; import { makeZoeForTest } from '@agoric/zoe/tools/setup-zoe.js'; import bundleSource from '@endo/bundle-source'; -import buildManualTimer from '@agoric/zoe/tools/manualTimer.js'; import { E } from '@endo/eventual-send'; -import { makeFakeBoard } from '@agoric/vats/tools/board-utils.js'; -import { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js'; -import { resolve as importMetaResolve } from 'import-meta-resolve'; import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js'; -import { MALLEABLE_NUMBER } from '../swingsetTests/contractGovernor/governedContract.js'; +import { resolve as importMetaResolve } from 'import-meta-resolve'; import { CONTRACT_ELECTORATE, ParamTypes } from '../../src/index.js'; +import { MALLEABLE_NUMBER } from '../swingsetTests/contractGovernor/governedContract.js'; +import { remoteNullMarshaller } from '../swingsetTests/utils.js'; const voteCounterRoot = '../../src/binaryVoteCounter.js'; const governedRoot = '../swingsetTests/contractGovernor/governedContract.js'; @@ -61,7 +61,7 @@ const setUpGovernedContract = async (zoe, electorateTerms, timer) => { electorateTerms, { storageNode: makeMockChainStorageRoot().makeChildNode('thisElectorate'), - marshaller: makeFakeBoard().getReadonlyMarshaller(), + marshaller: remoteNullMarshaller, }, ); From 7453fa3225bee3fa85819d4d4ea478d10e350bd3 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Sun, 6 Aug 2023 14:20:20 -0400 Subject: [PATCH 13/13] ci: reject package cycles --- lerna.json | 1 + 1 file changed, 1 insertion(+) diff --git a/lerna.json b/lerna.json index a6b094cfeba..128122483d4 100644 --- a/lerna.json +++ b/lerna.json @@ -13,6 +13,7 @@ "packages/*", "packages/wallet/*" ], + "rejectCycles": true, "useWorkspaces": true, "version": "independent" }