cache

package
v1.3.10 Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: GPL-3.0 Imports: 19 Imported by: 107

Documentation

Overview

Package cache includes all important caches for the runtime of an eth2 beacon node, ensuring the node does not spend resources computing duplicate operations such as committee calculations for validators during the same epoch, etc.

Index

Constants

This section is empty.

Variables

View Source
var (

	// CommitteeCacheMiss tracks the number of committee requests that aren't present in the cache.
	CommitteeCacheMiss = promauto.NewCounter(prometheus.CounterOpts{
		Name: "committee_cache_miss",
		Help: "The number of committee requests that aren't present in the cache.",
	})
	// CommitteeCacheHit tracks the number of committee requests that are in the cache.
	CommitteeCacheHit = promauto.NewCounter(prometheus.CounterOpts{
		Name: "committee_cache_hit",
		Help: "The number of committee requests that are present in the cache.",
	})
)
View Source
var (

	// ProposerIndicesCacheMiss tracks the number of proposerIndices requests that aren't present in the cache.
	ProposerIndicesCacheMiss = promauto.NewCounter(prometheus.CounterOpts{
		Name: "proposer_indices_cache_miss",
		Help: "The number of proposer indices requests that aren't present in the cache.",
	})
	// ProposerIndicesCacheHit tracks the number of proposerIndices requests that are in the cache.
	ProposerIndicesCacheHit = promauto.NewCounter(prometheus.CounterOpts{
		Name: "proposer_indices_cache_hit",
		Help: "The number of proposer indices requests that are present in the cache.",
	})
)
View Source
var ErrAlreadyInProgress = errors.New("already in progress")

ErrAlreadyInProgress appears when attempting to mark a cache as in progress while it is already in progress. The client should handle this error and wait for the in progress data to resolve via Get.

View Source
var ErrNotCommittee = errors.New("object is not a committee struct")

ErrNotCommittee will be returned when a cache object is not a pointer to a Committee struct.

View Source
var ErrNotProposerIndices = errors.New("object is not a proposer indices struct")

ErrNotProposerIndices will be returned when a cache object is not a pointer to a ProposerIndices struct.

View Source
var SubnetIDs = newSubnetIDs()

SubnetIDs for attester and aggregator.

Functions

This section is empty.

Types

type AttestationCache

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

AttestationCache is used to store the cached results of an AttestationData request.

func NewAttestationCache

func NewAttestationCache() *AttestationCache

NewAttestationCache initializes the map and underlying cache.

func (*AttestationCache) Get

Get waits for any in progress calculation to complete before returning a cached response, if any.

func (*AttestationCache) MarkInProgress

func (c *AttestationCache) MarkInProgress(req *ethpb.AttestationDataRequest) error

MarkInProgress a request so that any other similar requests will block on Get until MarkNotInProgress is called.

func (*AttestationCache) MarkNotInProgress

func (c *AttestationCache) MarkNotInProgress(req *ethpb.AttestationDataRequest) error

MarkNotInProgress will release the lock on a given request. This should be called after put.

func (*AttestationCache) Put

Put the response in the cache.

type CheckpointStateCache

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

CheckpointStateCache is a struct with 1 queue for looking up state by checkpoint.

func NewCheckpointStateCache

func NewCheckpointStateCache() *CheckpointStateCache

NewCheckpointStateCache creates a new checkpoint state cache for storing/accessing processed state.

func (*CheckpointStateCache) AddCheckpointState

func (c *CheckpointStateCache) AddCheckpointState(cp *ethpb.Checkpoint, s iface.ReadOnlyBeaconState) error

AddCheckpointState adds CheckpointState object to the cache. This method also trims the least recently added CheckpointState object if the cache size has ready the max cache size limit.

func (*CheckpointStateCache) StateByCheckpoint

func (c *CheckpointStateCache) StateByCheckpoint(cp *ethpb.Checkpoint) (iface.BeaconState, error)

StateByCheckpoint fetches state by checkpoint. Returns true with a reference to the CheckpointState info, if exists. Otherwise returns false, nil.

type CommitteeCache

type CommitteeCache struct {
	CommitteeCache *cache.FIFO
	// contains filtered or unexported fields
}

CommitteeCache is a struct with 1 queue for looking up shuffled indices list by seed.

func NewCommitteesCache added in v0.3.0

func NewCommitteesCache() *CommitteeCache

NewCommitteesCache creates a new committee cache for storing/accessing shuffled indices of a committee.

func (*CommitteeCache) ActiveIndices

func (c *CommitteeCache) ActiveIndices(seed [32]byte) ([]types.ValidatorIndex, error)

ActiveIndices returns the active indices of a given seed stored in cache.

