blob

package
v0.18.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: Apache-2.0 Imports: 31 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBlobNotFound = errors.New("blob: not found")
	ErrInvalidProof = errors.New("blob: invalid proof")
)

Functions

func BlobsToShares

func BlobsToShares(nodeBlobs ...*Blob) ([]share.Share, error)

BlobsToShares accepts blobs and convert them to the Shares.

func ToAppBlobs added in v0.15.0

func ToAppBlobs(blobs ...*Blob) []*squareblob.Blob

ToAppBlobs converts node's blob type to the blob type from go-square.

Types

type Blob

type Blob struct {
	*blob.Blob `json:"blob"`

	Commitment Commitment `json:"commitment"`
	// contains filtered or unexported fields
}

Blob represents any application-specific binary data that anyone can submit to Celestia.

func NewBlob

func NewBlob(shareVersion uint8, namespace share.Namespace, data []byte) (*Blob, error)

NewBlob constructs a new blob from the provided Namespace, data and share version.

func NewBlobV0

func NewBlobV0(namespace share.Namespace, data []byte) (*Blob, error)

NewBlobV0 constructs a new blob from the provided Namespace and data. The blob will be formatted as v0 shares.

func (*Blob) Index added in v0.13.1

func (b *Blob) Index() int

Index returns the blob's first share index in the EDS. Only retrieved, on-chain blobs will have the index set. Default is -1.

func (*Blob) Length added in v0.15.0

func (b *Blob) Length() (int, error)

Length returns the number of shares in the blob.

func (*Blob) MarshalJSON

func (b *Blob) MarshalJSON() ([]byte, error)

func (*Blob) Namespace

func (b *Blob) Namespace() share.Namespace

Namespace returns blob's namespace.

func (*Blob) UnmarshalJSON

func (b *Blob) UnmarshalJSON(data []byte) error

type Commitment

type Commitment []byte

Commitment is a Merkle Root of the subtree built from shares of the Blob. It is computed by splitting the blob into shares and building the Merkle subtree to be included after Submit.

func (Commitment) Equal

func (com Commitment) Equal(c Commitment) bool

Equal ensures that commitments are the same

func (Commitment) String

func (com Commitment) String() string

type CommitmentProof added in v0.15.0

type CommitmentProof struct {
	// SubtreeRoots are the subtree roots of the blob's data that are
	// used to create the commitment.
	SubtreeRoots [][]byte `json:"subtree_roots"`
	// SubtreeRootProofs are the NMT proofs for the subtree roots
	// to the row roots.
	SubtreeRootProofs []*nmt.Proof `json:"subtree_root_proofs"`
	// NamespaceID is the namespace id of the commitment being proven. This
	// namespace id is used when verifying the proof. If the namespace id doesn't
	// match the namespace of the shares, the proof will fail verification.
	NamespaceID namespace.ID `json:"namespace_id"`
	// RowProof is the proof of the rows containing the blob's data to the
	// data root.
	RowProof         proof.RowProof `json:"row_proof"`
	NamespaceVersion uint8          `json:"namespace_version"`
}

CommitmentProof is an inclusion proof of a commitment to the data root.

func ProveCommitment added in v0.15.0

func ProveCommitment(
	eds *rsmt2d.ExtendedDataSquare,
	namespace share.Namespace,
	blobShares []share.Share,
) (*CommitmentProof, error)

func (*CommitmentProof) Validate added in v0.15.0

func (commitmentProof *CommitmentProof) Validate() error

Validate performs basic validation to the commitment proof. Note: it doesn't verify if the proof is valid or not. Check Verify() for that.

func (*CommitmentProof) Verify added in v0.15.0

func (commitmentProof *CommitmentProof) Verify(root []byte, subtreeRootThreshold int) (bool, error)

Verify verifies that a commitment proof is valid, i.e., the subtree roots commit to some data that was posted to a square. Expects the commitment proof to be properly formulated and validated using the Validate() function.

type Proof

type Proof []*nmt.Proof

