db

package
v1.20.4 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const MaxAccountInternalTxCount = 100000

MaxAccountInternalTxCount is the maximum count returned for address internal transaction queries. If the actual count exceeds this, the query returns this limit and sets the "more" flag.

View Source
const MaxAccountTokenTransferCount = 100000

MaxAccountTokenTransferCount is the maximum count returned for address token transfer queries. If the actual count exceeds this, the query returns this limit and sets the "more" flag.

View Source
const MaxAccountTransactionCount = 100000

MaxAccountTransactionCount is the maximum count returned for address transaction queries. If the actual count exceeds this, the query returns this limit and sets the "more" flag.

View Source
const MaxAccountWithdrawalCount = 100000

MaxAccountWithdrawalCount is the maximum count returned for address withdrawal queries.

Variables

View Source
var DBPGX *pgxpool.Conn

DB is a pointer to the explorer-database

View Source
var EmbedPgsqlSchema embed.FS
View Source
var EmbedSqliteSchema embed.FS
View Source
var ReaderDb *sqlx.DB

Functions

func ApplyEmbeddedDbSchema

func ApplyEmbeddedDbSchema(version int64) error

func ConvertInt64ToUint64 added in v1.14.0

func ConvertInt64ToUint64(i int64) uint64

ConvertInt64ToUint64 converts an int64 to a uint64, supporting the full range of int64, but the value is translated to the range of uint64.

func ConvertUint64ToInt64 added in v1.14.0

func ConvertUint64ToInt64(u uint64) int64

ConvertUint64ToInt64 converts a uint64 to an int64, supporting the full range of uint64, but the value is translated to the range of int64.

func DeleteElAccount added in v1.19.9

func DeleteElAccount(ctx context.Context, dbTx *sqlx.Tx, id uint64) error

func DeleteElBalance added in v1.19.9

func DeleteElBalance(ctx context.Context, dbTx *sqlx.Tx, accountID uint64, tokenID uint64) error

func DeleteElBalancesByAccountID added in v1.19.9

func DeleteElBalancesByAccountID(ctx context.Context, dbTx *sqlx.Tx, accountID uint64) error

func DeleteElBalancesByTokenID added in v1.19.9

func DeleteElBalancesByTokenID(ctx context.Context, dbTx *sqlx.Tx, tokenID uint64) error

func DeleteElBlock added in v1.19.9

func DeleteElBlock(ctx context.Context, dbTx *sqlx.Tx, blockUid uint64) error

func DeleteElToken added in v1.19.9

func DeleteElToken(ctx context.Context, dbTx *sqlx.Tx, id uint64) error

func DeleteElTokenTransfer added in v1.19.9

func DeleteElTokenTransfer(ctx context.Context, dbTx *sqlx.Tx, blockUid uint64, txHash []byte, txIdx uint32) error

func DeleteElTokenTransfersByBlockUid added in v1.19.9

func DeleteElTokenTransfersByBlockUid(ctx context.Context, dbTx *sqlx.Tx, blockUid uint64) error

func DeleteElTokenTransfersByTokenID added in v1.19.9

func DeleteElTokenTransfersByTokenID(ctx context.Context, dbTx *sqlx.Tx, tokenID uint64) error

func DeleteElTokenTransfersByTxHash added in v1.19.9

func DeleteElTokenTransfersByTxHash(ctx context.Context, dbTx *sqlx.Tx, txHash []byte) error

func DeleteElTransaction added in v1.19.9

func DeleteElTransaction(ctx context.Context, dbTx *sqlx.Tx, blockUid uint64, txHash []byte) error

func DeleteElTransactionsByBlockUid added in v1.19.9

func DeleteElTransactionsByBlockUid(ctx context.Context, dbTx *sqlx.Tx, blockUid uint64) error

func DeleteElWithdrawal added in v1.19.9

func DeleteElWithdrawal(ctx context.Context, dbTx *sqlx.Tx, blockUid uint64, blockIndex uint16) error

func DeleteElWithdrawalsByBlockUid added in v1.19.9

func DeleteElWithdrawalsByBlockUid(ctx context.Context, dbTx *sqlx.Tx, blockUid uint64) error

func DeleteElZeroBalances added in v1.19.9

func DeleteElZeroBalances(ctx context.Context, dbTx *sqlx.Tx) (int64, error)

DeleteElZeroBalances deletes all balance entries with zero balance. Returns the number of deleted rows.

func DeleteFinalizedForks added in v1.11.0

func DeleteFinalizedForks(ctx context.Context, tx *sqlx.Tx, finalizedRoots [][]byte) error

func DeletePendingFunctionSignatures

func DeletePendingFunctionSignatures(ctx context.Context, tx *sqlx.Tx, sigBytes []types.TxSignatureBytes) error

func DeleteUnfinalizedBlocksBefore added in v1.11.0

func DeleteUnfinalizedBlocksBefore(ctx context.Context, tx *sqlx.Tx, slot uint64) error

func DeleteUnfinalizedDutiesBefore added in v1.11.0

func DeleteUnfinalizedDutiesBefore(ctx context.Context, tx *sqlx.Tx, epoch uint64) error

func DeleteUnfinalizedEpochsBefore added in v1.14.0

func DeleteUnfinalizedEpochsBefore(ctx context.Context, tx *sqlx.Tx, epoch uint64) error

func DeleteValidatorNames

func DeleteValidatorNames(ctx context.Context, tx *sqlx.Tx, validatorNames []uint64) error

func EngineQuery

func EngineQuery(queryMap map[dbtypes.DBEngineType]string) string

func GetBlob

func GetBlob(ctx context.Context, commitment []byte, withData bool) *dbtypes.Blob

func GetBlockHeadByRoot added in v1.11.0

func GetBlockHeadByRoot(ctx context.Context, root []byte) *dbtypes.BlockHead

func GetBlockHeadBySlot added in v1.15.0

func GetBlockHeadBySlot(ctx context.Context, slot uint64) *dbtypes.BlockHead

func GetBlockHeadBySlotRange added in v1.19.9

