Open dckc opened 9 months ago
Once it's moved out of Zoe package it will be a much lighter import https://github.com/Agoric/agoric-sdk/issues/7392
Meanwhile, one can copy the files locally, https://github.com/Agoric/agoric-sdk/blob/6cf29fb78e1dd862d8d93d7ed74772d3c2172039/packages/zoe/src/contractSupport/atomicTransfer.js
It looks like my node_modules
set-up is confusing the endo bundler.
unzip -l game1.zip >contents-sm
unzip -l game1big.zip >contents-lg
diff -ur contents-sm contents-lg >contents.diff
agoric install
gives 1.5MB bundleIf I use agoric install
rather than installing from npm with yarn
, I get a 1.5MB bundle (1532045 bytes) -- 1.1MB in .zip form.
@migueldingli1997 re https://github.com/Agoric/agoric-sdk/issues/7501#issuecomment-1865906516
I suspect you're running into this issue.
If you have steps to reproduce, perhaps file an issue in https://github.com/Agoric/dapp-offer-up/issues ?
@migueldingli1997 re #7501 (comment)
I suspect you're running into this issue.
If you have steps to reproduce, perhaps file an issue in https://github.com/Agoric/dapp-offer-up/issues ?
Thanks @dckc, this might be the same issue. I will try to come up with some steps to reproduce it.
Update (2024-01-03): Reproduced
any clues, @kriskowal ? @mhofman ? @michaelfig ?
I tried carefully syncing up package versions with agoric-upgrade-13:
https://github.com/agoric-labs/dapp-swaparoo/tree/dc-versions-13 7de95b9
But the symptoms persist:
In discussion with @kriskowal , I learned:
The many copies in the bundle of, for example, @endo/promise-kit
mirror many copies in the node_modules
directories.
So the solution is to wrestle with yarn to Don't Do That.
Yes, I suspect we need to have agoric-cli capture the versions of endo packages the corresponding sdk expects, and provide a tool to force those endo package versions as "resolutions"
in a dapp. That way a single version of endo packages would appear, avoiding eval twins.
@turadg asked why all these resolutions are necessary and suggested npx yarn-deduplicate
; I just tried it in dapp-agoric-basics and it seems to be working... to some extent... it builds bundles that are small enough to meet RPC request size constraints, but they're still significantly larger than with resolutions.
@kriskowal reminds me to run yarn install
after deduplicate.
~/projects/dapp-agoric-basics/contract$ yarn test test/test-build-proposal.js
yarn run v1.22.22
$ ava --verbose test/test-build-proposal.js
bundles bundle-postal-service.js valid: 190 files bundled at 2024-03-12T21:17:54.579Z with size 1621137
bundles bundle-sell-concert-tickets.js valid: 201 files bundled at 2024-03-12T21:17:50.819Z with size 1682649
bundles bundle-swaparoo.js valid: 218 files bundled at 2024-03-12T21:17:52.751Z with size 1801021
✔ bundles from build:deployer meet 1MB request limit (548ms)
ℹ {
bundleName: 'postal-service',
compressedSize: '0.401 MB',
originallySize: '1.546 MB',
}
ℹ {
bundleName: 'sell-concert-tickets',
compressedSize: '0.415 MB',
originallySize: '1.605 MB',
}
ℹ {
bundleName: 'swaparoo',
compressedSize: '0.447 MB',
originallySize: '1.718 MB',
}
~/projects/dapp-agoric-basics/contract$ git log10
2024-03-12 16:23 7c31b49 build: lock de-duplicated packages
2024-03-12 16:22 87576f1 build: punt resolutions in favor of yarn-deduplicate
$ git log10
2024-03-12 16:15 9bc9eb9 build: ses vs cannot delete... WIP
~/projects/dapp-agoric-basics/contract$ yarn test test/test-build-proposal.js
yarn run v1.22.22
$ ava --verbose test/test-build-proposal.js
bundles bundle-postal-service.js valid: 130 files bundled at 2024-03-12T21:25:49.390Z
bundles bundle-sell-concert-tickets.js valid: 141 files bundled at 2024-03-12T21:25:47.262Z
bundles bundle-swaparoo.js valid: 158 files bundled at 2024-03-12T21:25:48.458Z
✔ bundles from build:deployer meet 1MB request limit (4s)
ℹ {
bundleName: 'postal-service',
compressedSize: '0.277 MB',
originallySize: '1.064 MB',
}
ℹ {
bundleName: 'sell-concert-tickets',
compressedSize: '0.291 MB',
originallySize: '1.123 MB',
}
ℹ {
bundleName: 'swaparoo',
compressedSize: '0.322 MB',
originallySize: '1.236 MB',
}
@dckc try npx yarn-deduplicate --strategy fewer
to optimize for fewer. Then if there are still duplicates, that means there are non-overlapping ranges. resolutions
is necessary to override the ranges the packages specify, but you'll have a lot fewer than before.
I think we can close this issue if we document the strategies for reducing duplication through attentive use of the package manager, somewhere likely to be found. Any thoughts on where that would be? Maybe we can refer to an existing blog on dependency duplication strategies or create our own.
I think we can close this issue if we document the strategies for reducing duplication through attentive use of the package manager, somewhere likely to be found. Any thoughts on where that would be?
https://github.com/Agoric/agoric-sdk/discussions is often a good place to start.
The time when it's most relevant is when adding or updating dependencies to dapps, which falls under CONTRIBUTING, so:
https://github.com/Agoric/dapp-agoric-basics/blob/main/CONTRIBUTING.md https://github.com/Agoric/dapp-offer-up/blob/main/CONTRIBUTING.md
Then we should probably cover it in the docs site, somewhere near https://docs.agoric.com/guides/getting-started/tutorial-dapp-agoric-basics.html ; so an issue in https://github.com/Agoric/documentation/issues to track that seems in order.
To Reproduce
Steps to reproduce the behavior:
zcf.reallocate
yarn bundle-source
to bundle it. Get a 1.7MB bundle. Compressed, it's well under a 1MB threshold that RPC servers use when acceptingagd tx swingset install-bundle
transactions.import { atomicRearrange } from '@agoric/zoe/src/contractSupport/atomicTransfer.js';
https://github.com/agoric-labs/dapp-game-places/commit/fd2b5e79d799feedfdbc910acc6a03eefe382406Bundle is now 4.8MB. Compressed, it's over 1MB, and
agd tx swingset install-bundle
fails:Expected behavior
Using
atomicRearrange
should add a few Kb or so.Platform Environment
Ubuntu Linux 22.04. Node v18.17.1
I installed the SDK from npm using
yarn
in a dapp, not by checking it out.git describe --tags --always
)Relevant dependencies:
https://github.com/agoric-labs/dapp-game-places/blob/b22d43df5c43e104da706f834f2cf5bb5ac0f598/contract/package.json#L51-L57
Additional context