Documentation ¶
Index ¶
- Constants
- Variables
- func BlobMinSquareSize(shareCount int) int
- func NewReservedBytes(byteIndex uint32) ([]byte, error)
- func ParseReservedBytes(reservedBytes []byte) (uint32, error)
- func RoundDownPowerOfTwo[I constraints.Integer](input I) (I, error)
- func RoundUpPowerOfTwo[I constraints.Integer](input I) I
- func SubTreeWidth(shareCount, subtreeRootThreshold int) int
- func ToBytes(shares []Share) (bytes [][]byte)
- type Builder
- func (b *Builder) AddData(rawData []byte) (rawDataLeftOver []byte)
- func (b *Builder) AvailableBytes() int
- func (b *Builder) Build() (*Share, error)
- func (b *Builder) FlipSequenceStart()
- func (b *Builder) ImportRawShare(rawBytes []byte) *Builder
- func (b *Builder) Init() (*Builder, error)
- func (b *Builder) IsEmptyShare() bool
- func (b *Builder) MaybeWriteReservedBytes() error
- func (b *Builder) WriteSequenceLen(sequenceLen uint32) error
- func (b *Builder) ZeroPadIfNecessary() (bytesOfPadding int)
- type DataHash
- type InfoByte
- type Namespace
- func (n Namespace) Equals(target Namespace) bool
- func (n Namespace) ID() namespace.ID
- func (n Namespace) IsAboveMax(nodeHash []byte) bool
- func (n Namespace) IsBelowMin(nodeHash []byte) bool
- func (n Namespace) IsGreater(target Namespace) bool
- func (n Namespace) IsGreaterOrEqualThan(target Namespace) bool
- func (n Namespace) IsLess(target Namespace) bool
- func (n Namespace) IsLessOrEqual(target Namespace) bool
- func (n Namespace) IsOutsideRange(leftNodeHash, rightNodeHash []byte) bool
- func (n Namespace) Len() int
- func (n Namespace) Repeat(t int) []Namespace
- func (n Namespace) String() string
- func (n Namespace) ToAppNamespace() appns.Namespace
- func (n Namespace) ToNMT() namespace.ID
- func (n Namespace) Validate() error
- func (n Namespace) ValidateForBlob() error
- func (n Namespace) ValidateForData() error
- func (n Namespace) Version() byte
- type NamespacedRow
- type NamespacedShares
- type Root
- type Share
- func (s *Share) DoesSupportVersions(supportedShareVersions []uint8) error
- func (s *Share) InfoByte() (InfoByte, error)
- func (s Share) IsCompactShare() (bool, error)
- func (s *Share) IsPadding() (bool, error)
- func (s *Share) IsSequenceStart() (bool, error)
- func (s *Share) Len() int
- func (s *Share) Namespace() (namespace.Namespace, error)
- func (s *Share) RawData() (rawData []byte, err error)
- func (s *Share) RawDataUsingReserved() (rawData []byte, err error)
- func (s *Share) SequenceLen() (sequenceLen uint32, err error)
- func (s *Share) ToBytes() []byte
- func (s *Share) Validate() error
- func (s *Share) Version() (uint8, error)
- type SparseShareSplitter
Constants ¶
const ( // Size is a system-wide size of a share, including both data and namespace GetNamespace Size = appconsts.ShareSize )
Variables ¶
var ( MaxReservedNamespace = Namespace(appns.MaxReservedNamespace.Bytes()) TailPaddingNamespace = Namespace(appns.TailPaddingNamespace.Bytes()) ReservedPaddingNamespace = Namespace(appns.ReservedPaddingNamespace.Bytes()) TxNamespace = Namespace(appns.TxNamespace.Bytes()) PayForBlobNamespace = Namespace(appns.PayForBlobNamespace.Bytes()) )
Various reserved namespaces.
var ( // DefaultRSMT2DCodec sets the default rsmt2d.Codec for shares. DefaultRSMT2DCodec = appconsts.DefaultCodec )
var ( // ErrNotAvailable is returned whenever DA sampling fails. ErrNotAvailable = errors.New("share: data not available") )
Functions ¶
func BlobMinSquareSize ¶ added in v0.1.2
BlobMinSquareSize returns the minimum square size that can contain shareCount number of shares.
func NewReservedBytes ¶ added in v0.1.2
NewReservedBytes returns a byte slice of length appconsts.CompactShareReservedBytes that contains the byteIndex of the first unit that starts in a compact share.
func ParseReservedBytes ¶ added in v0.1.2
ParseReservedBytes parses a byte slice of length appconsts.CompactShareReservedBytes into a byteIndex.
func RoundDownPowerOfTwo ¶ added in v0.1.2
func RoundDownPowerOfTwo[I constraints.Integer](input I) (I, error)
RoundDownPowerOfTwo returns the next power of two less than or equal to input.
func RoundUpPowerOfTwo ¶ added in v0.1.2
func RoundUpPowerOfTwo[I constraints.Integer](input I) I
RoundUpPowerOfTwo returns the next power of two greater than or equal to input.
func SubTreeWidth ¶ added in v0.1.2
SubTreeWidth determines the maximum number of leaves per subtree in the share commitment over a given blob. The input should be the total number of shares used by that blob. The reasoning behind this algorithm is discussed in depth in ADR013 (celestia-app/docs/architecture/adr-013-non-interative-default-rules-for-zero-padding).
Types ¶
type Builder ¶ added in v0.1.2
type Builder struct {
// contains filtered or unexported fields
}
func NewBuilder ¶ added in v0.1.2
Init() needs to be called right after this method
func NewEmptyBuilder ¶ added in v0.1.2
func NewEmptyBuilder() *Builder
func (*Builder) AvailableBytes ¶ added in v0.1.2
func (*Builder) FlipSequenceStart ¶ added in v0.1.2
func (b *Builder) FlipSequenceStart()
FlipSequenceStart flips the sequence start indicator of the share provided
func (*Builder) ImportRawShare ¶ added in v0.1.2
func (*Builder) IsEmptyShare ¶ added in v0.1.2
IsEmptyShare returns true if no data has been written to the share
func (*Builder) MaybeWriteReservedBytes ¶ added in v0.1.2
MaybeWriteReservedBytes will be a no-op if the reserved bytes have already been populated. If the reserved bytes are empty, it will write the location of the next unit of data to the reserved bytes.
func (*Builder) WriteSequenceLen ¶ added in v0.1.2
writeSequenceLen writes the sequence length to the first share.
func (*Builder) ZeroPadIfNecessary ¶ added in v0.1.2
type InfoByte ¶ added in v0.1.2
type InfoByte byte
InfoByte is a byte with the following structure: the first 7 bits are reserved for version information in big endian form (initially `0000000`). The last bit is a "sequence start indicator", that is `1` if this is the first share of a sequence and `0` if this is a continuation share.
func NewInfoByte ¶ added in v0.1.2
func ParseInfoByte ¶ added in v0.1.2
func (InfoByte) IsSequenceStart ¶ added in v0.1.2
IsSequenceStart returns whether this share is the start of a sequence.
type Namespace ¶
type Namespace []byte
Namespace represents namespace of a Share. Consists of version byte and namespace ID.
func NamespaceFromBytes ¶
NamespaceFromBytes converts bytes into Namespace and validates it.
func NewBlobNamespaceV0 ¶
NewBlobNamespaceV0 takes a variable size byte slice and creates a valid version 0 Blob Namespace. The byte slice must be <= 10 bytes. If it is less than 10 bytes, it will be left padded to size 10 with 0s. Use predefined namespaces above, if non-blob namespace is needed.
func (Namespace) IsAboveMax ¶
IsAboveMax checks if the namespace is above the maximum namespace of the given hash.
func (Namespace) IsBelowMin ¶
IsBelowMin checks if the target namespace is below the minimum namespace of the given hash.
func (Namespace) IsGreaterOrEqualThan ¶
IsGreaterOrEqualThan reports if the Namespace is greater or equal than the target.
func (Namespace) IsLessOrEqual ¶
IsLessOrEqual reports if the Namespace is less than the target.
func (Namespace) IsOutsideRange ¶
IsOutsideRange checks if the namespace is outside the min-max range of the given hashes.
func (Namespace) ToAppNamespace ¶
ToAppNamespace converts the Namespace to App's definition of Namespace. TODO: Unify types between node and app
func (Namespace) ToNMT ¶
ToNMT converts the whole Namespace(both Version and ID parts) into NMT's namespace.ID NOTE: Once https://github.com/celestiaorg/nmt/issues/206 is closed Namespace should become NNT's type.
func (Namespace) ValidateForBlob ¶
ValidateForBlob checks if the Namespace is valid blob namespace.
func (Namespace) ValidateForData ¶
ValidateForData checks if the Namespace is of real/useful data.
type NamespacedRow ¶
NamespacedRow represents all shares with proofs within a specific namespace of a single EDS row.
type NamespacedShares ¶
type NamespacedShares []NamespacedRow
NamespacedShares represents all shares with proofs within a specific namespace of an EDS.
type Root ¶
type Root = core.DataAvailabilityHeader
Root represents root commitment to multiple Shares. In practice, it is a commitment to all the Data in a square.
type Share ¶
type Share struct {
// contains filtered or unexported fields
}
Share contains the raw share data without the corresponding namespace. NOTE: Alias for the byte is chosen to keep maximal compatibility, especially with rsmt2d. Ideally, we should define reusable type elsewhere and make everyone(Core, rsmt2d, ipld) to rely on it. Share contains the raw share data (including namespace ID).
func NamespacePaddingShare ¶ added in v0.1.2
NamespacePaddingShare returns a share that acts as padding. Namespace padding shares follow a blob so that the next blob may start at an index that conforms to blob share commitment rules. The ns parameter provided should be the namespace of the blob that precedes this padding in the data square.
func NamespacePaddingShares ¶ added in v0.1.2
NamespacePaddingShares returns n namespace padding shares.
func (*Share) DoesSupportVersions ¶ added in v0.1.2
func (Share) IsCompactShare ¶ added in v0.1.2
IsCompactShare returns true if this is a compact share.
func (*Share) IsSequenceStart ¶ added in v0.1.2
IsSequenceStart returns true if this is the first share in a sequence.
func (*Share) RawData ¶ added in v0.1.2
RawData returns the raw share data. The raw share data does not contain the namespace ID, info byte, sequence length, or reserved bytes.
func (*Share) RawDataUsingReserved ¶ added in v0.1.2
RawDataWithReserved returns the raw share data while taking reserved bytes into account.
func (*Share) SequenceLen ¶ added in v0.1.2
SequenceLen returns the sequence length of this *share and optionally an error. It returns 0, nil if this is a continuation share (i.e. doesn't contain a sequence length).
type SparseShareSplitter ¶ added in v0.1.2
type SparseShareSplitter struct {
// contains filtered or unexported fields
}
SparseShareSplitter lazily splits blobs into shares that will eventually be included in a data square. It also has methods to help progressively count how many shares the blobs written take up.
func NewSparseShareSplitter ¶ added in v0.1.2
func NewSparseShareSplitter() *SparseShareSplitter
func (*SparseShareSplitter) Count ¶ added in v0.1.2
func (sss *SparseShareSplitter) Count() int
Count returns the current number of shares that will be made if exporting.
func (*SparseShareSplitter) Export ¶ added in v0.1.2
func (sss *SparseShareSplitter) Export() []Share
Export finalizes and returns the underlying shares.
func (*SparseShareSplitter) Write ¶ added in v0.1.2
func (sss *SparseShareSplitter) Write(shareVersion uint32, ns, data []byte) error
Write writes the provided blob to this sparse share splitter. It returns an error or nil if no error is encountered.
func (*SparseShareSplitter) WriteNamespacePaddingShares ¶ added in v0.1.2
func (sss *SparseShareSplitter) WriteNamespacePaddingShares(count int) error
WriteNamespacePaddingShares adds padding shares with the namespace of the last written This is useful to follow the non-interactive default rules. This function assumes that at least one share has already been written.