func GetBlockHeadBySlotRange(ctx context.Context, startSlot uint64, endSlot uint64) []*dbtypes.BlockHead

func GetConsolidationRequestTxsByDequeueRange added in v1.12.1

func GetConsolidationRequestTxsByDequeueRange(ctx context.Context, dequeueFirst uint64, dequeueLast uint64) []*dbtypes.ConsolidationRequestTx

func GetConsolidationRequestTxsByTxHashes added in v1.12.1

func GetConsolidationRequestTxsByTxHashes(ctx context.Context, txHashes [][]byte) []*dbtypes.ConsolidationRequestTx

func GetConsolidationRequestTxsFiltered added in v1.12.1

func GetConsolidationRequestTxsFiltered(ctx context.Context, offset uint64, limit uint32, canonicalForkIds []uint64, filter *dbtypes.ConsolidationRequestTxFilter) ([]*dbtypes.ConsolidationRequestTx, uint64, error)

func GetConsolidationRequestsByElBlockRange added in v1.12.1

func GetConsolidationRequestsByElBlockRange(ctx context.Context, firstSlot uint64, lastSlot uint64) []*dbtypes.ConsolidationRequest

func GetConsolidationRequestsFiltered added in v1.12.0

func GetConsolidationRequestsFiltered(ctx context.Context, offset uint64, limit uint32, canonicalForkIds []uint64, filter *dbtypes.ConsolidationRequestFilter) ([]*dbtypes.ConsolidationRequest, uint64, error)

func GetDatabaseSize added in v1.20.4

func GetDatabaseSize() (int64, error)

GetDatabaseSize returns the total database size in bytes.

func GetDepositTxs

func GetDepositTxs(ctx context.Context, firstIndex uint64, limit uint32) []*dbtypes.DepositTx

func GetDepositTxsByIndexes added in v1.15.0

func GetDepositTxsByIndexes(ctx context.Context, indexes []uint64) []*dbtypes.DepositTx

func GetDepositTxsFiltered

func GetDepositTxsFiltered(ctx context.Context, offset uint64, limit uint32, canonicalForkIds []uint64, filter *dbtypes.DepositTxFilter) ([]*dbtypes.DepositTx, uint64, error)

func GetDepositsFiltered

func GetDepositsFiltered(ctx context.Context, offset uint64, limit uint32, canonicalForkIds []uint64, filter *dbtypes.DepositFilter, txFilter *dbtypes.DepositTxFilter) ([]*dbtypes.DepositWithTx, uint64, error)

func GetElAccountByAddress added in v1.19.9

func GetElAccountByAddress(ctx context.Context, address []byte) (*dbtypes.ElAccount, error)

func GetElAccountByID added in v1.19.9

func GetElAccountByID(ctx context.Context, id uint64) (*dbtypes.ElAccount, error)

func GetElAccountsByAddresses added in v1.20.0

func GetElAccountsByAddresses(ctx context.Context, addresses [][]byte) (map[string]*dbtypes.ElAccount, error)

GetElAccountsByAddresses retrieves multiple accounts by their addresses in a single query. Returns a map from address (as hex string) to account for efficient lookup.

func GetElAccountsByFunder added in v1.19.9

func GetElAccountsByFunder(ctx context.Context, funderID uint64, offset uint64, limit uint32) ([]*dbtypes.ElAccount, uint64, error)

func GetElAccountsByIDs added in v1.19.9

func GetElAccountsByIDs(ctx context.Context, ids []uint64) ([]*dbtypes.ElAccount, error)

GetElAccountsByIDs retrieves multiple accounts by their IDs in a single query.

func GetElAccountsFiltered added in v1.19.9

func GetElAccountsFiltered(ctx context.Context, offset uint64, limit uint32, filter *dbtypes.ElAccountFilter) ([]*dbtypes.ElAccount, uint64, error)

func GetElBalance added in v1.19.9

func GetElBalance(ctx context.Context, accountID uint64, tokenID uint64) (*dbtypes.ElBalance, error)

func GetElBalancesByAccountID added in v1.19.9

func GetElBalancesByAccountID(ctx context.Context, accountID uint64, offset uint64, limit uint32) ([]*dbtypes.ElBalance, uint64, error)

func GetElBalancesByTokenID added in v1.19.9

func GetElBalancesByTokenID(ctx context.Context, tokenID uint64, offset uint64, limit uint32) ([]*dbtypes.ElBalance, uint64, error)

func GetElBalancesFiltered added in v1.19.9

func GetElBalancesFiltered(ctx context.Context, offset uint64, limit uint32, accountID uint64, filter *dbtypes.ElBalanceFilter) ([]*dbtypes.ElBalance, uint64, error)

func GetElBlock added in v1.19.9

func GetElBlock(ctx context.Context, blockUid uint64) (*dbtypes.ElBlock, error)

func GetElBlocksByUids added in v1.19.9

func GetElBlocksByUids(ctx context.Context, blockUids []uint64) ([]*dbtypes.ElBlock, error)

func GetElEventIndexCountByTxHash added in v1.20.4

func GetElEventIndexCountByTxHash(ctx context.Context, txHash []byte) (uint64, error)

GetElEventIndexCountByTxHash returns the number of event index entries for a given transaction hash. Uses an index-only scan for fast counting.

func GetElEventIndicesBySource added in v1.20.3

func GetElEventIndicesBySource(
	ctx context.Context,
	sourceID uint64,
	offset uint64,
	limit uint32,
) ([]*dbtypes.ElEventIndex, uint64, error)

GetElEventIndicesBySource returns event index entries for a given source contract, ordered by block_uid DESC.

func GetElEventIndicesByTopic1 added in v1.20.3

func GetElEventIndicesByTopic1(
	ctx context.Context,
	topic1 []byte,
	offset uint64,
	limit uint32,
) ([]*dbtypes.ElEventIndex, uint64, error)

GetElEventIndicesByTopic1 returns event index entries for a given event signature (topic1), ordered by block_uid DESC.

func GetElEventIndicesByTxHash added in v1.20.3

