Working tree is now the canonical repo. Off-chain play-money + trustless on-chain (FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution, mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2.1 KiB
2.1 KiB
LibZip
Library for compressing and decompressing bytes.
Note:
The accompanying solady.js library includes implementations of FastLZ and calldata operations for convenience.
Fast LZ Operations
LZ77 implementation based on FastLZ.
Equivalent to level 1 compression and decompression at the following commit:
344eb4025f
Decompression is backwards compatible.
flzCompress(bytes)
function flzCompress(bytes memory data)
internal
pure
returns (bytes memory result)
Returns the compressed data.
flzDecompress(bytes)
function flzDecompress(bytes memory data)
internal
pure
returns (bytes memory result)
Returns the decompressed data.
Calldata Operations
Calldata compression and decompression using selective run length encoding:
- Sequences of 0x00 (up to 128 consecutive).
- Sequences of 0xff (up to 32 consecutive).
A run length encoded block consists of two bytes:
(0) 0x00
(1) A control byte with the following bit layout: - [7]
0: 0x00, 1: 0xff. - [0..6]
runLength - 1.
The first 4 bytes are bitwise negated so that the compressed calldata
can be dispatched into thefallbackandreceivefunctions.
cdCompress(bytes)
function cdCompress(bytes memory data)
internal
pure
returns (bytes memory result)
Returns the compressed data.
cdDecompress(bytes)
function cdDecompress(bytes memory data)
internal
pure
returns (bytes memory result)
Returns the decompressed data.
cdFallback()
function cdFallback() internal
To be called in the fallback function.
fallback() external payable { LibZip.cdFallback(); }
receive() external payable {}
Silence compiler warning to add a `receive` function.
For efficiency, this function will directly return the results, terminating the context.
If called internally, it must be called at the end of the function.