The Proof is a set of nmt proofs that can be verified only through the included method (due to limitation of the nmt https://github.com/celestiaorg/nmt/issues/218). Proof proves the WHOLE namespaced data to the row roots. TODO (@vgonkivs): rework `Proof` in order to prove a particular blob. https://github.com/celestiaorg/celestia-node/issues/2303

func (Proof) Len

func (p Proof) Len() int

type Service

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

func NewService

func NewService(
	submitter Submitter,
	getter shwap.Getter,
	headerGetter func(context.Context, uint64) (*header.ExtendedHeader, error),
	headerSub func(ctx context.Context) (<-chan *header.ExtendedHeader, error),
) *Service

func (*Service) Get

func (s *Service) Get(
	ctx context.Context,
	height uint64,
	namespace share.Namespace,
	commitment Commitment,
) (blob *Blob, err error)

Get retrieves a blob in a given namespace at the given height by commitment. Get collects all namespaced data from the EDS, construct the blob and compares the commitment argument. `ErrBlobNotFound` can be returned in case blob was not found.

func (*Service) GetAll

func (s *Service) GetAll(ctx context.Context, height uint64, namespaces []share.Namespace) ([]*Blob, error)

GetAll returns all blobs under the given namespaces at the given height. If all blobs were found without any errors, the user will receive a list of blobs. If the BlobService couldn't find any blobs under the requested namespaces, the user will receive an empty list of blobs along with an empty error. If some of the requested namespaces were not found, the user will receive all the found blobs and an empty error. If there were internal errors during some of the requests, the user will receive all found blobs along with a combined error message.

All blobs will preserve the order of the namespaces that were requested.

func (*Service) GetCommitmentProof added in v0.15.0

func (s *Service) GetCommitmentProof(
	ctx context.Context,
	height uint64,
	namespace share.Namespace,
	shareCommitment []byte,
) (*CommitmentProof, error)

func (*Service) GetProof

func (s *Service) GetProof(
	ctx context.Context,
	height uint64,
	namespace share.Namespace,
	commitment Commitment,
) (proof *Proof, err error)

GetProof returns an NMT inclusion proof for a specified namespace to the respective row roots on which the blob spans on at the given height, using the given commitment. It employs the same algorithm as service.Get() internally.

func (*Service) Included

func (s *Service) Included(
	ctx context.Context,
	height uint64,
	namespace share.Namespace,
	proof *Proof,
	commitment Commitment,
) (_ bool, err error)

Included verifies that the blob was included in a specific height. To ensure that blob was included in a specific height, we need: 1. verify the provided commitment by recomputing it; 2. verify the provided Proof against subtree roots that were used in 1.;

func (*Service) Start added in v0.15.0

func (s *Service) Start(context.Context) error

func (*Service) Stop added in v0.15.0

func (s *Service) Stop(context.Context) error

func (*Service) Submit

func (s *Service) Submit(ctx context.Context, blobs []*Blob, txConfig *SubmitOptions) (uint64, error)

Submit sends PFB transaction and reports the height at which it was included. Allows sending multiple Blobs atomically synchronously. Uses default wallet registered on the Node. Handles gas estimation and fee calculation.

func (*Service) Subscribe added in v0.15.0

func (s *Service) Subscribe(ctx context.Context, ns share.Namespace) (<-chan *SubscriptionResponse, error)

Subscribe returns a channel that will receive SubscriptionResponse objects. The channel will be closed when the context is canceled or the service is stopped. Please note that no errors are returned: underlying operations are retried until successful. Additionally, not reading from the returned channel will cause the stream to close after 16 messages.

type SubmitOptions

type SubmitOptions = state.TxConfig

SubmitOptions aliases TxOptions from state package allowing users to specify options for SubmitPFB transaction.

type Submitter

type Submitter interface {
	SubmitPayForBlob(context.Context, []*state.Blob, *state.TxConfig) (*types.TxResponse, error)
}

Submitter is an interface that allows submitting blobs to the celestia-core. It is used to avoid a circular dependency between the blob and the state package, since the state package needs the blob.Blob type for this signature.

type SubscriptionResponse added in v0.15.0

type SubscriptionResponse struct {
	Blobs  []*Blob
	Height uint64
}

SubscriptionResponse is the response type for the Subscribe method. It contains the blobs and the height at which they were included. If the Blobs slice is empty, it means that no blobs were included at the given height.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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