Skip to content

Commit

Permalink
Merge pull request #36 from Agoric/ta/shrink-bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg authored Sep 7, 2024
2 parents 9fef737 + 72c7c3a commit 486f4eb
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 11 deletions.
2 changes: 1 addition & 1 deletion contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"@agoric/vow": "dev",
"@agoric/zoe": "dev",
"@agoric/zone": "dev",
"@endo/bundle-source": "^3.3.0",
"@endo/bundle-source": "^3.4.0",
"@endo/errors": "^1.2.4",
"@endo/far": "^1.1.4",
"@endo/init": "^1.1.3",
Expand Down
10 changes: 7 additions & 3 deletions contract/test/build-proposal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const MB = 1024 * 1024;

const MAINNET_MAX_MB = 0.5;

const trace = (...msgs) => console.log('[build-proposal.test]', ...msgs);

test.before(async t => {
const bundleCache = await makeNodeBundleCache('bundles', {}, s => import(s));

Expand All @@ -20,7 +22,10 @@ test.before(async t => {
* @param {string} name of an _already cached_ bundle
*/
const compressBundle = async name => {
const bundle = await bundleCache.load('', name);
// NOTE load options must match those used in the proposal builder
const bundle = await bundleCache.load('', name, trace, {
elideComments: true,
});
const fileContents = JSON.stringify(bundle);
const buffer = Buffer.from(fileContents, 'utf-8');
const compressed = await promisify(gzip)(buffer);
Expand Down Expand Up @@ -53,8 +58,7 @@ test.before(async t => {
t.context = { compressBundle, $, runPackageScript, listBundles };
});

// Will not fit on Mainnet, but that's okay for current purposes
test.failing('bundles small enough for Mainnet', async t => {
test('bundles small enough for Mainnet', async t => {
// @ts-expect-error ses-ava types
const { runPackageScript, listBundles, compressBundle } = t.context;
await runPackageScript('build:deployer');
Expand Down
17 changes: 11 additions & 6 deletions contract/tools/rollup-plugin-core-eval.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import '@endo/init';
import { makeNodeBundleCache } from '@endo/bundle-source/cache.js';

const trace = (...msgs) => console.log('[rollup-plugin-core-eval]', ...msgs);

export const coreEvalGlobals = {
E: 'E',
Far: 'Far',
Expand Down Expand Up @@ -48,20 +50,23 @@ export const configureBundleID = ({ name, rootModule, cache }) => {
return {
name: 'configureBundleID',
transform: async (code, _id) => {
trace('transform', name, code, _id);
// passes in code
const bundle = await bundleCacheP.then(c => c.load(rootModule, name));
console.log(bundle.endoZipBase64Sha512);
console.log('rootModule: ', rootModule);
console.log('name: ', name);
const bundle = await bundleCacheP.then(c =>
c.load(rootModule, name, trace, { elideComments: true }),
);
trace(bundle.endoZipBase64Sha512);
trace('rootModule: ', rootModule);
trace('name: ', name);
const test = JSON.stringify(`z${bundle.endoZipBase64Sha512}`);
console.log(test);
trace(test);
const revised = code.replace(
pattern,
`bundleID = ${JSON.stringify(`b1-${bundle.endoZipBase64Sha512}`)}`,
// test,
// () => `b1-${test}`
);
console.log('revised === code:', revised === code);
trace('revised === code:', revised === code);
if (revised === code) return null;
return { code: revised };
},
Expand Down
143 changes: 142 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4192,6 +4192,13 @@ __metadata:
languageName: node
linkType: hard

"@endo/base64@npm:^1.0.7":
version: 1.0.7
resolution: "@endo/base64@npm:1.0.7"
checksum: 10c0/aab10f433f8ea588ebd1786188b6660c0be3a743c119ef2df52ee23afd4ce3844b1d954028952569a747f6657287aeced875afe8e136ea8bff4ba146a60578bd
languageName: node
linkType: hard

"@endo/bundle-source@npm:^2.5.1":
version: 2.8.0
resolution: "@endo/bundle-source@npm:2.8.0"
Expand Down Expand Up @@ -4237,6 +4244,27 @@ __metadata:
languageName: node
linkType: hard

"@endo/bundle-source@npm:^3.4.0":
version: 3.4.0
resolution: "@endo/bundle-source@npm:3.4.0"
dependencies:
"@endo/base64": "npm:^1.0.7"
"@endo/compartment-mapper": "npm:^1.2.2"
"@endo/evasive-transform": "npm:^1.3.0"
"@endo/init": "npm:^1.1.4"
"@endo/promise-kit": "npm:^1.1.5"
"@endo/where": "npm:^1.0.7"
"@rollup/plugin-commonjs": "npm:^19.0.0"
"@rollup/plugin-json": "npm:^6.1.0"
"@rollup/plugin-node-resolve": "npm:^13.0.0"
acorn: "npm:^8.2.4"
rollup: "npm:^2.79.1"
bin:
bundle-source: ./src/tool.js
checksum: 10c0/c21ee24b7beaf4e9b935c853f6917e42f2c22250697c02ceea97288cb142d8ba863491fd934c49c337a14cf94960d9edde84eb91355c679d27d303e89d429a46
languageName: node
linkType: hard

"@endo/captp@npm:^3.1.1":
version: 3.1.5
resolution: "@endo/captp@npm:3.1.5"
Expand Down Expand Up @@ -4297,6 +4325,13 @@ __metadata:
languageName: node
linkType: hard

"@endo/cjs-module-analyzer@npm:^1.0.7":
version: 1.0.7
resolution: "@endo/cjs-module-analyzer@npm:1.0.7"
checksum: 10c0/b7f93776dc83e44a3b346479efcd8749488ce1591aae4cefc832ec4280834cc8577d322bfb3ecdc7120dd2aa99509cb6ef1ac680b2dba4a4863483624a920ba6
languageName: node
linkType: hard

"@endo/common@npm:^1.2.2, @endo/common@npm:^1.2.4":
version: 1.2.4
resolution: "@endo/common@npm:1.2.4"
Expand Down Expand Up @@ -4344,6 +4379,18 @@ __metadata:
languageName: node
linkType: hard

"@endo/compartment-mapper@npm:^1.2.2":
version: 1.2.2
resolution: "@endo/compartment-mapper@npm:1.2.2"
dependencies:
"@endo/cjs-module-analyzer": "npm:^1.0.7"
"@endo/module-source": "npm:^1.0.2"
"@endo/zip": "npm:^1.0.7"
ses: "npm:^1.8.0"
checksum: 10c0/e16d6b19dbc273e72bb33e05b9fbcc7df38d8d43bc56b2e0af62b72d724d4a530468b81c1418163c54a4dff2645f5a04b58d1c3bc9e37845bbce959d651dece0
languageName: node
linkType: hard

"@endo/env-options@npm:^0.1.4":
version: 0.1.4
resolution: "@endo/env-options@npm:0.1.4"
Expand All @@ -4358,6 +4405,13 @@ __metadata:
languageName: node
linkType: hard

"@endo/env-options@npm:^1.1.6":
version: 1.1.6
resolution: "@endo/env-options@npm:1.1.6"
checksum: 10c0/0001b1cba6954cccfa40104f819378f2f5c8babc89103213a8a5da4f8f94248c8389bfa06ec37cecae81edabe570428558399313d649c64ad7c90743f563dea2
languageName: node
linkType: hard

"@endo/errors@npm:^1.2.2, @endo/errors@npm:^1.2.3, @endo/errors@npm:^1.2.4":
version: 1.2.4
resolution: "@endo/errors@npm:1.2.4"
Expand Down Expand Up @@ -4392,6 +4446,18 @@ __metadata:
languageName: node
linkType: hard

"@endo/evasive-transform@npm:^1.3.0":
version: 1.3.0
resolution: "@endo/evasive-transform@npm:1.3.0"
dependencies:
"@agoric/babel-generator": "npm:^7.17.6"
"@babel/parser": "npm:^7.23.6"
"@babel/traverse": "npm:^7.23.6"
source-map-js: "npm:^1.2.0"
checksum: 10c0/caca5f99423f4dcd57bce5fe8dc197019bfcaca657929016b1e91a6d4efe7a6d73e8b7c16cff83f56c03b035ca16e08565996a3459d30a65a83b632ef7d8d0a3
languageName: node
linkType: hard

"@endo/eventual-send@npm:0.17.2":
version: 0.17.2
resolution: "@endo/eventual-send@npm:0.17.2"
Expand All @@ -4417,6 +4483,15 @@ __metadata:
languageName: node
linkType: hard

"@endo/eventual-send@npm:^1.2.5":
version: 1.2.5
resolution: "@endo/eventual-send@npm:1.2.5"
dependencies:
"@endo/env-options": "npm:^1.1.6"
checksum: 10c0/7eaa30628582f768920659e4894b871c1056da4252b82b8ad70ed49a24c4559efb8d1655a6845984a0eae83d328179e4272b0917007a2f147dc8b15ecb0ecc52
languageName: node
linkType: hard

"@endo/exo@npm:^0.2.2":
version: 0.2.6
resolution: "@endo/exo@npm:0.2.6"
Expand Down Expand Up @@ -4544,6 +4619,18 @@ __metadata:
languageName: node
linkType: hard

"@endo/init@npm:^1.1.4":
version: 1.1.4
resolution: "@endo/init@npm:1.1.4"
dependencies:
"@endo/base64": "npm:^1.0.7"
"@endo/eventual-send": "npm:^1.2.5"
"@endo/lockdown": "npm:^1.0.10"
"@endo/promise-kit": "npm:^1.1.5"
checksum: 10c0/9e915b3b888b7a9f1d563d532ad180dea987253d71e79eda1fcda8d287391611bcca369f2d9b89c59b9f24b3adc548816954e8eaefa4f7402c68585245a686a5
languageName: node
linkType: hard

"@endo/lockdown@npm:0.1.28":
version: 0.1.28
resolution: "@endo/lockdown@npm:0.1.28"
Expand All @@ -4562,6 +4649,15 @@ __metadata:
languageName: node
linkType: hard

"@endo/lockdown@npm:^1.0.10":
version: 1.0.10
resolution: "@endo/lockdown@npm:1.0.10"
dependencies:
ses: "npm:^1.8.0"
checksum: 10c0/94be0c1b14cacb2d8088dcc17998e901159a028c51170d78a8cc6a820ae76cabc7d2694f1a1956cb4eab70a8c9a0c8254d88ea4c3f3d9725b739aacf6db83d5b
languageName: node
linkType: hard

"@endo/lockdown@npm:^1.0.7, @endo/lockdown@npm:^1.0.8, @endo/lockdown@npm:^1.0.9":
version: 1.0.9
resolution: "@endo/lockdown@npm:1.0.9"
Expand Down Expand Up @@ -4622,6 +4718,19 @@ __metadata:
languageName: node
linkType: hard

"@endo/module-source@npm:^1.0.2":
version: 1.0.2
resolution: "@endo/module-source@npm:1.0.2"
dependencies:
"@agoric/babel-generator": "npm:^7.17.6"
"@babel/parser": "npm:^7.23.6"
"@babel/traverse": "npm:^7.23.6"
"@babel/types": "npm:^7.24.0"
ses: "npm:^1.8.0"
checksum: 10c0/137b8b798c854a024074c2e7c62eef8663b21cc96e3faab94a9836a57ba13224a21d2116c7da187d060a701f7dc7a3b15f540181576d54afafc287f430ad6c23
languageName: node
linkType: hard

"@endo/nat@npm:4.1.27":
version: 4.1.27
resolution: "@endo/nat@npm:4.1.27"
Expand Down Expand Up @@ -4751,6 +4860,15 @@ __metadata:
languageName: node
linkType: hard

"@endo/promise-kit@npm:^1.1.5":
version: 1.1.5
resolution: "@endo/promise-kit@npm:1.1.5"
dependencies:
ses: "npm:^1.8.0"
checksum: 10c0/3a9fb59546507dbbb8c83ada4de664ca4f6085ffcb56c9e3e07789e002e717454b1ee5ae1273549935a7e77ac42be7ae8ddca94ff6d4f16914210d31159ce1a4
languageName: node
linkType: hard

"@endo/ses-ava@npm:^1.2.2, @endo/ses-ava@npm:^1.2.4":
version: 1.2.4
resolution: "@endo/ses-ava@npm:1.2.4"
Expand Down Expand Up @@ -4860,6 +4978,13 @@ __metadata:
languageName: node
linkType: hard

"@endo/where@npm:^1.0.7":
version: 1.0.7
resolution: "@endo/where@npm:1.0.7"
checksum: 10c0/a76306e670074b43c15a223e4118c500ad03851586516d6a0204d5d865e3b8eda161a86b54de503efe11aa70c04d7adbd9e5185a905c3a1a953a757f680d6a68
languageName: node
linkType: hard

"@endo/zip@npm:^0.2.31, @endo/zip@npm:^0.2.32, @endo/zip@npm:^0.2.35":
version: 0.2.35
resolution: "@endo/zip@npm:0.2.35"
Expand All @@ -4874,6 +4999,13 @@ __metadata:
languageName: node
linkType: hard

"@endo/zip@npm:^1.0.7":
version: 1.0.7
resolution: "@endo/zip@npm:1.0.7"
checksum: 10c0/a1c0d155448ce877012b34c8fe8cd3a58de9eb807514c81cddeebb802ee8e552b27d8a9a40fab3f3e4c49e0cb7fea6902fa1dd12a23ff6f30b56161fc3edc1f8
languageName: node
linkType: hard

"@es-joy/jsdoccomment@npm:~0.46.0":
version: 0.46.0
resolution: "@es-joy/jsdoccomment@npm:0.46.0"
Expand Down Expand Up @@ -13832,7 +13964,7 @@ __metadata:
"@agoric/zone": "npm:^0.2.2"
"@cosmjs/amino": "npm:^0.32.3"
"@cosmjs/proto-signing": "npm:^0.32.3"
"@endo/bundle-source": "npm:^3.3.0"
"@endo/bundle-source": "npm:^3.4.0"
"@endo/errors": "npm:^1.2.4"
"@endo/eslint-plugin": "npm:^2.2.0"
"@endo/far": "npm:^1.1.4"
Expand Down Expand Up @@ -20544,6 +20676,15 @@ __metadata:
languageName: node
linkType: hard

"ses@npm:^1.8.0":
version: 1.8.0
resolution: "ses@npm:1.8.0"
dependencies:
"@endo/env-options": "npm:^1.1.6"
checksum: 10c0/4b2114e586a547dd2a71477e0a42e8ea5d0ea9c3ff135d0dbfb63569eeda19c7152db76b82bcad12a2969d3f5fb09e5fa52e921b5a2831560e6876ca1f9ba207
languageName: node
linkType: hard

"set-blocking@npm:^2.0.0":
version: 2.0.0
resolution: "set-blocking@npm:2.0.0"
Expand Down

0 comments on commit 486f4eb

Please sign in to comment.