Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4548 boot no precious state #7579

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bfa0bec
docs: WalletName is const
dckc May 2, 2023
67420e8
fix: only startEconCharter once, not again in startPSM
dckc May 2, 2023
5a489af
feat: durable NameHubKit
dckc Apr 26, 2023
28d0c9d
chore: add agoricNames vat
dckc Apr 27, 2023
639dc03
feat: promiseSpace backed by store, with hooks
dckc Apr 27, 2023
11bdcc3
chore: makeWellKnownSpaces
dckc Apr 27, 2023
8e56ad3
chore: publish agoricNames from the agoricNames vat
dckc Apr 27, 2023
0c8994a
chore: durable MyAddressNameAdmin (exo extend KLUDGE)
dckc May 1, 2023
9ec6970
feat(NameAdmin): provideChild()
dckc May 1, 2023
2c728cb
chore: move namesByAddress to provisioning vat
dckc May 1, 2023
711636b
chore: provisioning.provideNameHubKit -> nameAdmin.provideChild
dckc May 2, 2023
7ace944
chore: move oracleBrand.USD to agoricNames vat
dckc May 2, 2023
14b7352
chore: regenerate boot config viz snapshot
dckc May 2, 2023
2c02609
fix: don't route vbank updates thru bootstrap
dckc May 2, 2023
74f2704
test: audit bootstrap exports
dckc May 2, 2023
5e010cd
fix: don't route getAssetSubscription() thru bootstrap
dckc May 2, 2023
308f7d4
fix(price-feed-proposal): makeIssuerKit().brand is not upgradeable
dckc May 2, 2023
aff5937
chore: repair types from durable MyAddressNameAdmin
dckc May 2, 2023
4a9e190
docs: narrow provider arg type
dckc May 3, 2023
edc75d5
chore(inter-protocol): reduce scope of boot-psm to testing
dckc May 3, 2023
e7baa88
chore(vats): move boot-psm to testing tool
dckc May 3, 2023
92ec4de
chore: temporarily skip inter-protocol/test/smartWallet
dckc May 3, 2023
1bb6103
WIP: skip 'connectFaucet produces payments'
dckc May 3, 2023
dc733dd
chore: prune obsolete PSM config files
dckc May 3, 2023
75a70cc
test: makeAgoricNamesAccess() is async
dckc May 3, 2023
e957100
test: don't test for PSM boot configs
dckc May 3, 2023
c61a9c8
reject namesByAddress without provisioning
turadg May 3, 2023
e36c8d1
mock provisioning in smartWallet tests
turadg May 3, 2023
3252dde
test: update psm tests for async agoricNamesAccess
dckc May 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 21 additions & 24 deletions packages/inter-protocol/src/proposals/price-feed-proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,17 @@ const sanitizePathSegment = name => {
/**
* Create inert brands (no mint or issuer) referred to by price oracles.
*
* @param {ChainBootstrapSpace} space
* @param {ChainBootstrapSpace & NamedVatPowers} space
* @param {{options: {priceFeedOptions: PriceFeedOptions}}} opt
* @returns {Promise<[Brand<'nat'>, Brand<'nat'>]>}
*/
export const ensureOracleBrands = async (
{ consume: { agoricNamesAdmin } },
{
namedVat: {
consume: { agoricNames },
},
oracleBrand: { produce: oracleBrandProduce },
},
{
options: {
priceFeedOptions: {
Expand All @@ -54,29 +59,18 @@ export const ensureOracleBrands = async (
},
) => {
trace('ensureOracleBrands');
/** @type {Promise<import('@agoric/vats').NameAdmin>} */
const obAdmin = E(agoricNamesAdmin).lookupAdmin('oracleBrand');

/** @type {(brand: ERef<Brand<'nat'> | undefined>, name: string, decimals: string) => Promise<Brand<'nat'>>} */
const updateFreshBrand = async (brand, name, decimals) => {
const b = await brand;
if (b) {
// Don't update if it was already set.
return b;
}
const freshBrand = makeIssuerKit(
name,
undefined,
harden({ decimalPlaces: parseInt(decimals, 10) }),
).brand;

if (!name) {
// Don't update unnamed brands.
return freshBrand;
let b = await brand;
if (!b) {
// not 1st await
// eslint-disable-next-line @jessie.js/no-nested-await
b = await E(agoricNames).provideBrandIdentity(
name,
harden({ decimalPlaces: parseInt(decimals, 10) }),
);
}

// Atomically update if not already set.
return E(obAdmin).default(name, freshBrand);
oracleBrandProduce[name].resolve(b);
};

return Promise.all([
Expand Down Expand Up @@ -286,8 +280,11 @@ export const getManifestForPriceFeed = async (
},
},
[ensureOracleBrands.name]: {
consume: {
agoricNamesAdmin: t,
namedVat: {
consume: { agoricNames: 'agoricNames' },
},
oracleBrand: {
produce: t,
},
},
},
Expand Down
12 changes: 0 additions & 12 deletions packages/inter-protocol/src/proposals/startPSM.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,18 +422,6 @@ export const PSM_GOV_MANIFEST = {
},
},
},
[startEconCharter.name]: {
consume: { zoe: 'zoe', agoricNames: true },
produce: {
econCharterKit: 'econCommitteeCharter',
},
installation: {
consume: { binaryVoteCounter: 'zoe', econCommitteeCharter: 'zoe' },
},
instance: {
produce: { econCommitteeCharter: 'econCommitteeCharter' },
},
},
};

export const INVITE_PSM_COMMITTEE_MANIFEST = harden(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const setupServices = async (t, params = defaultParams) => {
const timer = buildManualTimer();
await timer.advanceTo(140n);

const space = setupBootstrap(t, timer);
const space = await setupBootstrap(t, timer);
installPuppetGovernance(zoe, space.installation.produce);

// @ts-expect-error not all installs are needed for auctioneer.
Expand Down
6 changes: 4 additions & 2 deletions packages/inter-protocol/test/psm/setupPsm.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Far, makeLoopback } from '@endo/captp';
import { E } from '@endo/eventual-send';

import { makeAgoricNamesAccess, makePromiseSpace } from '@agoric/vats';
import { makePromiseSpace } from '@agoric/vats';
import { makeBoard } from '@agoric/vats/src/lib-board.js';
import { Stable } from '@agoric/vats/src/tokens.js';
import { makeScalarMapStore } from '@agoric/vat-data';
Expand All @@ -12,6 +12,7 @@ import { allValues } from '@agoric/internal';
import { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js';
import { makeIssuerKit } from '@agoric/ertp';

import { makeAgoricNamesAccess } from '@agoric/vats/test/boot-support.js';
import {
installGovernance,
provideBundle,
Expand Down Expand Up @@ -65,7 +66,8 @@ export const setupPsmBootstrap = async (
const zoe = space.consume.zoe;
produce.feeMintAccess.resolve(feeMintAccessP);

const { agoricNames, agoricNamesAdmin, spaces } = makeAgoricNamesAccess();
const { agoricNames, agoricNamesAdmin, spaces } =
await makeAgoricNamesAccess();
produce.agoricNames.resolve(agoricNames);
produce.agoricNamesAdmin.resolve(agoricNamesAdmin);

Expand Down
6 changes: 4 additions & 2 deletions packages/inter-protocol/test/psm/test-psm.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import { NonNullish } from '@agoric/assert';
import { documentStorageSchema } from '@agoric/governance/tools/storageDoc.js';
import { makeTracer } from '@agoric/internal';
import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';
import { makeAgoricNamesAccess, makePromiseSpace } from '@agoric/vats';
import { makePromiseSpace } from '@agoric/vats';
import { Stable } from '@agoric/vats/src/tokens.js';
import { E, Far } from '@endo/far';
import path from 'path';
import { makeAgoricNamesAccess } from '@agoric/vats/test/boot-support.js';
import { makeAnchorAsset, startPSM } from '../../src/proposals/startPSM.js';
import {
makeMockChainStorageRoot,
Expand Down Expand Up @@ -744,7 +745,8 @@ test('restore PSM: startPSM with previous metrics, params', async t => {
/** @type { import('../../src/proposals/econ-behaviors').EconomyBootstrapPowers } */
// @ts-expect-error mock
const { produce, consume } = makePromiseSpace();
const { agoricNames, agoricNamesAdmin, spaces } = makeAgoricNamesAccess();
const { agoricNames, agoricNamesAdmin, spaces } =
await makeAgoricNamesAccess();
const { zoe } = t.context;

// Prep bootstrap space
Expand Down
6 changes: 4 additions & 2 deletions packages/inter-protocol/test/reserve/setup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { E } from '@endo/eventual-send';
import { makeAgoricNamesAccess, makePromiseSpace } from '@agoric/vats';
import { makePromiseSpace } from '@agoric/vats';
import { makeBoard } from '@agoric/vats/src/lib-board.js';
import { makeAgoricNamesAccess } from '@agoric/vats/test/boot-support.js';
import { setupReserve } from '../../src/proposals/econ-behaviors.js';

import {
Expand Down Expand Up @@ -38,7 +39,8 @@ const setupReserveBootstrap = async (t, timer, farZoeKit) => {
// @ts-expect-error could be undefined
produce.chainTimerService.resolve(timer);
produce.zoe.resolve(zoe);
const { agoricNames, agoricNamesAdmin, spaces } = makeAgoricNamesAccess();
const { agoricNames, agoricNamesAdmin, spaces } =
await makeAgoricNamesAccess();
produce.agoricNames.resolve(agoricNames);
produce.agoricNamesAdmin.resolve(agoricNamesAdmin);
produce.feeMintAccess.resolve(feeMintAccessP);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,11 @@
// @ts-check
/** @file Boot script for PSM-only (aka Pismo) chain */
import { Far } from '@endo/far';
import {
installGovAndPSMContracts,
makeAnchorAsset,
startPSM,
inviteToEconCharter,
inviteCommitteeMembers,
PSM_MANIFEST,
PSM_GOV_MANIFEST,
startEconCharter,
INVITE_PSM_COMMITTEE_MANIFEST,
} from '@agoric/inter-protocol/src/proposals/startPSM.js';
import * as startPSMmod from '@agoric/inter-protocol/src/proposals/startPSM.js';
import { E, Far } from '@endo/far';
import * as ERTPmod from '@agoric/ertp';
// TODO: factor startEconomicCommittee out of econ-behaviors.js
import { mustMatch, M } from '@agoric/store';
import {
ECON_COMMITTEE_MANIFEST,
startEconomicCommittee,
} from '@agoric/inter-protocol/src/proposals/startEconCommittee.js';
import { makeAgoricNamesAccess } from './utils.js';
import { makePromiseSpace } from './promise-space.js';
import { Stable, Stake } from '../tokens.js';
import { makePromiseSpace } from '@agoric/vats/src/core/promise-space.js';
import { Stable, Stake } from '@agoric/vats/src/tokens.js';
import {
addBankAssets,
buildZoe,
Expand All @@ -31,8 +14,8 @@ import {
makeBoard,
makeVatsFromBundles,
mintInitialSupply,
} from './basic-behaviors.js';
import * as utils from './utils.js';
} from '@agoric/vats/src/core/basic-behaviors.js';
import * as utils from '@agoric/vats/src/core/utils.js';
import {
bridgeCoreEval,
bridgeProvisioner,
Expand All @@ -42,11 +25,30 @@ import {
publishAgoricNames,
startTimerService,
CHAIN_BOOTSTRAP_MANIFEST,
} from './chain-behaviors.js';
} from '@agoric/vats/src/core/chain-behaviors.js';
import {
startWalletFactory,
WALLET_FACTORY_MANIFEST,
} from './startWalletFactory.js';
} from '@agoric/vats/src/core/startWalletFactory.js';
// eslint-disable-next-line import/no-extraneous-dependencies
import { heapZone } from '@agoric/zone';
import { makeNameHubKit } from '@agoric/vats';
import {
ECON_COMMITTEE_MANIFEST,
startEconomicCommittee,
} from '../../src/proposals/startEconCommittee.js';
import * as startPSMmod from '../../src/proposals/startPSM.js';
import {
installGovAndPSMContracts,
makeAnchorAsset,
startPSM,
inviteToEconCharter,
inviteCommitteeMembers,
PSM_MANIFEST,
PSM_GOV_MANIFEST,
startEconCharter,
INVITE_PSM_COMMITTEE_MANIFEST,
} from '../../src/proposals/startPSM.js';

/** @typedef {import('@agoric/inter-protocol/src/proposals/econ-behaviors.js').EconomyBootstrapSpace} EconomyBootstrapSpace */

Expand Down Expand Up @@ -129,21 +131,37 @@ export const ParametersShape = M.splitRecord(
* anchorAssets: { denom: string, keyword?: string }[],
* }} vatParameters
*/
export const buildRootObject = (vatPowers, vatParameters) => {
const log = vatPowers.logger || console.info;
export const buildRootObject = async (vatPowers, vatParameters) => {
// @@@ const log = vatPowers.logger || console.info;
const log = console.info;
const zone = heapZone;

mustMatch(harden(vatParameters), ParametersShape, 'boot-psm params');
const { anchorAssets, economicCommitteeAddresses } = vatParameters;
const { produce, consume } = makePromiseSpace({ log });

// mock the provisioning vat
const { nameHub: namesByAddress, nameAdmin: namesByAddressAdmin } =
makeNameHubKit();
const mockProvisioning = {
getNamesByAddressKit: () => ({ namesByAddress, namesByAddressAdmin }),
};
produce.provisioning.resolve(mockProvisioning);

const { produce, consume } = makePromiseSpace(log);
const { agoricNames, agoricNamesAdmin, spaces } = makeAgoricNamesAccess(
log,
agoricNamesReserved,
);
produce.agoricNames.resolve(agoricNames);
produce.agoricNamesAdmin.resolve(agoricNamesAdmin);
let spaces;
let namedVat;

const runBootstrapParts = async (vats, devices) => {
const svc = E(vats.vatAdmin).createVatAdminService(devices.vatAdmin);
const criticalVatKey = await E(vats.vatAdmin).getCriticalVatKey();
namedVat = utils.makeVatSpace(svc, criticalVatKey, zone, console.log);

const namesVat = namedVat.consume.agoricNames;
const { agoricNames, agoricNamesAdmin } = await E(namesVat).getNameHubKit();
spaces = await utils.makeWellKnownSpaces(namesVat, log);
produce.agoricNames.resolve(agoricNames);
produce.agoricNamesAdmin.resolve(agoricNamesAdmin);

/** TODO: BootstrapPowers type puzzle */
/** @type { any } */
const allPowers = harden({
Expand All @@ -153,6 +171,7 @@ export const buildRootObject = (vatPowers, vatParameters) => {
devices,
produce,
consume,
namedVat,
...spaces,
// ISSUE: needed? runBehaviors,
// These module namespaces might be useful for core eval governance.
Expand All @@ -169,6 +188,16 @@ export const buildRootObject = (vatPowers, vatParameters) => {
...ECON_COMMITTEE_MANIFEST,
...PSM_MANIFEST,
...INVITE_PSM_COMMITTEE_MANIFEST,
[startEconCharter.name]: {
consume: { zoe: true },
produce: { econCharterKit: true },
installation: {
consume: { binaryVoteCounter: true, econCommitteeCharter: true },
},
instance: {
produce: { econCommitteeCharter: true },
},
},
[noProvisioner.name]: {
produce: {
provisioning: 'provisioning',
Expand Down Expand Up @@ -268,7 +297,7 @@ export const buildRootObject = (vatPowers, vatParameters) => {
},
// ??? any more dangerous than produceItem/consumeItem?
/** @type {() => PromiseSpace} */
getPromiseSpace: () => ({ consume, produce, ...spaces }),
getPromiseSpace: () => ({ consume, produce, namedVat, ...spaces }),
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import { NonNullish } from '@agoric/assert';
import { coalesceUpdates } from '@agoric/smart-wallet/src/utils.js';
import { buildRootObject } from '@agoric/vats/src/core/boot-psm.js';
import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { TimeMath } from '@agoric/time';
import { E } from '@endo/far';
import { zip } from '@agoric/internal';
import { buildRootObject } from './boot-psm.js';
import { INVITATION_MAKERS_DESC as EC_INVITATION_MAKERS_DESC } from '../../src/econCommitteeCharter.js';
import { INVITATION_MAKERS_DESC as ORACLE_INVITATION_MAKERS_DESC } from '../../src/price/fluxAggregatorKit.js';
import { ensureOracleBrands } from '../../src/proposals/price-feed-proposal.js';
Expand Down Expand Up @@ -57,12 +57,12 @@ const makeTestSpace = async (log, bundleCache) => {
// calling ensureOracleBrands and createPriceFeed
// ensuring a feed for ATOM-USD

// @ts-expect-error cast
const space = /** @type {ChainBootstrapSpace} */ (
psmVatRoot.getPromiseSpace()
);
await eventLoopIteration();

/** @type {ChainBootstrapSpace & NamedVatPowers} */
// @ts-expect-error cast
const space = psmVatRoot.getPromiseSpace();

const timer = buildManualTimer(log);
space.produce.chainTimerService.resolve(timer);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import { AmountMath, makeIssuerKit } from '@agoric/ertp';
import { buildRootObject as buildPSMRootObject } from '@agoric/vats/src/core/boot-psm.js';
import '@agoric/vats/src/core/types.js';
import { Stable } from '@agoric/vats/src/tokens.js';
import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js';
Expand All @@ -10,6 +9,7 @@ import { NonNullish } from '@agoric/assert';

import { coalesceUpdates } from '@agoric/smart-wallet/src/utils.js';
import { INVITATION_MAKERS_DESC } from '../../src/econCommitteeCharter.js';
import { buildRootObject as buildPSMRootObject } from './boot-psm.js';
import {
currentPurseBalance,
importBootTestUtils,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ import { makeCopyBag } from '@agoric/store';
import { unsafeMakeBundleCache } from '@agoric/swingset-vat/tools/bundleTool.js';
import centralSupplyBundle from '@agoric/vats/bundles/bundle-centralSupply.js';
import mintHolderBundle from '@agoric/vats/bundles/bundle-mintHolder.js';
import { makeAgoricNamesAccess, makePromiseSpace } from '@agoric/vats';
import { makePromiseSpace } from '@agoric/vats';
import { makeBoard } from '@agoric/vats/src/lib-board.js';
import { Stable } from '@agoric/vats/src/tokens.js';
import { makeRatio } from '@agoric/zoe/src/contractSupport/index.js';
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { E, Far } from '@endo/far';
import { deeplyFulfilled } from '@endo/marshal';
import { makeAgoricNamesAccess } from '@agoric/vats/test/boot-support.js';
import { startStakeFactory } from '../../src/proposals/econ-behaviors.js';
import { startEconomicCommittee } from '../../src/proposals/startEconCommittee.js';
import { ManagerKW as KW } from '../../src/stakeFactory/constants.js';
Expand Down Expand Up @@ -130,7 +131,7 @@ export const setupBootstrap = async (t, timer = buildManualTimer(t.log)) => {
produce.chainTimerService.resolve(timer);
produce.zoe.resolve(zoe);

const { agoricNames, spaces } = makeAgoricNamesAccess();
const { agoricNames, spaces } = await makeAgoricNamesAccess();
produce.agoricNames.resolve(agoricNames);

for (const contract of [
Expand Down
Loading