Documentation ¶
Overview ¶
Package datastore helps storing data, utilizing Redis and Postgres as backends
Index ¶
- Variables
- func PubkeyHexToLowerStr(pk boostTypes.PubkeyHex) string
- type BuilderBids
- type Datastore
- func (ds *Datastore) GetGetPayloadResponse(slot uint64, proposerPubkey, blockHash string) (*common.VersionedExecutionPayload, error)
- func (ds *Datastore) GetKnownValidatorPubkeyByIndex(index uint64) (types.PubkeyHex, bool)
- func (ds *Datastore) IsKnownValidator(pubkeyHex types.PubkeyHex) bool
- func (ds *Datastore) NumKnownValidators() int
- func (ds *Datastore) NumRegisteredValidators() (uint64, error)
- func (ds *Datastore) RefreshKnownValidators() (cnt int, err error)
- func (ds *Datastore) SaveValidatorRegistration(entry types.SignedValidatorRegistration) error
- type ExecutionPayloadRepository
- type GetHeaderResponseKey
- type GetPayloadResponseKey
- type Memcached
- type RedisCache
- func (r *RedisCache) CheckAndSetLastSlotAndHashDelivered(slot uint64, hash string) (err error)
- func (r *RedisCache) GetActiveValidators() (map[boostTypes.PubkeyHex]bool, error)
- func (r *RedisCache) GetBestBid(slot uint64, parentHash, proposerPubkey string) (*common.GetHeaderResponse, error)
- func (r *RedisCache) GetBidTrace(slot uint64, proposerPubkey, blockHash string) (*common.BidTraceV2, error)
- func (r *RedisCache) GetBuilderLatestPayloadReceivedAt(slot uint64, builderPubkey, parentHash, proposerPubkey string) (int64, error)
- func (r *RedisCache) GetBuilderLatestValue(slot uint64, parentHash, proposerPubkey, builderPubkey string) (topBidValue *big.Int, err error)
- func (r *RedisCache) GetExecutionPayload(slot uint64, proposerPubkey, blockHash string) (*common.VersionedExecutionPayload, error)
- func (r *RedisCache) GetFloorBidValue(slot uint64, parentHash, proposerPubkey string) (floorValue *big.Int, err error)
- func (r *RedisCache) GetKnownValidators() (map[uint64]boostTypes.PubkeyHex, error)
- func (r *RedisCache) GetLastHashDelivered() (hash string, err error)
- func (r *RedisCache) GetLastSlotDelivered() (slot uint64, err error)
- func (r *RedisCache) GetObj(key string, obj any) (err error)
- func (r *RedisCache) GetProposerDuties() (proposerDuties []common.BuilderGetValidatorsResponseEntry, err error)
- func (r *RedisCache) GetRelayConfig(field string) (string, error)
- func (r *RedisCache) GetStats(field string) (value string, err error)
- func (r *RedisCache) GetStatsUint64(field string) (value uint64, err error)
- func (r *RedisCache) GetTopBidValue(slot uint64, parentHash, proposerPubkey string) (topBidValue *big.Int, err error)
- func (r *RedisCache) GetValidatorRegistrationTimestamp(proposerPubkey boostTypes.PubkeyHex) (uint64, error)
- func (r *RedisCache) HSetObj(key, field string, value any, expiration time.Duration) (err error)
- func (r *RedisCache) SaveBidAndUpdateTopBid(payload *common.BuilderSubmitBlockRequest, ...) (state SaveBidAndUpdateTopBidResponse, err error)
- func (r *RedisCache) SaveBidTrace(trace *common.BidTraceV2) (err error)
- func (r *RedisCache) SaveBuilderBid(slot uint64, parentHash, proposerPubkey, builderPubkey string, ...) (err error)
- func (r *RedisCache) SaveExecutionPayload(slot uint64, proposerPubkey, blockHash string, resp *common.GetPayloadResponse) (err error)
- func (r *RedisCache) SetActiveValidator(pubkeyHex boostTypes.PubkeyHex) error
- func (r *RedisCache) SetKnownValidator(pubkeyHex boostTypes.PubkeyHex, proposerIndex uint64) error
- func (r *RedisCache) SetObj(key string, value any, expiration time.Duration) (err error)
- func (r *RedisCache) SetProposerDuties(proposerDuties []common.BuilderGetValidatorsResponseEntry) (err error)
- func (r *RedisCache) SetRelayConfig(field, value string) (err error)
- func (r *RedisCache) SetStats(field string, value any) (err error)
- func (r *RedisCache) SetValidatorRegistrationTimestamp(proposerPubkey boostTypes.PubkeyHex, timestamp uint64) error
- func (r *RedisCache) SetValidatorRegistrationTimestampIfNewer(proposerPubkey boostTypes.PubkeyHex, timestamp uint64) error
- type SaveBidAndUpdateTopBidResponse
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidProposerPublicKey = errors.New("invalid proposer public key specified") ErrInvalidBlockHash = errors.New("invalid block hash specified") )
var ( RedisConfigFieldPubkey = "pubkey" RedisStatsFieldLatestSlot = "latest-slot" RedisStatsFieldValidatorsTotal = "validators-total" ErrFailedUpdatingTopBidNoBids = errors.New("failed to update top bid because no bids were found") ErrAnotherPayloadAlreadyDeliveredForSlot = errors.New("another payload block hash for slot was already delivered") ErrPastSlotAlreadyDelivered = errors.New("payload for past slot was already delivered") )
Functions ¶
func PubkeyHexToLowerStr ¶
func PubkeyHexToLowerStr(pk boostTypes.PubkeyHex) string
Types ¶
type BuilderBids ¶ added in v0.20.0
type BuilderBids struct {
// contains filtered or unexported fields
}
BuilderBids supports redis.SaveBidAndUpdateTopBid
func NewBuilderBids ¶ added in v0.20.0
func NewBuilderBids(bidValueMap map[string]string) *BuilderBids
type Datastore ¶
type Datastore struct {
// contains filtered or unexported fields
}
Datastore provides a local memory cache with a Redis and DB backend
func NewDatastore ¶
func NewDatastore(log *logrus.Entry, redisCache *RedisCache, memcached *Memcached, db database.IDatabaseService) (ds *Datastore, err error)
func (*Datastore) GetGetPayloadResponse ¶
func (ds *Datastore) GetGetPayloadResponse(slot uint64, proposerPubkey, blockHash string) (*common.VersionedExecutionPayload, error)
GetGetPayloadResponse returns the getPayload response from memory or Redis or Database
func (*Datastore) GetKnownValidatorPubkeyByIndex ¶
func (*Datastore) IsKnownValidator ¶
func (*Datastore) NumKnownValidators ¶
func (*Datastore) NumRegisteredValidators ¶
func (*Datastore) RefreshKnownValidators ¶
RefreshKnownValidators loads known validators from Redis into memory
func (*Datastore) SaveValidatorRegistration ¶ added in v0.9.1
func (ds *Datastore) SaveValidatorRegistration(entry types.SignedValidatorRegistration) error
SaveValidatorRegistration saves a validator registration into both Redis and the database
type ExecutionPayloadRepository ¶ added in v0.20.0
type ExecutionPayloadRepository interface { GetExecutionPayload(slot uint64, proposerPubKey, blockHash string) (*common.VersionedExecutionPayload, error) SaveExecutionPayload(slot uint64, proposerPubKey, blockHash string, payload *common.GetPayloadResponse) error }
ExecutionPayloadRepository defines methods to fetch and store execution engine payloads
type GetHeaderResponseKey ¶
type GetPayloadResponseKey ¶
type Memcached ¶ added in v0.20.0
type Memcached struct {
// contains filtered or unexported fields
}
func NewMemcached ¶ added in v0.20.0
func (*Memcached) GetExecutionPayload ¶ added in v0.20.0
func (m *Memcached) GetExecutionPayload(slot uint64, proposerPubKey, blockHash string) (*common.VersionedExecutionPayload, error)
GetExecutionPayload attempts to fetch execution engine payload from memcached using composite key of slot, proposer public key, block hash, and cache prefix if specified.
func (*Memcached) SaveExecutionPayload ¶ added in v0.20.0
func (m *Memcached) SaveExecutionPayload(slot uint64, proposerPubKey, blockHash string, payload *common.GetPayloadResponse) error
SaveExecutionPayload attempts to insert execution engine payload to memcached using composite key of slot, proposer public key, block hash, and cache prefix if specified. Note that writes to the same key value (i.e. same slot, proposer public key, and block hash) will overwrite the existing entry.
type RedisCache ¶
type RedisCache struct {
// contains filtered or unexported fields
}
func NewRedisCache ¶
func NewRedisCache(prefix, redisURI, readonlyURI string) (*RedisCache, error)
func (*RedisCache) CheckAndSetLastSlotAndHashDelivered ¶ added in v0.24.0
func (r *RedisCache) CheckAndSetLastSlotAndHashDelivered(slot uint64, hash string) (err error)
func (*RedisCache) GetActiveValidators ¶ added in v0.9.1
func (r *RedisCache) GetActiveValidators() (map[boostTypes.PubkeyHex]bool, error)
func (*RedisCache) GetBestBid ¶ added in v0.11.0
func (r *RedisCache) GetBestBid(slot uint64, parentHash, proposerPubkey string) (*common.GetHeaderResponse, error)
func (*RedisCache) GetBidTrace ¶ added in v0.10.0
func (r *RedisCache) GetBidTrace(slot uint64, proposerPubkey, blockHash string) (*common.BidTraceV2, error)
func (*RedisCache) GetBuilderLatestPayloadReceivedAt ¶ added in v0.12.0
func (r *RedisCache) GetBuilderLatestPayloadReceivedAt(slot uint64, builderPubkey, parentHash, proposerPubkey string) (int64, error)
func (*RedisCache) GetBuilderLatestValue ¶ added in v0.20.0
func (r *RedisCache) GetBuilderLatestValue(slot uint64, parentHash, proposerPubkey, builderPubkey string) (topBidValue *big.Int, err error)
GetBuilderLatestValue gets the latest bid value for a given slot+parent+proposer combination for a specific builder pubkey.
func (*RedisCache) GetExecutionPayload ¶ added in v0.11.0
func (r *RedisCache) GetExecutionPayload(slot uint64, proposerPubkey, blockHash string) (*common.VersionedExecutionPayload, error)
func (*RedisCache) GetFloorBidValue ¶ added in v0.24.0
func (r *RedisCache) GetFloorBidValue(slot uint64, parentHash, proposerPubkey string) (floorValue *big.Int, err error)
GetFloorBidValue returns the value of the highest non-cancellable bid
func (*RedisCache) GetKnownValidators ¶
func (r *RedisCache) GetKnownValidators() (map[uint64]boostTypes.PubkeyHex, error)
func (*RedisCache) GetLastHashDelivered ¶ added in v0.24.0
func (r *RedisCache) GetLastHashDelivered() (hash string, err error)
func (*RedisCache) GetLastSlotDelivered ¶ added in v0.20.0
func (r *RedisCache) GetLastSlotDelivered() (slot uint64, err error)
func (*RedisCache) GetProposerDuties ¶
func (r *RedisCache) GetProposerDuties() (proposerDuties []common.BuilderGetValidatorsResponseEntry, err error)
func (*RedisCache) GetRelayConfig ¶
func (r *RedisCache) GetRelayConfig(field string) (string, error)
func (*RedisCache) GetStatsUint64 ¶ added in v0.20.0
func (r *RedisCache) GetStatsUint64(field string) (value uint64, err error)
GetStatsUint64 returns (valueUint64, nil), or (0, redis.Nil) if the field does not exist
func (*RedisCache) GetTopBidValue ¶ added in v0.20.0
func (r *RedisCache) GetTopBidValue(slot uint64, parentHash, proposerPubkey string) (topBidValue *big.Int, err error)
GetTopBidValue gets the top bid value for a given slot+parent+proposer combination
func (*RedisCache) GetValidatorRegistrationTimestamp ¶
func (r *RedisCache) GetValidatorRegistrationTimestamp(proposerPubkey boostTypes.PubkeyHex) (uint64, error)
func (*RedisCache) SaveBidAndUpdateTopBid ¶ added in v0.20.0
func (r *RedisCache) SaveBidAndUpdateTopBid(payload *common.BuilderSubmitBlockRequest, getPayloadResponse *common.GetPayloadResponse, getHeaderResponse *common.GetHeaderResponse, reqReceivedAt time.Time, isCancellationEnabled bool, floorValue *big.Int) (state SaveBidAndUpdateTopBidResponse, err error)
func (*RedisCache) SaveBidTrace ¶ added in v0.10.0
func (r *RedisCache) SaveBidTrace(trace *common.BidTraceV2) (err error)
func (*RedisCache) SaveBuilderBid ¶ added in v0.20.0
func (r *RedisCache) SaveBuilderBid(slot uint64, parentHash, proposerPubkey, builderPubkey string, receivedAt time.Time, headerResp *common.GetHeaderResponse) (err error)
SaveBuilderBid saves the latest bid by a specific builder. TODO: use transaction to make these writes atomic
func (*RedisCache) SaveExecutionPayload ¶ added in v0.11.0
func (r *RedisCache) SaveExecutionPayload(slot uint64, proposerPubkey, blockHash string, resp *common.GetPayloadResponse) (err error)
func (*RedisCache) SetActiveValidator ¶ added in v0.9.1
func (r *RedisCache) SetActiveValidator(pubkeyHex boostTypes.PubkeyHex) error
func (*RedisCache) SetKnownValidator ¶
func (r *RedisCache) SetKnownValidator(pubkeyHex boostTypes.PubkeyHex, proposerIndex uint64) error
func (*RedisCache) SetProposerDuties ¶
func (r *RedisCache) SetProposerDuties(proposerDuties []common.BuilderGetValidatorsResponseEntry) (err error)
func (*RedisCache) SetRelayConfig ¶
func (r *RedisCache) SetRelayConfig(field, value string) (err error)
func (*RedisCache) SetValidatorRegistrationTimestamp ¶ added in v0.9.1
func (r *RedisCache) SetValidatorRegistrationTimestamp(proposerPubkey boostTypes.PubkeyHex, timestamp uint64) error
func (*RedisCache) SetValidatorRegistrationTimestampIfNewer ¶ added in v0.9.1
func (r *RedisCache) SetValidatorRegistrationTimestampIfNewer(proposerPubkey boostTypes.PubkeyHex, timestamp uint64) error