chaindb

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2023 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregateValidatorBalance added in v0.2.0

type AggregateValidatorBalance struct {
	Epoch            phase0.Epoch
	Balance          phase0.Gwei
	EffectiveBalance phase0.Gwei
}

AggregateValidatorBalance holds aggreated information about validators' balances at a given epoch.

type AggregateValidatorBalancesProvider added in v0.2.0

type AggregateValidatorBalancesProvider interface {
	// AggregateValidatorBalancesByIndexAndEpoch fetches the aggregate validator balances for the given validators and epoch.
	AggregateValidatorBalancesByIndexAndEpoch(
		ctx context.Context,
		indices []phase0.ValidatorIndex,
		epoch phase0.Epoch,
	) (
		*AggregateValidatorBalance,
		error,
	)

	// AggregateValidatorBalancesByIndexAndEpochRange fetches the aggregate validator balances for the given validators and
	// epoch range.
	// Ranges are inclusive of start and exclusive of end i.e. a request with startEpoch 2 and endEpoch 4 will provide
	// balances for epochs 2 and 3.
	AggregateValidatorBalancesByIndexAndEpochRange(
		ctx context.Context,
		indices []phase0.ValidatorIndex,
		startEpoch phase0.Epoch,
		endEpoch phase0.Epoch,
	) (
		[]*AggregateValidatorBalance,
		error,
	)

	// AggregateValidatorBalancesByIndexAndEpochs fetches the validator balances for the given validators at the specified epochs.
	AggregateValidatorBalancesByIndexAndEpochs(
		ctx context.Context,
		indices []phase0.ValidatorIndex,
		epochs []phase0.Epoch,
	) (
		[]*AggregateValidatorBalance,
		error,
	)
}

AggregateValidatorBalancesProvider defines functions to access aggregate validator balances.

type Attestation

type Attestation struct {
	InclusionSlot      phase0.Slot
	InclusionBlockRoot phase0.Root
	InclusionIndex     uint64
	Slot               phase0.Slot
	CommitteeIndex     phase0.CommitteeIndex
	AggregationBits    []byte
	AggregationIndices []phase0.ValidatorIndex
	BeaconBlockRoot    phase0.Root
	SourceEpoch        phase0.Epoch
	SourceRoot         phase0.Root
	TargetEpoch        phase0.Epoch
	TargetRoot         phase0.Root
	Canonical          *bool
	TargetCorrect      *bool
	HeadCorrect        *bool
}

Attestation holds information about an attestation included by a block.

type AttestationsProvider added in v0.1.4

type AttestationsProvider interface {
	// AttestationsForBlock fetches all attestations made for the given block.
	AttestationsForBlock(ctx context.Context, blockRoot phase0.Root) ([]*Attestation, error)

	// AttestationsInBlock fetches all attestations contained in the given block.
	AttestationsInBlock(ctx context.Context, blockRoot phase0.Root) ([]*Attestation, error)

	// AttestationsForSlotRange fetches all attestations made for the given slot range.
	// Ranges are inclusive of start and exclusive of end i.e. a request with startSlot 2 and endSlot 4 will provide
	// attestations for slots 2 and 3.
	AttestationsForSlotRange(ctx context.Context, startSlot phase0.Slot, endSlot phase0.Slot) ([]*Attestation, error)

	// AttestationsInSlotRange fetches all attestations made in the given slot range.
	// Ranges are inclusive of start and exclusive of end i.e. a request with startSlot 2 and endSlot 4 will provide
	// attestations in slots 2 and 3.
	AttestationsInSlotRange(ctx context.Context, startSlot phase0.Slot, endSlot phase0.Slot) ([]*Attestation, error)

	// IndeterminateAttestationSlots fetches the slots in the given range with attestations that do not have a canonical status.
	IndeterminateAttestationSlots(ctx context.Context, minSlot phase0.Slot, maxSlot phase0.Slot) ([]phase0.Slot, error)
}

AttestationsProvider defines functions to access attestations.

type AttestationsSetter added in v0.1.4

type AttestationsSetter interface {
	// SetAttestation sets an attestation.
	SetAttestation(ctx context.Context, attestation *Attestation) error

	// SetAttestations sets multiple attestation.
	SetAttestations(ctx context.Context, attestations []*Attestation) error
}

AttestationsSetter defines functions to create and update attestations.

type AttesterDuty added in v0.1.3

type AttesterDuty struct {
	Slot           phase0.Slot
	Committee      phase0.CommitteeIndex
	ValidatorIndex phase0.ValidatorIndex
	// CommitteeIndex is the index of the validator in the committee.
	CommitteeIndex uint64
}

AttesterDuty holds information for attester duties.

type AttesterSlashing

type AttesterSlashing struct {
	InclusionSlot               phase0.Slot
	InclusionBlockRoot          phase0.Root
	InclusionIndex              uint64
	Attestation1Indices         []phase0.ValidatorIndex
	Attestation1Slot            phase0.Slot
	Attestation1CommitteeIndex  phase0.CommitteeIndex
	Attestation1BeaconBlockRoot phase0.Root
	Attestation1SourceEpoch     phase0.Epoch
	Attestation1SourceRoot      phase0.Root
	Attestation1TargetEpoch     phase0.Epoch
	Attestation1TargetRoot      phase0.Root
	Attestation1Signature       phase0.BLSSignature
	Attestation2Indices         []phase0.ValidatorIndex
	Attestation2Slot            phase0.Slot
	Attestation2CommitteeIndex  phase0.CommitteeIndex
	Attestation2BeaconBlockRoot phase0.Root
	Attestation2SourceEpoch     phase0.Epoch
	Attestation2SourceRoot      phase0.Root
	Attestation2TargetEpoch     phase0.Epoch
	Attestation2TargetRoot      phase0.Root
	Attestation2Signature       phase0.BLSSignature
}

AttesterSlashing holds information about an attester slashing included by a block.

type AttesterSlashingsProvider added in v0.3.0

type AttesterSlashingsProvider interface {
	// AttesterSlashingsForSlotRange fetches all attester slashings made for the given slot range.
	// It will return slashings from blocks that are canonical or undefined, but not from non-canonical blocks.
	AttesterSlashingsForSlotRange(ctx context.Context, minSlot phase0.Slot, maxSlot phase0.Slot) ([]*AttesterSlashing, error)

	// AttesterSlashingsForValidator fetches all attester slashings made for the given validator.
	// It will return slashings from blocks that are canonical or undefined, but not from non-canonical blocks.
	AttesterSlashingsForValidator(ctx context.Context, index phase0.ValidatorIndex) ([]*AttesterSlashing, error)
}

AttesterSlashingsProvider defines functions to obtain attester slashings.

type AttesterSlashingsSetter added in v0.1.4

type AttesterSlashingsSetter interface {
	// SetAttesterSlashing sets an attester slashing.
	SetAttesterSlashing(ctx context.Context, attesterSlashing *AttesterSlashing) error
}

AttesterSlashingsSetter defines functions to create and update attester slashings.

type BLSToExecutionChange added in v0.7.0

type BLSToExecutionChange struct {
	InclusionBlockRoot phase0.Root
	InclusionSlot      phase0.Slot
	InclusionIndex     uint
	ValidatorIndex     phase0.ValidatorIndex
	FromBLSPubKey      [32]byte
	ToExecutionAddress [20]byte
}

BLSToExecutionChange holds information about credentials change operations.

type BLSToExecutionChangeFilter added in v0.7.0

type BLSToExecutionChangeFilter struct {
	// Limit is the maximum number of items to return.
	Limit uint32

	// Order is either OrderEarliest, in which case the earliest results
	// that match the filter are returned, or OrderLatest, in which case the
	// latest results that match the filter are returned.
	// The default is OrderEarliest.
	Order Order

	// From is the earliest slot from which to fetch items.
	// This relates to the inclusion slot.
	// If nil then there is no earliest slot.
	From *phase0.Slot

	// To is the latest slot to which to fetch items.
	// This relates to the inclusion slot.
	// If nil then there is no latest slot.
	To *phase0.Slot

	// ValidatorIndices is the list of validator indices for which to obtain items.
	// If nil then no filter is applied
	ValidatorIndices []phase0.ValidatorIndex
}

BLSToExecutionChangeFilter defines a filter for fetching BLS to execution changes. Filter elements are ANDed together. Results are always returned in ascending (slot,index) order.

type BLSToExecutionChangesProvider added in v0.7.0

type BLSToExecutionChangesProvider interface {
	// BLSToExecutionChanges provides credential changes according to the filter.
	BLSToExecutionChanges(ctx context.Context, filter *BLSToExecutionChangeFilter) ([]*BLSToExecutionChange, error)
}

BLSToExecutionChangesProvider defines functions to fetch credential changes.

type BeaconCommittee

type BeaconCommittee struct {
	Slot      phase0.Slot
	Index     phase0.CommitteeIndex
	Committee []phase0.ValidatorIndex
}

BeaconCommittee holds information for beacon committees.

type BeaconCommitteeFilter added in v0.7.0

type BeaconCommitteeFilter struct {
	// Limit is the maximum number of items to return.
	Limit uint32

	// Order is either OrderEarliest, in which case the earliest results
	// that match the filter are returned, or OrderLatest, in which case the
	// latest results that match the filter are returned.
	// The default is OrderEarliest.
	Order Order

	// From is the earliest slot from which to fetch items.
	// If nil then there is no earliest slot.
	From *phase0.Slot

	// To is the latest slot to which to fetch items.
	// If nil then there is no latest slot.
	To *phase0.Slot

	// CommitteeIndices is the list of committee indices for which to obtain items.
	// If nil then no filter is applied
	CommitteeIndices []phase0.CommitteeIndex
}

BeaconCommitteeFilter defines a filter for fetching beacon committees. Filter elements are ANDed together. Results are always returned in ascending (slot, committee index) order.

type BeaconCommitteesProvider added in v0.1.4

type BeaconCommitteesProvider interface {
	// BeaconCommittees fetches the beacon committees matching the filter.
	BeaconCommittees(ctx context.Context, filter *BeaconCommitteeFilter) ([]*BeaconCommittee, error)

	// BeaconCommitteeBySlotAndIndex fetches the beacon committee with the given slot and index.
	// This is deprecated; please use BeaconCommittees.
	BeaconCommitteeBySlotAndIndex(ctx context.Context, slot phase0.Slot, index phase0.CommitteeIndex) (*BeaconCommittee, error)

	// AttesterDuties fetches the attester duties at the given slot range for the given validator indices.
	AttesterDuties(ctx context.Context, startSlot phase0.Slot, endSlot phase0.Slot, validatorIndices []phase0.ValidatorIndex) ([]*AttesterDuty, error)
}

BeaconCommitteesProvider defines functions to access beacon committee information.

type BeaconCommitteesSetter added in v0.1.4

type BeaconCommitteesSetter interface {
	// SetBeaconCommittee sets a beacon committee.
	SetBeaconCommittee(ctx context.Context, beaconCommittee *BeaconCommittee) error
}

BeaconCommitteesSetter defines functions to create and update beacon committee information.

type Block

type Block struct {
	Slot             phase0.Slot
	ProposerIndex    phase0.ValidatorIndex
	Root             phase0.Root
	Graffiti         []byte
	RANDAOReveal     phase0.BLSSignature
	BodyRoot         phase0.Root
	ParentRoot       phase0.Root
	StateRoot        phase0.Root
	Canonical        *bool
	ETH1BlockHash    []byte
	ETH1DepositCount uint64
	ETH1DepositRoot  phase0.Root
	// Information only available from Bellatrix onwards.
	ExecutionPayload *ExecutionPayload
	// Information only available from Capella onwards.
	BLSToExecutionChanges []*BLSToExecutionChange
}

Block holds information about a block.

type BlockSummariesProvider added in v0.5.3

type BlockSummariesProvider interface {
	// BlockSummaryForSlot obtains the summary of a block for a given slot.
	BlockSummaryForSlot(ctx context.Context, slot phase0.Slot) (*BlockSummary, error)
}

BlockSummariesProvider defines functions to fetch block summaries.

type BlockSummariesSetter added in v0.3.0

type BlockSummariesSetter interface {
	// SetBlockSummary sets a block summary.
	SetBlockSummary(ctx context.Context, summary *BlockSummary) error
}

BlockSummariesSetter defines functions to create and update block summaries.

type BlockSummary added in v0.3.0

type BlockSummary struct {
	Slot                          phase0.Slot
	AttestationsForBlock          int
	DuplicateAttestationsForBlock int
	VotesForBlock                 int
	ParentDistance                int
}

BlockSummary provides a summary of an epoch.

type BlocksProvider added in v0.1.4

type BlocksProvider interface {
	// BlocksBySlot fetches all blocks with the given slot.
	BlocksBySlot(ctx context.Context, slot phase0.Slot) ([]*Block, error)

	// BlocksForSlotRange fetches all blocks with the given slot range.
	// Ranges are inclusive of start and exclusive of end i.e. a request with startSlot 2 and endSlot 4 will provide
	// blocks duties for slots 2 and 3.
	BlocksForSlotRange(ctx context.Context, startSlot phase0.Slot, endSlot phase0.Slot) ([]*Block, error)

	// BlockByRoot fetches the block with the given root.
	BlockByRoot(ctx context.Context, root phase0.Root) (*Block, error)

	// BlocksByParentRoot fetches the blocks with the given parent root.
	BlocksByParentRoot(ctx context.Context, root phase0.Root) ([]*Block, error)

	// EmptySlots fetches the slots in the given range without a block in the database.
	EmptySlots(ctx context.Context, minSlot phase0.Slot, maxSlot phase0.Slot) ([]phase0.Slot, error)

	// LatestBlocks fetches the blocks with the highest slot number in the database.
	LatestBlocks(ctx context.Context) ([]*Block, error)

	// IndeterminateBlocks fetches the blocks in the given range that do not have a canonical status.
	IndeterminateBlocks(ctx context.Context, minSlot phase0.Slot, maxSlot phase0.Slot) ([]phase0.Root, error)

	// CanonicalBlockPresenceForSlotRange returns a boolean for each slot in the range for the presence
	// of a canonical block.
	// Ranges are inclusive of start and exclusive of end i.e. a request with startSlot 2 and endSlot 4 will provide
	// presence duties for slots 2 and 3.
	CanonicalBlockPresenceForSlotRange(ctx context.Context, minSlot phase0.Slot, maxSlot phase0.Slot) ([]bool, error)

	// LatestCanonicalBlock returns the slot of the latest canonical block known in the database.
	LatestCanonicalBlock(ctx context.Context) (phase0.Slot, error)
}

BlocksProvider defines functions to access blocks.

type BlocksSetter added in v0.1.4

type BlocksSetter interface {
	// SetBlock sets a block.
	SetBlock(ctx context.Context, block *Block) error
}

BlocksSetter defines functions to create and update blocks.

type ChainSpecProvider added in v0.2.0

type ChainSpecProvider interface {
	// ChainSpec fetches all chain specification values.
	ChainSpec(ctx context.Context) (map[string]interface{}, error)

	// ChainSpecValue fetches a chain specification value given its key.
	ChainSpecValue(ctx context.Context, key string) (interface{}, error)
}

ChainSpecProvider defines functions to access chain specification.

type ChainSpecSetter added in v0.2.0

type ChainSpecSetter interface {
	// SetChainSpecValue sets the value of the provided key.
	SetChainSpecValue(ctx context.Context, key string, value interface{}) error
}

ChainSpecSetter defines functions to create and update chain specification.

type Deposit added in v0.2.0

type Deposit struct {
	InclusionSlot         phase0.Slot
	InclusionBlockRoot    phase0.Root
	InclusionIndex        uint64
	ValidatorPubKey       phase0.BLSPubKey
	WithdrawalCredentials []byte
	Amount                phase0.Gwei
}

Deposit holds information about an Ethereum 2 deposit included by a block.

type DepositsProvider added in v0.2.0

type DepositsProvider interface {
	// DepositsByPublicKey fetches deposits for a given set of validator public keys.
	DepositsByPublicKey(ctx context.Context, pubKeys []phase0.BLSPubKey) (map[phase0.BLSPubKey][]*Deposit, error)

	// DepositsForSlotRange fetches all deposits made in the given slot range.
	// It will return deposits from blocks that are canonical or undefined, but not from non-canonical blocks.
	DepositsForSlotRange(ctx context.Context, minSlot phase0.Slot, maxSlot phase0.Slot) ([]*Deposit, error)
}

DepositsProvider defines functions to access deposits.

type DepositsSetter added in v0.2.0

type DepositsSetter interface {
	// SetDeposit sets a deposit.
	SetDeposit(ctx context.Context, deposit *Deposit) error
}

DepositsSetter defines functions to create and update deposits.

type ETH1Deposit added in v0.2.0

type ETH1Deposit struct {
	ETH1BlockNumber       uint64
	ETH1BlockHash         []byte
	ETH1BlockTimestamp    time.Time
	ETH1TxHash            []byte
	ETH1LogIndex          uint64
	ETH1Sender            []byte
	ETH1Recipient         []byte
	ETH1GasUsed           uint64
	ETH1GasPrice          uint64
	DepositIndex          uint64
	ValidatorPubKey       phase0.BLSPubKey
	WithdrawalCredentials []byte
	Signature             phase0.BLSSignature
	Amount                phase0.Gwei
}

ETH1Deposit holds information about an Ethereum 2 deposit made on the Ethereum 1 chain.

type ETH1DepositsProvider added in v0.2.0

type ETH1DepositsProvider interface {
	// ETH1DepositsByPublicKey fetches Ethereum 1 deposits for a given set of validator public keys.
	ETH1DepositsByPublicKey(ctx context.Context, pubKeys []phase0.BLSPubKey) ([]*ETH1Deposit, error)
}

ETH1DepositsProvider defines functions to access Ethereum 1 deposits.

type ETH1DepositsSetter added in v0.2.0

type ETH1DepositsSetter interface {
	// SetETH1Deposit sets an Ethereum 1 deposit.
	SetETH1Deposit(ctx context.Context, deposit *ETH1Deposit) error
}

ETH1DepositsSetter defines functions to create and update Ethereum 1 deposits.

type EpochSummariesSetter added in v0.3.0

type EpochSummariesSetter interface {
	// SetEpochSummary sets an epoch summary.
	SetEpochSummary(ctx context.Context, summary *EpochSummary) error
}

EpochSummariesSetter defines functions to create and update epoch summaries.

type EpochSummary added in v0.3.0

type EpochSummary struct {
	Epoch                         phase0.Epoch
	ActivationQueueLength         int
	ActivatingValidators          int
	ActiveValidators              int
	ActiveRealBalance             phase0.Gwei
	ActiveBalance                 phase0.Gwei
	AttestingValidators           int
	AttestingBalance              phase0.Gwei
	TargetCorrectValidators       int
	TargetCorrectBalance          phase0.Gwei
	HeadCorrectValidators         int
	HeadCorrectBalance            phase0.Gwei
	AttestationsForEpoch          int
	AttestationsInEpoch           int
	DuplicateAttestationsForEpoch int
	ProposerSlashings             int
	AttesterSlashings             int
	Deposits                      int
	ExitingValidators             int
	CanonicalBlocks               int
}

EpochSummary provides a summary of an epoch.

type ExecutionPayload added in v0.6.0

type ExecutionPayload struct {
	ParentHash    [32]byte
	FeeRecipient  [20]byte
	StateRoot     [32]byte
	ReceiptsRoot  [32]byte
	LogsBloom     [256]byte
	PrevRandao    [32]byte
	BlockNumber   uint64
	GasLimit      uint64
	GasUsed       uint64
	Timestamp     uint64
	ExtraData     []byte
	BaseFeePerGas *big.Int
	BlockHash     [32]byte
	// No transactions, they are stored in execd.
	Withdrawals []*Withdrawal
}

ExecutionPayload holds information about a block's execution payload.

type ForkScheduleProvider added in v0.4.0

type ForkScheduleProvider interface {
	// ForkSchedule provides details of past and future changes in the chain's fork version.
	ForkSchedule(ctx context.Context) ([]*phase0.Fork, error)
}

ForkScheduleProvider defines functions to access fork schedule information.

type ForkScheduleSetter added in v0.4.0

type ForkScheduleSetter interface {
	// SetForkSchedule sets the fork schedule.
	SetForkSchedule(ctx context.Context, schedule []*phase0.Fork) error
}

ForkScheduleSetter defines functions to create and update fork schedule information.

type GenesisProvider added in v0.2.0

type GenesisProvider interface {
	// Genesis fetches genesis values.
	Genesis(ctx context.Context) (*api.Genesis, error)
}

GenesisProvider defines functions to access genesis information.

type GenesisSetter added in v0.2.0

type GenesisSetter interface {
	// SetGenesis sets the genesis information.
	SetGenesis(ctx context.Context, genesis *api.Genesis) error
}

GenesisSetter defines functions to create and update genesis information.

type Order added in v0.5.3

type Order uint8

Order is the order in which results should be fetched (N.B. fetched, not returned).

const (
	// OrderEarliest fetches earliest transactions first.
	OrderEarliest Order = iota
	// OrderLatest fetches latest transactions first.
	OrderLatest
)

type ProposerDutiesProvider added in v0.3.0

type ProposerDutiesProvider interface {
	// ProposerDutiesForSlotRange fetches all proposer duties for the given slot range.
	// Ranges are inclusive of start and exclusive of end i.e. a request with startSlot 2 and endSlot 4 will provide
	// proposer duties for slots 2 and 3.
	ProposerDutiesForSlotRange(ctx context.Context, startSlot phase0.Slot, endSlot phase0.Slot) ([]*ProposerDuty, error)

	// ProposerDutiesForValidator provides all proposer duties for the given validator index.
	ProposerDutiesForValidator(ctx context.Context, proposer phase0.ValidatorIndex) ([]*ProposerDuty, error)
}

ProposerDutiesProvider defines functions to access proposer duties.

type ProposerDutiesSetter added in v0.1.4

type ProposerDutiesSetter interface {
	// SetProposerDuty sets a proposer duty.
	SetProposerDuty(ctx context.Context, proposerDuty *ProposerDuty) error
}

ProposerDutiesSetter defines the functions to create and update proposer duties.

type ProposerDuty

type ProposerDuty struct {
	Slot           phase0.Slot
	ValidatorIndex phase0.ValidatorIndex
}

ProposerDuty holds information for proposer duties.

type ProposerSlashing

type ProposerSlashing struct {
	InclusionSlot        phase0.Slot
	InclusionBlockRoot   phase0.Root
	InclusionIndex       uint64
	Block1Root           phase0.Root
	Header1Slot          phase0.Slot
	Header1ProposerIndex phase0.ValidatorIndex
	Header1ParentRoot    phase0.Root
	Header1StateRoot     phase0.Root
	Header1BodyRoot      phase0.Root
	Header1Signature     phase0.BLSSignature
	Block2Root           phase0.Root
	Header2Slot          phase0.Slot
	Header2ProposerIndex phase0.ValidatorIndex
	Header2ParentRoot    phase0.Root
	Header2StateRoot     phase0.Root
	Header2BodyRoot      phase0.Root
	Header2Signature     phase0.BLSSignature
}

ProposerSlashing holds information about a proposer slashing included by a block.

type ProposerSlashingsProvider added in v0.1.4

type ProposerSlashingsProvider interface {
	// ProposerSlashingsForSlotRange fetches all proposer slashings made for the given slot range.
	// It will return slashings from blocks that are canonical or undefined, but not from non-canonical blocks.
	ProposerSlashingsForSlotRange(ctx context.Context, minSlot phase0.Slot, maxSlot phase0.Slot) ([]*ProposerSlashing, error)

	// ProposerSlashingsForValidator fetches all proposer slashings made for the given validator.
	// It will return slashings from blocks that are canonical or undefined, but not from non-canonical blocks.
	ProposerSlashingsForValidator(ctx context.Context, index phase0.ValidatorIndex) ([]*ProposerSlashing, error)
}

ProposerSlashingsProvider defines functions to access proposer slashings.

type ProposerSlashingsSetter added in v0.1.4

type ProposerSlashingsSetter interface {
	// SetProposerSlashing sets an proposer slashing.
	SetProposerSlashing(ctx context.Context, proposerSlashing *ProposerSlashing) error
}

ProposerSlashingsSetter defines functions to create and update proposer slashings.

type Service

type Service interface {
	// BeginTx begins a transaction.
	BeginTx(ctx context.Context) (context.Context, context.CancelFunc, error)

	// CommitTx commits a transaction.
	CommitTx(ctx context.Context) error

	// BeginROTx begins a read-only transaction.
	// The transaction should be committed.
	BeginROTx(ctx context.Context) (context.Context, error)

	// CommitROTx commits a read-only transaction.
	CommitROTx(ctx context.Context)

	// SetMetadata sets a metadata key to a JSON value.
	SetMetadata(ctx context.Context, key string, value []byte) error

	// Metadata obtains the JSON value from a metadata key.
	Metadata(ctx context.Context, key string) ([]byte, error)
}

Service defines a minimal chain database service.

type SyncAggregate added in v0.4.0

type SyncAggregate struct {
	InclusionSlot      phase0.Slot
	InclusionBlockRoot phase0.Root
	Bits               []byte
	Indices            []phase0.ValidatorIndex
}

SyncAggregate holds information about a sync aggregate included in a block.

type SyncAggregateFilter added in v0.7.0

type SyncAggregateFilter struct {
	// Limit is the maximum number of items to return.
	Limit uint32

	// Order is either OrderEarliest, in which case the earliest results
	// that match the filter are returned, or OrderLatest, in which case the
	// latest results that match the filter are returned.
	// The default is OrderEarliest.
	Order Order

	// From is the earliest slot from which to fetch items.
	// This relates to the inclusion slot.
	// If nil then there is no earliest slot.
	From *phase0.Slot

	// To is the latest slot to which to fetch items.
	// This relates to the inclusion slot.
	// If nil then there is no latest slot.
	To *phase0.Slot
}

SyncAggregateFilter defines a filter for fetching sync aggregates. Filter elements are ANDed together. Results are always returned in ascending slot order.

type SyncAggregateProvider added in v0.4.0

type SyncAggregateProvider interface {
	// SyncAggregates provides sync aggregates according to the filter.
	SyncAggregates(ctx context.Context, filter *SyncAggregateFilter) ([]*SyncAggregate, error)
}

SyncAggregateProvider defines functions to access sync aggregate information.

type SyncAggregateSetter added in v0.4.0

type SyncAggregateSetter interface {
	// SetSyncAggregate sets the sync aggregate.
	SetSyncAggregate(ctx context.Context, syncAggregate *SyncAggregate) error
}

SyncAggregateSetter defines functions to create and update fork schedule information.

type SyncCommittee added in v0.4.0

type SyncCommittee struct {
	Period    uint64
	Committee []phase0.ValidatorIndex
}

SyncCommittee holds information for sync committees.

type SyncCommitteesProvider added in v0.4.0

type SyncCommitteesProvider interface {
	// SyncCommittee provides a sync committee for the given sync committee period.
	SyncCommittee(ctx context.Context, period uint64) (*SyncCommittee, error)
}

SyncCommitteesProvider defines functions to obtain sync committee information.

type SyncCommitteesSetter added in v0.4.0

type SyncCommitteesSetter interface {
	// SetSyncCommittee sets a sync committee.
	SetSyncCommittee(ctx context.Context, syncCommittee *SyncCommittee) error
}

SyncCommitteesSetter defines functions to create and update sync committee information.

type Validator

type Validator struct {
	PublicKey                  phase0.BLSPubKey
	Index                      phase0.ValidatorIndex
	EffectiveBalance           phase0.Gwei
	Slashed                    bool
	ActivationEligibilityEpoch phase0.Epoch
	ActivationEpoch            phase0.Epoch
	ExitEpoch                  phase0.Epoch
	WithdrawableEpoch          phase0.Epoch
}

Validator holds information about a validator.

type ValidatorBalance

type ValidatorBalance struct {
	Index            phase0.ValidatorIndex
	Epoch            phase0.Epoch
	Balance          phase0.Gwei
	EffectiveBalance phase0.Gwei
}

ValidatorBalance holds information about a validator's balance at a given epoch.

type ValidatorBalancesPruner added in v0.7.0

type ValidatorBalancesPruner interface {
	// PruneValidatorBalances prunes validator balances up to (but not including) the given epoch.
	PruneValidatorBalances(ctx context.Context, to phase0.Epoch, retain []phase0.ValidatorIndex) error
}

ValidatorBalancesPruner defines functions to prune validator balances.

type ValidatorDaySummariesProvider added in v0.7.0

type ValidatorDaySummariesProvider interface {
	// ValidatorDaySummaries provides summaries according to the filter.
	ValidatorDaySummaries(ctx context.Context, filter *ValidatorDaySummaryFilter) ([]*ValidatorDaySummary, error)
}

ValidatorDaySummariesProvider defines functions to fetch validator day summaries.

type ValidatorDaySummariesSetter added in v0.7.0

type ValidatorDaySummariesSetter interface {
	// SetValidatorDaySummary sets a validator day summary.
	SetValidatorDaySummary(ctx context.Context, summary *ValidatorDaySummary) error

	// SetValidatorDaySummaries sets multiple validator day summaries.
	SetValidatorDaySummaries(ctx context.Context, summaries []*ValidatorDaySummary) error
}

ValidatorDaySummariesSetter defines functions to create and update validator day summaries.

type ValidatorDaySummary added in v0.7.0

