The SSZ schema is defined as a series of types needed to represent the Code trie. After defining these types, the schema is processed by FastSSZ in order to generate all the data needed to create the tree, generate and verify proofs, this process generates Go source code in the types_encoding.go file.


path: codetrie/ssz/types.go


CodeTrie is the type created to represent the code tree:

type CodeTrie struct {
	Metadata *Metadata
	Chunks   []*Chunk `ssz-max:"1024"`

The code trie consists in some Metadata and the code Chunks.


The metadata will store the Version, CodeHash and total CodeLength, according to the EIP

type Metadata struct {
	Version    uint8
	CodeHash   Hash `ssz-size:"32"`
	CodeLength uint16


The Hash used in the Matadata's CodeHash is defined as a byte array.

type Hash []byte


Each Chunk contains a FIO, which corresponds to the First Instruction Offset (i.e. not part of a PUSH* opcode's input).

The Chunk type also contains an array of byte code up to 32 bytes each.

type Chunk struct {
	FIO  uint8
	Code []byte `ssz-size:"32"` // Last chunk is right-padded with zeros