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 WithRPCAttempts(attempts int) da.Option
- func WithRPCClient(rpc celtypes.CelestiaRPCClient) da.Option
- func WithRPCRetryDelay(delay time.Duration) da.Option
- func WithSubmitBackoff(c uretry.BackoffConfig) da.Option
- type Config
- type DataAvailabilityLayerClient
- func (c *DataAvailabilityLayerClient) CheckBatchAvailability(daMetaData *da.DASubmitMetaData) 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(daMetaData *da.DASubmitMetaData) da.ResultRetrieveBatch
- func (c *DataAvailabilityLayerClient) Start() (err error)
- func (c *DataAvailabilityLayerClient) Stop() error
- func (c *DataAvailabilityLayerClient) SubmitBatch(batch *types.Batch) da.ResultSubmitBatch
- type OpenRPC
- func (c *OpenRPC) Get(ctx context.Context, height uint64, namespace share.Namespace, ...) (*blob.Blob, error)
- func (c *OpenRPC) GetAll(ctx context.Context, height uint64, namespaces []share.Namespace) ([]*blob.Blob, error)
- func (c *OpenRPC) GetHeaders(ctx context.Context, height uint64) (*header.ExtendedHeader, error)
- func (c *OpenRPC) GetProof(ctx context.Context, height uint64, namespace share.Namespace, ...) (*blob.Proof, error)
- func (c *OpenRPC) Included(ctx context.Context, height uint64, namespace share.Namespace, ...) (bool, error)
- func (c *OpenRPC) Submit(ctx context.Context, blobs []*blob.Blob, options *openrpc.SubmitOptions) (uint64, error)
- func (c *OpenRPC) SubmitPayForBlob(ctx context.Context, fee state.Int, gasLim uint64, blobs []*blob.Blob) (*state.TxResponse, error)
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:26658", AppNodeURL: "", Timeout: 5 * time.Second, Fee: 0, GasLimit: 20000000, GasPrices: defaultGasPrices, GasAdjustment: defaultGasAdjustment, NamespaceIDStr: "", NamespaceID: openrpcns.Namespace{Version: namespaceVersion, ID: []byte{0, 0, 0, 0, 0, 0, 0, 0, 255, 255}}, }
Functions ¶
func DefaultEstimateGas ¶ added in v1.1.0
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 ¶ added in v1.1.0
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 ¶ added in v1.1.0
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 WithRPCAttempts ¶ added in v1.1.0
WithRPCAttempts sets failed rpc calls retry attempts.
func WithRPCClient ¶ added in v1.1.0
func WithRPCClient(rpc celtypes.CelestiaRPCClient) da.Option
WithRPCClient sets rpc client.
func WithRPCRetryDelay ¶ added in v1.1.0
WithRPCRetryDelay sets failed rpc calls retry delay.
func WithSubmitBackoff ¶ added in v1.1.1
func WithSubmitBackoff(c uretry.BackoffConfig) da.Option
WithSubmitBackoff sets submit retry delay config.
Types ¶
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"` AuthToken string `json:"auth_token"` NamespaceID openrpcns.Namespace `json:"-"` }
Config stores Celestia DALC configuration parameters.
func (*Config) InitNamespaceID ¶ added in v1.1.0
type DataAvailabilityLayerClient ¶
type DataAvailabilityLayerClient struct {
// contains filtered or unexported fields
}
DataAvailabilityLayerClient use celestia-node public API.
func (*DataAvailabilityLayerClient) CheckBatchAvailability ¶
func (c *DataAvailabilityLayerClient) CheckBatchAvailability(daMetaData *da.DASubmitMetaData) da.ResultCheckBatch
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 types.Logger, options ...da.Option) error
Init initializes DataAvailabilityLayerClient instance.
func (*DataAvailabilityLayerClient) RetrieveBatches ¶
func (c *DataAvailabilityLayerClient) RetrieveBatches(daMetaData *da.DASubmitMetaData) da.ResultRetrieveBatch
func (*DataAvailabilityLayerClient) Start ¶
func (c *DataAvailabilityLayerClient) Start() (err 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.
type OpenRPC ¶ added in v1.1.0
type OpenRPC struct {
// contains filtered or unexported fields
}
OpenRPC is a wrapper around the openrpc client.
func NewOpenRPC ¶ added in v1.1.0
NewOpenRPC creates a new openrpc client.
func (*OpenRPC) Get ¶ added in v1.1.0
func (c *OpenRPC) Get(ctx context.Context, height uint64, namespace share.Namespace, commitment blob.Commitment) (*blob.Blob, error)
Get blob for a specific share commitment
func (*OpenRPC) GetAll ¶ added in v1.1.0
func (c *OpenRPC) GetAll(ctx context.Context, height uint64, namespaces []share.Namespace) ([]*blob.Blob, error)
GetAll gets all blobs.
func (*OpenRPC) GetHeaders ¶ added in v1.1.0
Get extended Celestia headers for a specific height
func (*OpenRPC) GetProof ¶ added in v1.1.0
func (c *OpenRPC) GetProof(ctx context.Context, height uint64, namespace share.Namespace, commitment blob.Commitment) (*blob.Proof, error)
Getting proof for submitted blob
func (*OpenRPC) Included ¶ added in v1.1.0
func (c *OpenRPC) Included(ctx context.Context, height uint64, namespace share.Namespace, proof *blob.Proof, commitment blob.Commitment) (bool, error)
Get extended Celestia headers for a specific height