type ValidatorDaySummary struct {
	Index                         phase0.ValidatorIndex
	StartTimestamp                time.Time
	StartBalance                  uint64
	StartEffectiveBalance         uint64
	CapitalChange                 int64
	RewardChange                  int64
	EffectiveBalanceChange        int64
	Proposals                     int
	ProposalsIncluded             int
	Attestations                  int
	AttestationsIncluded          int
	AttestationsTargetCorrect     int
	AttestationsHeadCorrect       int
	AttestationsSourceTimely      int
	AttestationsTargetTimely      int
	AttestationsHeadTimely        int
	AttestationsInclusionDelay    float64
	SyncCommitteeMessages         int
	SyncCommitteeMessagesIncluded int
}

ValidatorDaySummary provides a summary of a validator's operations for a day.

type ValidatorDaySummaryFilter added in v0.7.0

type ValidatorDaySummaryFilter struct {
	// Limit is the maximum number of summaries to return.
	Limit uint32

	// Order is either OrderEarliest, in which case the earliest results
	// that match the filter are returned, or OrderLatest, in which case the
	// latest results that match the filter are returned.
	// The default is OrderEarliest.
	Order Order

	// From is the earliest timestamp from which to fetch summaries.
	// If nil then there is no earliest epoch.
	From *time.Time

	// To is the latest timestamp from which to fetch summaries.
	// If nil then there is no latest epoch.
	To *time.Time

	// ValidatorIndices is the list of validator indices for which to obtain summaries.
	// If nil then no filter is applied
	ValidatorIndices *[]phase0.ValidatorIndex
}

ValidatorDaySummaryFilter defines a filter for fetching validator day summaries. Filter elements are ANDed together. Results are always returned in ascending (start timestamp, validator index) order.

type ValidatorEpochSummariesProvider added in v0.5.2

type ValidatorEpochSummariesProvider interface {
	// ValidatorSummaries provides summaries according to the filter.
	ValidatorSummaries(ctx context.Context, filter *ValidatorSummaryFilter) ([]*ValidatorEpochSummary, error)

	// ValidatorSummariesForEpoch obtains all summaries for a given epoch.
	ValidatorSummariesForEpoch(ctx context.Context, epoch phase0.Epoch) ([]*ValidatorEpochSummary, error)

	// ValidatorSummaryForEpoch obtains the summary of a validator for a given epoch.
	ValidatorSummaryForEpoch(ctx context.Context, index phase0.ValidatorIndex, epoch phase0.Epoch) (*ValidatorEpochSummary, error)
}

ValidatorEpochSummariesProvider defines functions to fetch validator epoch summaries.

type ValidatorEpochSummariesPruner added in v0.7.0

type ValidatorEpochSummariesPruner interface {
	// PruneValidatorEpochSummaries prunes validator epoch summaries up to (but not including) the given point.
	PruneValidatorEpochSummaries(ctx context.Context, to phase0.Epoch, retain []phase0.ValidatorIndex) error
}

ValidatorEpochSummariesPruner defines functions to prune validator epoch summaries.

type ValidatorEpochSummariesSetter added in v0.3.0

type ValidatorEpochSummariesSetter interface {
	// SetValidatorEpochSummary sets a validator epoch summary.
	SetValidatorEpochSummary(ctx context.Context, summary *ValidatorEpochSummary) error

	// SetValidatorEpochSummaries sets multiple validator epoch summaries.
	SetValidatorEpochSummaries(ctx context.Context, summaries []*ValidatorEpochSummary) error
}

ValidatorEpochSummariesSetter defines functions to create and update validator epoch summaries.

type ValidatorEpochSummary added in v0.3.0

type ValidatorEpochSummary struct {
	Index                     phase0.ValidatorIndex
	Epoch                     phase0.Epoch
	ProposerDuties            int
	ProposalsIncluded         int
	AttestationIncluded       bool
	AttestationTargetCorrect  *bool
	AttestationHeadCorrect    *bool
	AttestationInclusionDelay *int
	AttestationSourceTimely   *bool
	AttestationTargetTimely   *bool
	AttestationHeadTimely     *bool
}

ValidatorEpochSummary provides a summary of a validator's operations for an epoch.

type ValidatorSummaryFilter added in v0.5.3

type ValidatorSummaryFilter struct {
	// Limit is the maximum number of summaries to return.
	Limit uint32

	// Order is either OrderEarliest, in which case the earliest results
	// that match the filter are returned, or OrderLatest, in which case the
	// latest results that match the filter are returned.
	// The default is OrderEarliest.
	Order Order

	// From is the earliest epoch from which to fetch summaries.
	// If nil then there is no earliest epoch.
	From *phase0.Epoch

	// To is the latest epoch from which to fetch summaries.
	// If nil then there is no latest epoch.
	To *phase0.Epoch

	// ValidatorIndices is the list of validator indices for which to obtain summaries.
	// If nil then no filter is applied
	ValidatorIndices *[]phase0.ValidatorIndex
}

ValidatorSummaryFilter defines a filter for fetching validator summaries. Filter elements are ANDed together. Results are always returned in ascending (epoch, validator index) order.

type ValidatorsProvider added in v0.1.4

