@agoric/vats 0.15.2-dev-228f08b.0 → 0.15.2-dev-4054171.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/vats",
|
|
3
|
-
"version": "0.15.2-dev-
|
|
3
|
+
"version": "0.15.2-dev-4054171.0+4054171",
|
|
4
4
|
"description": "Agoric's Vat library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -22,19 +22,19 @@
|
|
|
22
22
|
"author": "Agoric",
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@agoric/cosmic-proto": "0.4.1-dev-
|
|
26
|
-
"@agoric/ertp": "0.16.3-dev-
|
|
27
|
-
"@agoric/governance": "0.10.4-dev-
|
|
28
|
-
"@agoric/internal": "0.3.3-dev-
|
|
29
|
-
"@agoric/network": "0.1.1-dev-
|
|
30
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
31
|
-
"@agoric/store": "0.9.3-dev-
|
|
32
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
33
|
-
"@agoric/time": "0.3.3-dev-
|
|
34
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
35
|
-
"@agoric/vow": "0.1.1-dev-
|
|
36
|
-
"@agoric/zoe": "0.26.3-dev-
|
|
37
|
-
"@agoric/zone": "0.2.3-dev-
|
|
25
|
+
"@agoric/cosmic-proto": "0.4.1-dev-4054171.0+4054171",
|
|
26
|
+
"@agoric/ertp": "0.16.3-dev-4054171.0+4054171",
|
|
27
|
+
"@agoric/governance": "0.10.4-dev-4054171.0+4054171",
|
|
28
|
+
"@agoric/internal": "0.3.3-dev-4054171.0+4054171",
|
|
29
|
+
"@agoric/network": "0.1.1-dev-4054171.0+4054171",
|
|
30
|
+
"@agoric/notifier": "0.6.3-dev-4054171.0+4054171",
|
|
31
|
+
"@agoric/store": "0.9.3-dev-4054171.0+4054171",
|
|
32
|
+
"@agoric/swingset-vat": "0.32.3-dev-4054171.0+4054171",
|
|
33
|
+
"@agoric/time": "0.3.3-dev-4054171.0+4054171",
|
|
34
|
+
"@agoric/vat-data": "0.5.3-dev-4054171.0+4054171",
|
|
35
|
+
"@agoric/vow": "0.1.1-dev-4054171.0+4054171",
|
|
36
|
+
"@agoric/zoe": "0.26.3-dev-4054171.0+4054171",
|
|
37
|
+
"@agoric/zone": "0.2.3-dev-4054171.0+4054171",
|
|
38
38
|
"@endo/errors": "^1.2.10",
|
|
39
39
|
"@endo/far": "^1.1.11",
|
|
40
40
|
"@endo/import-bundle": "^1.4.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"jessie.js": "^0.3.4"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@agoric/swingset-liveslots": "0.10.3-dev-
|
|
50
|
+
"@agoric/swingset-liveslots": "0.10.3-dev-4054171.0+4054171",
|
|
51
51
|
"@endo/bundle-source": "^4.0.0",
|
|
52
52
|
"@endo/init": "^1.1.9",
|
|
53
53
|
"ava": "^5.3.0",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"typeCoverage": {
|
|
80
80
|
"atLeast": 90.43
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "4054171a6a562a8bad1824b0151d103b8fe2f502"
|
|
83
83
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export function terminateGoverned({ consume: { board, governedContractKits, zoe } }: BootstrapPowers, { options: { targetSpecifiers } }: {
|
|
2
|
+
options: {
|
|
3
|
+
targetSpecifiers: string[];
|
|
4
|
+
};
|
|
5
|
+
}): Promise<void>;
|
|
6
|
+
export function getManifest(_powers: object, targetSpecifiers: string[]): {
|
|
7
|
+
manifest: {
|
|
8
|
+
[terminateGoverned.name]: {
|
|
9
|
+
consume: {
|
|
10
|
+
board: boolean;
|
|
11
|
+
governedContractKits: boolean;
|
|
12
|
+
zoe: boolean;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
options: {
|
|
17
|
+
targetSpecifiers: string[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */
|
|
21
|
+
export const defaultProposalBuilder: import("@agoric/deploy-script-support/src/externalTypes.js").CoreEvalBuilder;
|
|
22
|
+
declare const _default: (homeP: Promise<import("@agoric/deploy-script-support/src/externalTypes.js").CommonHome>, endowments: import("@agoric/deploy-script-support/src/externalTypes.js").DeployScriptEndownments) => Promise<void>;
|
|
23
|
+
export default _default;
|
|
24
|
+
//# sourceMappingURL=terminate-governed-instance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminate-governed-instance.d.ts","sourceRoot":"","sources":["terminate-governed-instance.js"],"names":[],"mappings":"AA0EO,qFAPI,eAAe,qCAEvB;IAAuB,OAAO,EAC9B;QAAiC,gBAAgB,EAAzC,MAAM,EAAE;KAGlB;CAAA,iBAsFA;AAUM,qCAHI,MAAM,oBACN,MAAM,EAAE;;QAMb,CAAC,iBAAiB,CAAC,IAAI,CAAC;;;;;;UAEvB;;;;;EAMN;AAED,2FAA2F;AAC3F,qCADW,OAAO,oDAAoD,EAAE,eAAe,CAYrF;yBAGoB,uFAAK,EAAE,gGAAU"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Source for a core-eval to terminate governed contract instances along
|
|
3
|
+
* with their governors by mapping a board ID to a key in the Bootstrap Powers
|
|
4
|
+
* governedContractKits collection. Also functions as an off-chain builder
|
|
5
|
+
* script for such core-evals:
|
|
6
|
+
*
|
|
7
|
+
* agoric run /path/to/$0 <$instanceHandleBoardID:$instanceKitLabel>...
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/// <reference types="@agoric/vats/src/core/types-ambient"/>
|
|
11
|
+
|
|
12
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
13
|
+
// dynamic import { makeHelpers } from '@agoric/deploy-script-support';
|
|
14
|
+
// dynamic import { getSpecifier } from '@agoric/internal/src/module-utils.js';
|
|
15
|
+
import { E, passStyleOf } from '@endo/far';
|
|
16
|
+
import { makeTracer } from '@agoric/internal/src/debug.js';
|
|
17
|
+
|
|
18
|
+
const USAGE = `Usage: agoric run /path/to/terminate-governed-instance.js \\
|
|
19
|
+
<$instanceHandleBoardID:$instanceKitLabel>...`;
|
|
20
|
+
|
|
21
|
+
const repr = val =>
|
|
22
|
+
typeof val === 'string' || typeof val === 'object'
|
|
23
|
+
? JSON.stringify(val)
|
|
24
|
+
: String(val);
|
|
25
|
+
const defaultMakeError = (strings, ...subs) =>
|
|
26
|
+
Error(
|
|
27
|
+
strings.map((s, i) => `${i === 0 ? '' : repr(subs[i - 1])}${s}`).join(''),
|
|
28
|
+
);
|
|
29
|
+
const makeUsageError = (strings, ...subs) => {
|
|
30
|
+
const err = defaultMakeError(strings, ...subs);
|
|
31
|
+
console.error(err.message);
|
|
32
|
+
console.error(USAGE);
|
|
33
|
+
return err;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const rtarget = /^(?<boardID>board[0-9]+):(?<instanceKitLabel>.+)$/;
|
|
37
|
+
/**
|
|
38
|
+
* @param {string[]} args
|
|
39
|
+
* @param {(
|
|
40
|
+
* strings: TemplateStringsArray | string[],
|
|
41
|
+
* ...subs: unknown[]
|
|
42
|
+
* ) => Error} [makeError]
|
|
43
|
+
* for visible errors with or without `Fail`
|
|
44
|
+
* @returns {{ boardID: string; instanceKitLabel: string }[]}
|
|
45
|
+
*/
|
|
46
|
+
const parseTargets = (args = [], makeError = defaultMakeError) => {
|
|
47
|
+
if (!Array.isArray(args)) throw makeError`invalid targets: ${args}`;
|
|
48
|
+
/** @type {{ boardID: string; instanceKitLabel: string }[]} */
|
|
49
|
+
const targets = [];
|
|
50
|
+
const badTargets = [];
|
|
51
|
+
for (const arg of args) {
|
|
52
|
+
const m = typeof arg === 'string' && arg.match(rtarget);
|
|
53
|
+
if (!m) {
|
|
54
|
+
badTargets.push(arg);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
// @ts-expect-error cast
|
|
58
|
+
targets.push(m.groups);
|
|
59
|
+
}
|
|
60
|
+
if (badTargets.length) throw makeError`malformed target(s): ${badTargets}`;
|
|
61
|
+
if (!targets.length) throw makeError`no target(s)`;
|
|
62
|
+
return targets;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Terminate one or more governed contract instances and their governors.
|
|
67
|
+
*
|
|
68
|
+
* @param {BootstrapPowers} powers
|
|
69
|
+
* @param {object} config
|
|
70
|
+
* @param {object} config.options
|
|
71
|
+
* @param {string[]} config.options.targetSpecifiers An array of
|
|
72
|
+
* "$instanceHandleBoardID:$instanceKitLabel" strings corresponding with vats
|
|
73
|
+
* to terminate.
|
|
74
|
+
*/
|
|
75
|
+
export const terminateGoverned = async (
|
|
76
|
+
{ consume: { board, governedContractKits, zoe } },
|
|
77
|
+
{ options: { targetSpecifiers } },
|
|
78
|
+
) => {
|
|
79
|
+
const { Fail, quote: q } = assert;
|
|
80
|
+
|
|
81
|
+
// Parse and validate the targets.
|
|
82
|
+
const targets = parseTargets(targetSpecifiers, Fail);
|
|
83
|
+
const validationResults = await Promise.allSettled(
|
|
84
|
+
targets.map(async ({ boardID, instanceKitLabel }) => {
|
|
85
|
+
const targetData = [boardID, instanceKitLabel];
|
|
86
|
+
const logLabel = q(targetData);
|
|
87
|
+
const trace = makeTracer(`terminate-governed-instance ${logLabel}`, true);
|
|
88
|
+
const contractInstanceHandle = await E(board).getValue(boardID);
|
|
89
|
+
const instanceKit = await E(governedContractKits).get(
|
|
90
|
+
// @ts-expect-error TS2345 Property '[tag]' is missing
|
|
91
|
+
contractInstanceHandle,
|
|
92
|
+
);
|
|
93
|
+
trace('alleged governed contract instance kit', instanceKit);
|
|
94
|
+
|
|
95
|
+
const { label, governor, governorCreatorFacet, governorAdminFacet } =
|
|
96
|
+
instanceKit;
|
|
97
|
+
label === instanceKitLabel ||
|
|
98
|
+
Fail`${logLabel} unexpected instanceKit label, got ${label} but wanted ${q(instanceKitLabel)}`;
|
|
99
|
+
const govTerms = /** @type {any} */ (await E(zoe).getTerms(governor));
|
|
100
|
+
trace({ govTerms });
|
|
101
|
+
(passStyleOf(govTerms?.governed) === 'copyRecord' &&
|
|
102
|
+
passStyleOf(govTerms?.governedContractInstallation) === 'remotable') ||
|
|
103
|
+
Fail`${logLabel} instanceKit governor does not appear to have the right terms shape`;
|
|
104
|
+
|
|
105
|
+
const instanceAdminFacet = await E(governorCreatorFacet).getAdminFacet();
|
|
106
|
+
trace({ instanceAdminFacet });
|
|
107
|
+
return { logLabel, trace, instanceAdminFacet, governorAdminFacet };
|
|
108
|
+
}),
|
|
109
|
+
);
|
|
110
|
+
const validationProblems = targets.flatMap(
|
|
111
|
+
({ boardID, instanceKitLabel }, i) => {
|
|
112
|
+
if (validationResults[i].status === 'fulfilled') return [];
|
|
113
|
+
return [
|
|
114
|
+
{ boardID, instanceKitLabel, error: validationResults[i].reason },
|
|
115
|
+
];
|
|
116
|
+
},
|
|
117
|
+
);
|
|
118
|
+
if (validationProblems.length !== 0) {
|
|
119
|
+
console.error(
|
|
120
|
+
'terminate-governed-instance target validation failed',
|
|
121
|
+
validationProblems,
|
|
122
|
+
);
|
|
123
|
+
Fail`target validation failed: ${validationProblems}`;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Terminate each target governed contract and governor.
|
|
127
|
+
const terminationResults = await Promise.allSettled(
|
|
128
|
+
validationResults.map(async settlement => {
|
|
129
|
+
assert(settlement.status === 'fulfilled');
|
|
130
|
+
const { logLabel, trace, instanceAdminFacet, governorAdminFacet } =
|
|
131
|
+
settlement.value;
|
|
132
|
+
const terminateInstanceMessage = `governed contract ${logLabel} terminated by terminate-governed-instance`;
|
|
133
|
+
await E(instanceAdminFacet).terminateContract(
|
|
134
|
+
harden(Error(terminateInstanceMessage)),
|
|
135
|
+
);
|
|
136
|
+
trace('terminated governed instance');
|
|
137
|
+
|
|
138
|
+
const terminateGovernorMessage = `governor ${logLabel} terminated by terminate-governed-instance`;
|
|
139
|
+
await E(governorAdminFacet).terminateContract(
|
|
140
|
+
harden(Error(terminateGovernorMessage)),
|
|
141
|
+
);
|
|
142
|
+
trace('terminated governor');
|
|
143
|
+
}),
|
|
144
|
+
);
|
|
145
|
+
const terminationProblems = targets.flatMap(
|
|
146
|
+
({ boardID, instanceKitLabel }, i) => {
|
|
147
|
+
if (terminationResults[i].status === 'fulfilled') return [];
|
|
148
|
+
return [
|
|
149
|
+
{ boardID, instanceKitLabel, error: terminationResults[i].reason },
|
|
150
|
+
];
|
|
151
|
+
},
|
|
152
|
+
);
|
|
153
|
+
if (terminationProblems.length !== 0) {
|
|
154
|
+
console.error(
|
|
155
|
+
'terminate-governed-instance termination(s) failed',
|
|
156
|
+
terminationProblems,
|
|
157
|
+
);
|
|
158
|
+
Fail`termination(s) failed: ${terminationProblems}`;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
harden(terminateGoverned);
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Return a manifest for terminating one or more governed contract instances and
|
|
165
|
+
* their governors.
|
|
166
|
+
*
|
|
167
|
+
* @param {object} _powers
|
|
168
|
+
* @param {string[]} targetSpecifiers
|
|
169
|
+
*/
|
|
170
|
+
export const getManifest = (_powers, targetSpecifiers) => {
|
|
171
|
+
parseTargets(targetSpecifiers);
|
|
172
|
+
return {
|
|
173
|
+
manifest: {
|
|
174
|
+
[terminateGoverned.name]: {
|
|
175
|
+
consume: { board: true, governedContractKits: true, zoe: true },
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
// Provide `terminateGovernors` a second argument like
|
|
179
|
+
// `{ options: { targetSpecifiers } }`.
|
|
180
|
+
options: { targetSpecifiers },
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */
|
|
185
|
+
export const defaultProposalBuilder = async (_utils, targetSpecifiers) => {
|
|
186
|
+
parseTargets(targetSpecifiers);
|
|
187
|
+
|
|
188
|
+
// Dynamic import to avoid inclusion in the proposal bundle.
|
|
189
|
+
const { getSpecifier } = await import('@agoric/internal/src/module-utils.js');
|
|
190
|
+
const SELF = await getSpecifier(import.meta.url);
|
|
191
|
+
|
|
192
|
+
return harden({
|
|
193
|
+
sourceSpec: SELF,
|
|
194
|
+
getManifestCall: ['getManifest', targetSpecifiers],
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */
|
|
199
|
+
export default async (homeP, endowments) => {
|
|
200
|
+
const { scriptArgs } = endowments;
|
|
201
|
+
parseTargets(scriptArgs, makeUsageError);
|
|
202
|
+
|
|
203
|
+
// Dynamic import to avoid inclusion in the proposal bundle.
|
|
204
|
+
const { makeHelpers } = await import('@agoric/deploy-script-support');
|
|
205
|
+
const { writeCoreEval } = await makeHelpers(homeP, endowments);
|
|
206
|
+
await writeCoreEval(terminateGoverned.name, utils =>
|
|
207
|
+
defaultProposalBuilder(utils, scriptArgs),
|
|
208
|
+
);
|
|
209
|
+
};
|