agoric 0.21.2-upgrade-16-dev-8879538.0 → 0.21.2-upgrade-16-dev-24665a9.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",
3
- "version": "0.21.2-upgrade-16-dev-8879538.0+8879538",
3
+ "version": "0.21.2-upgrade-16-dev-24665a9.0+24665a9",
4
4
  "description": "Manage the Agoric Javascript smart contract platform",
5
5
  "type": "module",
6
6
  "main": "src/main.js",
@@ -29,29 +29,29 @@
29
29
  "lint:eslint": "eslint ."
30
30
  },
31
31
  "devDependencies": {
32
- "@agoric/cosmic-swingset": "0.41.4-upgrade-16-dev-8879538.0+8879538",
33
- "@agoric/deploy-script-support": "0.10.4-upgrade-16-dev-8879538.0+8879538",
32
+ "@agoric/cosmic-swingset": "0.41.4-upgrade-16-dev-24665a9.0+24665a9",
33
+ "@agoric/deploy-script-support": "0.10.4-upgrade-16-dev-24665a9.0+24665a9",
34
34
  "ava": "^5.3.0",
35
35
  "c8": "^9.1.0",
36
36
  "dd-trace": "^4.11.1"
37
37
  },
38
38
  "dependencies": {
39
- "@agoric/access-token": "0.4.22-upgrade-16-dev-8879538.0+8879538",
40
- "@agoric/assert": "0.6.1-upgrade-16-dev-8879538.0+8879538",
41
- "@agoric/cache": "0.3.3-upgrade-16-dev-8879538.0+8879538",
42
- "@agoric/casting": "0.4.3-upgrade-16-dev-8879538.0+8879538",
43
- "@agoric/cosmic-proto": "0.4.1-upgrade-16-dev-8879538.0+8879538",
44
- "@agoric/ertp": "0.16.3-upgrade-16-dev-8879538.0+8879538",
45
- "@agoric/governance": "0.10.4-upgrade-16-dev-8879538.0+8879538",
46
- "@agoric/inter-protocol": "0.16.2-upgrade-16-dev-8879538.0+8879538",
47
- "@agoric/internal": "0.3.3-upgrade-16-dev-8879538.0+8879538",
48
- "@agoric/network": "0.1.1-upgrade-16-dev-8879538.0+8879538",
49
- "@agoric/smart-wallet": "0.5.4-upgrade-16-dev-8879538.0+8879538",
50
- "@agoric/store": "0.9.3-upgrade-16-dev-8879538.0+8879538",
51
- "@agoric/swingset-vat": "0.32.3-upgrade-16-dev-8879538.0+8879538",
52
- "@agoric/vats": "0.15.2-upgrade-16-dev-8879538.0+8879538",
53
- "@agoric/zoe": "0.26.3-upgrade-16-dev-8879538.0+8879538",
54
- "@agoric/zone": "0.2.3-upgrade-16-dev-8879538.0+8879538",
39
+ "@agoric/access-token": "0.4.22-upgrade-16-dev-24665a9.0+24665a9",
40
+ "@agoric/assert": "0.6.1-upgrade-16-dev-24665a9.0+24665a9",
41
+ "@agoric/cache": "0.3.3-upgrade-16-dev-24665a9.0+24665a9",
42
+ "@agoric/casting": "0.4.3-upgrade-16-dev-24665a9.0+24665a9",
43
+ "@agoric/cosmic-proto": "0.4.1-upgrade-16-dev-24665a9.0+24665a9",
44
+ "@agoric/ertp": "0.16.3-upgrade-16-dev-24665a9.0+24665a9",
45
+ "@agoric/governance": "0.10.4-upgrade-16-dev-24665a9.0+24665a9",
46
+ "@agoric/inter-protocol": "0.16.2-upgrade-16-dev-24665a9.0+24665a9",
47
+ "@agoric/internal": "0.3.3-upgrade-16-dev-24665a9.0+24665a9",
48
+ "@agoric/network": "0.1.1-upgrade-16-dev-24665a9.0+24665a9",
49
+ "@agoric/smart-wallet": "0.5.4-upgrade-16-dev-24665a9.0+24665a9",
50
+ "@agoric/store": "0.9.3-upgrade-16-dev-24665a9.0+24665a9",
51
+ "@agoric/swingset-vat": "0.32.3-upgrade-16-dev-24665a9.0+24665a9",
52
+ "@agoric/vats": "0.15.2-upgrade-16-dev-24665a9.0+24665a9",
53
+ "@agoric/zoe": "0.26.3-upgrade-16-dev-24665a9.0+24665a9",
54
+ "@agoric/zone": "0.2.3-upgrade-16-dev-24665a9.0+24665a9",
55
55
  "@confio/relayer": "^0.11.3",
56
56
  "@cosmjs/crypto": "^0.32.3",
57
57
  "@cosmjs/encoding": "^0.32.3",
@@ -68,6 +68,7 @@
68
68
  "@endo/nat": "^5.0.7",
69
69
  "@endo/patterns": "^1.4.0",
70
70
  "@endo/promise-kit": "^1.1.2",
71
+ "@endo/zip": "^1.0.5",
71
72
  "@iarna/toml": "^2.2.3",
72
73
  "anylogger": "^0.21.0",
73
74
  "chalk": "^5.2.0",
@@ -100,5 +101,5 @@
100
101
  "typeCoverage": {
101
102
  "atLeast": 76.99
102
103
  },
103
- "gitHead": "8879538cd1d125a08346f02dd5701d0d70c90bb8"
104
+ "gitHead": "24665a97248b854fcb01185d360429301470ed57"
104
105
  }
