eds

package
v0.20.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyAccessor = &Rsmt2D{ExtendedDataSquare: share.EmptyEDS()}

EmptyAccessor is an accessor of an empty EDS block.

View Source
var RetrieveQuadrantTimeout = blockTime / numQuadrants * 2

RetrieveQuadrantTimeout defines how much time Retriever waits before starting to retrieve another quadrant.

NOTE: - The whole data square must be retrieved in less than block time. - We have 4 quadrants from two sources(rows, cols) which equals to 8 in total.

Functions

func BenchGetHalfAxisFromAccessor added in v0.20.2

func BenchGetHalfAxisFromAccessor(
	ctx context.Context,
	b *testing.B,
	createAccessor createAccessor,
	minOdsSize, maxOdsSize int,
)

func BenchGetSampleFromAccessor added in v0.20.2

func BenchGetSampleFromAccessor(
	ctx context.Context,
	b *testing.B,
	createAccessor createAccessor,
	minOdsSize, maxOdsSize int,
)

func NamespaceData added in v0.20.2

func NamespaceData(
	ctx context.Context,
	eds Accessor,
	namespace libshare.Namespace,
) (shwap.NamespaceData, error)

NamespaceData extracts shares for a specific namespace from an EDS, considering each row independently. It uses root to determine which rows to extract data from, avoiding the need to recalculate the row roots for each row.

func ProveShares added in v0.15.0

func ProveShares(eds *rsmt2d.ExtendedDataSquare, start, end int) (*types.ShareProof, error)

ProveShares generates a share proof for a share range. The share range, defined by start and end, is end-exclusive.

func ReadShares added in v0.20.2

func ReadShares(r io.Reader, shareSize, odsSize int) ([]libshare.Share, error)

ReadShares reads shares from the provided io.Reader until EOF. If EOF is reached, the remaining shares are populated as tail padding shares. Provided reader must contain shares in row-major order.

func TestStreamer added in v0.20.2

func TestStreamer(
	ctx context.Context,
	t *testing.T,
	create createAccessorStreamer,
	odsSize int,
)

func TestSuiteAccessor added in v0.20.2

func TestSuiteAccessor(
	ctx context.Context,
	t *testing.T,
	createAccessor createAccessor,
	maxSize int,
)

TestSuiteAccessor runs a suite of tests for the given Accessor implementation.

Types

type Accessor added in v0.20.2

type Accessor interface {
	// Size returns square size of the Accessor.
	Size(ctx context.Context) int
	// DataHash returns data hash of the Accessor.
	DataHash(ctx context.Context) (share.DataHash, error)
	// AxisRoots returns share.AxisRoots (DataAvailabilityHeader) of the Accessor.
	AxisRoots(ctx context.Context) (*share.AxisRoots, error)
	// Sample returns share and corresponding proof for row and column indices. Implementation can
	// choose which axis to use for proof. Chosen axis for proof should be indicated in the returned
	// Sample.
	Sample(ctx context.Context, rowIdx, colIdx int) (shwap.Sample, error)
	// AxisHalf returns half of shares axis of the given type and index. Side is determined by
	// implementation. Implementations should indicate the side in the returned AxisHalf.
	AxisHalf(ctx context.Context, axisType rsmt2d.Axis, axisIdx int) (AxisHalf, error)
	// RowNamespaceData returns data for the given namespace and row index.
	RowNamespaceData(ctx context.Context, namespace libshare.Namespace, rowIdx int) (shwap.RowNamespaceData, error)
	// Shares returns data (ODS) shares extracted from the Accessor.
	Shares(ctx context.Context) ([]libshare.Share, error)
}

Accessor is an interface for accessing extended data square data.

func WithValidation added in v0.20.2

func WithValidation(f Accessor) Accessor

type AccessorStreamer added in v0.20.2

type AccessorStreamer interface {
	Accessor
	Streamer
}

AccessorStreamer is an interface that groups Accessor and Streamer interfaces.

func AccessorAndStreamer added in v0.20.2

func AccessorAndStreamer(a Accessor, s Streamer) AccessorStreamer

func WithClosedOnce added in v0.20.2

func WithClosedOnce(f AccessorStreamer) AccessorStreamer

func WithProofsCache added in v0.20.2

func WithProofsCache(ac AccessorStreamer) AccessorStreamer

WithProofsCache creates a new eds accessor with caching of proofs for rows and columns. It is used to speed up the process of building proofs for rows and columns, reducing the number of reads from the underlying accessor.

type AxisHalf added in v0.20.2

type AxisHalf struct {
	Shares []libshare.Share
	// IsParity indicates whether the half is parity or data.
	IsParity bool
}

AxisHalf represents a half of data for a row or column in the EDS.

func (AxisHalf) Extended added in v0.20.2

func (a AxisHalf) Extended() ([]libshare.Share, error)

Extended returns full axis shares from half axis shares.

func (AxisHalf) ToRow added in v0.20.2

func (a AxisHalf) ToRow() shwap.Row

ToRow converts the AxisHalf to a shwap.Row.

type Retriever

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

