@@ -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 )
0 commit comments