filesystem

package
v5.0.4-rc.3 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBlobStorageSummarizerUnavailable = errors.New("BlobStorage not initialized with a pruner or cache")

ErrBlobStorageSummarizerUnavailable is a sentinel error returned when there is no pruner/cache available. This should be used by code that optionally uses the summarizer to optimize rpc requests. Being able to fallback when there is no summarizer allows client code to avoid test complexity where the summarizer doesn't matter.

Functions

func NewEphemeralBlobStorageWithMocker

func NewEphemeralBlobStorageWithMocker(_ testing.TB) (*BlobMocker, *BlobStorage)

NewEphemeralBlobStorageWithMocker returns a *BlobMocker value in addition to the BlobStorage value. BlockMocker encapsulates things blob path construction to avoid leaking implementation details.

Types

type BlobMocker

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

func (*BlobMocker) CreateFakeIndices

func (bm *BlobMocker) CreateFakeIndices(root [32]byte, indices ...uint64) error

CreateFakeIndices creates empty blob sidecar files at the expected path for the given root and indices to influence the result of Indices().

type BlobStorage

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

BlobStorage is the concrete implementation of the filesystem backend for saving and retrieving BlobSidecars.

func NewBlobStorage

func NewBlobStorage(opts ...BlobStorageOption) (*BlobStorage, error)

NewBlobStorage creates a new instance of the BlobStorage object. Note that the implementation of BlobStorage may attempt to hold a file lock to guarantee exclusive control of the blob storage directory, so this should only be initialized once per beacon node.

func NewEphemeralBlobStorage

func NewEphemeralBlobStorage(t testing.TB) *BlobStorage

NewEphemeralBlobStorage should only be used for tests. The instance of BlobStorage returned is backed by an in-memory virtual filesystem, improving test performance and simplifying cleanup.

func NewEphemeralBlobStorageWithFs

func NewEphemeralBlobStorageWithFs(t testing.TB) (afero.Fs, *BlobStorage)

NewEphemeralBlobStorageWithFs can be used by tests that want access to the virtual filesystem in order to interact with it outside the parameters of the BlobStorage api.

func (*BlobStorage) Clear

func (bs *BlobStorage) Clear() error

Clear deletes all files on the filesystem.

func (*BlobStorage) Get

func (bs *BlobStorage) Get(root [32]byte, idx uint64) (blocks.VerifiedROBlob, error)

Get retrieves a single BlobSidecar by its root and index. Since BlobStorage only writes blobs that have undergone full verification, the return value is always a VerifiedROBlob.

func (*BlobStorage) Indices

func (bs *BlobStorage) Indices(root [32]byte) ([fieldparams.MaxBlobsPerBlock]bool, error)

Indices generates a bitmap representing which BlobSidecar.Index values are present on disk for a given root. This value can be compared to the commitments observed in a block to determine which indices need to be found on the network to confirm data availability.

func (*BlobStorage) Remove

func (bs *BlobStorage) Remove(root [32]byte) error

Remove removes all blobs for a given root.

func (*BlobStorage) Save

func (bs *BlobStorage) Save(sidecar blocks.VerifiedROBlob) error

Save saves blobs given a list of sidecars.

func (*BlobStorage) WaitForSummarizer added in v5.0.4

func (bs *BlobStorage) WaitForSummarizer(ctx context.Context) (BlobStorageSummarizer, error)

WaitForSummarizer blocks until the BlobStorageSummarizer is ready to use. BlobStorageSummarizer is not ready immediately on node startup because it needs to sample the blob filesystem to determine which blobs are available.

func (*BlobStorage) WarmCache

func (bs *BlobStorage) WarmCache()

WarmCache runs the prune routine with an expiration of slot of 0, so nothing will be pruned, but the pruner's cache will be populated at node startup, avoiding a costly cold prune (~4s in syscalls) during syncing.

func (*BlobStorage) WithinRetentionPeriod added in v5.0.4

func (bs *BlobStorage) WithinRetentionPeriod(requested, current primitives.Epoch) bool

WithinRetentionPeriod checks if the requested epoch is within the blob retention period.

type BlobStorageOption

type BlobStorageOption func(*BlobStorage) error

BlobStorageOption is a functional option for configuring a BlobStorage.

func WithBasePath added in v5.0.1

func WithBasePath(base string) BlobStorageOption

WithBasePath is a required option that sets the base path of blob storage.

func WithBlobRetentionEpochs

func WithBlobRetentionEpochs(e primitives.Epoch) BlobStorageOption

WithBlobRetentionEpochs is an option that changes the number of epochs blobs will be persisted.

func WithSaveFsync added in v5.0.1

func WithSaveFsync(fsync bool) BlobStorageOption

WithSaveFsync is an option that causes Save to call fsync before renaming part files for improved durability.

type BlobStorageSummarizer added in v5.0.4

type BlobStorageSummarizer interface {
	Summary(root [32]byte) BlobStorageSummary
}

BlobStorageSummarizer can be used to receive a summary of metadata about blobs on disk for a given root. The BlobStorageSummary can be used to check which indices (if any) are available for a given block by root.

func NewMockBlobStorageSummarizer added in v5.0.4

func NewMockBlobStorageSummarizer(t *testing.T, set map[[32]byte][]int) BlobStorageSummarizer

type BlobStorageSummary added in v5.0.4

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

BlobStorageSummary represents cached information about the BlobSidecars on disk for each root the cache knows about.

func (BlobStorageSummary) AllAvailable added in v5.0.4

func (s BlobStorageSummary) AllAvailable(count int) bool

AllAvailable returns true if we have all blobs for all indices from 0 to count-1.

func (BlobStorageSummary) HasIndex added in v5.0.4

func (s BlobStorageSummary) HasIndex(idx uint64) bool

HasIndex returns true if the BlobSidecar at the given index is available in the filesystem.

Jump to

Keyboard shortcuts

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