# Introduction The `e2store` (extension: `.e2s`) is a simple linear [TLV](https://en.wikipedia.org/wiki/Type-length-value) file for storing arbitrary items typically encoded using serialization techniques used in ethereum 2 in general: SSZ, varint, snappy. # General structure `e2s` files consist of repeated type-length-value records. Each record is variable-length, and unknown records can easily be skipped. In particular, `e2s` files are designed to: * allow trivial implementations that are easy to audit * allow append-only implementations * allow future record types to be added, such as when the chain forks The type and length are encoded in an 8-byte header which is directly followed by data. ``` record = header | data header = type | length type = Vector[byte, 2] length = Vector[byte, 6] ``` The `length` is the first 6 bytes of a little-endian encoded `uint64`, not including the header itself. For example, the entry with header type `[0x22, 0x32]`, the length `4` and the bytes `[0x01, 0x02, 0x03, 0x04]` will be stored as the byte sequence `[0x22, 0x32, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04]`. `.e2s` files may freely be concatenated, and may contain out-of-order records. Types that have the high bit in the first byte set (those in the range `[0x80-0xff]`) are application and/or vendor specific. ## Reading The following python code can be used to read an e2 file: ```python import sys, struct with open(sys.argv[1], "rb") as f: header = f.read(8) typ = header[0:2] # First 2 bytes for type if typ != b"e2": raise RuntimeError("this is not an e2store file") while True: header = f.read(8) # Header is 8 bytes if not header: break typ = header[0:2] # First 2 bytes for type dlen = struct.unpack("--.era` with era and count hex-encoded to 8 digits. An `.era` file is structured in the following way: ``` era := group+ group := canonical-state | blocks* ``` The `canonical-state` is the state of the slot that immediately follows the end of the era without applying blocks from the next era. For example, for the era that covers the first 8192 slots will have all blocks applied up to slot 8191 and will `process_slots` up to 8192. The genesis group contains only the genesis state but no blocks. Era files place the state first for a number of reasons: the state is then guaranteed to contain all public keys and block roots needed to verify the blocks in the file. A special case is the genesis era file - this file contains only the genesis state.