func GetElEventIndicesByTxHash(ctx context.Context, txHash []byte) ([]*dbtypes.ElEventIndex, error)

GetElEventIndicesByTxHash returns all event index entries for a given transaction hash.

func GetElTokenByContract added in v1.19.9

func GetElTokenByContract(ctx context.Context, contract []byte) (*dbtypes.ElToken, error)

func GetElTokenByID added in v1.19.9

func GetElTokenByID(ctx context.Context, id uint64) (*dbtypes.ElToken, error)

func GetElTokenTransfer added in v1.19.9

func GetElTokenTransfer(ctx context.Context, blockUid uint64, txHash []byte, txIdx uint32) (*dbtypes.ElTokenTransfer, error)

func GetElTokenTransferCountByBlockUidAndTxHash added in v1.20.4

func GetElTokenTransferCountByBlockUidAndTxHash(ctx context.Context, blockUid uint64, txHash []byte) (uint64, error)

GetElTokenTransferCountByBlockUidAndTxHash returns the number of token transfers for a given block UID and transaction hash.

func GetElTokenTransfersByAccountID added in v1.19.9

func GetElTokenTransfersByAccountID(ctx context.Context, accountID uint64, isFrom bool, offset uint64, limit uint32) ([]*dbtypes.ElTokenTransfer, uint64, error)

func GetElTokenTransfersByAccountIDCombined added in v1.19.9

func GetElTokenTransfersByAccountIDCombined(ctx context.Context, accountID uint64, tokenTypes []uint8, offset uint64, limit uint32) ([]*dbtypes.ElTokenTransfer, uint64, bool, error)

GetElTokenTransfersByAccountIDCombined returns all token transfers where the account is either sender or receiver. Results are sorted by block_uid DESC, tx_pos DESC, tx_idx DESC. tokenTypes filters by token type (empty = all types). Returns transfers, total count (capped at MaxAccountTokenTransferCount), whether count is capped, and error.

func GetElTokenTransfersByBlockUid added in v1.19.9

func GetElTokenTransfersByBlockUid(ctx context.Context, blockUid uint64) ([]*dbtypes.ElTokenTransfer, error)

func GetElTokenTransfersByBlockUidAndTxHash added in v1.19.9

func GetElTokenTransfersByBlockUidAndTxHash(ctx context.Context, blockUid uint64, txHash []byte) ([]*dbtypes.ElTokenTransfer, error)

func GetElTokenTransfersByTokenID added in v1.19.9

func GetElTokenTransfersByTokenID(ctx context.Context, tokenID uint64, offset uint64, limit uint32) ([]*dbtypes.ElTokenTransfer, uint64, error)

func GetElTokenTransfersByTxHash added in v1.19.9

func GetElTokenTransfersByTxHash(ctx context.Context, txHash []byte) ([]*dbtypes.ElTokenTransfer, error)

func GetElTokenTransfersFiltered added in v1.19.9

func GetElTokenTransfersFiltered(ctx context.Context, offset uint64, limit uint32, filter *dbtypes.ElTokenTransferFilter) ([]*dbtypes.ElTokenTransfer, uint64, error)

func GetElTokens added in v1.19.9

func GetElTokens(ctx context.Context, offset uint64, limit uint32) ([]*dbtypes.ElToken, uint64, error)

func GetElTokensByContracts added in v1.20.0

func GetElTokensByContracts(ctx context.Context, contracts [][]byte) (map[string]*dbtypes.ElToken, error)

GetElTokensByContracts retrieves multiple tokens by their contract addresses in a single query. Returns a map from contract address (as hex string) to token for efficient lookup.

func GetElTokensByIDs added in v1.19.9

func GetElTokensByIDs(ctx context.Context, ids []uint64) ([]*dbtypes.ElToken, error)

GetElTokensByIDs retrieves multiple tokens by their IDs in a single query.

func GetElTokensFiltered added in v1.19.9

func GetElTokensFiltered(ctx context.Context, offset uint64, limit uint32, filter *dbtypes.ElTokenFilter) ([]*dbtypes.ElToken, uint64, error)

func GetElTransaction added in v1.19.9

func GetElTransaction(ctx context.Context, blockUid uint64, txHash []byte) (*dbtypes.ElTransaction, error)

func GetElTransactionsByAccountID added in v1.19.9

func GetElTransactionsByAccountID(ctx context.Context, accountID uint64, isFrom bool, offset uint64, limit uint32) ([]*dbtypes.ElTransaction, uint64, error)

func GetElTransactionsByAccountIDCombined added in v1.19.9

func GetElTransactionsByAccountIDCombined(ctx context.Context, accountID uint64, offset uint64, limit uint32) ([]*dbtypes.ElTransaction, uint64, bool, error)

GetElTransactionsByAccountIDCombined fetches transactions where the account is either sender (from_id) or receiver (to_id). Results are sorted by block_uid DESC, tx_index DESC. Returns transactions, total count (capped at MaxAccountTransactionCount), whether count is capped, and error.

func GetElTransactionsByBlockUid added in v1.19.9

func GetElTransactionsByBlockUid(ctx context.Context, blockUid uint64) ([]*dbtypes.ElTransaction, error)

func GetElTransactionsByHash added in v1.19.9

func GetElTransactionsByHash(ctx context.Context, txHash []byte) ([]*dbtypes.ElTransaction, error)

func GetElTransactionsByHashes added in v1.20.3

func GetElTransactionsByHashes(ctx context.Context, txHashes [][]byte) ([]*dbtypes.ElTransaction, error)

GetElTransactionsByHashes returns all transaction records matching the given tx hashes. May return multiple records per hash if the tx appears in multiple blocks (reorgs).

func GetElTransactionsFiltered added in v1.19.9

func GetElTransactionsFiltered(ctx context.Context, offset uint64, limit uint32, filter *dbtypes.ElTransactionFilter) ([]*dbtypes.ElTransaction, uint64, error)

func GetElTransactionsInternalByAccount added in v1.20.3

