Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling provableAPI.sol with Truffle yields 43 MB of JSON #95

Open
zippoxer opened this issue Jul 13, 2019 · 6 comments
Open

Compiling provableAPI.sol with Truffle yields 43 MB of JSON #95

zippoxer opened this issue Jul 13, 2019 · 6 comments

Comments

@zippoxer
Copy link

zippoxer commented Jul 13, 2019

Issue

Compiling provableAPI.sol yields 43 MB of JSON (6 files weighing ~7mb each).

Implications

For those of us who love Ganache, those huge JSON files cause Ganache UI to freeze as it tries to parse the compiled contracts, making it completely unusable.

I really want to work with Provable, but I can't ;-(

Reproduce

  1. Unbox truffle-starter
  2. Run truffle compile
  3. See these 6 fat JSON files in the build/contracts directory:
7.2M    build/contracts/Buffer.json
7.2M    build/contracts/CBOR.json
7.2M    build/contracts/OracleAddrResolverI.json
7.2M    build/contracts/ProvableI.json
7.2M    build/contracts/solcChecker.json
7.2M    build/contracts/usingProvable.json

This bloat can be attributed to the AST and legacyAST attributes, which contain the same 7 million bytes in each of the 6 JSON files.

My Environment

  • Truffle v5.0.27
  • Windows 10 64-bit

Note: Successfully reproduced in WSL (Ubuntu).


Is there another way to compile the Provable contract without getting this bloat?

@zippoxer zippoxer changed the title Compiling provableAPI.sol yields 43 MB of JSON Compiling provableAPI.sol with Truffle yields 43 MB of JSON Jul 15, 2019
@D-Nice
Copy link
Contributor

D-Nice commented Jul 17, 2019

Thanks for this report. We generally had used ganache cli / truffle so this was never an apparent issue to us. We'll probably have to discuss with the team working on the ganache UI if this is something they can rectify, as I don't know the likelihood of us being able to compress parts in the API without providing something akin to a lightweight version of it.

@cliffhall
Copy link

cliffhall commented Jul 18, 2019

Verified with truffle on Mac that it does generate all those fat ABIs. However you only deploy usingProvable.sol and your own contracts AFAIK.

Example:

const contracts = [
  artifacts.require('./EthPrice.sol'),
  artifacts.require('./usingProvable')
]

module.exports = deployer =>
  contracts.map(contract =>
    deployer.deploy(contract))

Still it's monster. It would be, IMHO, better to split the functionality up like Open Zeppelin so that a person can pick and choose the bits they need and not have to deploy (and pay gas for) that monolithic contract.

@gskapka
Copy link
Collaborator

gskapka commented Jul 19, 2019

Compiling provableAPI.sol yields 43 MB of JSON (6 files weighing ~7mb each).
those huge JSON files cause Ganache UI to freeze

@zippoxer These are Truffle Artifacts and are something over which we have no control. The awesome guys over at Truffle are aware of this issue and are working on it. You can track it via this issue here.

 


 

that monolithic contract.

@cliffhall Whilst the provableAPI.sol may indeed appear large, notice that the vast majority of it are function overloads of the myriad query types. Notice too that said vast majority are private functions, which means only those functions you inherit in your own contract get compiled. This means that you're deploying only what your contract uses.

@cliffhall
Copy link

@gskapka Thanks for the speedy response. I verified that it's not actually necessary to deploy the usingProvable contract as is done in the TruffleStarter demo. And in that case, the EthPrice.json abi is only 109kb. So it seems we can safely disregard these ABI artifacts.

@zippoxer
Copy link
Author

@cliffhall IIRC even if you don't deploy it, you import it in EthPrice.json, so those heavy artifacts are still in the build/contracts directory, which cripples Ganache. Is it not your experience?

@cliffhall
Copy link

cliffhall commented Jul 19, 2019

@zippoxer EthPrice.json is only 109kb. The artifacts are generated, true, but you could probably make a watcher process that deletes them with gulp or something if you're concerned about that. I was only concerned that I didn't have to actually deploy (and pay gas for) a 7MB contract :)

But no, it doesn't cause ganache any worries, because the artifacts are never deployed. EthPrice.json actually has all the stuff in it from the library that it uses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants