Skip to content

Commit 26e6f16

Browse files
authored
upgrade: celestia pkgs and light client ver (#21)
* upgrade: celestia pkgs and light client ver * chore: remove logs
1 parent d21d3b7 commit 26e6f16

File tree

5 files changed

+226
-230
lines changed

5 files changed

+226
-230
lines changed

celestia/client.go

+16-24
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@ import (
66
"errors"
77
"fmt"
88
"log"
9-
"math"
109

11-
"github.com/celestiaorg/celestia-app/pkg/appconsts"
12-
"github.com/celestiaorg/celestia-app/pkg/square"
13-
"github.com/celestiaorg/celestia-app/x/blob/types"
10+
"github.com/celestiaorg/celestia-app/v2/pkg/appconsts"
1411
rpc "github.com/celestiaorg/celestia-node/api/rpc/client"
1512
"github.com/celestiaorg/celestia-node/blob"
1613
"github.com/celestiaorg/celestia-node/share"
17-
sdktypes "github.com/cosmos/cosmos-sdk/types"
18-
auth "github.com/cosmos/cosmos-sdk/x/auth/types"
14+
"github.com/celestiaorg/celestia-node/state"
15+
square "github.com/celestiaorg/go-square/v2"
1916
"github.com/tendermint/tendermint/rpc/client/http"
2017

2118
"github.com/stackrlabs/go-daash/da"
@@ -86,11 +83,8 @@ func (c *Client) Commit(ctx context.Context, daBlob da.Blob) (da.Commitment, err
8683
if err != nil {
8784
return nil, err
8885
}
89-
commitment, err := types.CreateCommitment(&blob.Blob)
90-
if err != nil {
91-
return nil, err
92-
}
93-
return commitment, err
86+
87+
return blob.Commitment, nil
9488
}
9589

9690
// Submit submits the Blobs to Data Availability layer.
@@ -99,21 +93,17 @@ func (c *Client) Submit(ctx context.Context, daBlob da.Blob, gasPrice float64) (
9993
if err != nil {
10094
return nil, err
10195
}
102-
options := blob.DefaultSubmitOptions()
103-
// if gas price was configured globally use that as the default
104-
if c.gasPrice >= 0 && gasPrice < 0 {
105-
gasPrice = c.gasPrice
106-
}
107-
if gasPrice >= 0 {
108-
options.GasLimit = types.EstimateGas([]uint32{uint32(len(b.Data))}, appconsts.DefaultGasPerBlobByte, auth.DefaultTxSizeCostPerByte)
109-
options.Fee = sdktypes.NewInt(int64(math.Ceil(gasPrice * float64(options.GasLimit)))).Int64()
110-
}
111-
txResp, err := c.lightClient.State.SubmitPayForBlob(ctx, sdktypes.NewInt(int64(options.Fee)), options.GasLimit, []*blob.Blob{b})
96+
opts := state.NewTxConfig(state.WithGasPrice(gasPrice))
97+
err = b.Namespace().ValidateForBlob()
11298
if err != nil {
11399
return nil, err
114100
}
101+
txResp, err := c.lightClient.State.SubmitPayForBlob(ctx, []*state.Blob{b.Blob}, opts)
102+
if err != nil {
103+
return nil, errors.Join(err, fmt.Errorf("failed to submit blobs"))
104+
}
115105

116-
log.Println("successfully submitted blobs", "height", txResp.Height, "gas", options.GasLimit, "fee", options.Fee)
106+
log.Println("successfully submitted blobs", "height", txResp.Height, "gas", txResp.GasUsed)
117107

118108
commitment, err := c.Commit(ctx, daBlob)
119109
if err != nil {
@@ -181,8 +171,10 @@ func (c *Client) getSharePointer(ctx context.Context, txHash string) (SharePoint
181171
if err != nil {
182172
return SharePointer{}, fmt.Errorf("failed to get block: %w", err)
183173
}
184-
185-
shareRange, err := square.BlobShareRange(blockRes.Block.Data.Txs.ToSliceOfBytes(), int(tx.Index), 0, blockRes.Block.Header.Version.App)
174+
version := blockRes.Block.Header.Version.App
175+
maxSquareSize := appconsts.SquareSizeUpperBound(version)
176+
subtreeRootThreshold := appconsts.SubtreeRootThreshold(version)
177+
shareRange, err := square.BlobShareRange(blockRes.Block.Txs.ToSliceOfBytes(), int(tx.Index), 0, maxSquareSize, subtreeRootThreshold)
186178
// shareRange, err := square.TxShareRange(blockRes.Block.Data.Txs.ToSliceOfBytes(), int(tx.Index), blockRes.Block.Header.Version.App)
187179
if err != nil {
188180
return SharePointer{}, fmt.Errorf("failed to get share range: %w", err)

celestia/types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type ID struct {
1111

1212
type Proof = blob.Proof
1313

14-
type Commitment = []byte
14+
type Commitment = blob.Commitment
1515

1616
type SharePointer struct {
1717
Height int64

docker-compose.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@ version: "3.8"
22

33
services:
44
celestia-light-client-init:
5-
image: ghcr.io/celestiaorg/celestia-node:v0.14.0
6-
user: "10001:10001"
5+
image: ghcr.io/celestiaorg/celestia-node:v0.16.0-rc0
76
environment:
87
NODE_TYPE: ${NODE_TYPE} # Ensure these environment variables are set in your shell or a .env file
98
P2P_NETWORK: ${NETWORK}
109
volumes:
1110
- ${NODE_STORE_DIR}:/home/celestia
12-
command: celestia ${NODE_TYPE} init --p2p.network ${NETWORK}
11+
command: celestia ${NODE_TYPE} init --p2p.network ${NETWORK} --experimental-pruning
1312
restart: on-failure
1413

1514
celestia-light-client:
16-
image: ghcr.io/celestiaorg/celestia-node:v0.14.0
17-
user: "10001:10001"
15+
image: ghcr.io/celestiaorg/celestia-node:v0.16.0-rc0
1816
networks: [go-daash]
1917
environment:
2018
NODE_TYPE: ${NODE_TYPE}

0 commit comments

Comments
 (0)