types

package
v0.0.0-...-3063be3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ModuleName defines the module name
	ModuleName = "blob"

	// StoreKey defines the primary module store key
	StoreKey = ModuleName

	// RouterKey is the message route for slashing
	RouterKey = ModuleName

	// QuerierRoute defines the module's query routing key
	QuerierRoute = ModuleName

	// MemStoreKey defines the in-memory store key
	MemStoreKey = "mem_blob"
)
View Source
const (
	URLMsgPayForBlobs = "/celestia.blob.v1.MsgPayForBlobs"

	// PFBGasFixedCost is a rough estimate for the "fixed cost" in the gas cost
	// formula: gas cost = gas per byte * bytes per share * shares occupied by
	// blob + "fixed cost". In this context, "fixed cost" accounts for the gas
	// consumed by operations outside the blob's GasToConsume function (i.e.
	// signature verification, tx size, read access to accounts).
	//
	// Since the gas cost of these operations is not easy to calculate, linear
	// regression was performed on a set of observed data points to derive an
	// approximate formula for gas cost. Assuming gas per byte = 8 and bytes per
	// share = 512, we can solve for "fixed cost" and arrive at 65,000. gas cost
	// = 8 * 512 * number of shares occupied by the blob + 65,000 has a
	// correlation coefficient of 0.996. To be conservative, we round up "fixed
	// cost" to 75,000 because the first tx always takes up 10,000 more gas than
	// subsequent txs.
	PFBGasFixedCost = 75000

	// BytesPerBlobInfo is a rough estimation for the amount of extra bytes in
	// information a blob adds to the size of the underlying transaction.
	BytesPerBlobInfo = 70
)

Variables

View Source
var (
	ErrReservedNamespace              = errors.Register(ModuleName, 11110, "cannot use reserved namespace IDs")
	ErrInvalidNamespaceLen            = errors.Register(ModuleName, 11111, "invalid namespace length")
	ErrInvalidDataSize                = errors.Register(ModuleName, 11112, "data must be multiple of shareSize")
	ErrBlobSizeMismatch               = errors.Register(ModuleName, 11113, "actual blob size differs from that specified in the MsgPayForBlob")
	ErrCommittedSquareSizeNotPowOf2   = errors.Register(ModuleName, 11114, "committed to invalid square size: must be power of two")
	ErrCalculateCommitment            = errors.Register(ModuleName, 11115, "unexpected error calculating commitment for share")
	ErrInvalidShareCommitment         = errors.Register(ModuleName, 11116, "invalid commitment for share")
	ErrParitySharesNamespace          = errors.Register(ModuleName, 11117, "cannot use parity shares namespace ID")
	ErrTailPaddingNamespace           = errors.Register(ModuleName, 11118, "cannot use tail padding namespace ID")
	ErrTxNamespace                    = errors.Register(ModuleName, 11119, "cannot use transaction namespace ID")
	ErrInvalidShareCommitments        = errors.Register(ModuleName, 11122, "invalid share commitments: all relevant square sizes must be committed to")
	ErrUnsupportedShareVersion        = errors.Register(ModuleName, 11123, "unsupported share version")
	ErrZeroBlobSize                   = errors.Register(ModuleName, 11124, "cannot use zero blob size")
	ErrMismatchedNumberOfPFBorBlob    = errors.Register(ModuleName, 11125, "mismatched number of blobs per MsgPayForBlob")
	ErrNoPFB                          = errors.Register(ModuleName, 11126, "no MsgPayForBlobs found in blob transaction")
	ErrNamespaceMismatch              = errors.Register(ModuleName, 11127, "namespace of blob and its respective MsgPayForBlobs differ")
	ErrProtoParsing                   = errors.Register(ModuleName, 11128, "failure to parse a transaction from its protobuf representation")
	ErrMultipleMsgsInBlobTx           = errors.Register(ModuleName, 11129, "not yet supported: multiple sdk.Msgs found in BlobTx")
	ErrMismatchedNumberOfPFBComponent = errors.Register(ModuleName, 11130, "number of each component in a MsgPayForBlobs must be identical")
	ErrNoBlobs                        = errors.Register(ModuleName, 11131, "no blobs provided")
	ErrNoNamespaces                   = errors.Register(ModuleName, 11132, "no namespaces provided")
	ErrNoShareVersions                = errors.Register(ModuleName, 11133, "no share versions provided")
	ErrNoBlobSizes                    = errors.Register(ModuleName, 11134, "no blob sizes provided")
	ErrNoShareCommitments             = errors.Register(ModuleName, 11135, "no share commitments provided")
	ErrInvalidNamespace               = errors.Register(ModuleName, 11136, "invalid namespace")
	ErrInvalidNamespaceVersion        = errors.Register(ModuleName, 11137, "invalid namespace version")
	ErrTotalBlobSizeTooLarge          = errors.Register(ModuleName, 11138, "total blob size too large")
)
View Source
var (
	ErrInvalidLengthTx        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowTx          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group")
)

Functions

func CreateCommitment

func CreateCommitment(blob *Blob) ([]byte, error)

CreateCommitment generates the share commitment for a given blob. See [data square layout rationale] and [blob share commitment rules].

[data square layout rationale]: ../../specs/src/specs/data_square_layout.md [blob share commitment rules]: ../../specs/src/specs/data_square_layout.md#blob-share-commitment-rules

func CreateCommitments

func CreateCommitments(blobs []*Blob) ([][]byte, error)

func DefaultEstimateGas

func DefaultEstimateGas(blobSizes []uint32) uint64

DefaultEstimateGas runs EstimateGas with the system defaults. The network may change these values through governance, thus this function should predominantly be used in testing.

func EstimateGas

func EstimateGas(blobSizes []uint32, gasPerByte uint32, txSizeCost uint64) uint64

EstimateGas estimates the total gas required to pay for a set of blobs in a PFB. It is based on a linear model that is dependent on the governance parameters: gasPerByte and txSizeCost. It assumes other variables are constant. This includes assuming the PFB is the only message in the transaction.

func GasToConsume

func GasToConsume(blobSizes []uint32, gasPerByte uint32) uint64

GasToConsume works out the extra gas charged to pay for a set of blobs in a PFB. Note that tranasctions will incur other gas costs, such as the signature verification and reads to the user's account.

func KeyPrefix

func KeyPrefix(p string) []byte

func RegisterInterfaces

func RegisterInterfaces(registry codectypes.InterfaceRegistry)

func ValidateBlobNamespace

func ValidateBlobNamespace(ns appns.Namespace) error

ValidateBlobNamespace returns an error if the provided namespace is an invalid user-specifiable blob namespace (e.g. reserved, parity shares, or tail padding).

func ValidateBlobs

func ValidateBlobs(blobs ...*Blob) error

ValidateBlobs performs basic checks over the components of one or more PFBs.

Types

type Blob

type Blob = tmproto.Blob

func NewBlob

func NewBlob(ns appns.Namespace, blob []byte, shareVersion uint8) (*Blob, error)

NewBlob creates a new coretypes.Blob from the provided data after performing basic stateless checks over it.

type MsgPayForBlobs

type MsgPayForBlobs struct {
	// signer is the bech32 encoded signer address. See
	// https://en.bitcoin.it/wiki/Bech32.
	Signer string `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"`
	// namespaces is a list of namespaces that the blobs are associated with. A
	// namespace is a byte slice of length 29 where the first byte is the
	// namespaceVersion and the subsequent 28 bytes are the namespaceId.
	Namespaces [][]byte `protobuf:"bytes,2,rep,name=namespaces,proto3" json:"namespaces,omitempty"`
	// blob_sizes is a list of blob sizes (one per blob). Each size is in bytes.
	BlobSizes []uint32 `protobuf:"varint,3,rep,packed,name=blob_sizes,json=blobSizes,proto3" json:"blob_sizes,omitempty"`
	// share_commitments is a list of share commitments (one per blob).
	ShareCommitments [][]byte `protobuf:"bytes,4,rep,name=share_commitments,json=shareCommitments,proto3" json:"share_commitments,omitempty"`
	// share_versions are the versions of the share format that the blobs
	// associated with this message should use when included in a block. The
	// share_versions specified must match the share_versions used to generate the
	// share_commitment in this message.
	ShareVersions []uint32 `protobuf:"varint,8,rep,packed,name=share_versions,json=shareVersions,proto3" json:"share_versions,omitempty"`
}

MsgPayForBlobs pays for the inclusion of a blob in the block.

func NewMsgPayForBlobs

func NewMsgPayForBlobs(signer string, blobs ...*Blob) (*MsgPayForBlobs, error)

func (*MsgPayForBlobs) Descriptor

func (*MsgPayForBlobs) Descriptor() ([]byte, []int)

func (*MsgPayForBlobs) Gas

func (msg *MsgPayForBlobs) Gas(gasPerByte uint32) uint64

func (*MsgPayForBlobs) GetBlobSizes

func (m *MsgPayForBlobs) GetBlobSizes() []uint32

