pebble

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Duties key record types (stored at byte offset 10).
	DutiesRecordMeta       uint8 = 0 // per-epoch header
	DutiesRecordCommittees uint8 = 1 // per-slot attester committees
	DutiesRecordPtc        uint8 = 2 // per-slot PTC members

	// DutiesKeyLen: [ns:2][firstSlot:8][type:1][slotIndex:2] = 13 bytes
	DutiesKeyLen = 2 + 8 + 1 + 2
)
View Source
const (
	BlockTypeHeader  uint16 = 1
	BlockTypeBody    uint16 = 2
	BlockTypePayload uint16 = 3
	BlockTypeBal     uint16 = 4
)
View Source
const (
	KeyNamespaceBlock uint16 = 1
)
View Source
const (
	// KeyNamespaceDuties is the namespace prefix for per-epoch duties.
	// Each epoch is stored as several keys (one meta key plus one key per slot
	// for committees and PTC) so a single slot can be read with a point lookup
	// without loading the whole epoch. Keys are grouped by the epoch's first
	// slot to allow efficient range deletion.
	KeyNamespaceDuties uint16 = 3
)
View Source
const (
	// KeyNamespaceExecData is the namespace prefix for execution data keys.
	// Each key stores the full DXTX blob for one block.
	// Slot-first ordering enables efficient range deletion for pruning.
	KeyNamespaceExecData uint16 = 2
)
View Source
const (
	// KeyNamespaceLRU is the namespace for LRU tracking data.
	KeyNamespaceLRU uint16 = 2
)

Variables

This section is empty.

Functions

func MakeDutiesKey added in v1.24.0

func MakeDutiesKey(firstSlot uint64, recordType uint8, slotIndex uint16) []byte

MakeDutiesKey builds a Pebble key for a duties record. Exported so tooling (e.g. the blockdb-copy utility) can read/write duties records directly.

func NewPebbleEngine

func NewPebbleEngine(config dtypes.PebbleBlockDBConfig) (types.BlockDbEngine, error)

Types

type CacheCleanup added in v1.21.0

type CacheCleanup struct {
	// contains filtered or unexported fields
}

CacheCleanup manages background cleanup of cached data.

func NewCacheCleanup added in v1.21.0

func NewCacheCleanup(engine *PebbleEngine, logger logrus.FieldLogger) *CacheCleanup

NewCacheCleanup creates a new cache cleanup manager.

func (*CacheCleanup) DeleteLRU added in v1.21.0

func (c *CacheCleanup) DeleteLRU(root []byte)

DeleteLRU removes LRU data for a block (call when deleting block data).

func (*CacheCleanup) FlushLRU added in v1.21.0

func (c *CacheCleanup) FlushLRU()

FlushLRU flushes buffered LRU updates to Pebble.

func (*CacheCleanup) RecordAccess added in v1.21.0

func (c *CacheCleanup) RecordAccess(root []byte, flags types.BlockDataFlags)

RecordAccess records an access for LRU tracking. Buffered until flush.

func (*CacheCleanup) Start added in v1.21.0

func (c *CacheCleanup) Start()

Start begins the background cleanup loop.

func (*CacheCleanup) Stop added in v1.21.0

func (c *CacheCleanup) Stop()

Stop stops the background cleanup loop.

type PebbleEngine

type PebbleEngine struct {
	// contains filtered or unexported fields
}

func (*PebbleEngine) AddBlock

func (e *PebbleEngine) AddBlock(
	_ context.Context,
	_ uint64,
	root []byte,
	dataCb func() (*types.BlockData, error),
) (bool, bool, error)

AddBlock stores block data. Returns (added, updated, error). - added: true if a new block was created - updated: true if an existing block was updated with new components

func (*PebbleEngine) AddEpochDuties added in v1.24.0

func (e *PebbleEngine) AddEpochDuties(_ context.Context, duties *types.EpochDuties) (int64, error)

AddEpochDuties stores the duties for an epoch as per-slot keys.

func (*PebbleEngine) AddExecData added in v1.20.3

func (e *PebbleEngine) AddExecData(_ context.Context, slot uint64, blockHash []byte, data []byte) (int64, error)

AddExecData stores execution data for a block as a full DXTX blob. Returns the stored size in bytes.

func (*PebbleEngine) Close

