share

package
v0.18.0-not-final-expe... Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 14 Imported by: 15

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

View Source
const (
	// DataHashSize is the size of the DataHash.
	DataHashSize = 32
	// AxisRootSize is the size of the single root in AxisRoots.
	AxisRootSize = 90
)

Variables

View Source
var DefaultRSMT2DCodec = appconsts.DefaultCodec

DefaultRSMT2DCodec sets the default rsmt2d.Codec for shares.

View Source
var ErrNotAvailable = errors.New("share: data not available")

ErrNotAvailable is returned whenever DA sampling fails.

MaxSquareSize is currently the maximum size supported for unerasured data in rsmt2d.ExtendedDataSquare.

Functions

func EmptyBlockShares added in v0.11.0

func EmptyBlockShares() []libshare.Share

EmptyBlockShares returns the shares of the empty block.

func EmptyEDS added in v0.20.2

func EmptyEDS() *rsmt2d.ExtendedDataSquare

EmptyEDS returns the EDS of the empty block data square.

func IsAboveMax added in v0.20.2

func IsAboveMax(namespace libshare.Namespace, hash []byte) (bool, error)

IsAboveMax checks if the namespace is above the maximum namespace of the given hash.

func IsBelowMin added in v0.20.2

func IsBelowMin(namespace libshare.Namespace, hash []byte) (bool, error)

IsBelowMin checks if the target namespace is below the minimum namespace of the given hash.

func IsOutsideRange added in v0.20.2

func IsOutsideRange(namespace libshare.Namespace, leftHash, rightHash []byte) (bool, error)

IsOutsideRange checks if the namespace is outside the min-max range of the given hashes.

func NewSHA256Hasher added in v0.13.5

func NewSHA256Hasher() hash.Hash

NewSHA256Hasher returns a new instance of a SHA-256 hasher.

func RootHashForCoordinates added in v0.20.2

func RootHashForCoordinates(r *AxisRoots, axisType rsmt2d.Axis, rowIdx, colIdx uint) []byte

RootHashForCoordinates returns the root hash for the given coordinates.

func RowsWithNamespace added in v0.20.2

func RowsWithNamespace(root *AxisRoots, namespace libshare.Namespace) (idxs []int, err error)

RowsWithNamespace inspects the AxisRoots for the Namespace and provides a slices of Row indexes containing the namespace.

Types

type Availability

type Availability interface {
	// SharesAvailable subjectively validates if Shares committed to the given Root are available on
	// the Network.
	SharesAvailable(context.Context, *header.ExtendedHeader) error
}

Availability defines interface for validation of Shares' availability.

type AxisRoots added in v0.20.2

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 added in v0.20.2

func EmptyEDSRoots() *AxisRoots

EmptyEDSRoots returns AxisRoots of the empty block EDS.

func NewAxisRoots added in v0.20.2

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 added in v0.20.2

func EmptyEDSDataHash() DataHash

EmptyEDSDataHash returns DataHash of the empty block EDS.

func MustDataHashFromString added in v0.11.0

func MustDataHashFromString(datahash string) DataHash

MustDataHashFromString converts a hex string to a valid datahash.

func (DataHash) IsEmptyEDS added in v0.20.2

func (dh DataHash) IsEmptyEDS() bool

IsEmptyEDS check whether DataHash corresponds to the root of an empty block EDS.

func (DataHash) String added in v0.5.0

func (dh DataHash) String() string

func (DataHash) Validate added in v0.5.0

func (dh DataHash) Validate() error

type ShareWithProof

type ShareWithProof struct {
	// Share is a full data including namespace
	libshare.Share
	// Proof is a Merkle Proof of current share
	Proof *nmt.Proof
	// Axis is a type of axis against which the share proof is computed
	Axis rsmt2d.Axis
}

ShareWithProof contains data with corresponding Merkle Proof

func (*ShareWithProof) Validate

func (s *ShareWithProof) Validate(rootHash []byte, x, y, edsSize int) bool

Validate validates inclusion of the share under the given root CID.

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.
eds
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.
pb

Jump to

Keyboard shortcuts

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