From adc2123de2a2e761216428dbef7f300b4fb7aa5e Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Thu, 11 May 2023 16:19:59 -0700 Subject: [PATCH 1/3] chore(agoricNames): more idiomatic provideInterBrand --- packages/vats/src/vat-agoricNames.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/vats/src/vat-agoricNames.js b/packages/vats/src/vat-agoricNames.js index a190d4da9af..1548c8b9923 100644 --- a/packages/vats/src/vat-agoricNames.js +++ b/packages/vats/src/vat-agoricNames.js @@ -4,6 +4,7 @@ import { E, Far } from '@endo/far'; import { BrandI } from '@agoric/ertp'; import { provide } from '@agoric/vat-data'; import { makeDurableZone } from '@agoric/zone/durable.js'; +import { provideLazy } from '@agoric/store'; import { prepareNameHubKit } from './nameHub.js'; /** @param {import('@agoric/zone').Zone} zone */ @@ -80,6 +81,8 @@ export const buildRootObject = (_vatPowers, _vatParameters, baggage) => { * @param {DisplayInfo} displayInfo */ provideInertBrand: (keyword, displayInfo) => - provide(brandStore, keyword, () => makeNatBrand(keyword, displayInfo)), + provideLazy(brandStore, keyword, () => + makeNatBrand(keyword, displayInfo), + ), }); }; From 5387e35d7826329e6d93b3e80b3ed1779887ba82 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Thu, 11 May 2023 16:22:10 -0700 Subject: [PATCH 2/3] test: restarting all PSM instances --- .../src/proposals/econ-behaviors.js | 1 + .../inter-protocol/src/proposals/startPSM.js | 22 ++++++++----- .../src/proposals/restart-vats-proposal.js | 33 ++++++++++++------- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/packages/inter-protocol/src/proposals/econ-behaviors.js b/packages/inter-protocol/src/proposals/econ-behaviors.js index 72f00690233..531832f3339 100644 --- a/packages/inter-protocol/src/proposals/econ-behaviors.js +++ b/packages/inter-protocol/src/proposals/econ-behaviors.js @@ -28,6 +28,7 @@ const SECONDS_PER_DAY = 24n * SECONDS_PER_HOUR; /** * @typedef {object} PSMKit + * @property {string} label * @property {Instance} psm * @property {Instance} psmGovernor * @property {Awaited>['creatorFacet']['getLimitedCreatorFacet']>>} psmCreatorFacet diff --git a/packages/inter-protocol/src/proposals/startPSM.js b/packages/inter-protocol/src/proposals/startPSM.js index 034fad7e341..5d7f6d6bc8c 100644 --- a/packages/inter-protocol/src/proposals/startPSM.js +++ b/packages/inter-protocol/src/proposals/startPSM.js @@ -88,6 +88,7 @@ export const startPSM = async ( consume: { agoricNamesAdmin, board, + diagnostics, zoe, feeMintAccess: feeMintAccessP, economicCommitteeCreatorFacet, @@ -203,6 +204,12 @@ export const startPSM = async ( }, }), ); + const psmPrivateArgs = { + feeMintAccess, + initialPoserInvitation, + marshaller, + storageNode, + }; /** @type {GovernorStartedInstallationKit} */ const governorFacets = await E(zoe).startInstance( contractGovernor, @@ -210,12 +217,7 @@ export const startPSM = async ( governorTerms, harden({ economicCommitteeCreatorFacet, - governed: { - feeMintAccess, - initialPoserInvitation, - marshaller, - storageNode, - }, + governed: psmPrivateArgs, }), `${instanceKey}.governor`, ); @@ -225,6 +227,7 @@ export const startPSM = async ( E(governorFacets.creatorFacet).getCreatorFacet(), E(governorFacets.creatorFacet).getAdminFacet(), ]); + await E(diagnostics).savePrivateArgs(psm, psmPrivateArgs); /** @param {MetricsNotification} metrics */ const restoreMetrics = async metrics => { @@ -243,9 +246,9 @@ export const startPSM = async ( }; await (oldState.metrics && restoreMetrics(oldState.metrics)); - /** @typedef {import('./econ-behaviors.js').PSMKit} psmKit */ - /** @type {psmKit} */ + /** @type {import('./econ-behaviors.js').PSMKit} */ const newpsmKit = harden({ + label: instanceKey, psm, psmGovernor: governorFacets.instance, psmCreatorFacet, @@ -256,7 +259,7 @@ export const startPSM = async ( // Provide pattern with a promise. producepsmKit.resolve(makeScalarBigMapStore('PSM Kits', { durable: true })); - /** @type {MapStore} */ + /** @type {MapStore} */ const psmKitMap = await psmKit; // TODO init into governedContractKits too to simplify testing @@ -436,6 +439,7 @@ export const PSM_MANIFEST = { agoricNamesAdmin: true, board: true, chainStorage: true, + diagnostics: true, zoe: 'zoe', feeMintAccess: 'zoe', economicCommitteeCreatorFacet: 'economicCommittee', diff --git a/packages/vats/src/proposals/restart-vats-proposal.js b/packages/vats/src/proposals/restart-vats-proposal.js index 09ed159ef32..b3c7798e3c6 100644 --- a/packages/vats/src/proposals/restart-vats-proposal.js +++ b/packages/vats/src/proposals/restart-vats-proposal.js @@ -33,12 +33,15 @@ export const restartVats = async ({ consume }, { options }) => { await consume.vaultFactoryKit; trace('testing restarts'); - const { contractKits, governedContractKits } = await deeplyFulfilledObject( - harden({ - contractKits: consume.contractKits, - governedContractKits: consume.governedContractKits, - }), - ); + const { contractKits, governedContractKits, psmKit, vatStore } = + await deeplyFulfilledObject( + harden({ + contractKits: consume.contractKits, + governedContractKits: consume.governedContractKits, + psmKit: consume.psmKit, + vatStore: consume.vatStore, + }), + ); const instancePrivateArgs = await consume.instancePrivateArgs; @@ -49,7 +52,7 @@ export const restartVats = async ({ consume }, { options }) => { * @param {Instance} instance * @param {ERef} adminFacet */ - const tryRestart = async (debugName, instance, adminFacet) => { + const tryRestartContract = async (debugName, instance, adminFacet) => { // TODO document that privateArgs cannot contain promises // TODO try making all the contract starts take resolved values const privateArgs = await deeplyFulfilledObject( @@ -76,16 +79,17 @@ export const restartVats = async ({ consume }, { options }) => { } }; - // iterate over the two contractKits and use the adminFacet to restartContract + trace('iterating over contractKits'); for (const kit of contractKits.values()) { const debugName = kit.label || getInterfaceOf(kit.publicFacet) || 'UNLABELED'; if (debugName !== kit.label) { console.warn('MISSING LABEL:', kit); } - await tryRestart(debugName, kit.instance, kit.adminFacet); + await tryRestartContract(debugName, kit.instance, kit.adminFacet); } + trace('iterating over governedContractKits'); for (const kit of governedContractKits.values()) { const debugName = kit.label || getInterfaceOf(kit.publicFacet) || 'UNLABELED'; @@ -94,16 +98,22 @@ export const restartVats = async ({ consume }, { options }) => { } trace('restarting governed', debugName); - await tryRestart(debugName, kit.instance, kit.adminFacet); + await tryRestartContract(debugName, kit.instance, kit.adminFacet); trace('restarting governor of', debugName); - await tryRestart( + await tryRestartContract( `${debugName} [Governor]`, kit.governor, kit.governorAdminFacet, ); } + trace('iterating over psmKit'); + for (const kit of psmKit.values()) { + console.log('restarting PSM', kit.label); + await tryRestartContract(kit.label, kit.psm, kit.psmAdminFacet); + } + trace('restartVats done with ', failures.length, 'failures'); console.log(HR); if (failures.length) { @@ -121,6 +131,7 @@ export const getManifestForRestart = (_powers, options) => ({ governedContractKits: true, instancePrivateArgs: true, loadCriticalVat: true, + psmKit: true, zoe: 'zoe', provisioning: 'provisioning', vaultFactoryKit: true, From 1b2bd2e24552c5e4c826f0dd1b3b7466f11a43ee Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Thu, 11 May 2023 16:26:12 -0700 Subject: [PATCH 3/3] test: document vat upgrade coverages --- packages/vats/src/core/basic-behaviors.js | 1 - packages/vats/src/core/types.js | 1 + packages/vats/src/core/utils.js | 2 +- .../src/proposals/restart-vats-proposal.js | 26 +++++++++++++++---- .../test/bootstrapTests/test-vats-restart.js | 3 ++- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/packages/vats/src/core/basic-behaviors.js b/packages/vats/src/core/basic-behaviors.js index f3d2f6173ae..a7d870ff705 100644 --- a/packages/vats/src/core/basic-behaviors.js +++ b/packages/vats/src/core/basic-behaviors.js @@ -51,7 +51,6 @@ const bootMsgEx = { /** * @param {BootstrapPowers & { - * consume: {vatStore: Promise } * }} powers * * @typedef {import('@agoric/swingset-vat').CreateVatResults} CreateVatResults as from createVatByName diff --git a/packages/vats/src/core/types.js b/packages/vats/src/core/types.js index 11ba4151f82..50fd004ba1d 100644 --- a/packages/vats/src/core/types.js +++ b/packages/vats/src/core/types.js @@ -276,6 +276,7 @@ * walletBridgeManager: import('../types.js').ScopedBridgeManager | undefined, * walletFactoryStartResult: import('./startWalletFactory').WalletFactoryStartResult, * provisionPoolStartResult: unknown, + * vatStore: import('./utils.js').VatStore, * zoe: ZoeService, * }} ChainBootstrapSpaceT * @typedef {PromiseSpaceOf} ChainBootstrapSpace diff --git a/packages/vats/src/core/utils.js b/packages/vats/src/core/utils.js index 40f6746c9d0..92660cf3d25 100644 --- a/packages/vats/src/core/utils.js +++ b/packages/vats/src/core/utils.js @@ -317,7 +317,7 @@ export const makeMyAddressNameAdminKit = address => { * @param {string} [label] * * @typedef {import('@agoric/swingset-vat').CreateVatResults} CreateVatResults as from createVatByName - * @typedef {MapStore>} VatStore + * @typedef {MapStore} VatStore */ export const makeVatSpace = ( svc, diff --git a/packages/vats/src/proposals/restart-vats-proposal.js b/packages/vats/src/proposals/restart-vats-proposal.js index b3c7798e3c6..e064f667002 100644 --- a/packages/vats/src/proposals/restart-vats-proposal.js +++ b/packages/vats/src/proposals/restart-vats-proposal.js @@ -11,12 +11,18 @@ const trace = makeTracer('RV'); const HR = '----------------'; /** - * TODO cover each of these collections - * - [x] contractKits - * - [ ] psmKit - * - [x] governedContractKits - * - [ ] vatStore + * Non-contract vats aren't automatically restarted here because doing it would + * break many other tests that are fragile. */ +const vatUpgradeStatus = { + agoricNames: 'UNTESTED', + bank: 'covered by test-upgrade-vats: upgrade vat-bank', + board: 'covered by test-upgrade-vats: upgrade vat-board', + bridge: 'covered by test-upgrade-vats: upgrade vat-bridge', + priceAuthority: 'covered by test-upgrade-vats: upgrade vat-priceAuthority', + provisioning: 'UNTESTED', + zoe: 'tested in @agoric/zoe', +}; /** * @param {BootstrapPowers & import('@agoric/inter-protocol/src/proposals/econ-behaviors.js').EconomyBootstrapSpace} space @@ -114,6 +120,15 @@ export const restartVats = async ({ consume }, { options }) => { await tryRestartContract(kit.label, kit.psm, kit.psmAdminFacet); } + trace('iterating over vatStore'); + for (const [name] of vatStore.entries()) { + const status = vatUpgradeStatus[name]; + if (!status) { + Fail`unaudited vat ${name}`; + } + console.log('VAT', name, status); + } + trace('restartVats done with ', failures.length, 'failures'); console.log(HR); if (failures.length) { @@ -132,6 +147,7 @@ export const getManifestForRestart = (_powers, options) => ({ instancePrivateArgs: true, loadCriticalVat: true, psmKit: true, + vatStore: true, zoe: 'zoe', provisioning: 'provisioning', vaultFactoryKit: true, diff --git a/packages/vats/test/bootstrapTests/test-vats-restart.js b/packages/vats/test/bootstrapTests/test-vats-restart.js index 1468f01475c..48bab7b2492 100644 --- a/packages/vats/test/bootstrapTests/test-vats-restart.js +++ b/packages/vats/test/bootstrapTests/test-vats-restart.js @@ -18,7 +18,8 @@ import { makeSwingsetTestKit, makeWalletFactoryDriver } from './supports.js'; */ const test = anyTest; -const PLATFORM_CONFIG = '@agoric/vats/decentral-devnet-config.json'; +// main/production config doesn't have initialPrice, upon which 'open vaults' depends +const PLATFORM_CONFIG = '@agoric/vats/decentral-test-vaults-config.json'; // presently all these tests use one collateral manager const collateralBrandKey = 'ATOM';