Documentation ¶
Index ¶
- Constants
- func LoadBeaconBlock(ctx context.Context, client *Client, root phase0.Root) (*spec.VersionedSignedBeaconBlock, error)
- func LoadBeaconHeader(ctx context.Context, client *Client, root phase0.Root) (*phase0.SignedBeaconBlockHeader, error)
- func LoadBeaconHeaderBySlot(ctx context.Context, client *Client, slot phase0.Slot) (*phase0.SignedBeaconBlockHeader, phase0.Root, bool, error)
- func LoadBeaconState(ctx context.Context, client *Client, root phase0.Root) (*spec.VersionedBeaconState, error)
- type Block
- func (block *Block) AwaitBlock(ctx context.Context, timeout time.Duration) *spec.VersionedSignedBeaconBlock
- func (block *Block) AwaitHeader(ctx context.Context, timeout time.Duration) *phase0.SignedBeaconBlockHeader
- func (block *Block) EnsureBlock(loadBlock func() (*spec.VersionedSignedBeaconBlock, error)) (bool, error)
- func (block *Block) EnsureHeader(loadHeader func() (*phase0.SignedBeaconBlockHeader, error)) error
- func (block *Block) GetBlock() *spec.VersionedSignedBeaconBlock
- func (block *Block) GetBlockIndex() *BlockBodyIndex
- func (block *Block) GetDbBlock(indexer *Indexer) *dbtypes.Slot
- func (block *Block) GetDbConsolidationRequests(indexer *Indexer) []*dbtypes.ConsolidationRequest
- func (block *Block) GetDbDeposits(indexer *Indexer, depositIndex *uint64) []*dbtypes.Deposit
- func (block *Block) GetDbSlashings(indexer *Indexer) []*dbtypes.Slashing
- func (block *Block) GetDbVoluntaryExits(indexer *Indexer) []*dbtypes.VoluntaryExit
- func (block *Block) GetDbWithdrawalRequests(indexer *Indexer) []*dbtypes.WithdrawalRequest
- func (block *Block) GetForkId() ForkKey
- func (block *Block) GetHeader() *phase0.SignedBeaconBlockHeader
- func (block *Block) GetParentRoot() *phase0.Root
- func (block *Block) GetSeenBy() []*Client
- func (block *Block) SetBlock(body *spec.VersionedSignedBeaconBlock)
- func (block *Block) SetHeader(header *phase0.SignedBeaconBlockHeader)
- func (block *Block) SetSeenBy(client *Client)
- type BlockBodyIndex
- type ChainHead
- type Client
- type EpochStats
- func (es *EpochStats) GetDbEpoch(indexer *Indexer, headBlock *Block) *dbtypes.Epoch
- func (es *EpochStats) GetDependentRoot() phase0.Root
- func (es *EpochStats) GetEpoch() phase0.Epoch
- func (es *EpochStats) GetEpochVotes(indexer *Indexer, headBlock *Block) *EpochVotes
- func (es *EpochStats) GetOrLoadValues(indexer *Indexer, withPrecalc bool, keepInCache bool) *EpochStatsValues
- func (es *EpochStats) GetValues(withPrecalc bool) *EpochStatsValues
- type EpochStatsPacked
- type EpochStatsPackedValidator
- type EpochStatsValues
- type EpochVotes
- type Fork
- type ForkHead
- type ForkKey
- type Indexer
- func (indexer *Indexer) AddClient(index uint16, client *consensus.Client, priority int, archive bool, ...) *Client
- func (indexer *Indexer) GetAllClients() []*Client
- func (indexer *Indexer) GetBlockByParentRoot(blockRoot phase0.Root) []*Block
- func (indexer *Indexer) GetBlockByRoot(blockRoot phase0.Root) *Block
- func (indexer *Indexer) GetBlockByStateRoot(stateRoot phase0.Root) *Block
- func (indexer *Indexer) GetBlockCacheState() (finalizedEpoch phase0.Epoch, prunedEpoch phase0.Epoch)
- func (indexer *Indexer) GetBlockDistance(baseRoot phase0.Root, headRoot phase0.Root) (bool, uint64)
- func (indexer *Indexer) GetBlocksByExecutionBlockHash(blockHash phase0.Hash32) []*Block
- func (indexer *Indexer) GetBlocksByExecutionBlockNumber(blockNumber uint64) []*Block
- func (indexer *Indexer) GetBlocksBySlot(slot phase0.Slot) []*Block
- func (indexer *Indexer) GetCanonicalHead(overrideForkId *ForkKey) *Block
- func (indexer *Indexer) GetCanonicalValidatorSet(overrideForkId *ForkKey) []*v1.Validator
- func (indexer *Indexer) GetChainHeads() []*ChainHead
- func (indexer *Indexer) GetEpochStats(epoch phase0.Epoch, overrideForkId *ForkKey) *EpochStats
- func (indexer *Indexer) GetForkHeads() []*ForkHead
- func (indexer *Indexer) GetOrphanedBlockByRoot(blockRoot phase0.Root) (*Block, error)
- func (indexer *Indexer) GetParentForkIds(forkId ForkKey) []ForkKey
- func (indexer *Indexer) GetReadyClient(preferArchive bool) *Client
- func (indexer *Indexer) GetReadyClientByBlockRoot(blockRoot phase0.Root, preferArchive bool) *Client
- func (indexer *Indexer) GetReadyClients(preferArchive bool) []*Client
- func (indexer *Indexer) GetReadyClientsByBlockRoot(blockRoot phase0.Root, preferArchive bool) []*Client
- func (indexer *Indexer) GetReadyClientsByCheckpoint(finalizedRoot phase0.Root, preferArchive bool) []*Client
- func (indexer *Indexer) GetSynchronizerState() (running bool, syncHead phase0.Epoch)
- func (indexer *Indexer) IsCanonicalBlock(block *Block, overrideForkId *ForkKey) bool
- func (indexer *Indexer) StartIndexer()
Constants ¶
const EtherGweiFactor = 1_000_000_000
const FarFutureEpoch = phase0.Epoch(math.MaxUint64)
Variables ¶
This section is empty.
Functions ¶
func LoadBeaconBlock ¶
func LoadBeaconBlock(ctx context.Context, client *Client, root phase0.Root) (*spec.VersionedSignedBeaconBlock, error)
LoadBeaconBlock loads the block body from the RPC client.
func LoadBeaconHeader ¶
func LoadBeaconHeader(ctx context.Context, client *Client, root phase0.Root) (*phase0.SignedBeaconBlockHeader, error)
LoadBeaconHeader loads the block header from the client.
func LoadBeaconHeaderBySlot ¶
func LoadBeaconHeaderBySlot(ctx context.Context, client *Client, slot phase0.Slot) (*phase0.SignedBeaconBlockHeader, phase0.Root, bool, error)
LoadBeaconHeaderBySlot loads the block header with given slot number from the client.
func LoadBeaconState ¶
func LoadBeaconState(ctx context.Context, client *Client, root phase0.Root) (*spec.VersionedBeaconState, error)
LoadBeaconState loads the beacon state from the client.
Types ¶
type Block ¶
Block represents a beacon block.
func (*Block) AwaitBlock ¶
func (block *Block) AwaitBlock(ctx context.Context, timeout time.Duration) *spec.VersionedSignedBeaconBlock
AwaitBlock waits for the versioned signed beacon block of this block to be available.
func (*Block) AwaitHeader ¶
func (block *Block) AwaitHeader(ctx context.Context, timeout time.Duration) *phase0.SignedBeaconBlockHeader
AwaitHeader waits for the signed beacon block header of this block to be available.
func (*Block) EnsureBlock ¶
func (block *Block) EnsureBlock(loadBlock func() (*spec.VersionedSignedBeaconBlock, error)) (bool, error)
EnsureBlock ensures that the versioned signed beacon block of this block is available.
func (*Block) EnsureHeader ¶
func (block *Block) EnsureHeader(loadHeader func() (*phase0.SignedBeaconBlockHeader, error)) error
EnsureHeader ensures that the signed beacon block header of this block is available.
func (*Block) GetBlock ¶
func (block *Block) GetBlock() *spec.VersionedSignedBeaconBlock
GetBlock returns the versioned signed beacon block of this block.
func (*Block) GetBlockIndex ¶
func (block *Block) GetBlockIndex() *BlockBodyIndex
GetBlockIndex returns the block index of this block.
func (*Block) GetDbBlock ¶
GetDbBlock returns the database representation of this block.
func (*Block) GetDbConsolidationRequests ¶
func (block *Block) GetDbConsolidationRequests(indexer *Indexer) []*dbtypes.ConsolidationRequest
GetDbConsolidationRequests returns the database representation of the consolidation requests in this block.
func (*Block) GetDbDeposits ¶
GetDbDeposits returns the database representation of the deposits in this block.
func (*Block) GetDbSlashings ¶
GetDbSlashings returns the database representation of the slashings in this block.
func (*Block) GetDbVoluntaryExits ¶
func (block *Block) GetDbVoluntaryExits(indexer *Indexer) []*dbtypes.VoluntaryExit
GetDbVoluntaryExits returns the database representation of the voluntary exits in this block.
func (*Block) GetDbWithdrawalRequests ¶ added in v1.12.0
func (block *Block) GetDbWithdrawalRequests(indexer *Indexer) []*dbtypes.WithdrawalRequest
GetDbWithdrawalRequests returns the database representation of the withdrawal requests in this block.
func (*Block) GetHeader ¶
func (block *Block) GetHeader() *phase0.SignedBeaconBlockHeader
GetHeader returns the signed beacon block header of this block.
func (*Block) GetParentRoot ¶
GetParentRoot returns the parent root of this block.
func (*Block) SetBlock ¶
func (block *Block) SetBlock(body *spec.VersionedSignedBeaconBlock)
SetBlock sets the versioned signed beacon block of this block.
func (*Block) SetHeader ¶
func (block *Block) SetHeader(header *phase0.SignedBeaconBlockHeader)
SetHeader sets the signed beacon block header of this block.
type BlockBodyIndex ¶
type BlockBodyIndex struct { Graffiti [32]byte ExecutionExtraData []byte ExecutionHash phase0.Hash32 ExecutionNumber uint64 }
BlockBodyIndex holds important block propoerties that are used as index for cache lookups. this structure should be preserved after pruning, so the block is still identifiable.
type ChainHead ¶
type ChainHead struct { HeadBlock *Block // The head block of the chain. AggregatedHeadVotes phase0.Gwei // The aggregated votes of the last 2 epochs for the head block. PerEpochVotingPercent []float64 // The voting percentage in the last epochs (ascendeing order). }
ChainHead represents a head block of the chain.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a consensus pool client that should be used for indexing beacon blocks.
func (*Client) GetPriority ¶
type EpochStats ¶
type EpochStats struct {
// contains filtered or unexported fields
}
EpochStats holds the epoch-specific information based on the underlying dependent beacon state.
func (*EpochStats) GetDbEpoch ¶
func (es *EpochStats) GetDbEpoch(indexer *Indexer, headBlock *Block) *dbtypes.Epoch
GetDbEpoch returns the database Epoch representaion for the EpochStats.
func (*EpochStats) GetDependentRoot ¶ added in v1.12.1
func (es *EpochStats) GetDependentRoot() phase0.Root
func (*EpochStats) GetEpoch ¶
func (es *EpochStats) GetEpoch() phase0.Epoch
func (*EpochStats) GetEpochVotes ¶
func (es *EpochStats) GetEpochVotes(indexer *Indexer, headBlock *Block) *EpochVotes
GetEpochVotes aggregates & returns the EpochVotes for the EpochStats.
func (*EpochStats) GetOrLoadValues ¶
func (es *EpochStats) GetOrLoadValues(indexer *Indexer, withPrecalc bool, keepInCache bool) *EpochStatsValues
GetOrLoadValues returns the EpochStats values, loading them from the database if necessary.
func (*EpochStats) GetValues ¶
func (es *EpochStats) GetValues(withPrecalc bool) *EpochStatsValues
GetValues returns the EpochStats values.
type EpochStatsPacked ¶
type EpochStatsPacked struct { ActiveValidators []EpochStatsPackedValidator SyncCommitteeDuties []phase0.ValidatorIndex RandaoMix phase0.Hash32 NextRandaoMix phase0.Hash32 TotalBalance phase0.Gwei ActiveBalance phase0.Gwei FirstDepositIndex uint64 }
EpochStatsPacked holds the packed values for the epoch-specific information.
type EpochStatsPackedValidator ¶
type EpochStatsPackedValidator struct { ValidatorIndexOffset uint32 // offset to the previous index in the list (this is smaller than storing the full validator index) EffectiveBalanceEth uint16 // effective balance in full ETH }
EpochStatsPackedValidator holds the packed values for an active validator.
type EpochStatsValues ¶
type EpochStatsValues struct { RandaoMix phase0.Hash32 NextRandaoMix phase0.Hash32 ActiveIndices []phase0.ValidatorIndex EffectiveBalances []uint16 ProposerDuties []phase0.ValidatorIndex AttesterDuties [][][]duties.ActiveIndiceIndex SyncCommitteeDuties []phase0.ValidatorIndex ActiveValidators uint64 TotalBalance phase0.Gwei ActiveBalance phase0.Gwei EffectiveBalance phase0.Gwei FirstDepositIndex uint64 }
EpochStatsValues holds the values for the epoch-specific information.
func (*EpochStatsValues) GetEffectiveBalance ¶
func (v *EpochStatsValues) GetEffectiveBalance(index duties.ActiveIndiceIndex) phase0.Gwei
GetEffectiveBalance returns the effective balance for the given active validator indice.
type EpochVotes ¶
type EpochVotes struct { CurrentEpoch struct { TargetVoteAmount phase0.Gwei HeadVoteAmount phase0.Gwei TotalVoteAmount phase0.Gwei } NextEpoch struct { TargetVoteAmount phase0.Gwei HeadVoteAmount phase0.Gwei TotalVoteAmount phase0.Gwei } TargetVotePercent float64 HeadVotePercent float64 TotalVotePercent float64 AmountIsCount bool ActivityBitfield bitfield.Bitfield }
EpochVotes represents the aggregated votes for an epoch.
type Fork ¶
type Fork struct {
// contains filtered or unexported fields
}
Fork represents a fork in the beacon chain.
type Indexer ¶
type Indexer struct {
// contains filtered or unexported fields
}
Indexer is responsible for indexing the ethereum beacon chain.
func NewIndexer ¶
func NewIndexer(logger logrus.FieldLogger, consensusPool *consensus.Pool) *Indexer
NewIndexer creates a new instance of the Indexer.
func (*Indexer) AddClient ¶
func (indexer *Indexer) AddClient(index uint16, client *consensus.Client, priority int, archive bool, skipValidators bool) *Client
AddClient adds a new consensus pool client to the indexer.
func (*Indexer) GetAllClients ¶
GetAllClients returns a slice of all clients in the indexer.
func (*Indexer) GetBlockByParentRoot ¶
GetBlockByParentRoot returns a slice of blocks with the given parent root.
func (*Indexer) GetBlockByRoot ¶
GetBlockByRoot returns the block with the given block root.
func (*Indexer) GetBlockByStateRoot ¶
GetBlockByStateRoot returns the block with the given state root.
func (*Indexer) GetBlockCacheState ¶
func (indexer *Indexer) GetBlockCacheState() (finalizedEpoch phase0.Epoch, prunedEpoch phase0.Epoch)
GetBlockCacheState returns the state of the block cache, including the last finalized epoch and the last pruned epoch. this represents the internal cache state and might be behind the actual finalization checkpoint.
func (*Indexer) GetBlockDistance ¶
GetBlockDistance returns whether the base root is in the canonical chain defined by the head root and the distance between both blocks.
func (*Indexer) GetBlocksByExecutionBlockHash ¶
GetBlocksByExecutionBlockHash returns a slice of blocks with the given execution block hash.
func (*Indexer) GetBlocksByExecutionBlockNumber ¶
GetBlocksByExecutionBlockNumber returns a slice of blocks with the given execution block number.
func (*Indexer) GetBlocksBySlot ¶
GetBlocksBySlot returns a slice of blocks with the given slot.
func (*Indexer) GetCanonicalHead ¶
GetCanonicalHead returns the canonical head block of the chain.
func (*Indexer) GetCanonicalValidatorSet ¶
GetCanonicalValidatorSet returns the latest canonical validator set. If an overrideForkId is provided, the latest validator set for the fork is returned.
func (*Indexer) GetChainHeads ¶
GetChainHeads returns the chain heads sorted by voting percentages.
func (*Indexer) GetEpochStats ¶
func (indexer *Indexer) GetEpochStats(epoch phase0.Epoch, overrideForkId *ForkKey) *EpochStats
GetEpochStats returns the epoch stats for the given epoch and optional fork ID override.
func (*Indexer) GetForkHeads ¶
GetForkHeads returns a slice of fork heads in the indexer.
func (*Indexer) GetOrphanedBlockByRoot ¶
GetOrphanedBlockByRoot returns the orphaned block with the given block root.
func (*Indexer) GetParentForkIds ¶ added in v1.12.1
GetParentForkIds returns the parent fork ids of the given fork.
func (*Indexer) GetReadyClient ¶
GetReadyClient returns a single client that is on the finalized chain and preference for archive clients.
func (*Indexer) GetReadyClientByBlockRoot ¶
func (indexer *Indexer) GetReadyClientByBlockRoot(blockRoot phase0.Root, preferArchive bool) *Client
GetReadyClientByBlockRoot returns a single client that is ready for requests for the chain including the block root and preference for archive clients.
func (*Indexer) GetReadyClients ¶
GetReadyClients returns a slice of clients that are on the finalized chain and preference for archive clients.
func (*Indexer) GetReadyClientsByBlockRoot ¶
func (indexer *Indexer) GetReadyClientsByBlockRoot(blockRoot phase0.Root, preferArchive bool) []*Client
GetReadyClientsByBlockRoot returns a slice of clients that are ready for requests for the chain including the block root and preference for archive clients.
func (*Indexer) GetReadyClientsByCheckpoint ¶
func (indexer *Indexer) GetReadyClientsByCheckpoint(finalizedRoot phase0.Root, preferArchive bool) []*Client
GetReadyClientsByCheckpoint returns a slice of clients that are ready for processing based on the finalized root and preference for archive clients.
func (*Indexer) GetSynchronizerState ¶ added in v1.12.1
GetSynchronizerState returns the state of the synchronizer, including whether it is running and the current epoch.
func (*Indexer) IsCanonicalBlock ¶
func (*Indexer) StartIndexer ¶
func (indexer *Indexer) StartIndexer()
StartIndexer starts the indexing process.