txindexer

package
v1.24.3 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: GPL-3.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PruneObjZeroBalances   = "zero_balances"
	PruneObjTransactions   = "transactions"
	PruneObjInternalTxs    = "internal_txs"
	PruneObjTokenTransfers = "token_transfers"
	PruneObjBlocks         = "blocks"
	PruneObjExecData       = "exec_data"
	PruneObjTxHashIndex    = "tx_hash_index"
)

Object-type identifiers for per-object pruning stats.

Variables

This section is empty.

Functions

This section is empty.

Types

type BalanceLookupPriority

type BalanceLookupPriority uint8

BalanceLookupPriority defines the priority level for balance lookups.

const (
	// LowPriority is for background verification lookups.
	LowPriority BalanceLookupPriority = 0
	// HighPriority is for user-facing address page lookups.
	HighPriority BalanceLookupPriority = 1
)

type BalanceLookupRequest

type BalanceLookupRequest struct {
	AccountID uint64         // 0 if address not in DB
	TokenID   uint64         // 0 for native ETH
	Address   common.Address // Required for RPC calls
	Contract  common.Address // Token contract (zero for native ETH)
	Decimals  uint8          // Token decimals
	Priority  BalanceLookupPriority
	Timestamp time.Time // When request was added
}

BalanceLookupRequest represents a request to look up a balance. AccountID can be 0 for addresses not yet in the database.

type BalanceLookupService

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

BalanceLookupService manages balance lookup requests with priority queuing.

func NewBalanceLookupService

func NewBalanceLookupService(logger logrus.FieldLogger, indexer *TxIndexer) *BalanceLookupService

NewBalanceLookupService creates a new balance lookup service.

func (*BalanceLookupService) FetchETHBalance

func (s *BalanceLookupService) FetchETHBalance(ctx context.Context, address common.Address) (*big.Int, error)

FetchETHBalance fetches the native ETH balance for an address via eth_getBalance.

func (*BalanceLookupService) FetchTokenBalance

func (s *BalanceLookupService) FetchTokenBalance(ctx context.Context, address common.Address, tokenContract common.Address) (*big.Int, error)

FetchTokenBalance fetches the ERC20 token balance for an address via balanceOf static call.

func (*BalanceLookupService) GetPendingLookups

func (s *BalanceLookupService) GetPendingLookups(maxCount int) []*BalanceLookupRequest

GetPendingLookups returns up to maxCount lookups to process. High priority requests are returned first.

func (*BalanceLookupService) GetQueueStats

func (s *BalanceLookupService) GetQueueStats() (highPrio, lowPrio int)

GetQueueStats returns current queue sizes.

func (*BalanceLookupService) HasPendingLookups

func (s *BalanceLookupService) HasPendingLookups() bool

HasPendingLookups returns true if there are any pending lookups in the queues.

func (*BalanceLookupService) ProcessPendingLookups

func (s *BalanceLookupService) ProcessPendingLookups(ctx context.Context) (dbCommitCallback, error)

ProcessPendingLookups processes pending balance lookups and returns updated balances. For known accounts (AccountID > 0), updates the balance directly. For unknown accounts (AccountID == 0), creates the account if balance > 0.

func (*BalanceLookupService) QueueAddressBalanceLookups added in v1.20.0

func (s *BalanceLookupService) QueueAddressBalanceLookups(accountID uint64, address []byte)

QueueAddressBalanceLookups queues balance lookups for an address page view. accountID should be 0 if the address is not in the database. Rate limited to prevent excessive RPC calls.

func (*BalanceLookupService) QueueBalanceLookup

func (s *BalanceLookupService) QueueBalanceLookup(req *BalanceLookupRequest)

QueueBalanceLookup adds a balance lookup request to the queue. High priority requests are processed before low priority ones. Duplicate requests are deduplicated, with priority upgraded if needed.

type BlockRef

type BlockRef struct {
	Slot        phase0.Slot
	BlockUID    uint64
	BlockHash   []byte        // EL block hash
	BlockRoot   []byte        // Beacon block root (used as key for exec data in blockdb)
	Block       *beacon.Block // optional, may be nil for historical blocks
	ProcessTime time.Time     // earliest time this block can be processed (zero means immediate)
	IsRecent    bool
	// contains filtered or unexported fields
}

BlockRef represents a reference to a block for EL indexing.

type ElPruningObjectStat added in v1.24.1

type ElPruningObjectStat struct {
	Type      string `json:"type"`
	Deleted   int64  `json:"deleted"`
	SizeBytes int64  `json:"size_bytes"` // freed bytes where known, else 0
}

ElPruningObjectStat is the per-object-type result of a cleanup cycle.

type ElPruningRun added in v1.24.1

