Documentation ¶
Index ¶
- Constants
- Variables
- func ShareFromProto(s *pb.Share) (libshare.Share, error)
- func SharesFromProto(shrs []*pb.Share) ([]libshare.Share, error)
- func SharesToProto(shrs []libshare.Share) []*pb.Share
- type EdsID
- type Getter
- type NamespaceData
- type NamespaceDataID
- type Row
- type RowID
- type RowNamespaceData
- func (rnd RowNamespaceData) IsEmpty() bool
- func (rnd *RowNamespaceData) ReadFrom(reader io.Reader) (int64, error)
- func (rnd RowNamespaceData) ToProto() *pb.RowNamespaceData
- func (rnd RowNamespaceData) Verify(roots *share.AxisRoots, namespace libshare.Namespace, rowIdx int) error
- func (rnd RowNamespaceData) WriteTo(writer io.Writer) (int64, error)
- type RowNamespaceDataID
- func (rndid *RowNamespaceDataID) Equals(other RowNamespaceDataID) bool
- func (rndid RowNamespaceDataID) MarshalBinary() ([]byte, error)
- func (rndid *RowNamespaceDataID) ReadFrom(r io.Reader) (int64, error)
- func (rndid RowNamespaceDataID) Validate() error
- func (rndid RowNamespaceDataID) Verify(edsSize int) error
- func (rndid RowNamespaceDataID) WriteTo(w io.Writer) (int64, error)
- type RowSide
- type Sample
- type SampleID
- type SampleIndex
Constants ¶
const EDSName = "eds_v0"
EDSName is the name identifier for the Extended Data Square.
const EdsIDSize = 8
EdsIDSize defines the byte size of the EdsID.
const NamespaceDataIDSize = EdsIDSize + libshare.NamespaceSize
NamespaceDataIDSize defines the total size of a NamespaceDataID in bytes, combining the size of a EdsID and the size of a Namespace.
const NamespaceDataName = "nd_v0"
NamespaceDataName is the name identifier for the namespace data container.
const RowIDSize = EdsIDSize + 2
RowIDSize defines the size in bytes of RowID, consisting of the size of EdsID and 2 bytes for RowIndex.
const RowName = "row_v0"
RowName is the name identifier for the row container.
const RowNamespaceDataIDSize = RowIDSize + libshare.NamespaceSize
RowNamespaceDataIDSize defines the total size of a RowNamespaceDataID in bytes, combining the size of a RowID and the size of a Namespace.
const RowNamespaceDataName = "rnd_v0"
RowNamespaceDataName is the name identifier for the row namespace data container.
const SampleIDSize = RowIDSize + 2
SampleIDSize defines the size of the SampleID in bytes, combining RowID size and 2 additional bytes for the ShareIndex.
const SampleName = "sample_v0"
SampleName is the name identifier for the sample container.
Variables ¶
var ( // ErrOperationNotSupported is used to indicate that the operation is not supported by the // implementation of the getter interface. ErrOperationNotSupported = errors.New("operation is not supported") // ErrNotFound is used to indicate that requested data could not be found. ErrNotFound = errors.New("data not found") // ErrInvalidID is used to indicate that an ID failed validation. ErrInvalidID = errors.New("invalid shwap ID") // ErrOutOfBounds is used to indicate that a passed row or column index is out of bounds of the // square size. ErrOutOfBounds = fmt.Errorf("index out of bounds: %w", ErrInvalidID) )
var ErrFailedVerification = errors.New("failed to verify inclusion")
ErrFailedVerification is returned when inclusion proof verification fails. It is returned when the data and the proof do not match trusted data root.
var ErrNamespaceOutsideRange = errors.New("target namespace is outside of namespace range for the given root")
ErrNamespaceOutsideRange is returned by RowNamespaceDataFromShares when the target namespace is outside of the namespace range for the given row. In this case, the implementation cannot return the non-inclusion proof and will return ErrNamespaceOutsideRange.
Functions ¶
func ShareFromProto ¶
ShareFromProto converts a protobuf Share object to the application's internal share representation. It returns nil if the input protobuf Share is nil, ensuring safe handling of nil values.
func SharesFromProto ¶
SharesFromProto converts a slice of protobuf Share objects to the application's internal slice of Shares. It ensures that each Share is correctly transformed using the ShareFromProto function.
Types ¶
type EdsID ¶
type EdsID struct {
Height uint64 // Height specifies the block height.
}
EdsID represents a unique identifier for a row, using the height of the block to identify the data square in the chain.
func EdsIDFromBinary ¶
EdsIDFromBinary decodes a byte slice into an EdsID, validating the length of the data. It returns an error if the data slice does not match the expected size of an EdsID.
func (EdsID) MarshalBinary ¶
MarshalBinary encodes an EdsID into its binary form, primarily for storage or network transmission.
type Getter ¶
type Getter interface { // GetSamples gets samples by their indices. // Returns Sample slice with requested number of samples in the requested order. // May return partial response with some samples being empty if they weren't found. GetSamples(ctx context.Context, header *header.ExtendedHeader, indices []SampleIndex) ([]Sample, error) // GetEDS gets the full EDS identified by the given extended header. GetEDS(context.Context, *header.ExtendedHeader) (*rsmt2d.ExtendedDataSquare, error) // Shares are returned in a row-by-row order if the namespace spans multiple rows. // Inclusion of returned data could be verified using Verify method on NamespacedShares. // If no shares are found for target namespace non-inclusion could be also verified by calling // Verify method. GetSharesByNamespace(context.Context, *header.ExtendedHeader, libshare.Namespace) (NamespaceData, error) }
Getter interface provides a set of accessors for shares by the Root. Automatically verifies integrity of shares(exceptions possible depending on the implementation).
type NamespaceData ¶
type NamespaceData []RowNamespaceData
NamespaceData stores collections of RowNamespaceData, each representing shares and their proofs within a namespace. NOTE: NamespaceData does not have it protobuf Container representation and its only *streamed* as RowNamespaceData. The protobuf might be added as need comes.
func (NamespaceData) Flatten ¶
func (nd NamespaceData) Flatten() []libshare.Share
Flatten combines all shares from all rows within the namespace into a single slice.
func (*NamespaceData) ReadFrom ¶
func (nd *NamespaceData) ReadFrom(reader io.Reader) (int64, error)
ReadFrom reads NamespaceData from the provided reader implementing io.ReaderFrom. It reads series of length-delimited RowNamespaceData until EOF draining the stream.
type NamespaceDataID ¶
type NamespaceDataID struct { // Embedding EdsID to include the block height. EdsID // DataNamespace will be used to identify the data within the EDS. DataNamespace libshare.Namespace }
NamespaceDataID filters the data in the EDS by a specific namespace.
func NamespaceDataIDFromBinary ¶
func NamespaceDataIDFromBinary(data []byte) (NamespaceDataID, error)
NamespaceDataIDFromBinary deserializes a NamespaceDataID from its binary form. It returns an error if the binary data's length does not match the expected size.
func NewNamespaceDataID ¶
func NewNamespaceDataID(height uint64, namespace libshare.Namespace) (NamespaceDataID, error)
NewNamespaceDataID creates a new NamespaceDataID with the specified parameters. It validates the namespace and returns an error if it is invalid.
func (*NamespaceDataID) Equals ¶
func (ndid *NamespaceDataID) Equals(other NamespaceDataID) bool
Equals checks equality of NamespaceDataID.
func (NamespaceDataID) MarshalBinary ¶
func (ndid NamespaceDataID) MarshalBinary() ([]byte, error)
MarshalBinary encodes NamespaceDataID into binary form. NOTE: Proto is avoided because * Its size is not deterministic which is required for IPLD. * No support for uint16
func (*NamespaceDataID) ReadFrom ¶
func (ndid *NamespaceDataID) ReadFrom(r io.Reader) (int64, error)
ReadFrom reads the binary form of NamespaceDataID from the provided reader.
func (NamespaceDataID) Validate ¶
func (ndid NamespaceDataID) Validate() error
Validate checks if the NamespaceDataID is valid. It checks the validity of the EdsID and the DataNamespace.
type Row ¶
type Row struct {
// contains filtered or unexported fields
}
Row represents a portion of a row in an EDS, either left or right half.
func RowFromProto ¶
RowFromProto converts a protobuf Row to a Row structure.
func RowFromShares ¶
RowFromShares constructs a new Row from an Extended Data Square based on the specified index and side.
func (Row) Shares ¶
Shares reconstructs the complete row shares from the half provided, using RSMT2D for data recovery if needed.
type RowID ¶
type RowID struct { EdsID // Embedding EdsID to include the block height in RowID. RowIndex int // RowIndex specifies the position of the row within the data share. }
RowID uniquely identifies a row in the data square of a blockchain block, combining block height with the row's index.
func NewRowID ¶
NewRowID creates a new RowID with the specified block height, row index, and EDS size. It returns an error if the validation fails, ensuring the RowID conforms to expected constraints.
func RowIDFromBinary ¶
RowIDFromBinary decodes a RowID from its binary representation. It returns an error if the input data does not conform to the expected size or content format.
func (RowID) MarshalBinary ¶
MarshalBinary encodes the RowID into a binary form for storage or network transmission.
type RowNamespaceData ¶
type RowNamespaceData struct { Proof *nmt.Proof `json:"proof"` // Proof of the shares' inclusion in the namespace. }
RowNamespaceData holds shares and their corresponding proof for a single row within a namespace.
func RowNamespaceDataFromProto ¶
func RowNamespaceDataFromProto(row *pb.RowNamespaceData) (RowNamespaceData, error)
RowNamespaceDataFromProto constructs RowNamespaceData out of its protobuf representation.
func RowNamespaceDataFromShares ¶
func RowNamespaceDataFromShares( shares []libshare.Share, namespace libshare.Namespace, rowIndex int, ) (RowNamespaceData, error)
RowNamespaceDataFromShares extracts and constructs a RowNamespaceData from shares within the specified namespace.
func (RowNamespaceData) IsEmpty ¶
func (rnd RowNamespaceData) IsEmpty() bool
IsEmpty reports whether the RowNamespaceData is empty, i.e. doesn't contain a proof.
func (*RowNamespaceData) ReadFrom ¶
func (rnd *RowNamespaceData) ReadFrom(reader io.Reader) (int64, error)
ReadFrom reads length-delimited protobuf representation of RowNamespaceData implementing io.ReaderFrom.
func (RowNamespaceData) ToProto ¶
func (rnd RowNamespaceData) ToProto() *pb.RowNamespaceData
ToProto converts RowNamespaceData to its protobuf representation for serialization.
type RowNamespaceDataID ¶
type RowNamespaceDataID struct { RowID // Embedded RowID representing the specific row in the EDS. // DataNamespace is used to facilitate comparisons. DataNamespace libshare.Namespace }
RowNamespaceDataID uniquely identifies a piece of namespaced data within a row of an Extended Data Square (EDS).
func NewRowNamespaceDataID ¶
func NewRowNamespaceDataID( height uint64, rowIdx int, namespace libshare.Namespace, edsSize int, ) (RowNamespaceDataID, error)
NewRowNamespaceDataID creates a new RowNamespaceDataID with the specified parameters. It validates the RowNamespaceDataID against the provided EDS size.
func RowNamespaceDataIDFromBinary ¶
func RowNamespaceDataIDFromBinary(data []byte) (RowNamespaceDataID, error)
RowNamespaceDataIDFromBinary deserializes a RowNamespaceDataID from its binary form. It returns an error if the binary data's length does not match the expected size.
func (*RowNamespaceDataID) Equals ¶
func (rndid *RowNamespaceDataID) Equals(other RowNamespaceDataID) bool
Equals checks equality of RowNamespaceDataID.
func (RowNamespaceDataID) MarshalBinary ¶
func (rndid RowNamespaceDataID) MarshalBinary() ([]byte, error)
MarshalBinary encodes RowNamespaceDataID into binary form. NOTE: Proto is avoided because * Its size is not deterministic which is required for IPLD. * No support for uint16
func (*RowNamespaceDataID) ReadFrom ¶
func (rndid *RowNamespaceDataID) ReadFrom(r io.Reader) (int64, error)
ReadFrom reads the binary form of RowNamespaceDataID from the provided reader.
func (RowNamespaceDataID) Validate ¶
func (rndid RowNamespaceDataID) Validate() error
Validate performs basic field validation.
func (RowNamespaceDataID) Verify ¶
func (rndid RowNamespaceDataID) Verify(edsSize int) error
Verify validates the RowNamespaceDataID and verifies the embedded RowID.
type RowSide ¶
type RowSide int
RowSide enumerates the possible sides of a row within an Extended Data Square (EDS).
func (RowSide) ToProto ¶
func (s RowSide) ToProto() pb.Row_HalfSide
ToProto converts a RowSide to its protobuf representation.
type Sample ¶
type Sample struct { Proof *nmt.Proof // Proof is the Merkle Proof validating the share's inclusion. ProofType rsmt2d.Axis // ProofType indicates whether the proof is against a row or a column. }
Sample represents a data share along with its Merkle proof, used to validate the share's inclusion in a data square.
func SampleFromProto ¶
SampleFromProto converts a protobuf Sample back into its domain model equivalent.
func SampleFromShares ¶
func SampleFromShares(shares []libshare.Share, proofType rsmt2d.Axis, idx SampleIndex) (Sample, error)
SampleFromShares creates a Sample from a list of shares, using the specified proof type and the share index to be included in the sample.
type SampleID ¶
type SampleID struct { RowID // Embeds RowID to incorporate block height and row index. }
SampleID uniquely identifies a specific sample within a row of an Extended Data Square (EDS).
func NewSampleID ¶
func NewSampleID(height uint64, idx SampleIndex, edsSize int) (SampleID, error)
NewSampleID constructs a new SampleID using the provided block height, sample index, and EDS size. It calculates the row and share index based on the sample index and EDS size.
func SampleIDFromBinary ¶
SampleIDFromBinary deserializes a SampleID from binary data, ensuring the data length matches the expected size.
func (SampleID) MarshalBinary ¶
MarshalBinary encodes SampleID into binary form. NOTE: Proto is avoided because * Its size is not deterministic which is required for IPLD. * No support for uint16
type SampleIndex ¶
type SampleIndex int
func SampleIndexFromCoordinates ¶
func SampleIndexFromCoordinates(rowIdx, colIdx, edsSize int) (SampleIndex, error)
func (SampleIndex) Coordinates ¶
func (s SampleIndex) Coordinates(squareSize int) (int, int, error)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
mock
Package mock is a generated GoMock package.
|
Package mock is a generated GoMock package. |
p2p
|
|
shrex
Package shrex provides functionality that powers the share exchange protocols used by celestia-node.
|
Package shrex provides functionality that powers the share exchange protocols used by celestia-node. |
shrex/peers
Package peers provides a peer manager that handles peer discovery and peer selection for the shrex getter.
|
Package peers provides a peer manager that handles peer discovery and peer selection for the shrex getter. |
shrex/shrexeds
This package defines a protocol that is used to request extended data squares from peers in the network.
|
This package defines a protocol that is used to request extended data squares from peers in the network. |
shrex/shrexnd
This package defines a protocol that is used to request namespaced data from peers in the network.
|
This package defines a protocol that is used to request namespaced data from peers in the network. |
shrex/shrexsub
This package defines a protocol that is used to broadcast shares to peers over a pubsub network.
|
This package defines a protocol that is used to broadcast shares to peers over a pubsub network. |