Uniswap / v4-core

🦄 🦄 🦄 🦄 Core smart contracts of Uniswap v4
https://blog.uniswap.org/uniswap-v4
2.01k stars 972 forks source link

[Bug]: PoolManager.sol over bytecode limit #200

Closed zhongeric closed 8 months ago

zhongeric commented 1 year ago

Describe the bug

Warning: Contract code size is 26070 bytes and exceeds 24576 bytes (a limit introduced in Spurious Dragon). This contract may not be deployable on Mainnet. Consider enabling the optimizer (with a low "runs" value!), turning off revert strings, or using libraries.
  --> contracts/PoolManager.sol:24:1:
   |
24 | contract PoolManager is IPoolManager, Owned, NoDelegateCall, ERC1155, IERC1155Receiver {
   | ^ (Relevant source part starts here and spans across multiple lines).

Expected Behavior

No response

To Reproduce

git checkout main && yarn snapshots

Additional context

No response

kcmcrypto commented 1 year ago

I tried all possible optimizer settings combinations and the most I could compress was down to about 25674. I tried Yul, viaIR, not Yul, not viaIR and lot of strings for YulStepsSequence... But I've been so excited about uni v4 that I couldn't wait until team addressed this. So I cloned https://github.com/ethereum/go-ethereum and in https://github.com/ethereum/go-ethereum/blob/master/params/protocol_params.go#L127 I forked my own testnet with amplified contract code size...

As has been said, this code is not frozen and is waiting fro some updates like flash storage. At the same time there is a new optimizer setting which is not still stable (I tried it and it hanged my terminal every time)... not stable yet. I think whenever that features emerge, we will have a version for this code that will fit in 24576B

Until then, good look hacking and building ethereum from source...

beihaili commented 1 year ago

same problem

nzhl commented 1 year ago

Try converting all internal functions in Pool.sol to external/public as a temporary workaround. This change will make the Pool library compiled as a standalone library instead of being inlined into PoolManager, hence greatly reduces the size limit for PoolManager

snreynolds commented 1 year ago

Tagging this as part of ongoing exploration into decreasing bytecode