2022-03-14 20:58:13 +00:00
|
|
|
//go:build fuzz
|
2020-10-07 17:25:08 +00:00
|
|
|
|
|
|
|
// This file is used in fuzzer builds to bypass proposer indices caches.
|
|
|
|
package cache
|
|
|
|
|
2023-12-19 13:14:55 +00:00
|
|
|
import (
|
2023-12-22 18:47:51 +00:00
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
2024-02-15 05:46:47 +00:00
|
|
|
forkchoicetypes "github.com/prysmaticlabs/prysm/v5/beacon-chain/forkchoice/types"
|
|
|
|
fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
2023-12-19 13:14:55 +00:00
|
|
|
)
|
2021-02-23 00:14:50 +00:00
|
|
|
|
2023-12-22 18:47:51 +00:00
|
|
|
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.",
|
|
|
|
})
|
|
|
|
)
|
|
|
|
|
2020-10-07 17:25:08 +00:00
|
|
|
// FakeProposerIndicesCache is a struct with 1 queue for looking up proposer indices by root.
|
|
|
|
type FakeProposerIndicesCache struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewProposerIndicesCache creates a new proposer indices cache for storing/accessing proposer index assignments of an epoch.
|
|
|
|
func NewProposerIndicesCache() *FakeProposerIndicesCache {
|
|
|
|
return &FakeProposerIndicesCache{}
|
|
|
|
}
|
|
|
|
|
2023-12-19 13:14:55 +00:00
|
|
|
// ProposerIndices is a stub.
|
|
|
|
func (c *FakeProposerIndicesCache) ProposerIndices(_ primitives.Epoch, _ [32]byte) ([fieldparams.SlotsPerEpoch]primitives.ValidatorIndex, bool) {
|
|
|
|
return [fieldparams.SlotsPerEpoch]primitives.ValidatorIndex{}, false
|
2020-10-07 17:25:08 +00:00
|
|
|
}
|
|
|
|
|
2023-12-19 13:14:55 +00:00
|
|
|
// UnsafeProposerIndices is a stub.
|
|
|
|
func (c *FakeProposerIndicesCache) UnsafeProposerIndices(_ primitives.Epoch, _ [32]byte) ([fieldparams.SlotsPerEpoch]primitives.ValidatorIndex, bool) {
|
|
|
|
return [fieldparams.SlotsPerEpoch]primitives.ValidatorIndex{}, false
|
2020-10-07 17:25:08 +00:00
|
|
|
}
|
2020-12-15 00:09:30 +00:00
|
|
|
|
2023-12-19 13:14:55 +00:00
|
|
|
// Prune is a stub.
|
|
|
|
func (p *FakeProposerIndicesCache) Prune(epoch primitives.Epoch) {}
|
|
|
|
|
|
|
|
// Set is a stub.
|
|
|
|
func (p *FakeProposerIndicesCache) Set(epoch primitives.Epoch, root [32]byte, indices [fieldparams.SlotsPerEpoch]primitives.ValidatorIndex) {
|
2020-12-15 00:09:30 +00:00
|
|
|
}
|
2022-05-04 06:15:09 +00:00
|
|
|
|
2023-12-19 13:14:55 +00:00
|
|
|
// SetUnsafe is a stub.
|
|
|
|
func (p *FakeProposerIndicesCache) SetUnsafe(epoch primitives.Epoch, root [32]byte, indices [fieldparams.SlotsPerEpoch]primitives.ValidatorIndex) {
|
2022-05-04 06:15:09 +00:00
|
|
|
}
|
2023-04-27 00:50:04 +00:00
|
|
|
|
2023-12-19 13:14:55 +00:00
|
|
|
// SetCheckpoint is a stub.
|
|
|
|
func (p *FakeProposerIndicesCache) SetCheckpoint(c forkchoicetypes.Checkpoint, root [32]byte) {}
|
|
|
|
|
|
|
|
// IndicesFromCheckpoint is a stub.
|
|
|
|
func (p *FakeProposerIndicesCache) IndicesFromCheckpoint(_ forkchoicetypes.Checkpoint) ([fieldparams.SlotsPerEpoch]primitives.ValidatorIndex, bool) {
|
|
|
|
return [fieldparams.SlotsPerEpoch]primitives.ValidatorIndex{}, false
|
2023-04-27 00:50:04 +00:00
|
|
|
}
|