func GetElTransactionsInternalByAccount(
	ctx context.Context,
	accountID uint64,
	offset uint64,
	limit uint32,
) ([]*dbtypes.ElTransactionInternal, uint64, error)

GetElTransactionsInternalByAccount returns internal transactions involving the given account (as sender or receiver), ordered by block_uid DESC. Uses UNION ALL instead of OR to enable index scans on the composite indexes (from_id, block_uid DESC) and (to_id, block_uid DESC). NULLS LAST is required to match the index definition and enable index scans.

func GetElTransactionsInternalByTxHash added in v1.20.3

func GetElTransactionsInternalByTxHash(ctx context.Context, txHash []byte) ([]*dbtypes.ElTransactionInternal, error)

GetElTransactionsInternalByTxHash returns all internal transactions for a given transaction hash.

func GetElTransactionsInternalCountByTxHash added in v1.20.4

func GetElTransactionsInternalCountByTxHash(ctx context.Context, txHash []byte) (uint64, error)

GetElTransactionsInternalCountByTxHash returns the number of internal transactions for a given transaction hash. Uses an index-only scan.

func GetElWithdrawal added in v1.19.9

func GetElWithdrawal(ctx context.Context, blockUid uint64, blockIndex uint16) (*dbtypes.ElWithdrawal, error)

func GetElWithdrawalsByAccountID added in v1.19.9

func GetElWithdrawalsByAccountID(ctx context.Context, accountID uint64, offset uint64, limit uint32) ([]*dbtypes.ElWithdrawal, uint64, error)

func GetElWithdrawalsByBlockUid added in v1.19.9

func GetElWithdrawalsByBlockUid(ctx context.Context, blockUid uint64) ([]*dbtypes.ElWithdrawal, error)

func GetElWithdrawalsFiltered added in v1.19.9

func GetElWithdrawalsFiltered(ctx context.Context, offset uint64, limit uint32, filter *dbtypes.ElWithdrawalFilter) ([]*dbtypes.ElWithdrawal, uint64, error)

func GetEpochs

func GetEpochs(ctx context.Context, firstEpoch uint64, limit uint32) []*dbtypes.Epoch

func GetExplorerState

func GetExplorerState(ctx context.Context, key string, returnValue interface{}) (interface{}, error)

func GetFilteredSlots

func GetFilteredSlots(ctx context.Context, filter *dbtypes.BlockFilter, firstSlot uint64, offset uint64, limit uint32) []*dbtypes.AssignedSlot

func GetForkBlockCounts added in v1.18.3

func GetForkBlockCounts(ctx context.Context, startSlot uint64, endSlot uint64) (map[uint64]uint64, error)

GetForkBlockCounts returns the number of blocks for each fork ID

func GetForkById added in v1.12.1

func GetForkById(ctx context.Context, forkId uint64) *dbtypes.Fork

func GetForkVisualizationData added in v1.18.3

func GetForkVisualizationData(ctx context.Context, startSlot uint64, endSlot uint64) ([]*dbtypes.Fork, error)

func GetHighestMevBlockSlotByRelay

func GetHighestMevBlockSlotByRelay(ctx context.Context, relayId uint8) (uint64, error)

func GetHighestRootBeforeSlot

func GetHighestRootBeforeSlot(ctx context.Context, slot uint64, withOrphaned bool) []byte

func GetLatestBlobAssignment

func GetLatestBlobAssignment(ctx context.Context, commitment []byte) *dbtypes.BlobAssignment

func GetLatestElBlockSlot added in v1.20.4

func GetLatestElBlockSlot() (uint64, error)

GetLatestElBlockSlot returns the slot of the most recently indexed EL block.

func GetMaxValidatorIndex added in v1.14.0

func GetMaxValidatorIndex(ctx context.Context) (uint64, error)

GetMaxValidatorIndex returns the highest validator index in the database

func GetMevBlockByBlockHash

func GetMevBlockByBlockHash(ctx context.Context, blockHash []byte) *dbtypes.MevBlock

func GetMevBlocksByBlockHashes added in v1.16.0

func GetMevBlocksByBlockHashes(ctx context.Context, blockHashes [][]byte) map[string]*dbtypes.MevBlock

GetMevBlocksByBlockHashes retrieves multiple MEV blocks in a single database query for better performance

func GetMevBlocksFiltered

func GetMevBlocksFiltered(ctx context.Context, offset uint64, limit uint32, filter *dbtypes.MevBlockFilter) ([]*dbtypes.MevBlock, uint64, error)

func GetNewestElBlockUid added in v1.19.9

func GetNewestElBlockUid(ctx context.Context) (uint64, error)

GetNewestElBlockUid returns the newest (maximum) block_uid in the el_blocks table. Returns 0 if no blocks exist.

func GetOldestElBlockUid added in v1.19.9

func GetOldestElBlockUid(ctx context.Context) (uint64, error)

GetOldestElBlockUid returns the oldest (minimum) block_uid in the el_blocks table. Returns 0 if no blocks exist.

func GetOldestElBlocksWithData added in v1.20.3

func GetOldestElBlocksWithData(ctx context.Context, limit uint32) ([]*dbtypes.ElBlock, error)

GetOldestElBlocksWithData returns the oldest blocks that have blockdb data, ordered by block_uid ascending.

func GetOrphanedBlock

func GetOrphanedBlock(ctx context.Context, root []byte) *dbtypes.OrphanedBlock

func GetOrphanedEpoch added in v1.18.3

func GetOrphanedEpoch(ctx context.Context, epoch uint64, headRoot []byte) *dbtypes.OrphanedEpoch

func GetPendingFunctionSignatures

func GetPendingFunctionSignatures(ctx context.Context, limit uint64) []*dbtypes.TxPendingFunctionSignature

func GetSlashingForValidator

func GetSlashingForValidator(ctx context.Context, validator uint64) *dbtypes.Slashing

func GetSlashingsFiltered

func GetSlashingsFiltered(ctx context.Context, offset uint64, limit uint32, finalizedBlock uint64, filter *dbtypes.SlashingFilter) ([]*dbtypes.Slashing, uint64, error)

