Documentation ¶
Overview ¶
Package share contains logic related to the retrieval and random sampling of shares of block data.
Though this package contains several useful methods for getting specific shares and/or sampling them at random, a particularly useful method is GetSharesByNamespace which retrieves all shares of block data of the given Namespace from the block associated with the given DataAvailabilityHeader (DAH, but referred to as AxisRoots within this package).
This package also contains declaration of the Availability interface. Implementations of the interface (light, full) are located in the availability sub-folder. Light Availability implementation samples for 16 shares of block data (enough to verify the block's availability on the network). Full Availability implementation samples for as many shares as necessary to fully reconstruct the block data.
Index ¶
- Constants
- Variables
- func EmptyEDS() *rsmt2d.ExtendedDataSquare
- func GetData(s Share) []byte
- func NewSHA256Hasher() hash.Hash
- func RootHashForCoordinates(r *AxisRoots, axisType rsmt2d.Axis, rowIdx, colIdx uint) []byte
- func RowsWithNamespace(root *AxisRoots, namespace Namespace) (idxs []int)
- func ValidateShare(s Share) error
- type Availability
- type AxisRoots
- type DataHash
- type Namespace
- func (n Namespace) AddInt(val int) (Namespace, error)
- 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 Share
- type ShareWithProof
Constants ¶
const ( // DataHashSize is the size of the DataHash. DataHashSize = 32 // AxisRootSize is the size of the single root in AxisRoots. AxisRootSize = 90 )
const NamespaceSize = appns.NamespaceSize
NamespaceSize is a system-wide size for NMT namespaces.
const ( // Size is a system-wide size of a share, including both data and namespace GetNamespace Size = appconsts.ShareSize )
Variables ¶
var ( // MaxPrimaryReservedNamespace is the highest primary reserved namespace. // Namespaces lower than this are reserved for protocol use. MaxPrimaryReservedNamespace = Namespace(appns.MaxPrimaryReservedNamespace.Bytes()) // MinSecondaryReservedNamespace is the lowest secondary reserved namespace // reserved for protocol use. Namespaces higher than this are reserved for // protocol use. MinSecondaryReservedNamespace = Namespace(appns.MinSecondaryReservedNamespace.Bytes()) TailPaddingNamespace = Namespace(appns.TailPaddingNamespace.Bytes()) PrimaryReservedPaddingNamespace = Namespace(appns.PrimaryReservedPaddingNamespace.Bytes()) TxNamespace = Namespace(appns.TxNamespace.Bytes()) PayForBlobNamespace = Namespace(appns.PayForBlobNamespace.Bytes()) ISRNamespace = Namespace(appns.IntermediateStateRootsNamespace.Bytes()) )
Various reserved namespaces.
var DefaultRSMT2DCodec = appconsts.DefaultCodec
DefaultRSMT2DCodec sets the default rsmt2d.Codec for shares.
var ErrNotAvailable = errors.New("share: data not available")
ErrNotAvailable is returned whenever DA sampling fails.
var MaxSquareSize = appconsts.SquareSizeUpperBound(appconsts.LatestVersion)
MaxSquareSize is currently the maximum size supported for unerasured data in rsmt2d.ExtendedDataSquare.
Functions ¶
func EmptyEDS ¶
func EmptyEDS() *rsmt2d.ExtendedDataSquare
EmptyEDS returns the EDS of the empty block data square.
func NewSHA256Hasher ¶ added in v0.13.5
NewSHA256Hasher returns a new instance of a SHA-256 hasher.
func RootHashForCoordinates ¶
RootHashForCoordinates returns the root hash for the given coordinates.
func RowsWithNamespace ¶
RowsWithNamespace inspects the AxisRoots for the Namespace and provides a slices of Row indexes containing the namespace.
func ValidateShare ¶
ValidateShare checks the size of a given share.
Types ¶
type Availability ¶
type Availability interface { // the Network. SharesAvailable(context.Context, *header.ExtendedHeader) error }
Availability defines interface for validation of Shares' availability.
type AxisRoots ¶
type AxisRoots = da.DataAvailabilityHeader
AxisRoots represents root commitment to multiple Shares. In practice, it is a commitment to all the Data in a square.
func EmptyEDSRoots ¶
func EmptyEDSRoots() *AxisRoots
EmptyEDSRoots returns AxisRoots of the empty block EDS.
func NewAxisRoots ¶
func NewAxisRoots(eds *rsmt2d.ExtendedDataSquare) (*AxisRoots, error)
NewAxisRoots generates AxisRoots(DataAvailabilityHeader) using the provided extended data square.
type DataHash ¶ added in v0.5.0
type DataHash []byte
DataHash is a representation of the AxisRoots hash.
func EmptyEDSDataHash ¶
func EmptyEDSDataHash() DataHash
EmptyEDSDataHash returns DataHash of the empty block EDS.
func MustDataHashFromString ¶ added in v0.11.0
MustDataHashFromString converts a hex string to a valid datahash.
func (DataHash) IsEmptyEDS ¶
IsEmptyEDS check whether DataHash corresponds to the root of an empty block EDS.
type Namespace ¶ added in v0.11.0
type Namespace []byte
Namespace represents namespace of a Share. Consists of version byte and namespace ID.
func GetNamespace ¶ added in v0.11.0
GetNamespace slices Namespace out of the Share.
func NamespaceFromBytes ¶ added in v0.11.0
NamespaceFromBytes converts bytes into Namespace and validates it.
func NewBlobNamespaceV0 ¶ added in v0.11.0
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) AddInt ¶
AddInt adds arbitrary int value to namespace, treating namespace as big-endian implementation of int
func (Namespace) IsAboveMax ¶ added in v0.11.0
IsAboveMax checks if the namespace is above the maximum namespace of the given hash.
func (Namespace) IsBelowMin ¶ added in v0.11.0
IsBelowMin checks if the target namespace is below the minimum namespace of the given hash.
func (Namespace) IsGreater ¶ added in v0.11.0
IsGreater reports if the Namespace is greater than the target.
func (Namespace) IsGreaterOrEqualThan ¶ added in v0.11.0
IsGreaterOrEqualThan reports if the Namespace is greater or equal than the target.
func (Namespace) IsLessOrEqual ¶ added in v0.11.0
IsLessOrEqual reports if the Namespace is less than the target.
func (Namespace) IsOutsideRange ¶ added in v0.11.0
IsOutsideRange checks if the namespace is outside the min-max range of the given hashes.
func (Namespace) ToAppNamespace ¶ added in v0.11.0
ToAppNamespace converts the Namespace to App's definition of Namespace. TODO: Unify types between node and app
func (Namespace) ToNMT ¶ added in v0.11.0
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 ¶ added in v0.11.0
ValidateForBlob checks if the Namespace is valid blob namespace.
func (Namespace) ValidateForData ¶ added in v0.11.0
ValidateForData checks if the Namespace is of real/useful data.
type Share ¶
type Share = []byte
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.
func EmptyBlockShares ¶ added in v0.11.0
func EmptyBlockShares() []Share
EmptyBlockShares returns the shares of the empty block.
func TailPadding ¶
func TailPadding() Share
TailPadding is a constant tail padding share exported for reuse
type ShareWithProof ¶
ShareWithProof contains data with corresponding Merkle Proof
Directories ¶
Path | Synopsis |
---|---|
availability
|
|
light
TODO(@Wondertan): Instead of doing sampling over the coordinates do a random walk over NMT trees.
|
TODO(@Wondertan): Instead of doing sampling over the coordinates do a random walk over NMT trees. |
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
getters/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. |
p2p/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. |
p2p/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. |
p2p/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. |
p2p/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. |