celestia

package
v0.0.0-...-568787c Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShareSize = types.ShareSize

	// 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

	// DefaultGasPerBlobByte is the default gas cost deducted per byte of blob
	// included in a PayForBlobs txn
	DefaultGasPerBlobByte = 8

	DefaultTxSizeCostPerByte uint64 = 10
)

Variables

View Source
var CelestiaDefaultConfig = Config{
	BaseURL:        "http://127.0.0.1:26659",
	AppNodeURL:     "",
	Timeout:        30 * time.Second,
	Fee:            0,
	GasLimit:       20000000,
	GasPrices:      defaultGasPrices,
	GasAdjustment:  defaultGasAdjustment,
	NamespaceIDStr: "000000000000ffff",
	NamespaceID:    cnc.Namespace{Version: namespaceVersion, ID: []byte{0, 0, 0, 0, 0, 0, 255, 255}},
}

Functions

func DefaultEstimateGas

func DefaultEstimateGas(blobSize 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 WithCNCClient

func WithCNCClient(client CNCClientI) da.Option

WithCNCClient sets CNC client.

func WithRPCClient

func WithRPCClient(rpcClient rpcclient.Client) da.Option

WithRPCClient sets rpc client.

func WithSubmitRetryDelay

func WithSubmitRetryDelay(delay time.Duration) da.Option

WithSubmitRetryDelay sets submit retry delay.

func WithTxPollingAttempts

func WithTxPollingAttempts(attempts int) da.Option

WithTxPollingAttempts sets tx polling retry delay.

func WithTxPollingRetryDelay

func WithTxPollingRetryDelay(delay time.Duration) da.Option

WithTxPollingRetryDelay sets tx polling retry delay.

Types

type CNCClientI

type CNCClientI interface {
	SubmitPFB(ctx context.Context, namespaceID cnc.Namespace, blob []byte, fee int64, gasLimit uint64) (*cnc.TxResponse, error)
	NamespacedShares(ctx context.Context, namespaceID cnc.Namespace, height uint64) ([][]byte, error)
	NamespacedData(ctx context.Context, namespaceID cnc.Namespace, height uint64) ([][]byte, error)
}

type Config

type Config struct {
	BaseURL        string        `json:"base_url"`
	AppNodeURL     string        `json:"app_node_url"`
	Timeout        time.Duration `json:"timeout"`
	Fee            int64         `json:"fee"`
	GasPrices      float64       `json:"gas_prices"`
	GasAdjustment  float64       `json:"gas_adjustment"`
	GasLimit       uint64        `json:"gas_limit"`
	NamespaceIDStr string        `json:"namespace_id"`
	NamespaceID    cnc.Namespace `json:"-"`
}

Config stores Celestia DALC configuration parameters.

func (*Config) InitNamespaceID

func (c *Config) InitNamespaceID() error

type DataAvailabilityLayerClient

type DataAvailabilityLayerClient struct {
	RPCClient rpcclient.Client
	// contains filtered or unexported fields
}

DataAvailabilityLayerClient use celestia-node public API.

func (*DataAvailabilityLayerClient) CheckBatchAvailability

func (c *DataAvailabilityLayerClient) CheckBatchAvailability(dataLayerHeight uint64) da.ResultCheckBatch

CheckBatchAvailability queries DA layer to check data availability of block at given height.

func (*DataAvailabilityLayerClient) GetClientType

func (c *DataAvailabilityLayerClient) GetClientType() da.Client

GetClientType returns client type.

func (*DataAvailabilityLayerClient) Init

func (c *DataAvailabilityLayerClient) Init(config []byte, pubsubServer *pubsub.Server, kvStore store.KVStore, logger log.Logger, options ...da.Option) error

Init initializes DataAvailabilityLayerClient instance.

func (*DataAvailabilityLayerClient) RetrieveBatches

func (c *DataAvailabilityLayerClient) RetrieveBatches(dataLayerHeight uint64) da.ResultRetrieveBatch

RetrieveBatches gets a batch of blocks from DA layer.

func (*DataAvailabilityLayerClient) Start

Start prepares DataAvailabilityLayerClient to work.

func (*DataAvailabilityLayerClient) Stop

Stop stops DataAvailabilityLayerClient.

func (*DataAvailabilityLayerClient) SubmitBatch

SubmitBatch submits a batch to the DA layer.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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