Documentation
¶
Overview ¶
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: d3acce19a9e9c0afc0038f9dfd949d804d4b82beafef97cc4d618d03c202d4af Version: v1.2.1 (https://github.com/pk910/dynamic-ssz)
Index ¶
- Constants
- Variables
- func BuildExecDataObject(blockSlot uint64, blockNumber uint64, blockMeta []byte, ...) []byte
- func ExecDataIndexSize(txCount uint32) int
- func ExecDataMinHeaderSize() int
- func ExtractSectionData(objectData []byte, txCount uint32, sectionOffset uint64, sectionCompLen uint32) ([]byte, error)
- func ParseExecDataTxCount(header []byte) (uint32, error)
- type BlockData
- type BlockDbEngine
- type BlockReceiptMeta
- func (t *BlockReceiptMeta) HashTreeRoot() (root [32]byte, err error)
- func (t *BlockReceiptMeta) HashTreeRootWith(hh sszutils.HashWalker) error
- func (t *BlockReceiptMeta) MarshalSSZ() ([]byte, error)
- func (t *BlockReceiptMeta) MarshalSSZTo(buf []byte) (dst []byte, err error)
- func (t *BlockReceiptMeta) SizeSSZ() (size int)
- func (t *BlockReceiptMeta) UnmarshalSSZ(buf []byte) (err error)
- type EventData
- func (t *EventData) HashTreeRoot() (root [32]byte, err error)
- func (t *EventData) HashTreeRootWith(hh sszutils.HashWalker) error
- func (t *EventData) MarshalSSZ() ([]byte, error)
- func (t *EventData) MarshalSSZTo(buf []byte) (dst []byte, err error)
- func (t *EventData) SizeSSZ() (size int)
- func (t *EventData) UnmarshalSSZ(buf []byte) (err error)
- type EventDataList
- type ExecDataEngine
- type ExecDataObject
- type ExecDataTxEntry
- type ExecDataTxSectionData
- type ExecDataTxSections
- type FlatCallFrame
- func (t *FlatCallFrame) HashTreeRoot() (root [32]byte, err error)
- func (t *FlatCallFrame) HashTreeRootWith(hh sszutils.HashWalker) error
- func (t *FlatCallFrame) MarshalSSZ() ([]byte, error)
- func (t *FlatCallFrame) MarshalSSZTo(buf []byte) (dst []byte, err error)
- func (t *FlatCallFrame) SizeSSZ() (size int)
- func (t *FlatCallFrame) UnmarshalSSZ(buf []byte) (err error)
- type ReceiptMetaData
- func (t *ReceiptMetaData) HashTreeRoot() (root [32]byte, err error)
- func (t *ReceiptMetaData) HashTreeRootWith(hh sszutils.HashWalker) error
- func (t *ReceiptMetaData) MarshalSSZ() ([]byte, error)
- func (t *ReceiptMetaData) MarshalSSZTo(buf []byte) (dst []byte, err error)
- func (t *ReceiptMetaData) SizeSSZ() (size int)
- func (t *ReceiptMetaData) UnmarshalSSZ(buf []byte) (err error)
- type StateChangeAccount
- func (t *StateChangeAccount) HashTreeRoot() (root [32]byte, err error)
- func (t *StateChangeAccount) HashTreeRootWith(hh sszutils.HashWalker) error
- func (t *StateChangeAccount) MarshalSSZ() ([]byte, error)
- func (t *StateChangeAccount) MarshalSSZTo(buf []byte) (dst []byte, err error)
- func (t *StateChangeAccount) SizeSSZ() (size int)
- func (t *StateChangeAccount) UnmarshalSSZ(buf []byte) (err error)
- type StateChangeSlot
Constants ¶
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 )
const ( CallTypeCall = 0 CallTypeStaticCall = 1 CallTypeDelegateCall = 2 CallTypeCreate = 3 CallTypeCreate2 = 4 CallTypeSelfDestruct = 5 )
Call type constants matching the callTracer output.
const ( CallStatusSuccess = 0 CallStatusReverted = 1 CallStatusError = 2 )
Call status constants for binary encoding.
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).
const (
BlockReceiptMetaVersion1 = 1
)
Block receipt metadata version. Bump when adding new block-wide fields.
const (
ReceiptMetaVersion1 = 1
)
Receipt metadata version. Bump when adding new fields.
const (
StateChangesVersion1 = 1
)
State change section version.
Variables ¶
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 ExecDataIndexSize ¶ added in v1.20.3
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 ParseExecDataTxCount ¶ added in v1.20.3
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 {
HeaderVersion uint64
HeaderData []byte
BodyVersion uint64
BodyData []byte
Body interface{}
}
BlockData holds beacon block header and body data.
type BlockDbEngine ¶
type BlockDbEngine interface {
Close() error
GetBlock(ctx context.Context, slot uint64, root []byte, parseBlock func(uint64, []byte) (interface{}, error)) (*BlockData, error)
AddBlock(ctx context.Context, slot uint64, root []byte, dataCb func() (*BlockData, error)) (bool, error)
}
BlockDbEngine is the interface for beacon block storage.
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)
func (*BlockReceiptMeta) HashTreeRootWith ¶ added in v1.20.3
func (t *BlockReceiptMeta) HashTreeRootWith(hh sszutils.HashWalker) error
func (*BlockReceiptMeta) MarshalSSZ ¶ added in v1.20.3
func (t *BlockReceiptMeta) MarshalSSZ() ([]byte, error)
func (*BlockReceiptMeta) MarshalSSZTo ¶ added in v1.20.3
func (t *BlockReceiptMeta) MarshalSSZTo(buf []byte) (dst []byte, err error)
func (*BlockReceiptMeta) SizeSSZ ¶ added in v1.20.3
func (t *BlockReceiptMeta) SizeSSZ() (size int)
func (*BlockReceiptMeta) UnmarshalSSZ ¶ added in v1.20.3
func (t *BlockReceiptMeta) UnmarshalSSZ(buf []byte) (err error)
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
}
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 (*EventData) HashTreeRootWith ¶ added in v1.20.3
func (t *EventData) HashTreeRootWith(hh sszutils.HashWalker) error
func (*EventData) MarshalSSZ ¶ added in v1.20.3
func (*EventData) MarshalSSZTo ¶ added in v1.20.3
func (*EventData) UnmarshalSSZ ¶ added in v1.20.3
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
Output []byte
Error string
}
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)
func (*FlatCallFrame) HashTreeRootWith ¶ added in v1.20.3
func (t *FlatCallFrame) HashTreeRootWith(hh sszutils.HashWalker) error
func (*FlatCallFrame) MarshalSSZ ¶ added in v1.20.3
func (t *FlatCallFrame) MarshalSSZ() ([]byte, error)
func (*FlatCallFrame) MarshalSSZTo ¶ added in v1.20.3
func (t *FlatCallFrame) MarshalSSZTo(buf []byte) (dst []byte, err error)
func (*FlatCallFrame) SizeSSZ ¶ added in v1.20.3
func (t *FlatCallFrame) SizeSSZ() (size int)
func (*FlatCallFrame) UnmarshalSSZ ¶ added in v1.20.3
func (t *FlatCallFrame) UnmarshalSSZ(buf []byte) (err error)
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)
func (*ReceiptMetaData) HashTreeRootWith ¶ added in v1.20.3
func (t *ReceiptMetaData) HashTreeRootWith(hh sszutils.HashWalker) error
func (*ReceiptMetaData) MarshalSSZ ¶ added in v1.20.3
func (t *ReceiptMetaData) MarshalSSZ() ([]byte, error)
func (*ReceiptMetaData) MarshalSSZTo ¶ added in v1.20.3
func (t *ReceiptMetaData) MarshalSSZTo(buf []byte) (dst []byte, err error)
func (*ReceiptMetaData) SizeSSZ ¶ added in v1.20.3
func (t *ReceiptMetaData) SizeSSZ() (size int)
func (*ReceiptMetaData) UnmarshalSSZ ¶ added in v1.20.3
func (t *ReceiptMetaData) UnmarshalSSZ(buf []byte) (err error)
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
PostCode []byte
// Storage
Slots []StateChangeSlot
}
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)
func (*StateChangeAccount) HashTreeRootWith ¶ added in v1.20.3
func (t *StateChangeAccount) HashTreeRootWith(hh sszutils.HashWalker) error
func (*StateChangeAccount) MarshalSSZ ¶ added in v1.20.3
func (t *StateChangeAccount) MarshalSSZ() ([]byte, error)
func (*StateChangeAccount) MarshalSSZTo ¶ added in v1.20.3
func (t *StateChangeAccount) MarshalSSZTo(buf []byte) (dst []byte, err error)
func (*StateChangeAccount) SizeSSZ ¶ added in v1.20.3
func (t *StateChangeAccount) SizeSSZ() (size int)
func (*StateChangeAccount) UnmarshalSSZ ¶ added in v1.20.3
func (t *StateChangeAccount) UnmarshalSSZ(buf []byte) (err error)
type StateChangeSlot ¶ added in v1.20.3
StateChangeSlot is a single changed storage slot.