func GetSlotAssignment

func GetSlotAssignment(ctx context.Context, slot uint64) uint64

func GetSlotBlobCountByExecutionHashes added in v1.18.3

func GetSlotBlobCountByExecutionHashes(ctx context.Context, blockHashes [][]byte) []*dbtypes.BlockBlobCount

func GetSlotByRoot

func GetSlotByRoot(ctx context.Context, root []byte) *dbtypes.Slot

func GetSlotStatus

func GetSlotStatus(ctx context.Context, blockRoots [][]byte) []*dbtypes.BlockStatus

func GetSlotsByBlockHash

func GetSlotsByBlockHash(ctx context.Context, blockHash []byte) []*dbtypes.Slot

func GetSlotsByParentRoot

func GetSlotsByParentRoot(ctx context.Context, parentRoot []byte) []*dbtypes.Slot

func GetSlotsByRoots added in v1.11.1

func GetSlotsByRoots(ctx context.Context, roots [][]byte) map[phase0.Root]*dbtypes.Slot

func GetSlotsRange

func GetSlotsRange(ctx context.Context, firstSlot uint64, lastSlot uint64, withMissing bool, withOrphaned bool) []*dbtypes.AssignedSlot

func GetSyncAssignmentsForPeriod

func GetSyncAssignmentsForPeriod(ctx context.Context, period uint64) []uint64

func GetSyncCommitteeParticipation added in v1.18.3

func GetSyncCommitteeParticipation(ctx context.Context, slot uint64) (float64, error)

func GetTotalElBlockDataSize added in v1.20.3

func GetTotalElBlockDataSize(ctx context.Context) (int64, error)

GetTotalElBlockDataSize returns the total data_size across all el_blocks.

func GetTxFunctionSignaturesByBytes

func GetTxFunctionSignaturesByBytes(ctx context.Context, sigBytes []types.TxSignatureBytes) []*dbtypes.TxFunctionSignature

func GetUnfinalizedBlock

func GetUnfinalizedBlock(ctx context.Context, root []byte) *dbtypes.UnfinalizedBlock

func GetUnfinalizedDuty added in v1.11.0

func GetUnfinalizedDuty(ctx context.Context, epoch uint64, dependentRoot []byte) *dbtypes.UnfinalizedDuty

func GetUnfinalizedEpoch

func GetUnfinalizedEpoch(ctx context.Context, epoch uint64, headRoot []byte) *dbtypes.UnfinalizedEpoch

func GetUnfinalizedForks added in v1.11.0

func GetUnfinalizedForks(ctx context.Context, finalizedSlot uint64) []*dbtypes.Fork

func GetUnknownFunctionSignatures

func GetUnknownFunctionSignatures(ctx context.Context, sigBytes []types.TxSignatureBytes) []*dbtypes.TxUnknownFunctionSignature

func GetValidatorByIndex added in v1.14.0

func GetValidatorByIndex(ctx context.Context, index phase0.ValidatorIndex) *dbtypes.Validator

GetValidatorByIndex returns a validator by index

func GetValidatorByPubkey added in v1.14.0

func GetValidatorByPubkey(ctx context.Context, pubkey []byte) *dbtypes.Validator

GetValidatorByPubkey returns a validator by pubkey

func GetValidatorIndexesByFilter added in v1.14.0

func GetValidatorIndexesByFilter(ctx context.Context, filter dbtypes.ValidatorFilter, currentEpoch uint64) ([]uint64, error)

GetValidatorIndexesByFilter returns validator indexes matching a filter

func GetValidatorNames

func GetValidatorNames(ctx context.Context, minIdx uint64, maxIdx uint64) []*dbtypes.ValidatorName

func GetValidatorRange added in v1.14.0

func GetValidatorRange(ctx context.Context, startIndex uint64, endIndex uint64) []*dbtypes.Validator

GetValidatorRange returns validators in a given index range

func GetVoluntaryExitForValidator

func GetVoluntaryExitForValidator(ctx context.Context, validator uint64) *dbtypes.VoluntaryExit

func GetVoluntaryExitsFiltered

func GetVoluntaryExitsFiltered(ctx context.Context, offset uint64, limit uint32, finalizedBlock uint64, filter *dbtypes.VoluntaryExitFilter) ([]*dbtypes.VoluntaryExit, uint64, error)

func GetWithdrawalRequestTxsByDequeueRange added in v1.12.1

func GetWithdrawalRequestTxsByDequeueRange(ctx context.Context, dequeueFirst uint64, dequeueLast uint64) []*dbtypes.WithdrawalRequestTx

func GetWithdrawalRequestTxsByTxHashes added in v1.12.1

func GetWithdrawalRequestTxsByTxHashes(ctx context.Context, txHashes [][]byte) []*dbtypes.WithdrawalRequestTx

func GetWithdrawalRequestTxsFiltered added in v1.12.1

func GetWithdrawalRequestTxsFiltered(ctx context.Context, offset uint64, limit uint32, canonicalForkIds []uint64, filter *dbtypes.WithdrawalRequestTxFilter) ([]*dbtypes.WithdrawalRequestTx, uint64, error)

func GetWithdrawalRequestsByElBlockRange added in v1.12.1

func GetWithdrawalRequestsByElBlockRange(ctx context.Context, firstSlot uint64, lastSlot uint64) []*dbtypes.WithdrawalRequest

func GetWithdrawalRequestsFiltered added in v1.11.0

func GetWithdrawalRequestsFiltered(ctx context.Context, offset uint64, limit uint32, canonicalForkIds []uint64, filter *dbtypes.WithdrawalRequestFilter) ([]*dbtypes.WithdrawalRequest, uint64, error)

func HasElTransactionsInternalByAccount added in v1.20.4

func HasElTransactionsInternalByAccount(ctx context.Context, accountID uint64) (bool, error)

HasElTransactionsInternalByAccount returns true if the given account has any internal transactions (as sender or receiver). Uses EXISTS for O(1) lookup.

func HasElWithdrawalsByAccountID added in v1.20.4