func (*CommitteeCache) ActiveIndicesCount added in v1.0.0

func (c *CommitteeCache) ActiveIndicesCount(seed [32]byte) (int, error)

ActiveIndicesCount returns the active indices count of a given seed stored in cache.

func (*CommitteeCache) AddCommitteeShuffledList

func (c *CommitteeCache) AddCommitteeShuffledList(committees *Committees) error

AddCommitteeShuffledList adds Committee shuffled list object to the cache. T his method also trims the least recently list if the cache size has ready the max cache size limit.

func (*CommitteeCache) Committee added in v0.3.0

func (c *CommitteeCache) Committee(slot types.Slot, seed [32]byte, index types.CommitteeIndex) ([]types.ValidatorIndex, error)

Committee fetches the shuffled indices by slot and committee index. Every list of indices represent one committee. Returns true if the list exists with slot and committee index. Otherwise returns false, nil.

func (*CommitteeCache) HasEntry added in v1.0.0

func (c *CommitteeCache) HasEntry(seed string) bool

HasEntry returns true if the committee cache has a value.

type Committees added in v0.3.0

type Committees struct {
	CommitteeCount  uint64
	Seed            [32]byte
	ShuffledIndices []types.ValidatorIndex
	SortedIndices   []types.ValidatorIndex
}

Committees defines the shuffled committees seed.

type ProposerIndices added in v1.0.0

type ProposerIndices struct {
	BlockRoot       [32]byte
	ProposerIndices []types.ValidatorIndex
}

ProposerIndices defines the cached struct for proposer indices.

type ProposerIndicesCache added in v1.0.0

type ProposerIndicesCache struct {
	ProposerIndicesCache *cache.FIFO
	// contains filtered or unexported fields
}

ProposerIndicesCache is a struct with 1 queue for looking up proposer indices by root.

func NewProposerIndicesCache added in v1.0.0

func NewProposerIndicesCache() *ProposerIndicesCache

NewProposerIndicesCache creates a new proposer indices cache for storing/accessing proposer index assignments of an epoch.

func (*ProposerIndicesCache) AddProposerIndices added in v1.0.0

func (c *ProposerIndicesCache) AddProposerIndices(p *ProposerIndices) error

AddProposerIndices adds ProposerIndices object to the cache. This method also trims the least recently list if the cache size has ready the max cache size limit.

func (*ProposerIndicesCache) HasProposerIndices added in v1.1.0

func (c *ProposerIndicesCache) HasProposerIndices(r [32]byte) (bool, error)

HasProposerIndices returns the proposer indices of a block root seed.

func (*ProposerIndicesCache) ProposerIndices added in v1.0.0

func (c *ProposerIndicesCache) ProposerIndices(r [32]byte) ([]types.ValidatorIndex, error)

ProposerIndices returns the proposer indices of a block root seed.

type SkipSlotCache added in v0.3.2

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

SkipSlotCache is used to store the cached results of processing skip slots in state.ProcessSlots.

func NewSkipSlotCache added in v0.3.2

func NewSkipSlotCache() *SkipSlotCache

NewSkipSlotCache initializes the map and underlying cache.

func (*SkipSlotCache) Disable added in v0.3.10

func (c *SkipSlotCache) Disable()

Disable the skip slot cache.

func (*SkipSlotCache) Enable added in v0.3.10

func (c *SkipSlotCache) Enable()

Enable the skip slot cache.

func (*SkipSlotCache) Get added in v0.3.2

func (c *SkipSlotCache) Get(ctx context.Context, r [32]byte) (iface.BeaconState, error)

Get waits for any in progress calculation to complete before returning a cached response, if any.

func (*SkipSlotCache) MarkInProgress added in v0.3.2

func (c *SkipSlotCache) MarkInProgress(r [32]byte) error

MarkInProgress a request so that any other similar requests will block on Get until MarkNotInProgress is called.

func (*SkipSlotCache) MarkNotInProgress added in v0.3.2

func (c *SkipSlotCache) MarkNotInProgress(r [32]byte) error

MarkNotInProgress will release the lock on a given request. This should be called after put.

func (*SkipSlotCache) Put added in v0.3.2

func (c *SkipSlotCache) Put(_ context.Context, r [32]byte, state iface.BeaconState) error

Put the response in the cache.

Directories

Path Synopsis
Package depositcache is the source of validator deposits maintained in-memory by the beacon node – deposits processed from the eth1 powchain are then stored in this cache to be accessed by any other service during a beacon node's runtime.
Package depositcache is the source of validator deposits maintained in-memory by the beacon node – deposits processed from the eth1 powchain are then stored in this cache to be accessed by any other service during a beacon node's runtime.

Jump to

Keyboard shortcuts

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