Retriever retrieves rsmt2d.ExtendedDataSquares from the IPLD network. Instead of requesting data 'share by share' it requests data by quadrants minimizing bandwidth usage in the happy cases.

 ---- ----
| 0  | 1  |
 ---- ----
| 2  | 3  |
 ---- ----

Retriever randomly picks one of the data square quadrants and tries to request them one by one until it is able to reconstruct the whole square.

func NewRetriever

func NewRetriever(bServ blockservice.BlockService) *Retriever

NewRetriever creates a new instance of the Retriever over IPLD BlockService and rmst2d.Codec

func (*Retriever) Retrieve

func (r *Retriever) Retrieve(ctx context.Context, roots *share.AxisRoots) (*rsmt2d.ExtendedDataSquare, error)

Retrieve retrieves all the data committed to DataAvailabilityHeader.

If not available locally, it aims to request from the network only one quadrant (1/4) of the data square and reconstructs the other three quadrants (3/4). If the requested quadrant is not available within RetrieveQuadrantTimeout, it starts requesting another quadrant until either the data is reconstructed, context is canceled or ErrByzantine is generated.

type Rsmt2D added in v0.20.2

type Rsmt2D struct {
	*rsmt2d.ExtendedDataSquare
}

Rsmt2D is a rsmt2d based in-memory implementation of Accessor.

func ReadAccessor added in v0.20.2

func ReadAccessor(ctx context.Context, reader io.Reader, root *share.AxisRoots) (*Rsmt2D, error)

ReadAccessor reads up EDS out of the io.Reader until io.EOF and provides.

func Rsmt2DFromShares added in v0.20.2

func Rsmt2DFromShares(shares []libshare.Share, odsSize int) (*Rsmt2D, error)

Rsmt2DFromShares constructs an Extended Data Square from shares.

func (*Rsmt2D) AxisHalf added in v0.20.2

func (eds *Rsmt2D) AxisHalf(_ context.Context, axisType rsmt2d.Axis, axisIdx int) (AxisHalf, error)

AxisHalf returns Shares for the first half of the axis of the given type and index.

func (*Rsmt2D) AxisRoots added in v0.20.2

func (eds *Rsmt2D) AxisRoots(context.Context) (*share.AxisRoots, error)

AxisRoots returns AxisRoots of the Accessor.

func (*Rsmt2D) Close added in v0.20.2

func (eds *Rsmt2D) Close() error

func (*Rsmt2D) DataHash added in v0.20.2

func (eds *Rsmt2D) DataHash(context.Context) (share.DataHash, error)

DataHash returns data hash of the Accessor.

func (*Rsmt2D) HalfRow added in v0.20.2

func (eds *Rsmt2D) HalfRow(idx int, side shwap.RowSide) (shwap.Row, error)

HalfRow constructs a new shwap.Row from an Extended Data Square based on the specified index and side.

func (*Rsmt2D) Reader added in v0.20.2

func (eds *Rsmt2D) Reader() (io.Reader, error)

Reader returns binary reader for the file.

func (*Rsmt2D) RowNamespaceData added in v0.20.2

func (eds *Rsmt2D) RowNamespaceData(
	_ context.Context,
	namespace libshare.Namespace,
	rowIdx int,
) (shwap.RowNamespaceData, error)

RowNamespaceData returns data for the given namespace and row index.

func (*Rsmt2D) Sample added in v0.20.2

func (eds *Rsmt2D) Sample(
	_ context.Context,
	rowIdx, colIdx int,
) (shwap.Sample, error)

Sample returns share and corresponding proof for row and column indices.

func (*Rsmt2D) SampleForProofAxis added in v0.20.2

func (eds *Rsmt2D) SampleForProofAxis(
	rowIdx, colIdx int,
	proofType rsmt2d.Axis,
) (shwap.Sample, error)

SampleForProofAxis samples a share from an Extended Data Square based on the provided row and column indices and proof axis. It returns a sample with the share and proof.

func (*Rsmt2D) Shares added in v0.20.2

func (eds *Rsmt2D) Shares(_ context.Context) ([]libshare.Share, error)

Shares returns data (ODS) shares extracted from the EDS. It returns new copy of the shares each time.

func (*Rsmt2D) Size added in v0.20.2

func (eds *Rsmt2D) Size(context.Context) int

Size returns the size of the Extended Data Square.

type ShareReader added in v0.20.2

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

ShareReader implement io.Reader over general function that gets shares by their respective Row and Col coordinates. It enables share streaming over arbitrary storages.

func NewShareReader added in v0.20.2

func NewShareReader(odsSize int, getShare func(rowIdx, colIdx int) (libshare.Share, error)) *ShareReader

NewShareReader constructs a new ShareGetter from underlying ODS size and general share getting function.

func (*ShareReader) Read added in v0.20.2

func (r *ShareReader) Read(p []byte) (int, error)

type Streamer added in v0.20.2

type Streamer interface {
	// Reader returns binary reader for the shares. It should read the shares from the
	// ODS part of the square row by row.
	Reader() (io.Reader, error)
	io.Closer
}

Directories

Path Synopsis
pb

Jump to

Keyboard shortcuts

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