@@ -0,0 +1,102 @@
1
+ // @ts-check
2
+
3
+ /* global Buffer */
4
+
5
+ import assert from 'node:assert/strict';
6
+ import fs from 'node:fs';
7
+ import { join } from 'node:path';
8
+
9
+ import { ZipReader } from '@endo/zip';
10
+
11
+ /** @import {Bundle} from '@agoric/swingset-vat'; */
12
+ /** @import {CoreEvalPlan} from '@agoric/deploy-script-support/src/writeCoreEvalParts.js' */
13
+
14
+ const PACKAGE_NAME_RE = /(?<packageName>.*-v[\d.]+)\//;
15
+
16
+ /**
17
+ * @typedef {{ name: string, label: string, location: string, modules: Record<string, {compartment: string, module: string}>}} Compartment
18
+ */
19
+
20
+ /**
21
+ * @typedef CompartmentMap
22
+ * @property {string[]} tags
23
+ * @property {{compartment: string, module: string}} entry
24
+ * @property {Record<string, Compartment>} compartments
25
+ */
26
+
27
+ /** @param {Bundle} bundleObj*/
28
+ export const extractBundleInfo = async bundleObj => {
29
+ if (bundleObj.moduleFormat !== 'endoZipBase64') {
30
+ throw new Error('only endoZipBase64 is supported');
31
+ }
32
+
33
+ const contents = Buffer.from(bundleObj.endoZipBase64, 'base64');
34
+
35
+ const zipReader = new ZipReader(contents);
36
+ const { files } = zipReader;
37
+
38
+ const cmapEntry = files.get('compartment-map.json');
39
+ /** @type {CompartmentMap} */
40
+ const compartmentMap = JSON.parse(Buffer.from(cmapEntry.content).toString());
41
+
42
+ // XXX mapIter better but requires SES
43
+ const fileSizes = Object.fromEntries(
44
+ Array.from(files.values()).map(f => [
45
+ f.name,
46
+ // bundle contents are not compressed
47
+ f.content.length,
48
+ ]),
49
+ );
50
+
51
+ return { compartmentMap, fileSizes };
52
+ };
53
+
54
+ // UNTIL https://github.com/endojs/endo/issues/1656
55
+ /** @param {string} bundleFilename */
56
+ export const statBundle = async bundleFilename => {
57
+ const bundle = fs.readFileSync(bundleFilename, 'utf8');
58
+ /** @type {Bundle} */
59
+ const bundleObj = JSON.parse(bundle);
60
+ console.log('\nBUNDLE', bundleObj.moduleFormat, bundleFilename);
61
+
62
+ const info = await extractBundleInfo(bundleObj);
63
+ assert(info, 'no bundle info');
64
+
65
+ /** @type {Record<string, number>} */
66
+ const byPackage = {};
67
+ let totalSize = 0;
68
+ for (const [filename, size] of Object.entries(info.fileSizes)) {
69
+ totalSize += size;
70
+ if (filename === 'compartment-map.json') {
71
+ continue;
72
+ }
73
+ const { packageName } = filename.match(PACKAGE_NAME_RE)?.groups ?? {};
74
+ assert(packageName, `invalid filename ${filename}`);
75
+ byPackage[packageName] ||= 0;
76
+ byPackage[packageName] += size;
77
+ }
78
+
79
+ console.log('Sum of file sizes in each package:');
80
+ console.table(byPackage);
81
+
82
+ console.log('total size:', totalSize);
83
+ console.log('\nTo explore the contents:\n');
84
+ console.log(
85
+ ` DIR=$(mktemp -d); cat ${bundleFilename} | jq -r .endoZipBase64 | base64 -d | tar xC $DIR; open $DIR`,
86
+ );
87
+ };
88
+
89
+ /** @param {string} path */
90
+ export const statPlans = async path => {
91
+ const files = await fs.promises.readdir(path);
92
+ const planfiles = files.filter(f => f.endsWith('plan.json'));
93
+
94
+ for (const planfile of planfiles) {
95
+ /** @type {CoreEvalPlan} */
96
+ const plan = JSON.parse(fs.readFileSync(join(path, planfile), 'utf8'));
97
+ console.log('\n**\nPLAN', plan.name);
98
+ for (const bundle of plan.bundles) {
99
+ await statBundle(bundle.fileName);
100
+ }
101
+ }
102
+ };
package/src/main.js CHANGED
@@ -1,23 +1,24 @@
1
1
  /* global process */
2
- import { Command } from 'commander';
3
- import path from 'path';
4
- import url from 'url';
5
2
  import { assert, details as X } from '@agoric/assert';
