what is compression?

State Compression is the method of creating a “fingerprint” (or hash) of off-chain data and storing this fingerprint on-chain for secure verification. Effectively using the security of the Solana ledger to securely validate off-chain data, verifying it has not been tampered with.

  • uses cheap blockchain ledger space instead of expensive account space to store data
  • uses binary tree structure known as concurrent merkle tree to create a hash of each piece of data ( called a leaf ), hashing those together and only storing the final hash onchain

concurrent merkle tree

  • allows multiple changes to any given tree to happen, while still maintaining the integrity and validity of the tree
  • retains a changelog of the tree onchain, allowing for multiple rapid changes to the same tree before a proof is invalidated
  • allows upto maxBufferSize changes to the same tree in SAME slot

not the same as file compression

3 params to create a merkle tree:

  • maxDepth
  • maxBufferSize
  • canopyDepth

nodes_count = 2 ^ maxDepth The higher the max depth, the higher the cost The larger the canopy depth value, the higher the cost Smaller canopy limits composability