types

package
v1.24.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package types: per-slot bids object format (BIDS).

One object stores all execution payload bids of a single slot together with their gossip observations: which clients saw each bid and when. The object is self-sufficient (full bid fields, not just key tuples), so historic bid data could be served from the blockdb alone without the relational block_bids table. Clients are identified by name via a per-object client table, so objects stay decodable across client config changes. Per-bid observations are stored as a bitmask over the client table plus one first-seen offset (ms from slot start) per set bit.

Object layout:

HEADER (20 bytes)
├── Magic:       [4]byte = "BIDS"
├── Version:     uint16
├── Flags:       uint8   (reserved, 0)
├── Reserved:    uint8
├── Slot:        uint64
├── ClientCount: uint16
└── BidCount:    uint16
CLIENT TABLE: per client: uint8 name length + name bytes
BID RECORDS: per bid:
├── ParentRoot:   32 bytes
├── ParentHash:   32 bytes
├── BlockHash:    32 bytes
├── FeeRecipient: 20 bytes
├── BuilderIndex: uint64 (two's complement int64)
├── GasLimit:     uint64
├── Value:        uint64
├── ElPayment:    uint64
├── SeenMask:     ceil(ClientCount/8) bytes (bit i = client table index i)
└── SeenTimes:    int32 per set mask bit, in ascending client index order

Package types: per-epoch duties object format (DUTY).

One object stores the resolved attester committees and PTC (payload timeliness committee) duty mappings for a single finalized epoch, keyed by the epoch's first slot. The layout is deterministic: committee byte offsets are a pure function of the epoch's active-validator count, so a reader can address any (slot, committee) range without an index table.

Object layout:

HEADER (v1: 40 bytes, v2: 72 bytes)
├── Magic:             [4]byte = "DUTY"
├── Version:           uint16  (1 = legacy, 2 = adds DependentRoot + proposers)
├── Flags:             uint8   (bit 0 = DutiesFlagDiverging)
├── IndexWidth:        uint8   (bytes per validator index, = 6)
├── Epoch:             uint64
├── ValidatorCount:    uint64  (active validator count; drives attester offsets)
├── SlotsPerEpoch:     uint32
├── CommitteesPerSlot: uint32  (stored so the object reads without spec constants)
├── PtcSize:           uint32  (0 if pre-Gloas)
└── DependentRoot:     [32]byte (v2 only; committee-shuffling dependent root)
ATTESTER SECTION: ValidatorCount * IndexWidth bytes
│   flat list of global validator indices in (slotIndex, committeeIndex, position) order
PROPOSER SECTION: SlotsPerEpoch * IndexWidth bytes (v2 only; one proposer index per slot)
PTC SECTION: SlotsPerEpoch * PtcSize * IndexWidth bytes (omitted if PtcSize == 0)

Package types provides the per-block execution data binary format (DXTX).

The format stores events, call traces, state changes, and receipt metadata for all transactions in a block. Each section is independently snappy-compressed for efficient selective decompression.

Object layout:

OBJECT HEADER (40 bytes)
├── Magic:              [4]byte  = "DXTX"
├── Format Version:     uint16
├── Flags:              uint16   (reserved, 0)
├── Block Slot:         uint64
├── Block Number:       uint64
├── BlockMeta Section:  offset(8) + compLen(4) + uncompLen(4)
TX COUNT (4 bytes)
├── TX Count:           uint32
TX INDEX TABLE (100 bytes per tx)
For each TX:
├── TX Hash:            [32]byte
├── Sections Bitmap:    uint32   (0x01=ReceiptMeta, 0x02=Events, 0x04=CallTrace, 0x08=StateChanges)
├── ReceiptMeta Section: offset(8) + compLen(4) + uncompLen(4)
├── Events Section:     offset(8) + compLen(4) + uncompLen(4)
├── CallTrace Section:  offset(8) + compLen(4) + uncompLen(4)
└── StateChanges Section: offset(8) + compLen(4) + uncompLen(4)
DATA AREA
├── [BlockMeta section blob (snappy-compressed)]
├── [Per-TX snappy-compressed section blobs]

Code generated by dynamic-ssz. DO NOT EDIT. Hash: e3d1774fca5db9c355caeb23b8ffdaafe31f862babbbb051946a0d35ad37846d Version: v1.4.0-pre.2 (https://github.com/pk910/dynamic-ssz)

Index

Constants

View Source
const (
	// BidsFormatVersion is the current bids object format version.
	BidsFormatVersion uint16 = 1

	// BidsHeaderSize is the fixed header size for version 1.
	BidsHeaderSize = 20
)
View Source
const (
	// DutiesFormatVersion is the current duties object format version.
	DutiesFormatVersion uint16 = 2

	// DutiesHeaderSize is the fixed header size for version 1 (also the base
	// layout shared by v2). v2 appends a 32-byte dependent root.
	DutiesHeaderSize = 40

	// DutiesHeaderSizeV2 is the fixed header size for version 2 (v1 + 32-byte
	// dependent root).
	DutiesHeaderSizeV2 = 72

	// DutiesIndexWidth is the number of bytes used to encode a validator index.
	DutiesIndexWidth uint8 = 6

	// DutiesFlagDiverging marks a duties object that belongs to a non-canonical
	// (diverging) fork, keyed by its dependent root.
	DutiesFlagDiverging uint8 = 1
)
View Source
const (
	ExecDataFormatVersion = 1

	// Object header: 4 magic + 2 version + 2 flags + 8 slot + 8 blockNumber + 16 blockMeta ptr = 40
	ExecDataHeaderSize = 40

	// TX count field: 4 bytes
	ExecDataTxCountSize = 4

	// Per-TX index entry: 32 hash + 4 bitmap + 4*(8+4+4) sections = 100
	ExecDataTxEntrySize = 100

	// Section bitmap flags
	ExecDataSectionReceiptMeta = 0x01
	ExecDataSectionEvents      = 0x02
	ExecDataSectionCallTrace   = 0x04
	ExecDataSectionStateChange = 0x08
)
View Source
const (
	CallTypeCall         = 0
	CallTypeStaticCall   = 1
	CallTypeDelegateCall = 2
	CallTypeCreate       = 3
	CallTypeCreate2      = 4
	CallTypeSelfDestruct = 5
)

Call type constants matching the callTracer output.

View Source
const (
	CallStatusSuccess  = 0
	CallStatusReverted = 1
	CallStatusError    = 2
)

Call status constants for binary encoding.

View Source
const (
	StateChangeFlagBalanceChanged = 0x01
	StateChangeFlagNonceChanged   = 0x02
	StateChangeFlagCodeChanged    = 0x04
	StateChangeFlagStorageChanged = 0x08
	StateChangeFlagAccountCreated = 0x10 // exists only in post
	StateChangeFlagAccountKilled  = 0x20 // exists only in pre
)

State change flags per account (bitmask).

View Source
const (
	BlockReceiptMetaVersion1 = 1
)

Block receipt metadata version. Bump when adding new block-wide fields.

View Source
const (
	ReceiptMetaVersion1 = 1
)

Receipt metadata version. Bump when adding new fields.

View Source
const (
	StateChangesVersion1 = 1
)

State change section version.

View Source
const TxHashPrefixLen = 10

TxHashPrefixLen is the number of leading tx-hash bytes stored in the index. 10 bytes (80 bits) keeps collisions negligible (~1e-8 across ~160M txs) while using only ~1/3 of the full 32-byte hash. Candidates are always disambiguated against the full hash, so a collision is harmless.

Variables

View Source
var BidsMagic = [4]byte{'B', 'I', 'D', 'S'}

BidsMagic identifies a per-slot bids object.

View Source
var DutiesMagic = [4]byte{'D', 'U', 'T', 'Y'}

DutiesMagic identifies a duties object.

View Source
var ExecDataMagic = [4]byte{'D', 'X', 'T', 'X'}

Binary format constants

Functions

func BuildExecDataObject added in v1.20.3

func BuildExecDataObject(
	blockSlot uint64,
	blockNumber uint64,
	blockMeta []byte,
	blockMetaUncompLen uint32,
	txSections []ExecDataTxSectionData,
) []byte

BuildExecDataObject serializes a per-block execution data object. blockMeta is the pre-compressed block-level metadata section (nil if none). txSections contains pre-compressed section data for each transaction.

func DecodeIndexList added in v1.24.0

func DecodeIndexList(b []byte, width uint8) []uint64

DecodeIndexList decodes a tightly packed list of width-byte big-endian indices.

func DecodeSlotCommittees added in v1.24.0

func DecodeSlotCommittees(data []byte) ([][]uint64, error)

DecodeSlotCommittees decodes a blob produced by EncodeSlotCommittees.

func EncodeDutiesHeader added in v1.24.0

func EncodeDutiesHeader(d *EpochDuties) []byte

EncodeDutiesHeader returns the fixed-size DUTY header bytes for the epoch. The size depends on the format version: 40 bytes for v1, 72 bytes for v2 (which carries the dependent root and precedes a proposer section).

func EncodeEpochDuties added in v1.24.0

func EncodeEpochDuties(d *EpochDuties) ([]byte, error)

EncodeEpochDuties serializes the duties for an epoch into the DUTY object format.

func EncodeIndexList added in v1.24.0

func EncodeIndexList(indices []uint64) ([]byte, error)

EncodeIndexList serializes a list of validator indices as packed width-byte values.

func EncodeSlotBids added in v1.24.4

func EncodeSlotBids(s *SlotBids) ([]byte, error)

EncodeSlotBids packs a SlotBids into a single BIDS object.

func EncodeSlotCommittees added in v1.24.0

func EncodeSlotCommittees(committees [][]uint64) ([]byte, error)

EncodeSlotCommittees serializes a single slot's attester committees into a self-delimited blob (used by the Pebble backend's per-slot keys):

[committeeCount:2] then per committee [memberCount:4][packed indices]

func ExecDataIndexSize added in v1.20.3

func ExecDataIndexSize(txCount uint32) int

ExecDataIndexSize returns the size in bytes of the index (header + all TX entries) for a given number of transactions.

func ExecDataMinHeaderSize added in v1.20.3

func ExecDataMinHeaderSize() int

ExecDataMinHeaderSize returns the minimum bytes needed to read the TX count.

func ExtractSectionData added in v1.20.3

func ExtractSectionData(objectData []byte, txCount uint32, sectionOffset uint64, sectionCompLen uint32) ([]byte, error)

ExtractSectionData extracts a specific compressed section from raw object data. The offset is relative to the start of the DATA AREA (after the index). Returns nil if the section has zero length.

func HashPrefix added in v1.24.1

func HashPrefix(txHash []byte) []byte

HashPrefix returns a fresh TxHashPrefixLen-byte copy of the tx hash (never aliases the input). A short input is right-padded with zeroes.

func NewSeenObservations added in v1.24.4

func NewSeenObservations(seen map[int]int32, clientCount int) (mask []byte, times []int32)

NewSeenObservations builds SeenMask/SeenTimes from a map of client table index to first-seen offset, for a client table of the given size.

func ParseExecDataTxCount added in v1.20.3

func ParseExecDataTxCount(header []byte) (uint32, error)

ParseExecDataTxCount parses the minimum header bytes needed to extract the transaction count from an execution data object. This is intended for partial reads (e.g., S3 range reads) where only the first ExecDataMinHeaderSize bytes are available.

Types

type BlockData

type BlockData struct {
	// Header data
	HeaderVersion uint64
	HeaderData    []byte

	// Body data
	BodyVersion uint64
	BodyData    []byte
	Body        any // Parsed body (optional)

	// Execution payload data (ePBS)
	PayloadVersion uint64
	PayloadData    []byte
	Payload        any // Parsed payload (optional)

	// Block access list data
	BalVersion uint64
	BalData    []byte
}

BlockData contains all data components for a block.

type BlockDataFlags added in v1.21.0

type BlockDataFlags uint8

BlockDataFlags specifies which components to load from storage.

const (
	// BlockDataFlagHeader requests the block header data.
	BlockDataFlagHeader BlockDataFlags = 1 << iota // 0x01
	// BlockDataFlagBody requests the block body data.
	BlockDataFlagBody // 0x02
	// BlockDataFlagPayload requests the execution payload data.
	BlockDataFlagPayload // 0x04
	// BlockDataFlagBal requests the block access list data.
	BlockDataFlagBal // 0x08

	// BlockDataFlagAll requests all block components.
	BlockDataFlagAll = BlockDataFlagHeader | BlockDataFlagBody | BlockDataFlagPayload | BlockDataFlagBal
)

func StoredFlagsFromBlockData added in v1.22.0

func StoredFlagsFromBlockData(data *BlockData) BlockDataFlags

StoredFlagsFromBlockData returns which block components are present in data.

func (BlockDataFlags) Add added in v1.21.0

Add returns a new flag set with the specified flag added.

func (BlockDataFlags) Has added in v1.21.0

func (f BlockDataFlags) Has(flag BlockDataFlags) bool

Has returns true if the flag set contains the specified flag.

func (BlockDataFlags) HasAny added in v1.21.0

func (f BlockDataFlags) HasAny(flags BlockDataFlags) bool

HasAny returns true if the flag set contains any of the specified flags.

func (BlockDataFlags) Remove added in v1.21.0

Remove returns a new flag set with the specified flag removed.

type BlockDbEngine

type BlockDbEngine interface {
	// Close closes the database engine.
	Close() error

	// GetBlock retrieves block data with selective loading based on flags.
	// If parseBlock is nil, raw body data is stored in BlockData.BodyData.
	// If parsePayload is nil, raw payload data is stored in BlockData.PayloadData.
	GetBlock(
		ctx context.Context,
		slot uint64,
		root []byte,
		flags BlockDataFlags,
		parseBlock func(uint64, []byte) (any, error),
		parsePayload func(uint64, []byte) (any, error),
	) (*BlockData, error)

	// AddBlock stores block data. Returns:
	// - added: true if a new block was created
	// - updated: true if an existing block was updated with new components
	AddBlock(
		ctx context.Context,
		slot uint64,
		root []byte,
		dataCb func() (*BlockData, error),
	) (added bool, updated bool, err error)

	// GetStoredComponents returns which components exist for a block.
	GetStoredComponents(ctx context.Context, slot uint64, root []byte) (BlockDataFlags, error)
}

BlockDbEngine defines the interface for block database engines.

type BlockDbObjectStats added in v1.24.4

type BlockDbObjectStats struct {
	// BlockCount is the number of block header records (namespace ns1), which
	// includes both canonical and orphaned blocks (they share the namespace).
	BlockCount uint64
	// CanonicalDutiesCount is the number of canonical per-epoch duties objects.
	CanonicalDutiesCount uint64
	// DivergingDutiesCount is the number of diverging-fork duties objects.
	DivergingDutiesCount uint64
	// BidsCount is the number of per-slot bids objects (namespace ns7).
	BidsCount uint64
	// BidsBytes is the total encoded size of the bids objects, if available.
	BidsBytes uint64
}

BlockDbObjectStats holds engine-level object counts obtained by scanning the key namespaces. Only cheap-to-scan local (Pebble) engines populate it.

type BlockReceiptMeta added in v1.20.3

type BlockReceiptMeta struct {
	Version      uint16 // Schema version for forward compatibility
	BlobGasPrice uint64 // Block-wide blob gas price in wei (EIP-4844), 0 if not applicable
}

BlockReceiptMeta holds block-wide receipt metadata needed to reconstruct full receipts. Stored as a versioned section so new fields can be added without changing the DXTX format version.

func (*BlockReceiptMeta) HashTreeRoot added in v1.20.3

func (t *BlockReceiptMeta) HashTreeRoot() (root [32]byte, err error)

HashTreeRoot computes the SSZ hash tree root of the *BlockReceiptMeta.

func (*BlockReceiptMeta) HashTreeRootWith added in v1.20.3

func (t *BlockReceiptMeta) HashTreeRootWith(hh sszutils.HashWalker) error

HashTreeRootWith computes the SSZ hash tree root of the *BlockReceiptMeta using the given hash walker.

func (*BlockReceiptMeta) MarshalSSZ added in v1.20.3

func (t *BlockReceiptMeta) MarshalSSZ() ([]byte, error)

MarshalSSZ marshals the *BlockReceiptMeta to SSZ-encoded bytes.

func (*BlockReceiptMeta) MarshalSSZTo added in v1.20.3

func (t *BlockReceiptMeta) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo marshals the *BlockReceiptMeta to SSZ-encoded bytes, appending to the provided buffer.

func (*BlockReceiptMeta) SizeSSZ added in v1.20.3

func (t *BlockReceiptMeta) SizeSSZ() (size int)

SizeSSZ returns the SSZ encoded size of the *BlockReceiptMeta.

func (*BlockReceiptMeta) UnmarshalSSZ added in v1.20.3

func (t *BlockReceiptMeta) UnmarshalSSZ(buf []byte) (err error)

UnmarshalSSZ unmarshals the *BlockReceiptMeta from SSZ-encoded bytes.

type DutiesEngine added in v1.24.0

type DutiesEngine interface {
	// AddEpochDuties stores the resolved duties for an epoch.
	// Returns the stored size in bytes.
	AddEpochDuties(ctx context.Context, duties *EpochDuties) (int64, error)

	// GetEpochDuties retrieves the full resolved duties for an epoch.
	// Returns nil, nil if not found. Used for whole-epoch copies.
	GetEpochDuties(ctx context.Context, firstSlot uint64) (*EpochDuties, error)

	// AddDivergingEpochDuties stores the resolved duties of a diverging fork,
	// keyed additionally by duties.DependentRoot (which must be non-zero).
	// Returns the stored size in bytes.
	AddDivergingEpochDuties(ctx context.Context, duties *EpochDuties) (int64, error)

	// GetEpochDutiesForRoot retrieves the full diverging-fork duties for an epoch
	// under the given dependent root. Returns nil, nil if not found.
	GetEpochDutiesForRoot(ctx context.Context, firstSlot uint64, depRoot [32]byte) (*EpochDuties, error)

	// GetSlotCommitteesForRoot returns the attester committees for a single slot
	// of the diverging fork identified by depRoot. Returns nil, nil if not found.
	GetSlotCommitteesForRoot(ctx context.Context, firstSlot uint64, slot uint64, depRoot [32]byte) ([][]uint64, error)

	// GetSlotPtcForRoot returns the PTC members for a single slot of the
	// diverging fork identified by depRoot. Returns nil, nil if not found.
	GetSlotPtcForRoot(ctx context.Context, firstSlot uint64, slot uint64, depRoot [32]byte) ([]uint64, error)

	// GetSlotCommittees returns the attester committees for a single slot
	// (global validator indices, in committee order). firstSlot identifies the
	// epoch object. Returns nil, nil if not found.
	GetSlotCommittees(ctx context.Context, firstSlot uint64, slot uint64) ([][]uint64, error)

	// GetSlotPtc returns the PTC members for a single slot (global validator
	// indices). Returns nil, nil if not found or the epoch has no PTC.
	GetSlotPtc(ctx context.Context, firstSlot uint64, slot uint64) ([]uint64, error)

	// HasEpochDuties checks if duties exist for an epoch.
	HasEpochDuties(ctx context.Context, firstSlot uint64) (bool, error)

	// PruneEpochDutiesBefore deletes duties for all epochs whose first slot is
	// before maxFirstSlot. Returns the number of epochs deleted.
	PruneEpochDutiesBefore(ctx context.Context, maxFirstSlot uint64) (int64, error)
}

DutiesEngine stores the resolved attester committees and PTC duty mappings for a finalized epoch, keyed by the epoch's first slot.

type DutiesHeader added in v1.24.0

type DutiesHeader struct {
	Version           uint16
	Flags             uint8
	IndexWidth        uint8
	Epoch             uint64
	ValidatorCount    uint64
	SlotsPerEpoch     uint64
	CommitteesPerSlot uint64
	PtcSize           uint64
	// DependentRoot is the committee-shuffling dependent root. Non-zero only in
	// v2 (diverging-fork) objects; zero for v1 (canonical) objects.
	DependentRoot [32]byte
}

DutiesHeader is the decoded header of a duties object. Section offsets are derived, not stored.

func DecodeDutiesHeader added in v1.24.0

func DecodeDutiesHeader(b []byte) (*DutiesHeader, error)

DecodeDutiesHeader parses and validates a duties object header.

func (*DutiesHeader) AttesterSlotRange added in v1.24.0

func (h *DutiesHeader) AttesterSlotRange(slotIndex uint64) (offset int64, length int64)

AttesterSlotRange returns the byte (offset, length) spanning all committees of the given slot in the attester section.

func (*DutiesHeader) ProposerSectionRange added in v1.24.4

func (h *DutiesHeader) ProposerSectionRange() (offset int64, length int64)

ProposerSectionRange returns the byte (offset, length) of the whole proposer section (one index per slot). Length is zero for v1 objects.

func (*DutiesHeader) PtcSlotRange added in v1.24.0

func (h *DutiesHeader) PtcSlotRange(slotIndex uint64) (offset int64, length int64)

PtcSlotRange returns the byte (offset, length) of the PTC members for the slot.

func (*DutiesHeader) SplitSlotCommittees added in v1.24.0

func (h *DutiesHeader) SplitSlotCommittees(slotIndex uint64, slotBytes []byte) ([][]uint64, error)

SplitSlotCommittees splits the raw bytes of a slot's attester span (as returned by an AttesterSlotRange read) into per-committee global validator index lists.

type EpochDuties added in v1.24.0

type EpochDuties struct {
	FirstSlot         uint64
	Epoch             uint64
	ValidatorCount    uint64
	SlotsPerEpoch     uint64
	CommitteesPerSlot uint64
	PtcSize           uint64

	// DependentRoot is the committee-shuffling dependent root of the fork these
	// duties belong to. Set for v2 objects (both canonical and diverging); zero
	// for legacy v1 objects.
	DependentRoot [32]byte

	// Diverging marks the object as belonging to a non-canonical fork (sets the
	// DutiesFlagDiverging header flag). Purely informational: keying already
	// distinguishes canonical (firstSlot) from diverging (firstSlot, depRoot).
	Diverging bool

	// Committees[slotIndex][committeeIndex] holds the global validator indices
	// of that committee in attestation-bit order.
	Committees [][][]uint64
	// ProposerDuties[slotIndex] holds the global validator index of the slot's
	// proposer. Length SlotsPerEpoch in v2; nil for v1. Unknown/out-of-range
	// proposers are stored as 0.
	ProposerDuties []uint64
	// Ptc[slotIndex] holds the PTC members (global validator indices), each
	// slice exactly PtcSize long. Nil if PtcSize == 0.
	Ptc [][]uint64
}

EpochDuties holds the resolved duty mappings for one epoch. It is the input to EncodeEpochDuties and the result of decoding a full object.

func DecodeEpochDuties added in v1.24.0

func DecodeEpochDuties(firstSlot uint64, data []byte) (*EpochDuties, error)

DecodeEpochDuties decodes a full DUTY object into the resolved EpochDuties.

type EventData added in v1.20.3

type EventData struct {
	EventIndex uint32
	Source     [20]byte
	Topics     [][]byte `ssz-size:"?,32" ssz-max:"5"`
	Data       []byte   `ssz-max:"10485760"`
}

EventData holds the data for a single event log to be encoded into the events section of the execution data object.

func (*EventData) HashTreeRoot added in v1.20.3

func (t *EventData) HashTreeRoot() (root [32]byte, err error)

HashTreeRoot computes the SSZ hash tree root of the *EventData.

func (*EventData) HashTreeRootWith added in v1.20.3

func (t *EventData) HashTreeRootWith(hh sszutils.HashWalker) error

HashTreeRootWith computes the SSZ hash tree root of the *EventData using the given hash walker.

func (*EventData) MarshalSSZ added in v1.20.3

func (t *EventData) MarshalSSZ() ([]byte, error)

MarshalSSZ marshals the *EventData to SSZ-encoded bytes.

func (*EventData) MarshalSSZTo added in v1.20.3

func (t *EventData) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo marshals the *EventData to SSZ-encoded bytes, appending to the provided buffer.

func (*EventData) SizeSSZ added in v1.20.3

func (t *EventData) SizeSSZ() (size int)

SizeSSZ returns the SSZ encoded size of the *EventData.

func (*EventData) UnmarshalSSZ added in v1.20.3

func (t *EventData) UnmarshalSSZ(buf []byte) (err error)

UnmarshalSSZ unmarshals the *EventData from SSZ-encoded bytes.

type EventDataList added in v1.20.3

type EventDataList []EventData

EventDataList is a list of EventData.

type ExecDataEngine added in v1.20.3

type ExecDataEngine interface {
	// AddExecData stores execution data for a block.
	// Returns the stored object size in bytes.
	AddExecData(ctx context.Context, slot uint64, blockRoot []byte, data []byte) (int64, error)

	// GetExecData retrieves full execution data for a block.
	// Returns nil, nil if not found.
	GetExecData(ctx context.Context, slot uint64, blockRoot []byte) ([]byte, error)

	// GetExecDataRange retrieves a byte range of execution data.
	// For S3: uses Range header. For Pebble: reads full value and slices.
	// Returns nil, nil if not found.
	GetExecDataRange(ctx context.Context, slot uint64, blockRoot []byte, offset int64, length int64) ([]byte, error)

	// GetExecDataTxSections retrieves compressed section data for a single
	// transaction without loading the entire exec data object.
	// sections is a bitmask of ExecDataSection* constants selecting which
	// sections to return. Contiguous requested sections are fetched in a
	// single range read (S3) or key lookup (Pebble).
	// Returns nil, nil if the transaction is not found.
	GetExecDataTxSections(ctx context.Context, slot uint64, blockRoot []byte, txHash []byte, sections uint32) (*ExecDataTxSections, error)

	// HasExecData checks if execution data exists for a block.
	HasExecData(ctx context.Context, slot uint64, blockRoot []byte) (bool, error)

	// DeleteExecData deletes execution data for a specific block.
	DeleteExecData(ctx context.Context, slot uint64, blockRoot []byte) error

	// PruneExecDataBefore deletes execution data for all slots before maxSlot.
	// Returns the number of objects deleted.
	PruneExecDataBefore(ctx context.Context, maxSlot uint64) (int64, error)
}

ExecDataEngine is the interface for per-block execution data storage. Execution data (events, traces, state changes) is stored separately from beacon block data, keyed by slot+blockRoot for efficient range-based pruning.

type ExecDataObject added in v1.20.3

type ExecDataObject struct {
	FormatVersion uint16
	Flags         uint16
	BlockSlot     uint64
	BlockNumber   uint64

	// Block-level metadata section pointer.
	BlockMetaOffset    uint64
	BlockMetaCompLen   uint32
	BlockMetaUncompLen uint32

	Transactions []ExecDataTxEntry
}

ExecDataObject represents the decoded index of a per-block execution data object. The actual section data is not loaded until explicitly requested.

func ParseExecDataIndex added in v1.20.3

func ParseExecDataIndex(data []byte) (*ExecDataObject, error)

ParseExecDataIndex parses only the index (header + TX entries) from an execution data object. Does NOT read any section data. This is designed for use with partial reads (S3 range requests or Pebble slicing).

func (*ExecDataObject) ExtractBlockMeta added in v1.20.3

func (obj *ExecDataObject) ExtractBlockMeta(objectData []byte) ([]byte, error)

ExtractBlockMeta extracts the compressed block metadata section from raw object data. Returns nil if no block meta section is present.

func (*ExecDataObject) FindTxEntry added in v1.20.3

func (obj *ExecDataObject) FindTxEntry(txHash []byte) *ExecDataTxEntry

FindTxEntry finds the index entry for a specific transaction hash. Returns nil if not found.

type ExecDataTxEntry added in v1.20.3

type ExecDataTxEntry struct {
	TxHash         [32]byte
	SectionsBitmap uint32

	ReceiptMetaOffset    uint64
	ReceiptMetaCompLen   uint32
	ReceiptMetaUncompLen uint32

	EventsOffset    uint64
	EventsCompLen   uint32
	EventsUncompLen uint32

	CallTraceOffset    uint64
	CallTraceCompLen   uint32
	CallTraceUncompLen uint32

	StateChangeOffset    uint64
	StateChangeCompLen   uint32
	StateChangeUncompLen uint32
}

ExecDataTxEntry is the index entry for a single transaction.

func (*ExecDataTxEntry) GetTxSectionSpan added in v1.20.3

func (entry *ExecDataTxEntry) GetTxSectionSpan(mask uint32) (offset uint64, length uint64)

GetTxSectionSpan calculates the contiguous byte range in the data area covering the requested sections for a tx entry. mask selects which sections to include (ExecDataSection* constants). Returns the offset (relative to data area start) and total length. Returns 0,0 if no matching sections are present.

func (*ExecDataTxEntry) SliceTxSections added in v1.20.3

func (entry *ExecDataTxEntry) SliceTxSections(
	chunk []byte, spanOffset uint64, mask uint32,
) (events, callTrace, stateChange, receiptMeta []byte)

SliceTxSections extracts individual section blobs from a contiguous data chunk that was read starting at spanOffset in the data area. mask selects which sections to extract. The chunk must cover the span returned by GetTxSectionSpan with the same mask.

type ExecDataTxSectionData added in v1.20.3

type ExecDataTxSectionData struct {
	TxHash [32]byte

	// Compressed section data (nil if section not present)
	ReceiptMetaData []byte
	EventsData      []byte
	CallTraceData   []byte
	StateChangeData []byte

	// Uncompressed lengths (for the index)
	ReceiptMetaUncompLen uint32
	EventsUncompLen      uint32
	CallTraceUncompLen   uint32
	StateChangeUncompLen uint32
}

ExecDataTxSectionData holds the compressed section data for a single transaction. Used during object construction.

type ExecDataTxSections added in v1.20.3

type ExecDataTxSections struct {
	ReceiptMetaData []byte // snappy-compressed, nil if section not present
	EventsData      []byte // snappy-compressed, nil if section not present
	CallTraceData   []byte // snappy-compressed, nil if section not present
	StateChangeData []byte // snappy-compressed, nil if section not present
}

ExecDataTxSections holds all compressed section data for a single transaction. Returned by GetExecDataTxSections so callers get everything in one call (backed by a single range read for S3, single key lookup for Pebble).

type FlatCallFrame added in v1.20.3

type FlatCallFrame struct {
	Depth   uint16
	Type    uint8 // CallType* constants
	From    [20]byte
	To      [20]byte
	Value   uint256.Int // nil or zero means no value
	Gas     uint64
	GasUsed uint64
	Status  uint8  // CallStatus* constants
	Input   []byte `ssz-max:"10485760"`
	Output  []byte `ssz-max:"10485760"`
	Error   string `ssz-max:"10485760"`
}

FlatCallFrame is a single call frame in a flattened depth-first call trace.

func (*FlatCallFrame) HashTreeRoot added in v1.20.3

func (t *FlatCallFrame) HashTreeRoot() (root [32]byte, err error)

HashTreeRoot computes the SSZ hash tree root of the *FlatCallFrame.

func (*FlatCallFrame) HashTreeRootWith added in v1.20.3

func (t *FlatCallFrame) HashTreeRootWith(hh sszutils.HashWalker) error

HashTreeRootWith computes the SSZ hash tree root of the *FlatCallFrame using the given hash walker.

func (*FlatCallFrame) MarshalSSZ added in v1.20.3

func (t *FlatCallFrame) MarshalSSZ() ([]byte, error)

MarshalSSZ marshals the *FlatCallFrame to SSZ-encoded bytes.

func (*FlatCallFrame) MarshalSSZTo added in v1.20.3

func (t *FlatCallFrame) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo marshals the *FlatCallFrame to SSZ-encoded bytes, appending to the provided buffer.

func (*FlatCallFrame) SizeSSZ added in v1.20.3

func (t *FlatCallFrame) SizeSSZ() (size int)

SizeSSZ returns the SSZ encoded size of the *FlatCallFrame.

func (*FlatCallFrame) UnmarshalSSZ added in v1.20.3

func (t *FlatCallFrame) UnmarshalSSZ(buf []byte) (err error)

UnmarshalSSZ unmarshals the *FlatCallFrame from SSZ-encoded bytes.

type ObjectStatsEngine added in v1.24.4

type ObjectStatsEngine interface {
	// GetObjectStats returns per-namespace object counts.
	GetObjectStats(ctx context.Context) (*BlockDbObjectStats, error)
}

ObjectStatsEngine is an optional interface implemented by engines that can cheaply count stored objects per namespace (e.g. the Pebble engine via range scans). Engines without a cheap scan (e.g. S3) do not implement it.

type ReceiptMetaData added in v1.20.3

type ReceiptMetaData struct {
	Version           uint16      // Schema version for forward compatibility
	Status            uint8       // 0=failure, 1=success
	TxType            uint8       // Transaction type (0=legacy, 1=access list, 2=dynamic fee, 3=blob, 4=set code)
	CumulativeGasUsed uint64      // Cumulative gas used in block up to and including this tx
	GasUsed           uint64      // Gas used by this specific transaction
	EffectiveGasPrice uint256.Int // Actual gas price paid (in wei)
	BlobGasUsed       uint64      // Blob gas used (EIP-4844), 0 otherwise
	LogsBloom         [256]byte   // Bloom filter for this receipt's logs
	From              [20]byte    // Sender address
	To                [20]byte    // Receiver address (zero for contract creation)
	ContractAddress   [20]byte    // Created contract address (zero if not creation)
	HasContractAddr   bool        // Whether ContractAddress is valid (contract creation tx)
}

ReceiptMetaData holds per-transaction receipt metadata needed to reconstruct a full eth_getTransactionReceipt JSON response. Stored in the ReceiptMeta section (bitmap flag 0x08) of the execution data object.

func (*ReceiptMetaData) HashTreeRoot added in v1.20.3

func (t *ReceiptMetaData) HashTreeRoot() (root [32]byte, err error)

HashTreeRoot computes the SSZ hash tree root of the *ReceiptMetaData.

func (*ReceiptMetaData) HashTreeRootWith added in v1.20.3

func (t *ReceiptMetaData) HashTreeRootWith(hh sszutils.HashWalker) error

HashTreeRootWith computes the SSZ hash tree root of the *ReceiptMetaData using the given hash walker.

func (*ReceiptMetaData) MarshalSSZ added in v1.20.3

func (t *ReceiptMetaData) MarshalSSZ() ([]byte, error)

MarshalSSZ marshals the *ReceiptMetaData to SSZ-encoded bytes.

func (*ReceiptMetaData) MarshalSSZTo added in v1.20.3

func (t *ReceiptMetaData) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo marshals the *ReceiptMetaData to SSZ-encoded bytes, appending to the provided buffer.

func (*ReceiptMetaData) SizeSSZ added in v1.20.3

func (t *ReceiptMetaData) SizeSSZ() (size int)

SizeSSZ returns the SSZ encoded size of the *ReceiptMetaData.

func (*ReceiptMetaData) UnmarshalSSZ added in v1.20.3

func (t *ReceiptMetaData) UnmarshalSSZ(buf []byte) (err error)

UnmarshalSSZ unmarshals the *ReceiptMetaData from SSZ-encoded bytes.

type SlotBids added in v1.24.4

type SlotBids struct {
	Slot    uint64
	Clients []string
	Bids    []*SlotBidsEntry
}

SlotBids holds all bids of one slot with their gossip observations. It is the input to EncodeSlotBids and the result of DecodeSlotBids.

func DecodeSlotBids added in v1.24.4

func DecodeSlotBids(data []byte) (*SlotBids, error)

DecodeSlotBids decodes a BIDS object.

func MergeSlotBids added in v1.24.4

func MergeSlotBids(a, b *SlotBids) *SlotBids

MergeSlotBids merges two bids objects for the same slot, unifying their client tables and bid lists. Observations keep the earliest first-seen offset per client; for bids present in both objects the bid fields of the second (newer) object win. Either argument may be nil.

type SlotBidsEngine added in v1.24.4

type SlotBidsEngine interface {
	// AddSlotBids stores the bids object for a slot, replacing any existing
	// object. Returns the stored size in bytes.
	AddSlotBids(ctx context.Context, bids *SlotBids) (int64, error)

	// GetSlotBids retrieves the bids object for a slot.
	// Returns nil, nil if not found.
	GetSlotBids(ctx context.Context, slot uint64) (*SlotBids, error)

	// PruneSlotBidsBefore deletes bids objects for all slots before maxSlot.
	// Returns the number of objects deleted.
	PruneSlotBidsBefore(ctx context.Context, maxSlot uint64) (int64, error)
}

SlotBidsEngine stores per-slot bids objects: all execution payload bids of a slot with their gossip observations, keyed by slot.

type SlotBidsEntry added in v1.24.4

type SlotBidsEntry struct {
	Bid *dbtypes.BlockBid
	// SeenMask bit i is set if the client at table index i observed the bid.
	SeenMask []byte
	// SeenTimes holds one first-seen offset (ms from slot start) per set mask
	// bit, in ascending client index order.
	SeenTimes []int32
}

SlotBidsEntry is one bid with its observations. Bid carries the full bid fields; decoded entries derive Bid.Slot from the object and the seen counters from the observations (SeenCount = observer count, SeenTotal = client table size).

func (*SlotBidsEntry) Key added in v1.24.4

func (e *SlotBidsEntry) Key() string

Key returns the string key identifying this bid across objects, built from the bid's dedup tuple (parent root, parent hash, block hash, builder index).

func (*SlotBidsEntry) SeenBitSet added in v1.24.4

func (e *SlotBidsEntry) SeenBitSet(i int) bool

SeenBitSet returns whether the client at table index i observed the bid.

func (*SlotBidsEntry) SeenByClientIndex added in v1.24.4

func (e *SlotBidsEntry) SeenByClientIndex() map[int]int32

SeenByClientIndex returns a map from client table index to first-seen offset (ms from slot start) for all clients that observed the bid.

func (*SlotBidsEntry) SeenCount added in v1.24.4

func (e *SlotBidsEntry) SeenCount() int

SeenCount returns the number of clients that observed the bid.

type StateChangeAccount added in v1.20.3

type StateChangeAccount struct {
	Address [20]byte
	Flags   uint8

	// Balance
	PreBalance  uint256.Int
	PostBalance uint256.Int

	// Nonce
	PreNonce  uint64
	PostNonce uint64

	// Code
	PreCode  []byte `ssz-max:"10485760"`
	PostCode []byte `ssz-max:"10485760"`

	// Storage
	Slots []StateChangeSlot `ssz-max:"10485760"`
}

StateChangeAccount is the normalized per-account state diff representation used by EncodeStateChangesSection.

func (*StateChangeAccount) HashTreeRoot added in v1.20.3

func (t *StateChangeAccount) HashTreeRoot() (root [32]byte, err error)

HashTreeRoot computes the SSZ hash tree root of the *StateChangeAccount.

func (*StateChangeAccount) HashTreeRootWith added in v1.20.3

func (t *StateChangeAccount) HashTreeRootWith(hh sszutils.HashWalker) error

HashTreeRootWith computes the SSZ hash tree root of the *StateChangeAccount using the given hash walker.

func (*StateChangeAccount) MarshalSSZ added in v1.20.3

func (t *StateChangeAccount) MarshalSSZ() ([]byte, error)

MarshalSSZ marshals the *StateChangeAccount to SSZ-encoded bytes.

func (*StateChangeAccount) MarshalSSZTo added in v1.20.3

func (t *StateChangeAccount) MarshalSSZTo(buf []byte) (dst []byte, err error)

MarshalSSZTo marshals the *StateChangeAccount to SSZ-encoded bytes, appending to the provided buffer.

func (*StateChangeAccount) SizeSSZ added in v1.20.3

func (t *StateChangeAccount) SizeSSZ() (size int)

SizeSSZ returns the SSZ encoded size of the *StateChangeAccount.

func (*StateChangeAccount) UnmarshalSSZ added in v1.20.3

func (t *StateChangeAccount) UnmarshalSSZ(buf []byte) (err error)

UnmarshalSSZ unmarshals the *StateChangeAccount from SSZ-encoded bytes.

type StateChangeSlot added in v1.20.3

type StateChangeSlot struct {
	Slot      [32]byte
	PreValue  [32]byte
	PostValue [32]byte
}

StateChangeSlot is a single changed storage slot.

type TxHashEntry added in v1.24.1

type TxHashEntry struct {
	Prefix []byte // TxHashPrefixLen bytes
	TxUid  uint64 // slot<<32 | block_index<<16 | tx_index
}

TxHashEntry maps a tx-hash prefix to its tx_uid for index insertion.

type TxHashIndex added in v1.24.1

type TxHashIndex interface {
	// PutTxHashes inserts (idempotently) one entry per transaction.
	PutTxHashes(ctx context.Context, entries []TxHashEntry) error
	// LookupTxHash returns all candidate tx_uids for an exact prefix.
	LookupTxHash(ctx context.Context, prefix []byte) ([]uint64, error)
	// LookupTxHashRange returns candidate tx_uids for prefixes in [lo, hi),
	// used for partial-hash search.
	LookupTxHashRange(ctx context.Context, lo, hi []byte) ([]uint64, error)
	// PruneTxHashBefore removes all entries for slots below maxSlot and returns
	// the number of entries removed.
	PruneTxHashBefore(ctx context.Context, maxSlot uint64) (int64, error)
}

TxHashIndex is an optional blockdb-layer capability that maps tx-hash prefixes to tx_uids so a transaction can be located by hash after its relational row has been pruned. It is implemented natively by the Pebble/Tiered engines and by a relational adapter for the S3 engine.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL