chaindb

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2021 License: Apache-2.0 Imports: 4 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            spec.Epoch
	Balance          spec.Gwei
	EffectiveBalance spec.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 []spec.ValidatorIndex,
		epoch spec.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 []spec.ValidatorIndex,
		startEpoch spec.Epoch,
		endEpoch spec.Epoch,
	) (
		[]*AggregateValidatorBalance,
		error,
	)

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

AggregateValidatorBalancesProvider defines functions to access aggregate validator balances.

type Attestation

type Attestation struct {
	InclusionSlot      spec.Slot
	InclusionBlockRoot spec.Root
	InclusionIndex     uint64
	Slot               spec.Slot
	CommitteeIndex     spec.CommitteeIndex
	AggregationBits    []byte
	AggregationIndices []spec.ValidatorIndex
	BeaconBlockRoot    spec.Root
	SourceEpoch        spec.Epoch
	SourceRoot         spec.Root
	TargetEpoch        spec.Epoch
	TargetRoot         spec.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 spec.Root) ([]*Attestation, error)

	// AttestationsInBlock fetches all attestations contained in the given block.
	AttestationsInBlock(ctx context.Context, blockRoot spec.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 spec.Slot, endSlot spec.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 spec.Slot, endSlot spec.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 spec.Slot, maxSlot spec.Slot) ([]spec.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
}

AttestationsSetter defines functions to create and update attestations.

type AttesterDuty added in v0.1.3