func (*MsgPayForBlobs) GetNamespaces

func (m *MsgPayForBlobs) GetNamespaces() [][]byte

func (*MsgPayForBlobs) GetShareCommitments

func (m *MsgPayForBlobs) GetShareCommitments() [][]byte

func (*MsgPayForBlobs) GetShareVersions

func (m *MsgPayForBlobs) GetShareVersions() []uint32

func (*MsgPayForBlobs) GetSigner

func (m *MsgPayForBlobs) GetSigner() string

func (*MsgPayForBlobs) Marshal

func (m *MsgPayForBlobs) Marshal() (dAtA []byte, err error)

func (*MsgPayForBlobs) MarshalTo

func (m *MsgPayForBlobs) MarshalTo(dAtA []byte) (int, error)

func (*MsgPayForBlobs) MarshalToSizedBuffer

func (m *MsgPayForBlobs) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*MsgPayForBlobs) ProtoMessage

func (*MsgPayForBlobs) ProtoMessage()

func (*MsgPayForBlobs) Reset

func (m *MsgPayForBlobs) Reset()

func (*MsgPayForBlobs) Route

func (msg *MsgPayForBlobs) Route() string

Route fulfills the legacytx.LegacyMsg interface

func (*MsgPayForBlobs) Size

func (m *MsgPayForBlobs) Size() (n int)

func (*MsgPayForBlobs) String

func (m *MsgPayForBlobs) String() string

func (*MsgPayForBlobs) Type

func (msg *MsgPayForBlobs) Type() string

Type fulfills the legacytx.LegacyMsg interface

func (*MsgPayForBlobs) Unmarshal

func (m *MsgPayForBlobs) Unmarshal(dAtA []byte) error

func (*MsgPayForBlobs) ValidateBasic

func (msg *MsgPayForBlobs) ValidateBasic() error

ValidateBasic fulfills the sdk.Msg interface by performing stateless validity checks on the msg that also don't require having the actual blob(s)

func (*MsgPayForBlobs) XXX_DiscardUnknown

func (m *MsgPayForBlobs) XXX_DiscardUnknown()

func (*MsgPayForBlobs) XXX_Marshal

func (m *MsgPayForBlobs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*MsgPayForBlobs) XXX_Merge

func (m *MsgPayForBlobs) XXX_Merge(src proto.Message)

func (*MsgPayForBlobs) XXX_Size

func (m *MsgPayForBlobs) XXX_Size() int

func (*MsgPayForBlobs) XXX_Unmarshal

func (m *MsgPayForBlobs) XXX_Unmarshal(b []byte) error

type MsgPayForBlobsResponse

type MsgPayForBlobsResponse struct {
}

MsgPayForBlobsResponse describes the response returned after the submission of a PayForBlobs

func (*MsgPayForBlobsResponse) Descriptor

func (*MsgPayForBlobsResponse) Descriptor() ([]byte, []int)

func (*MsgPayForBlobsResponse) Marshal

func (m *MsgPayForBlobsResponse) Marshal() (dAtA []byte, err error)

func (*MsgPayForBlobsResponse) MarshalTo

func (m *MsgPayForBlobsResponse) MarshalTo(dAtA []byte) (int, error)

func (*MsgPayForBlobsResponse) MarshalToSizedBuffer

func (m *MsgPayForBlobsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*MsgPayForBlobsResponse) ProtoMessage

func (*MsgPayForBlobsResponse) ProtoMessage()

func (*MsgPayForBlobsResponse) Reset

func (m *MsgPayForBlobsResponse) Reset()

func (*MsgPayForBlobsResponse) Size

func (m *MsgPayForBlobsResponse) Size() (n int)

func (*MsgPayForBlobsResponse) String

func (m *MsgPayForBlobsResponse) String() string

func (*MsgPayForBlobsResponse) Unmarshal

func (m *MsgPayForBlobsResponse) Unmarshal(dAtA []byte) error

func (*MsgPayForBlobsResponse) XXX_DiscardUnknown

func (m *MsgPayForBlobsResponse) XXX_DiscardUnknown()

func (*MsgPayForBlobsResponse) XXX_Marshal

func (m *MsgPayForBlobsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*MsgPayForBlobsResponse) XXX_Merge

func (m *MsgPayForBlobsResponse) XXX_Merge(src proto.Message)

func (*MsgPayForBlobsResponse) XXX_Size

func (m *MsgPayForBlobsResponse) XXX_Size() int

func (*MsgPayForBlobsResponse) XXX_Unmarshal

func (m *MsgPayForBlobsResponse) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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