Documentation
¶
Overview ¶
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 (40 bytes) ├── Magic: [4]byte = "DUTY" ├── Version: uint16 ├── Flags: uint8 (reserved, 0) ├── 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) ATTESTER SECTION: ValidatorCount * IndexWidth bytes │ flat list of global validator indices in (slotIndex, committeeIndex, position) order 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: d3acce19a9e9c0afc0038f9dfd949d804d4b82beafef97cc4d618d03c202d4af Version: v1.3.2 (https://github.com/pk910/dynamic-ssz)
Index ¶
- Constants
- Variables
- func BuildExecDataObject(blockSlot uint64, blockNumber uint64, blockMeta []byte, ...) []byte
- func DecodeIndexList(b []byte, width uint8) []uint64
- func DecodeSlotCommittees(data []byte) ([][]uint64, error)
- func EncodeDutiesHeader(d *EpochDuties) []byte
- func EncodeEpochDuties(d *EpochDuties) ([]byte, error)
- func EncodeIndexList(indices []uint64) ([]byte, error)
- func EncodeSlotCommittees(committees [][]uint64) ([]byte, error)
- func ExecDataIndexSize(txCount uint32) int
- func ExecDataMinHeaderSize() int
- func ExtractSectionData(objectData []byte, txCount uint32, sectionOffset uint64, sectionCompLen uint32) ([]byte, error)
- func HashPrefix(txHash []byte) []byte
- func ParseExecDataTxCount(header []byte) (uint32, error)
- type BlockData
- type BlockDataFlags
- 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 DutiesEngine
- type DutiesHeader
- type EpochDuties
- 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
- type TxHashEntry
- type TxHashIndex
Constants ¶
const ( // DutiesFormatVersion is the current duties object format version. DutiesFormatVersion uint16 = 1 // DutiesHeaderSize is the fixed header size for version 1. DutiesHeaderSize = 40 // DutiesIndexWidth is the number of bytes used to encode a validator index. DutiesIndexWidth uint8 = 6 )
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.
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 ¶
var DutiesMagic = [4]byte{'D', 'U', 'T', 'Y'}
DutiesMagic identifies a duties object.
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
DecodeIndexList decodes a tightly packed list of width-byte big-endian indices.
func DecodeSlotCommittees ¶ added in v1.24.0
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.
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
EncodeIndexList serializes a list of validator indices as packed width-byte values.
func EncodeSlotCommittees ¶ added in v1.24.0
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
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
HashPrefix returns a fresh TxHashPrefixLen-byte copy of the tx hash (never aliases the input). A short input is right-padded with zeroes.
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 {
// 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
func (f BlockDataFlags) Add(flag BlockDataFlags) BlockDataFlags
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
func (f BlockDataFlags) Remove(flag BlockDataFlags) BlockDataFlags
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 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)
// 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
}
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) 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
// Committees[slotIndex][committeeIndex] holds the global validator indices
// of that committee in attestation-bit order.
Committees [][][]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
}
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
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
MarshalSSZ marshals the *EventData to SSZ-encoded bytes.
func (*EventData) MarshalSSZTo ¶ added in v1.20.3
MarshalSSZTo marshals the *EventData to SSZ-encoded bytes, appending to the provided buffer.
func (*EventData) SizeSSZ ¶ added in v1.20.3
SizeSSZ returns the SSZ encoded size of the *EventData.
func (*EventData) UnmarshalSSZ ¶ added in v1.20.3
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
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)
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 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 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)
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
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.