func HasElWithdrawalsByAccountID(ctx context.Context, accountID uint64) (bool, error)

HasElWithdrawalsByAccountID returns true if the given account has any withdrawals or fee recipient rewards. Uses EXISTS for O(1) lookup.

func InsertBlob

func InsertBlob(ctx context.Context, tx *sqlx.Tx, blob *dbtypes.Blob) error

func InsertBlobAssignment

func InsertBlobAssignment(ctx context.Context, tx *sqlx.Tx, blobAssignment *dbtypes.BlobAssignment) error

func InsertConsolidationRequestTxs added in v1.12.1

func InsertConsolidationRequestTxs(ctx context.Context, tx *sqlx.Tx, consolidationTxs []*dbtypes.ConsolidationRequestTx) error

func InsertConsolidationRequests added in v1.11.0

func InsertConsolidationRequests(ctx context.Context, tx *sqlx.Tx, consolidations []*dbtypes.ConsolidationRequest) error

func InsertDepositTxs

func InsertDepositTxs(ctx context.Context, tx *sqlx.Tx, depositTxs []*dbtypes.DepositTx) error

func InsertDeposits

func InsertDeposits(ctx context.Context, tx *sqlx.Tx, deposits []*dbtypes.Deposit) error

func InsertElAccount added in v1.19.9

func InsertElAccount(ctx context.Context, dbTx *sqlx.Tx, account *dbtypes.ElAccount) (uint64, error)

func InsertElBalances added in v1.19.9

func InsertElBalances(ctx context.Context, dbTx *sqlx.Tx, balances []*dbtypes.ElBalance) error

func InsertElBlock added in v1.19.9

func InsertElBlock(ctx context.Context, dbTx *sqlx.Tx, block *dbtypes.ElBlock) error

func InsertElEventIndices added in v1.20.3

func InsertElEventIndices(ctx context.Context, dbTx *sqlx.Tx, entries []*dbtypes.ElEventIndex) error

InsertElEventIndices inserts event index entries in batch.

func InsertElToken added in v1.19.9

func InsertElToken(ctx context.Context, dbTx *sqlx.Tx, token *dbtypes.ElToken) (uint64, error)

func InsertElTokenTransfers added in v1.19.9

func InsertElTokenTransfers(ctx context.Context, dbTx *sqlx.Tx, transfers []*dbtypes.ElTokenTransfer) error

func InsertElTransactions added in v1.19.9

func InsertElTransactions(ctx context.Context, dbTx *sqlx.Tx, txs []*dbtypes.ElTransaction) error

func InsertElTransactionsInternal added in v1.20.3

func InsertElTransactionsInternal(ctx context.Context, dbTx *sqlx.Tx, entries []*dbtypes.ElTransactionInternal) error

InsertElTransactionsInternal inserts internal transaction index entries in batch.

func InsertElWithdrawals added in v1.19.9

func InsertElWithdrawals(ctx context.Context, dbTx *sqlx.Tx, withdrawals []*dbtypes.ElWithdrawal) error

func InsertEpoch

func InsertEpoch(ctx context.Context, tx *sqlx.Tx, epoch *dbtypes.Epoch) error

func InsertFork added in v1.11.0

func InsertFork(ctx context.Context, tx *sqlx.Tx, fork *dbtypes.Fork) error

func InsertMevBlocks

func InsertMevBlocks(ctx context.Context, tx *sqlx.Tx, mevBlocks []*dbtypes.MevBlock) error

func InsertMissingSlot

func InsertMissingSlot(ctx context.Context, tx *sqlx.Tx, block *dbtypes.SlotHeader) error

func InsertOrphanedBlock

func InsertOrphanedBlock(ctx context.Context, tx *sqlx.Tx, block *dbtypes.OrphanedBlock) error

func InsertOrphanedEpoch added in v1.18.3

func InsertOrphanedEpoch(ctx context.Context, tx *sqlx.Tx, epoch *dbtypes.OrphanedEpoch) error

func InsertPendingFunctionSignatures

func InsertPendingFunctionSignatures(ctx context.Context, tx *sqlx.Tx, txPendingSigs []*dbtypes.TxPendingFunctionSignature) error

func InsertSlashings

func InsertSlashings(ctx context.Context, tx *sqlx.Tx, slashings []*dbtypes.Slashing) error

func InsertSlot

func InsertSlot(ctx context.Context, tx *sqlx.Tx, slot *dbtypes.Slot) error

func InsertSyncAssignments

func InsertSyncAssignments(ctx context.Context, tx *sqlx.Tx, syncAssignments []*dbtypes.SyncAssignment) error

func InsertTxFunctionSignature

func InsertTxFunctionSignature(ctx context.Context, tx *sqlx.Tx, txFuncSig *dbtypes.TxFunctionSignature) error

func InsertUnfinalizedBlock

func InsertUnfinalizedBlock(ctx context.Context, tx *sqlx.Tx, block *dbtypes.UnfinalizedBlock) error

func InsertUnfinalizedDuty added in v1.11.0

func InsertUnfinalizedDuty(ctx context.Context, tx *sqlx.Tx, duty *dbtypes.UnfinalizedDuty) error

func InsertUnfinalizedEpoch

func InsertUnfinalizedEpoch(ctx context.Context, tx *sqlx.Tx, epoch *dbtypes.UnfinalizedEpoch) error

func InsertUnknownFunctionSignatures

func InsertUnknownFunctionSignatures(ctx context.Context, tx *sqlx.Tx, txUnknownSigs []*dbtypes.TxUnknownFunctionSignature) error

func InsertValidator added in v1.14.0

func InsertValidator(ctx context.Context, tx *sqlx.Tx, validator *dbtypes.Validator) error

InsertValidator inserts a single validator into the database

func InsertValidatorBatch added in v1.14.0

func InsertValidatorBatch(ctx context.Context, tx *sqlx.Tx, validators []*dbtypes.Validator) error

InsertValidatorBatch inserts multiple validators in a batch

func InsertValidatorNames

func InsertValidatorNames(ctx context.Context, tx *sqlx.Tx, validatorNames []*dbtypes.ValidatorName) error