type AttesterDuty struct {
	Slot           spec.Slot
	Committee      spec.CommitteeIndex
	ValidatorIndex spec.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               spec.Slot
	InclusionBlockRoot          spec.Root
	InclusionIndex              uint64
	Attestation1Indices         []spec.ValidatorIndex
	Attestation1Slot            spec.Slot
	Attestation1CommitteeIndex  spec.CommitteeIndex
	Attestation1BeaconBlockRoot spec.Root
	Attestation1SourceEpoch     spec.Epoch
	Attestation1SourceRoot      spec.Root
	Attestation1TargetEpoch     spec.Epoch
	Attestation1TargetRoot      spec.Root
	Attestation1Signature       spec.BLSSignature
	Attestation2Indices         []spec.ValidatorIndex
	Attestation2Slot            spec.Slot
	Attestation2CommitteeIndex  spec.CommitteeIndex
	Attestation2BeaconBlockRoot spec.Root
	Attestation2SourceEpoch     spec.Epoch
	Attestation2SourceRoot      spec.Root
	Attestation2TargetEpoch     spec.Epoch
	Attestation2TargetRoot      spec.Root
	Attestation2Signature       spec.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 spec.Slot, maxSlot spec.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 spec.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 BeaconCommittee

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

BeaconCommittee holds information for beacon committees.

type BeaconCommitteesProvider added in v0.1.4

type BeaconCommitteesProvider interface {
	// BeaconComitteeBySlotAndIndex fetches the beacon committee with the given slot and index.
	BeaconCommitteeBySlotAndIndex(ctx context.Context, slot spec.Slot, index spec.CommitteeIndex) (*BeaconCommittee, error)

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

BeaconCommitteesProvider defines functions to access beacon committee information.

type BeaconCommitteesSetter added in v0.1.4

type BeaconCommitteesSetter interface {
	// SetBeaconComittee 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             spec.Slot
	ProposerIndex    spec.ValidatorIndex
	Root             spec.Root
	Graffiti         []byte
	RANDAOReveal     spec.BLSSignature
	BodyRoot         spec.Root
	ParentRoot       spec.Root
	StateRoot        spec.Root
	Canonical        *bool
	ETH1BlockHash    []byte
	ETH1DepositCount uint64
	ETH1DepositRoot  spec.Root
}

Block holds information about a block.

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                          spec.Slot
	AttestationsForBlock          int
	DuplicateAttestationsForBlock int
	VotesForBlock                 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 spec.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 spec.Slot, endSlot spec.Slot) ([]*Block, error)

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

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

	// EmptySlots fetches the slots in the given range without a block in the database.
	EmptySlots(ctx context.Context, minSlot spec.Slot, maxSlot spec.Slot) ([]spec.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 spec.Slot, maxSlot spec.Slot) ([]spec.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 spec.Slot, maxSlot spec.Slot) ([]bool, error)

	// LatestCanonicalBlock returns the slot of the latest canonical block known in the database.
	LatestCanonicalBlock(ctx context.Context) (spec.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         spec.Slot
	InclusionBlockRoot    spec.Root
	InclusionIndex        uint64
	ValidatorPubKey       spec.BLSPubKey
	WithdrawalCredentials []byte
	Amount                spec.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 []spec.BLSPubKey) (map[spec.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 spec.Slot, maxSlot spec.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       spec.BLSPubKey
	WithdrawalCredentials []byte
	Signature             spec.BLSSignature
	Amount                spec.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 []spec.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                         spec.Epoch
	ActivationQueueLength         int
	ActivatingValidators          int
	ActiveValidators              int
	ActiveRealBalance             spec.Gwei
	ActiveBalance                 spec.Gwei
	AttestingValidators           int
	AttestingBalance              spec.Gwei
	TargetCorrectValidators       int
	TargetCorrectBalance          spec.Gwei
	HeadCorrectValidators         int
	HeadCorrectBalance            spec.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 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 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 spec.Slot, endSlot spec.Slot) ([]*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           spec.Slot
	ValidatorIndex spec.ValidatorIndex
}

ProposerDuty holds information for proposer duties.

type ProposerSlashing

type ProposerSlashing struct {
	InclusionSlot        spec.Slot
	InclusionBlockRoot   spec.Root
	InclusionIndex       uint64
	Block1Root           spec.Root
	Header1Slot          spec.Slot
	Header1ProposerIndex spec.ValidatorIndex
	Header1ParentRoot    spec.Root
	Header1StateRoot     spec.Root
	Header1BodyRoot      spec.Root
	Header1Signature     spec.BLSSignature
	Block2Root           spec.Root
	Header2Slot          spec.Slot
	Header2ProposerIndex spec.ValidatorIndex
	Header2ParentRoot    spec.Root
	Header2StateRoot     spec.Root
	Header2BodyRoot      spec.Root
	Header2Signature     spec.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 spec.Slot, maxSlot spec.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 spec.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

	// 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 Validator

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

Validator holds information about a validator.

type ValidatorBalance

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

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

type ValidatorEpochSummariesSetter added in v0.3.0

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

ValidatorEpochSummariesSetter defines functions to create and update validator epoch summaries.

type ValidatorEpochSummary added in v0.3.0

type ValidatorEpochSummary struct {
	Index                     spec.ValidatorIndex
	Epoch                     spec.Epoch
	ProposerDuties            int
	ProposalsIncluded         int
	AttestationIncluded       bool
	AttestationTargetCorrect  *bool
	AttestationHeadCorrect    *bool
	AttestationInclusionDelay *int
}

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

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 []spec.BLSPubKey) (map[spec.BLSPubKey]*Validator, error)

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

	// ValidatorBalancesByIndexAndEpoch fetches the validator balances for the given validators and epoch.
	ValidatorBalancesByIndexAndEpoch(
		ctx context.Context,
		indices []spec.ValidatorIndex,
		epoch spec.Epoch,
	) (
		map[spec.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 []spec.ValidatorIndex,
		startEpoch spec.Epoch,
		endEpoch spec.Epoch,
	) (
		map[spec.ValidatorIndex][]*ValidatorBalance,
		error,
	)

	// ValidatorBalancesByIndexAndEpochs fetches the validator balances for the given validators at the specified epochs.
	ValidatorBalancesByIndexAndEpochs(
		ctx context.Context,
		indices []spec.ValidatorIndex,
		epochs []spec.Epoch,
	) (
		map[spec.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
}

ValidatorsSetter defines functions to create and update validator information.

type VoluntaryExit

type VoluntaryExit struct {
	InclusionSlot      spec.Slot
	InclusionBlockRoot spec.Root
	InclusionIndex     uint64
	ValidatorIndex     spec.ValidatorIndex
	Epoch              spec.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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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