Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultEstimateGas(blobSize uint32) uint64
- func EstimateGas(blobSizes []uint32, gasPerByte uint32, txSizeCost uint64) uint64
- func GasToConsume(blobSizes []uint32, gasPerByte uint32) uint64
- func WithCNCClient(client CNCClientI) da.Option
- func WithRPCClient(rpcClient rpcclient.Client) da.Option
- func WithSubmitRetryDelay(delay time.Duration) da.Option
- func WithTxPollingAttempts(attempts int) da.Option
- func WithTxPollingRetryDelay(delay time.Duration) da.Option
- type CNCClientI
- type Config
- type DataAvailabilityLayerClient
- func (c *DataAvailabilityLayerClient) CheckBatchAvailability(dataLayerHeight uint64) da.ResultCheckBatch
- func (c *DataAvailabilityLayerClient) GetClientType() da.Client
- func (c *DataAvailabilityLayerClient) Init(config []byte, pubsubServer *pubsub.Server, kvStore store.KVStore, ...) error
- func (c *DataAvailabilityLayerClient) RetrieveBatches(dataLayerHeight uint64) da.ResultRetrieveBatch
- func (c *DataAvailabilityLayerClient) Start() error
- func (c *DataAvailabilityLayerClient) Stop() error
- func (c *DataAvailabilityLayerClient) SubmitBatch(batch *types.Batch) da.ResultSubmitBatch
Constants ¶
const ( // 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 ¶
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 ¶
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 ¶
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 ¶
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 WithRPCClient ¶
WithRPCClient sets rpc client.
func WithSubmitRetryDelay ¶
WithSubmitRetryDelay sets submit retry delay.
func WithTxPollingAttempts ¶
WithTxPollingAttempts sets tx polling retry delay.
Types ¶
type CNCClientI ¶
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 ¶
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 ¶
func (c *DataAvailabilityLayerClient) Start() error
Start prepares DataAvailabilityLayerClient to work.
func (*DataAvailabilityLayerClient) Stop ¶
func (c *DataAvailabilityLayerClient) Stop() error
Stop stops DataAvailabilityLayerClient.
func (*DataAvailabilityLayerClient) SubmitBatch ¶
func (c *DataAvailabilityLayerClient) SubmitBatch(batch *types.Batch) da.ResultSubmitBatch
SubmitBatch submits a batch to the DA layer.