type ElPruningRun struct {
	Time       int64                 `json:"time"`        // unix seconds
	DurationMs int64                 `json:"duration_ms"` // total cycle duration
	Objects    []ElPruningObjectStat `json:"objects"`     // per-object-type results
}

ElPruningRun captures the result of one cleanup cycle.

type ElPruningStatus added in v1.24.1

type ElPruningStatus struct {
	LastCleanup int64 `json:"last_cleanup"` // unix seconds of the last cleanup cycle

	// RelationalPrunedEpoch is the epoch below which relational rows
	// (transactions/transfers/internal/blocks) have been pruned. Data is
	// available from this epoch up to IndexedEpoch.
	RelationalEnabled     bool   `json:"rel_enabled"`
	RelationalPrunedEpoch uint64 `json:"rel_pruned_epoch"`

	// DetailsPrunedEpoch is the epoch below which blockdb exec data and the
	// tx-hash index have been pruned (drives by-hash availability).
	DetailsEnabled     bool   `json:"det_enabled"`
	DetailsPrunedEpoch uint64 `json:"det_pruned_epoch"`

	// Runs holds the most recent cleanup cycles (newest first, capped).
	Runs []ElPruningRun `json:"runs"`
}

ElPruningStatus is the persisted EL pruning status, also exposed for UI display. It is stored in explorer_state under cleanupStateKey.

type IndexingMode added in v1.20.3

type IndexingMode uint8

IndexingMode represents the execution indexer operating mode.

const (
	// ModeDisabled means no EL indexing at all.
	ModeDisabled IndexingMode = iota

	// ModeLightweight is DB-only indexing: transactions, token transfers,
	// accounts, tokens, balances, withdrawals. No event storage, no blockdb.
	ModeLightweight

	// ModeFull is everything from ModeLightweight plus per-block detail
	// objects in blockdb (events, call traces). Requires blockdb.
	ModeFull
)

type TxIndexer

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

TxIndexer is responsible for indexing EL transactions from beacon blocks.

func NewTxIndexer

func NewTxIndexer(
	logger logrus.FieldLogger,
	indexerCtx *execution.IndexerCtx,
) *TxIndexer

NewTxIndexer creates a new TxIndexer instance.

func (*TxIndexer) GetBalanceLookupService

func (t *TxIndexer) GetBalanceLookupService() *BalanceLookupService

GetBalanceLookupService returns the balance lookup service for direct access.

func (*TxIndexer) GetBalanceLookupStats

func (t *TxIndexer) GetBalanceLookupStats() (highPrio, lowPrio int)

GetBalanceLookupStats returns the current balance lookup queue statistics.

func (*TxIndexer) GetDebugStats added in v1.20.4

func (t *TxIndexer) GetDebugStats() *TxIndexerDebugStats

GetDebugStats returns current debug statistics.

func (*TxIndexer) GetMode added in v1.20.3

func (t *TxIndexer) GetMode() IndexingMode

GetMode returns the current indexing mode.

func (*TxIndexer) GetPruningStatus added in v1.24.1

func (t *TxIndexer) GetPruningStatus() ElPruningStatus

GetPruningStatus returns a copy of the current pruning status for display.

func (*TxIndexer) GetReadyClients

func (t *TxIndexer) GetReadyClients() []*elclients.Client

GetReadyClients returns a list of ready EL clients that have reached the finalized block. Prefers archive clients if available.

func (*TxIndexer) GetSyncEpoch

func (t *TxIndexer) GetSyncEpoch() phase0.Epoch

GetSyncEpoch returns the current sync epoch.

func (*TxIndexer) QueueAddressBalanceLookups

func (t *TxIndexer) QueueAddressBalanceLookups(accountID uint64, address []byte)

QueueAddressBalanceLookups queues all balance lookups for an address page view. This is called by the address handler when a user views an address page. The lookups are rate-limited to prevent excessive RPC calls.

func (*TxIndexer) Start

func (t *TxIndexer) Start() error

Start begins the tx indexer processing.

func (*TxIndexer) Stop

func (t *TxIndexer) Stop() error

Stop halts the tx indexer processing.

type TxIndexerDebugStats added in v1.20.4

type TxIndexerDebugStats struct {
	Mode               string
	Running            bool
	SyncEpoch          uint64
	HighPrioQueueLen   int
	LowPrioQueueLen    int
	BalanceHighPrioLen int
	BalanceLowPrioLen  int
}

TxIndexerDebugStats holds debug statistics for the tx indexer.

type WithdrawalData

type WithdrawalData struct {
	Index     uint64
	Validator uint64
	Address   common.Address
	Amount    uint64 // Amount in Gwei
}

WithdrawalData represents a withdrawal from the beacon chain

Jump to

Keyboard shortcuts

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