Skip to content

A WAL block is 4096 bytes, sealed whole. It carries up to 4048 bytes of payload and ends with the 32-byte seal trailer.

offset 0 offset 4096 gen u32 used u16 first u16 stream_off u64 payload, 4048 B used bytes of records, then zeros trailer 32 B 4 B 2 B 2 B 8 B 4048 B tag, nonce, key id Header: 16 bytes, encrypted together with the payload. Trailer: 32 bytes, the seal (tag, epoch, counter, data key id). AAD = "wal" || segment id || block index. The block is valid only if the generation equals the epoch in its own nonce.
The 16-byte header, the 4048-byte payload and the 32-byte seal trailer.
Offset Size Type Meaning
0 4 u32 LE generation, the keyring epoch at write time
4 2 u16 LE used, payload bytes in this block, at most 4048
6 2 u16 LE first_record, offset within the payload of the first record that starts in this block, or 0xFFFF if none
8 8 u64 LE stream_offset, the logical stream offset of payload byte 0
16 4048 bytes payload (used bytes), zero-filled
4064 32 bytes seal trailer
WAL block, 4096 bytes
  1. generation4 B
  2. used2 B
  3. first_record2 B
  4. stream_offset8 B
  5. payload4048 B
  6. trailer32 B

The AAD is "wal" ‖ segment ‖ block index, see AAD per object.

A block is valid if and only if all of these hold:

  • it is not all-zero,
  • it authenticates,
  • generation equals the epoch in its own nonce (SPEC V64),
  • used is at most 4048,
  • first_record is 0xFFFF or less than used.