func InsertVoluntaryExits

func InsertVoluntaryExits(ctx context.Context, tx *sqlx.Tx, voluntaryExits []*dbtypes.VoluntaryExit) error

func InsertWithdrawalRequestTxs added in v1.12.1

func InsertWithdrawalRequestTxs(ctx context.Context, tx *sqlx.Tx, withdrawalTxs []*dbtypes.WithdrawalRequestTx) error

func InsertWithdrawalRequests added in v1.11.0

func InsertWithdrawalRequests(ctx context.Context, tx *sqlx.Tx, elRequests []*dbtypes.WithdrawalRequest) error

func IsEpochSynchronized

func IsEpochSynchronized(ctx context.Context, epoch uint64) bool

func IsSyncCommitteeSynchronized

func IsSyncCommitteeSynchronized(ctx context.Context, period uint64) bool

func MustCloseDB

func MustCloseDB()

func MustInitDB

func MustInitDB(dbcfg *types.DatabaseConfig)

func ResetElBlockDataStatus added in v1.20.3

func ResetElBlockDataStatus(ctx context.Context, dbTx *sqlx.Tx, blockUids []uint64) error

ResetElBlockDataStatus resets data_status and data_size for blocks that have been evicted from blockdb.

func ResetElBlockDataStatusBefore added in v1.20.3

func ResetElBlockDataStatusBefore(ctx context.Context, dbTx *sqlx.Tx, blockUidThreshold uint64) (int64, error)

ResetElBlockDataStatusBefore resets data_status and data_size for all blocks with block_uid below the given threshold (used for time-based pruning).

func RunDBTransaction

func RunDBTransaction(handler func(tx *sqlx.Tx) error) error

func SetExplorerState

func SetExplorerState(ctx context.Context, tx *sqlx.Tx, key string, value interface{}) error

func StreamOrphanedEpochs added in v1.18.3

func StreamOrphanedEpochs(ctx context.Context, epoch uint64, cb func(duty *dbtypes.OrphanedEpoch)) error

func StreamUnfinalizedBlocks added in v1.11.0

func StreamUnfinalizedBlocks(ctx context.Context, slot uint64, cb func(block *dbtypes.UnfinalizedBlock)) error

func StreamUnfinalizedDuties added in v1.11.0

func StreamUnfinalizedDuties(ctx context.Context, epoch uint64, cb func(duty *dbtypes.UnfinalizedDuty)) error

func StreamUnfinalizedEpochs added in v1.11.0

func StreamUnfinalizedEpochs(ctx context.Context, epoch uint64, cb func(duty *dbtypes.UnfinalizedEpoch)) error

func StreamValidatorsByIndexes added in v1.14.0

func StreamValidatorsByIndexes(ctx context.Context, indexes []uint64, cb func(validator *dbtypes.Validator) bool) error

func UpdateConsolidationRequestTxHash added in v1.12.1

func UpdateConsolidationRequestTxHash(ctx context.Context, tx *sqlx.Tx, slotRoot []byte, slotIndex uint64, txHash []byte) error

func UpdateElAccount added in v1.19.9

func UpdateElAccount(ctx context.Context, dbTx *sqlx.Tx, account *dbtypes.ElAccount) error

func UpdateElAccountsLastNonce added in v1.19.9

func UpdateElAccountsLastNonce(ctx context.Context, dbTx *sqlx.Tx, accounts []*dbtypes.ElAccount) error

UpdateElAccountsLastNonce batch updates last_nonce and last_block_uid for multiple accounts by ID. Uses VALUES clause for efficient batch update - 10-50x faster than individual updates.

func UpdateElBalance added in v1.19.9

func UpdateElBalance(ctx context.Context, dbTx *sqlx.Tx, balance *dbtypes.ElBalance) error

func UpdateElBlockDataStatus added in v1.20.3

func UpdateElBlockDataStatus(ctx context.Context, dbTx *sqlx.Tx, blockUid uint64, dataStatus uint16, dataSize int64) error

UpdateElBlockDataStatus updates the data_status and data_size for a block after writing execution data to blockdb.

func UpdateElToken added in v1.19.9

func UpdateElToken(ctx context.Context, dbTx *sqlx.Tx, token *dbtypes.ElToken) error

func UpdateFinalizedForkParents added in v1.11.0

func UpdateFinalizedForkParents(ctx context.Context, tx *sqlx.Tx, finalizedRoots [][]byte) error

func UpdateForkParent added in v1.11.1

func UpdateForkParent(ctx context.Context, tx *sqlx.Tx, parentRoot []byte, parentForkId uint64) error

func UpdateMevBlockByEpoch

func UpdateMevBlockByEpoch(ctx context.Context, tx *sqlx.Tx, epoch uint64, slotsPerEpoch uint64, canonicalHashes [][]byte) error

func UpdateUnfinalizedBlockExecutionTimes added in v1.17.0

func UpdateUnfinalizedBlockExecutionTimes(ctx context.Context, tx *sqlx.Tx, root []byte, minExecTime uint32, maxExecTime uint32, execTimes []byte) error

func UpdateUnfinalizedBlockForkId added in v1.11.0

func UpdateUnfinalizedBlockForkId(ctx context.Context, tx *sqlx.Tx, roots [][]byte, forkId uint64) error

func UpdateUnfinalizedBlockStatus added in v1.11.0

func UpdateUnfinalizedBlockStatus(ctx context.Context, tx *sqlx.Tx, roots [][]byte, blockStatus dbtypes.UnfinalizedBlockStatus) error

func UpdateWithdrawalRequestTxHash added in v1.12.1

func UpdateWithdrawalRequestTxHash(ctx context.Context, tx *sqlx.Tx, slotRoot []byte, slotIndex uint64, txHash []byte) error

Types

type BlobStatistics added in v1.19.5