func (e *PebbleEngine) Close() error

func (*PebbleEngine) DeleteExecData added in v1.20.3

func (e *PebbleEngine) DeleteExecData(_ context.Context, slot uint64, blockHash []byte) error

DeleteExecData deletes execution data for a specific block.

func (*PebbleEngine) GetBlock

func (e *PebbleEngine) GetBlock(
	_ context.Context,
	_ uint64,
	root []byte,
	flags types.BlockDataFlags,
	parseBlock func(uint64, []byte) (any, error),
	parsePayload func(uint64, []byte) (any, error),
) (*types.BlockData, error)

GetBlock retrieves block data with selective loading based on flags. Note: LRU access tracking should be done by the caller via CacheCleanup.RecordAccess() to avoid expensive read-modify-write operations on every access.

func (*PebbleEngine) GetConfig added in v1.21.0

func (e *PebbleEngine) GetConfig() dtypes.PebbleBlockDBConfig

GetConfig returns the engine configuration.

func (*PebbleEngine) GetDB added in v1.20.4

func (e *PebbleEngine) GetDB() *pebble.DB

GetDB returns the underlying pebble database for metrics collection.

func (*PebbleEngine) GetEpochDuties added in v1.24.0

func (e *PebbleEngine) GetEpochDuties(_ context.Context, firstSlot uint64) (*types.EpochDuties, error)

GetEpochDuties reads and reassembles the full duties for an epoch.

func (*PebbleEngine) GetExecData added in v1.20.3

func (e *PebbleEngine) GetExecData(_ context.Context, slot uint64, blockHash []byte) ([]byte, error)

GetExecData retrieves the full DXTX blob for a block. Returns nil, nil if not found.

func (*PebbleEngine) GetExecDataRange added in v1.20.3

func (e *PebbleEngine) GetExecDataRange(_ context.Context, slot uint64, blockHash []byte, offset int64, length int64) ([]byte, error)

GetExecDataRange retrieves a byte range of the DXTX blob.

func (*PebbleEngine) GetExecDataTxSections added in v1.20.3

func (e *PebbleEngine) GetExecDataTxSections(_ context.Context, slot uint64, blockHash []byte, txHash []byte, sections uint32) (*types.ExecDataTxSections, error)

GetExecDataTxSections retrieves compressed section data for a single transaction by loading the full DXTX blob and extracting the requested sections from it.

func (*PebbleEngine) GetSlotCommittees added in v1.24.0

func (e *PebbleEngine) GetSlotCommittees(_ context.Context, firstSlot uint64, slot uint64) ([][]uint64, error)

GetSlotCommittees reads the attester committees for a single slot.

func (*PebbleEngine) GetSlotPtc added in v1.24.0

func (e *PebbleEngine) GetSlotPtc(_ context.Context, firstSlot uint64, slot uint64) ([]uint64, error)

GetSlotPtc reads the PTC members for a single slot.

func (*PebbleEngine) GetStoredComponents added in v1.21.0

func (e *PebbleEngine) GetStoredComponents(_ context.Context, _ uint64, root []byte) (types.BlockDataFlags, error)

GetStoredComponents returns which components exist for a block.

func (*PebbleEngine) HasEpochDuties added in v1.24.0

func (e *PebbleEngine) HasEpochDuties(_ context.Context, firstSlot uint64) (bool, error)

HasEpochDuties checks if duties exist for an epoch (via its meta key).

func (*PebbleEngine) HasExecData added in v1.20.3

func (e *PebbleEngine) HasExecData(_ context.Context, slot uint64, blockHash []byte) (bool, error)

HasExecData checks if execution data exists for a block.

func (*PebbleEngine) PruneEpochDutiesBefore added in v1.24.0

func (e *PebbleEngine) PruneEpochDutiesBefore(_ context.Context, maxFirstSlot uint64) (int64, error)

PruneEpochDutiesBefore deletes all duties records for epochs whose first slot is before maxFirstSlot. Returns the number of epochs deleted.

func (*PebbleEngine) PruneExecDataBefore added in v1.20.3

func (e *PebbleEngine) PruneExecDataBefore(_ context.Context, maxSlot uint64) (int64, error)

PruneExecDataBefore deletes execution data for all slots before maxSlot. Returns the number of objects deleted.

Jump to

Keyboard shortcuts

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