Skip to main content
netspecsEthereum networking

1.8.Snappy wire compression

Stage
Current
Validity
Active non-fork protocol.
Sources
3 pinned sources

Snappy compresses the message payloads of both Ethereum planes. The execution wire frames each message with it; the consensus wire wraps SSZ objects in snappy framing.

Execution wire

After the Hello exchange, every eth-protocol message is compressed with Snappy. The wire frame is msg-id || snappyCompress(msg-data). A receiver decodes the message ID and decompresses the payload; the snappy format carries a length, so the uncompressed size is known before decompression. EIP-706 added Snappy message compression to the RLPx protocol stack.

Consensus wire

Consensus Req/Resp protocols use the ssz_snappy encoding strategy: objects are SSZ-encoded, then compressed with Snappy. The strategy uses snappy framing, the streaming format, rather than the block format, so large requests and response chunks stream frame by frame; a snappy frame's contents have a maximum size of 65536 bytes.

The length prefix is the raw SSZ byte length encoded as an unsigned protobuf varint, written before the compressed stream and using at most 10 bytes. Writers compute and write the SSZ length, then stream the payload through a buffered snappy compressor. Readers decode the length, then stream the payload through a buffered snappy decompressor.