type BlobStatistics struct {
	BlobsLast1h            uint64
	BlobsLast24h           uint64
	BlobsLast7d            uint64
	BlobsLast18d           uint64
	BlocksWithBlobsLast1h  uint64
	BlocksWithBlobsLast24h uint64
	BlocksWithBlobsLast7d  uint64
	BlocksWithBlobsLast18d uint64
	BlobGasLast1h          uint64
	BlobGasLast24h         uint64
	BlobGasLast7d          uint64
	BlobGasLast18d         uint64
}

func GetBlobStatistics added in v1.19.5

func GetBlobStatistics(ctx context.Context, currentSlot uint64) (*BlobStatistics, error)

type BlockDbStats added in v1.20.4

type BlockDbStats struct {
	BeaconBlockCount int64
	BeaconBlockSize  int64
	ExecDataCount    int64
	ExecDataSize     int64
}

BlockDbStats holds aggregate stats about data stored in the block database.

func GetBlockDbStats added in v1.20.4

func GetBlockDbStats() (*BlockDbStats, error)

GetBlockDbStats returns counts and sizes for beacon blocks and execution data tracked in the database, avoiding expensive S3/Pebble listing.

type CleanupStats added in v1.19.9

type CleanupStats struct {
	ZeroBalancesDeleted   int64
	TransactionsDeleted   int64
	InternalTxsDeleted    int64
	EventIndicesDeleted   int64
	TokenTransfersDeleted int64
	WithdrawalsDeleted    int64
	BlocksDeleted         int64
}

CleanupStats holds statistics from cleanup operations.

func DeleteElDataBeforeBlockUid added in v1.19.9

func DeleteElDataBeforeBlockUid(ctx context.Context, blockUidThreshold uint64, _ *sqlx.Tx) (*CleanupStats, error)

DeleteElDataBeforeBlockUid deletes all EL data (transactions, internal txs, event index, transfers, withdrawals, blocks) with block_uid less than the specified threshold. Returns statistics about deleted rows. Uses batched deletes to avoid long locks - deletes in chunks and commits between batches. Uses default batch size of 50000 rows per batch.

type EpochParticipation added in v1.18.3

type EpochParticipation struct {
	Epoch       uint64 `db:"epoch"`
	BlockCount  uint64 `db:"block_count"`
	Eligible    uint64 `db:"eligible"`
	VotedTarget uint64 `db:"voted_target"`
	VotedHead   uint64 `db:"voted_head"`
	VotedTotal  uint64 `db:"voted_total"`
}

EpochParticipation represents participation data for a finalized canonical epoch

func GetFinalizedEpochParticipation added in v1.18.3

func GetFinalizedEpochParticipation(ctx context.Context, startEpoch, endEpoch uint64) ([]*EpochParticipation, error)

GetFinalizedEpochParticipation gets participation data for finalized canonical epochs in the given range

type ForkParticipationByEpoch added in v1.18.3

type ForkParticipationByEpoch struct {
	ForkId        uint64  `db:"fork_id"`
	Epoch         uint64  `db:"epoch"`
	Participation float64 `db:"avg_participation"`
	SlotCount     uint64  `db:"slot_count"`
}

ForkParticipationByEpoch represents participation data for a fork in a specific epoch

func GetForkParticipationByEpoch added in v1.18.3

func GetForkParticipationByEpoch(ctx context.Context, startEpoch, endEpoch uint64, forkIds []uint64) ([]*ForkParticipationByEpoch, error)

GetForkParticipationByEpoch gets average participation per fork per epoch for the given epoch range This is optimized to fetch all data in one query to avoid expensive repeated queries

type OrphanedEpochParticipation added in v1.18.3

type OrphanedEpochParticipation struct {
	Epoch       uint64 `db:"epoch"`
	HeadForkId  uint64 `db:"epoch_head_fork_id"`
	BlockCount  uint64 `db:"block_count"`
	Eligible    uint64 `db:"eligible"`
	VotedTarget uint64 `db:"voted_target"`
	VotedHead   uint64 `db:"voted_head"`
	VotedTotal  uint64 `db:"voted_total"`
}

OrphanedEpochParticipation represents participation data for an orphaned epoch

func GetOrphanedEpochParticipation added in v1.18.3

func GetOrphanedEpochParticipation(ctx context.Context, startEpoch, endEpoch uint64) ([]*OrphanedEpochParticipation, error)

GetOrphanedEpochParticipation gets participation data for orphaned epochs in the given range

type RecentBlockStats added in v1.20.4

type RecentBlockStats struct {
	BlockCount   int64
	Transactions int64
	Events       int64
	Transfers    int64
	ExecData     int64
	ExecDataSize int64
}

RecentBlockStats holds aggregate stats for a range of recent EL blocks.

func GetRecentElBlockStats added in v1.20.4

func GetRecentElBlockStats(lastN int64) (*RecentBlockStats, error)

GetRecentElBlockStats returns aggregate stats for the most recent N EL blocks.

type TableStats added in v1.20.4

type TableStats struct {
	Name     string
	RowCount int64
	Size     int64 // bytes, -1 if unavailable
}

TableStats holds size information for a database table.

func GetTableStats added in v1.20.4

func GetTableStats() ([]*TableStats, error)

GetTableStats returns row counts and sizes for all known tables.

type UnfinalizedEpochParticipation added in v1.18.3

type UnfinalizedEpochParticipation struct {
	Epoch       uint64 `db:"epoch"`
	HeadForkId  uint64 `db:"epoch_head_fork_id"`
	BlockCount  uint64 `db:"block_count"`
	Eligible    uint64 `db:"eligible"`
	VotedTarget uint64 `db:"voted_target"`
	VotedHead   uint64 `db:"voted_head"`
	VotedTotal  uint64 `db:"voted_total"`
}

UnfinalizedEpochParticipation represents participation data for an unfinalized epoch

func GetUnfinalizedEpochParticipation added in v1.18.3

func GetUnfinalizedEpochParticipation(ctx context.Context, startEpoch, endEpoch uint64) ([]*UnfinalizedEpochParticipation, error)

GetUnfinalizedEpochParticipation gets participation data for unfinalized epochs in the given range This is used for pruned epochs that are stored in the database

Jump to

Keyboard shortcuts

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