Skip to content

Commit

Permalink
Merge pull request #7049 from Agoric/dc-boot-check
Browse files Browse the repository at this point in the history
replace ROLE with 3 bootstrap modules; audit contents
  • Loading branch information
mergify[bot] authored Mar 14, 2023
2 parents ce7244d + 478dc43 commit 3d87d1d
Show file tree
Hide file tree
Showing 61 changed files with 1,862 additions and 1,045 deletions.
11 changes: 6 additions & 5 deletions packages/SwingSet/src/controller/initializeSwingset.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,22 +282,23 @@ function sortObjectProperties(obj, firsts = []) {
return result;
}

/** @typedef {{ kernelBundles?: Record<string, Bundle>, verbose?: boolean,
/**
* @typedef {{ kernelBundles?: Record<string, Bundle>, verbose?: boolean,
* addVatAdmin?: boolean, addComms?: boolean, addVattp?: boolean,
* addTimer?: boolean,
* }} InitializationOptions
*/

/**
* @param {SwingSetConfig} config
* @param {string[]} argv
* @param {unknown} bootstrapArgs
* @param {SwingStoreKernelStorage} kernelStorage
* @param {InitializationOptions} initializationOptions
* @param {{ env?: Record<string, string | undefined > }} runtimeOptions
*/
export async function initializeSwingset(
config,
argv = [],
bootstrapArgs,
kernelStorage,
initializationOptions = {},
runtimeOptions = {},
Expand Down Expand Up @@ -353,13 +354,13 @@ export async function initializeSwingset(
kvStore.set('lockdownBundle', JSON.stringify(kernelBundles.lockdown));
kvStore.set('supervisorBundle', JSON.stringify(kernelBundles.supervisor));

if (config.bootstrap && argv) {
if (config.bootstrap && bootstrapArgs) {
const bootConfig = config.vats[config.bootstrap];
if (bootConfig) {
if (!bootConfig.parameters) {
bootConfig.parameters = {};
}
bootConfig.parameters.argv = argv;
bootConfig.parameters.argv = bootstrapArgs;
}
}

Expand Down
1 change: 0 additions & 1 deletion packages/cosmic-swingset/src/chain-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ export default async function main(progname, args, { env, homedir, agcc }) {
};

const argv = {
ROLE: 'chain',
bootMsg,
};
const vatHref = await importMetaResolve(
Expand Down
17 changes: 7 additions & 10 deletions packages/cosmic-swingset/src/launch-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,19 @@ const getHostKey = path => `host.${path}`;
* @param {*} bridgeOutbound
* @param {SwingStoreKernelStorage} kernelStorage
* @param {string} vatconfig absolute path
* @param {Record<string, any>} argv XXX argv should be an array but it's being called with object
* @param {{ ROLE: string }} env
* @param {unknown} bootstrapArgs JSON-serializable data
* @param {{}} env
* @param {*} options
*/
export async function buildSwingset(
mailboxStorage,
bridgeOutbound,
kernelStorage,
vatconfig,
argv,
bootstrapArgs,
env,
{ debugName = undefined, slogCallbacks, slogSender },
) {
// FIXME: Find a better way to propagate the role.
process.env.ROLE = argv.ROLE;
env.ROLE = argv.ROLE;

const debugPrefix = debugName === undefined ? '' : `${debugName}:`;
/** @type {import('@agoric/swingset-vat').SwingSetConfig | null} */
let config = await loadSwingsetConfigFile(vatconfig);
Expand Down Expand Up @@ -122,8 +118,10 @@ export async function buildSwingset(
}
config.pinBootstrapRoot = true;

// @ts-expect-error XXX argv object
await initializeSwingset(config, argv, kernelStorage, { debugPrefix });
await initializeSwingset(config, bootstrapArgs, kernelStorage, {
// @ts-expect-error debugPrefix? what's that?
debugPrefix,
});
}
await ensureSwingsetInitialized();
const controller = await makeSwingsetController(
Expand Down Expand Up @@ -275,7 +273,6 @@ export async function launch({
kernelStorage,
vatconfig,
argv,
// @ts-expect-error process.env default
env,
{
debugName,
Expand Down
1 change: 0 additions & 1 deletion packages/cosmic-swingset/src/sim-chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export async function connectToFakeChain(basedir, GCI, delay, inbound) {
const mailboxStorage = await makeMapStorage(mailboxFile);

const argv = {
ROLE: 'sim-chain',
giveMeAllTheAgoricPowers: true,
hardcodedClientAddresses: [bootAddress],
bootMsg: {
Expand Down
3 changes: 1 addition & 2 deletions packages/cosmic-swingset/src/sim-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ export const defaultBeansPerUnit = [
makeStringBeans(BeansPerXsnapComputron, defaultBeansPerXsnapComputron),
];

export const defaultBootstrapVatConfig =
'@agoric/vats/decentral-devnet-config.json';
const defaultBootstrapVatConfig = '@agoric/vats/decentral-demo-config.json';

export const defaultPowerFlagFees = [
makePowerFlagFee('SMART_WALLET', [makeCoin('ubld', 10_000_000n)]),
Expand Down
5 changes: 1 addition & 4 deletions packages/inter-protocol/scripts/init-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const mainProposalBuilder = async ({
install: install0,
wrapInstall,
}) => {
const { ROLE = 'chain', VAULT_FACTORY_CONTROLLER_ADDR } = process.env;
const { VAULT_FACTORY_CONTROLLER_ADDR } = process.env;

const install = wrapInstall ? wrapInstall(install0) : install0;

Expand All @@ -119,7 +119,6 @@ export const mainProposalBuilder = async ({
getManifestCall: [
getManifestForMain.name,
{
ROLE,
vaultFactoryControllerAddress: VAULT_FACTORY_CONTROLLER_ADDR,
installKeys: {
...publishGroup(installKeyGroups.main),
Expand All @@ -139,7 +138,6 @@ export const defaultProposalBuilder = async (
/** @param {string|undefined} s */
const optBigInt = s => s && BigInt(s);
const {
ROLE = env.ROLE || 'chain',
vaultFactoryControllerAddress = env.VAULT_FACTORY_CONTROLLER_ADDR,
minInitialPoolLiquidity = env.MIN_INITIAL_POOL_LIQUIDITY,
endorsedUi,
Expand Down Expand Up @@ -176,7 +174,6 @@ export const defaultProposalBuilder = async (
getManifestCall: [
getManifestForInterProtocol.name,
{
ROLE,
vaultFactoryControllerAddress,
minInitialPoolLiquidity: optBigInt(minInitialPoolLiquidity),
endorsedUi,
Expand Down
18 changes: 4 additions & 14 deletions packages/inter-protocol/src/proposals/core-proposal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ import * as econBehaviors from './econ-behaviors.js';
import { ECON_COMMITTEE_MANIFEST } from './startEconCommittee.js';

export * from './econ-behaviors.js';
export * from './sim-behaviors.js';
// @ts-expect-error Module './econ-behaviors.js' has already exported a member
// named 'EconomyBootstrapPowers'.
export * from './startPSM.js'; // eslint-disable-line import/export
export * from './startEconCommittee.js'; // eslint-disable-line import/export

/** @type {import('@agoric/vats/src/core/manifest.js').BootstrapManifest} */
/** @type {import('@agoric/vats/src/core/lib-boot.js').BootstrapManifest} */
const SHARED_MAIN_MANIFEST = harden({
/** @type {import('@agoric/vats/src/core/manifest.js').BootstrapManifestPermit} */
/** @type {import('@agoric/vats/src/core/lib-boot.js').BootstrapManifestPermit} */
[econBehaviors.startVaultFactory.name]: {
consume: {
board: 'board',
Expand Down Expand Up @@ -200,19 +199,9 @@ export const getManifestForMain = (
};
};

const roleToManifest = harden({
chain: {
...REWARD_MANIFEST,
...STAKE_FACTORY_MANIFEST,
},
'sim-chain': SIM_CHAIN_MANIFEST,
client: {},
});

export const getManifestForInterProtocol = (
{ restoreRef },
{
ROLE = 'chain',
econCommitteeOptions,
installKeys,
vaultFactoryControllerAddress,
Expand All @@ -237,7 +226,8 @@ export const getManifestForInterProtocol = (
manifest: {
...econCommitteeManifest.manifest,
...mainManifest.manifest,
...roleToManifest[ROLE],
...REWARD_MANIFEST,
...STAKE_FACTORY_MANIFEST,
},
installations: {
...econCommitteeManifest.installations,
Expand Down
39 changes: 0 additions & 39 deletions packages/inter-protocol/src/proposals/sim-behaviors.js

This file was deleted.

15 changes: 8 additions & 7 deletions packages/inter-protocol/src/proposals/startPSM.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
inviteToEconCharter,
} from './committee-proposal.js';

/** @typedef {import('@agoric/vats/src/core/lib-boot.js').BootstrapManifest} BootstrapManifest */

const BASIS_POINTS = 10000n;
const { details: X } = assert;

Expand Down Expand Up @@ -314,7 +316,7 @@ export const installGovAndPSMContracts = async ({
* named swingset bundles only in
* decentral-psm-config.json
*
* @type {import('@agoric/vats/src/core/manifest.js').BootstrapManifest}
* @type {BootstrapManifest}
*/
export const PSM_GOV_MANIFEST = {
[installGovAndPSMContracts.name]: {
Expand Down Expand Up @@ -345,8 +347,7 @@ export const PSM_GOV_MANIFEST = {
};

export const INVITE_PSM_COMMITTEE_MANIFEST = harden(
/** @type {import('@agoric/vats/src/core/manifest.js').BootstrapManifest} */
({
/** @type {BootstrapManifest} */ ({
[inviteCommitteeMembers.name]: {
consume: {
namesByAddressAdmin: true,
Expand All @@ -363,9 +364,8 @@ export const INVITE_PSM_COMMITTEE_MANIFEST = harden(
}),
);

/** @type {import('@agoric/vats/src/core/manifest.js').BootstrapManifest} */
export const PSM_MANIFEST = harden({
/** @type {import('@agoric/vats/src/core/manifest.js').BootstrapManifestPermit} */
/** @type {BootstrapManifest} */
export const PSM_MANIFEST = {
[makeAnchorAsset.name]: {
consume: { agoricNamesAdmin: true, bankManager: 'bank', zoe: 'zoe' },
installation: { consume: { mintHolder: 'zoe' } },
Expand Down Expand Up @@ -395,7 +395,8 @@ export const PSM_MANIFEST = harden({
consume: { [Stable.symbol]: 'zoe' },
},
},
});
};
harden(PSM_MANIFEST);

export const getManifestForPsmGovernance = (
{ restoreRef },
Expand Down
5 changes: 1 addition & 4 deletions packages/inter-protocol/test/psm/setupPsm.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { Far, makeLoopback } from '@endo/captp';
import { E } from '@endo/eventual-send';

import {
makeAgoricNamesAccess,
makePromiseSpace,
} from '@agoric/vats/src/core/utils.js';
import { makeAgoricNamesAccess, 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 Down
5 changes: 1 addition & 4 deletions packages/inter-protocol/test/reserve/setup.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import buildManualTimer from '@agoric/zoe/tools/manualTimer.js';
import { E } from '@endo/eventual-send';
import {
makeAgoricNamesAccess,
makePromiseSpace,
} from '@agoric/vats/src/core/utils.js';
import { makeAgoricNamesAccess, makePromiseSpace } from '@agoric/vats';
import { makeBoard } from '@agoric/vats/src/lib-board.js';
import { setupReserve } from '../../src/proposals/econ-behaviors.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ 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/src/core/utils.js';
import { makeAgoricNamesAccess, 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';
Expand Down
5 changes: 1 addition & 4 deletions packages/inter-protocol/test/supports.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import committeeBundle from '@agoric/governance/bundles/bundle-committee.js';
import contractGovernorBundle from '@agoric/governance/bundles/bundle-contractGovernor.js';
import puppetContractGovernorBundle from '@agoric/governance/bundles/bundle-puppetContractGovernor.js';
import * as utils from '@agoric/vats/src/core/utils.js';
import {
makeAgoricNamesAccess,
makePromiseSpace,
} from '@agoric/vats/src/core/utils.js';
import { makePromiseSpace, makeAgoricNamesAccess } from '@agoric/vats';
import { makeBoard } from '@agoric/vats/src/lib-board.js';
import { Stable } from '@agoric/vats/src/tokens.js';
import { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js';
Expand Down
9 changes: 9 additions & 0 deletions packages/internal/src/magic-cookie-test-only.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const cookie = harden({});

/**
* Facilitate static analysis to prevent
* demo/test facilities from being bundled in production.
*/
export const notForProductionUse = () => {
return cookie;
};
2 changes: 1 addition & 1 deletion packages/smart-wallet/src/walletFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { observeIteration } from '@agoric/notifier';
import { M, makeExo, makeScalarMapStore, mustMatch } from '@agoric/store';
import { makeAtomicProvider } from '@agoric/store/src/stores/store-utils.js';
import { prepareExo, provideDurableMapStore } from '@agoric/vat-data';
import { makeMyAddressNameAdminKit } from '@agoric/vats/src/core/basic-behaviors.js';
import { makeMyAddressNameAdminKit } from '@agoric/vats/src/core/utils.js';
import { provideAll } from '@agoric/zoe/src/contractSupport/durability.js';
import { E } from '@endo/far';
import { prepareSmartWallet } from './smartWallet.js';
Expand Down
5 changes: 1 addition & 4 deletions packages/smart-wallet/test/supports.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import {
} from '@agoric/vats/src/core/basic-behaviors.js';
import { setupClientManager } from '@agoric/vats/src/core/chain-behaviors.js';
import '@agoric/vats/src/core/types.js';
import {
makeAgoricNamesAccess,
makePromiseSpace,
} from '@agoric/vats/src/core/utils.js';
import { makeAgoricNamesAccess, makePromiseSpace } from '@agoric/vats';
import { buildRootObject as boardRoot } from '@agoric/vats/src/vat-board.js';
import { buildRootObject as mintsRoot } from '@agoric/vats/src/vat-mints.js';
import { makeMockChainStorageRoot } from '@agoric/internal/src/storage-test-utils.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/solo/solo-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"sourceSpec": "./src/vat-uploads.js"
},
"bootstrap": {
"sourceSpec": "@agoric/vats/src/core/boot.js"
"sourceSpec": "@agoric/vats/src/core/boot-solo.js"
}
}
}
Loading

0 comments on commit 3d87d1d

Please sign in to comment.