solady
solady copied to clipboard
📝 Plan for `CLZ` opcode
In the future, when the CLZ opcode https://eips.ethereum.org/EIPS/eip-7939 is added, many algorithms in Solady can be drastically improved upon.
Libraries such as LibBit, LibBytes, LibString, FixedPointMathLib, LibZip can see a dramatic speedup.
CLZ can be the highest impact improvement to accelerate the EVM for the next 2 years:
- More so than transient storage (can be substituted with using warm slots).
- More so than PUSH0 (can be substituted with other 2 gas opcodes).
-
LibZip.cdCompresswill be more widely used to pack storage automatically. This usesCLZrepeatedly.
To enable maximum support and backwards compatibility:
- Once the
CLZopcode appears on mainnet, the corresponding library will be in thefuturedirectory (e.g.utils/future). - Let's also take the opportunity to introduce stuff like
MCOPY(e.g. for insertion sort). - When most L2s have the
CLZopcode, we may decide to move the libraries fromfutureinto the actual directory. Then, the nonCLZlibraries will be moved into thelegacydirectory.