Skip to content

Commit

Permalink
9900 elide comments in bundles (#9997)
Browse files Browse the repository at this point in the history
refs: #9900

## Description
This uses the new `--elide-comments` option in Endo bundle-source to… elide comments. Always.

Measured with:
```
cd a3p-integration
rm -f **/b1-*.json*
yarn build:submissions
du -csh **/b1-*.json
gzip **/b1-*.json
du -csh **/b1-*.json.gz
```

Before: 26M (6.7M gz)
After: 19M (4.1M gz)


### Security Considerations
No change in runtime. Does affect code auditability. Existing bundles are base64 encoded so readers will have to find the sources anyway. Either way we will need to invest in special tooling: endojs/endo#1656

### Scaling Considerations
reduces on-chain storage

### Documentation Considerations
End users who base64 decode the on-chain bundles will no longer see comments… I don't expect anyone was doing this.

### Testing Considerations
existing coverage

### Upgrade Considerations
won't affect any existing deployments
  • Loading branch information
mergify[bot] authored Aug 31, 2024
2 parents 17c73b7 + 9e15cb4 commit f6011d0
Show file tree
Hide file tree
Showing 32 changed files with 184 additions and 720 deletions.
11 changes: 0 additions & 11 deletions multichain-testing/scripts/update-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@ sed -i -e 's/index_all_keys = false/index_all_keys = true/g' $CHAIN_DIR/config/c
sed -i -e 's/seeds = ".*"/seeds = ""/g' $CHAIN_DIR/config/config.toml
sed -i -e 's#cors_allowed_origins = \[\]#cors_allowed_origins = \["*"\]#g' $CHAIN_DIR/config/config.toml

echo "Increase $(*_bytes) parameters for MsgInstallBundle"
# See https://github.com/Agoric/agoric-sdk/blob/7b684a6268c999b082a326fdb22f63e4575bac4f/packages/agoric-cli/src/chain-config.js#L66
RPC_MAX_BODY_BYTES=15000000
MAX_HEADER_BYTES=$((RPC_MAX_BODY_BYTES / 10))
MAX_TXS_BYTES=$((RPC_MAX_BODY_BYTES * 50))
sed -i -e "s/max_body_bytes = .*/max_body_bytes = $RPC_MAX_BODY_BYTES/g" $CHAIN_DIR/config/config.toml
sed -i -e "s/max_header_bytes = .*/max_header_bytes = $MAX_HEADER_BYTES/g" $CHAIN_DIR/config/config.toml
sed -i -e "s/max_txs_bytes = .*/max_txs_bytes = $MAX_TXS_BYTES/g" $CHAIN_DIR/config/config.toml
sed -i -e "s/max_tx_bytes = .*/max_tx_bytes = $RPC_MAX_BODY_BYTES/g" $CHAIN_DIR/config/config.toml
sed -i -e "s/^rpc-max-body-bytes =.*/rpc-max-body-bytes = $RPC_MAX_BODY_BYTES/" $CHAIN_DIR/config/app.toml

echo "Update client.toml file"
sed -i -e 's#keyring-backend = "os"#keyring-backend = "test"#g' $CHAIN_DIR/config/client.toml
sed -i -e 's#output = "text"#output = "json"#g' $CHAIN_DIR/config/client.toml
Expand Down
2 changes: 1 addition & 1 deletion packages/ERTP/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"devDependencies": {
"@agoric/swingset-vat": "^0.32.2",
"@endo/bundle-source": "^3.3.0",
"@endo/bundle-source": "^3.4.0",
"@fast-check/ava": "^1.1.5",
"ava": "^5.3.0",
"tsd": "^0.31.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/SwingSet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@agoric/xsnap": "^0.14.2",
"@agoric/xsnap-lockdown": "^0.14.0",
"@endo/base64": "^1.0.6",
"@endo/bundle-source": "^3.3.0",
"@endo/bundle-source": "^3.4.0",
"@endo/captp": "^4.2.2",
"@endo/check-bundle": "^1.0.8",
"@endo/compartment-mapper": "^1.2.1",
Expand Down
4 changes: 3 additions & 1 deletion packages/SwingSet/src/devices/vat-admin/device-vat-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,16 @@ bundleID before submitting to the kernel), or (temporarily) a full bundle.
* @typedef { string } VatID
* @typedef { string } UpgradeID
* @typedef {{
* changeOptions: (vatID: string, options: {}) => void;
* createMeter: (remaining: bigint, threshold: bigint) => MeterID
* createUnlimitedMeter: () => MeterID
* addMeterRemaining: (meterID: MeterID, delta: bigint) => void
* setMeterThreshold: (meterID: MeterID, threshold: bigint) => void
* getMeter: (meterID: MeterID) => { remaining: bigint, threshold: bigint }
* createByBundle: (bundle: Bundle, options: {}) => VatID
* createByBundleID: (bundleID: BundleID, options: {}) => VatID
* upgradeVat: (bundleID: BundleID, vatParameters: {}) => UpgradeID
* getBundleIDByName: (name: string) => string;
* upgradeVat: (vatID: string, bundleID: BundleID, _vatParameters: unknown, upgradeMessage: string) => UpgradeID;
* terminateWithFailure: (vatID: VatID, reason: {}) => void
* getBundleCap: (bundleID: BundleID) => BundleCap
* getNamedBundleCap: (name: string) => BundleCap
Expand Down
24 changes: 21 additions & 3 deletions packages/SwingSet/src/vats/vat-admin/vat-vat-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,38 @@ import {
prepareSingleton,
} from '@agoric/vat-data';

/**
* @import {VatAdminRootDeviceNode} from '../../devices/vat-admin/device-vat-admin.js';
* @import {DProxy} from'../plugin-manager.js';
* @import {Baggage} from '@agoric/vat-data';
*/

const managerTypes = ['local', 'node-subprocess', 'xsnap', 'xs-worker']; // xs-worker is alias

function producePRR() {
const { promise, resolve, reject } = makePromiseKit();
return /** @type {const} */ ([promise, { resolve, reject }]);
}

/**
* Build root object of the bootstrap vat.
*
* @param {VatPowers & {
* D: DProxy;
* }} vatPowers
* @param {never} _vatParameters
* @param {Baggage} baggage
*/
export function buildRootObject(vatPowers, _vatParameters, baggage) {
const criticalVatKey = prepareSingleton(baggage, 'criticalVatKey', {});

const { D } = vatPowers;
const pendingVatCreations = new Map(); // vatID -> { resolve, reject } for promise
const pendingBundles = new Map(); // bundleID -> Promise<BundleCap>
/** @type {Map<BundleID, PromiseKit<BundleCap>>} */
const pendingBundles = new Map();
const pendingUpgrades = new Map(); // upgradeID -> Promise<UpgradeResults>

/** @type {import('../plugin-manager.js').Device<VatAdminRootDeviceNode>} */
let vatAdminDev;

const runningVats = new Map(); // vatID -> [doneP, { resolve, reject }]
Expand Down Expand Up @@ -200,7 +217,7 @@ export function buildRootObject(vatPowers, _vatParameters, baggage) {
console.log(`bundle ${bundleID} missing, hoping for reinstall`);
return;
}
pendingBundles.get(bundleID).resolve(bundlecap);
pendingBundles.get(bundleID)?.resolve(bundlecap);
pendingBundles.delete(bundleID);
checkForQuiescence();
}
Expand Down Expand Up @@ -418,8 +435,9 @@ export function buildRootObject(vatPowers, _vatParameters, baggage) {
if (!pendingBundles.has(bundleID)) {
pendingBundles.set(bundleID, makePromiseKit());
}
return pendingBundles.get(bundleID).promise;
return pendingBundles.get(bundleID)?.promise;
},
/** @type {(bundleID: BundleID) => BundleCap} */
getBundleCap(bundleID) {
const bundlecap = D(vatAdminDev).getBundleCap(bundleID);
if (bundlecap) {
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@cosmjs/math": "^0.32.3",
"@cosmjs/proto-signing": "^0.32.3",
"@cosmjs/stargate": "^0.32.3",
"@endo/bundle-source": "^3.3.0",
"@endo/bundle-source": "^3.4.0",
"@endo/captp": "^4.2.2",
"@endo/compartment-mapper": "^1.2.1",
"@endo/env-options": "^1.1.5",
Expand Down
13 changes: 11 additions & 2 deletions packages/agoric-cli/src/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,17 @@ export { bootPlugin } from ${JSON.stringify(absPath)};

const allEndowments = harden({
home: bootP,
bundleSource: (file, options = undefined) =>
bundleSource(pathResolve(file), options),
/**
* @template {import('@endo/bundle-source').ModuleFormat} ModuleFormat
* @param {string} file
* @param {import('@endo/bundle-source').BundleOptions<ModuleFormat>} options
* @returns {Promise<import('@endo/bundle-source').BundleSourceResult<ModuleFormat>>}
*/
bundleSource: (file, options = {}) =>
bundleSource(pathResolve(file), {
elideComments: true,
...options,
}),
...endowments,
pathResolve,
installUnsafePlugin,
Expand Down
2 changes: 1 addition & 1 deletion packages/boot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@agoric/vow": "^0.1.0",
"@agoric/zoe": "^0.26.2",
"@agoric/zone": "^0.2.2",
"@endo/bundle-source": "^3.3.0",
"@endo/bundle-source": "^3.4.0",
"@endo/captp": "^4.2.2",
"@endo/eventual-send": "^1.2.4",
"@endo/far": "^1.1.4",
Expand Down
169 changes: 0 additions & 169 deletions packages/boot/test/bootstrapTests/addAssets.test.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/builders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@agoric/vat-data": "^0.5.2",
"@agoric/vats": "^0.15.1",
"@agoric/zoe": "^0.26.2",
"@endo/bundle-source": "^3.3.0",
"@endo/bundle-source": "^3.4.0",
"@endo/captp": "^4.2.2",
"@endo/eventual-send": "^1.2.4",
"@endo/far": "^1.1.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-proto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"@agoric/cosmos": "^0.34.1",
"@ava/typescript": "^4.1.0",
"@cosmology/telescope": "^1.7.1",
"@endo/bundle-source": "^3.3.0",
"@endo/bundle-source": "^3.4.0",
"@endo/import-bundle": "^1.2.1",
"ava": "^5.3.1",
"rimraf": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@agoric/swingset-vat": "^0.32.2",
"@agoric/telemetry": "^0.6.2",
"@agoric/vm-config": "^0.1.0",
"@endo/bundle-source": "^3.3.0",
"@endo/bundle-source": "^3.4.0",
"@endo/env-options": "^1.1.5",
"@endo/far": "^1.1.4",
"@endo/import-bundle": "^1.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-dapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"c8": "^9.1.0"
},
"dependencies": {
"agoric": "^0.22.0-u16.2"
"agoric": "^0.21.1"
},
"keywords": [],
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/deploy-script-support/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@agoric/time": "^0.3.2",
"@agoric/zoe": "^0.26.2",
"@endo/base64": "^1.0.6",
"@endo/bundle-source": "^3.3.0",
"@endo/bundle-source": "^3.4.0",
"@endo/far": "^1.1.4",
"@endo/marshal": "^1.5.2",
"@endo/nat": "^5.0.9",
Expand Down
4 changes: 2 additions & 2 deletions packages/governance/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@agoric/time": "^0.3.2",
"@agoric/vat-data": "^0.5.2",
"@agoric/zoe": "^0.26.2",
"@endo/bundle-source": "^3.3.0",
"@endo/bundle-source": "^3.4.0",
"@endo/captp": "^4.2.2",
"@endo/eventual-send": "^1.2.4",
"@endo/far": "^1.1.4",
Expand All @@ -50,7 +50,7 @@
},
"devDependencies": {
"@agoric/swingset-vat": "^0.32.2",
"@endo/bundle-source": "^3.3.0",
"@endo/bundle-source": "^3.4.0",
"@endo/init": "^1.1.3",
"ava": "^5.3.0",
"c8": "^9.1.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/inter-protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@agoric/swingset-liveslots": "^0.10.2",
"@agoric/swingset-vat": "^0.32.2",
"@agoric/zone": "^0.2.2",
"@endo/bundle-source": "^3.3.0",
"@endo/bundle-source": "^3.4.0",
"@endo/init": "^1.1.3",
"@endo/promise-kit": "^1.1.4",
"@fast-check/ava": "^1.1.5",
Expand Down
Loading

0 comments on commit f6011d0

Please sign in to comment.