Skip to content

Commit

Permalink
feat: make production Zoe use prebundled zcf
Browse files Browse the repository at this point in the history
  • Loading branch information
FUDCo committed Aug 12, 2020
1 parent 60050a5 commit 138ddd7
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 17 deletions.
6 changes: 5 additions & 1 deletion packages/cosmic-swingset/lib/ag-solo/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import anylogger from 'anylogger';

import {
loadBasedir,
loadSwingsetConfigFile,
buildCommand,
buildVatController,
buildMailboxStateMap,
Expand Down Expand Up @@ -87,7 +88,10 @@ async function buildSwingset(
const cm = buildCommand(broadcast);
const timer = buildTimer();

const config = await loadBasedir(vatsDir);
let config = loadSwingsetConfigFile(`${vatsDir}/solo-config.json`);
if (config === null) {
config = loadBasedir(vatsDir);
}
config.devices = [
['mailbox', mb.srcPath, mb.endowments],
['command', cm.srcPath, cm.endowments],
Expand Down
49 changes: 49 additions & 0 deletions packages/cosmic-swingset/lib/ag-solo/vats/chain-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"bootstrap": "bootstrap",
"bundles": {
"zcf": {
"sourcePath": "../../../../zoe/src/contractFacet.js"
}
},
"vats": {
"board": {
"sourcePath": "vat-board.js"
},
"host": {
"sourcePath": "vat-host.js"
},
"http": {
"sourcePath": "vat-http.js"
},
"ibc": {
"sourcePath": "vat-ibc.js"
},
"mints": {
"sourcePath": "vat-mints.js"
},
"network": {
"sourcePath": "vat-network.js"
},
"provisioning": {
"sourcePath": "vat-provisioning.js"
},
"registrar": {
"sourcePath": "vat-registrar.js"
},
"sharing": {
"sourcePath": "vat-sharing.js"
},
"uploads": {
"sourcePath": "vat-uploads.js"
},
"zoe": {
"sourcePath": "vat-zoe.js",
"parameters": {
"zcfBundleName": "zcf"
}
},
"bootstrap": {
"sourcePath": "bootstrap.js"
}
}
}
49 changes: 49 additions & 0 deletions packages/cosmic-swingset/lib/ag-solo/vats/solo-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"bootstrap": "bootstrap",
"bundles": {
"zcf": {
"sourcePath": "../../../../zoe/src/contractFacet.js"
}
},
"vats": {
"board": {
"sourcePath": "vat-board.js"
},
"host": {
"sourcePath": "vat-host.js"
},
"http": {
"sourcePath": "vat-http.js"
},
"ibc": {
"sourcePath": "vat-ibc.js"
},
"mints": {
"sourcePath": "vat-mints.js"
},
"network": {
"sourcePath": "vat-network.js"
},
"provisioning": {
"sourcePath": "vat-provisioning.js"
},
"registrar": {
"sourcePath": "vat-registrar.js"
},
"sharing": {
"sourcePath": "vat-sharing.js"
},
"uploads": {
"sourcePath": "vat-uploads.js"
},
"zoe": {
"sourcePath": "vat-zoe.js",
"parameters": {
"zcfBundleName": "zcf"
}
},
"bootstrap": {
"sourcePath": "bootstrap.js"
}
}
}
21 changes: 6 additions & 15 deletions packages/cosmic-swingset/lib/launch-chain.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import fs from 'fs';
import path from 'path';
import anylogger from 'anylogger';

Expand All @@ -9,6 +8,8 @@ import {
buildTimer,
buildBridge,
buildVatController,
loadBasedir,
loadSwingsetConfigFile,
} from '@agoric/swingset-vat';
import { getBestSwingStore } from './check-lmdb';

Expand All @@ -25,7 +26,10 @@ async function buildSwingset(
debugName = undefined,
) {
const debugPrefix = debugName === undefined ? '' : `${debugName}:`;
const config = {};
let config = loadSwingsetConfigFile(`${vatsDir}/chain-config.json`);
if (config === null) {
config = loadBasedir(vatsDir);
}
const mbs = buildMailboxStateMap();
mbs.populateFromData(mailboxState);
const timer = buildTimer();
Expand All @@ -36,19 +40,6 @@ async function buildSwingset(
['mailbox', mb.srcPath, mb.endowments],
['timer', timer.srcPath, timer.endowments],
];
config.vats = {};
for (const fname of fs.readdirSync(vatsDir)) {
const match = fname.match(/^vat-(.*)\.js$/);
if (match) {
config.vats[match[1]] = {
sourcePath: require.resolve(`${vatsDir}/${fname}`),
};
}
}
config.vats.bootstrap = {
sourcePath: require.resolve(`${vatsDir}/bootstrap.js`),
};
config.bootstrap = 'bootstrap';

const controller = await buildVatController(config, argv, {
hostStorage: storage,
Expand Down
2 changes: 1 addition & 1 deletion packages/zoe/test/unitTests/contracts/fakeVatAdmin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default harden({
root: E(evalContractBundle(bundle)).buildRootObject(),
});
},
createVatByName: name => {
createVatByName: _name => {
throw Error(`createVatByName not supported in fake mode`);
},
});

0 comments on commit 138ddd7

Please sign in to comment.