1

Does Ethereum have a package manager that is hosted on chain to mitigate code duplication? I've been learning Solidity development in brownie and as per my understanding in the brownie-config.yaml you can add dependencies such as OpenZeppelin or Chainlink which reference open source GitHub repositories such that you can import interfaces or contracts defined in .sol scripts, and when brownie compile is executed the ABI, etc which is deployed to Ethereum includes the compiled dependencies and not references to those dependencies. Which would in my mind indicate that there's a ton of duplicate bytecode for essentially the same code being stored on Ethereum.

Is this in fact what is going on behind the scenes or is there some intelligent handling that allows for the EVM to attach references to contract/interfaces and not duplicate code?

1 Answer 1

1

Yes, that's exactly what is happening. There are some limited reuse mechanisms, like libraries in Solidity but they are not very popular in that use case because external calls are expensive. It's usually much cheaper to have the relevant code compiled into your own contract and the only incentive to use a library is to split your contract into smaller parts when you hit the bytecode size limit (~24 kB).

There were some early ideas to provide a library auto-reuse mechanism as a Solidity compiler feature but so far nothing came out of it.

Currently package management on Ethereum is mostly off-chain. While for example EthPM does support providing references to deployed contracts from a package, most real-life projects I've seen pull dependencies from github, npm or some other language language-specific package manager that just makes the source available locally.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.