type ValidatorsProvider interface {
	// Validators fetches all validators.
	Validators(ctx context.Context) ([]*Validator, error)

	// ValidatorsByPublicKey fetches all validators matching the given public keys.
	// This is a common starting point for external entities to query specific validators, as they should
	// always have the public key at a minimum, hence the return map keyed by public key.
	ValidatorsByPublicKey(ctx context.Context, pubKeys []phase0.BLSPubKey) (map[phase0.BLSPubKey]*Validator, error)

	// ValidatorsByIndex fetches all validators matching the given indices.
	ValidatorsByIndex(ctx context.Context, indices []phase0.ValidatorIndex) (map[phase0.ValidatorIndex]*Validator, error)

	// ValidatorBalancesByEpoch fetches all validator balances for the given epoch.
	ValidatorBalancesByEpoch(
		ctx context.Context,
		epoch phase0.Epoch,
	) (
		[]*ValidatorBalance,
		error,
	)

	// ValidatorBalancesByIndexAndEpoch fetches the validator balances for the given validators and epoch.
	ValidatorBalancesByIndexAndEpoch(
		ctx context.Context,
		indices []phase0.ValidatorIndex,
		epoch phase0.Epoch,
	) (
		map[phase0.ValidatorIndex]*ValidatorBalance,
		error,
	)

	// ValidatorBalancesByIndexAndEpochRange fetches the validator balances for the given validators and epoch range.
	// Ranges are inclusive of start and exclusive of end i.e. a request with startEpoch 2 and endEpoch 4 will provide
	// balances for epochs 2 and 3.
	ValidatorBalancesByIndexAndEpochRange(
		ctx context.Context,
		indices []phase0.ValidatorIndex,
		startEpoch phase0.Epoch,
		endEpoch phase0.Epoch,
	) (
		map[phase0.ValidatorIndex][]*ValidatorBalance,
		error,
	)

	// ValidatorBalancesByIndexAndEpochs fetches the validator balances for the given validators at the specified epochs.
	ValidatorBalancesByIndexAndEpochs(
		ctx context.Context,
		indices []phase0.ValidatorIndex,
		epochs []phase0.Epoch,
	) (
		map[phase0.ValidatorIndex][]*ValidatorBalance,
		error,
	)
}

ValidatorsProvider defines functions to access validator information.

type ValidatorsSetter added in v0.1.4

type ValidatorsSetter interface {
	// SetValidator sets a validator.
	SetValidator(ctx context.Context, validator *Validator) error

	// SetValidatorBalance sets a validator balance.
	SetValidatorBalance(ctx context.Context, validatorBalance *ValidatorBalance) error

	// SetValidatorBalances sets multiple validator balances.
	SetValidatorBalances(ctx context.Context, validatorBalances []*ValidatorBalance) error
}

ValidatorsSetter defines functions to create and update validator information.

type VoluntaryExit

type VoluntaryExit struct {
	InclusionSlot      phase0.Slot
	InclusionBlockRoot phase0.Root
	InclusionIndex     uint64
	ValidatorIndex     phase0.ValidatorIndex
	Epoch              phase0.Epoch
}

VoluntaryExit holds information about a voluntary exit included in a block.

type VoluntaryExitsSetter added in v0.1.4

type VoluntaryExitsSetter interface {
	// SetVoluntaryExit sets a voluntary exit.
	SetVoluntaryExit(ctx context.Context, voluntaryExit *VoluntaryExit) error
}

VoluntaryExitsSetter defines functions to create and update voluntary exits.

type Withdrawal added in v0.7.0

type Withdrawal struct {
	InclusionBlockRoot phase0.Root
	InclusionSlot      phase0.Slot
	InclusionIndex     uint
	Index              capella.WithdrawalIndex
	ValidatorIndex     phase0.ValidatorIndex
	Address            [20]byte
	Amount             phase0.Gwei
}

Withdrawal holds information about a withdrawal from consensus to execution layer.

type WithdrawalFilter added in v0.7.0

type WithdrawalFilter struct {
	// Limit is the maximum number of items to return.
	Limit uint32

	// Order is either OrderEarliest, in which case the earliest results
	// that match the filter are returned, or OrderLatest, in which case the
	// latest results that match the filter are returned.
	// The default is OrderEarliest.
	Order Order

	// From is the earliest slot from which to fetch items.
	// This relates to the inclusion slot.
	// If nil then there is no earliest slot.
	From *phase0.Slot

	// To is the latest slot to which to fetch items.
	// This relates to the inclusion slot.
	// If nil then there is no latest slot.
	To *phase0.Slot

	// ValidatorIndices is the list of validator indices for which to obtain items.
	// If nil then no filter is applied
	ValidatorIndices []phase0.ValidatorIndex
}

WithdrawalFilter defines a filter for fetching withdrawals. Filter elements are ANDed together. Results are always returned in ascending (slot,index) order.

type WithdrawalsProvider added in v0.7.0

type WithdrawalsProvider interface {
	// Withdrawals provides withdrawals according to the filter.
	Withdrawals(ctx context.Context, filter *WithdrawalFilter) ([]*Withdrawal, error)
}

WithdrawalsProvider defines functions to fetch withdrawals.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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