Skip to content

Commit

Permalink
fix: implement robust plugin persistence model
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Sep 16, 2020
1 parent d2a545e commit 2de552e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
7 changes: 4 additions & 3 deletions packages/agoric-cli/lib/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ export default async function deployMain(progname, rawArgs, powers, opts) {

let installUnsafePlugin;
if (!allowUnsafePlugins) {
installUnsafePlugin = async plugin => {
installUnsafePlugin = async (plugin, _opts = undefined) => {
throw Error(
`Installing unsafe plugin ${JSON.stringify(
pathResolve(plugin),
)} disabled; maybe you meant '--allow-unsafe-plugins'?`,
);
};
} else {
installUnsafePlugin = async plugin => {
installUnsafePlugin = async (plugin, pluginOpts = undefined) => {
try {
const absPath = pathResolve(plugin);
const pluginName = absPath.replace(PATH_SEP_RE, '_');
Expand All @@ -202,7 +202,8 @@ export { bootPlugin } from ${JSON.stringify(absPath)};

// Return the bootstrap object for this plugin.
console.info(`Loading plugin ${JSON.stringify(pluginFile)}`);
return E.G(E(pluginManager).load(pluginName)).bootstrap;
return E.G(E(pluginManager).load(pluginName, pluginOpts))
.bootstrap;
} catch (e) {
throw Error(
`Cannot install unsafe plugin: ${(e && e.stack) || e}`,
Expand Down
1 change: 0 additions & 1 deletion packages/agoric-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"lint-check-jessie": "eslint -c '.eslintrc-jessie.js' '**/*.{js,jsx}'"
},
"devDependencies": {
"@agoric/install-ses": "^0.2.0",
"ava": "^3.12.1",
"nyc": "^15.1.0",
"tmp": "^0.1.0"
Expand Down
16 changes: 9 additions & 7 deletions packages/captp/lib/captp.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,15 @@ export function makeCapTP(ourId, rawSend, bootstrapObj = undefined, opts = {}) {
const { questionID } = obj;
const bootstrap =
typeof bootstrapObj === 'function' ? bootstrapObj() : bootstrapObj;
// console.log('sending bootstrap', bootstrap);
answers.set(questionID, bootstrap);
return send({
type: 'CTP_RETURN',
epoch,
answerID: questionID,
result: serialize(bootstrap),
E.when(bootstrap, bs => {
// console.log('sending bootstrap', bootstrap);
answers.set(questionID, bs);
return send({
type: 'CTP_RETURN',
epoch,
answerID: questionID,
result: serialize(bs),
});
});
},
// Remote is invoking a method or retrieving a property.
Expand Down
4 changes: 1 addition & 3 deletions packages/cosmic-swingset/lib/ag-solo/chain-cosmos-sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,7 @@ export async function connectToChain(
if (!r.stdout) {
console.error(`\
=============
${chainID} chain does not yet know of address ${myAddr}${adviseEgress(
myAddr,
)}
${chainID} chain does not yet know of address ${myAddr}${adviseEgress(myAddr)}
=============
`);
return undefined;
Expand Down
14 changes: 8 additions & 6 deletions packages/cosmic-swingset/lib/ag-solo/vats/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function makePluginManager(pluginDevice, { D, ...vatPowers }) {
/**
* Load a module, and call resetter.onReset(bootP) every time it is instantiated.
*/
load(mod, resetter = { onReset: _ => {} }) {
load(specifier, opts = undefined, resetter = { onReset: _ => {} }) {
// This is the internal state: a promise kit that doesn't
// resolve until we are connected. It is replaced by
// a new promise kit when we abort the prior module connection.
Expand All @@ -82,7 +82,7 @@ export function makePluginManager(pluginDevice, { D, ...vatPowers }) {
let currentReset = _ => {};

// Connect to the module.
const index = D(pluginDevice).connect(mod);
const index = D(pluginDevice).connect(specifier);
if (typeof index !== 'number') {
// An error string.
throw Error(index);
Expand All @@ -108,9 +108,11 @@ export function makePluginManager(pluginDevice, { D, ...vatPowers }) {
// Create a CapTP channel.
const myEpoch = nextEpoch;
nextEpoch += 1;
console.info(`Connecting to ${mod}.${index} with epoch ${myEpoch}`);
console.info(
`Connecting to ${specifier}.${index} with epoch ${myEpoch}`,
);
const { getBootstrap, dispatch } = makeCapTP(
mod,
specifier,
obj => {
// console.warn('sending', index, obj);
D(pluginDevice).send(index, obj);
Expand All @@ -136,8 +138,8 @@ export function makePluginManager(pluginDevice, { D, ...vatPowers }) {

currentEpoch = myEpoch;

// Publish our bootstrap promise.
bootPK.resolve(getBootstrap());
// Publish our started plugin.
bootPK.resolve(E(getBootstrap()).start(opts));
};

const actions = harden({
Expand Down
2 changes: 2 additions & 0 deletions packages/dapp-svelte-wallet/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "@agoric/dapp-svelte-wallet-ui",
"version": "1.1.1",
"license": "Apache-2.0",
"author": "Agoric",
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
Expand Down

0 comments on commit 2de552e

Please sign in to comment.