blob

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// DefaultGasPrice specifies the default gas price value to be used when the user
	// wants to use the global minimal gas price, which is fetched from the celestia-app.
	DefaultGasPrice float64 = -1.0
)
View Source
const (
	// NMTIgnoreMaxNamespace is currently used value for IgnoreMaxNamespace option in NMT.
	// IgnoreMaxNamespace defines whether the largest possible Namespace MAX_NID should be 'ignored'.
	// If set to true, this allows for shorter proofs in particular use-cases.
	NMTIgnoreMaxNamespace = true
)

Variables

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

Functions

func BlobsToShares added in v0.5.0

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

BlobsToShares accepts blobs and convert them to the Shares.

Types

type API

type API struct {
	// Submit sends Blobs and reports the height in which they were included.
	// Allows sending multiple Blobs atomically synchronously.
	// Uses default wallet registered on the Node.
	Submit func(context.Context, []*Blob, *SubmitOptions) (uint64, error) `perm:"write"`
	// Get retrieves the blob by commitment under the given namespace and height.
	Get func(context.Context, uint64, share.Namespace, Commitment) (*Blob, error) `perm:"read"`
	// GetAll returns all blobs at the given height under the given namespaces.
	GetAll func(context.Context, uint64, []share.Namespace) ([]*Blob, error) `perm:"read"`
	// GetProof retrieves proofs in the given namespaces at the given height by commitment.
	GetProof func(context.Context, uint64, share.Namespace, Commitment) (*Proof, error) `perm:"read"`
	// Included checks whether a blob's given commitment(Merkle subtree root) is included at
	// given height and under the namespace.
	Included func(context.Context, uint64, share.Namespace, *Proof, Commitment) (bool, error) `perm:"read"`
	// GetCommitmentProof generates a commitment proof for a share commitment.
	GetCommitmentProof func(
		ctx context.Context,
		height uint64,
		namespace share.Namespace,
		shareCommitment []byte,
	) (*CommitmentProof, error) `perm:"read"`
	// Subscribe to published blobs from the given namespace as they are included.
	Subscribe func(
		context.Context,
		share.Namespace,
	) (<-chan *SubscriptionResponse, error) `perm:"read"`
}

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.5.0

func (b *Blob) Index() int

func (*Blob) Length added in v0.5.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) 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.5.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         proofs.RowProof `json:"row_proof"`
	NamespaceVersion uint8           `json:"namespace_version"`
}

CommitmentProof is an inclusion proof of a commitment to the data root. TODO: The verification methods are not copied over from celestia-node because of problematic imports.

type ConfigOption added in v0.5.0

type ConfigOption func(cfg *SubmitOptions)

ConfigOption is the functional option that is applied to the TxConfig instance to configure parameters.

func WithFeeGranterAddress added in v0.5.0

func WithFeeGranterAddress(granter string) ConfigOption

WithFeeGranterAddress is an option that allows you to specify a GranterAddress to pay the fees.

func WithGas added in v0.5.0

func WithGas(gas uint64) ConfigOption

WithGas is an option that allows to specify Gas. Gas will be calculated in case it wasn't specified.

func WithGasPrice added in v0.5.0

func WithGasPrice(gasPrice float64) ConfigOption

WithGasPrice is an option that allows to specify a GasPrice, which is needed to calculate the fee. In case GasPrice is not specified, the global GasPrice fetched from celestia-app will be used.

func WithKeyName added in v0.5.0

func WithKeyName(key string) ConfigOption

WithKeyName is an option that allows you to specify an KeyName, which is needed to sign the transaction. This key should be associated with the address and stored locally in the key store. Default Account will be used in case it wasn't specified.

func WithSignerAddress added in v0.5.0

func WithSignerAddress(address string) ConfigOption

WithSignerAddress is an option that allows you to specify an address, that will sign the transaction. This address must be stored locally in the key store. Default signerAddress will be used in case it wasn't specified.

type Proof

type Proof []*nmt.Proof

Proof is a collection of nmt.Proofs that verifies the inclusion of the data. Proof proves the WHOLE namespaced data for the particular row. 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 SubmitOptions added in v0.5.0

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

SubmitOptions specifies additional options that will be applied to the Tx.

func NewSubmitOptions added in v0.5.0

func NewSubmitOptions(opts ...ConfigOption) *SubmitOptions

NewSubmitOptions constructs a new SubmitOptions with the provided options. It starts with a DefaultGasPrice and then applies any additional options provided through the variadic parameter.

func (*SubmitOptions) FeeGranterAddress added in v0.5.0

func (cfg *SubmitOptions) FeeGranterAddress() string

func (*SubmitOptions) GasLimit added in v0.5.0

func (cfg *SubmitOptions) GasLimit() uint64

func (*SubmitOptions) GasPrice added in v0.5.0

func (cfg *SubmitOptions) GasPrice() float64

func (*SubmitOptions) KeyName added in v0.5.0

func (cfg *SubmitOptions) KeyName() string

func (*SubmitOptions) MarshalJSON added in v0.5.0

func (cfg *SubmitOptions) MarshalJSON() ([]byte, error)

func (*SubmitOptions) SignerAddress added in v0.5.0

func (cfg *SubmitOptions) SignerAddress() string

func (*SubmitOptions) UnmarshalJSON added in v0.5.0

func (cfg *SubmitOptions) UnmarshalJSON(data []byte) error

type SubscriptionResponse added in v0.5.0

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

Jump to

Keyboard shortcuts

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