6
3
  import {
7
- DEFAULT_KEEP_POLLING_SECONDS,
8
4
  DEFAULT_JITTER_SECONDS,
5
+ DEFAULT_KEEP_POLLING_SECONDS,
9
6
  } from '@agoric/casting';
7
+ import { Command } from 'commander';
8
+ import path from 'path';
9
+ import url from 'url';
10
+ import { makeWalletCommand } from './commands/wallet.js';
10
11
  import cosmosMain from './cosmos.js';
11
12
  import deployMain from './deploy.js';
12
- import runMain from './run.js';
13
- import publishMain from './main-publish.js';
13
+ import followMain from './follow.js';
14
14
  import initMain from './init.js';
15
15
  import installMain from './install.js';
16
+ import { statPlans } from './lib/bundles.js';
17
+ import publishMain from './main-publish.js';
18
+ import walletMain from './open.js';
19
+ import runMain from './run.js';
16
20
  import setDefaultsMain from './set-defaults.js';
17
21
  import startMain from './start.js';
18
- import followMain from './follow.js';
19
- import walletMain from './open.js';
20
- import { makeWalletCommand } from './commands/wallet.js';
21
22
 
22
23
  const DEFAULT_DAPP_TEMPLATE = 'dapp-offer-up';
23
24
  const DEFAULT_DAPP_URL_BASE = 'https://github.com/Agoric/';
@@ -46,6 +47,7 @@ const main = async (progname, rawArgs, powers) => {
46
47
  return true;
47
48
  }
48
49
 
50
+ // XXX exits process when fn resolves
49
51
  function subMain(fn, args, options) {
50
52
  return fn(progname, args, powers, options).then(
51
53
  // This seems to be the only way to propagate the exit code.
@@ -280,29 +282,6 @@ const main = async (progname, rawArgs, powers) => {
280
282
  return subMain(followMain, ['follow', ...pathSpecs], opts);
281
283
  });
282
284
 
283
- const addRunOptions = cmd =>
284
- cmd
285
- .option(
286
- '--allow-unsafe-plugins',
287
- `CAREFUL: installed Agoric VM plugins will also have all your user's privileges`,
288
- false,
289
- )
290
- .option(
291
- '--hostport <host:port>',
292
- 'host and port to connect to VM',
293
- '127.0.0.1:8000',
294
- )
295
- .option(
296
- '--need <subsystems>',
297
- 'comma-separated names of subsystems to wait for',
298
- 'local,agoric,wallet',
299
- )
300
- .option(
301
- '--provide <subsystems>',
302
- 'comma-separated names of subsystems this script initializes',
303
- '',
304
- );
305
-
306
285
  baseCmd('run <script> [script-args...]')
307
286
  .description(
308
287
  'run a script with all your user privileges and some Agoric endowments',
@@ -310,23 +289,46 @@ const main = async (progname, rawArgs, powers) => {
310
289
  .passThroughOptions(true)
311
290
  .action(async (script, scriptArgs, _options, cmd) => {
312
291
  const opts = { ...program.opts(), ...cmd.opts(), ...cmdOpts, scriptArgs };
313
- return subMain(runMain, ['run', script], opts);
292
+ await runMain(progname, ['run', script], powers, opts);
293
+
294
+ if (opts.verbose) {
295
+ await statPlans(process.cwd());
296
+ }
314
297
  });
315
298
 
316
- addRunOptions(
317
- baseCmd('deploy [script...]')
318
- .option(
319
- '--target <target>',
320
- 'One of agoric, local, cosmos, or sim',
321
- 'agoric',
322
- )
323
- .description(
324
- 'run multiple scripts with all your user privileges against the local Agoric VM',
325
- ),
326
- ).action(async (scripts, _options, cmd) => {
327
- const opts = { ...program.opts(), ...cmd.opts() };
328
- return subMain(deployMain, ['deploy', ...scripts], opts);
329
- });
299
+ baseCmd('deploy [script...]')
300
+ .option(
301
+ '--target <target>',
302
+ 'One of agoric, local, cosmos, or sim',
303
+ 'agoric',
304
+ )
305
+ .option(
306
+ '--allow-unsafe-plugins',
307
+ `CAREFUL: installed Agoric VM plugins will also have all your user's privileges`,
308
+ false,
309
+ )
310
+ .option(
311
+ '--hostport <host:port>',
312
+ 'host and port to connect to VM',
313
+ '127.0.0.1:8000',
314
+ )
315
+ .option(
316
+ '--need <subsystems>',
317
+ 'comma-separated names of subsystems to wait for',
318
+ 'local,agoric,wallet',
319
+ )
320
+ .option(
321
+ '--provide <subsystems>',
322
+ 'comma-separated names of subsystems this script initializes',
323
+ '',
324
+ )
325
+ .description(
326
+ 'run multiple scripts with all your user privileges against the local Agoric VM',
327
+ )
328
+ .action(async (scripts, _options, cmd) => {
329
+ const opts = { ...program.opts(), ...cmd.opts() };
330
+ return subMain(deployMain, ['deploy', ...scripts], opts);
331
+ });
330
332
 
331
333
  baseCmd('publish [bundle...]')
332
334
  .option(